aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/mozilla
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/mozilla
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/mozilla')
-rw-r--r--files/zh-cn/mozilla/accessibility/index.html13
-rw-r--r--files/zh-cn/mozilla/accessibility/software_accessibility_today/index.html133
-rw-r--r--files/zh-cn/mozilla/add-ons/add-on_guidelines/index.html9
-rw-r--r--files/zh-cn/mozilla/add-ons/amo/index.html11
-rw-r--r--files/zh-cn/mozilla/add-ons/amo/policy/contact/index.html28
-rw-r--r--files/zh-cn/mozilla/add-ons/amo/policy/index.html23
-rw-r--r--files/zh-cn/mozilla/add-ons/code_snippets/canvas/index.html237
-rw-r--r--files/zh-cn/mozilla/add-ons/code_snippets/index.html134
-rw-r--r--files/zh-cn/mozilla/add-ons/code_snippets/js_xpcom/index.html97
-rw-r--r--files/zh-cn/mozilla/add-ons/code_snippets/modules/index.html37
-rw-r--r--files/zh-cn/mozilla/add-ons/code_snippets/queryselector/index.html114
-rw-r--r--files/zh-cn/mozilla/add-ons/code_snippets/timers/index.html67
-rw-r--r--files/zh-cn/mozilla/add-ons/creating_custom_firefox_extensions_with_the_mozilla_build_system/index.html470
-rw-r--r--files/zh-cn/mozilla/add-ons/creating_opensearch_plugins_for_firefox/index.html159
-rw-r--r--files/zh-cn/mozilla/add-ons/creating_opensearch_plugins_for_firefox_clone/index.html175
-rw-r--r--files/zh-cn/mozilla/add-ons/extension_frequently_asked_questions_move/index.html35
-rw-r--r--files/zh-cn/mozilla/add-ons/extension_packaging/index.html38
-rw-r--r--files/zh-cn/mozilla/add-ons/index.html87
-rw-r--r--files/zh-cn/mozilla/add-ons/install_manifests/index.html363
-rw-r--r--files/zh-cn/mozilla/add-ons/legacy_add_ons/index.html19
-rw-r--r--files/zh-cn/mozilla/add-ons/overlay_extensions/index.html61
-rw-r--r--files/zh-cn/mozilla/add-ons/performance_best_practices_in_extensions/index.html91
-rw-r--r--files/zh-cn/mozilla/add-ons/plugins/index.html116
-rw-r--r--files/zh-cn/mozilla/add-ons/plugins/reference/index.html16
-rw-r--r--files/zh-cn/mozilla/add-ons/plugins/samples_and_test_cases/index.html21
-rw-r--r--files/zh-cn/mozilla/add-ons/plugins/shipping_a_plugin_as_a_toolkit_bundle/index.html56
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/builder/index.html13
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/guides/content_scripts/index.html486
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/guides/index.html115
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/guides/multiprocess_firefox_and_the_sdk/index.html212
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/guides/working_with_events/index.html122
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/high-level_apis/base64/index.html65
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/high-level_apis/clipboard/index.html101
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/high-level_apis/index.html12
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/high-level_apis/notifications/index.html129
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/high-level_apis/panel/index.html899
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/high-level_apis/tabs/index.html669
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/high-level_apis/url/index.html191
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/high-level_apis/widget/index.html839
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/index.html104
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/low-level_apis/index.html26
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/low-level_apis/test_assert/index.html283
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/low-level_apis/ui_button_action/index.html526
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tools/index.html14
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tools/jpm/index.html652
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tools/package_json/index.html312
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/add_a_menu_item_to_firefox/index.html92
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/adding_a_button_to_the_toolbar/index.html83
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/annotator/implementing_the_widget/index.html92
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/annotator/index.html36
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/annotator/overview/index.html54
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/display_a_popup/index.html135
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/getting_started/index.html172
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/getting_started_(jpm)/index.html162
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/index.html144
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/installation/index.html135
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/l10n/index.html381
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/list_open_tabs/index.html72
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/listen_for_page_load/index.html42
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/modifying_the_page_hosted_by_a_tab/index.html109
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/modifying_web_pages_based_on_url/index.html210
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/open_a_web_page/index.html52
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/troubleshooting/index.html39
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/unit_testing/index.html102
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/日志/index.html62
-rw-r--r--files/zh-cn/mozilla/add-ons/sdk/tutorials/添加一个菜单项/index.html49
-rw-r--r--files/zh-cn/mozilla/add-ons/setting_up_extension_development_environment/index.html58
-rw-r--r--files/zh-cn/mozilla/add-ons/submitting_an_add-on_to_amo/index.html24
-rw-r--r--files/zh-cn/mozilla/add-ons/themes/index.html65
-rw-r--r--files/zh-cn/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/index.html28
-rw-r--r--files/zh-cn/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/uuid/index.html6
-rw-r--r--files/zh-cn/mozilla/add-ons/themes/obsolete/index.html10
-rw-r--r--files/zh-cn/mozilla/add-ons/themes/obsolete/theme_changes_in_firefox_3/index.html92
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/add_a_button_to_the_toolbar/index.html220
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/anatomy_of_a_webextension/index.html148
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/alarms/create/index.html127
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/alarms/index.html58
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/bookmarks/bookmarktreenode/index.html81
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/bookmarks/gettree/index.html120
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/bookmarks/index.html128
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/bookmarks/remove/index.html106
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/browseraction/index.html116
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/captiveportal/index.html90
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/captiveportal/onstatechanged/index.html94
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/contentscripts/index.html41
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/contextmenus/index.html191
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/cookies/cookie/index.html121
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/cookies/index.html151
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/devtools.inspectedwindow/index.html72
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/downloads/download/index.html144
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/downloads/downloaditem/index.html101
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/downloads/index.html134
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/find/index.html25
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/history/index.html134
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/history/ontitlechanged/index.html111
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/i18n/index.html85
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/idle/index.html97
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/index.html50
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/permissions/contains/index.html94
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/permissions/index.html93
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/proxy/index.html65
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/runtime/connectnative/index.html114
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/runtime/getmanifest/index.html79
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/runtime/index.html181
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/runtime/onconnect/index.html228
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/runtime/onmessage/index.html307
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/runtime/openoptionspage/index.html92
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/runtime/platformarch/index.html70
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/runtime/platformos/index.html76
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/runtime/sendmessage/index.html157
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/runtime/sendnativemessage/index.html109
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/search/index.html34
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/search/search/index.html93
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/sessions/index.html136
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/sessions/session/index.html78
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/storage/index.html103
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/tabs/create/index.html137
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/tabs/discard/index.html108
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/tabs/executescript/index.html173
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/tabs/index.html192
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/tabs/insertcss/index.html129
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/tabs/onactivated/index.html110
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/tabs/sendmessage/index.html129
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/tabs/tab/index.html117
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/tabs/查询/index.html179
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/types/browsersetting/index.html85
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/types/browsersetting/set/index.html118
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/types/index.html66
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/webnavigation/index.html155
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/webnavigation/ondomcontentloaded/index.html137
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/webrequest/index.html186
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/webrequest/requestfilter/index.html71
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/windows/create/index.html169
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/windows/index.html116
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/windows/windowstate/index.html66
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/windows/windowtype/index.html65
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/剪切板/index.html36
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/剪切板/setimagedata/index.html79
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/browser_support_for_javascript_apis/index.html17
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/chrome_incompatibilities/index.html154
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/content_scripts/index.html575
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/content_security_policy/index.html107
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/embedded_webextensions/index.html205
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/examples/index.html31
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/extending_the_developer_tools/index.html164
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/index.html122
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/interact_with_the_clipboard/index.html157
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/intercept_http_requests/index.html158
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/internationalization/index.html394
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/manifest.json/author/index.html40
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/manifest.json/background/index.html88
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/manifest.json/browser_action/index.html209
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/manifest.json/browser_specific_settings/index.html66
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/manifest.json/content_scripts/index.html216
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/manifest.json/default_locale/index.html42
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/manifest.json/description/index.html43
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/manifest.json/developer/index.html48
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/manifest.json/index.html140
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/manifest.json/manifest_version/index.html45
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/manifest.json/name/index.html43
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/manifest.json/permissions/index.html182
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/manifest.json/short_name/index.html43
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/manifest.json/version/index.html49
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/manifest.json/web_accessible_resources/index.html96
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/manifest.json/主页地址/index.html42
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/match_patterns/index.html384
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/modify_a_web_page/index.html239
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/native_manifests/index.html344
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/native_messaging/index.html326
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/packaging_and_installation/index.html82
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/porting_from_google_chrome/index.html22
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/prerequisites/index.html21
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/publishing_your_webextension/index.html98
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/safely_inserting_external_content_into_a_page/index.html102
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/user_interface/browser_action/index.html50
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/user_interface/browser_styles/index.html466
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/user_interface/context_menu_items/index.html48
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/user_interface/devtools_panels/index.html61
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/user_interface/index.html92
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/user_interface/page_actions/index.html93
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/user_interface/侧边栏/index.html53
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/walkthrough/index.html488
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/what_are_webextensions/index.html61
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/what_next_/index.html58
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/working_with_the_tabs_api/index.html634
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/your_first_webextension/index.html238
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/实现一个设置页面/index.html203
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/构建一个跨浏览器的扩展插件/index.html275
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/用户界面元素/index.html162
-rw-r--r--files/zh-cn/mozilla/add-ons/working_with_multiprocess_firefox/index.html296
-rw-r--r--files/zh-cn/mozilla/add-ons/雷鸟/index.html131
-rw-r--r--files/zh-cn/mozilla/adding_a_new_event/index.html186
-rw-r--r--files/zh-cn/mozilla/bugzilla/index.html58
-rw-r--r--files/zh-cn/mozilla/bugzilla/testopia/index.html134
-rw-r--r--files/zh-cn/mozilla/chrome_registration/index.html229
-rw-r--r--files/zh-cn/mozilla/command_line_options/index.html407
-rw-r--r--files/zh-cn/mozilla/connect/index.html122
-rw-r--r--files/zh-cn/mozilla/debugging/existing_tools/index.html36
-rw-r--r--files/zh-cn/mozilla/debugging/index.html139
-rw-r--r--files/zh-cn/mozilla/developer_guide/adding_apis_to_the_navigator_object/index.html34
-rw-r--r--files/zh-cn/mozilla/developer_guide/customizing_firefox/index.html9
-rw-r--r--files/zh-cn/mozilla/developer_guide/index.html106
-rw-r--r--files/zh-cn/mozilla/developer_guide/source_code/cvs/index.html192
-rw-r--r--files/zh-cn/mozilla/developer_guide/source_code/index.html48
-rw-r--r--files/zh-cn/mozilla/developer_guide/source_code/latestpassingsource/index.html22
-rw-r--r--files/zh-cn/mozilla/firefox/australis_add-on_compat/index.html130
-rw-r--r--files/zh-cn/mozilla/firefox/developer_edition/index.html57
-rw-r--r--files/zh-cn/mozilla/firefox/enterprise_deployment/index.html138
-rw-r--r--files/zh-cn/mozilla/firefox/experimental_features/index.html623
-rw-r--r--files/zh-cn/mozilla/firefox/headless_mode/index.html270
-rw-r--r--files/zh-cn/mozilla/firefox/index.html74
-rw-r--r--files/zh-cn/mozilla/firefox/multiprocess_firefox/cross_process_object_wrappers/index.html114
-rw-r--r--files/zh-cn/mozilla/firefox/multiprocess_firefox/debugging_frame_scripts/index.html53
-rw-r--r--files/zh-cn/mozilla/firefox/multiprocess_firefox/faq/index.html18
-rw-r--r--files/zh-cn/mozilla/firefox/multiprocess_firefox/index.html78
-rw-r--r--files/zh-cn/mozilla/firefox/multiprocess_firefox/limitations_of_chrome_scripts/index.html197
-rw-r--r--files/zh-cn/mozilla/firefox/multiprocess_firefox/limitations_of_frame_scripts/index.html101
-rw-r--r--files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/communicating_with_frame_scripts/index.html205
-rw-r--r--files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/frame_script_environment/index.html104
-rw-r--r--files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/frame_script_loading_and_lifetime/index.html124
-rw-r--r--files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/index.html68
-rw-r--r--files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/message_manager_overview/index.html442
-rw-r--r--files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/performance/index.html292
-rw-r--r--files/zh-cn/mozilla/firefox/multiprocess_firefox/motivation/index.html44
-rw-r--r--files/zh-cn/mozilla/firefox/multiprocess_firefox/tab_selection_in_multiprocess_firefox/index.html21
-rw-r--r--files/zh-cn/mozilla/firefox/multiprocess_firefox/technical_overview/index.html164
-rw-r--r--files/zh-cn/mozilla/firefox/multiprocess_firefox/which_uris_load_where/index.html53
-rw-r--r--files/zh-cn/mozilla/firefox/privacy/index.html22
-rw-r--r--files/zh-cn/mozilla/firefox/privacy/storage_access_policy/errors/index.html24
-rw-r--r--files/zh-cn/mozilla/firefox/privacy/storage_access_policy/errors/禁用外部cookie/index.html39
-rw-r--r--files/zh-cn/mozilla/firefox/privacy/storage_access_policy/index.html261
-rw-r--r--files/zh-cn/mozilla/firefox/privacy/tracking_protection/index.html87
-rw-r--r--files/zh-cn/mozilla/firefox/releases/1.5/index.html123
-rw-r--r--files/zh-cn/mozilla/firefox/releases/1.5/using_firefox_1.5_caching/index.html184
-rw-r--r--files/zh-cn/mozilla/firefox/releases/12/index.html165
-rw-r--r--files/zh-cn/mozilla/firefox/releases/14/index.html98
-rw-r--r--files/zh-cn/mozilla/firefox/releases/15/index.html122
-rw-r--r--files/zh-cn/mozilla/firefox/releases/16/index.html114
-rw-r--r--files/zh-cn/mozilla/firefox/releases/17/index.html146
-rw-r--r--files/zh-cn/mozilla/firefox/releases/18/index.html82
-rw-r--r--files/zh-cn/mozilla/firefox/releases/19/index.html76
-rw-r--r--files/zh-cn/mozilla/firefox/releases/20/index.html47
-rw-r--r--files/zh-cn/mozilla/firefox/releases/21/index.html107
-rw-r--r--files/zh-cn/mozilla/firefox/releases/22/index.html89
-rw-r--r--files/zh-cn/mozilla/firefox/releases/23/index.html94
-rw-r--r--files/zh-cn/mozilla/firefox/releases/24/index.html22
-rw-r--r--files/zh-cn/mozilla/firefox/releases/25/index.html50
-rw-r--r--files/zh-cn/mozilla/firefox/releases/25/site_compatibility/index.html40
-rw-r--r--files/zh-cn/mozilla/firefox/releases/26/index.html41
-rw-r--r--files/zh-cn/mozilla/firefox/releases/26/site_compatibility/index.html104
-rw-r--r--files/zh-cn/mozilla/firefox/releases/27/index.html45
-rw-r--r--files/zh-cn/mozilla/firefox/releases/28/index.html117
-rw-r--r--files/zh-cn/mozilla/firefox/releases/28/site_compatibility/index.html56
-rw-r--r--files/zh-cn/mozilla/firefox/releases/3.6/index.html305
-rw-r--r--files/zh-cn/mozilla/firefox/releases/3/index.html310
-rw-r--r--files/zh-cn/mozilla/firefox/releases/3/site_compatibility/index.html26
-rw-r--r--files/zh-cn/mozilla/firefox/releases/31/index.html46
-rw-r--r--files/zh-cn/mozilla/firefox/releases/32/index.html154
-rw-r--r--files/zh-cn/mozilla/firefox/releases/33/index.html38
-rw-r--r--files/zh-cn/mozilla/firefox/releases/35/index.html213
-rw-r--r--files/zh-cn/mozilla/firefox/releases/41/index.html209
-rw-r--r--files/zh-cn/mozilla/firefox/releases/43/index.html173
-rw-r--r--files/zh-cn/mozilla/firefox/releases/44/index.html222
-rw-r--r--files/zh-cn/mozilla/firefox/releases/45/index.html187
-rw-r--r--files/zh-cn/mozilla/firefox/releases/49/index.html348
-rw-r--r--files/zh-cn/mozilla/firefox/releases/56/index.html129
-rw-r--r--files/zh-cn/mozilla/firefox/releases/59/index.html130
-rw-r--r--files/zh-cn/mozilla/firefox/releases/62/index.html187
-rw-r--r--files/zh-cn/mozilla/firefox/releases/65/index.html128
-rw-r--r--files/zh-cn/mozilla/firefox/releases/68/index.html240
-rw-r--r--files/zh-cn/mozilla/firefox/releases/69/index.html185
-rw-r--r--files/zh-cn/mozilla/firefox/releases/78/index.html116
-rw-r--r--files/zh-cn/mozilla/firefox/releases/index.html12
-rw-r--r--files/zh-cn/mozilla/firefox/the_about_protocol/index.html163
-rw-r--r--files/zh-cn/mozilla/firefox_for_android/index.html65
-rw-r--r--files/zh-cn/mozilla/gecko/index.html74
-rw-r--r--files/zh-cn/mozilla/gecko/versions/index.html130
-rw-r--r--files/zh-cn/mozilla/gecko/嵌入mozilla/index.html49
-rw-r--r--files/zh-cn/mozilla/how_mozilla_determines_mime_types/index.html94
-rw-r--r--files/zh-cn/mozilla/how_to_get_a_process_dump_with_windows_task_manager/index.html48
-rw-r--r--files/zh-cn/mozilla/implementing_pontoon_in_a_mozilla_website/index.html76
-rw-r--r--files/zh-cn/mozilla/index.html8
-rw-r--r--files/zh-cn/mozilla/instantbird/index.html62
-rw-r--r--files/zh-cn/mozilla/introduction_to_layout_in_mozilla/index.html360
-rw-r--r--files/zh-cn/mozilla/ipdl/creating_a_new_protocol/index.html32
-rw-r--r--files/zh-cn/mozilla/ipdl/index.html33
-rw-r--r--files/zh-cn/mozilla/ipdl/入门/index.html670
-rw-r--r--files/zh-cn/mozilla/javascript-dom_prototypes_in_mozilla/index.html145
-rw-r--r--files/zh-cn/mozilla/javascript_code_modules/assert.jsm/index.html448
-rw-r--r--files/zh-cn/mozilla/javascript_code_modules/dict.jsm/index.html344
-rw-r--r--files/zh-cn/mozilla/javascript_code_modules/downloads.jsm/download/index.html335
-rw-r--r--files/zh-cn/mozilla/javascript_code_modules/downloads.jsm/index.html306
-rw-r--r--files/zh-cn/mozilla/javascript_code_modules/geometry.jsm/index.html19
-rw-r--r--files/zh-cn/mozilla/javascript_code_modules/geometry.jsm/services.jsm/index.html25
-rw-r--r--files/zh-cn/mozilla/javascript_code_modules/http.jsm/index.html74
-rw-r--r--files/zh-cn/mozilla/javascript_code_modules/index.html84
-rw-r--r--files/zh-cn/mozilla/javascript_code_modules/promise.jsm/deferred/index.html190
-rw-r--r--files/zh-cn/mozilla/javascript_code_modules/promise.jsm/index.html172
-rw-r--r--files/zh-cn/mozilla/javascript_code_modules/promise.jsm/promise/index.html226
-rw-r--r--files/zh-cn/mozilla/javascript_code_modules/timer.jsm/index.html33
-rw-r--r--files/zh-cn/mozilla/javascript_code_modules/using/index.html194
-rw-r--r--files/zh-cn/mozilla/javascript_tips/index.html112
-rw-r--r--files/zh-cn/mozilla/js-ctypes/index.html53
-rw-r--r--files/zh-cn/mozilla/js-ctypes/js-ctypes_reference/ctypes/index.html534
-rw-r--r--files/zh-cn/mozilla/js-ctypes/js-ctypes_reference/index.html96
-rw-r--r--files/zh-cn/mozilla/js-ctypes/using_js-ctypes/declaring_and_using_callbacks/index.html100
-rw-r--r--files/zh-cn/mozilla/js-ctypes/using_js-ctypes/index.html210
-rw-r--r--files/zh-cn/mozilla/js-ctypes/using_js-ctypes/memory_management/index.html88
-rw-r--r--files/zh-cn/mozilla/js-ctypes/using_js-ctypes/working_with_arraybuffers/index.html212
-rw-r--r--files/zh-cn/mozilla/localization/faq/index.html17
-rw-r--r--files/zh-cn/mozilla/localization/index.html20
-rw-r--r--files/zh-cn/mozilla/localization/l10n_style_guide/index.html482
-rw-r--r--files/zh-cn/mozilla/localization/localizing_extension_descriptions/index.html60
-rw-r--r--files/zh-cn/mozilla/mercurial/basics/index.html56
-rw-r--r--files/zh-cn/mozilla/mercurial/index.html43
-rw-r--r--files/zh-cn/mozilla/mercurial/installing_mercurial/index.html145
-rw-r--r--files/zh-cn/mozilla/mfbt/index.html48
-rw-r--r--files/zh-cn/mozilla/mozilla_on_github/index.html121
-rw-r--r--files/zh-cn/mozilla/mozilla_persona/index.html155
-rw-r--r--files/zh-cn/mozilla/participating_in_the_mozilla_project/index.html94
-rw-r--r--files/zh-cn/mozilla/performance/about_colon_memory/index.html144
-rw-r--r--files/zh-cn/mozilla/performance/index.html138
-rw-r--r--files/zh-cn/mozilla/performance/scroll-linked_effects/index.html121
-rw-r--r--files/zh-cn/mozilla/persona/bootstrapping_persona/index.html29
-rw-r--r--files/zh-cn/mozilla/persona/branding/index.html79
-rw-r--r--files/zh-cn/mozilla/persona/browser_compatibility/index.html89
-rw-r--r--files/zh-cn/mozilla/persona/glossary/index.html61
-rw-r--r--files/zh-cn/mozilla/persona/index.html138
-rw-r--r--files/zh-cn/mozilla/persona/protocol_overview/index.html96
-rw-r--r--files/zh-cn/mozilla/persona/quick_setup/index.html140
-rw-r--r--files/zh-cn/mozilla/persona/remote_verification_api/index.html120
-rw-r--r--files/zh-cn/mozilla/persona/security_considerations/index.html55
-rw-r--r--files/zh-cn/mozilla/persona/why_persona/index.html30
-rw-r--r--files/zh-cn/mozilla/preferences/index.html6
-rw-r--r--files/zh-cn/mozilla/preferences/mozilla_networking_preferences/index.html536
-rw-r--r--files/zh-cn/mozilla/preferences/preference_reference/browser.altclicksave/index.html12
-rw-r--r--files/zh-cn/mozilla/preferences/preference_reference/browser.download.lastdir.savepersite/index.html31
-rw-r--r--files/zh-cn/mozilla/preferences/preference_reference/browser.search.context.loadinbackground/index.html14
-rw-r--r--files/zh-cn/mozilla/preferences/preference_reference/browser.urlbar.trimurls/index.html12
-rw-r--r--files/zh-cn/mozilla/preferences/preference_reference/dom.event.clipboardevents.enabled/index.html12
-rw-r--r--files/zh-cn/mozilla/preferences/preference_reference/index.html8
-rw-r--r--files/zh-cn/mozilla/preferences/preference_reference/javascript.options.strict/index.html13
-rw-r--r--files/zh-cn/mozilla/preferences/preference_reference/ui.alertnotificationorigin/index.html12
-rw-r--r--files/zh-cn/mozilla/preferences/preference_reference/ui.spellcheckerunderline/index.html12
-rw-r--r--files/zh-cn/mozilla/preferences/preference_reference/ui.spellcheckerunderlinestyle/index.html13
-rw-r--r--files/zh-cn/mozilla/preferences/preference_reference/ui.tooltipdelay/index.html13
-rw-r--r--files/zh-cn/mozilla/preferences/preference_reference/view_source.syntax_highlight/index.html6
-rw-r--r--files/zh-cn/mozilla/projects/crash_reporting/index.html47
-rw-r--r--files/zh-cn/mozilla/projects/emscripten/index.html37
-rw-r--r--files/zh-cn/mozilla/projects/index.html14
-rw-r--r--files/zh-cn/mozilla/projects/l20n/index.html127
-rw-r--r--files/zh-cn/mozilla/projects/nspr/index.html60
-rw-r--r--files/zh-cn/mozilla/projects/nspr/reference/index.html770
-rw-r--r--files/zh-cn/mozilla/projects/nspr/reference/memory_management_operations/index.html424
-rw-r--r--files/zh-cn/mozilla/projects/psm/index.html15
-rw-r--r--files/zh-cn/mozilla/projects/rhino/bsf/index.html10
-rw-r--r--files/zh-cn/mozilla/projects/rhino/community/index.html24
-rw-r--r--files/zh-cn/mozilla/projects/rhino/debugger/index.html220
-rw-r--r--files/zh-cn/mozilla/projects/rhino/documentation/index.html81
-rw-r--r--files/zh-cn/mozilla/projects/rhino/download_rhino/index.html106
-rw-r--r--files/zh-cn/mozilla/projects/rhino/embedding_tutorial/index.html221
-rw-r--r--files/zh-cn/mozilla/projects/rhino/examples/index.html35
-rw-r--r--files/zh-cn/mozilla/projects/rhino/index.html22
-rw-r--r--files/zh-cn/mozilla/projects/rhino/license/index.html47
-rw-r--r--files/zh-cn/mozilla/projects/rhino/overview/index.html78
-rw-r--r--files/zh-cn/mozilla/projects/rhino/requirements_and_limitations/index.html24
-rw-r--r--files/zh-cn/mozilla/projects/rhino/scripting_java/index.html397
-rw-r--r--files/zh-cn/mozilla/projects/rhino/shell/index.html179
-rw-r--r--files/zh-cn/mozilla/projects/social_api/index.html97
-rw-r--r--files/zh-cn/mozilla/projects/social_api/share/index.html86
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/build_documentation/index.html294
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/comparision_of_js_engines/index.html105
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/index.html132
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/internals/bytecodes/index.html30
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/internals/functions/index.html73
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/internals/index.html292
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/introduction_to_the_javascript_shell/index.html382
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/javascript-c引擎嵌入开发指南/index.html11
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/boolean_to_jsval/index.html53
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/index.html646
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_defineconstdoubles/index.html59
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_doublecolon_call/index.html92
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_doublecolon_ordinarytoprimitive/index.html66
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_evaluatescript/index.html69
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_getversion/index.html29
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_hasownproperty/index.html73
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_newruntime/index.html33
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_seterrorreporter/index.html61
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_valuetostring/index.html45
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jsclass/index.html137
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jsconstdoublespec/index.html56
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jserrorreport/index.html6
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jsproperty/index.html29
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jspropertydescriptor/index.html69
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jsruntime/index.html29
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/parser_api/index.html1625
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/releases/index.html42
-rw-r--r--files/zh-cn/mozilla/projects/spidermonkey/split_object/index.html72
-rw-r--r--files/zh-cn/mozilla/rust/index.html40
-rw-r--r--files/zh-cn/mozilla/tech/index.html7
-rw-r--r--files/zh-cn/mozilla/tech/toolkit_api/extisessionstorage/index.html48
-rw-r--r--files/zh-cn/mozilla/tech/toolkit_api/index.html18
-rw-r--r--files/zh-cn/mozilla/tech/viewing_and_searching_mozilla_source_code_online/index.html26
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/glue/index.html71
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/arrays/index.html573
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/creating_components/an_overview_of_xpcom/index.html535
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/creating_components/building_the_weblock_ui/index.html297
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/creating_components/component_internals/index.html217
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/creating_components/creating_the_component_code/index.html727
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/creating_components/finishing_the_component/index.html337
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/creating_components/index.html278
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/creating_components/packaging_weblock/index.html136
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/creating_components/preface/index.html83
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/creating_components/resources/index.html10
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/creating_components/setting_up_the_gecko_sdk/index.html204
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/creating_components/starting_weblock/index.html1104
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/creating_components/using_xpcom_components/index.html311
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/creating_components/using_xpcom_utilities_to_make_things_easier/index.html388
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/hashtables/index.html282
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/index.html15
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/guide/internal_strings/index.html809
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/index.html44
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/interfacing_with_the_xpcom_cycle_collector/index.html141
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/language_bindings/components.utils.cloneinto/index.html290
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/language_bindings/components.utils.getglobalforobject/index.html41
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/language_bindings/index.html20
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/language_bindings/javaxpcom/index.html49
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/language_bindings/javaxpcom/使用javaxpcom在java应用程序中嵌入mozilla/index.html65
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/language_bindings/javaxpcom/开发/index.html26
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/language_bindings/pyxpcom/index.html67
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/language_bindings/xpconnect/index.html67
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/observer_notifications/index.html880
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/glue_classes/index.html16
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/glue_classes/nscomptr/getting_started_guide/index.html478
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/glue_classes/nscomptr/index.html56
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/index.html14
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/index.html11
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiaccessibleprovider/index.html45
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiclipboard/index.html91
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiclipboardhelper/index.html65
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiconsoleservice/index.html215
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsidirectoryserviceprovider/index.html65
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsidomclientrect/index.html92
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsifile/index.html828
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsifilepicker/index.html376
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsihttpchannel/index.html365
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiidleservice/index.html119
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsilocalfile/index.html478
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiprocess/index.html283
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiprompt/index.html55
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsipromptservice/index.html696
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiscriptableunicodeconverter/index.html609
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsisyncmessagesender/index.html65
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsitimer/index.html285
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsitraceablechannel/index.html71
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiuri/index.html407
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/reference/interface/nsixmlhttprequest/index.html90
-rw-r--r--files/zh-cn/mozilla/tech/xpcom/setting_http_request_headers/index.html261
-rw-r--r--files/zh-cn/mozilla/tech/xpidl/index.html502
-rw-r--r--files/zh-cn/mozilla/tech/xpidl/syntax/index.html127
-rw-r--r--files/zh-cn/mozilla/tech/xpidl/xpidl/index.html58
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/acceltext/index.html23
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/accesskey/index.html43
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/activetitlebarcolor/index.html19
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/align/index.html54
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/allowevents/index.html30
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/allownegativeassertions/index.html18
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/autocheck/index.html24
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/autoscroll/index.html12
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/buttonaccesskeyaccept/index.html20
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/buttonlabelextra1/index.html19
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/buttonlabelextra2/index.html19
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/buttons/index.html28
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/checked/index.html24
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/class/index.html23
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/coalesceduplicatearcs/index.html17
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/collapsed/index.html27
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/command/index.html30
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/container/index.html18
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/control/index.html23
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/crop/index.html37
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/description/index.html23
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/dir/index.html39
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/disabled/index.html38
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/flex/index.html23
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/href/index.html24
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/id/index.html41
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/image.onload/index.html12
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/image/index.html25
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/increment/index.html15
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/index.html304
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/label/index.html41
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/max/index.html20
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/menuitem.key/index.html23
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/menuitem.name/index.html38
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/menuitem.type/index.html28
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/min/index.html16
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/name/index.html16
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/onpopupshowing/index.html21
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/onpopupshown/index.html21
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/orient/index.html16
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/pending/index.html15
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/persist/index.html24
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/selected/index.html28
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/selectedindex/index.html15
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/tabindex/index.html18
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/validate/index.html27
-rw-r--r--files/zh-cn/mozilla/tech/xul/attribute/value/index.html30
-rw-r--r--files/zh-cn/mozilla/tech/xul/broadcaster/index.html91
-rw-r--r--files/zh-cn/mozilla/tech/xul/browser/index.html409
-rw-r--r--files/zh-cn/mozilla/tech/xul/button/index.html528
-rw-r--r--files/zh-cn/mozilla/tech/xul/checkbox/index.html329
-rw-r--r--files/zh-cn/mozilla/tech/xul/command/index.html105
-rw-r--r--files/zh-cn/mozilla/tech/xul/deprecated_defunct_markup/index.html50
-rw-r--r--files/zh-cn/mozilla/tech/xul/dialog/index.html364
-rw-r--r--files/zh-cn/mozilla/tech/xul/events/index.html497
-rw-r--r--files/zh-cn/mozilla/tech/xul/image/index.html145
-rw-r--r--files/zh-cn/mozilla/tech/xul/index.html79
-rw-r--r--files/zh-cn/mozilla/tech/xul/key/index.html166
-rw-r--r--files/zh-cn/mozilla/tech/xul/label/index.html298
-rw-r--r--files/zh-cn/mozilla/tech/xul/list_of_commands/index.html196
-rw-r--r--files/zh-cn/mozilla/tech/xul/listbox/index.html480
-rw-r--r--files/zh-cn/mozilla/tech/xul/listheader/index.html180
-rw-r--r--files/zh-cn/mozilla/tech/xul/menu/index.html370
-rw-r--r--files/zh-cn/mozilla/tech/xul/menubar/index.html113
-rw-r--r--files/zh-cn/mozilla/tech/xul/menuitem/index.html575
-rw-r--r--files/zh-cn/mozilla/tech/xul/menulist/index.html509
-rw-r--r--files/zh-cn/mozilla/tech/xul/menupopup/index.html324
-rw-r--r--files/zh-cn/mozilla/tech/xul/menuseparator/index.html435
-rw-r--r--files/zh-cn/mozilla/tech/xul/method/extra1/index.html15
-rw-r--r--files/zh-cn/mozilla/tech/xul/method/focus/index.html15
-rw-r--r--files/zh-cn/mozilla/tech/xul/method/getbrowserfortab/index.html15
-rw-r--r--files/zh-cn/mozilla/tech/xul/method/getbutton/index.html15
-rw-r--r--files/zh-cn/mozilla/tech/xul/method/increase/index.html21
-rw-r--r--files/zh-cn/mozilla/tech/xul/method/index.html170
-rw-r--r--files/zh-cn/mozilla/tech/xul/method/reset/index.html15
-rw-r--r--files/zh-cn/mozilla/tech/xul/method/stop/index.html15
-rw-r--r--files/zh-cn/mozilla/tech/xul/namespaces/index.html73
-rw-r--r--files/zh-cn/mozilla/tech/xul/popup/index.html23
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/accessibletype/index.html183
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/accesskey/index.html21
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/browser.preferences/index.html15
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/buttons/index.html10
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/command/index.html21
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/crop/index.html21
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/defaultvalue/index.html15
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/disabled/index.html21
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/image/index.html21
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/index.html266
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/label/index.html21
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/labelelement/index.html21
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/markupdocumentviewer/index.html15
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/max/index.html15
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/menuitem.control/index.html21
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/parentcontainer/index.html21
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/selected/index.html18
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/selectedindex/index.html21
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/selecteditem/index.html21
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/selectionstart/index.html16
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/spinbuttons/index.html15
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/tabindex/index.html21
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/textbox.value/index.html15
-rw-r--r--files/zh-cn/mozilla/tech/xul/property/value/index.html21
-rw-r--r--files/zh-cn/mozilla/tech/xul/radio/index.html379
-rw-r--r--files/zh-cn/mozilla/tech/xul/radiogroup/index.html275
-rw-r--r--files/zh-cn/mozilla/tech/xul/script/index.html117
-rw-r--r--files/zh-cn/mozilla/tech/xul/statusbar/index.html131
-rw-r--r--files/zh-cn/mozilla/tech/xul/style/index.html6
-rw-r--r--files/zh-cn/mozilla/tech/xul/style/menuitem-iconic/index.html16
-rw-r--r--files/zh-cn/mozilla/tech/xul/style/menuitem-non-iconic/index.html16
-rw-r--r--files/zh-cn/mozilla/tech/xul/tabbox/index.html156
-rw-r--r--files/zh-cn/mozilla/tech/xul/template_guide/index.html68
-rw-r--r--files/zh-cn/mozilla/tech/xul/textbox/index.html653
-rw-r--r--files/zh-cn/mozilla/tech/xul/toolbarpalette/index.html103
-rw-r--r--files/zh-cn/mozilla/tech/xul/toolbars/creating_toolbar_buttons/index.html183
-rw-r--r--files/zh-cn/mozilla/tech/xul/toolbars/custom_toolbar_button/index.html332
-rw-r--r--files/zh-cn/mozilla/tech/xul/toolbars/index.html65
-rw-r--r--files/zh-cn/mozilla/tech/xul/toolbox/index.html6
-rw-r--r--files/zh-cn/mozilla/tech/xul/tree/index.html512
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/adding_buttons/index.html98
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/adding_event_handlers/index.html161
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/adding_html_elements/index.html113
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/adding_labels_and_images/index.html40
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/adding_more_elements/index.html115
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/adding_style_sheets/index.html10
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/anonymous_content/index.html166
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/box_model_details/index.html6
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/content_panels/index.html63
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/creating_a_skin/index.html177
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/creating_a_window/index.html116
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/creating_an_installer/index.html98
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/creating_dialogs/index.html6
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/document_object_model/index.html220
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/element_positioning/index.html254
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/features_of_a_window/index.html6
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/grids/index.html175
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/groupboxes/index.html85
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/index.html171
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/input_controls/index.html110
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/introduction/index.html70
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/introduction_to_rdf/index.html109
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/list_controls/index.html133
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/localization/index.html296
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/manifest_files/index.html113
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/modifying_a_xul_interface/index.html118
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/modifying_the_default_skin/index.html63
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/more_button_features/index.html216
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/more_event_handlers/index.html183
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/more_menu_features/index.html108
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/more_wizards/index.html64
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/numeric_controls/index.html78
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/popup_menus/index.html6
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/progress_meters/index.html58
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/property_files/index.html97
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/rdf_datasources/index.html267
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/scroll_bars/index.html9
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/scrolling_menus/index.html45
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/simple_menu_bars/index.html159
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/splitters/index.html85
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/stack_positioning/index.html30
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/stacks_and_decks/index.html71
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/styling_a_tree/index.html12
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/tabboxes/index.html125
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/templates/index.html77
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/the_box_model/index.html39
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/the_chrome_url/index.html74
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/toolbars/index.html101
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/trees/index.html8
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/using_spacers/index.html111
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/using_xbl_from_stylesheets/index.html223
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/xbl介绍/index.html104
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/xpcom_接口/index.html179
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/xul_structure/index.html43
-rw-r--r--files/zh-cn/mozilla/tech/xul/tutorial/更多的按钮特性/index.html68
-rw-r--r--files/zh-cn/mozilla/tech/xul/vbox/index.html130
-rw-r--r--files/zh-cn/mozilla/tech/xul/window/index.html281
-rw-r--r--files/zh-cn/mozilla/tech/xul/xul_reference/index.html20
-rw-r--r--files/zh-cn/mozilla/thunderbird/index.html75
-rw-r--r--files/zh-cn/mozilla/thunderbird/mail_client_architecture_overview/index.html94
-rw-r--r--files/zh-cn/mozilla/thunderbird/mailnews_protocols/index.html31
-rw-r--r--files/zh-cn/mozilla/toolkit_version_format/index.html88
-rw-r--r--files/zh-cn/mozilla/webidl_bindings/index.html920
-rw-r--r--files/zh-cn/mozilla/xmlhttprequest_changes_for_gecko_1.8/index.html19
-rw-r--r--files/zh-cn/mozilla/同时使用多个相互独立的火狐浏览器/index.html123
-rw-r--r--files/zh-cn/mozilla/日历/index.html75
645 files changed, 89007 insertions, 0 deletions
diff --git a/files/zh-cn/mozilla/accessibility/index.html b/files/zh-cn/mozilla/accessibility/index.html
new file mode 100644
index 0000000000..38f8dff03d
--- /dev/null
+++ b/files/zh-cn/mozilla/accessibility/index.html
@@ -0,0 +1,13 @@
+---
+title: Accessibility and Mozilla
+slug: Mozilla/Accessibility
+tags:
+ - Accessibility
+ - Mozilla
+ - NeedsTranslation
+ - TopicStub
+translation_of: Mozilla/Accessibility
+---
+<p><span class="seoSummary"><a href="/en-US/docs/Accessibility" title="/ es-es / docs / Accesibilidad"><font><font>La accesibilidad</font></font></a><font><font> es la idea de que el software (entre otras cosas) debe estar diseñado para ser utilizable y, en la medida de lo posible, conveniente para las personas con discapacidad. Mozilla se esfuerza por hacer que su software sea accesible; los documentos a continuación cubren las formas en que lo hacemos . SO</font></font></span><font><font> Estos artículos proporcionan detalles acerca de la accesibilidad Mozilla específico -.</font></font></p>
+
+<p><font><font>{{LandingPageListSubpages}}=Mx</font></font></p>
diff --git a/files/zh-cn/mozilla/accessibility/software_accessibility_today/index.html b/files/zh-cn/mozilla/accessibility/software_accessibility_today/index.html
new file mode 100644
index 0000000000..8f6884cbd0
--- /dev/null
+++ b/files/zh-cn/mozilla/accessibility/software_accessibility_today/index.html
@@ -0,0 +1,133 @@
+---
+title: 软件无障碍:我们前进到哪里了?
+slug: Mozilla/Accessibility/Software_accessibility_today
+tags:
+ - Accessibility
+ - 可访问性
+ - 无障碍
+translation_of: Mozilla/Accessibility/Software_accessibility_today
+---
+<p id="Where_Are_We_Today.3F">在过去的二十年内,计算机软件的无障碍辅助功能已经出现了大幅改善。本文综述了这一方面的发展进度和技术。</p>
+
+<h2 id="我们前进到哪里了?">我们前进到哪里了?</h2>
+
+<p>到目前为止,桌面计算机环境背后最大的驱动力来自微软公司,首先,他们开发出了 MS DOS,随后是一代又一代的 Microsoft Windows。在设计时,这些操作系统并没有考虑到残疾人的需要。许多人,包括那些失明或有其他身体残疾的人,无法使用一些为微软操作系统编写的应用程序。这些应用程序假设计算机用户可以:</p>
+
+<ul>
+ <li>浏览屏幕上的文字与图片并对其做出响应。</li>
+ <li>在标准键盘上打字。</li>
+ <li>使用鼠标选择文本、图片和其他元素</li>
+ <li>对播放的音效做出响应。This tends to be somewhat less of a limitation in that most software doesn't rely exclusively on audio to relay feedback.</li>
+</ul>
+
+<p>如果一个人不能做到完成上面列出的项目中的任何一条,他就会发现自己无法使用许多流行的计算机应用程序。以下是一些在执行这些任务时会遇到问题的人群:</p>
+
+<ul>
+ <li>Print disabled: blind, deaf-blind, low vision, obstructed vision, dyslexic, cognitively disabled and illiterate individuals.</li>
+ <li>Physically disabled: users have amputations, paralysis, repetitive stress, cerebral palsy, muscular dystrophy, Parkinson's or other problems limiting mobility.</li>
+ <li>Hearing impaired</li>
+</ul>
+
+<p>我们还必须考虑到,有越来越多的上了年纪的 50 后、60 后,还有 70 后开始出现视觉、视力或者灵活性方面的问题。当您将所有可能的用户群体加在一起时,就会发现,无障碍功能其实有很多潜在的用户!</p>
+
+<p>In answer to this problem, many small accessibility hardware and software vendors created products and software which helped people who could not perform one of the four basic tasks to use common computer applications. Some examples of these assistive devices and software include:</p>
+
+<ul>
+ <li>Screen reading software, which speaks text displayed on the screen using hardware or software text-to-speech, and which allows a blind person to use the keyboard to simulate mouse actions</li>
+ <li>Alternate input devices, which allow people with physical disabilities to use alternatives to a keyboard and mouse</li>
+ <li>Voice recognition software, which allows a person to simulate typing on a keyboard or selecting with a mouse by speaking into the computer</li>
+ <li>Screen magnification software, which allows a low-vision computer user to more easily read portions of the screen</li>
+ <li>Comprehension software, which allows a dyslexic or learning disabled computer user to see and hear text as it is manipulated on the computer screen</li>
+</ul>
+
+<p>In fact, the entire adaptive technology industry has grown up around these issues. One great place to go and learn about this industry is the <a class="ex-ref" href="http://www.csun.edu/cod/">CSUN conference</a> in Los Angeles, which takes place every year in mid-late March.</p>
+
+<h2 id="访问屏幕内容的替代方法">访问屏幕内容的替代方法</h2>
+
+<p>大多数计算机程序都是图形化的,对于有视力障碍的人来说,其中一些程序难以使用或者根本无法使用。好在,这种情况不一定就无法挽回。以下是一些现在的视力障碍读者使用桌面软件的方式:</p>
+
+<dl>
+ <dt>Text-to-speech (TTS)</dt>
+ <dd>Makes the computer talk to the user: Those who can't read print at all usually use talking programs (text-to-speech). Talking programs are also useful for print disabilities other than visual impairments, such as dyslexia. Additionally, text-to-speech is used by those who cannot speak, in place of their own voice. Finally, this technology could be useful to mainstream users, on portable information appliances, or to access information when the eyes are busy elsewhere.</dd>
+ <dt>放大</dt>
+ <dd>Enlarges the screen's contents: For those with low vision, it may suffice to use a larger font, a built-in high contrast theme, or even just an an extra large screen. Otherwise, screen magnification programs may be used, which allow zooming in to portions of the screen, while following the mouse or the current focus. Screen magnifiers also have some built-in text-to-speech and the ability to filter text and images through various color palettes, such as black on yellow for high contrast, or green on blue for low contrast.</dd>
+ <dt>The Optacon</dt>
+ <dd>Provides access to printed words, graphics and on-screen information by means of an array vibrating pins the size of an index finger. The user uses one hand to read the vibrating pins, and the other hand moves a mini-camera over the material to be read. Unfortunately, the unit is not currently produced, although there is occasional talk of resurrecting this useful device.</dd>
+ <dt>Braille</dt>
+ <dd>A solution used for quiet reading, for detailed work, and by deaf-blind users. This can come in the form of hard copy braille printed on braille embossers, or from a refreshable braille display (see below). These technologies requires special drivers, braille formatting routines and software based text-to-braille translation. The importance of braille itself must be emphasized. For those that read it, braille can offer higher levels of employment and life fulfillment.</dd>
+</dl>
+
+<table>
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;"><img alt="" src="https://mdn.mozillademos.org/files/6145/powerbraille.jpg" style="border-style: solid; border-width: 1px; height: 189px; width: 303px;"></td>
+ <td style="vertical-align: top;"><img alt="" src="https://mdn.mozillademos.org/files/6147/vpduo2.jpg" style="border-style: solid; border-width: 1px; height: 171px; width: 184px;"></td>
+ </tr>
+ <tr>
+ <td>Refreshable braille displays of various sizes</td>
+ <td>A braille embosser</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>Audio- and braille- based user interfaces are concepts that software designers are historically untrained for. The basic concept is easy - dealing with information when you're blind is like seeing everything through a mail slot - sequentially and methodically. Only small pieces of sequential, non-graphical information can be conveyed - via text-to-speech or a refreshable braille display. Whatever the user does, the software needs to respond with small, bite sized pieces of information that are as short and to the point as possible. Ideally, intelligent decisions are made, so the user does not have to wade through as much non-relevant data.</p>
+
+<h2 id="操作计算机、输入数据的替代方法">操作计算机、输入数据的替代方法</h2>
+
+<p>Another problem is how people with disabilities get information into the computer. If you're physically disabled, you may not be able to type on a regular keyboard or use a mouse. Here are some of the alternative ways physically disabled people enter information:</p>
+
+<dl>
+ <dt>粘滞键</dt>
+ <dd>Make entering key combinations easy. For example to make a capital letter, first press the shift key, release it, then press the letter to be capitalized. The sticky key technique is utilized by people who have only one usable hand, or who have no use of their hands and type using a stick in their mouth.</dd>
+ <dt>Single switch</dt>
+ <dd>Technologies enable persons with severe physical disabilities. Some, like Stephen Hawking, enter information by choosing among lists of options. They might press a switch down to begin moving a highlight bar through the list, and release the switch when the desired option is highlighted.</dd>
+ <dt>特种键盘</dt>
+ <dd>Exist to make data entry easier. However, any special features are generally handled in the keyboard itself, so that no special programming is required.</dd>
+ <dt>语音识别</dt>
+ <dd>Technology lets people talk to the computer. This technology has come a long way, but still needs to be more integrated into mainstream software.</dd>
+ <dt>Consistent keyboard support and hotkeys</dt>
+ <dd>Many people can't use a mouse. Extremely consistent keystroke support is a very important consideration. Blind testers have knack for finding ways to improve keystroke support in almost any given piece of software. Testing with people that have disabilities generally benefits everyone. Use the <a href="/en-US/docs/Mozilla/Accessibility/What_needs_to_be_done_when_building_new_toolkits">accessible toolkit checklist</a> to make sure your UI controls adhere to standards.</dd>
+</dl>
+
+<h2 id="一大主要限制——上下文缺失">一大主要限制——上下文缺失</h2>
+
+<p>这些无障碍软件厂商开发的解决方案大大增加了几十万残障人士的就业率和幸福指数,这些工作的重要性绝不能被轻视。然而,这些解决方案都没能为残障人士提供一个完全可访问、高度易用的工作环境。这是由于一个和上下文有关的简单问题——用户与计算机间的交互是由交互的上下文决定的。当用户在键盘上输入一些东西,或者一个应用程序在屏幕上显示了一些文本或图像,在不同的上下文中,这些交互行为的具体含义也可以是截然不同的。举个例子,一个应用程序可能在处理任务时显示一个电灯泡,而另一个程序可能是在完成任务后显示电灯泡。如果盲人不能得知显示是哪个程序显示了电灯泡,就无法理解这个电灯泡代表什么意思,只能靠猜。类似地,语音识别软件常常需要用户补充交互的上下文信息,来保证用户的语音输入作用到正确的上下文中。这个上下文的问题依然困扰着现代的辅助功能解决方案。</p>
+
+<p>The most recent noteable attempt at solving this problem was put forth by Microsoft in 1997, and is called <dfn>Microsoft Active Accessibility (MSAA)</dfn>. Realizing that complete accessibility was not possible without cooperation between applications and accessibility aids such as screen reading software or voice recognition software, Microsoft Active Accessibility defines a Windows-based standard by which applications can communicate context and other pertanent information to accessibility aids. This solution has seen only partial success, largely due to the fact that it requires significant changes to applications which are made accessible. Because most popular desktop and productivity applications are not open source, this forced disabled people to rely on the companies which produce this software to make it accessible. These companies were often reluctant for various reasons including the large amount of time required to do so. On a positive note, recent federal purchasing rules such as Section 508 have caused many companies to pay attention and implement MSAA support.</p>
+
+<h2 id="步入开源软件之门">步入开源软件之门</h2>
+
+<p>Microsoft was on the right track with Microsoft Active Accessibility, but because the source code to most popular desktop applications which are used in large corporations is not publicly available, they were never made fully accessible. In open source, however, making the necessary modifications to make them accessible is very possible.</p>
+
+<p>Open source software is an ideal way to the needs of disabled users, because accessibility can be fully integrated into the core designs, rather than tacked onto as an afterthought. It also gives disabled programmers a chance to control their own destiny, by giving them the opportunity and the right to directly fix the innaccessible software themselves.</p>
+
+<p>Furthermore, any software solution that can enable equality should by all rights be free of charge - an integral part of society's infrastructure. If no special hardware is required, why should a disabled person pay extra money to use the same software as everyone else? That said, there is still an important role for adaptive technology vendors in creating special services and hardware, or even proprietary software on platforms where that is appropriate. . The ideal situation would be for adaptive technology professionals to make money on rehab, trainingand support - something there is currently not enough of. Each end user has a unique set problems, and in the open source world, providing highly customized solutions can be a business in itself.</p>
+
+<p>Right now, GUI's on Linux are mostly not accessible. Microsoft Windows is still far more accesible. Gnome, KDE, StarOffice, KOffice, Mozilla and all other GUI software packages in Linux are unuseable by large numbers of disabled users. There has been some progress with the support of Gnome's ATK APIs in many of these packages, and the development of GOK (Gnome Onscreen Keyboard) and Gnopernicus (screenreader and magnifier). However, these solutions are not yet truly usable for real disabled end users.</p>
+
+<h2 id="我需要做什么?">我需要做什么?</h2>
+
+<h3 id="Mozilla_开发者">Mozilla 开发者</h3>
+
+<ul>
+ <li>Follow the general front-end accessibility requirements:<br>
+ There are a number of potential "gotchas" when developing XUL UI. Please follow the practical techniques put forth listed in the <a href="/en-US/Accessible_XUL_Authoring_Guidelines">Accessible XUL Authoring Guidelines</a>. These guidelines cover many possible scenarios. If you take a little time to learn them, they will become an unconscious improvement to your design and engineering technique.<br>
+  </li>
+ <li><span>Ensure correct keyboard accessibility when developing new controls:</span><br>
+ Mozilla's XUL and HTML widgets already support proper keyboard accessibility, so let's not regress in that area. Make sure that every new UI control that's developed provides the correct keyboard support.<br>
+ Follow the <a href="/en-US/docs/Mozilla/Accessibility/What_needs_to_be_done_when_building_new_toolkits">Accessible toolkit checklist</a> whenever using XBL to create a new widget.<br>
+  </li>
+ <li><span>Support MSAA and ATK via nsIAccessible when developing new controls</span>:<br>
+ Mozilla is a great position to provide context so that custom controls can be made accessible. Engineers can provide context simply by creating an nsIAccessible for each custom control. The infrastructure to do this is straightforward.</li>
+</ul>
+
+<h3 id="其他开发者">其他开发者</h3>
+
+<p>无论您从事何种工作,可访问性的基础是要了解每一个用户都是不同的。在此之后,具体需要采用的技术可能会随工程环境的不同而变化。下面的{{anch("参见")}}含有分别适用于 Web 开发者和桌面应用程序开发者的各种信息与工具。</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li><a href="/zh-CN/docs/Accessibility">Mozilla 无障碍项目页面</a></li>
+ <li>对于感兴趣的读者,一些含有 Web 可访问性、开源无障碍或者通用的无障碍资源的<a href="/en-US/docs/Mozilla/Accessibility/Links_and_Resources">实用链接</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/add-on_guidelines/index.html b/files/zh-cn/mozilla/add-ons/add-on_guidelines/index.html
new file mode 100644
index 0000000000..58b185e048
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/add-on_guidelines/index.html
@@ -0,0 +1,9 @@
+---
+title: 附加组件准则
+slug: Mozilla/Add-ons/Add-on_guidelines
+tags:
+ - add-on
+ - 附加组件
+translation_of: 'https://extensionworkshop.com/documentation/publish/add-on-policies/'
+---
+<p>REDIRECT <a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/AMO/Policy/Reviews">https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/AMO/Policy/Reviews</a></p>
diff --git a/files/zh-cn/mozilla/add-ons/amo/index.html b/files/zh-cn/mozilla/add-ons/amo/index.html
new file mode 100644
index 0000000000..0845e54e3d
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/amo/index.html
@@ -0,0 +1,11 @@
+---
+title: AMO
+slug: Mozilla/Add-ons/AMO
+tags:
+ - NeedsTranslation
+ - TopicStub
+translation_of: Mozilla/Add-ons/AMO
+---
+<p>{{AddonSidebar}}</p>
+
+<p>Content to be added.</p>
diff --git a/files/zh-cn/mozilla/add-ons/amo/policy/contact/index.html b/files/zh-cn/mozilla/add-ons/amo/policy/contact/index.html
new file mode 100644
index 0000000000..c847ed92d1
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/amo/policy/contact/index.html
@@ -0,0 +1,28 @@
+---
+title: AMO 联系信息
+slug: Mozilla/Add-ons/AMO/Policy/Contact
+tags:
+ - 附加组件支持
+translation_of: Mozilla/Add-ons#Contact_us
+---
+<p>{{AddonSideBar}}</p>
+
+<p><span id="result_box" lang="zh-CN"><span>感谢您愿意与Mozilla 附加组件小组联络。</span> <span>请仔细阅读此页面,以确保您的请求能到达正确的地方。</span></span></p>
+
+<h4 id="附加组件支持">附加组件支持</h4>
+
+<p><span class="long_text" id="result_box" lang="zh-CN"><span>如果您有关于特定</span></span><span class="long_text" lang="zh-CN"><span>附加组件的支持问题,例如“如何使用此附加组件?”</span> <span>或“为什么不能正常工作?”,请通过附加组件列表页上列出的支持渠道联系该附加组件作者。</span></span></p>
+
+<h4 id="附加组件审查相关">附加组件审查相关</h4>
+
+<p><span class="long_text" id="result_box" lang="zh-CN"><span>如果您有关于附加组件审核希望报告违反政策的问题,请发送电子邮件至</span></span> <a href="mailto:amo-editors@mozilla.org">amo-editors@mozilla.org</a><span class="long_text" lang="zh-CN"><span>。几乎所有的附加组件报告都属于这个类别。请务必包含相关附加组件的链接以及您的问题或评论的详细说明。</span></span></p>
+
+<h4 id="附加组件安全漏洞">附加组件安全漏洞</h4>
+
+<p><span class="long_text" id="result_box" lang="zh-CN"><span>如果您在附加程序中发现了安全漏洞,即使它不在此处托管,Mozilla也对您的发现感兴趣并将与附加开发人员一起尽快更正该问题。</span></span><span><span>附加组件的安全问题可以直接报告</span></span>在 <a href="https://bugzilla.mozilla.org/enter_bug.cgi?product=addons.mozilla.org&amp;component=Add-on%20Security&amp;maketemplate=Add-on%20Security%20Bug&amp;bit-23=1&amp;rep_platform=All&amp;op_sys=All">Bugzilla</a> 的 <a href="http://www.mozilla.org/projects/security/security-bugs-policy.html">confidentially</a> 或发邮件给 <a href="mailto:amo-admins@mozilla.org">amo-admins@mozilla.org</a>.</p>
+
+<h4 id="网站功能与发展"><span><span>网站功能与发展</span></span></h4>
+
+<p><span><span>如果您发现本网站有问题</span></span> , 我们乐意修复。请在Github <a href="https://github.com/mozilla/addons/issues/new">上传BUG报告</a>, 报告中包括问题的位置以及您如何遇到这个问题。</p>
+
+<p><span class="comment seoSummary">关于这些政策或您的插件如何与我们联系。</span></p>
diff --git a/files/zh-cn/mozilla/add-ons/amo/policy/index.html b/files/zh-cn/mozilla/add-ons/amo/policy/index.html
new file mode 100644
index 0000000000..58179ed4fa
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/amo/policy/index.html
@@ -0,0 +1,23 @@
+---
+title: AMO Policies
+slug: Mozilla/Add-ons/AMO/Policy
+tags:
+ - NeedsTranslation
+ - TopicStub
+translation_of: Mozilla/Add-ons/AMO/Policy
+---
+<p>{{AddonSidebar}}</p>
+
+<p>Mozilla 致力于为我们的用户和开发人员确保极佳的附加体验,在提交您的附加组件之前,请查阅下列政策。</p>
+
+<dl>
+ <dd></dd><dt><a href="/Mozilla/Add-ons/AMO/Policy/Agreement">开发者协议</a></dt>
+<dd>Effective January 5, 2016</dd> <dt><a href="/Mozilla/Add-ons/AMO/Policy/Reviews">审核处理</a></dt>
+<dd>Add-ons extend the core capabilities of Firefox, allowing users to modify and personalize their Web experience. A healthy add-on ecosystem, built on trust, is vital for developers to be successful and users to feel safe making Firefox their own. For these reasons, Mozilla requires all add-ons to comply with the following set of policies on acceptable practices. The below is not intended to serve as legal advice, nor is it intended to serve as a comprehensive list of terms to include in your add-on’s privacy policy.</dd><br>
+ <dt><a href="/Mozilla/Add-ons/AMO/Policy/Featured">精选的Add-ons</a></dt>
+<dd>How up-and-coming add-ons become featured and what's involved in the process. </dd><br>
+ <strong><a href="https://developer.mozilla.org/en-US/Add-ons#Contact_us">联系我们</a></strong>
+
+ <p> How to get in touch with us regarding these policies or your add-on.</p>
+
+</dl>
diff --git a/files/zh-cn/mozilla/add-ons/code_snippets/canvas/index.html b/files/zh-cn/mozilla/add-ons/code_snippets/canvas/index.html
new file mode 100644
index 0000000000..002a1b8600
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/code_snippets/canvas/index.html
@@ -0,0 +1,237 @@
+---
+title: Canvas 代码片段
+slug: Mozilla/Add-ons/Code_snippets/Canvas
+translation_of: Archive/Add-ons/Code_snippets/Canvas
+---
+<p><span style="color: #000000; display: inline !important; float: none; font-family: Cantarell; font-size: 14.666666984558105px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal;">{{LegacyAddonsNotice}}</span></p>
+
+<p>关于使用<code>&lt;canvas&gt;</code>的一般信息,请参阅 <a class="internal" href="/en-US/docs/Web/API/Canvas_API" title="En/HTML/Canvas">canvas topic page</a>.</p>
+
+<h2 id="网页中可以用到的代码">网页中可以用到的代码</h2>
+
+<h3 id="在画布中获取特定颜色的像素数量">在画布中获取特定颜色的像素数量</h3>
+
+<p>下面的函数将返回画布上颜色(RGB格式)为r、g、b的像素数量。如果用户希望像<a href="https://hacks.mozilla.org/2013/06/building-a-simple-paint-game-with-html5-canvas-and-vanilla-javascript/" title="https://hacks.mozilla.org/2013/06/building-a-simple-paint-game-with-html5-canvas-and-vanilla-javascript/">这篇博客文章</a>中在另一个区域绘画,那么这将非常有用。 </p>
+
+<pre class="brush: js">function getpixelamount(canvas, r, g, b) {
+ var cx = canvas.getContext('2d');
+ var pixels = cx.getImageData(0, 0, canvas.width, canvas.height);
+ var all = pixels.data.length;
+ var amount = 0;
+ for (i = 0; i &lt; all; i += 4) {
+ if (pixels.data[i] === r &amp;&amp;
+ pixels.data[i + 1] === g &amp;&amp;
+ pixels.data[i + 2] === b) {
+ amount++;
+ }
+ }
+ return amount;
+};
+</pre>
+
+<h3 id="在画布中获取某一个像素的颜色">在画布中获取某一个像素的颜色</h3>
+
+<p>下面的代码片段返回一个对象,该对象在画布的x和y的位置上具有RGBA值。这可以用来确定鼠标光标是否在一个特定的形状中。</p>
+
+<pre class="brush: js">function getpixelcolour(canvas, x, y) {
+ var cx = canvas.getContext('2d');
+ var pixel = cx.getImageData(x, y, 1, 1);
+ return {
+ r: pixel.data[0],
+ g: pixel.data[1],
+ b: pixel.data[2],
+ a: pixel.data[3]
+ };
+}
+</pre>
+
+<h3 id="链式调用方法">链式调用方法</h3>
+
+<p>这个类允许可以像jQuery那样链式地访问 2D 渲染上下文的方法和属性 。</p>
+
+<pre class="brush: js">function Canvas2DContext(canvas) {
+ if (typeof canvas === 'string') {
+ canvas = document.getElementById(canvas);
+ }
+ if (!(this instanceof Canvas2DContext)) {
+ return new Canvas2DContext(canvas);
+ }
+ this.context = this.ctx = canvas.getContext('2d');
+ if (!Canvas2DContext.prototype.arc) {
+ Canvas2DContext.setup.call(this, this.ctx);
+ }
+}
+Canvas2DContext.setup = function() {
+ var methods = ['arc', 'arcTo', 'beginPath', 'bezierCurveTo', 'clearRect', 'clip',
+ 'closePath', 'drawImage', 'fill', 'fillRect', 'fillText', 'lineTo', 'moveTo',
+ 'quadraticCurveTo', 'rect', 'restore', 'rotate', 'save', 'scale', 'setTransform',
+ 'stroke', 'strokeRect', 'strokeText', 'transform', 'translate'];
+
+ var getterMethods = ['createPattern', 'drawFocusRing', 'isPointInPath', 'measureText', // drawFocusRing not currently supported
+ // The following might instead be wrapped to be able to chain their child objects
+ 'createImageData', 'createLinearGradient',
+ 'createRadialGradient', 'getImageData', 'putImageData'
+ ];
+
+ var props = ['canvas', 'fillStyle', 'font', 'globalAlpha', 'globalCompositeOperation',
+ 'lineCap', 'lineJoin', 'lineWidth', 'miterLimit', 'shadowOffsetX', 'shadowOffsetY',
+ 'shadowBlur', 'shadowColor', 'strokeStyle', 'textAlign', 'textBaseline'];
+
+ for (let m of methods) {
+ let method = m;
+ Canvas2DContext.prototype[method] = function() {
+ this.ctx[method].apply(this.ctx, arguments);
+ return this;
+ };
+ }
+
+ for (let m of getterMethods) {
+ let method = m;
+ Canvas2DContext.prototype[method] = function() {
+ return this.ctx[method].apply(this.ctx, arguments);
+ };
+ }
+
+ for (let p of props) {
+ let prop = p;
+ Canvas2DContext.prototype[prop] = function(value) {
+ if (value === undefined)
+ return this.ctx[prop];
+ this.ctx[prop] = value;
+ return this;
+ };
+ }
+};
+
+var canvas = document.getElementById('canvas');
+
+// Use context to get access to underlying context
+var ctx = Canvas2DContext(canvas)
+ .strokeStyle('rgb(30, 110, 210)')
+ .transform(10, 3, 4, 5, 1, 0)
+ .strokeRect(2, 10, 15, 20)
+ .context;
+
+// Use property name as a function (but without arguments) to get the value
+var strokeStyle = Canvas2DContext(canvas)
+ .strokeStyle('rgb(50, 110, 210)')
+ .strokeStyle();
+</pre>
+
+<h2 id="Saving_a_canvas_image_to_a_file" name="Saving_a_canvas_image_to_a_file">Code usable only from privileged code</h2>
+
+<p>These snippets are only useful from privileged code, such as extensions or privileged apps.</p>
+
+<h3 id="Saving_a_canvas_image_to_a_file" name="Saving_a_canvas_image_to_a_file">将canvas图片保存到文件中</h3>
+
+<p>The following function accepts a canvas object and a destination file path string. The canvas is converted to a PNG file and saved to the specified location. The function returns a promise which resolves when the file has been completely saved.</p>
+
+<pre class="brush: js">function saveCanvas(canvas, path, type, options) {
+ return Task.spawn(function *() {
+ var reader = new FileReader;
+ var blob = yield new Promise(accept =&gt; canvas.toBlob(accept, type, options));
+ reader.readAsArrayBuffer(blob);
+
+ yield new Promise(accept =&gt; { reader.onloadend = accept });
+
+ return yield OS.File.writeAtomic(path, new Uint8Array(reader.result),
+ { tmpPath: path + '.tmp' });
+ });
+}
+</pre>
+
+<h3 id="Loading_a_remote_page_onto_a_canvas_element" name="Loading_a_remote_page_onto_a_canvas_element">将一个远程页面加载到canvas元素上</h3>
+
+<p>The following class first creates a hidden iframe element and attaches a listener to the frame's load event. Once the remote page has loaded, the remotePageLoaded method fires. This method gets a reference to the iframe's window and draws this window to a canvas object.</p>
+
+<p>Note that this only works if you are running the page from chrome. If you try running the code as a plain webpage, you will get a 'Security error" code: "1000' error.</p>
+
+<pre class="brush: js">RemoteCanvas = function() {
+ this.url = 'http://developer.mozilla.org';
+};
+
+RemoteCanvas.CANVAS_WIDTH = 300;
+RemoteCanvas.CANVAS_HEIGHT = 300;
+
+RemoteCanvas.prototype.load = function() {
+ var windowWidth = window.innerWidth - 25;
+ var iframe;
+ iframe = document.createElement('iframe');
+ iframe.id = 'test-iframe';
+ iframe.height = '10px';
+ iframe.width = windowWidth + 'px';
+ iframe.style.visibility = 'hidden';
+ iframe.src = this.url;
+ // Here is where the magic happens... add a listener to the
+ // frame's onload event
+ iframe.addEventListener('load', this.remotePageLoaded, true);
+ //append to the end of the page
+ window.document.body.appendChild(iframe);
+ return;
+};
+
+RemoteCanvas.prototype.remotePageLoaded = function() {
+ // Look back up the iframe by id
+ var ldrFrame = document.getElementById('test-iframe');
+ // Get a reference to the window object you need for the canvas
+ // drawWindow method
+ var remoteWindow = ldrFrame.contentWindow;
+
+ //Draw canvas
+ var canvas = document.createElement('canvas');
+ canvas.style.width = RemoteCanvas.CANVAS_WIDTH + 'px';
+ canvas.style.height = RemoteCanvas.CANVAS_HEIGHT + 'px';
+ canvas.width = RemoteCanvas.CANVAS_WIDTH;
+ canvas.height = RemoteCanvas.CANVAS_HEIGHT;
+ var windowWidth = window.innerWidth - 25;
+ var windowHeight = window.innerHeight;
+
+ var ctx = canvas.getContext('2d');
+ ctx.clearRect(0, 0,
+ RemoteCanvas.CANVAS_WIDTH,
+ RemoteCanvas.CANVAS_HEIGHT);
+ ctx.save();
+ ctx.scale(RemoteCanvas.CANVAS_WIDTH / windowWidth,
+ RemoteCanvas.CANVAS_HEIGHT / windowHeight);
+ ctx.drawWindow(remoteWindow,
+ 0, 0,
+ windowWidth, windowHeight,
+ 'rgb(255, 255, 255)');
+ ctx.restore();
+};
+</pre>
+
+<p>Usage:</p>
+
+<pre class="brush: js">var remoteCanvas = new RemoteCanvas();
+remoteCanvas.load();
+</pre>
+
+<h3 id="Loading_a_remote_page_onto_a_canvas_element" name="Loading_a_remote_page_onto_a_canvas_element">将图像文件转换为base64字符串</h3>
+
+<p>下面代码加载远程图片,并把它的内容转化为 <code><a href="/en/data_URIs">Data URI scheme</a></code>。</p>
+
+<pre class="brush: js">var canvas = document.createElement('canvas');
+var ctxt = canvas.getContext('2d');
+function loadImageFile(url, callback) {
+ var image = new Image();
+ image.src = url;
+ return new Promise((accept, reject) =&gt; {
+ image.onload = accept;
+ image.onerror = reject;
+ }).then(accept =&gt; {
+ canvas.width = this.width;
+ canvas.height = this.height;
+ ctxt.clearRect(0, 0, this.width, this.height);
+ ctxt.drawImage(this, 0, 0);
+ accept(canvas.toDataURL());
+ });
+}
+</pre>
+
+<p>Usage:</p>
+
+<pre class="brush: js">loadImageFile('myimage.jpg').then(string64 =&gt; { alert(string64); });
+</pre>
+
+<p>如果你想获取本地文件(使用文件选择input元素)的 base64 内容,你必须使用 <code><a href="/en/DOM/FileReader#readAsDataURL%28%29" title="en/DOM/FileReader#readAsDataURL%28%29">FileReader</a></code> 对象。</p>
diff --git a/files/zh-cn/mozilla/add-ons/code_snippets/index.html b/files/zh-cn/mozilla/add-ons/code_snippets/index.html
new file mode 100644
index 0000000000..bfe77a4e38
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/code_snippets/index.html
@@ -0,0 +1,134 @@
+---
+title: Code snippets
+slug: Mozilla/Add-ons/Code_snippets
+tags:
+ - Add-ons
+ - Code snippets
+ - Extensions
+ - NeedsTranslation
+ - TopicStub
+translation_of: Archive/Add-ons/Code_snippets
+---
+<p><span style="color: #000000; display: inline !important; float: none; font-family: Cantarell; font-size: 14.666666984558105px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal;">{{LegacyAddonsNotice}}</span></p>
+
+<p>This is a quick list of useful code snippets (small code samples) available for developers of extensions for the various Mozilla applications. Many of these samples can also be used in XULRunner applications, as well as in actual Mozilla code itself.</p>
+
+<p>These examples demonstrate how to accomplish basic tasks that might not be immediately obvious.</p>
+
+<h2 id="General" name="General">General</h2>
+
+<dl>
+ <dt><a href="/en-US/docs/Code_snippets/From_articles" title="/en-US/docs/Code_snippets/From_articles">Examples and demos from MDN articles</a></dt>
+ <dd>A collection of examples and demos from articles.</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Windows" title="/en-US/docs/Code_snippets/Windows">Window code</a></dt>
+ <dd>Opening and manipulating windows</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Toolbar" title="/en-US/docs/Code_snippets/Toolbar">Toolbar</a></dt>
+ <dd>Toolbar related code</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Sidebar" title="/en-US/docs/Code_snippets/Sidebar">Sidebar</a></dt>
+ <dd>Sidebar related code</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Forms">Forms</a></dt>
+ <dd>Forms related code</dd>
+ <dt><a href="/en-US/docs/Code_snippets/XML" title="/en-US/docs/Code_snippets/XML">XML</a></dt>
+ <dd>Code used to parse, write, manipulate, etc. XML</dd>
+ <dt><a href="/en-US/docs/Code_snippets/File_I_O" title="/en-US/docs/Code_snippets/File_I/O">File I/O</a></dt>
+ <dd>Code used to read, write and process files</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Drag_&amp;_Drop" title="/en-US/docs/Code_snippets/Drag_&amp;_Drop">Drag &amp; Drop</a></dt>
+ <dd>Code used to setup and handle drag and drop events</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Dialogs_and_Prompts" title="/en-US/docs/Code_snippets/Dialogs_and_Prompts">Dialogs</a></dt>
+ <dd>Code used to display and process dialog boxes</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Alerts_and_Notifications" title="/en-US/docs/Code snippets/Alerts and Notifications">Alerts and Notifications </a></dt>
+ <dd>Modal and non-modal ways to notify users</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Preferences" title="/en-US/docs/Code_snippets/Preferences">Preferences</a></dt>
+ <dd>Code used to read, write, and modify preferences</dd>
+ <dt><a href="/en-US/docs/Code_snippets/JS_XPCOM" title="/en-US/docs/Code_snippets/JS_XPCOM">JS XPCOM</a></dt>
+ <dd>Code used to define and call XPCOM components in JavaScript</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Running_applications" title="/en-US/docs/Code_snippets/Running_applications">Running applications</a></dt>
+ <dd>Code used to run other applications</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Canvas" title="/en-US/docs/Code_snippets/Canvas"><code>&lt;canvas&gt;</code> related</a></dt>
+ <dd><a href="/en-US/docs/HTML/Canvas" title="/en-US/docs/HTML/Canvas">WHAT WG Canvas</a>-related code</dd>
+ <dt><a href="/en-US/docs/Signing_a_XPI" title="/en-US/docs/Signing_a_XPI">Signing a XPI</a></dt>
+ <dd>How to sign an XPI with PKI</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Threads">Delayed Execution</a></dt>
+ <dd>Performing background operations.</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Miscellaneous" title="/en-US/docs/Code_snippets/Miscellaneous">Miscellaneous</a></dt>
+ <dd>Miscellaneous useful code fragments</dd>
+ <dt><a href="/en-US/docs/Code_snippets/HTML_to_DOM" title="/en-US/docs/Code_snippets/HTML_to_DOM">HTML to DOM</a></dt>
+ <dd>Using a hidden browser element to parse HTML to a window's DOM</dd>
+</dl>
+
+<h2 id="javascript-libraries" name="javascript-libraries">JavaScript libraries</h2>
+
+<p>Here are some JavaScript libraries that may come in handy.</p>
+
+<dl>
+ <dt><a href="/en-US/docs/Code_snippets/StringView" title="/en-US/docs/Code_snippets/StringView">StringView</a></dt>
+ <dd>A library that implements a <code>StringView</code> view for <a href="/en-US/docs/Web/JavaScript/Typed_arrays" title="/en-US/docs/Web/JavaScript/Typed_arrays">JavaScript typed arrays</a>. This lets you access data in typed arrays using C-like string functions.</dd>
+ <dt><a href="/en-US/Add-ons/Code_snippets/Rosetta" title="/en-US/docs/Code_snippets/Rosetta">Rosetta</a></dt>
+ <dd>By default, the only possible standardized scripting language for HTML is <strong>ECMAScript</strong>. Hence, if you are going to use another scripting language you might expect that most of the browsers will not recognize it. Nevertheless, the increasing computational power of modern browsers together with the introduction of <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays">typed arrays</a> in ECMAScript allow us, in theory, to build full <a class="external external-icon" href="http://en.wikipedia.org/wiki/Virtual_machine">virtual machines</a> in pure ECMAScript. Therefore, it is also possible, in theory, to use ECMAScript for a smaller task: parsing exotic programming languages (i.e., creating compilers). This snippets shows a possible way to start from.</dd>
+</dl>
+
+<h2 id="Browser-oriented_code" name="Browser-oriented_code">Browser-oriented code</h2>
+
+<dl>
+ <dt><a href="/en-US/docs/Code_snippets/Tabbed_browser" title="/en-US/docs/Code_snippets/Tabbed_browser">Tabbed browser code</a> (Firefox/SeaMonkey)</dt>
+ <dd>Basic operations, such as page loading, with the tabbed browser, which is the heart of Mozilla's browser applications</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Cookies" title="/en-US/docs/Code_snippets/Cookies">Cookies</a></dt>
+ <dd>Reading, writing, modifying, and removing cookies</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Page_Loading" title="/en-US/docs/Code_snippets/Page_Loading">Page Loading</a></dt>
+ <dd>Code used to load pages, reload pages, and listen for page loads</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Interaction_between_privileged_and_non-privileged_pages" title="/en-US/docs/Code_snippets/Interaction_between_privileged_and_non-privileged_pages">Interaction between privileged and non-privileged code</a></dt>
+ <dd>How to communicate from extensions to websites and vice-versa.</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Downloading_Files" title="/en-US/docs/Code_snippets/Downloading_Files">Downloading Files</a></dt>
+ <dd>Code to download files, images, and to monitor download progress</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Password_Manager" title="/en-US/docs/Code_snippets/Password_Manager">Password Manager</a></dt>
+ <dd>Code used to read and write passwords to/from the integrated password manager</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Bookmarks" title="/en-US/docs/Code_snippets/Bookmarks">Bookmarks</a></dt>
+ <dd>Code used to read and write bookmarks</dd>
+ <dt><a href="/en-US/docs/Code_snippets/JavaScript_Debugger_Service" title="/en-US/docs/Code_snippets/JavaScript_Debugger_Service">JavaScript Debugger Service</a></dt>
+ <dd>Code used to interact with the JavaScript Debugger Service</dd>
+</dl>
+
+<h2 id="SVG" name="SVG">SVG</h2>
+
+<dl>
+ <dt><a href="/en-US/docs/Code_snippets/SVG_General" title="/en-US/docs/Code_snippets/SVG_General">General</a></dt>
+ <dd>General information and utilities</dd>
+ <dt><a href="/en-US/docs/Code_snippets/SVG_Animation" title="/en-US/docs/Code_snippets/SVG_Animation">SVG Animation</a></dt>
+ <dd>Animate SVG using JavaScript and SMIL</dd>
+ <dt><a href="/en-US/docs/Code_snippets/SVG_Interacting_with_script" title="/en-US/docs/Code_snippets/SVG_Interacting_with_script">SVG Interacting with Script</a></dt>
+ <dd>Using JavaScript and DOM events to create interactive SVG</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Embedding_SVG" title="/en-US/docs/Code_snippets/Embedding_SVG">Embedding SVG in HTML and XUL</a></dt>
+ <dd>Using SVG to enhance HTML or XUL based markup</dd>
+</dl>
+
+<h2 id="XUL_Widgets" name="XUL_Widgets">XUL Widgets</h2>
+
+<dl>
+ <dt><a href="/en-US/docs/Code_snippets/HTML_in_XUL_for_rich_tooltips" title="/en-US/docs/Code_snippets/HTML_in_XUL_for_rich_tooltips">HTML in XUL for Rich Tooltips</a></dt>
+ <dd>Dynamically embed HTML into a XUL element to attain markup in a tooltip</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Label_and_description" title="/en-US/docs/Code_snippets/Label_and_description">Label and description</a></dt>
+ <dd>Special uses and line breaking examples</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Tree" title="/en-US/docs/Code_snippets/Tree">Tree</a></dt>
+ <dd>Setup and manipulation of trees using XUL and JS</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Scrollbar" title="/en-US/docs/Code_snippets/Scrollbar">Scrollbar</a></dt>
+ <dd>Changing style of scrollbars. Applies to scrollbars in browser and iframe as well.</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Autocomplete" title="/en-US/docs/Code_snippets/Autocomplete">Autocomplete</a></dt>
+ <dd>Code used to enable form autocomplete in a browser</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Boxes" title="/en-US/docs/Code_snippets/Boxes">Boxes</a></dt>
+ <dd>Tips and tricks when using boxes as containers</dd>
+ <dt><a class="internal" href="/en-US/docs/Code_snippets/Tabbox" title="/en-US/docs/Code snippets/Tabbox">Tabbox</a></dt>
+ <dd>Removing and manipulating tabs in a tabbox</dd>
+</dl>
+
+<h2 id="Windows-specific" name="Windows-specific">Windows-specific</h2>
+
+<dl>
+ <dt><a href="/en-US/docs/Code_snippets/Finding_Window_Handles" title="/en-US/docs/Code_snippets/Finding_Window_Handles">Finding Window Handles (HWND)</a> (Firefox)</dt>
+ <dd>How to use Windows API calls to find various kinds of Mozilla window handles. Window handles can be used for IPC and Accessibility purposes.</dd>
+ <dt><a href="/en-US/docs/Accessing_the_Windows_Registry_Using_XPCOM" title="/en-US/docs/Accessing_the_Windows_Registry_Using_XPCOM">Using the Windows Registry with XPCOM</a></dt>
+ <dd>How to read, write, modify, delete, enumerate, and watch registry keys and values.</dd>
+</dl>
+
+<h2 id="External_links" name="External_links">External links</h2>
+
+<p>The content at <a class="external" href="http://kb.mozillazine.org/Category:Example_code">MozillaZine Example Code</a> is slowly being moved here, but you can still find useful examples there for now.</p>
diff --git a/files/zh-cn/mozilla/add-ons/code_snippets/js_xpcom/index.html b/files/zh-cn/mozilla/add-ons/code_snippets/js_xpcom/index.html
new file mode 100644
index 0000000000..e5ab2b6189
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/code_snippets/js_xpcom/index.html
@@ -0,0 +1,97 @@
+---
+title: JS XPCOM
+slug: Mozilla/Add-ons/Code_snippets/JS_XPCOM
+translation_of: Archive/Add-ons/Code_snippets/JS_XPCOM
+---
+<p><span style="color: #000000; display: inline !important; float: none; font-family: Cantarell; font-size: 14.666666984558105px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal;">{{LegacyAddonsNotice}}</span></p>
+
+<p>这是一些解决XPCOM组件相关的有用的JavaScript代码。</p>
+
+<h3 id="Contract_IDs" name="Contract_IDs">Contract IDs</h3>
+
+<p>契约ID是XPCOM对象独一无二的名字。它们用于创建或者获得XPCOM中的对象。</p>
+
+<h3 id="Interfaces" name="Interfaces">Interfaces</h3>
+
+<p>Every XPCOM object implements one or more interfaces. An interface is simply a list of constants and methods that can be called on the object, an example is <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile" title="nsIFile is the correct platform-agnostic way to specify a file; you should always use this instead of a string to ensure compatibility.">nsIFile</a></code>. Every XPCOM object must implement the <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/Code_snippets/JS_XPCOM" title="">nsISupports</a></code> interface.</p>
+
+<h3 id="Accessing_XPCOM_components_from_JavaScript" name="Accessing_XPCOM_components_from_JavaScript">Accessing XPCOM components from JavaScript</h3>
+
+<p>XPCOM objects are either created as new instances (each creation gives you a completely new COM object) or as services (each access gives you the same COM object, often called a singleton). Whether you must create a new instance or access as a service depends on the contract. In order to get an XPCOM object you need to know the contract ID of the object and the interface that you wish to use on it.</p>
+
+<h4 id="Creating_an_instance_of_a_component" name="Creating_an_instance_of_a_component">Creating an instance of a component</h4>
+
+<p>The preferred method of creating XPCOM instances is via the <code><a href="/en-US/docs/Components.Constructor">Components.Constructor</a></code> helper. For example,</p>
+
+<pre class="brush: js">var nsFile = Components.Constructor("@mozilla.org/file/local;1", "nsIFile", "initWithPath");
+
+var file = new nsFile(filePath);
+</pre>
+
+<p>They can also be created and initialized manually:</p>
+
+<pre class="brush: js">var file = Components.classes["@mozilla.org/file/local;1"]
+ .createInstance(Components.interfaces.nsIFile);
+file.initWithPath(filePath);
+</pre>
+
+<p>This creates a new instance of the object with contract ID <code>@mozilla.org/file/local;1</code> and allows you to call methods from the <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile" title="nsIFile is the correct platform-agnostic way to specify a file; you should always use this instead of a string to ensure compatibility.">nsIFile</a></code> interface on it.</p>
+
+<h4 id="Getting_an_XPCOM_service" name="Getting_an_XPCOM_service">Getting an XPCOM service</h4>
+
+<pre class="brush: js">var preferences = Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefService);
+</pre>
+
+<p>You can then call any methods in the <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/Code_snippets/JS_XPCOM" title="">nsIPrefService</a></code> interface on the preferences object.</p>
+
+<h4 id="Getting_a_different_interface_for_a_component" name="Getting_a_different_interface_for_a_component">Getting a different interface for a component</h4>
+
+<p>Some components implement more than one interface. Sometimes JavaScript is clever enough to know all the interfaces available on a component, but in most cases you will have to explicitly check for an interface. With the preferences service from the previous example we can do the following:</p>
+
+<pre class="brush: js">var preferences = preferences.QueryInterface(Components.interfaces.nsIPrefBranch2);
+</pre>
+
+<p>This allows you to use the methods in the <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/Code_snippets/JS_XPCOM" title="">nsIPrefBranch2</a></code> interface.</p>
+
+<h4 id="Determining_which_interfaces_an_XPCOM_component_supports" name="Determining_which_interfaces_an_XPCOM_component_supports">Determining which interfaces an XPCOM component supports</h4>
+
+<p>To display a list of all interfaces that an XPCOM component supports, do the following:</p>
+
+<pre class="brush: js">// |c| is the XPCOM component instance
+for each (i in Components.interfaces) { if (c instanceof i) { alert(i); } }
+</pre>
+
+<p>In this context, <code>instanceof</code> is the same as <code>QueryInterface</code> except that it returns false instead of throwing an exception when <code>|c|</code> doesn't support interface <code>|i|</code>. Another difference is that <code>QueryInterface</code> returns an object, where as <code>instanceof</code> returns a <code>boolean</code>.</p>
+
+<h3 id="XPCOMUtils_-_About_protocol_handler" name="XPCOMUtils_-_About_protocol_handler">XPCOMUtils - About protocol handler</h3>
+
+<p>{{ Fx_minversion_inline(3) }}This example implements a quick about protocol handler in JS using <a href="/en/XPCOMUtils.jsm" title="en/XPCOMUtils.jsm">XPCOMUtils.jsm</a>.</p>
+
+<pre class="brush: js">Components.utils.import("resource://gre/modules/Services.jsm");
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+
+function AboutHandler() {}
+AboutHandler.prototype = {
+ newChannel: function(uri) {
+ var channel = Services.io.newChannel("chrome://mystuff/content/mystuff.xul", null, null);
+ channel.originalURI = uri;
+ return channel;
+ },
+ getURIFlags: function(uri) {
+ // Do NOT return Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT unless
+ // you make sure to set a non-system principal in newChannel.
+ return 0;
+ },
+
+ classDescription: "About MyStuff Page",
+ classID: Components.ID("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"),
+ contractID: "@mozilla.org/network/protocol/about;1?what=mystuff",
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule])
+}
+
+var NSGetModule = XPCOMUtils.generateNSGetModule([AboutHandler]);
+}
+</pre>
diff --git a/files/zh-cn/mozilla/add-ons/code_snippets/modules/index.html b/files/zh-cn/mozilla/add-ons/code_snippets/modules/index.html
new file mode 100644
index 0000000000..413e32f59a
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/code_snippets/modules/index.html
@@ -0,0 +1,37 @@
+---
+title: Modules
+slug: Mozilla/Add-ons/Code_snippets/Modules
+translation_of: Archive/Add-ons/Code_snippets/Modules
+---
+<p><span style="color: #000000; display: inline !important; float: none; font-family: Cantarell; font-size: 14.666666984558105px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal;"><font><font>{{LegacyAddonsNotice}}</font></font></span></p>
+
+<p><font><font>一些简单的代码将</font></font><a href="/en/JavaScript_code_modules" title="en / JavaScript代码模块"><font><font>JavaScript模块</font></font></a><font><font>转换为非Mozilla特定的代码(例如,如果移植到浏览器)。</font><font>eval()的使用可能不会被关注,因为它仅在</font></font><code>EXPORTED_SYMBOLS</code><font><font> 数组</font><font>上使用,</font><font>而不依赖于用户输入。</font></font></p>
+
+<pre class="brush: js"><font><font>函数importModule(thatObj){</font></font><font><font>
+ thatObj = thatObj || </font><font>窗口;</font></font>
+<font><font>
+ var EXPORTED_SYMBOLS = [</font></font><font><font>
+ //把符号放在这里</font></font><font><font>
+ ]。</font></font>
+<font><font>
+ //你的代码在这里...</font></font>
+<font><font>
+ //在你的代码结尾处:(假设'i'和'thatObj'都没有被导出!)</font></font><font><font>
+ for(var i = 0; i &lt;EXPORTED_SYMBOLS.length; i ++){thatObj [EXPORTED_SYMBOLS [i]] = eval(EXPORTED_SYMBOLS [i]);}</font></font><font><font>
+}</font></font>
+</pre>
+
+<p><font><font>或一次性使用模块:</font></font></p>
+
+<pre class="brush: js"><font><font>(function(thatObj){</font></font><font><font>
+ thatObj = thatObj || </font><font>窗口;</font></font>
+<font><font>
+ var EXPORTED_SYMBOLS = [</font></font><font><font>
+ //把符号放在这里</font></font><font><font>
+ ]。</font></font>
+<font><font>
+ //你的代码在这里...</font></font>
+<font><font>
+ //在你的代码结尾处:(假设'i'和'thatObj'都没有被导出!)</font></font><font><font>
+ for(var i = 0; i &lt;EXPORTED_SYMBOLS.length; i ++){thatObj [EXPORTED_SYMBOLS [i]] = eval(EXPORTED_SYMBOLS [i]);}</font></font><font><font>
+})(); </font><font>//可以在这里放置一个对象参数</font></font></pre>
diff --git a/files/zh-cn/mozilla/add-ons/code_snippets/queryselector/index.html b/files/zh-cn/mozilla/add-ons/code_snippets/queryselector/index.html
new file mode 100644
index 0000000000..364909681f
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/code_snippets/queryselector/index.html
@@ -0,0 +1,114 @@
+---
+title: QuerySelector
+slug: Mozilla/Add-ons/Code_snippets/QuerySelector
+tags:
+ - $
+ - $$
+ - querySelector
+translation_of: Archive/Add-ons/Code_snippets/QuerySelector
+---
+<p> {{ fx_minversion_header(3.5) }}</p>
+
+<p>沿着其他框架,如jQuery或Prototype, 缩短“querySelector”的名称可以很方便:</p>
+
+<pre class="brush: js"> HTMLDocument.prototype.$ = function (selector) {
+  // Only for HTML
+ return this.querySelector(selector);
+ };
+ $(`div`);
+ HTMLDocument.prototype.$$ = function (selector) {
+ // Only for HTML
+ return this.querySelectorAll(selector);
+ };
+ $$(`div`);</pre>
+
+<pre class="brush: js">function $ (selector, el) {
+ if (!el) {el = document;}
+ return el.querySelector(selector);
+}
+function $$ (selector, el) {
+ if (!el) {el = document;}
+ return el.querySelectorAll(selector);
+ // Note: the returned object is a NodeList.
+ // If you'd like to convert it to a Array for convenience, use this instead:
+ // return Array.prototype.slice.call(el.querySelectorAll(selector));
+}
+alert($('#myID').id);
+</pre>
+
+<p>(请注意,在使用火狐浏览器控制台时,上述功能可自动使用.)</p>
+
+<p> XUL 甚至 XML可以很简单的支持(有以下两种替代方法,添加ChromeWindow.prototype 或者 Window.prototype,访问 this.document.querySelector, 或者根据jQuery 风格的链接,即在每个原型的$()方法中返回的‘this'</p>
+
+<pre class="brush: js">HTMLDocument.prototype.$ = function (selector) { // 只用于HTML
+ return this.querySelector(selector);
+};
+
+Example:
+
+&lt;h1&gt;Test!&lt;/h1&gt;
+&lt;script&gt;
+HTMLDocument.prototype.$ = function (selector) {
+ return this.querySelector(selector);
+};
+alert(document.$('h1')); // [object HTMLHeadingElement]
+&lt;/script&gt;
+</pre>
+
+<pre class="brush: js">XULDocument.prototype.$ = function (selector) { // 只用于XUL
+ return this.querySelector(selector);
+};
+
+Example:
+
+&lt;label value="Test!"/&gt;
+&lt;script type="text/javascript"&gt;&lt;![CDATA[
+XULDocument.prototype.$ = function (selector) { // 只用于XUL
+ return this.querySelector(selector);
+};
+
+alert(document.$('label')); // [object XULElement]
+]]&gt;&lt;/script&gt;
+</pre>
+
+<pre class="brush: js">Document.prototype.$ = function (selector) { // 只用于XML
+ return this.querySelector(selector);
+};
+var foo = document.implementation.createDocument('someNS', 'foo', null); // Create an XML document &lt;foo xmlns="someNS"/&gt;
+var bar = foo.createElementNS('someNS', 'bar'); // add &lt;bar xmlns="someNS"/&gt;
+foo.documentElement.appendChild(bar);
+alert(foo.$('bar').nodeName); // gives 'bar'
+</pre>
+
+<pre class="brush: js">Element.prototype.$ = function (selector) { // 可用于HTML,XUL,XML
+ return this.querySelector(selector);
+};
+
+HTML 例子:
+&lt;h1&gt;&lt;a&gt;Test!&lt;a/&gt;&lt;/h1&gt;
+&lt;script&gt;
+Element.prototype.$ = function (selector) {
+ return this.querySelector(selector);
+};
+alert(document.getElementsByTagName('h1')[0].$('a').nodeName); // 'A'
+
+XUL 例子:
+&lt;hbox&gt;&lt;vbox/&gt;&lt;/hbox&gt;
+&lt;script type="text/javascript"&gt;&lt;![CDATA[
+Element.prototype.$ = function (selector) {
+ return this.querySelector(selector);
+};
+var XULNS = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul';
+alert(document.getElementsByTagNameNS(XULNS, 'hbox')[0].$('vbox').nodeName); // vbox
+]]&gt;&lt;/script&gt;
+
+XML 例子:
+&lt;foo xmlns="someNS"&gt;&lt;bar/&gt;&lt;/foo&gt; in document earlier
+var foo = document.getElementsByTagNameNS('someNS', 'foo')[0];
+alert(foo.$('bar'));
+
+</pre>
+
+<p>注意在XML中,  # 'id'选择器将不能体现为'id'属性(因此一个这样名字的属性不一定是XML的ID,尽管他在HTML 和XUL中是这样的), 也不会对 <a href="/en/xml/xml:id" title="en/xml/id">xml:id</a> 起作用.</p>
+
+<p>然而,它将工作于指向没有无前缀属性选择器 (例如'id',但是不是 xml:id: <a class="external" href="http://www.w3.org/TR/selectors-api/#resolving" rel="freelink">http://www.w3.org/TR/selectors-api/#resolving</a>) (即使 CSS3 支持命名空间属性选择器: <a class="external" href="http://www.w3.org/TR/css3-selectors/#attrnmsp" rel="freelink">http://www.w3.org/TR/css3-selectors/#attrnmsp</a> 以及可能将xml:id 当作 #: <a class="external" href="http://www.w3.org/TR/css3-selectors/#id-selectors" rel="freelink">http://www.w3.org/TR/css3-selectors/#id-selectors</a> ).</p>
diff --git a/files/zh-cn/mozilla/add-ons/code_snippets/timers/index.html b/files/zh-cn/mozilla/add-ons/code_snippets/timers/index.html
new file mode 100644
index 0000000000..f15f127f61
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/code_snippets/timers/index.html
@@ -0,0 +1,67 @@
+---
+title: JavaScript timers
+slug: Mozilla/Add-ons/Code_snippets/Timers
+translation_of: Archive/Add-ons/Code_snippets/Timers
+---
+<p><span style="color: #000000; display: inline !important; float: none; font-family: Cantarell; font-size: 14.666666984558105px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal;">{{LegacyAddonsNotice}}</span></p>
+
+<p> </p>
+
+<p>JavaScript的代码块通常情况下是顺序执行的。不过有几个JavaScript内置函数(计时器),能够让我们推迟任意指令的执行:</p>
+
+<ul>
+ <li>{{domxref("window.setTimeout","setTimeout()")}}</li>
+ <li>{{domxref("window.setInterval","setInterval()")}}</li>
+ <li>{{domxref("window.setImmediate","setImmediate()")}}</li>
+ <li>{{domxref("window.requestAnimationFrame","requestAnimationFrame()")}}</li>
+</ul>
+
+<p>The <code>setTimeout()</code> function is commonly used if you wish to have your function called <em>once</em> after the specified delay. The <code>setInterval()</code> function is commonly used to set a delay for functions that are executed again and again, such as animations. The <code>setImmediate()</code> function can be used instead of the <code>setTimeout(<em>fn</em>, <strong>0</strong>)</code> method to execute heavy operations in IE. The <code>requestAnimationFrame()</code> function tells the browser that you wish to perform an animation and requests that the browser schedule a repaint of the window for the next animation frame.</p>
+
+<h2 class="Documentation" id="Documentation" name="Documentation">Documentation</h2>
+
+<dl>
+ <dt>{{domxref("window.setTimeout","setTimeout()")}}</dt>
+ <dd>Calls a function or executes a code snippet after specified delay.</dd>
+ <dt>{{domxref("window.setInterval","setInterval()")}}</dt>
+ <dd>Calls a function or executes a code snippet repeatedly, with a fixed time delay between each call to that function.</dd>
+ <dt>{{domxref("window.setImmediate","setImmediate()")}}</dt>
+ <dd>Calls a function immediately after the browser has completed other operations, such as events and display updates.</dd>
+ <dt>{{domxref("window.clearTimeout","clearTimeout()")}}</dt>
+ <dd>Clears the delay set by <code>setTimeout()</code>.</dd>
+ <dt>{{domxref("window.clearInterval","clearInterval()")}}</dt>
+ <dd>Cancels repeated action which was set up using <code>setInterval()</code>.</dd>
+ <dt>{{domxref("window.clearImmediate","clearImmediate()")}}</dt>
+ <dd>Cancels the immediate actions, just like {{domxref("window.clearTimeout","clearTimeout()")}} for {{domxref("window.setTimeout","setTimeout()")}}.</dd>
+ <dt><a href="/en-US/docs/Web/JavaScript/Timers/Daemons">Using JavaScript timers within animations (Javascript Daemons Management)</a></dt>
+ <dd>In Computer science a <em>daemon</em> is a task that runs as a background process, rather than being under the direct control of an interactive user. In JavaScript programming language, all <em>daemons</em> are processes created by JavaScript timers or by a {{domxref("Worker")}} instantiation. Here are some code snippets which simplify and abstract the management of daemons.</dd>
+ <dt>{{domxref("window.requestAnimationFrame","requestAnimationFrame()")}}</dt>
+ <dd><code>requestAnimationFrame()</code> tells the browser that you wish to perform an animation and requests that the browser schedule a repaint of the window for the next animation frame. The method takes as an argument a callback to be invoked before the repaint.</dd>
+ <dt>{{domxref("performance.now","performance.now()")}}</dt>
+ <dd>
+ <p><code>performance.now()</code> returns a timestamp, measured in milliseconds, accurate to one thousandth of a millisecond. This timestamp is equal to the number of milliseconds since the <code>navigationStart </code>attribute of the <a href="/en-US/docs/Navigation_timing" title="/en-US/docs/Navigation_timing"><code>performance.timing</code></a> interface.</p>
+ </dd>
+ <dt><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now" title="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now"><code>Date.now()</code></a></dt>
+ <dd><code>Date.now()</code> returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.</dd>
+ <dt><a href="/en-US/docs/Web/Guide/Performance/Using_web_workers#Timeouts_and_intervals">Using JavaScript timers within workers</a></dt>
+ <dd>Workers can use timeouts and intervals just like the main thread can. This can be useful, for example, if you want to have your worker thread run code periodically instead of nonstop.</dd>
+ <dt><a href="/en-US/docs/Web/Guide/Needs_categorization/Functions_available_to_workers">Functions available to workers</a></dt>
+ <dd>In addition to the standard JavaScript set of functions (such as String, Array, Object, JSON etc), there are a variety of functions available from the DOM to workers. This article provides a list of those.</dd>
+ <dt><a href="/en-US/docs/Web/HTML/Canvas/Tutorial/Basic_animations">Basic animations</a></dt>
+ <dd>Since we're using script to control canvas elements it's also very easy to make (interactive) animations. Unfortunately the canvas element was never designed to be used in this way (unlike Flash) so there are limitations.</dd>
+ <dt><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Timer.jsm" title="/en-US/docs/Mozilla/JavaScript_code_modules/Timer.jsm">Timer.jsm</a></dt>
+ <dd>The <code>Timer.jsm</code> JavaScript code module contains pure-JavaScript implementations of <a href="/en-US/docs/DOM/window.setTimeout" title="/en-US/docs/DOM/window.setTimeout"><code>setTimeout </code></a>and <a href="/en-US/docs/DOM/window.clearTimeout" title="/en-US/docs/DOM/window.clearTimeout"><code>clearTimeout</code></a> that are compatible with the DOM window functions, but that can be used by code that does not have access to a DOM window (for example, <a href="/en-US/docs/Mozilla/JavaScript_code_modules" title="/en-US/docs/Mozilla/JavaScript_code_modules">JavaScript code modules </a>or <a href="/en-US/docs/The_message_manager" title="/en-US/docs/The_message_manager">content frame scripts</a>).</dd>
+</dl>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Web/API/window.setTimeout#Callback_arguments">Callback arguments polyfill</a></li>
+ <li><a href="/en-US/docs/Web/API/window.setInterval#A_little_framework">A little <code>setInterval</code> framework</a></li>
+ <li><a href="/en-US/docs/Web/JavaScript">JavaScript</a>, <a href="/en-US/docs/Web/Guide/Performance/Using_web_workers">Workers</a></li>
+ <li><a href="/en-US/docs/Web/Guide/Performance/Using_web_workers">Using web workers</a></li>
+ <li>{{domxref("window.performance")}}</li>
+ <li><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date" title="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date"><code>Date</code></a></li>
+</ul>
+
+<p>&lt;embed height="0" id="xunlei_com_thunder_helper_plugin_d462f475-c18e-46be-bd10-327458d045bd" type="application/thunder_download_plugin" width="0"&gt;</p>
diff --git a/files/zh-cn/mozilla/add-ons/creating_custom_firefox_extensions_with_the_mozilla_build_system/index.html b/files/zh-cn/mozilla/add-ons/creating_custom_firefox_extensions_with_the_mozilla_build_system/index.html
new file mode 100644
index 0000000000..617d86487c
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/creating_custom_firefox_extensions_with_the_mozilla_build_system/index.html
@@ -0,0 +1,470 @@
+---
+title: Creating Custom Firefox Extensions with the Mozilla Build System
+slug: >-
+ Mozilla/Add-ons/Creating_Custom_Firefox_Extensions_with_the_Mozilla_Build_System
+translation_of: >-
+ Archive/Add-ons/Creating_Custom_Firefox_Extensions_with_the_Mozilla_Build_System
+---
+<div class="note">
+ <strong>Note:</strong> All instructions in this article apply to the Mozilla 1.8 branch only (i.e. Firefox 1.5). I'll try to keep it up-to-date as the trunk changes, but you certainly should not assume that this will work with the 1.7 branch (i.e. Firefox 1.0) or older.</div>
+<p>There is a <a href="/en/Extensions" title="en/Extensions">wealth of material</a> on creating extensions for Firefox. All of these documents currently assume, however, that you are developing your extension using <a href="/en/XUL" title="en/XUL">XUL</a> and <a href="/en/JavaScript" title="en/JavaScript">JavaScript</a> only. For complex extensions, it may be necessary to create components in C++ that provide additional functionality. Reasons why you might want to include C++ components in your extension include:</p>
+<p>有大量如何创建扩展的资料, 但是这些文档都假定仅仅使用XUL和Javascript开发扩展. 对于复杂的扩展, 可能需要C++开发相关的功能代码. 下列原因可能使你想要在扩展中包括C++组件(Components):</p>
+<ul>
+ <li>Need for high-performance beyond what can be delivered by JavaScript code.</li>
+ <li>性能要求高, Javascript达不到要求</li>
+ <li>Use of third-party libraries written in C or C++.</li>
+ <li>需要使用第三方C/C++库</li>
+ <li>Use of Mozilla interfaces that are not exposed via <a href="/en/XPCOM" title="en/XPCOM">XPCOM</a> (e.g. <a href="/en/NSPR" title="en/NSPR">NSPR</a>).</li>
+ <li>使用Mozilla接口,不仅仅是XPCOM提供的接口</li>
+</ul>
+<p>This article describes how to set up the development environment for a large, complex Firefox extension with any or all of the above-mentioned requirements. The process of garnering this information has been somewhat painful due to the lack of published information on this topic, but has been assisted by the contributions of various members of the Mozilla development community, who have shown extraordinary patience in fielding ignorant newbie questions. I can’t stress enough that I’m far from a Mozilla expert, though I’m getting better. There may be much in this document that is inaccurate, misleading or just plain wrong. In fact, one of my goals in writing this is to fine-tune these instructions until they constitute a definite guide for hardcore hackers who want to extend the Firefox platform. If you’re one of the many people who know more about this than I do, your help in improving this article would be greatly appreciated.</p>
+<p>I should also stress that you do <em>not</em> have to build Mozilla or use the Mozilla build system if you want to create C++ components for Mozilla. If you are just looking to create an <a href="/en/XPCOM" title="en/XPCOM">XPCOM</a> component or two, this is probably overkill, and you might want to take a look at <a class="external" href="http://www.iosart.com/firefox/xpcom/">this guide</a> instead. On the other hand, if you are an experienced developer or team, and you know that you are going to build a large, complex extension, you would do well to consider the approach described in this article.</p>
+<p>One final note: I’ve only tried these techniques inside Firefox, but they’ll probably work more or less unchanged on other Gecko-based platforms like Thunderbird or Seamonkey. If someone can confirm this and/or provide guidelines for what’s different, I’ll update the article to incorporate this information.</p>
+<h3 id="Bambi_Meets_Mozilla(小鹿斑比遇见Mozilla)">Bambi Meets Mozilla(小鹿斑比遇见Mozilla)</h3>
+<p>None of this is for the faint of heart. In particular, the initial step involves building Mozilla, which is a huge - nay, gargantuan! - project. Many intelligent developers have been driven to the brink of insanity trying to build it for the first time. If you're not an experienced C++ developer, I wouldn’t even bother. Stick to JavaScript.</p>
+<p>(小鹿斑比小时候很胆小)其实这些并不适合胆小者. 尤其是, 第一步编译Mozilla, 那是庞大的 -- 非常非常巨大的 -- 项目. 在初次编译Mozilla时, 许多聪明的开发者都快被逼疯了. 如果你不是资深的C++开发者, 就别烦恼了, 继续玩Javascript.</p>
+<h4 id="On_Windows_Platforms">On Windows Platforms</h4>
+<p>The first time I built Mozilla I used <a href="/En/Developer_Guide/Build_Instructions/Windows_Prerequisites" title="En/Developer_Guide/Build_Instructions/Windows_Prerequisites">this guide</a>. I can’t even remember why anymore, but I got stuck in a number of places, and the whole affair ended up taking far longer than I originally expected. Much furniture was smashed, much hair torn out by the roots. Here’s a <a class="external" href="http://whereswalden.com/mozilla/msvcfree/">comprehensive looking guide</a> that’s gotten good reviews. Follow every step methodically and you’ll probably be alright. Focus on the fact that once you get the build working, it’ll probably work effortlessly from then on. Maybe.</p>
+<h4 id="On_Other_Platforms">On Other Platforms</h4>
+<p>On other platforms, namely Linux and MacOS, the process is much easier. All the tools for building are available built-in, and therefore all you have to do is run some commands in the terminal. You can find full instructions for almost any OS <a href="/En/Developer_Guide/Build_Instructions" title="En/Developer_Guide/Build_Instructions">here</a>.</p>
+<h3 id="Structuring_Your_Project(构造您的项目)">Structuring Your Project(构造您的项目)</h3>
+<p>Mozilla includes a number of complex extensions that are integrated into its build process. It has thus been necessary to solve all of the issues involved in creating and registering XPCOM components, building JAR files and manifests, installing the lot into the Firefox <code>extensions/</code> directory and so forth. So it behooves us to piggyback on this infrastructure to build our extension.</p>
+<p>First of all, think of a catchy name for your extension and create a directory with that name under the <code>/mozilla/extensions/</code> directory. Use only lowercase letters. You should see a bunch of other directories (<code>inspector/</code>, <code>reporter/</code> and so forth) at the same level in the build tree.</p>
+<p>Note that before actually building anything, the Mozilla build system invokes a configuration process that generates the actual makefiles used for the build from makefile templates called <code>Makefile.in</code>. The actual makefiles tend to be very similar or identical to the templates, but the extra flexibility gained from having the makefiles generated dynamically is one of the things that makes the build system so powerful.</p>
+<h4 id="Anatomy_of_a_Simple_C_Extension(分析一个简单的C扩展)">Anatomy of a Simple C++ Extension(分析一个简单的C++扩展)</h4>
+<p>We assume that you are using C++ to write XPCOM components that can be used either from other C++ components or from JavaScript. The process of creating a component is actually relatively straightforward when the Mozilla build system is used.</p>
+<p>In the simplest case, a component will consist of a single main directory with two subdirectories, <code>public/</code> and <code>src/</code>. The main directory and each subdirectory must contain a <code>Makefile.in</code> (from now on I’ll just refer to this file as a makefile although we know that it is actually used to generate the real makefile). This makefile says two things. First of all, it lists the subdirectories that make up the extension, so the build system knows where to look for additional makefiles. Secondly, it instructs the build system to create a new extension, rather than copying the components directly into Firefox’s binary directory. The main advantage of using an extension is that it is easy to package everything up and install it on another machine.</p>
+<p>So here’s your basic, plain-vanilla top-level makefile (<code>Makefile.in</code> in the main extension directory):</p>
+<pre>DEPTH = ../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = myextension
+
+DIRS = public src
+
+XPI_NAME = myextension
+INSTALL_EXTENSION_ID = myextension@mycompany.com
+XPI_PKGNAME = myextension
+
+DIST_FILES = install.rdf
+
+include $(topsrcdir)/config/rules.mk
+</pre>
+<p>A detailed description of the make process, describing the key features of this makefile, can be found <a href="/en/How_Mozilla's_build_system_works" title="en/How_Mozilla's_build_system_works">here</a>. <strong>MODULE</strong> and <strong>XPI_NAME</strong> are both set to the name of your extension; they should be repeated in all project makefiles so that all of the files land in the same place in the XPI staging area (see below). <strong>INSTALL_EXTENSION_ID</strong> is the unique ID of your extension. This can be a GUID, but the format shown above is prettier and, let’s face it, a lot easier to remember. You don’t have to provide an <strong>XPI_PKGNAME</strong>, but if you do an XPI file, suitable for distribution, is automatically created in the root of the XPI staging area (<code>/mozilla/$(MOZ_OBJDIR)/dist/xpi-stage/</code>).</p>
+<p>Every extension must include an <code>install.rdf</code> file that tells Firefox how to install it. This file should be located in the main extension directory and look something like this:</p>
+<pre>&lt;?xml version="1.0"?&gt;
+
+&lt;RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:em="http://www.mozilla.org/2004/em-rdf#"&gt;
+ &lt;Description about="urn:mozilla:install-manifest"&gt;
+ &lt;em:id&gt;myextension@mycompany.com&lt;/em:id&gt;
+ &lt;em:version&gt;0.1&lt;/em:version&gt;
+
+ &lt;em:targetApplication&gt;
+ &lt;!-- Firefox --&gt;
+ &lt;Description&gt;
+ &lt;em:id&gt;{ec8030f7-c20a-464f-9b0e-13a3a9e97384}&lt;/em:id&gt;
+ &lt;em:minVersion&gt;1.0+&lt;/em:minVersion&gt;
+ &lt;em:maxVersion&gt;1.0+&lt;/em:maxVersion&gt;
+ &lt;/Description&gt;
+ &lt;/em:targetApplication&gt;
+
+ &lt;!-- front-end metadata --&gt;
+ &lt;em:name&gt;My First Extension&lt;/em:name&gt;
+ &lt;em:description&gt;Just an example.&lt;/em:description&gt;
+ &lt;em:creator&gt;allpeers.com&lt;/em:creator&gt;
+ &lt;em:homepageURL&gt;http://www.allpeers.com/blog/&lt;/em:homepageURL&gt;
+ &lt;/Description&gt;
+&lt;/RDF&gt;
+</pre>
+<p>There's a <a href="/en/Install_Manifests" title="en/Install_Manifests">detailed description</a> of the format of the <code>install.rdf</code> file. Use the <strong>DIST_FILES</strong> variable in the makefile to tell <code>make</code> to copy the file into the extension directory and (optional) XPI file.</p>
+<h4 id="Public_Interfaces(公共接口)">Public Interfaces(公共接口)</h4>
+<p>The <code>public/</code> directory contains any interfaces that need to be accessed by other modules. These can be <a class="external" href="http://www.mozilla.org/scriptable/xpidl/idl-authors-guide/index.html">IDL</a> files describing <a href="/en/XPCOM" title="en/XPCOM">XPCOM</a> interfaces, which are used to generate normal C++ header files for inclusion in your source files. They can also be normal C++ header files that are to be used directly by other modules. The easiest way to accomplish the latter is to use inline implementations for all methods so you don’t have any additional linking dependencies. Otherwise you will have to link statically to your module if you use these public headers in other modules. Personally I would discourage this practice (among other things, static linking means the same code gets loaded more than once into memory, and the code won’t be available from JavaScript or other non-C++ languages) and encourage the use of XPCOM wherever possible.</p>
+<p>The makefile in the <code>public/</code> directory should follow this model:</p>
+<pre>DEPTH = ../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = myextension
+XPIDL_MODULE = myextension
+
+XPI_NAME = myextension
+
+EXPORTS = \
+ myHeader.h \
+ $(NULL)
+
+XPIDLSRCS = \
+ myIFirstComponent.idl \
+ myISecondComponent.idl \
+ $(NULL)
+
+include $(topsrcdir)/config/rules.mk
+</pre>
+<p><strong>XPIDL_MODULE</strong> is the name of the generated XPT file that contains type information about your <a class="external" href="http://www.mozilla.org/scriptable/xpidl/idl-authors-guide/index.html">IDL</a> interfaces. If you have multiple modules, make absolutely sure that you use a different value for <strong>XPIDL_MODULE</strong> for each one. Otherwise the first module’s XPT file will be overwritten by the second and you’ll get <strong>NS_ERROR_XPC_BAD_IID</strong> errors when you try to access its IDL interfaces from your code. The files under <strong>EXPORTS</strong> are copied directly to the <code>/mozilla/$(MOZ_OBJDIR)/dist/include/myextension/</code> directory and are thus accessible from other modules (the value of <strong>MOZ_OBJDIR</strong> is defined in <code>/mozilla/.mozconfig</code>). XPIDLSRCS are run through the IDL processor, and the generated C++ headers are copied into the same include directory. In addition, an XPT (type library) file is generated and placed in the <code>components/</code> subdirectory of your extension.</p>
+<h4 id="Source_Files(源文件)">Source Files(源文件)</h4>
+<p>Now it’s time to create the makefile and source files in the <code>src/</code> subdirectory. If you're implementing interfaces that you've described using IDL, the easiest way to do this is to leave the <code>src/</code> directory empty and run <code>make</code> on the <code>public/</code> directory only; this will be explained shortly.</p>
+<p>Then open the generated header file for your interface from <code>/mozilla/$(MOZ_OBJDIR)/dist/include/myextension/</code>. It contains stubs for the component .H and .CPP files that you can copy and paste into your implementation files. All you have to do is fill in the implementation stubs in the C++ file and you’re good to go.</p>
+<p>Here’s an example of the makefile you need to place into your <code>src</code> directory:</p>
+<pre class="eval">DEPTH = ../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+IS_COMPONENT = 1
+<a href="/en/MODULE" title="en/MODULE">MODULE</a> = myextension
+<a href="/en/LIBRARY_NAME" title="en/LIBRARY_NAME">LIBRARY_NAME</a> = myExtension
+<a href="/en/USE_STATIC_LIBS" title="en/USE_STATIC_LIBS">USE_STATIC_LIBS</a> = 1
+
+XPI_NAME = myextension
+
+REQUIRES = xpcom \
+ string \
+ $(NULL)
+
+<a href="/en/CPPSRCS" title="en/CPPSRCS">CPPSRCS</a> = \
+ myFirstComponent.cpp \
+ mySecondComponent.cpp \
+ myExtension.cpp \
+ $(NULL)
+
+include $(topsrcdir)/config/rules.mk
+
+<a href="/en/EXTRA_DSO_LDOPTS" title="en/EXTRA_DSO_LDOPTS">EXTRA_DSO_LDOPTS</a> += \
+ $(XPCOM_GLUE_LDOPTS) \
+ $(NSPR_LIBS) \
+ $(NULL)
+
+# <span class="highlightred">NOTE: If you are coding against the 1.8.0 branch (not 1.8 branch or trunk), the</span>
+# <span class="highlightred">above line won't work, due to linker flag issues.</span> Use the following
+# variables instead:
+#
+# EXTRA_DSO_LDOPTS += \
+# $(MOZ_COMPONENT_LIBS) \
+# $(NULL)
+#
+# Unfortunately, using MOZ_COMPONENT_LIBS links against xpcom_core, which means
+# your components will not work in future versions of Firefox.
+</pre>
+<p>The <code>REQUIRES</code> section tells <code>make</code> which modules your components uses. This causes the relevant subdirectories of <code>/mozilla/$(MOZ_OBJDIR)/dist/include/</code> to be added to the C++ compiler's include path. If you’re including Mozilla headers and the compiler isn’t finding them, it could well mean that you haven’t listed all of the necessary modules here. <code>CPPSRCS</code> lists the source files that need to be built.</p>
+<p>In this example, the first two files contain the implementation of the extension’s two components. The final file, <code>myExtension.cpp</code>, contains the code necessary to register these components, as described in the next section.</p>
+<h4 id="Registering_Your_Components(注册组件)">Registering Your Components(注册组件)</h4>
+<p>In order to use your components from other C++ modules and JavaScript, you first have to register them. To do this, your extension needs to implement a class that exposes the <code><a href="/en/XPCOM_Interface_Reference/nsIModule" title="en/XPCOM_Interface_Reference/nsIModule">nsIModule</a></code> interface, which has methods for accessing the components defined in a module. Luckily, this can be accomplished through the use of a few simple macros, so you don’t have to concern yourself with the messy details of what’s happening under the hood.</p>
+<p>The first step is to define a CID, contract ID and class name for each of your components. Place the following code (adapting the <strong>#defines</strong> accordingly) into the header of each component that you want to be able to instantiate using the component manager:</p>
+<pre>// {00000000-0000-0000-0000-000000000000}
+#define MYFIRSTCOMPONENT_CID \
+ { 0x00000000, 0x0000, 0x0000, \
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
+
+#define MYFIRSTCOMPONENT_CONTRACTID "@mycompany.com/myfirst;1"
+#define MYFIRSTCOMPONENT_CLASSNAME "My First Component"
+</pre>
+<p>Obviously you need to fill in the CID with a real GUID. Under Windows, this can be generated using <a class="external" href="http://www.microsoft.com/downloads/details.aspx?familyid=94551F58-484F-4A8C-BB39-ADB270833AFC">guidgen.exe</a>. Unix people can use uuidgen (comes standard with most unixes and Linux distros).</p>
+<p>Now create the <code>myExtension.cpp</code> file like so:</p>
+<pre>#include "nsXPCOM.h"
+
+#include "nsIGenericFactory.h"
+
+/**
+ * Components to be registered
+ */
+#include "myFirstComponent.h"
+#include "mySecondComponent.h"
+
+NS_GENERIC_FACTORY_CONSTRUCTOR(myFirstComponent)
+NS_GENERIC_FACTORY_CONSTRUCTOR(mySecondComponent)
+
+//----------------------------------------------------------
+
+static const nsModuleComponentInfo components[] =
+{
+ {
+ MYFIRSTCOMPONENT_CLASSNAME,
+ MYFIRSTCOMPONENT_CID,
+ MYFIRSTCOMPONENT_CONTRACTID,
+ myFirstComponentConstructor
+ },
+ {
+ MYSECONDCOMPONENT_CLASSNAME,
+ MYSECONDCOMPONENT_CID,
+ MYSECONDCOMPONENT_CONTRACTID,
+ mySecondComponentConstructor
+ },
+};
+
+NS_IMPL_NSGETMODULE(MyExtension, components)
+</pre>
+<p>The <strong>NS_IMPL_NSGETMODULE</strong> macro creates the appropriate module object providing access to all of the components listed in the <code><a href="/en/NsModuleComponentInfo" title="en/NsModuleComponentInfo">nsModuleComponentInfo</a></code> array.</p>
+<h4 id="Building_It(编译扩展)">Building It(编译扩展)</h4>
+<p>As mentioned above, you’ll probably want to build your extension immediately after creating your IDL files in order to generate the C++ stubs for your component implementations. I’m assuming that you’ve already built Firefox successfully. If not, return immediately to the beginning of this article and don’t come back til you have a functioning <code>firefox.exe</code>. Do not pass go. Do not collect $200.</p>
+<p>Still here? Okay, now we have to modify your <code>.mozconfig</code> (in the <code>/mozilla/</code> root directory) so that your extension is built along with Mozilla. Add the following line at the end of the file:</p>
+<pre>ac_add_options --enable-extensions=default,myextension
+</pre>
+<p>Now launch <code>make</code> from the Mozilla root:</p>
+<pre>make -f client.mk build
+</pre>
+<p>Even if you have an up-to-date Firefox build, you’ll have to wait a while for <code>make</code> to recurse over the entire Mozilla source tree looking for new stuff (on my machine, which is pretty fast, this takes a good 10-15 minutes). Eventually it will reach your extension and generate a bunch of stuff under <code>/mozilla/$(MOZ_OBJDIR)/</code>:</p>
+<ul>
+ <li>Exported header files and generated header files (from IDL) in <code>dist/include/myextension/</code></li>
+ <li>Static libraries for your modules in <code>dist/lib/</code> (in case other modules want to link statically to your stuff instead of using XPCOM).</li>
+ <li>XPI file in <code>dist/xpi-stage/myextension.xpi</code>.</li>
+ <li>Generated makefiles for your projects in <code>extensions/myextension/</code> (remember, we’re under <code>/mozilla/$(MOZ_OBJDIR)/</code>.</li>
+ <li>Everything else in <code><a class="link-mailto" href="mailto:dist/bin/extensions/myextension@mycompany.com" rel="freelink">dist/bin/extensions/myextension@mycompany.com</a>/</code>.</li>
+</ul>
+<p>A lot of this stuff won’t get created on this first pass since <code>make</code> will gag when it doesn’t find the source files for your components. Don’t worry about this; all you need are the generated header files that contain the C++ implementation stubs. Go back and flesh out the C++ implementation of your components so that the build can complete next time. Remember that you should never, ever modify any of these generated files. Always modify the files used to generate them and rerun <code>make</code>. There might be exceptions to this rule, but if you’re changing the generated files directly, you’re probably doing something wrong.</p>
+<p>The process of walking the entire Mozilla tree takes a long time. If you already have a Mozilla build, you can avoid this by creating a makefile for your extension directly. Go to the root of your $(MOZ_OBJDIR) and (from a bash-compatible shell) enter:</p>
+<pre class="eval">../build/autoconf/make-makefile extensions/myextension
+</pre>
+<p>If your $(MOZ_OBJDIR) is located outside your $(TOPSRCDIR), you'll need to do:</p>
+<pre class="eval">$(TOPSRCDIR)/build/autoconf/make-makefile -t $(TOPSRCDIR) extensions/myextension
+</pre>
+<p>in order for the script to know where your source is (it'll use the extension path you gave it relative to the current dir to figure out where you want your makefiles to go).</p>
+<p>This will generate the proper makefile for your extension. Whether you build the whole Mozilla tree or take this shortcut, you can build from now on by going to <code>/mozilla/$(MOZ_OBJDIR)/extensions/myextension/</code> and typing "make" on the command line. It should build your component without bothering with the rest of Mozilla. If everything works out, you’ll see your XPI file in the XPI staging area. You’ll also see the "exploded" version of the XPI (i.e. the unzipped directory structure) underneath <code>/mozilla/$(MOZ_OBJDIR)/dist/bin/extensions</code>. (If something goes wrong, figure out what, fix it and then come back here and add it to this article.)</p>
+<p>To make sure that the build really finished, launch Firefox and check that your extension is listed when you select Tools/Extensions. If you are using Firefox as your regular browser (and if you’re not, why not!?), you might be annoyed by the fact that you have to close regular Firefox before running your custom-built version. If so, try setting the <strong>MOZ_NO_REMOTE</strong> environment variable to "1" before running the development version of Firefox. You’ll also need to use a different profile for your development version:</p>
+<pre class="eval">firefox -P <em>development</em>
+</pre>
+<p>Where <em>development</em> is replaced with the name of the extra profile you’ve created. This will let you run both versions of Firefox simultaneously, saving you oodles of time over the course of the build/test cycle.</p>
+<h4 id="No_Place_Like_Chrome">No Place Like Chrome</h4>
+<p>Yippee-ki-yay! Now you have an extension that does, well, absolutely nothing. It’s time to do something with those groovy components that you’ve implemented and registered. The simplest way to do this is to write some <a href="/en/JavaScript" title="en/JavaScript">JavaScript</a> and <a href="/en/XUL" title="en/XUL">XUL</a> code. At this point, it would be very helpful to have a bit of experience <a href="/en/Extensions" title="en/Extensions">writing "regular" extensions</a> (i.e. without using custom C++ components). If you’ve never done this, I strongly recommend that you think of a cool idea for something simple that you’ve always wanted to tweak in Firefox and write it. Just displaying a new menu item that opens a "Hello, World!" dialog box would be already be a great exercise to get warmed up with.</p>
+<p>Assuming you know how to write XUL/JavaScript extensions, you’re aware that the most important stuff goes in the <code>chrome/</code> directory of your extension. Well, the fact that you’re also using C++ components doesn’t change that one whit. So now you need to create the normal <code>content/</code>, <code>locale/</code> and <code>skin/</code> directories in which to place your chrome files. Personally I like placing these directly under the root directory of my module, but I don’t suppose it makes any difference if you prefer putting them under a <code>chrome/</code> subdirectory or whatever. Let freedom reign!</p>
+<p>Once you’ve written the necessary chrome files (for instance, an overlay that adds a menu item to instantiate and use one of your components), you need to package them up as part of your extension. This is accomplished through the use of a <a href="/en/JAR_Manifests" title="en/JAR_Manifests">JAR Manifest</a>. For our simple extension example, this file might look something like this:</p>
+<pre>myextension.jar:
+% content myextension %content/
+% locale myextension en-US %locale/en-US/
+% skin myextension classic/1.0 %skin/classic/
+% overlay chrome://browser/content/browser.xul chrome://myextension/content/MyExtensionOverlay.xul
+ content/MyExtensionOverlay.js (content/MyExtensionOverlay.js)
+ content/MyExtensionOverlay.xul (content/MyExtensionOverlay.xul)
+ locale/en-US/MyExtension.dtd (locale/en-US/MyExtension.dtd)
+ locale/en-US/MyExtension.properties (locale/en-US/MyExtension.properties)
+ skin/classic/MyExtension.css (skin/classic/MyExtension.css)
+</pre>
+<p>Place this code in a file called <code>jar.mn</code> in the root directory of your extension, making sure that the paths in parentheses point to actual files (when interpreted relative to the root directory). You also have to make one small change to the makefile in the same directory, adding the following line:</p>
+<pre class="eval">USE_EXTENSION_MANIFEST = 1
+</pre>
+<p>This tells <code>make</code> to create a single manifest file called <code>chrome.manifest</code> instead of creating separate manifests with goofy names for each package.</p>
+<p>Now launch <code>make</code> again, and you should see a <code>chrome</code> subdirectory appear in your extension (<code>/mozilla/$(MOZ_OBJDIR)<a class="link-mailto" href="mailto:/dist/bin/extensions/myextension@mycompany.com" rel="freelink">/dist/bin/extensions/myextension@mycompany.com</a>/</code>). Note that the <code>chrome</code> directory contains a JAR (i.e. ZIP) file with all the chrome files listed in <code>jar.mn</code> as well as a complete directory structure mirroring that of the JAR file. The directory structure, however, is empty. Why? I don’t know. Don’t worry about this, the files in the JAR are the ones that are actually used.</p>
+<h4 id="Keeping_it_Complex">Keeping it Complex</h4>
+<p>If you’re developing a really complex extension with lots of <a href="/en/XPCOM" title="en/XPCOM">XPCOM</a> components, you’ll probably want to divide your code up into smaller modules.</p>
+<h5 id="Kinda_Sorta_Complex_Extensions">Kinda, Sorta Complex Extensions</h5>
+<p>For a moderately complex extension, it’s probably enough just to subdivide the code into a single level of modules. Let’s assume that you have a <code>base/</code> module that defines a bunch of basic XPCOM components and an <code>advanced/</code> module that defines some chrome as well as other components that use the basic components. Your complete directory structure will look something like this:</p>
+<ul>
+ <li>myextension
+ <ul>
+ <li>base
+ <ul>
+ <li>public</li>
+ <li>src</li>
+ </ul>
+ </li>
+ <li>advanced
+ <ul>
+ <li>content</li>
+ <li>locale
+ <ul>
+ <li>en-US</li>
+ <li>...other locales...</li>
+ </ul>
+ </li>
+ <li>public</li>
+ <li>skin
+ <ul>
+ <li>classic</li>
+ <li>...other skins...</li>
+ </ul>
+ </li>
+ <li>src</li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+</ul>
+<p>Other than that, nothing really changes. The makefiles in the <code>base/</code> and <code>advanced/</code> directories should look more or less like your original root makefile, remembering to change the <strong>DEPTH</strong> variable to account for the fact that they’ve moved a level further away from the Mozilla root. You also need to remove the <strong>DIST_FILES</strong> variable since that’s going to be in the top-level makefile. Every makefile that generates anything should define the <strong>XPI_NAME</strong> variable to make sure generated files go into your extension and not into the global <code>components/</code> directory. In fact, just define this in every makefile to be safe. You can use the same <strong>MODULE</strong> in both <code>base/</code> and <code>advanced/</code> so that all the generated include files go into the same directory, but make sure that you don’t use the same <strong>XPIDL_MODULE</strong> in the two <code>public/</code> directories or one of the component type libraries (i.e. XPT files) will overwrite the other one and all hell will break loose.</p>
+<p>Each module must also have a different value for the <strong>LIBRARY_NAME</strong> variable. This is the name of the generated dynamic library, so if we call the libraries "myBase" and "myAdvanced", we’ll end up with <code>myBase.dll</code> and <code>myAdvanced.dll</code> (on Windows, at least). And each of these modules is going to have a separate C++ file for registering components. So there will be two files that look like <code>myExtension.cpp</code> in the original example, say <code>Base.cpp</code> and <code>Advanced.cpp</code>. Finally, each module will obviously have its own <code>jar.mn</code>, though they can reference the same JAR filename and package name if you want all the chrome files to be organized in a single JAR file and package. The only file that really stays put is <code>install.rdf</code>, which still exists once and only once in the extension root directory.</p>
+<p>As for the top-level makefile, it will now look like this:</p>
+<pre>DEPTH = ../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = myextension
+
+DIRS = base advanced
+
+XPI_NAME = myextension
+INSTALL_EXTENSION_ID = myextension@mycompany.com
+XPI_PKGNAME = myextension
+
+DIST_FILES = install.rdf
+
+include $(topsrcdir)/config/rules.mk
+</pre>
+<h5 id="Seriously_Complex_Extensions">Seriously Complex Extensions</h5>
+<p>At some point, even a single module may grow to the point where you want to divide it further into submodules. The difference between having separate modules and having a single module with separate submodules is that the submodules all share the same file for registering components (the famous <code>myExtension.cpp</code> file), and when compiled they create a single dynamic library. The decision to split a module into submodules is all about code organization; it doesn’t really affect the final product at all.</p>
+<p>To split a module into submodules, first create a subdirectory for each submodule. Then create an additional directory called <code>build/</code>. Each submodule will be configured to create a static library, and the <code>build/</code> directory will pull these libraries together to create a single dynamic component library. Confused? Here’s an example, showing just the <code>advanced/</code> subbranch of the <code>myextension/</code> directory:</p>
+<ul>
+ <li>advanced
+ <ul>
+ <li>build</li>
+ <li>intricate
+ <ul>
+ <li>public</li>
+ <li>src</li>
+ </ul>
+ </li>
+ <li>multifarious
+ <ul>
+ <li>public</li>
+ <li>src</li>
+ </ul>
+ </li>
+ <li>content</li>
+ <li>locale
+ <ul>
+ <li>en-US</li>
+ <li>...other locales...</li>
+ </ul>
+ </li>
+ <li>skin
+ <ul>
+ <li>classic</li>
+ <li>...other skins...</li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+</ul>
+<p>As you can see, we’ve split <code>advanced/</code> into two submodules: <code>intricate/</code> and <code>multifarious/</code>, and we’ve added an additional <code>build/</code> subdirectory. We’ve left the chrome directories directly under <code>advanced/</code>, since they aren’t tied to any specific submodule. This means that <code>jar.mn</code> will stay in the same place.</p>
+<p>The <code>intricate/</code> and <code>multifarious/</code> makefiles will look a lot like the original <code>advanced/</code> makefile, but we’ll need to tweak them a bit. As always, we have to adjust the <strong>DEPTH</strong> variable since the makefiles are deeper in the directory structure. And we should change the <strong>LIBRARY_NAME</strong> to indicate that we’re generating a static library for each submodule. By convention the "_s" suffix is used for this purpose. So let’s call them "myIntricate_s" and "myMultifarious_s". Finally, we define the variable <strong>FORCE_STATIC_LIB</strong>, resulting in a makefile that starts something like this:</p>
+<pre>DEPTH = ../../../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = myextension
+LIBRARY_NAME = myIntricate_s
+FORCE_STATIC_LIB = 1
+USE_STATIC_LIBS = 1
+
+XPI_NAME = myextension
+
+...more stuff here...
+</pre>
+<p>The <code>build</code> makefile pulls together the static libraries generated by the submodules and creates a single (dynamic) component library:</p>
+<pre>DEPTH = ../../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+IS_COMPONENT = 1
+MODULE = myextension
+LIBRARY_NAME = myAdvanced
+USE_STATIC_LIBS = 1
+
+XPI_NAME = myextension
+
+DEFINES += XPCOM_GLUE
+
+SHARED_LIBRARY_LIBS = \
+ $(DIST)/lib/$(LIB_PREFIX)myIntricate_s.$(LIB_SUFFIX) \
+ $(DIST)/lib/$(LIB_PREFIX)myMultifarious_s.$(LIB_SUFFIX) \
+ $(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
+ $(DIST)/lib/$(LIB_PREFIX)xpcom.$(LIB_SUFFIX) \
+ $(DIST)/lib/$(LIB_PREFIX)nspr4.$(LIB_SUFFIX) \
+ $(DIST)/lib/$(LIB_PREFIX)plds4.$(LIB_SUFFIX) \
+ $(DIST)/lib/$(LIB_PREFIX)plc4.$(LIB_SUFFIX) \
+ $(NULL)
+
+REQUIRES = \
+ xpcom \
+ string \
+ $(NULL)
+
+CPPSRCS = \
+ Advanced.cpp \
+ $(NULL)
+
+include $(topsrcdir)/config/rules.mk
+
+LOCAL_INCLUDES += \
+ -I$(srcdir)/../intricate/src \
+ -I$(srcdir)/../multifarious/src \
+ $(NULL)
+</pre>
+<p>The makefile in the <code>advanced/</code> directory should list the <code>intricate/</code>, <code>multifarious/</code> and <code>build/</code> directories in its <strong>DIRS</strong> variable. Make sure that <code>build/</code> comes last since it can’t create the component library until the other makefiles have completed.</p>
+<h3 id="Other_Topics">Other Topics</h3>
+<h4 id="Adding_Data_Files_to_Your_Extensions">Adding Data Files to Your Extensions</h4>
+<p>In some cases, you may wish to include additional files in your extension that don’t belong in the <code>chrome/</code> subdirectory. Examples might be database files or XML schemas. This can be achieved by adding a custom step to your makefile that copies the files from the source tree into the extension’s target directory.</p>
+<h5 id="Copying_Data_Files_Into_Target_Directory">Copying Data Files Into Target Directory</h5>
+<p>Let’s say that you have some data files containing statistical information that you want to include in your extension and make available to your components. You’ve placed these files, which have the extension .TXT, into a <code>stats/</code> subdirectory under your extension directory in the source tree. The following makefile rule can be used to copy these files into the final target directory of the extension:</p>
+<pre>export::
+ if test ! -d $(FINAL_TARGET)/stats; then \
+ $(NSINSTALL) -D $(FINAL_TARGET)/stats; \
+ fi
+ $(INSTALL) $(srcdir)/*.txt $(FINAL_TARGET)/stats
+</pre>
+<h5 id="Accessing_Data_Files_From_Components">Accessing Data Files From Components</h5>
+<p>The trick to accessing your data files is to figure out where the home directory of your extension is. Rumor has it that at some future date, this will possible through the <code><a href="/en/XPCOM_Interface_Reference/nsIExtensionManager" title="en/XPCOM_Interface_Reference/nsIExtensionManager">nsIExtensionManager</a></code> interface or something similar. In the meantime, there is a simple and reliable hack that can be used to achieve this. In the implementation of any JavaScript XPCOM component, there is a special <strong>__LOCATION__</strong> (two leading and two trailing underscores) symbol that points to the component’s implementation file. So you can write a simple component which deduces the root directory of your extensions by extrapolating from its location.</p>
+<p><a class="external" href="http://www.builderau.com.au/program/soa/Creating_XPCOM_components_with_JavaScript/0,39024614,39206503,00.htm">This article</a> explains how to create an XPCOM component in JavaScript. You’ll need an IDL file for an interface that looks something like this:</p>
+<pre>interface myILocation : nsISupports
+{
+ readonly attribute nsIFile locationFile;
+};
+</pre>
+<p>Place the IDL file in the <code>public/</code> directory of your project or subproject. In the <code>src/</code> directory, place the JavaScript file that implements the component. The component implementation will include the methods for retrieving the path or file for the extension’s home directory:</p>
+<pre>myLocation.prototype =
+{
+ QueryInterface: function(iid)
+ {
+ if (iid.equals(nsISupports))
+ return this;
+ if (iid.equals(myILocation))
+ return this;
+
+ Components.returnCode = Components.results.NS_ERROR_NO_INTERFACE;
+ return null;
+ },
+
+ get locationFile()
+ {
+ return __LOCATION__.parent.parent;
+ }
+}
+</pre>
+<p>This assumes that the component resides in a subdirectory of the extension directory (by convention, this directory is called <code>components/</code>). The <code>parent</code> property of <strong>__LOCATION__</strong> returns the <code>components/</code>, and the <code>parent</code> of this is the extension directory.</p>
+<p>The last step is to modify the makefile of the source directory where you placed your JavaScript file so that it is copied into the appropriate location in the extension:</p>
+<pre>export::
+ $(INSTALL) $(srcdir)/*.js $(FINAL_TARGET)/components
+</pre>
+<p>Now you can instantiate an instance of this component and use the <code>locationFile</code> property to get an <code><a href="/en/XPCOM_Interface_Reference/nsIFile" title="en/XPCOM_Interface_Reference/nsIFile">nsIFile</a></code> interface that points to your extension’s home directory.</p>
+<h4 id="Using_Third-Party_Libraries">Using Third-Party Libraries</h4>
+<p>For more sophisticated extensions, you may want to integrate third-party libraries that provide specialized functionality for database connectivity, image processing, networking and the like. If you want your extension to run on all Firefox platforms, you will need to have the source code for the library in question, so I assume that this is available.</p>
+<p>The most convenient approach from the perspective of the development cycle is to create a Mozilla-style makefile for the library. This works well for libraries that have a straightforward make process without extensive configuration. A good example of this is the SQLite library included in the Mozilla build tree at <code>db/sqlite</code>. By adapting the makefile in this way, the library is created as part of the standard Mozilla build process, which eliminates additional build steps. The downside is that you will need to update the modified makefile any time a new version of the library is released.</p>
+<p>For libraries that have complex configuration processes, use a non-standard compiler or have other special characteristics, it may be unfeasible to create a Mozilla-compliant makefile. In this case, I would recommend placing the entire library distribution inside the project or subproject that uses it. So if library <code>acmelib</code> is used inside the <code>multifarious/</code> subproject in the above example, it would be placed as a subdirectory underneath that subproject (at the same level as <code>public/</code> and <code>src/</code>).</p>
+<p>Of course, this means that you will have to build <code>acmelib</code> manually on all platforms before launching the Mozilla build. But at least you can then refer to include files and import libraries from your component using relative paths.</p>
+<h4 id="Building_for_Multiple_Platforms">Building for Multiple Platforms</h4>
+<p>TODO</p>
+<div class="originaldocinfo">
+ <h2 id="Original_Document_Information">Original Document Information</h2>
+ <ul>
+ <li>Author: Matthew Gertner - July 26, 2005.</li>
+ <li>Permission granted to migrate in Jan 2006, including permission to relicense under the CC:By-SA.</li>
+ <li>Original Source: <a class="external" href="http://www.allpeers.com/blog/creating-complex-firefox-extensions/" rel="freelink">http://www.allpeers.com/blog/creatin...ox-extensions/</a></li>
+ </ul>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/add-ons/creating_opensearch_plugins_for_firefox/index.html b/files/zh-cn/mozilla/add-ons/creating_opensearch_plugins_for_firefox/index.html
new file mode 100644
index 0000000000..b03cc689c9
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/creating_opensearch_plugins_for_firefox/index.html
@@ -0,0 +1,159 @@
+---
+title: 为 Firefox 创建 OpenSearch 插件
+slug: Mozilla/Add-ons/Creating_OpenSearch_plugins_for_Firefox
+translation_of: Web/OpenSearch
+---
+<p>{{ fx_minversion_header("2") }}</p>
+<p><a href="/en/Firefox_2_for_developers" title="en/Firefox_2_for_developers">Firefox 2</a> 支持使用 <a class="external" href="http://opensearch.org/">OpenSearch</a> 格式开发搜索引擎插件. 使用 <a class="external" href="http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_document">OpenSearch 格式</a>开发能够在IE 7 以及 Firefox上实现兼容. 这是这种语法被推荐使用的原因.</p>
+<p>Firefox 也支持不被包括在 <a class="external" href="http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_document">OpenSearch格式</a>  中的其它的搜索功能,例如搜索建议(search suggestion)以及 <code>SearchForm</code> 元素. 这篇文章主要关注创建与OpenSearch格式兼容的支持额外的firefox特殊特征的搜索插件.</p>
+<p>OpenSearch 描述文件也能被如在 <a href="#Autodiscovery_of_search_plugins">Autodiscovery of search plugins</a>  中描述的一样被advertised(道歉这里不知如何翻译) ,并且能够如在 <a href="/en/Adding_search_engines_from_web_pages" title="en/Adding_search_engines_from_web_pages">Adding search engines from web pages</a>中所说的进行编程安装.</p>
+<h2 id="OpenSearch_描述文件">OpenSearch 描述文件</h2>
+<p>遵循以下的模板,你就会发现通过 XML 文件写一个搜索引擎实际上是如此的简单。 粗体字部分需要根据具体你所写的搜索引擎需要来进行定制 。</p>
+<pre class="brush: xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+&lt;OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
+ xmlns:moz="http://www.mozilla.org/2006/browser/search/"&gt;
+ &lt;ShortName&gt;<strong>engineName</strong>&lt;/ShortName&gt;
+ &lt;Description&gt;<strong>engineDescription</strong>&lt;/Description&gt;
+ &lt;InputEncoding&gt;<strong>inputEncoding</strong>&lt;/InputEncoding&gt;
+ &lt;Image width="16" height="16" type="image/x-icon"&gt;data:image/x-icon;base64,<strong>imageData</strong>&lt;/Image&gt;
+ &lt;Url type="text/html" method="<strong>method</strong>" template="<strong>searchURL</strong>"&gt;
+ &lt;Param name="<strong>paramName1</strong>" value="<strong>paramValue1</strong>"/&gt;
+ ...
+ &lt;Param name="<strong>paramNameN</strong>" value="<strong>paramValueN</strong>"/&gt;
+ &lt;/Url&gt;
+ &lt;Url type="application/x-suggestions+json" template="<strong>suggestionURL</strong>"/&gt;
+ &lt;moz:SearchForm&gt;<strong>searchFormURL</strong>&lt;/moz:SearchForm&gt;
+&lt;/OpenSearchDescription&gt;</pre>
+<dl>
+ <dt>
+ <strong>ShortName</strong></dt>
+ <dd>
+ 对搜索引擎的简称</dd>
+ <dd>
+ <strong>限制:</strong> 名称仅能包含16个字符以下的纯文本. 名称不能包含HTML标志或其他标志.</dd>
+</dl>
+<dl>
+ <dt>
+ <strong>Description</strong></dt>
+ <dd>
+ 对于搜索引擎的简单描述</dd>
+ <dd>
+ <strong>限制:</strong> 描述仅能包含少于1024个字符的纯文本.  名称不能包含HTML标志或其他标志.</dd>
+</dl>
+<dl>
+ <dt>
+ <strong>InputEncoding</strong></dt>
+ <dd>
+ 向搜索引擎所输内容的字符编码.例如: <code>&lt;InputEncoding&gt;UTF-8&lt;/InputEncoding&gt;</code>.</dd>
+</dl>
+<dl>
+ <dt>
+ <strong>Image</strong></dt>
+ <dd>
+ 使用指向一个图标的URL来代表这个搜索引擎. 可能的话, 应提供16x16大小的"image/x-icon"类型的图像以及一个64x64大小的 "image/jpeg" 或 "image/png"类型的图像. 链接也可以使用 <a class="external" href="http://en.wikipedia.org/wiki/Data:_URI_scheme">data: URI scheme</a>.  <a class="external" href="http://software.hixie.ch/utilities/cgi/data/data">The data: URI kitchen</a>在这能找到一个能有效地帮助你构建写在此处的数据的工具.
+ <pre class="eval">&lt;Image height="16" width="16" type="image/x-icon"&gt;<a class="external" href="http://example.com/favicon.ico" rel="freelink">http://example.com/favicon.ico</a>&lt;/Image&gt;
+  OR
+&lt;Image height="16" width="16"&gt;data:image/x-icon;base64,AAABAAEAEBAAA ... DAAA=&lt;/Image&gt;
+</pre>
+ Firefox以base64编码的data: URI (搜索插件被保存在 profile中的 "searchplugins" 文件夹) 缓存此图标. 当这完成时, http: URIs 被改变为 data: URIs.</dd>
+</dl>
+<dl>
+ <dt>
+ <strong>Url</strong></dt>
+ <dd>
+ 描述用来实现搜索请求的一个或多个URL.  <code>method</code> 属性决定使用 <code>GET</code> 还是 <code>POST</code>请求来获取返回的数据. <code>template</code> 属性指定实现搜索请求的 URL.</dd>
+ <dd>
+ <div class="note">
+ <strong>注意:</strong> IE7 不支持 <code>POST</code> 请求.</div>
+ </dd>
+</dl>
+<dl>
+ <dd>
+ 这是两种firefox支持的URL类型:</dd>
+</dl>
+<ul>
+ <li><code>type="text/html"</code> 用来指定进行搜索查询的URL.</li>
+ <li><code>type="application/x-suggestions+json"</code> 用来指定获取搜索建议(search suggestions)的URL.</li>
+</ul>
+<dl>
+ <dd>
+ 这两种URL任何一种你都能使用 <code>{searchTerms}</code>来替换用户在搜索栏中输入的搜索内容. 其他支持的动态搜索参数可见 <a class="external" href="http://www.opensearch.org/Specifications/OpenSearch/1.1/Draft_3#OpenSearch_1.1_parameters">OpenSearch 1.1 parameters</a>.</dd>
+</dl>
+<dl>
+ <dd>
+ 对使用搜索建议查询来说,  URL template用来获取JSON格式的建议列表. 若需要知道关于如何在服务器上实现搜索建议支持, 请见 <a href="/en/Supporting_search_suggestions_in_search_plugins" title="en/Supporting_search_suggestions_in_search_plugins">Supporting search suggestions in search plugins</a>.</dd>
+</dl>
+<p><img alt="Image:SearchSuggestionSample.png" class="internal" src="/@api/deki/files/358/=SearchSuggestionSample.png"></p>
+<dl>
+ <dt>
+ <strong>Param</strong></dt>
+ <dd>
+ 这个参数用来包括那些需要和搜索查询一起被传递的作为键值对的参数.<code> 你能使用{searchTerms}</code>来指代用户输入的搜索条目.</dd>
+ <dd>
+ <div class="note">
+ <strong>注意:</strong> IE7不支持此元素.</div>
+ </dd>
+</dl>
+<dl>
+ <dt>
+ <strong>SearchForm</strong></dt>
+ <dd>
+ 跳往搜索页的 URL. 这使得Firefox能让用户直接浏览目的网站.</dd>
+ <dd>
+ <div class="note">
+ <strong>注意:</strong> 这个元素是firefox限定的, 并不是 OpenSearch 的一部分, 我们在例子中使用 "<code>moz:</code>" XML命名前缀来确保其它的不支持此元素的用户代理能安全地忽略此元素.</div>
+ </dd>
+</dl>
+<h2 id="自动搜寻搜索插件">自动搜寻搜索插件</h2>
+<p>提供搜索插件的网站能宣传自己以使firefox使用者能容易地下载并安装此插件.</p>
+<p>要支持自动搜寻 你仅需在 你网页的<code>&lt;head&gt;</code> 中加上一条:</p>
+<pre class="eval">&lt;link rel="search" type="application/opensearchdescription+xml" title="<em>searchTitle</em>" href="<em>pluginURL</em>"&gt;
+</pre>
+<p>斜体字部分解释如下:</p>
+<dl>
+ <dt>
+ <strong>searchTitle</strong></dt>
+ <dd>
+ 搜索的名称, 如 "Search MDC" or "Yahoo! Search". 这个值应该与你在插件文件中的ShortName相一致.</dd>
+</dl>
+<dl>
+ <dt>
+ <strong>pluginURL</strong></dt>
+ <dd>
+ 指向 XML搜索插件的URL, 能让浏览者下载插件.</dd>
+</dl>
+<p>如果你的网站提供多个插件, 你能为他们每一个都支持自动搜寻功能. 例如:</p>
+<pre class="eval">&lt;link rel="search" type="application/opensearchdescription+xml" title="MySite: By Author" href="<a class="external" href="http://www.mysite.com/mysiteauthor.xml" rel="freelink">http://www.mysite.com/mysiteauthor.xml</a>"&gt;
+&lt;link rel="search" type="application/opensearchdescription+xml" title="MySite: By Title" href="<a class="external" href="http://www.mysite.com/mysitetitle.xml" rel="freelink">http://www.mysite.com/mysitetitle.xml</a>"&gt;
+</pre>
+<p>这样,你的网站提供的插件就能同时以作者和名称分别作为搜索条目而被搜索.</p>
+<h2 id="为_OpenSearch_插件支持自动更新">为 OpenSearch 插件支持自动更新</h2>
+<p>{{ fx_minversion_note("3.5", "This section covers a feature introduced in Firefox 3.5.") }}</p>
+<p>从Firefox 3.5开始, OpenSearch 插件能够自动更新.  要支持这个, 需要包括一个额外的 "<code>application/opensearchdescription+xml</code>"类型<code>Url</code> 元素.  <code>rel</code>属性需要设为 "<code>self</code>" , template 属性需要是指向能自动更新的OpenSearch文档的 URL.</p>
+<p>例如:</p>
+<pre>&lt;Url type="application/opensearchdescription+xml"
+     rel="self"
+     template="http://www.foo.com/mysearchdescription.xml" /&gt;
+</pre>
+<div class="note">
+ <strong>注意:</strong>  <a class="external" href="http://addons.mozilla.org" title="http://addons.mozilla.org/">addons.mozilla.org</a> (AMO) 不支持 OpenSearch 插件的自动更新. 如果你想将你的插件发布在 AMO上, 你不应该使用自动更新.</div>
+<h2 id="排错指南">排错指南</h2>
+<p>如果你的搜索插件有错误, 当在firefox2中添加插件时会出错. 然而,错误信息可能并不是完全有所帮助的, 因此接下来的建议能帮你发现问题.</p>
+<ul>
+ <li>你的服务器应当运行使用MIME类型为<code>application/opensearchdescription+xml的</code> OpenSearch 插件.</li>
+ <li>确保你的搜索插件正确地格式化了. 你能通过直接将插件加载入firefox来检查.  template URL 中的&amp;符号需要使用 &amp;amp代替;标签需要以斜杠或是相匹配的结束标志结束。</li>
+ <li><code>xmlns</code>属性是很重要的, 没有了他你会得到 "Firefox could not download the search plugin from: (URL)"错误信息.</li>
+ <li>注意你必须包含一个 <code>text/html</code> URL — 仅包含 Atom 或 <a href="/en/RSS" title="en/RSS">RSS</a> URL 类型 (有效但firefox不支持)的插件将产生  "could not download the search plugin"错误.</li>
+ <li>远程获取的收藏夹图标大小不能超过10KB (见 {{ Bug(361923) }}).</li>
+</ul>
+<p>另外, 搜索插件服务提供了日志机制,这对于插件开发者来说可能能起到一定作用 . 使用 <em>about:config</em> 设定 '<code>browser.search.log</code>' 为 <code>true</code>. 插件被加载后日志信息将显示在火狐的 <a href="/en/Error_Console" title="en/Error_Console">Error Console</a> 中(Tools-&gt;Error Console).</p>
+<h2 id="参考资料">参考资料</h2>
+<ul>
+ <li><a class="external" href="http://opensearch.org/">OpenSearch Documentation</a>, <a class="external" href="http://www.opensearch.org/Specifications/OpenSearch/Extensions/Parameter/1.0">OpenSearch Documentation about the Url and Param element</a></li>
+ <li>Technorati.com has a <a class="external" href="http://technorati.com/osd.xml">working osd.xml</a></li>
+ <li>More on Autodiscovery difficulties at bugzilla {{ Bug(340208) }}</li>
+ <li><a class="external" href="http://en.wikipedia.org/wiki/Data:_URI_scheme"><code>data:</code> URI scheme</a></li>
+ <li><a class="external" href="http://www.searchplugins.net">searchplugins.net</a> - create OpenSearch plugins for use with Firefox 2. <a class="external" href="http://www.searchplugins.net/pluginlist.aspx">List of generated search plugins</a></li>
+ <li><a class="external" href="http://keijisaito.info/ready2search/e/">Ready2Search</a> - create OpenSearch plugins. <a class="external" href="http://keijisaito.info/arc/search/en_make_plugin.htm">Customized Search through Ready2Search</a></li>
+</ul>
+<p>{{ languages( { "es": "es/Creación_de_plugins_OpenSearch_para_Firefox", "de": "de/OpenSearch_Plugin_für_Firefox_erstellen", "ca": "ca/Creació_de_connectors_OpenSearch_per_al_Firefox", "fr": "fr/Création_de_plugins_OpenSearch_pour_Firefox", "ja": "ja/Creating_OpenSearch_plugins_for_Firefox", "pl": "pl/Tworzenie_wtyczek_OpenSearch_dla_Firefoksa", "pt": "pt/Criando_plugins_OpenSearch_para_o_Firefox" } ) }}</p>
diff --git a/files/zh-cn/mozilla/add-ons/creating_opensearch_plugins_for_firefox_clone/index.html b/files/zh-cn/mozilla/add-ons/creating_opensearch_plugins_for_firefox_clone/index.html
new file mode 100644
index 0000000000..5c511cc132
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/creating_opensearch_plugins_for_firefox_clone/index.html
@@ -0,0 +1,175 @@
+---
+title: 为 Firefox 创建 OpenSearch 插件
+slug: Mozilla/Add-ons/Creating_OpenSearch_plugins_for_Firefox_clone
+tags:
+ - 定制
+ - 搜索
+---
+<p>{{ fx_minversion_header("2") }}</p>
+
+<p><a href="/en/Firefox_2_for_developers" title="en/Firefox_2_for_developers">Firefox 2</a> 支持使用 <a class="external" href="http://opensearch.org/">OpenSearch</a> 格式开发搜索引擎插件. 使用 <a class="external" href="http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_document">OpenSearch 格式</a>开发能够在IE 7 以及 Firefox上实现兼容. 这是这种语法被推荐使用的原因.</p>
+
+<p>Firefox 也支持不被包括在 <a class="external" href="http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_document">OpenSearch格式</a>  中的其它的搜索功能,例如搜索建议(search suggestion)以及 <code>SearchForm</code> 元素. 这篇文章主要关注创建与OpenSearch格式兼容的支持额外的firefox特殊特征的搜索插件.</p>
+
+<p>OpenSearch 描述文件也能被如在 <a href="#Autodiscovery_of_search_plugins">Autodiscovery of search plugins</a>  中描述的一样被advertised(道歉这里不知如何翻译) ,并且能够如在 <a href="/en/Adding_search_engines_from_web_pages" title="en/Adding_search_engines_from_web_pages">Adding search engines from web pages</a>中所说的进行编程安装.</p>
+
+<h2 id="OpenSearch_描述文件">OpenSearch 描述文件</h2>
+
+<p>遵循以下的模板,你就会发现通过 XML 文件写一个搜索引擎实际上是如此的简单。 粗体字部分需要根据具体你所写的搜索引擎需要来进行定制 。</p>
+
+<pre class="brush: xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+&lt;OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
+ xmlns:moz="http://www.mozilla.org/2006/browser/search/"&gt;
+ &lt;ShortName&gt;<strong>engineName</strong>&lt;/ShortName&gt;
+ &lt;Description&gt;<strong>engineDescription</strong>&lt;/Description&gt;
+ &lt;InputEncoding&gt;<strong>inputEncoding</strong>&lt;/InputEncoding&gt;
+ &lt;Image width="16" height="16" type="image/x-icon"&gt;data:image/x-icon;base64,<strong>imageData</strong>&lt;/Image&gt;
+ &lt;Url type="text/html" method="<strong>method</strong>" template="<strong>searchURL</strong>"&gt;
+ &lt;Param name="<strong>paramName1</strong>" value="<strong>paramValue1</strong>"/&gt;
+ ...
+ &lt;Param name="<strong>paramNameN</strong>" value="<strong>paramValueN</strong>"/&gt;
+ &lt;/Url&gt;
+ &lt;Url type="application/x-suggestions+json" template="<strong>suggestionURL</strong>"/&gt;
+ &lt;moz:SearchForm&gt;<strong>searchFormURL</strong>&lt;/moz:SearchForm&gt;
+&lt;/OpenSearchDescription&gt;</pre>
+
+<dl>
+ <dt><strong>ShortName</strong></dt>
+ <dd>对搜索引擎的简称</dd>
+ <dd><strong>限制:</strong> 名称仅能包含16个字符以下的纯文本. 名称不能包含HTML标志或其他标志.</dd>
+</dl>
+
+<dl>
+ <dt><strong>Description</strong></dt>
+ <dd>对于搜索引擎的简单描述</dd>
+ <dd><strong>限制:</strong> 描述仅能包含少于1024个字符的纯文本.  名称不能包含HTML标志或其他标志.</dd>
+</dl>
+
+<dl>
+ <dt><strong>InputEncoding</strong></dt>
+ <dd>向搜索引擎所输内容的字符编码.例如: <code>&lt;InputEncoding&gt;UTF-8&lt;/InputEncoding&gt;</code>.</dd>
+</dl>
+
+<dl>
+ <dt><strong>Image</strong></dt>
+ <dd>使用指向一个图标的URL来代表这个搜索引擎. 可能的话, 应提供16x16大小的"image/x-icon"类型的图像以及一个64x64大小的 "image/jpeg" 或 "image/png"类型的图像. 链接也可以使用 <a class="external" href="http://en.wikipedia.org/wiki/Data:_URI_scheme">data: URI scheme</a>.  <a class="external" href="http://software.hixie.ch/utilities/cgi/data/data">The data: URI kitchen</a>在这能找到一个能有效地帮助你构建写在此处的数据的工具.
+ <pre class="eval">&lt;Image height="16" width="16" type="image/x-icon"&gt;<a class="external" href="http://example.com/favicon.ico" rel="freelink">http://example.com/favicon.ico</a>&lt;/Image&gt;
+  OR
+&lt;Image height="16" width="16"&gt;data:image/x-icon;base64,AAABAAEAEBAAA ... DAAA=&lt;/Image&gt;
+</pre>
+ Firefox以base64编码的data: URI (搜索插件被保存在 profile中的 "searchplugins" 文件夹) 缓存此图标. 当这完成时, http: URIs 被改变为 data: URIs.</dd>
+</dl>
+
+<dl>
+ <dt><strong>Url</strong></dt>
+ <dd>描述用来实现搜索请求的一个或多个URL.  <code>method</code> 属性决定使用 <code>GET</code> 还是 <code>POST</code>请求来获取返回的数据. <code>template</code> 属性指定实现搜索请求的 URL.</dd>
+ <dd>
+ <div class="note"><strong>注意:</strong> IE7 不支持 <code>POST</code> 请求.</div>
+ </dd>
+</dl>
+
+<dl>
+ <dd>这是两种firefox支持的URL类型:</dd>
+</dl>
+
+<ul>
+ <li><code>type="text/html"</code> 用来指定进行搜索查询的URL.</li>
+ <li><code>type="application/x-suggestions+json"</code> 用来指定获取搜索建议(search suggestions)的URL.</li>
+</ul>
+
+<dl>
+ <dd>这两种URL任何一种你都能使用 <code>{searchTerms}</code>来替换用户在搜索栏中输入的搜索内容. 其他支持的动态搜索参数可见 <a class="external" href="http://www.opensearch.org/Specifications/OpenSearch/1.1/Draft_3#OpenSearch_1.1_parameters">OpenSearch 1.1 parameters</a>.</dd>
+</dl>
+
+<dl>
+ <dd>对使用搜索建议查询来说,  URL template用来获取JSON格式的建议列表. 若需要知道关于如何在服务器上实现搜索建议支持, 请见 <a href="/en/Supporting_search_suggestions_in_search_plugins" title="en/Supporting_search_suggestions_in_search_plugins">Supporting search suggestions in search plugins</a>.</dd>
+</dl>
+
+<p><img alt="Image:SearchSuggestionSample.png" class="internal" src="/@api/deki/files/358/=SearchSuggestionSample.png"></p>
+
+<dl>
+ <dt><strong>Param</strong></dt>
+ <dd>这个参数用来包括那些需要和搜索查询一起被传递的作为键值对的参数.<code> 你能使用{searchTerms}</code>来指代用户输入的搜索条目.</dd>
+ <dd>
+ <div class="note"><strong>注意:</strong> IE7不支持此元素.</div>
+ </dd>
+</dl>
+
+<dl>
+ <dt><strong>SearchForm</strong></dt>
+ <dd>跳往搜索页的 URL. 这使得Firefox能让用户直接浏览目的网站.</dd>
+ <dd>
+ <div class="note"><strong>注意:</strong> 这个元素是firefox限定的, 并不是 OpenSearch 的一部分, 我们在例子中使用 "<code>moz:</code>" XML命名前缀来确保其它的不支持此元素的用户代理能安全地忽略此元素.</div>
+ </dd>
+</dl>
+
+<h2 id="自动搜寻搜索插件">自动搜寻搜索插件</h2>
+
+<p>提供搜索插件的网站能宣传自己以使firefox使用者能容易地下载并安装此插件.</p>
+
+<p>要支持自动搜寻 你仅需在 你网页的<code>&lt;head&gt;</code> 中加上一条:</p>
+
+<pre class="eval">&lt;link rel="search" type="application/opensearchdescription+xml" title="<em>searchTitle</em>" href="<em>pluginURL</em>"&gt;
+</pre>
+
+<p>斜体字部分解释如下:</p>
+
+<dl>
+ <dt><strong>searchTitle</strong></dt>
+ <dd>搜索的名称, 如 "Search MDC" or "Yahoo! Search". 这个值应该与你在插件文件中的ShortName相一致.</dd>
+</dl>
+
+<dl>
+ <dt><strong>pluginURL</strong></dt>
+ <dd>指向 XML搜索插件的URL, 能让浏览者下载插件.</dd>
+</dl>
+
+<p>如果你的网站提供多个插件, 你能为他们每一个都支持自动搜寻功能. 例如:</p>
+
+<pre class="eval">&lt;link rel="search" type="application/opensearchdescription+xml" title="MySite: By Author" href="<a class="external" href="http://www.mysite.com/mysiteauthor.xml" rel="freelink">http://www.mysite.com/mysiteauthor.xml</a>"&gt;
+&lt;link rel="search" type="application/opensearchdescription+xml" title="MySite: By Title" href="<a class="external" href="http://www.mysite.com/mysitetitle.xml" rel="freelink">http://www.mysite.com/mysitetitle.xml</a>"&gt;
+</pre>
+
+<p>这样,你的网站提供的插件就能同时以作者和名称分别作为搜索条目而被搜索.</p>
+
+<h2 id="为_OpenSearch_插件支持自动更新">为 OpenSearch 插件支持自动更新</h2>
+
+<p>{{ fx_minversion_note("3.5", "This section covers a feature introduced in Firefox 3.5.") }}</p>
+
+<p>从Firefox 3.5开始, OpenSearch 插件能够自动更新.  要支持这个, 需要包括一个额外的 "<code>application/opensearchdescription+xml</code>"类型<code>Url</code> 元素.  <code>rel</code>属性需要设为 "<code>self</code>" , template 属性需要是指向能自动更新的OpenSearch文档的 URL.</p>
+
+<p>例如:</p>
+
+<pre>&lt;Url type="application/opensearchdescription+xml"
+     rel="self"
+     template="http://www.foo.com/mysearchdescription.xml" /&gt;
+</pre>
+
+<div class="note"><strong>注意:</strong>  <a class="external" href="http://addons.mozilla.org" title="http://addons.mozilla.org/">addons.mozilla.org</a> (AMO) 不支持 OpenSearch 插件的自动更新. 如果你想将你的插件发布在 AMO上, 你不应该使用自动更新.</div>
+
+<h2 id="排错指南">排错指南</h2>
+
+<p>如果你的搜索插件有错误, 当在firefox2中添加插件时会出错. 然而,错误信息可能并不是完全有所帮助的, 因此接下来的建议能帮你发现问题.</p>
+
+<ul>
+ <li>你的服务器应当运行使用MIME类型为<code>application/opensearchdescription+xml的</code> OpenSearch 插件.</li>
+ <li>确保你的搜索插件正确地格式化了. 你能通过直接将插件加载入firefox来检查.  template URL 中的&amp;符号需要使用 &amp;amp代替;标签需要以斜杠或是相匹配的结束标志结束。</li>
+ <li><code>xmlns</code>属性是很重要的, 没有了他你会得到 "Firefox could not download the search plugin from: (URL)"错误信息.</li>
+ <li>注意你必须包含一个 <code>text/html</code> URL — 仅包含 Atom 或 <a href="/en/RSS" title="en/RSS">RSS</a> URL 类型 (有效但firefox不支持)的插件将产生  "could not download the search plugin"错误.</li>
+ <li>远程获取的收藏夹图标大小不能超过10KB (见 {{ Bug(361923) }}).</li>
+</ul>
+
+<p>另外, 搜索插件服务提供了日志机制,这对于插件开发者来说可能能起到一定作用 . 使用 <em>about:config</em> 设定 '<code>browser.search.log</code>' 为 <code>true</code>. 插件被加载后日志信息将显示在火狐的 <a href="/en/Error_Console" title="en/Error_Console">Error Console</a> 中(Tools-&gt;Error Console).</p>
+
+<h2 id="参考资料">参考资料</h2>
+
+<ul>
+ <li><a class="external" href="http://opensearch.org/">OpenSearch Documentation</a>, <a class="external" href="http://www.opensearch.org/Specifications/OpenSearch/Extensions/Parameter/1.0">OpenSearch Documentation about the Url and Param element</a></li>
+ <li>Technorati.com has a <a class="external" href="http://technorati.com/osd.xml">working osd.xml</a></li>
+ <li>More on Autodiscovery difficulties at bugzilla {{ Bug(340208) }}</li>
+ <li><a class="external" href="http://en.wikipedia.org/wiki/Data:_URI_scheme"><code>data:</code> URI scheme</a></li>
+ <li><a class="external" href="http://www.searchplugins.net">searchplugins.net</a> - create OpenSearch plugins for use with Firefox 2. <a class="external" href="http://www.searchplugins.net/pluginlist.aspx">List of generated search plugins</a></li>
+ <li><a class="external" href="http://keijisaito.info/ready2search/e/">Ready2Search</a> - create OpenSearch plugins. <a class="external" href="http://keijisaito.info/arc/search/en_make_plugin.htm">Customized Search through Ready2Search</a></li>
+</ul>
+
+<p>{{ languages( { "es": "es/Creación_de_plugins_OpenSearch_para_Firefox", "de": "de/OpenSearch_Plugin_für_Firefox_erstellen", "ca": "ca/Creació_de_connectors_OpenSearch_per_al_Firefox", "fr": "fr/Création_de_plugins_OpenSearch_pour_Firefox", "ja": "ja/Creating_OpenSearch_plugins_for_Firefox", "pl": "pl/Tworzenie_wtyczek_OpenSearch_dla_Firefoksa", "pt": "pt/Criando_plugins_OpenSearch_para_o_Firefox" } ) }}</p>
diff --git a/files/zh-cn/mozilla/add-ons/extension_frequently_asked_questions_move/index.html b/files/zh-cn/mozilla/add-ons/extension_frequently_asked_questions_move/index.html
new file mode 100644
index 0000000000..6b9e091642
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/extension_frequently_asked_questions_move/index.html
@@ -0,0 +1,35 @@
+---
+title: 扩展的常见问题解答
+slug: Mozilla/Add-ons/Extension_Frequently_Asked_Questions_move
+translation_of: Archive/Mozilla/Extension_Frequently_Asked_Questions
+---
+<p>这里是关于<a class="internal" href="/cn/%E6%89%A9%E5%B1%95" title="cn/扩展">扩展</a>开发中最常见问题的解答集锦。其中的绝大多数是关于 FireFox 的,但是大部分能够方便的移植到 SeaMonkey,Thunderbird 或其它 Mozilla 应用上。</p>
+<p>如果你还不知道怎么开始,可以先看看我们的教程:<a class="internal" href="/cn/%E6%9E%84%E5%BB%BA%E4%B8%80%E4%B8%AA%E6%89%A9%E5%B1%95" title="Cn/构建一个扩展">构建一个扩展</a>或者 <a class="external" href="http://kb.mozillazine.org/Getting_started_with_extension_development" title="http://kb.mozillazine.org/Getting_started_with_extension_development">MozillaZine 上的新手教程</a>。然后用<a class="external" href="http://ted.mielczarek.org/code/mozilla/extensionwiz/" title="http://ted.mielczarek.org/code/mozilla/extensionwiz/">扩展向导</a>创建一个供开始用的简单扩展。</p>
+<p>不要忘记先<a class="internal" href="/%E8%AE%BE%E7%BD%AE%E6%89%A9%E5%B1%95%E7%9A%84%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83" title="设置扩展的开发环境">设置好扩展的开发环境</a>。</p>
+<h2 id="调试">调试</h2>
+<p>调试之前先<a class="internal" href="/%E8%AE%BE%E7%BD%AE%E6%89%A9%E5%B1%95%E7%9A%84%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83" title="设置扩展的开发环境">设置扩展的开发环境</a>。</p>
+<p>如果调试的代码很复杂,可能会用到 <a class="internal" href="/cn/venkman" title="cn/Venkman">Venkman</a> JavaScript 调试器。在用 Venkman 调试扩展代码之前需要把 "Debug -&gt; Exclude Browser Files" 选项勾掉。</p>
+<h3 id="怎样记录代码中的错误?">怎样记录代码中的错误?</h3>
+<p>将<a class="internal" href="/%E8%AE%BE%E7%BD%AE%E6%89%A9%E5%B1%95%E7%9A%84%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83" title="设置扩展的开发环境"><strong>javascript.options.showInConsole</strong> 设为 <strong>true</strong></a>,这样错误就会被记录在<a class="internal" href="/cn/%E9%94%99%E8%AF%AF%E6%8E%A7%E5%88%B6%E5%8F%B0" title="cn/错误控制台">错误控制台</a>中,使得 bug 容易追踪些。</p>
+<h3 id="怎样显示扩展当前状态?">怎样显示扩展当前状态?</h3>
+<p>要想显示变量值,调试消息等,可以使用 alert(),dump() ,Components.utils.reportError() 或者控制台服务。当然也可以用 Venkman 调试器。</p>
+<h3 id="为什么我的脚本不能正确运行?">为什么我的脚本不能正确运行?</h3>
+<p>如果你的脚本不能如预期运行,第一个要检查的是错误控制台(参见#)。</p>
+<p>访问尚未加载完毕的 DOM 也常常是错误的来源。这种错误通常是因为初始化代码被放在程序顶层(即所有函数之外)。通过监听 <span style="font-family: Courier New;">load</span> 事件延期执行初始化代码可以解决这个问题(<span style="font-family: Courier New;">load</span> 事件表示窗口已经加载完毕):</p>
+<pre class="eval">function exampleBrowserStartup(event)
+{
+ // 初始化代码
+}
+window.addEventListener("load", exampleBrowserStartup, false);
+</pre>
+<p> </p>
+<h3 id="不能访问网页的文档(document)对象">不能访问网页的文档(document)对象</h3>
+<p>要从 browser.xul 这个 overlay 中访问当前网页,应当使用 <span style="font-family: Courier New;">content.document </span>而不是 <span style="font-family: Courier New;">document。这是因为 document 表示浏览器窗口自身。更多信息参考 <a class="internal" href="/en/Working_with_windows_in_chrome_code" title="En/Working with windows in chrome code">Working with windows in chrome code</a>。</span></p>
+<h3 id="无法在扩展中使用_XMLHttpRequest">无法在扩展中使用 XMLHttpRequest</h3>
+<p>使用 XMLHttpRequest 发送接收信息时,一般都需要做跨域(crosss domain)操作。 一般来说跨域很麻烦,但因为在 chrome 窗口内发起请求时,是在安全区域内的,所以请求会被默许。</p>
+<p>You need to make sure that you are initializing the cross domain XMLHttpRequest from JavaScript code that is referencing a XUL window. If you try and execute the request in relation to the browser content document, as opposed to the "document" of the XUL window, you will receive a Permission Denied error.</p>
+<h3 id="XML_文件是规范的,但是却出现_XML_解析错误!">XML 文件是规范的,但是却出现 XML 解析错误!</h3>
+<h3 id="示例代码">示例代码</h3>
+<h3 id="得到更多帮助">得到更多帮助</h3>
+<p> </p>
+<p> </p>
diff --git a/files/zh-cn/mozilla/add-ons/extension_packaging/index.html b/files/zh-cn/mozilla/add-ons/extension_packaging/index.html
new file mode 100644
index 0000000000..8057385c7c
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/extension_packaging/index.html
@@ -0,0 +1,38 @@
+---
+title: 扩展打包
+slug: Mozilla/Add-ons/Extension_Packaging
+tags:
+ - Extensions
+ - Toolkit API
+translation_of: Archive/Add-ons/Extension_Packaging
+---
+<p> </p>
+<p>扩展为一种<a href="cn/Bundles">可安装包</a>的形式,它可以由使用者下载并安装,或者是由外部程序或应用程序提供的预安装包。扩展使用<a href="cn/Bundles">目录结构</a>,此结构提供有chrome,components,和其他文件以扩展XUL程序的功能。</p>
+<p>每个扩展必须提供一个<a href="cn/Install.rdf">install.rdf</a>文件,包含关于扩展的元数据,例如唯一的ID,版本,作者,和兼容性信息。</p>
+<p>扩展文件和install.rdf准备好之后,有几种方法准备扩展以便安装:将扩展目录ZIP打包为用户可安装的<a href="cn/XPI">XPI</a>(xpinstall)文件,直接将扩展解开到用户程序或设置目录中,或将扩展注册到Windows注册表中。</p>
+<h3 id=".E5.88.B6.E4.BD.9C.E6.89.A9.E5.B1.95XPI" name=".E5.88.B6.E4.BD.9C.E6.89.A9.E5.B1.95XPI">制作扩展XPI</h3>
+<p>一个<a href="cn/XPI">XPI</a> (XPInstall) 文件就是一个简单的ZIP文件,包括了扩展文件,<a href="cn/Install.rdf">install.rdf</a>文件在ZIP的根目录中。使用者可以从网站上下载或者从本地安装XPI文件,将其打开或拖拽到扩展管理窗口。</p>
+<p>XPI文件的MIME类型被Firefox识别为
+ <i>
+ application/x-xpinstall</i>
+ ,因为大多数HTTP服务器不能够默认设置为将.xpi返回MIME类型。在Apache HTTP服务器上,可以在设置文件或.htaccess中增加以下命令来实现:</p>
+<pre class="eval">AddType application/x-xpinstall .xpi
+</pre>
+<h3 id=".E7.9B.B4.E6.8E.A5.E5.AE.89.E8.A3.85.E6.89.A9.E5.B1.95.E6.96.87.E4.BB.B6" name=".E7.9B.B4.E6.8E.A5.E5.AE.89.E8.A3.85.E6.89.A9.E5.B1.95.E6.96.87.E4.BB.B6">直接安装扩展文件</h3>
+<p>如果你知道程序的位置(例如,如果你作为应用程序安装者的角色来安装扩展),你可以直接将扩展文件安装到&lt;appdir&gt;/extensions/&lt;extensionID&gt;中。在下次程序启动的时候扩展管理器会自动找到此扩展。</p>
+<p>当使用此方法的时候你必须核实以确保系统允许扩展目录和文件正确设置。否则,扩展管理器在此扩展下不能够正确运行,或者扩展本身不能正确工作。</p>
+<h3 id=".E4.BD.BF.E7.94.A8Windows.E6.B3.A8.E5.86.8C.E8.A1.A8.E5.B7.A5.E5.85.B7.E6.B3.A8.E5.86.8C.E6.89.A9.E5.B1.95.E6.89.80.E5.9C.A8.E7.9B.AE.E5.BD.95" name=".E4.BD.BF.E7.94.A8Windows.E6.B3.A8.E5.86.8C.E8.A1.A8.E5.B7.A5.E5.85.B7.E6.B3.A8.E5.86.8C.E6.89.A9.E5.B1.95.E6.89.80.E5.9C.A8.E7.9B.AE.E5.BD.95">使用Windows注册表工具注册扩展所在目录</h3>
+<p>外部安装程序(例如Java虚拟机)也许希望将应用程序整合点作为扩展安装,即便是应用程序还没有安装。这可以在Windows中<a href="cn/Adding_Extensions_using_the_Windows_Registry">使用注册表</a>来完成。</p>
+<h3 id=".E5.A4.9A.E6.9D.A1.E7.9B.AE.E6.89.A9.E5.B1.95_XPIs" name=".E5.A4.9A.E6.9D.A1.E7.9B.AE.E6.89.A9.E5.B1.95_XPIs">多条目扩展 XPIs</h3>
+<p>在有些情况下也许希望用单独的XPI文件安装多个扩展/主题。一种特殊的扩展XPI称为<a href="cn/Multiple_Item_Packaging">多条目包</a>,用来解释如何创建此类型的扩展包。(需要Firefox 1.5/XULRunner 1.8。)</p>
+<h3 id="Toolkit_API.E7.9A.84.E5.AE.98.E6.96.B9.E5.8F.82.E8.80.83" name="Toolkit_API.E7.9A.84.E5.AE.98.E6.96.B9.E5.8F.82.E8.80.83"><a href="cn/Toolkit_API">Toolkit API</a>的官方参考</h3>
+<p>
+ </p><ul>
+ <li><a href="/en/Bundles" title="en/Bundles">Structure of an Installable Bundle</a>: describes the common structure of installable bundles, including extensions, themes, and XULRunner applications</li>
+ <li><a href="/en/Extension_Packaging" title="en/Extension_Packaging">Extension Packaging</a>: specific information about how to package extensions</li>
+ <li><a href="/en/Theme_Packaging" title="en/Theme_Packaging">Theme Packaging</a>: specific information about how to package themes</li>
+ <li><a href="/en/Multiple_Item_Packaging" title="en/Multiple_Item_Packaging">Multiple-item Extension Packaging</a>: specific information about multiple-item extension XPIs</li>
+ <li><a href="/en/XUL_Application_Packaging" title="en/XUL_Application_Packaging">XUL Application Packaging</a>: specific information about how to package XULRunner applications</li>
+ <li><a href="/en/Chrome_Registration" title="en/Chrome_Registration">Chrome Registration</a></li>
+ <li><a href="/en-US/docs/Mozilla/Tech/XUL/Printing">Printing in XUL Apps</a></li>
+ </ul>
diff --git a/files/zh-cn/mozilla/add-ons/index.html b/files/zh-cn/mozilla/add-ons/index.html
new file mode 100644
index 0000000000..90026e701c
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/index.html
@@ -0,0 +1,87 @@
+---
+title: 附加组件
+slug: Mozilla/Add-ons
+tags:
+ - Add-ons
+ - Extension
+ - Mozilla
+ - 扩展
+ - 附加组件
+translation_of: Mozilla/Add-ons
+---
+<div>{{AddonSidebar}}</div>
+
+<p>附加组件允许开发者们去扩展和修改 Firefox 的功能。开发者们能使用标准的 Web 技术「JavaScript,HTML 以及 CSS」再加上一些专用的 JavaScript APIs 来开发附加组件。除此之外,附加组件还能:</p>
+
+<ul>
+ <li>改变指定网站的外观或者内容</li>
+ <li>修改 Firefox 的用户界面</li>
+ <li>给 Firefox 加上新功能</li>
+</ul>
+
+<p>有几种附件组件类型,但最常见类型是扩展。</p>
+
+<h2 id="开发扩展">开发扩展</h2>
+
+<p>在过去,有几种工具集用于开发 Firefox 扩展,但是到 2017 年 11 月底,扩展必须使用 <a href="https://developer.mozilla.org/zh-CN/Add-ons/WebExtensions">WebExtensions APIs</a> 构建。其余工具集「包括 overlay add-ons、bootstrapped add-ons 和 Add-on SDK」将会同时被废弃。</p>
+
+<p>如果你在编写一个新的扩展,请使用 <a href="https://developer.mozilla.org/zh-CN/Add-ons/WebExtensions">WebExtensions APIs</a>。</p>
+
+<p>使用 Firefox WebExtensions APIs 编写的扩展设计为跨浏览器兼容。在大多数情况下它也能在 Chrome,Edge 和 Opera 中运行,几乎没有任何变化。它们也完全兼容多进程 Firefox。</p>
+
+<p><a href="https://developer.mozilla.org/zh-CN/Add-ons/WebExtensions/Browser_support_for_JavaScript_APIs">查看目前在火狐和其他浏览器中支持的 APIs</a>. 我们将继续设计并改进新的 API 以满足开发人员的需求。</p>
+
+<p>绝大多数的 WebExtensions APIs 对于 Firefox Android 版也是可用的。</p>
+
+<h3 id="迁移现有扩展">迁移现有扩展</h3>
+
+<p>如果你正在维护一个旧式扩展,比如 XUL overlay、bootstrapped,或者基于 Add-on SDK 的扩展,我们建议你使用 WebExtension APIs 移植它。这里有一些 <a href="https://developer.mozilla.org/zh-CN/Add-ons/WebExtensions/Porting_a_legacy_Firefox_add-on"> MDN 中的移植教程</a>。</p>
+
+<p style="position: relative; max-width: 400px; margin-bottom: 70px;">我们在 wiki 页面收集了一些<a href="https://wiki.mozilla.org/Add-ons/developer/communication">教程</a>来支持开发者们过渡。在开始之前,请使用兼容性<a href="https://compatibility-lookup.services.mozilla.com/">检测工具</a>来查看你的附加组件是否受影响。</p>
+
+<h2 id="发布附加组件">发布附加组件</h2>
+
+<p><a href="https://addons.mozilla.org">Addons.mozilla.org</a>,俗称 「AMO」,是 Mozilla 官方的官方站点, 方便开发者发布扩展组件和用户查找。通过上传附加组件到  AMO, 你可以加入我们的用户和开发者社区,为你的附加组件找到订阅者。</p>
+
+<p>你不需要在 AMO 上发布你的附加组件,但你的附加组件必须要经过 Mozilla 签名,否则用户不能安装它。</p>
+
+<p>为你发布的附加组件添加概述,请查看<a href="https://developer.mozilla.org/zh-CN/Add-ons/Distribution">签名和部署你的附加组件</a>。</p>
+
+<h2 id="其他类型的附加组件">其他类型的附加组件</h2>
+
+<p>通常,当人们谈起附加组件时是指扩展工具,但是这里也有一些其他类型的附加组件允许用户定制 Firefox.  这些附加组件包括:</p>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/Add-ons/Themes/Background">轻量主题</a> 是一种简单的方式来提供有限的 Firefox 定制;</li>
+ <li><a href="https://developer.mozilla.org/zh-CN/Add-ons/Firefox_for_Android">移动附加组件</a> 是给 Firefox 的 Android 版使用的。注意,虽然如此,我们仍打算弃用这些 API 依赖的一些技术。在将来,Firefox 的 Android 版将会在一定程度上完全支持 WebExtension APIs;</li>
+ <li><a href="https://developer.mozilla.org/zh-CN/docs/Creating_OpenSearch_plugins_for_Firefox">搜索引擎插件</a> 可以添加新的搜索引擎到浏览器的搜索栏;</li>
+ <li><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Creating_a_spell_check_dictionary_add-on">用户字典</a> 是可以进行各种语言的拼写检查的插件;</li>
+ <li><a href="https://support.mozilla.org/kb/use-firefox-interface-other-languages-language-pack">语言包</a> 让你有更多可用的语言用于Firefox的界面。</li>
+</ul>
+
+<h2 id="联系我们">联系我们</h2>
+
+<p>你可以从以下链接获得帮助,时刻关注关于附加组件的最新消息,并且给予我们反馈。</p>
+
+<h3 id="附加组件论坛">附加组件论坛</h3>
+
+<p>到 <a href="https://discourse.mozilla-community.org/c/add-ons">附加组件交流论坛</a> 讨论附加组件的任何方面并获得帮助。</p>
+
+<h3 id="邮件列表">邮件列表</h3>
+
+<p>通过 <strong>dev-addons</strong> 列表来讨论附加组件生态系统的发展,包括 WebExtensions 系统和 AMO。</p>
+
+<ul>
+ <li><a href="https://mail.mozilla.org/listinfo/dev-addons">dev-addons list info</a></li>
+ <li><a href="https://mail.mozilla.org/pipermail/dev-addons/">dev-addons archives</a></li>
+</ul>
+
+<h3 id="IRC">IRC</h3>
+
+<p>如果你更喜欢使用 IRC,你可以在以下 channel 和其他人交流:</p>
+
+<ul>
+ <li><a href="irc://irc.mozilla.org/addons">#addons</a> (附加组件生态系统的讨论)</li>
+ <li><a href="irc://irc.mozilla.org/extdev">#extdev</a> (附加组件的发展战略的讨论)</li>
+ <li><a href="irc://irc.mozilla.org/webextensions">#webextensions</a> (对WebExtensions具体的讨论)</li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/install_manifests/index.html b/files/zh-cn/mozilla/add-ons/install_manifests/index.html
new file mode 100644
index 0000000000..936ae3fb86
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/install_manifests/index.html
@@ -0,0 +1,363 @@
+---
+title: 安装清单
+slug: Mozilla/Add-ons/Install_Manifests
+tags:
+ - bug-840092
+ - bug-840092-dup
+translation_of: Archive/Add-ons/Install_Manifests
+---
+<h2 id="简介">简介</h2>
+<p>安装清单是一个附加文件,具有Add-on的XUL程序(例如火狐或者雷鸟),用这个文件来确定即将要安装的add-on的安装信息。他包含了add-on的元数据验证、创建者信息、add-on的详细介绍页面地址、版本号、如何更新、兼容性、等等。</p>
+<p>安装清单的格式是 RDF/XML.</p>
+<p>这个文件名字必须为 <code>install.rdf</code> 并且必须放在 XPI 文件的根目录。</p>
+<h2 id="结构">结构</h2>
+<p>安装清单的最基本结构如下:</p>
+<div style="overflow: hidden;">
+ <pre class="brush:xml;auto-links:false">&lt;?xml version="1.0"?&gt;
+
+&lt;RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:em="http://www.mozilla.org/2004/em-rdf#"&gt;
+ &lt;Description about="urn:mozilla:install-manifest"&gt;
+ &lt;!-- properties --&gt;
+ &lt;/Description&gt;
+&lt;/RDF&gt;
+</pre>
+</div>
+<p>有些属性是是必须的,有些是可选的。有些属性只是简单的字符串啥啥啥的,有些属性会很复杂。</p>
+<h2 id="必要的属性">必要的属性</h2>
+<p>你的清单必须要包含下面的这些属性,不听话的话,你的add-on是不会安装成功滴。</p>
+<h3 id="id">id</h3>
+<p>id是一个这样子的东东:</p>
+<ul>
+ <li><a href="/en-US/docs/Generating_GUIDs" title="Generating_GUIDs">GUID</a> (Firefox 1.0)</li>
+ <li>{{ Fx_minversion_inline(1.5) }}是一个这样结构的字符串:</li>
+</ul>
+<pre><code class="plain">extensionname@example.org</code></pre>
+<p>后面的这个格式更容易生成和操作。火狐1.5已经检测你的id,确保它是属于第一种格式还是其他格式,并且让那些id格式乱七八糟的add-on不会被安装。</p>
+<p>例如:</p>
+<pre class="brush:xml;auto-links:false">&lt;em:id&gt;extensionname@example.org&lt;/em:id&gt;
+
+&lt;em:id&gt;{daf44bf7-a45e-4450-979c-91cf07434c3d}&lt;/em:id&gt;</pre>
+<h3 id="版本">版本</h3>
+<p>一个标志当前add-on版本的字符串。</p>
+<p>对于火狐/雷鸟1.0来说,这个格式必须满足这里所说的要求: <a href="/en-US/docs/Extension_Versioning,_Update_and_Compatibility" title="Extension_Versioning,_Update_and_Compatibility">Extension Versioning, Update and Compatibility</a>. 对于火狐/雷鸟1.5, 看这里:<a href="/en-US/docs/Toolkit_version_format" title="Toolkit_version_format">Toolkit version format</a>.</p>
+<p>示例:</p>
+<pre class="brush:xml">&lt;em:version&gt;2.0&lt;/em:version&gt;
+
+&lt;em:version&gt;1.0.2&lt;/em:version&gt;
+
+&lt;em:version&gt;0.4.1.2005090112&lt;/em:version&gt;</pre>
+<p><strong>Firefox 1.5 / XULRunner 1.8</strong> - add-ons that do not use a valid version format will not be installed. The version format is different from, although backwards-compatible with, 1.0's.</p>
+<p><strong>For addons hosted on addons.mozilla.org</strong> - Mozilla's update website may repackage your add-on and correct or reject malformed version strings.</p>
+<h3 id="类型">类型</h3>
+<p>一个整数代表add-on的类型</p>
+<table>
+ <tbody>
+ <tr>
+ <td>2</td>
+ <td>扩展</td>
+ </tr>
+ <tr>
+ <td>4</td>
+ <td>主题</td>
+ </tr>
+ <tr>
+ <td>8</td>
+ <td>地区(译者注:多语言)</td>
+ </tr>
+ <tr>
+ <td>32</td>
+ <td><a href="/en-US/docs/Multiple_Item_Packaging" title="Multiple_Item_Packaging">多个物品包</a></td>
+ </tr>
+ <tr>
+ <td>64</td>
+ <td>拼写检测字典</td>
+ </tr>
+ </tbody>
+</table>
+<p>例如:</p>
+<pre class="brush:xml">&lt;em:type&gt;2&lt;/em:type&gt;</pre>
+<p>{{ Fx_minversion_inline(1.5) }} This property was added for Firefox 1.5, and is only required for add-on types other than Extensions and Themes.</p>
+<p>{{ Fx_minversion_inline(3) }} Firefox 2 and previous supported a value of 16 to represent plug-ins. In Firefox 3 this has been removed.</p>
+<h3 id="targetApplication">targetApplication</h3>
+<p>An object specifying an application targeted by this add-on. This means that the add-on will work with the application identified by the id property (<code>&lt;em:id&gt;</code>) specified (for a comprehensive list of application IDs and valid min/maxVersions for them see <a class="link-https" href="https://addons.mozilla.org/en-US/firefox/pages/appversions">Valid application versions for add-on developers</a>), from the minimum version (<code>&lt;em:minVersion&gt;</code>) up to and including the maximum version (<code>&lt;em:maxVersion&gt;</code>). These version strings are formatted in the same fashion as the <a href="#version"><code>version</code> property</a> and will be compared to the application version; this allows the extension author to specify which versions of Firefox an extension has been tested with.</p>
+<p><code>id</code>, <code>minVersion</code>, and <code>maxVersion</code> are all required.</p>
+<div class="note">
+ Extensions compatible with Firefox 3.5 should specify a <code>maxVersion</code> of<code> 3.5.*</code>, so that they are automatically compatible with security and stability updates. For Firefox 3.0, a <code>maxVersion</code> of<code> 3.0.*</code> should be used. Extensions compatible only with Firefox or Thunderbird 2 should specify a <code>maxVersion</code> of <code>2.0.0.*</code>.</div>
+<p>The Install Manifest must specify at least one of these objects, and may specify more if the add-on targets multiple applications that support the Add-on Manager (e.g. Firefox and Thunderbird)</p>
+<p><strong>Examples</strong></p>
+<pre class="brush:xml">&lt;em:targetApplication&gt;
+ &lt;Description&gt;
+ &lt;em:id&gt;{ec8030f7-c20a-464f-9b0e-13a3a9e97384}&lt;/em:id&gt; &lt;!--Firefox--&gt;
+ &lt;em:minVersion&gt;1.5&lt;/em:minVersion&gt;
+ &lt;em:maxVersion&gt;3.0.*&lt;/em:maxVersion&gt;
+ &lt;/Description&gt;
+&lt;/em:targetApplication&gt;</pre>
+<p>{{ Fx_minversion_inline(3) }} Gecko 1.9 based applications allow you to use the special <code>targetApplication </code>id <code class="plain">toolkit@mozilla.org</code> to say that the add-on is compatible with any toolkit app with a toolkit version matching the <code>minVersion</code> and <code>maxVersion</code>.</p>
+<h3 id="name">name</h3>
+<p>The name of the add-on; intended for display in the UI.</p>
+<p><strong>Examples </strong></p>
+<pre class="brush:xml">&lt;em:name&gt;My Extension&lt;/em:name&gt;</pre>
+<h2 id="Optional_Property_Reference">Optional Property Reference</h2>
+<p>You may need to supply these properties, depending on the capabilities of your add-on.</p>
+<h3 id="bootstrap">bootstrap</h3>
+<p>{{ Fx_minversion_inline(4) }} A Boolean value that tells the application whether the extension is boot-strappable. At the moment this only works for add-ons with em:type="2". The default value is <code>false</code>. For more information, see <a href="/en-US/docs/Extensions/Bootstrapped_extensions" title="Extensions/Bootstrapped extensions">Bootstrapped extensions</a>.</p>
+<h3 id="unpack">unpack</h3>
+<p>{{ Fx_minversion_inline(4) }} A true or false value that tells the application whether the extension requires its files be unpacked into a directory in order to work or whether the extension can be loaded direct from the XPI. In versions before Gecko 2.0 all extensions were unpacked, in Gecko 2.0 and later the default is to not unpack. If an extension includes the following then it must request unpacking:</p>
+<ul>
+ <li>Binary <a href="/en-US/docs/XPCOM" title="XPCOM">XPCOM</a> components</li>
+ <li><a href="/en-US/docs/Shipping_a_plugin_as_a_Toolkit_bundle" title="Shipping a plugin as a Toolkit bundle">Plugins</a></li>
+ <li><a href="/en-US/docs/Creating_MozSearch_plugins" title="Creating MozSearch plugins">Search plugins</a></li>
+ <li>DLLs loaded with <a href="/en-US/docs/Mozilla/js-ctypes" title="js-ctypes">ctypes</a></li>
+ <li>Dictionaries</li>
+ <li>Window icons</li>
+</ul>
+<p><strong>Examples</strong></p>
+<pre class="brush:xml">&lt;Description about="urn:mozilla:install-manifest"&gt;
+ &lt;em:id&gt;extension@mysite.com&lt;/em:id&gt;
+ &lt;em:unpack&gt;true&lt;/em:unpack&gt;
+ ...
+&lt;/Description&gt;</pre>
+<h3 id="localized">localized</h3>
+<p>{{ Fx_minversion_inline(3) }} Allows you to localize the add-on's name, description, contributors and other metadata. The localized description must specify at least one <code>em:locale</code> which indicates which locales to use this information for.</p>
+<p><strong>Examples</strong></p>
+<p>This declares a set of add-on metadata to be displayed when the application is running in the de-DE locale.</p>
+<pre class="brush:xml">&lt;em:localized&gt;
+ &lt;Description&gt;
+ &lt;em:locale&gt;de-DE&lt;/em:locale&gt;
+ &lt;em:name&gt;Tab Sidebar&lt;/em:name&gt;
+ &lt;em:description&gt;Zeigt in einer Sidebar Vorschaubilder der Inhalte aller offenen Tabs an.&lt;/em:description&gt;
+ &lt;/Description&gt;
+&lt;/em:localized&gt;</pre>
+<p>The following properties which are described elsewhere in this page can be included in the localized property:</p>
+<ul>
+ <li>name</li>
+ <li>description</li>
+ <li>creator</li>
+ <li>homepageURL</li>
+ <li>developer</li>
+ <li>translator</li>
+ <li>contributor</li>
+</ul>
+<p>More documentation can be found at <a href="/en-US/docs/Localizing_extension_descriptions" title="Localizing_extension_descriptions">Localizing extension descriptions</a>.</p>
+<h3 id="description">description</h3>
+<p>A short description of the add-on - intended for display in the user interface. This description should fit on one short line of text.</p>
+<p><strong>Examples</strong></p>
+<pre class="brush:xml">&lt;em:description&gt;Advanced foo tools.&lt;/em:description&gt;</pre>
+<h3 id="creator">creator</h3>
+<p>The name of the creator/principal developer - intended for display in the user interface.</p>
+<p><strong>Examples</strong></p>
+<pre class="brush:xml">&lt;em:creator&gt;John Doe&lt;/em:creator&gt;</pre>
+<p>or</p>
+<pre class="brush:xml">&lt;em:creator&gt;CoolExtension Team&lt;/em:creator&gt;</pre>
+<h3 id="developer">developer</h3>
+<p>{{ Fx_minversion_inline(2) }} The name(s) of co-developers. You may specify more than one of this value to specify multiple developers.</p>
+<p><strong>Examples</strong></p>
+<pre class="brush:xml">&lt;em:developer&gt;Jane Doe&lt;/em:developer&gt;
+&lt;em:developer&gt;Koos van der Merwe&lt;/em:developer&gt;
+</pre>
+<h3 id="translator">translator</h3>
+<p>{{ Fx_minversion_inline(2) }} The name(s) of translators. You may specify more than one of this value to specify multiple translators.</p>
+<p><strong>Examples</strong></p>
+<pre class="brush:xml">&lt;em:translator&gt;Janez Novak&lt;/em:translator&gt;
+&lt;em:translator&gt;Kari Nordmann&lt;/em:translator&gt;
+</pre>
+<h3 id="contributor">contributor</h3>
+<p>The name(s) of additional contributors. You may specify more than one of this value to specify multiple contributors.</p>
+<p><strong>Examples</strong></p>
+<pre class="brush:xml">&lt;em:contributor&gt;John Doe&lt;/em:contributor&gt;
+
+&lt;em:contributor&gt;John Doe&lt;/em:contributor&gt;
+&lt;em:contributor&gt;Jane Doe&lt;/em:contributor&gt;
+&lt;em:contributor&gt;Elvis Presley&lt;/em:contributor&gt;
+</pre>
+<h3 id="homepageURL">homepageURL</h3>
+<p>A link to the add-on's home page - intended for display in the user interface.</p>
+<p><strong>Examples</strong></p>
+<pre class="brush:xml;auto-links:false">&lt;em:homepageURL&gt;http://www.foo.com/&lt;/em:homepageURL&gt;
+</pre>
+<h3 id="updateURL">updateURL</h3>
+<p>A link to a custom Update Manifest file that specifies available updates to the add-on. The format is described below. If enabled, the add-on manager periodically checks with this Manifest file to determine if newer versions are available.</p>
+<div class="note">
+ <strong>Note:</strong> It is strongly recommended that the <code>updateURL</code> be an HTTPS (secure) link. Non-secure update URLs can be hijacked by a malicious <code>update.rdf</code> file, enabling malware to infiltrate the user's computer. <strong>Alternatively, you could host your extension on </strong><a class="external" href="http://addons.mozilla.org"><strong>AMO</strong></a><strong> and leave out the <code>updateURL</code> completely.</strong> This provides secure updates automatically.</div>
+<p>{{ Fx_minversion_inline(3) }} For security reasons, Gecko 1.9 applications <strong>require</strong> that if you specify an <code>updateURL</code>, it must be an https URL, or you must include an <code><a href="#updateKey">updateKey</a></code>.</p>
+<p>Your server must send this file as <code>text/rdf</code>, <code>text/xml</code> or <code>application/xml+rdf</code> or the update checker may not work.</p>
+<p>The addon manager will substitute the following values into this URL in case you wish to generate the response RDF dynamically, such as using PHP or CGI:</p>
+<table>
+ <tbody>
+ <tr>
+ <td><code>%REQ_VERSION%</code></td>
+ <td>The version of the request. Currently 1</td>
+ </tr>
+ <tr>
+ <td><code>%ITEM_ID%</code></td>
+ <td>The <code>id</code> of the addon being updated</td>
+ </tr>
+ <tr>
+ <td><code>%ITEM_VERSION%</code></td>
+ <td>The <code>version</code> of the addon being updated</td>
+ </tr>
+ <tr>
+ <td><code>%ITEM_MAXAPPVERSION%</code></td>
+ <td>The <code>maxVersion</code> of the <code>targetApplication</code> object corresponding to the current application for the addon being updated.</td>
+ </tr>
+ <tr>
+ <td><code>%ITEM_STATUS%</code></td>
+ <td>{{ Fx_minversion_inline(2) }} Comma separated list of the add-ons operating status in the application. Contains at the least either <code>userEnabled</code> or <code>userDisabled</code> plus any number of <code>incompatible</code>, <code>blockslisted</code> or <code>needsDependencies</code>.</td>
+ </tr>
+ <tr>
+ <td><code>%APP_ID%</code></td>
+ <td>The <code>id</code> of the current application</td>
+ </tr>
+ <tr>
+ <td><code>%APP_VERSION%</code></td>
+ <td>The <code>version</code> of the application to check for updates for</td>
+ </tr>
+ <tr>
+ <td><code>%CURRENT_APP_VERSION%</code></td>
+ <td>{{ Fx_minversion_inline(3.5) }} The <code>version</code> of the current application</td>
+ </tr>
+ <tr>
+ <td><code>%APP_OS%</code></td>
+ <td>{{ Fx_minversion_inline(1.5) }} The value of <code><a href="/en-US/docs/OS_TARGET" title="OS_TARGET">OS_TARGET</a></code> from the Firefox build system, identifying the operating system being used.</td>
+ </tr>
+ <tr>
+ <td><code>%APP_ABI%</code></td>
+ <td>{{ Fx_minversion_inline(1.5) }} The value of the <code><a href="/en-US/docs/XPCOM_ABI" title="XPCOM_ABI">TARGET_XPCOM_ABI</a></code> value from the Firefox build system, identifying the compiler/architecture combination used to compile the current application.</td>
+ </tr>
+ <tr>
+ <td><code>%APP_LOCALE%</code></td>
+ <td>{{ Fx_minversion_inline(3) }} The current application's locale.</td>
+ </tr>
+ <tr>
+ <td><code>%UPDATE_TYPE%</code></td>
+ <td>{{ Fx_minversion_inline(4) }} <code>UPDATE_TYPE_COMPATIBILITY(32)</code>, <code>UPDATE_TYPE_NEWVERSION(64)</code></td>
+ </tr>
+ <tr>
+ <td><code>%COMPATIBILITY_MODE%</code></td>
+ <td>{{ Fx_minversion_inline(10) }} related to <a href="/en-US/docs/Firefox/Updating_add-ons_for_Firefox_10#Compatible_by_default" title="https://developer.mozilla.org/en-US/docs/Firefox/Updating_add-ons_for_Firefox_10#Compatible_by_default">default to compatible</a>, values could be <code>normal</code>, <code>ignore</code> or <code>strict</code>.</td>
+ </tr>
+ </tbody>
+</table>
+<p><strong>Examples</strong></p>
+<pre class="brush:xml;auto-links:false">&lt;em:updateURL&gt;http://www.foo.com/update.cgi?id=%ITEM_ID%&amp;amp;version=%ITEM_VERSION%&lt;/em:updateURL&gt;
+&lt;em:updateURL&gt;http://www.foo.com/extension/windows.rdf&lt;/em:updateURL&gt;
+</pre>
+<p><strong>For add-ons hosted on addons.mozilla.org:</strong> You may not specify an <code>updateURL</code> property. By default, Mozilla applications using the Add-on Manager (such as Firefox and Thunderbird) will send update requests to <code>addons.mozilla.org</code> using the default web service. Every time you upload a new version of your add-on or change its compatibility parameters through the author interface, your update manifest will be generated automatically. Add-ons currently marked as <a class="link-https" href="https://addons.mozilla.org/firefox/pages/experimentalAddons">experimental</a> will not be updated due to security concerns.</p>
+<p><strong>Format of the Update Manifest:</strong> The Update Manifest is a RDF/XML datasource. For examples of an update manifest, see <a href="/en-US/docs/Extension_Versioning,_Update_and_Compatibility#Update_RDF_Format" title="Extension_Versioning,_Update_and_Compatibility#Update_RDF_Format">Extension Versioning, Update and Compatibility</a> and <a href="/en-US/docs/Enabling_Extension_Updates_(external)" title="Enabling_Extension_Updates_(external)">Enabling Extension Updates (external)</a>.</p>
+<h3 id="updateKey">updateKey</h3>
+<div>
+ {{ Gecko_minversion_header(1.9) }} {{ Fx_minversion_header(3) }}</div>
+<p>To ensure the security of update rdf data that is retrieved over plain http you must use a digital signature to verify the contents of the data. In order to do so you must include the public part of the cryptographic key in an updateKey entry in the install.rdf of the add-on. This can be generated using the <a href="/en-US/docs/McCoy" title="McCoy">McCoy</a> tool. Any line breaks and whitespace as part of this entry are ignored.</p>
+<pre class="brush:xml">&lt;em:updateKey&gt;MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDK426erD/H3XtsjvaB5+PJqbhj
+ Zc9EDI5OCJS8R3FIObJ9ZHJK1TXeaE7JWqt9WUmBWTEFvwS+FI9vWu8058N9CHhD
+ NyeP6i4LuUYjTURnn7Yw/IgzyIJ2oKsYa32RuxAyteqAWqPT/J63wBixIeCxmysf
+ awB/zH4KaPiY3vnrzQIDAQAB&lt;/em:updateKey&gt;
+</pre>
+<h3 id="optionsURL">optionsURL</h3>
+<p>The <code>chrome://</code> URL of the extension's options dialog box. This is only useful to extensions. If this property is specified, when the extension is selected in the Extensions list, the Options button is enabled and will show this.</p>
+<pre class="brush:xml">&lt;em:optionsURL&gt;chrome://myext/content/options.xul&lt;/em:optionsURL&gt;</pre>
+<p>{{ gecko_minversion_note("7", "In Firefox 7 you can also simply include your options XUL as a file named <code>options.xul</code>, in the base directory of the add-on.") }}</p>
+<p>{{ h3_gecko_minversion("optionsType", 7) }}</p>
+<p>The type of user-interface used for displaying the options. Accepted values are:</p>
+<table style="">
+ <tbody>
+ <tr>
+ <td>1</td>
+ <td>Opens optionsURL in a dialog box</td>
+ </tr>
+ <tr>
+ <td>2</td>
+ <td><a href="/en-US/docs/Extensions/Inline_Options" title="Extensions/Inline Options">Options are displayed inside the Add-on Manager</a></td>
+ </tr>
+ <tr>
+ <td>3</td>
+ <td>Opens optionsURL in a new tab (if the application supports that), or a dialog box</td>
+ </tr>
+ </tbody>
+</table>
+<p>optionsType defaults to 1 if there is an optionsURL included in install.rdf or 2 if there is no optionsURL and the file <code>options.xul</code> exists in the root of the add-on.</p>
+<pre class="brush:xml">&lt;em:optionsType&gt;2&lt;/em:optionsType&gt;
+</pre>
+<h3 id="aboutURL">aboutURL</h3>
+<p>The<code> chrome://</code> URL of the extension's about dialog box. This is only useful to extensions. If this property is specified, when the extension is selected in the Extensions list, the About... link in the extension's context menu will show this dialog, rather than the default.</p>
+<div class="geckoVersionNote">
+ <p>{{ gecko_callout_heading("2.0") }}</p>
+ <p>The dialog receives the <code>Addon</code> object representing your add-on as a parameter.</p>
+</div>
+<p><strong>Examples</strong></p>
+<pre class="brush:xml">&lt;em:aboutURL&gt;<a class="external" rel="freelink">chrome://myext/content/about.xul</a>&lt;/em:aboutURL&gt;
+</pre>
+<h3 id="iconURL">iconURL</h3>
+<p>A <code>chrome://</code> URL to an icon to display in the add-ons list. The icon will be displayed at 32x32 in Firefox 3.6 and lower. In Firefox 4.0 and later the icon can be up to 48x48 pixels in size. If this property is not specified, a default icon is used.</p>
+<pre class="brush:xml">&lt;em:iconURL&gt;<a class="external" rel="freelink">chrome://myext/skin/icon.png</a>&lt;/em:iconURL&gt;
+</pre>
+<div class="note">
+ <strong>Note:</strong> For the above example to work you will also have to add a <code>skin package</code> line to your <code>chrome.manifest</code> file. See <a href="/en-US/docs/Chrome_Registration#skin" title="Chrome_Registration#skin">Chrome Registration#skin</a>. Alternatively you can place your icon in the directory specified in your <code>content package</code> line.</div>
+<p>{{ gecko_minversion_note("1.9.2", "Starting in Gecko 1.9.2 (Firefox 3.6), you can also simply include your icon, named <code>icon.png</code>, in the base directory of the add-on. This allows your add-on's icon to be displayed even when the add-on is disabled, or if the manifest is missing an <code>iconURL</code> entry.") }}</p>
+<p>{{ h3_gecko_minversion("icon64URL", "2.0") }}</p>
+<p>A <code>chrome://</code> URL to a 64x64 pixel icon to display in the add-on's details view . If this property is not specified, the smaller icon above will be used.</p>
+<pre class="brush:xml">&lt;em:icon64URL&gt;<a class="external" rel="freelink">chrome://myext/skin/icon64.png</a>&lt;/em:icon64URL&gt;
+</pre>
+<div class="note">
+ <strong>Note:</strong> For the above example to work you will also have to add a <code>skin package</code> line to your <code>chrome.manifest</code> file. See <a href="/en-US/docs/Chrome_Registration#skin" title="Chrome_Registration#skin">Chrome Registration#skin</a>. Alternatively you can place your icon in the directory specified in your <code>content package</code> line.</div>
+<p>{{ h3_gecko_minversion("targetPlatform", "1.8") }}</p>
+<p>A string specifying a platform that the add-on supports. It contains either the value of <code><a href="/en-US/docs/OS_TARGET" title="OS_TARGET">OS_TARGET</a></code> alone or combined with <code><a href="/en-US/docs/XPCOM_ABI" title="XPCOM_ABI">TARGET_XPCOM_ABI</a></code>, separated by an underscore (_).</p>
+<p>You can specify multiple <code>targetPlatform</code> properties per manifest. If any value matches the application's build parameters, it will be installed; if not, the user will get an appropriate error message.</p>
+<p><strong>Examples</strong></p>
+<pre class="brush:xml">&lt;em:targetPlatform&gt;WINNT_x86-msvc&lt;/em:targetPlatform&gt;
+
+&lt;em:targetPlatform&gt;Linux&lt;/em:targetPlatform&gt;
+
+&lt;em:targetPlatform&gt;Darwin_ppc-gcc3&lt;/em:targetPlatform&gt;
+
+&lt;em:targetPlatform&gt;SunOS_sparc-sunc&lt;/em:targetPlatform&gt;</pre>
+<p>Usually, you would use only the OS part for themes or for extensions that are not fully cross-platform. For extensions including binary (compiled) components, you should never use the OS alone, but include the <a href="/en-US/docs/XPCOM_ABI" title="XPCOM_ABI">ABI (s)</a> that you compiled the components with. If you want to include multiple versions of the components, you should also use <a href="/en-US/docs/Bundles#Platform-specific_Subdirectories" title="Bundles#Platform-specific_Subdirectories">Platform-specific Subdirectories</a>.</p>
+<p><strong>Notes</strong></p>
+<ul>
+ <li>In the same manifest file, you could even mix values with and without ABI. If a value for the application's OS is encountered that requires any specific ABI, the ABI is considered important for that OS and the application will refuse to install the add-on if it does not find a matching OS/ABI combination. This means that if all of the above examples would occur in one manifest, the add-on will install on any Linux build of the application, regardless of its ABI, but not on a Windows Cygwin build.</li>
+ <li>There may be builds of Firefox and Thunderbird which do not "know" their ABI (most likely ports to rare platforms, or non-official builds). These builds will refuse to install any addon that requires a specific ABI for their platform.</li>
+</ul>
+<p>This property was added for Firefox/Thunderbird 1.5. Previous versions of these applications will ignore the restrictions and install the add-on regardless of the platform.</p>
+<p>{{ h3_gecko_minversion("strictCompatibility", "10.0") }}</p>
+<p>A Boolean value indicating if the add-on should be enabled when the version of the application is greater than its max version. By default, the value of this property is <code>false</code> meaning that the compatibility checking will not be performed against the max version.</p>
+<pre class="brush:xml">&lt;em:strictCompatibility&gt;true&lt;/em:strictCompatibility&gt;</pre>
+<p>Usually, there is no need to restrict the compatibility: not all new releases will break your extension and, if it is hosted on AMO, you'll get notice several weeks in advance if a potential risk has been detected. Moreover, an extension being disabled, even for a short period, leads to a bad experience for the user. About the only time you should need to set this if your add-on does things that are likely to be broken by Firefox updates. You <strong>do not</strong> need to set this flag if your add-on has a binary component, since add-ons with binary components are always subject to strict compatibility checking (because binary components need to be rebuilt for every major application release anyway).</p>
+<div class="note">
+ <strong>Note:</strong> If you want to restore the old behavior of strict compatibility checking of all add-ons, regardless of the value of this setting in their manifests, you can set the <code>extensions.strictCompatibility</code> preference to <code>true</code>.</div>
+<div class="geckoVersionNote" style="">
+ <p class="note">{{ gecko_callout_heading("11.0") }}</p>
+ <p class="note">Starting in Gecko 11.0 {{ geckoRelease("11.0") }}, applications such as Firefox will assume add-ons that have not been updated in a very long time are no longer compatible by default.</p>
+</div>
+<h2 id="Obsolete_Property_Reference">Obsolete Property Reference</h2>
+<p>These properties were required in older versions of the Add-on Manager, but have been replaced with newer and better mechanisms.</p>
+<h3 id="file">file</h3>
+<p><strong>Firefox 1.0</strong> This property pointed to a chrome <code>.jar</code> file that contains chrome packages that require registration with the Chrome Registry.</p>
+<p>The <code>&lt;em:file&gt;</code> property has a complex object value. The uri of the value is <code>urn:mozilla:extension:file:jarFile.jar</code> where <code>jarFile.jar</code> is the name of the jar file that contains the chrome package's files. This could also be the name of a directory that contains the chrome package's files, un-jarred (e.g. <code>urn:mozilla:extension:file:directory</code>). In either case, the referenced chrome package file(s) must be placed in the <code>chrome</code> subdirectory of the XPI's top level.</p>
+<p>This object has a <code>package</code> property (with a path within the jar file or directory that leads to the location where the <code>contents.rdf</code> file responsible for registering that package is located), a <code>locale</code> property (ditto, but to register the locale) and a <code>skin</code> property (ditto, but to register the theme material).</p>
+<p>In extensions for Firefox 1.5, this property is no longer necessary: the <code><a href="/en-US/docs/Chrome_Registration" title="Chrome_Registration">chrome.manifest</a></code> at the top level of the XPI is used to locate chrome to register. If there is no chrome.manifest, this property is still read by the Add-on Manager and a chrome.manifest is generated from old-style contents.rdf.</p>
+<p><strong>Examples</strong></p>
+<pre class="brush:xml">&lt;em:file&gt;
+ &lt;Description about="urn:mozilla:extension:file:myext.jar"&gt;
+ &lt;em:package&gt;content/myext/&lt;/em:package&gt;
+ &lt;em:locale&gt;locale/en-US/myext/&lt;/em:locale&gt;
+ &lt;em:skin&gt;skin/classic/myext/&lt;em:skin&gt;
+ &lt;/Description&gt;
+&lt;/em:file&gt;
+</pre>
+<p>An Install Manifest may specify multiple <code>file</code> properties, one for each jar file or subdirectory that contains chrome to register.</p>
+<h3 id="hidden">hidden</h3>
+<p><strong>Firefox 1.0</strong><strong> - 3.5</strong> A boolean value that when <code>true</code> makes the add-on not show up in the add-ons list, provided the add-on is installed in a {{ Anch("restricted access area") }} (so it does not work for add-ons installed in the profile). This is for bundling integration hooks to larger applications where having an entry in the Extensions list does not make sense.</p>
+<div class="note">
+ <strong>Note:</strong> This property is no longer supported under Gecko 1.9.2 (Firefox 3.6) or later, to prevent extensions from being installed in such a way that the user might not be able to tell they're installed.</div>
+<p><strong>Examples</strong></p>
+<pre class="brush:xml">&lt;em:hidden&gt;true&lt;/em:hidden&gt;
+</pre>
+<h3 id="requires">requires</h3>
+<p><strong>Firefox 2.0 - 3.6.x</strong>. Other versions will ignore the restrictions and install the add-on regardless of the requirements.</p>
+<p>See <a class="link-https" href="https://groups.google.com/forum/#!topic/mozilla.dev.platform/u9QT2ZucV-c" title="https://groups.google.com/forum/#!topic/mozilla.dev.platform/u9QT2ZucV-c">Replacement for install.rdf property "requires"</a> discussion for rationale behind removing this feature and the suggested workaround.</p>
+<p><code>&lt;em:requires</code>&gt; has a similar syntax to the <code>&lt;em:targetApplication&gt;</code> tag (i.e. you must specify <code>&lt;em:id&gt;</code>, <code>&lt;em:minVersion&gt;</code>, <code>&lt;em:maxVersion&gt;</code> when using it). If the add-on specified by the <code>&lt;em:id&gt;</code> tag is not installed or has an incompatible version, the extension manager will disable your extension and show the message "Requires additional items". You can add as many <code>&lt;em:requires&gt;</code> tags as you like. Your extension will be disabled if any of the specified requirements fail. It is not possible to add dependencies that are specific to a <code>&lt;em:targetApplication&gt;</code>. See <a href="https://wiki.mozilla.org/Extension_Dependencies" title="https://wiki.mozilla.org/Extension_Dependencies">Extension Dependencies</a> for more details.</p>
+<h2 id="Glossary">Glossary</h2>
+<h2 id="restricted_access_area">restricted access area</h2>
+<p>A <em>restricted access area</em> is an install location that could be restricted on a restricted-access account, regardless of whether or not the location is restricted with the current user privileges (see {{ Source("toolkit/mozapps/extensions/public/nsIExtensionManager.idl#80", "nsIInstallLocation::restricted") }}). Currently, the <code>($APPDIR)/extensions</code> folder and the registry install location under <code>HKEY_LOCAL_MACHINE</code> (see <a href="/en-US/docs/Adding_Extensions_using_the_Windows_Registry" title="Adding_Extensions_using_the_Windows_Registry">Adding Extensions using the Windows Registry</a> for details) are restricted.</p>
+<p>The <code>($PROFILE)/extensions</code> and <code>HKEY_CURRENT_USER</code> install locations, on the other hand, are not restricted.</p>
diff --git a/files/zh-cn/mozilla/add-ons/legacy_add_ons/index.html b/files/zh-cn/mozilla/add-ons/legacy_add_ons/index.html
new file mode 100644
index 0000000000..9200ccb0f6
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/legacy_add_ons/index.html
@@ -0,0 +1,19 @@
+---
+title: 旧式附件组件
+slug: Mozilla/Add-ons/Legacy_add_ons
+translation_of: Archive/Add-ons/Legacy_add_ons
+---
+<p>{{LegacyAddonsNotice}}{{AddonSidebar}}</p>
+
+<p>本节包含附件组件开发的旧式技术文档链接,包括:</p>
+
+<ul>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/SDK">附件组件 SDK</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/Legacy_Firefox_for_Android">Firefox for Android旧式扩展</a></li>
+ <li>早期技术
+ <ul>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/Bootstrapped_extensions">Bootstrapped 扩展</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/Overlay_Extensions">Overlay 扩展</a></li>
+ </ul>
+ </li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/overlay_extensions/index.html b/files/zh-cn/mozilla/add-ons/overlay_extensions/index.html
new file mode 100644
index 0000000000..6504a2ef16
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/overlay_extensions/index.html
@@ -0,0 +1,61 @@
+---
+title: Overlay扩展
+slug: Mozilla/Add-ons/Overlay_Extensions
+tags:
+ - Add-ons
+ - Extensions
+ - Landing
+ - NeedsTranslation
+ - TopicStub
+translation_of: Archive/Add-ons/Overlay_Extensions
+---
+<p>{{LegacyAddonsNotice}}{{AddonSidebar}}</p>
+
+<p>本页面为那些基于 Gecko 的应用开发扩展插件的开发者们提供了可用的参考文献链接。</p>
+
+<ul>
+ <li>XUL 覆盖指定的接口</li>
+ <li>对应用与内容的之间交互的特定代码提供了可用的APIs, 比如 <a href="/zh-CN/docs/XUL/tabbrowser">页签浏览</a> 和<a href="/zh-CN/docs/Mozilla/JavaScript_code_modules">JavaScript模组</a>。</li>
+</ul>
+
+<p>唯一可行的方法是开发扩展在 Gecko 2.0 发布之前. 但是现在有两种可以选择的技术:免重启扩展和基于 SDK 的扩展插件. 这些特定的 JavaScript APIs 仍旧可以被这些较新的技术使用。</p>
+
+<p>Prior to Firefox 4, and the Gecko 2 engine that powers it, this was the only way to develop extensions. This methodology has largely been superseded by <a href="/en-US/docs/Extensions/Bootstrapped_extensions">restartless extensions</a>, and the <a href="/en-US/Add-ons/SDK">Add-on SDK</a>, which is built on top of them. The privileged JavaScript APIs described here can still be used in these newer types of add-ons.</p>
+
+<h2 id="XUL_学校">XUL 学校</h2>
+
+<p><a href="/zh-CN/Add-ons/Overlay_Extensions/XUL_School">XUL 学校</a> 是一个综合性的拓展开发指南,主要针对 Firefox 的扩展开发,但是绝大多数可应用于其他基于 Gecko 的应用。</p>
+
+<h2 id="更多资源">更多资源</h2>
+
+<div class="column-container">
+<div class="column-half">
+<dl>
+ <dt><a href="/en-US/Mozilla/Add-ons/Setting_up_extension_development_environment">设置环境</a></dt>
+ <dd>设置扩展开发需要的应用.</dd>
+ <dt><a href="/en-US/docs/XUL">XUL</a></dt>
+ <dd>相关的指南介绍XUL 扩展的接口.</dd>
+ <dt><a href="/en-US/Mozilla/Add-ons/Code_snippets">代码片段</a></dt>
+ <dd>提供了很多的简单示例代码片段.</dd>
+ <dt><a href="/en-US/Mozilla/Add-ons/Installing_extensions">安装扩展</a></dt>
+ <dd>如何通过把扩展的文件拷贝进应用的安装目录来安装扩展.</dd>
+ <dt><a href="/en-US/Add-ons/Overlay_extensions/Firefox_addons_developer_guide">Firefox 插件的开发者指南</a></dt>
+ <dd>开发扩展的指南.</dd>
+</dl>
+</div>
+
+<div class="column-half">
+<dl>
+ <dt><a href="/en-US/docs/Mozilla/JavaScript_code_modules">JavaScript 模块代码</a></dt>
+ <dd>适用于扩展开发者的 JavaScript 模块。</dd>
+ <dt><a href="/en-US/Mozilla/Add-ons/Inline_Options">扩展偏好</a></dt>
+ <dd>如何在你的扩展出现在附加组件管理界面的时候指定偏好设置。</dd>
+ <dt><a href="/en-US/Mozilla/Add-ons/Extension_Frequently_Asked_Questions">常见问题</a></dt>
+ <dd>常见的扩展开发中的错误。</dd>
+ <dt><a href="/en-US/Mozilla/Add-ons/Extension_Packaging">扩展打包</a></dt>
+ <dd>看看扩展是如何被打包和安装的。</dd>
+ <dt><a href="/en-US/Mozilla/Add-ons/Creating_Custom_Firefox_Extensions_with_the_Mozilla_Build_System">Firefox 的二进制扩展</a></dt>
+ <dd>为 Firefox 创建二进制扩展。</dd>
+</dl>
+</div>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/performance_best_practices_in_extensions/index.html b/files/zh-cn/mozilla/add-ons/performance_best_practices_in_extensions/index.html
new file mode 100644
index 0000000000..d6a6f7515b
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/performance_best_practices_in_extensions/index.html
@@ -0,0 +1,91 @@
+---
+title: 扩展中的性能最佳实践
+slug: Mozilla/Add-ons/Performance_best_practices_in_extensions
+translation_of: Archive/Add-ons/Performance_best_practices_in_extensions
+---
+<p>Firefox 的一个巨大优势就是可扩展性非常强。扩展组件几乎可以做任何事情。但这也带来了一个劣势: 扩展组件如果写的不好,将会大大的影响浏览器性能,包括 firefox 的整体体验。 本文则提供了一些最佳实践方式,他们不仅能够提升你的组件的性能和速度,也会对 firefox 带来同样的影响。</p>
+<h2 id="提升启动性能">提升启动性能</h2>
+<p>Extensions are loaded and run whenever a new browser window opens. That means every time a window opens, your extension can have an impact on how long it takes the user to see the content they're trying to view. There are several things you can do to reduce the amount of time your extension delays the appearance of the user's desired content.</p>
+<h3 id="只在需要的时候装载需要的东西">只在需要的时候装载需要的东西</h3>
+<p>Don't load things during startup that are only needed if the user clicks a button, or if a given preference is enabled when it's not. If your extension has features that only work when the user has logged into a service, don't load the resources for those features until the user actually logs in.</p>
+<h3 id="使用_JavaScript_code_modules">使用  JavaScript code modules</h3>
+<p>You can create your own <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Using" title="/en-US/docs/Mozilla/JavaScript_code_modules/Using">JavaScript code modules</a> incorporating sets of features that are only needed under specific circumstances. This makes it easy to load chunks of your extension on the fly as needed, instead of loading everything all at once.</p>
+<p>This has an advantage over XPCOM modules, which are always loaded when your extension starts up.</p>
+<p>Of course, for extremely simple extensions it may not make sense to modularize your code.</p>
+<h3 id="Defer_everything_that_you_can">Defer everything that you can</h3>
+<p>Most extensions have a load event listener in the main overlay that runs their startup functions. Do as little as possible here. The browser window is blocked while your add-on's load handler runs, so the more it does, the slower Firefox will appear to the user.</p>
+<p>If there is <em>anything</em> that can be done even a fraction of a second later, you can use an {{ interface("nsITimer") }} or the {{ domxref("window.setTimeout()") }} method to schedule that work for later.  Even a short delay can have a big impact.</p>
+<h2 id="通用性能提示">通用性能提示</h2>
+<h3 id="避免产生内存泄漏">避免产生内存泄漏</h3>
+<p>Memory leaks require the garbage collector and the cycle collector to work harder, which can significantly degrade performance.</p>
+<p>Zombie compartments are a particular kind of memory leak that you can detect with minimal effort.  See the<a href="/en/Zombie_compartments" title="en/Zombie_compartments"> </a><a href="/en/Zombie_compartments" title="en/Zombie_compartments">Zombie compartments page</a>, especially the <a href="/en/Zombie_compartments#Proactive_checking_of_add-ons" title="en/Zombie_compartments#Proactive_checking_of_add-ons">Proactive checking of add-ons</a> section.</p>
+<p>See <a href="/en/Extensions/Common_causes_of_memory_leaks_in_extensions" title="en/Extensions/Common_causes_of_zombie_compartments_in_extensions">Common causes of memory leaks in extensions</a> for ways to avoid zombie compartments and other kinds of leaks.</p>
+<p>As well as looking for these specific kinds of leaks, it's worth exercising your extension's functionality and checking the contents of about:memory for any excessive memory usage.  For example, <a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=719601" title="https://bugzilla.mozilla.org/show_bug.cgi?id=719601">bug 719601</a> featured a "System Principal" JavaScript compartment containing 100s of MBs of memory, which is <em>much</em> larger than usual.</p>
+<h3 id="Use_JavaScript_Modules">Use JavaScript Modules</h3>
+<p>JavaScript modules are just like any other JavaScript, with the exception that they are singletons and Firefox can cache the compiled code for faster use the next time the browser is started. Any time your add-on loads JavaScript from an {{ HTMLElement("script") }} element you should consider using a JavaScript Module instead. For more on how JavaScript modules work, see the <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Using" title="/en-US/docs/Mozilla/JavaScript_code_modules/Using">Using JavaScript Code Modules page</a>.</p>
+<h3 id="Avoid_Writing_Slow_CSS">Avoid Writing Slow CSS</h3>
+<ul>
+ <li>Read the <a href="/en/CSS/Writing_Efficient_CSS" title="en/CSS/Writing_Efficient_CSS">"writing efficient CSS"</a> guide.</li>
+ <li>Remember that any selector in your rule which might match many different nodes is a source of inefficiency during either selector matching or dynamic update processing. This is especially bad for the latter if the selector can dynamically start or stop matching. Avoid unqualified ":hover" like the plague.</li>
+</ul>
+<h3 id="Avoid_DOM_mutation_event_listeners">Avoid DOM mutation event listeners</h3>
+<p>Adding DOM mutation listeners to a document disables most DOM modification optimizations and <a class="external" href="http://groups.google.com/group/mozilla.dev.platform/browse_thread/thread/2f42f1d75bb906fb?pli=1">profoundly degrades the performance</a> of further DOM modifications to that document. Moreover, removing the listeners does not reverse the damage. For these reasons, the following events should be avoided wherever possible: <code>DOMAttrModified</code>, <code>DOMAttributeNameChanged</code>, <code>DOMCharacterDataModified</code>, <code>DOMElementNameChanged</code>, <code>DOMNodeInserted</code>, <code>DOMNodeInsertedIntoDocument</code>, <code>DOMNodeRemoved</code>, <code>DOMNodeRemovedFromDocument</code>, <code>DOMSubtreeModified</code></p>
+<p>For more on these events and their deprecation, see <a href="/en-US/docs/Web/Guide/DOM/Events/Mutation_events" title="en-US/docs/Web/Guide/DOM/Events/Mutation_events">Mutation events</a>. Use <a href="/en-US/docs/Web/API/MutationObserver" title="en-US/docs/Web/API/MutationObserver">Mutation Observers</a> instead if possible.</p>
+<h3 id="延迟加载服务_services">延迟加载服务 services</h3>
+<p>The <a href="/en/JavaScript_code_modules/XPCOMUtils.jsm#Methods" title="en/JavaScript_code_modules/XPCOMUtils.jsm#Methods">XPCOMUtils JavaScript module</a> provides two methods for lazily loading things:</p>
+<ul>
+ <li><code>defineLazyGetter()</code> defines a function on a specified object that acts as a getter which will be created the first time it's used. <a class="external" href="http://mxr.mozilla.org/mozilla-central/search?string=defineLazyGetter">See examples</a>.</li>
+ <li><code>defineLazyServiceGetter()</code> defines a function on a specified object which acts as a getter for a service. The service isn't obtained until the first time it's used. {{ LXRSearch("ident", "string", "defineLazyServiceGetter", "Look through the source") }} for examples.</li>
+</ul>
+<p>As of Firefox 4.0, many common services are already cached for you in <a href="/en/JavaScript_code_modules/Services.jsm" title="en/JavaScript_code_modules/Services.jsm">Services.jsm</a>.</p>
+<h3 id="Reduce_file_IO">Reduce file I/O</h3>
+<p>TODO: Give examples below, link to code, bugs, docs.</p>
+<ul>
+ <li>If you're targeting Firefox 3.6 and earlier, or if you're specifying <code>em:unpack</code> then use chrome JARs!</li>
+ <li>Combine CSS</li>
+ <li>Combine pref files</li>
+ <li>Combine interfaces into a single .idl to reduce xpt files</li>
+ <li>Combine toolbar icons in a single file.</li>
+</ul>
+<h3 id="Use_the_right_compression_level_for_JAR_and_XPI_files">Use the right compression level for JAR and XPI files</h3>
+<p>Reading data from compressed archives costs time. The higher the compression level of the archive, the higher also the performance cost of reading the data from it. So any JAR files in your extension should always be packed with compression level 0 (no compression) for better performance. It may seem counter-intuitive, but doing this will increase the JAR file size and actually <em>decrease</em> the XPI file size as it allows for compression between files inside the JAR to be done when compressing the XPI (essentially a poor-man's <a class="external" href="http://en.wikipedia.org/wiki/Solid_archive" title="http://en.wikipedia.org/wiki/Solid_archive">solid archive</a> effect).</p>
+<p>If your extension doesn't specify <code>em:unpack</code> then its XPI file will not be unpacked in Firefox 4 and used directly instead. This makes choosing a low compression level preferable; we recommend using compression level 1. It will increase the download size only a small amount, even compared to maximum compression.</p>
+<h3 id="使用异步_IO">使用异步 I/O</h3>
+<p>This cannot be stressed enough: never do synchronous I/O on the GUI thread.</p>
+<ul>
+ <li>Never use synchronous XMLHttpRequests (XHR). Use asynchronous requests instead and show a throbber image or message in case you need the user to wait.</li>
+ <li><a href="/en/JavaScript_code_modules/NetUtil.jsm" title="en/JavaScript_code_modules/NetUtil.jsm">NetUtils.jsm</a> provides helpers for asynchronous reading and copying of files.</li>
+ <li>Never access a SQLite database synchronously. Use the <a href="/en/Storage#Asynchronously" title="en/Storage#Asynchronously">asynchronous API</a> instead.</li>
+</ul>
+<h3 id="Unnecessary_onreadystatechange_in_XHR">Unnecessary onreadystatechange in XHR</h3>
+<p><code>addEventListener</code>(load/error) and/or xhr.onload/.onerror are usually sufficient for most uses and will only be called once, contrary to <code>onreadystatechange</code>. When using XHR in websites people tend to use <code>onreadystatechange</code> (for compatiblity reasons). Often it is enough to just load the resource or handle errors. load/error event listener are far less often called than <code>onreadystatechange</code>, i.e. only once, and you don't need to check <code>readyState</code> or figure out if it is an error or not. Only use <code>onreadystatechange</code> if you want to process the response while it is still arriving.</p>
+<h3 id="Removing_Event_Listeners">Removing Event Listeners</h3>
+<p>Remove event listener if they are not needed any more. It is better to actually remove event listener instead of just having some flag to check if the listener is active which is checked every time when an event is propagated. Abandon schemes like: <code>function onMouseOver(evt) { if (is_active) { /* doSomeThing */ } }</code> Also, remove "fire-once" listeners again:</p>
+<pre class="brush: js"> function init() {
+ var largeArray;
+ addEventListener('load', function onLoad() {
+ removeEventListener('load', onLoad, true);
+ largeArray.forEach();
+ }, true);
+</pre>
+<p>Else a lot of closure stuff might be still referenced (<code>largeArray</code> in this example). And the listener will sit idle in some internal table.</p>
+<h3 id="Populate_menus_as_needed">Populate menus as needed</h3>
+<p>Populate "context" menus (page, tabs, tools) as needed and keep computation to a minimum (UI responsiveness). There is no need to populate the context menu every time something changes. It is enough to populate it once the user actually needs it. Add a listener to the "popupshowing" event and compute there.</p>
+<h3 id="Avoid_mouse_movement_events">Avoid mouse movement events</h3>
+<p>Avoid mouse movement events (enter/over/exit) or at least keep computation to a minimum. Mouse movement events, especially the <code>mouseover</code> event, usually happen at high frequency. Best would be to only store the new information and compute "stuff" once the user actually requests it (e.g. in a <code>popupshowing</code> event). Also don't forget to remove the event listeners when no longer needed (see above).</p>
+<h3 id="Avoid_polling">Avoid polling</h3>
+<p>Use {{ interface("nsIObserverService") }} functionality instead. Everybody is free to post "custom" notifications via {{ interface("nsIObserverService") }}, but few extensions actually use this. However, a lot of other services also provide observer functionality, such as nsIPrefBranch2.</p>
+<h3 id="aPNGaGIF_inappropriate_in_a_lot_of_cases">aPNG/aGIF inappropriate in a lot of cases</h3>
+<p>Animations require a lot of time to set up, as a lot of images are decoded (the frames). Animated images may have their cached representations evicted quite often, causing the frames of your animated images to be reloaded lots of times, not just once. {{ interface("nsITree") }} / {{ XULElem("tree") }} seems to be extra special in this regard, as it doesn't seem to cache animations at all under certain circumstances.</p>
+<h3 id="base64md5sha1_implementations">base64/md5/sha1 implementations</h3>
+<p>Do not ship your own base64/md5/sha1 implementations. Regarding base64 there are the built-in <code>atob</code>/<code>btoa</code> functions that do the job just well and are available in overlay script as well as in in JavaScript modules and components. Hashes can be computed using {{ interface("nsICryptoHash") }}, which accepts either a string or an {{ interface("nsIInputStream") }}.</p>
+<h3 id="Image_sprites">Image sprites</h3>
+<p>You may combine multiple images into one (sprites). See {{ cssxref("-moz-image-region") }}. Most XUL widgets that are used to display some image (incl. {{ XULElem("button") }} and {{ XULElem("toolbarbutton") }}) allow to use {{ cssxref("list-style-image") }}. Avoid the <code>imagesrc</code>/<code>src</code> attributes to define images where possible.</p>
+<h3 id="Consider_using_Chrome_Workers">Consider using Chrome Workers</h3>
+<p>You can use a {{ domxref("ChromeWorker") }} to execute long running tasks or do data processing.</p>
+<h2 id="参考">参考</h2>
+<ul>
+ <li><a href="/en/Performance/Measuring_add-on_startup_performance" title="en/Measuring Add-on Startup Performance">Measuring Add-on Startup Performance</a></li>
+ <li><a class="external" href="http://blog.mozilla.com/addons/2010/06/14/improve-extension-startup-performance/" title="http://blog.mozilla.com/addons/2010/06/14/improve-extension-startup-performance/">How to Improve Extension Startup Performance</a></li>
+ <li><a href="/en-US/docs/Performance">General information about measuring and improving performance in Mozilla code</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/plugins/index.html b/files/zh-cn/mozilla/add-ons/plugins/index.html
new file mode 100644
index 0000000000..f35791a3bf
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/plugins/index.html
@@ -0,0 +1,116 @@
+---
+title: Plugins
+slug: Mozilla/Add-ons/Plugins
+tags:
+ - Add-ons
+ - NPAPI
+ - NeedsTranslation
+ - Plugins
+ - TopicStub
+translation_of: Archive/Plugins
+---
+<div class="blockIndicator warning">
+<p><strong>Important</strong>: Since <a href="/en-US/docs/Mozilla/Firefox/Releases/52">Firefox 52</a>, all plugin support except Flash has been dropped (see <span><a href="https://www.fxsitecompat.com/en-CA/docs/2016/plug-in-support-has-been-dropped-other-than-flash/">Plug-in support has been dropped other than Flash</a> for more details</span>). Flash usage is also set to be phased out in the future.</p>
+</div>
+
+<div class="blockIndicator note">
+<p><strong>Note</strong>: Plugins are now a legacy technology. They are not available on most mobile devices. Mozilla encourages website developers to avoid using plugins wherever possible and use standard Web APIs instead. If there are plugin features which are not available in the web platform, we encourage developers to post their use cases to mozilla.dev.platform project list, so that Mozilla can prioritize web platform work to make those use cases possible.</p>
+</div>
+
+<p>For more information about plugin roadmap, see <a href="/en-US/docs/Plugins">non-archived plugin information</a>.</p>
+
+<p>Plugins are shared libraries that users can install to display content that the browser can't display natively. For example, the Adobe Reader plugin lets the user open PDF files directly inside the browser, and the QuickTime and RealPlayer plugins are used to play special format videos in a web page.</p>
+
+<p>Plugins are written using <strong>NPAPI</strong>, the cross-browser API for plugins. The main source of documentation for NPAPI is the <a href="/en/Gecko_Plugin_API_Reference" title="en/Gecko_Plugin_API_Reference">Gecko Plugin API Reference</a>. To make your plugin scriptable from web pages, use <a href="/en/Gecko_Plugin_API_Reference/Scripting_plugins" title="en/Gecko_Plugin_API_Reference/Scripting_plugins">npruntime</a>.</p>
+
+<p>Plugins can be written completely from scratch using C APIs (usually in C or C++) or they may be built on a plugin framework such as <a class="external" href="http://www.firebreath.org" title="http://www.firebreath.org/">Firebreath</a>, <a class="external" href="http://www.juce.com/" title="http://www.rawmaterialsoftware.com/juce.php">JUCE</a>, or <a class="external" href="http://doc.qt.nokia.com/solutions/4/qtbrowserplugin/developingplugins.html" title="http://doc.qt.nokia.com/solutions/4/qtbrowserplugin/developingplugins.html">QtBrowserPlugin</a>. There are also some code generation tools that may be helpful. More information about these tools can be found on the <a href="/en/Plugins/External_resources_for_plugin_creation" title="en/Plugins/External resources for plugin creation">External Resources</a> page.</p>
+
+<p>Plugins are different from <a href="/en/Extensions" title="en/Extensions">extensions</a>, which modify or enhance the functionality of the browser itself. Plugins are also different from <a href="/en/Creating_OpenSearch_plugins_for_Firefox" title="en/Creating_OpenSearch_plugins_for_Firefox">search plugins</a>, which plug additional search engines in the search bar.</p>
+
+<hr>
+<div class="topicpage-table">
+<div class="section">
+<dl>
+ <dt><a href="/en/Gecko_Plugin_API_Reference" title="en/Gecko_Plugin_API_Reference">Gecko Plugin API Reference</a> (NPAPI)</dt>
+ <dd>This reference describes the application programming interfaces for NPAPI plugins and provides information about how to use these interfaces.</dd>
+ <dt><a href="/en-US/docs/Site_Author_Guide_for_Click-To-Activate_Plugins">Site Author Guide For Click-To-Activate Plugins</a></dt>
+ <dd>These guidelines will help website authors use plugins when they are blocked by default with the Firefox click-to-activate feature.</dd>
+</dl>
+
+<dl>
+ <dt><a href="/en/Gecko_Plugin_API_Reference/Scripting_plugins" title="en/Gecko_Plugin_API_Reference/Scripting_plugins">Scripting plugins</a> (npruntime)</dt>
+ <dd>This reference describes the new cross-browser NPAPI extensions that let plugins be scriptable and also let them access the script objects in the browser.</dd>
+</dl>
+
+<dl>
+ <dt><a href="/en/Shipping_a_plugin_as_a_Toolkit_bundle" title="en/Shipping_a_plugin_as_a_Toolkit_bundle">Shipping a plugin as a Toolkit bundle</a></dt>
+ <dd>Plugins can be shipped as a Toolkit <a href="/en/Bundles" title="Bundles">bundle</a>, allowing a user to easily install, uninstall and manage their personal plugins.</dd>
+</dl>
+
+<dl>
+ <dt><a class="internal" href="/En/Supporting_private_browsing_in_plugins" title="en/Supporting private browsing in plugins">Supporting private browsing in plugins</a></dt>
+ <dd>Firefox 3.5 introduced support for private browsing; learn how to make your plugin respect the user's privacy wishes.</dd>
+ <dt><a href="/en/Plugins/Multi-Process_Plugin_Architecture" title="en/Plugins/Multi-Process Plugin Architecture">Multi-Process Plugin Architecture</a></dt>
+ <dd>How Firefox loads plugins into a separate process. Firefox 3.6.4 introduced out-of-process plugins which execute in a separate process so that a crashing plugin does not crash the browser.</dd>
+ <dt><a href="/en/Plugins/Logging" title="en/Plugins/Logging">Logging and Debugging for Multi-Process Plugins</a></dt>
+ <dd>How to create a plugin log to aid in debugging problems with multi-process plugins.</dd>
+</dl>
+</div>
+
+<div class="section">
+<dl>
+ <dt><a class="internal" href="/En/Writing_a_plugin_for_Mac_OS_X" title="en/Writing a plugin for Mac OS X">Writing a plugin for Mac OS X</a></dt>
+ <dd>Learn how to write a plugin for Mac OS X; a template Xcode project is provided.</dd>
+</dl>
+
+<dl>
+ <dt><a href="/en/Monitoring_plugins" title="en/Monitoring_plugins">Monitoring Plugins</a></dt>
+ <dd>Use an observer service notification to monitor the amount of time spent executing calls in plugins. This can be useful when trying to determine if a plug-in is consuming too many resources.</dd>
+</dl>
+
+<dl>
+ <dt><a href="/en/Scripting_Plugins/Adobe_Flash" title="en/Scripting_Plugins/Macromedia_Flash">Scripting Plugins: Macromedia Flash</a></dt>
+ <dd>This article explains how JavaScript can be used to access methods from within the Flash plugin, as well as how a feature called FSCommands can be used to access JavaScript functions from within the Flash animation.</dd>
+</dl>
+
+<dl>
+ <dt><a href="/en/Gecko_Plugin_API_Reference/Plug-in_Development_Overview" title="en/Plugins/The_First_Install_Problem">Plugins: The First Install Problem</a></dt>
+ <dd>The First Install Problem is the name given to the conditions arising when a plugin or embeddable software installs itself on a system first, before any other Gecko-based browser.</dd>
+</dl>
+
+<dl>
+ <dt><a href="/en/Plugins/Samples_and_Test_Cases" title="en/Plugins/Samples_and_Test_Cases">Plugins: Samples and Test Cases</a></dt>
+ <dd>NPAPI plugin samples and test cases.</dd>
+ <dt><a href="/en/Plugins/External_resources_for_plugin_creation" title="https://developer.mozilla.org/en/Plugins/External_resources_for_plugin_creation">External Resources for Plugin Creation</a></dt>
+ <dd>External projects, frameworks, and blog posts that may be useful.</dd>
+</dl>
+
+<dl>
+ <dt><a href="/en/XEmbed_Extension_for_Mozilla_Plugins" title="en/XEmbed_Extension_for_Mozilla_Plugins">XEmbed Extension for Mozilla Plugins</a></dt>
+ <dd>Recent versions of Mozilla on *nix-based systems include an extension for writing plugins that use XEmbed instead of using the old Xt-based main loop that most plugins have been using since the Netscape 3.x days.</dd>
+</dl>
+</div>
+</div>
+
+<hr>
+<p><span class="comment">Categories</span></p>
+
+<p><span class="comment">Interwiki Language Links</span></p>
+
+<div class="blockIndicator communitybox" dir="ltr">
+<div class="column-container">
+<h2 id="Join_the_plugin_development_community">Join the plugin development community</h2>
+
+<div class="column-half">
+<div class="communitysubhead">Choose your preferred method for joining the discussion:</div>
+
+<ul class="communitymailinglist">
+ <li><a href="https://lists.mozilla.org/listinfo/dev-tech-plugins">Mailing list</a></li>
+ <li><a href="http://groups.google.com/group/mozilla.dev.tech.plugins">Newsgroup</a></li>
+ <li><a href="http://groups.google.com/group/mozilla.dev.tech.plugins/feeds">RSS feed</a></li>
+</ul>
+</div>
+
+<div class="column-half"> </div>
+</div>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/plugins/reference/index.html b/files/zh-cn/mozilla/add-ons/plugins/reference/index.html
new file mode 100644
index 0000000000..fcb2ba7232
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/plugins/reference/index.html
@@ -0,0 +1,16 @@
+---
+title: NPAPI plugin reference
+slug: Mozilla/Add-ons/Plugins/Reference
+tags:
+ - Deprecated
+ - Landing
+ - NPAPI
+ - NeedsTranslation
+ - Plugins
+ - Reference
+ - TopicStub
+translation_of: Archive/Plugins/Reference
+---
+<p>{{deprecated_header}}</p>
+<p>The articles below describe each of the APIs related to NPAPI plugins.</p>
+<p>{{LandingPageListSubpages}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/plugins/samples_and_test_cases/index.html b/files/zh-cn/mozilla/add-ons/plugins/samples_and_test_cases/index.html
new file mode 100644
index 0000000000..4d0ac34085
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/plugins/samples_and_test_cases/index.html
@@ -0,0 +1,21 @@
+---
+title: Samples and Test Cases
+slug: Mozilla/Add-ons/Plugins/Samples_and_Test_Cases
+translation_of: Archive/Plugins/Samples_and_Test_Cases
+---
+<h2 id="NPAPI_Plugin_Samples">NPAPI Plugin Samples</h2>
+<p>Collections of NPAPI plugin samples can be found in the Seamonkey source code at <a class="external" href="http://mxr.mozilla.org/seamonkey/source/modules/plugin/samples/" title="http://mxr.mozilla.org/seamonkey/source/modules/plugin/samples/">/modules/plugin/sdk/samples</a>.</p>
+<p>The samples may not build any more on all platforms. There are plans to clean up the sample plugin situation - better organization, updated build systems, get them building on all platforms. However, even if one cannot build the samples they can still be very valuable as code references.</p>
+<p>There is a <a href="/en/Compiling_The_npruntime_Sample_Plugin_in_Visual_Studio" title="en/Compiling_The_npruntime_Sample_Plugin_in_Visual_Studio">guide to compiling the npruntime sample in Visual Studio</a>.</p>
+<p>In addition to those samples, there are 2 more plugins in the tree that might be helpful.</p>
+<ul>
+ <li><a class="external" href="http://mxr.mozilla.org/seamonkey/source/modules/plugin/tools/spy/">Spy</a></li>
+ <li><a class="external" href="http://mxr.mozilla.org/seamonkey/source/modules/plugin/tools/tester/">Tester</a></li>
+</ul>
+<h2 id="NPAPI_Plugin_Test_Cases">NPAPI Plugin Test Cases</h2>
+<ul>
+ <li>mozilla.org QA <a class="external" href="http://www.mozilla.org/quality/browser/front-end/testcases/plugins/">Plugins testcases</a></li>
+ <li>mozilla.org QA <a class="external" href="http://www.mozilla.org/quality/browser/front-end/testcases/oji/">OJI testcases</a></li>
+ <li><a class="external" href="http://www.mozilla.org/projects/plugins/plugins_testing_checklist.html">Plugins Verification Testing Checklist</a> (including <a class="external" href="http://www.mozilla.org/quality/smoketests/">SmokeTesting</a>)</li>
+</ul>
+<p>{{ languages( { "de": "de/Plugins/Beispiele_und_Testfälle" } ) }}</p>
diff --git a/files/zh-cn/mozilla/add-ons/plugins/shipping_a_plugin_as_a_toolkit_bundle/index.html b/files/zh-cn/mozilla/add-ons/plugins/shipping_a_plugin_as_a_toolkit_bundle/index.html
new file mode 100644
index 0000000000..30aae2d422
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/plugins/shipping_a_plugin_as_a_toolkit_bundle/index.html
@@ -0,0 +1,56 @@
+---
+title: Shipping a plugin as an extension
+slug: Mozilla/Add-ons/Plugins/Shipping_a_plugin_as_a_Toolkit_bundle
+tags:
+ - Extensions
+ - Plugins
+translation_of: Archive/Plugins/Shipping_a_plugin_as_a_Toolkit_bundle
+---
+<p>One of the new features that is available in Firefox 1.5 is the ability to place browser plug-ins in a Firefox extension.</p>
+<p>Historically, most people have chosen to use an install.js script to install a plug-in. When this method is used, you can choose to either place the plug-in into the plugins directory, or place it into your own directory and modify the Windows registry to let Firefox know where to find the plug-in. The downside to this method is that once the plug-in is installed, it might be difficult for users to upgrade, uninstall, or disable the plug-in. As of Firefox 3 (and any Gecko 1.9 based application) the use of install.js scripts is no longer possible and plugins must either be shipped as an executable installer or as an extension as described here.</p>
+<h2 id="Bundle_structure" name="Bundle_structure">Bundle structure</h2>
+<p><a href="cn/Bundles">Toolkit bundles</a> can be used for all add-ons including extensions, themes and plugins. Plugin packages should only need to package a small set of files in the follow structure in the xpi file:</p>
+<pre>install.rdf
+plugins/
+ pluginlib.dll
+ plugintypes.xpt
+</pre>
+<p>The install.rdf file contains an <a href="#Install_Manifest">install manifest</a> that describes the plugin to the user. The library and scripting interfaces are held in the &lt;tt&gt;plugins&lt;/tt&gt; directory.</p>
+<h3 id="Platform-specific_files" name="Platform-specific_files">Platform-specific files</h3>
+<p>It is possible to package multiple plugin libraries for different operating systems into a single xpi bundle. In the xpi you can use the following structure:</p>
+<pre>platform/
+ Linux_x86-gcc3/
+ plugins/
+ libplugin.so
+ Darwin_ppc-gcc3/
+ plugins/
+ libplugin.dylib
+</pre>
+<p>More specific information can be found in the <a href="cn/Bundles#Platform-specific_Subdirectories">platform-specific subdirectories</a> documentation.</p>
+<h2 id="Install_Manifest" name="Install_Manifest">Install Manifest</h2>
+<p>The <a href="cn/Install.rdf">install manifest</a> describes the plugin to the user. For a plugin the manifest only needs to be very simple:</p>
+<pre>&lt;RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#"&gt;
+ &lt;Description about="urn:mozilla:install-manifest"&gt;
+ &lt;em:id&gt;mypluginid@myplugin.com&lt;/em:id&gt;
+ &lt;em:name&gt;My Plugin&lt;/em:name&gt;
+ &lt;em:version&gt;1.0&lt;/em:version&gt;
+ &lt;em:targetApplication&gt;
+ &lt;Description&gt;
+ &lt;em:id&gt;{ec8030f7-c20a-464f-9b0e-13a3a9e97384}&lt;/em:id&gt;
+ &lt;em:minVersion&gt;1.5&lt;/em:minVersion&gt;
+ &lt;em:maxVersion&gt;3.0.*&lt;/em:maxVersion&gt;
+ &lt;/Description&gt;
+ &lt;/em:targetApplication&gt;
+ &lt;/Description&gt;
+&lt;/RDF&gt;
+</pre>
+<p>This contains 4 required pieces of information.</p>
+<ol>
+ <li>Every add-on must have a unique id. This can be in a guid form but the simpler email form is preferred now. You should aim to use a domain-name that you own and then your own unique short-name for the plugin before the @.</li>
+ <li>The plugin must have a name to identify the plugin to the user in the list of add-ons.</li>
+ <li>The version is fairly self-descriptive, it must be a <a href="cn/Toolkit_version_format">toolkit version format</a>.</li>
+ <li>The target application block says which versions of an application the plugin is compatible with. It includes the application ID and the minimum and maximum version of the application that the plugin works with. There can be multiple targetApplication blocks listed.</li>
+</ol>
+<h2 id="Providing_updates" name="Providing_updates">Providing updates</h2>
+<p>When plugins are packaged in this way they can make use of the built in add-on update system. This allows a remote update file to be read periodically and an updated version of the plugin offered to the user or to mark the plugin as compatible with a wider range of applications.</p>
+<p>This is performed by including an <a href="cn/Install.rdf#updateURL">updateURL</a> in the install manifest. This should point to an <a href="cn/Extension_Versioning%2c_Update_and_Compatibility#Update_RDF_Format">update.rdf</a> file on the internet which will include the updated versions and version information for the plugin.</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/builder/index.html b/files/zh-cn/mozilla/add-ons/sdk/builder/index.html
new file mode 100644
index 0000000000..1baa282d43
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/builder/index.html
@@ -0,0 +1,13 @@
+---
+title: Builder
+slug: Mozilla/Add-ons/SDK/Builder
+translation_of: Archive/Add-ons/Add-on_SDK/Builder
+---
+<p>The Add-on Builder was a web-based development environment that allowed developers to create add-ons using the SDK APIs, but without needing to use the <code>cfx</code> command line tool. It was retired on April 1, 2014, and the "builder.addons.mozilla.org" domain now redirects to this page.<br>
+ <br>
+ If you have only used the SDK through the Builder, you already know most of what you need to know to develop using just the SDK. The <a href="/en-US/Add-ons/SDK/High-Level_APIs">high-level</a> and <a href="/en-US/Add-ons/SDK/Low-Level_APIs">low-level</a> APIs used for Builder add-ons are exactly the same for Builder and SDK. To switch to the SDK:</p>
+<ul>
+ <li><a href="/en-US/Add-ons/SDK/Tutorials/Installation">install the SDK locally</a></li>
+ <li>get to know the cfx command line tool, with this <a href="/en-US/Add-ons/SDK/Tutorials/Getting_started">introductory walkthrough</a> and the <a href="/en-US/Add-ons/SDK/Tools/cfx">detailed <code>cfx</code> reference</a></li>
+ <li>get to know the <a href="/en-US/Add-ons/SDK/Tools/package_json">package.json</a> file used to configure attributes of your add-on</li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/guides/content_scripts/index.html b/files/zh-cn/mozilla/add-ons/sdk/guides/content_scripts/index.html
new file mode 100644
index 0000000000..fa95b15db3
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/guides/content_scripts/index.html
@@ -0,0 +1,486 @@
+---
+title: Content Scripts(内容脚本)
+slug: Mozilla/Add-ons/SDK/Guides/Content_Scripts
+translation_of: Archive/Add-ons/Add-on_SDK/Guides/Content_Scripts
+---
+<article id="wikiArticle">{{AddonSidebar}}
+<p><span class="seoSummary">很多 add-ons 需要访问和修改 web 页面的内容。但是 add-on 的主代码不能直接访问 web 内容。替代方案是, SDK add-ons 需要使用一些分散的脚本代理访问 web 内容,这些脚本被称作<em>内容脚本(content scripts)</em>。本页面描述如何开发和部署内容脚本。 </span></p>
+
+<p>内容脚本是在使用SDK时很令人疑惑的点,但你很有可能不得不使用它们。下面有五个基本原则:</p>
+
+<ul>
+ <li>add-on 的主代码,包括"main.js"和其他"lib"下的模块,可以使用 SDK <a href="/zh-CN/docs/Mozilla/Add-ons/SDK/High-Level_APIs">高层次</a>和<a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Low-Level_APIs">低层次</a> APIs,但不能直接访问 web 内容</li>
+ <li>内容脚本 <a href="/en-US/Add-ons/SDK/Guides/Two_Types_of_Scripts#API_Access_for_Add-on_Code_and_Content_Scripts">不能使用 SDK 的 API</a>(访问不了 globals 的 <code>exports</code>、<code>require</code>),但你可以访问 web 内容</li>
+ <li>SDK API 可以使用,内容脚本,比如 <a href="/en-US/Add-ons/SDK/High-Level_APIs/page-mod">page-mod</a> 和 <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs">tabs</a>,提供了一些函数,使得 add-on 的主代码可以将内容脚本载入web页面中。</li>
+ <li>内容脚本可以作为字符串加载,但是更常见的是分离存储为 add-on 的"data"目录下文件。 jpm 不会默认创建"data"目录,所以你必须添加该目录并把脚本放进去。</li>
+ <li>一个消息传递 API 允许主代码和内容脚本间相互通信。</li>
+</ul>
+
+<p>这个完整的 add-on 表现出所有的这些原则。它的"main.js"使用 <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs">tabs</a> 模块附加了一个内容脚本到当前标签页。本例中内容脚本作为字符串传递,内容脚本简单地替换了页面的内容:</p>
+
+<pre class="brush: js">// main.js
+var tabs = require("sdk/tabs");
+var contentScriptString = 'document.body.innerHTML = "&lt;h1&gt;this page has been eaten&lt;/h1&gt;";'
+
+tabs.activeTab.attach({
+ contentScript: contentScriptString
+});</pre>
+
+<p>下面的高层次 SDK 模块能使用内容脚本来修改 web 页面:</p>
+
+<ul>
+ <li><a href="/en-US/Add-ons/SDK/High-Level_APIs/page-mod">page-mod</a>:使你能附加一个内容脚本到匹配上特定 URL 模式的web页面。</li>
+ <li><a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs">tabs</a>:导出一个 <code>Tab</code> 对象来处理浏览器标签页。<code>Tab</code> 对象包括了一个 <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs#attach(options)"><code>attach()</code></a> 函数来附加内容脚本到标签页。</li>
+ <li><a href="/en-US/Add-ons/SDK/High-Level_APIs/page-worker">page-worker</a>:让你能够恢复一个 web 页面,但不显示它。你可以附加内容脚本到该页面,来访问和操作该页面的 DOM。</li>
+ <li><a href="/en-US/Add-ons/SDK/High-Level_APIs/context-menu">context-menu</a>:使用内容脚本来和按钮所在的页面交互。</li>
+</ul>
+
+<p>另外,还能使用 HTML 定义了一些 SDK 用户接口组件,并且使用分类的脚本来和这些内容交互。从很多方面来讲,这些脚本就像内容脚本一样,但它们并不是本文的关注点。要学习如何和用户接口模块的内容交互,请参看模块定义文档:<a href="/en-US/Add-ons/SDK/High-Level_APIs/panel">panel</a>、<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_sidebar">sidebar</a>、<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_frame">frame</a>。</p>
+
+<p>这篇指南中列出的几乎所有的示例都是完整并且且最小的,可以在 Github 的 <a href="https://github.com/mdn/addon-sdk-content-scripts">addon-sdk-content-scripts repository</a> 页面上获得。</p>
+
+<h2 id="加载用户脚本">加载用户脚本</h2>
+
+<article id="wikiArticle">
+<p>你可以声明一个字符串或者指定 <code>contentScript</code> 或 <code>contentScriptFile</code> 选项加载一个单独的脚本。<code>contentScript</code> 选项接受一个作为脚本的字符串:</p>
+
+<pre class="brush: js">// main.js
+
+var pageMod = require("sdk/page-mod");
+var contentScriptValue = 'document.body.innerHTML = ' +
+ ' "&lt;h1&gt;Page matches ruleset&lt;/h1&gt;";';
+
+pageMod.PageMod({
+ include: "*.mozilla.org",
+ contentScript: contentScriptValue
+});</pre>
+
+<p><code>contentScriptFile</code> 选项接受一个作为 resource:// URL 的字符串,指向一个存储在你的 add-on 的 <code>data</code> 目录中的脚本文件。jpm不会默认创建"data"目录,所以你必须创建该目录并将你的用户脚本放进去。</p>
+
+<p>本 add-on 提供一个 URL ,指向"content-script.js"文件,存储在 add-on 根目录下的 <code>data</code> 子目录:</p>
+
+<pre class="brush: js">// main.js
+
+var data = require("sdk/self").data;
+var pageMod = require("sdk/page-mod");
+
+pageMod.PageMod({
+ include: "*.mozilla.org",
+ contentScriptFile: data.url("content-script.js")
+});</pre>
+
+<pre class="brush: js">// content-script.js
+
+document.body.innerHTML = "&lt;h1&gt;Page matches ruleset&lt;/h1&gt;";</pre>
+
+<div class="note">
+<p>从 Firefox 34 开始,你可以使用"./content-script.js"替代 self.data.url("content-script.js")。所以你可以像这样重写:</p>
+
+<pre class="brush: js">var pageMod = require("sdk/page-mod");
+
+pageMod.PageMod({
+ include: "*.mozilla.org",
+ contentScriptFile: "./content-script.js"
+});
+</pre>
+</div>
+
+<div class="warning">
+<p>除非你的内容脚本非常简单并且固定是一个静态的字符串,请不要使用 <code>contentScript</code>:否则,你会在从 AMO 获取你的add-on上遇到问题。</p>
+
+<p>相反,把脚本放到一个单独的文件并用 <code>contentScriptFile</code> 加载它。这回事你的代码更易维护、安全、调试和审核。</p>
+</div>
+
+<p>你可以给 <code>contentScript</code> 或 <code>contentScriptFile</code> 传递字符串数组来加载多个脚本:</p>
+
+<pre class="brush: js">// main.js
+
+var tabs = require("sdk/tabs");
+
+tabs.on('ready', function(tab) {
+ tab.attach({
+ contentScript: ['document.body.style.border = "5px solid red";', 'window.alert("hi");']
+ });
+});
+</pre>
+
+<pre class="brush: js">// main.js
+
+var data = require("sdk/self").data;
+var pageMod = require("sdk/page-mod");
+
+pageMod.PageMod({
+ include: "*.mozilla.org",
+ contentScriptFile: [data.url("jquery.min.js"), data.url("my-content-script.js")]
+});</pre>
+
+<p>如果你这么做,这些脚本之间可以直接交互,就像他们被同一个 web 页面加载一样。</p>
+
+<p>你也可以把 <code>contentScript</code> 和 <code>contentScriptFile</code> 一起用。如果你这么做,使用 <code>contentScriptFile</code> 定义的脚本会在使用 <code>contentScript</code> 定义的脚本之前加载。这使你能够用 URL 加载比如 jQuery 这样的 JavaScript 库,然后传递一个简单的能够使用jQuery脚本:</p>
+
+<pre class="brush: js">// main.js
+
+var data = require("sdk/self").data;
+var pageMod = require("sdk/page-mod");
+
+var contentScriptString = '$("body").html("&lt;h1&gt;Page matches ruleset&lt;/h1&gt;");';
+
+pageMod.PageMod({
+ include: "*.mozilla.org",
+ contentScript: contentScriptString,
+ contentScriptFile: data.url("jquery.js")
+});</pre>
+
+<div class="warning">
+<p>除非你的内容脚本非常简单并且固定是一个静态的字符串,请不要使用 <code>contentScript</code>:否则,在从 AMO 获取你的 add-on 上,你会遇到问题。</p>
+
+<p>相反,把脚本放到一个单独的文件并用 <code>contentScriptFile</code> 加载它。这回事你的代码更易维护、安全、调试和审核。</p>
+</div>
+
+<h3 id="控制附加脚本的时间">控制附加脚本的时间</h3>
+
+<p><code>contentScriptWhen</code> 选项指定了什么时候加载内容脚本。从这里选一个:</p>
+
+<ul>
+ <li><code>"start"</code>:页面 document 元素插入 DOM 之后,立即加载脚本。这时 DOM 的内容仍未加载,所以脚本不能与其交互。</li>
+ <li><code>"ready"</code>:页面 DOM 加载完后加载脚本:也就是说,在那个时间点 <a href="https://developer.mozilla.org/en/Gecko-Specific_DOM_Events">DOMContentLoaded</a> 事件触发。这时,内容脚本可以和DOM内容交互,但外部引用的样式表和图片可能还没有完成加载。</li>
+ <li><code>"end"</code>:页面上所有内容(DOM、JS、CSS、images)加载完后,加载脚本,就是在 <a href="https://developer.mozilla.org/en/DOM/window.onload">window.onload 事件</a>触发的时候</li>
+</ul>
+
+<p>默认值为 <code>"end"</code>。</p>
+
+<p>注意 <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs#attach(options)"><code>tab.attach()</code></a> 不支持 contentScriptWhen,因为它原来就是在页面加载页面的时候被调用的。</p>
+
+<h3 id="传递配置选项">传递配置选项</h3>
+
+<p><code>contentScriptOptions</code> 是一个作为只读对象暴露给内容脚本的JSON对象,在 <code><a href="/en-US/Add-ons/SDK/Guides/Content_Scripts/self">self</a>.options</code> 的属性里:</p>
+
+<pre class="brush: js">// main.js
+
+var tabs = require("sdk/tabs");
+
+tabs.on('ready', function(tab) {
+ tab.attach({
+ contentScript: 'window.alert(self.options.message);',
+ contentScriptOptions: {"message" : "hello world"}
+ });
+});</pre>
+
+<p>这里可以使用任何可以转成json的值(object、array、string等等)。</p>
+
+<h2 id="访问_DOM">访问 DOM</h2>
+
+<p>内容脚本可以访问页面的 DOM,就像任何页面中加载的脚本(页面脚本)一样。但是内容脚本和页面脚本之间是隔离的:</p>
+
+<ul>
+ <li>内容脚本不能看到任何由页面脚本添加到页面的 JavaScript 对象</li>
+ <li>如果页面脚本重定义了某个 DOM 对象的行为,但内容脚本只会看到原来的那个行为。</li>
+</ul>
+
+<p>相反也是如此:页面脚本不能看到内容脚本添加的 JavaScript 对象。</p>
+
+<p>例如,假想一个页面用页面脚本添加变量 <code>foo</code> 到 <code>window</code> 对象:</p>
+
+<pre class="brush: html">&lt;!DOCTYPE html"&gt;
+&lt;html&gt;
+ &lt;head&gt;
+ &lt;script&gt;
+ window.foo = "hello from page script"
+ &lt;/script&gt;
+ &lt;/head&gt;
+&lt;/html&gt;</pre>
+
+<p>在这个脚本后面加载到页面的其他脚本也可以访问 <code>foo</code>。但是内容脚本不能:</p>
+
+<pre class="brush: js">// main.js
+
+var tabs = require("sdk/tabs");
+var mod = require("sdk/page-mod");
+var self = require("sdk/self");
+
+var pageUrl = self.data.url("page.html")
+
+var pageMod = mod.PageMod({
+ include: pageUrl,
+ contentScript: "console.log(window.foo);"
+})
+
+tabs.open(pageUrl);</pre>
+
+<pre>console.log: my-addon: null
+</pre>
+
+<p>这种隔离策略有着很合理的理由。首先,这意味着内容脚本不会泄露对象给 web 页面,这样可能会打开安全漏洞。第二,这意味着,在内容脚本创建对象的时候,可以不用担心是否会和页面脚本添加的对象相冲突。</p>
+
+<p>这种隔离意味着,例如,如果一个 web 页面加载了 jQuery 库,那么内容脚本不能够看到由该库添加的 <code>jQuery</code> 对象——但是可以看到内容脚本添加的自己的 <code>jQuery</code> 对象,并且它不会和页面脚本的 jQuery 版本冲突。</p>
+
+<h3 id="和页面脚本交互">和页面脚本交互</h3>
+
+<p>一般来说,这种内容脚本和页面脚本的隔离正是你所希望的。但是有时候你也许会希望和页面脚本交互:你想在内容脚本和页面脚本之间共享对象来,来在它们之间发送消息。如果你需要这么做,请阅读<a href="/en-US/Add-ons/SDK/Guides/Content_Scripts/Interacting_with_page_scripts">和页面脚本交互</a>。</p>
+
+<h3 id="事件监听器">事件监听器</h3>
+
+<p>你可以监听 DOM 的事件,就像在页面脚本中一样,但是有两个重要的区别:</p>
+
+<p>第一,如果你向 <a href="https://developer.mozilla.org/en/DOM/element.setAttribute"><code>setAttribute()</code></a> 传递字符串,来定义了事件监听器,那么此监听器被当做是在页面上下文中的,所以它不能访问任何内容脚本中的变量。</p>
+
+<p>如下,内容脚本会失败报错"theMessage is not defined":</p>
+
+<pre class="brush: js">var theMessage = "Hello from content script!";
+anElement.setAttribute("onclick", "alert(theMessage);");</pre>
+
+<p>Second, if you define an event listener by direct assignment to a <a href="/en-US/docs/Web/API/GlobalEventHandlers">global event handler</a> like <code>onclick</code>, then the assignment might be overridden by the page. For example, here's an add-on that tries to add a click handler by assignment to <code>window.onclick</code>:</p>
+
+<pre class="brush: js">var myScript = "window.onclick = function() {" +
+ " console.log('unsafewindow.onclick: ' + window.document.title);" +
+ "}";
+
+require("sdk/page-mod").PageMod({
+ include: "*",
+ contentScript: myScript,
+ contentScriptWhen: "start"
+});</pre>
+
+<p>这个示例会在大多数页面上正常工作,但是会在定义 <code>onclick</code> 的页面上失败:</p>
+
+<pre class="brush: html">&lt;html&gt;
+ &lt;head&gt;
+ &lt;/head&gt;
+ &lt;body&gt;
+ &lt;script&gt;
+ window.onclick = function() {
+ window.alert("it's my click now!");
+ }
+ &lt;/script&gt;
+ &lt;/body&gt;
+&lt;/html&gt;</pre>
+
+<p>由于这些原因,最好还是用 <a href="https://developer.mozilla.org/en/DOM/element.addEventListener"><code>addEventListener()</code> 添加一个事件监听器</a>,定义监听器为一个函数:</p>
+
+<pre class="brush: js">var theMessage = "Hello from content script!";
+
+anElement.onclick = function() {
+ alert(theMessage);
+};
+
+anotherElement.addEventListener("click", function() {
+ alert(theMessage);
+});</pre>
+
+<h2 id="和_add-on_通信">和 add-on 通信</h2>
+
+<p>为了使 add-on 脚本和内容脚本相互通信,任何一通信端都要访问 <code>port</code> 对象。</p>
+
+<ul>
+ <li>要从一头发送消息到另一头,使用 <code>port.emit()</code></li>
+ <li>要从另一头接收消息,使用 <code>port.on()</code></li>
+</ul>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/7873/content-scripting-overview.png" style="display: block; margin-left: auto; margin-right: auto;">消息是异步的:也就是说,发送方不会等待接收方的回应,而仅仅是发送消息完后继续处理别的事情。</p>
+
+<p>这里有一个简单的 add-on 使用 <code>port</code> 发送一个消息到内容脚本:</p>
+
+<pre class="brush: js">// main.js
+
+var tabs = require("sdk/tabs");
+var self = require("sdk/self");
+
+tabs.on("ready", function(tab) {
+ var worker = tab.attach({
+ contentScriptFile: self.data.url("content-script.js")
+ });
+ worker.port.emit("alert", "Message from the add-on");
+});
+
+tabs.open("http://www.mozilla.org");</pre>
+
+<pre class="brush: js">// content-script.js
+
+self.port.on("alert", function(message) {
+ window.alert(message);
+});</pre>
+
+<div class="note">
+<p>context-menu 模块没有使用这里描述的通信模型。了解更多关于使用 context-menu 和内容脚本通信的事情,参看 <a href="/en-US/Add-ons/SDK/High-Level_APIs/context-menu">context-menu documentation</a>。</p>
+</div>
+
+<h3 id="在内容脚本中访问_port"><code>在内容脚本中访问 port</code></h3>
+
+<p>内容脚本中,<code>port</code> 对象是作为global下 <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts/self"><code>self</code></a> 对象的属性。所以要从内容脚本中发送消息的话:</p>
+
+<pre class="brush: js">self.port.emit("myContentScriptMessage", myContentScriptMessagePayload);</pre>
+
+<p>要从 add-on 代码接收消息</p>
+
+<pre class="brush: js">self.port.on("myAddonMessage", function(myAddonMessagePayload) {
+ // Handle the message
+});</pre>
+
+<div class="note">
+<p>注意 global下 <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts/self"><code>self</code></a> 对象和 <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/self"><code>self</code> 模块</a>完全不一样,后者提供一个API给 add-on,用来访问它的数据文件和ID。</p>
+</div>
+
+<h3 id="在内容脚本中访问_port_2">在内容脚本中访问 port</h3>
+
+<p>在 add-on 代码中,联通 add-on 和某一特定内容脚本上下文的通道被封装入 <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/content_worker"><code>worker</code></a> 对象。所以和内容脚本通信的 <code>port</code> 对象其实是其相对应的 <code>worker</code> 对象的一个属性。</p>
+
+<p>但是,这个 worker 没有暴露给 add-on 代码,以及同样所有的模块。</p>
+
+<h4 id="从_page-worker">从 <code>page-worker</code></h4>
+
+<p><code>page-worker</code> 对象直接整合了 work API。所以要从一个由 <code>page-worker</code> 关联的内容脚本接收消息的话,你可以使用 <code>pageWorker.port.on()</code>:</p>
+
+<pre class="brush: js">// main.js
+
+var self = require("sdk/self");
+
+var pageWorker = require("sdk/page-worker").Page({
+  contentScriptFile: self.data.url("content-script.js"),
+  contentURL: "http://en.wikipedia.org/wiki/Internet"
+});
+
+pageWorker.port.on("first-para", function(firstPara) {
+  console.log(firstPara);
+});</pre>
+
+<p>要从你的 add-on 发送用户定义的消息,你可以只调用 <code>pageWorker.port.emit()</code>:</p>
+
+<pre class="brush: js">// main.js
+
+var self = require("sdk/self");
+
+var pageWorker = require("sdk/page-worker").Page({
+  contentScriptFile: self.data.url("content-script.js"),
+  contentURL: "http://en.wikipedia.org/wiki/Internet"
+});
+
+pageWorker.port.on("first-para", function(firstPara) {
+  console.log(firstPara);
+});
+
+pageWorker.port.emit("get-first-para");</pre>
+
+<pre class="brush: js">// content-script.js
+
+self.port.on("get-first-para", getFirstPara);
+
+function getFirstPara() {
+ var paras = document.getElementsByTagName("p");
+ if (paras.length &gt; 0) {
+ var firstPara = paras[0].textContent;
+ self.port.emit("first-para", firstPara);
+ }
+}</pre>
+
+<h4 id="从_page-mod">从<code> page-mod</code></h4>
+
+<p>单个 <code>page-mod</code> 对象可以附加它的脚本到多个页面,每个页面有它自己的上下文来运行内容脚本,所以每个页面都需要相互隔离的通道(worker)。</p>
+
+<p>所以 <code>page-mod</code> 没有直接整合 worker 的 API。而是在每次内容脚本被附加到页面时,page-mod 发送一个 <code>attach</code> 事件,它的监听器会给对应的上下文传递一个 worker。通过为 <code>attach</code> 提供一个监听器,你可以访问被一个 page-mod 附加到页面上的内容脚本的 <code>port</code> 对象:</p>
+
+<pre class="brush: js">// main.js
+
+var pageMods = require("sdk/page-mod");
+var self = require("sdk/self");
+
+var pageMod = pageMods.PageMod({
+  include: ['*'],
+  contentScriptFile: self.data.url("content-script.js"),
+  onAttach: startListening
+});
+
+function startListening(worker) {
+  worker.port.on('click', function(html) {
+    worker.port.emit('warning', 'Do not click this again');
+  });
+}</pre>
+
+<pre class="brush: js">// content-script.js
+
+window.addEventListener('click', function(event) {
+ self.port.emit('click', event.target.toString());
+ event.stopPropagation();
+ event.preventDefault();
+}, false);
+
+self.port.on('warning', function(message) {
+ window.alert(message);
+});
+</pre>
+
+<p>上面的 add-on 里有两条消息:</p>
+
+<ul>
+ <li>当用户点击页面元素时,<code>click</code> 从 page-mod 被发送到当前 add-on。</li>
+ <li><code>warning</code> 发送一条傻气的字符串回给page-mod</li>
+</ul>
+
+<h4 id="从_Tab.attach()">从 <code>Tab.attach()</code></h4>
+
+<p><code>Tab.attach()</code> 方法返回一个 worker,你可以用来和附加的内容脚本通信。</p>
+
+<p>这个 add-on 添加了一个按钮到Firefox:等用户点击按钮是,这个 add-on 附加一个内容脚本到当前的标签页,发送给内容脚本一条名为 "my-addon-message"的消息,并且监听名为"my-script-response"的响应:</p>
+
+<pre class="brush: js">//main.js
+
+var tabs = require("sdk/tabs");
+var buttons = require("sdk/ui/button/action");
+var self = require("sdk/self");
+
+buttons.ActionButton({
+ id: "attach-script",
+ label: "Attach the script",
+ icon: "./icon-16.png",
+ onClick: attachScript
+});
+
+function attachScript() {
+ var worker = tabs.activeTab.attach({
+ contentScriptFile: self.data.url("content-script.js")
+ });
+ worker.port.on("my-script-response", function(response) {
+ console.log(response);
+ });
+ worker.port.emit("my-addon-message", "Message from the add-on");
+}
+</pre>
+
+<pre class="brush: js">// content-script.js
+
+self.port.on("my-addon-message", handleMessage);
+
+function handleMessage(message) {
+ alert(message);
+ self.port.emit("my-script-response", "Response from content script");
+}</pre>
+
+<h3 id="port的API">port的API</h3>
+
+<p>参看 <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts/port"><code>port</code> 对象的参考文档</a>.</p>
+</article>
+
+<h3 id="postMessage的API">postMessage的API</h3>
+
+<p>在 <code>port</code> 对象加载之前,add-on 代码和内容脚本可以使用另一个 API 通信:</p>
+
+<ul>
+ <li>内容脚本调用 <code>self.postMessage()</code> 来发送,并用 <code>self.on()</code> 来接收</li>
+ <li>内容脚本调用 <code>worker.postMessage()</code> 来发送,并用 <code>worker.on()</code> 来接收</li>
+</ul>
+
+<p>这个API依然可用,并且还有<a href="/en-US/Add-ons/SDK/Guides/Content_Scripts/using_postMessage">文档</a>,但是没有理由替代前文描述的 <code>port</code> API。 例外是 <a href="/en-US/Add-ons/SDK/High-Level_APIs/context-menu">context-menu</a> 模块,它还是使用 postMessage。</p>
+
+<h3 id="内容脚本的内容脚本">内容脚本的内容脚本</h3>
+
+<p>内容脚本可用直接和其他同一个上下文中的内容脚本通信。举个例子,如果一次 <code>Tab.attach()</code> 的调用附加了两个脚本,那么他们可用直接相互查看,就像加载在同一页面内的页面脚本一样。但是如果你调用 <code>Tab.attach()</code> 两次,每次附加一个内容脚本,那么这些内容脚本之间不能通信。你必须使用port API 通过 add-on 的主代码来传递消息。</p>
+
+<h2 id="跨域的内容脚本">跨域的内容脚本</h2>
+
+<p>默认情况下,内容脚本没有跨域的权限。特别是,它们不能访问在不同 <code>iframe</code> 中的在另外的域名上的内容,也不能发起跨域的 XMLHttpRequests。</p>
+
+<p>但是,你可以把需要的域名添加到 <a href="/en-US/Add-ons/SDK/Tools/package_json">package.json</a> 中<code>"permissions"</code>键下的 <code>"cross-domain-content"</code>键下,为这些域名打开这些特性。参阅文章<a href="/en-US/Add-ons/SDK/Guides/Content_Scripts/Cross_Domain_Content_Scripts">跨域内容脚本</a>。</p>
+</article>
+
+<div id="xunlei_com_thunder_helper_plugin_d462f475-c18e-46be-bd10-327458d045bd"> </div>
+
+<div id="xunlei_com_thunder_helper_plugin_d462f475-c18e-46be-bd10-327458d045bd"> </div>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/guides/index.html b/files/zh-cn/mozilla/add-ons/sdk/guides/index.html
new file mode 100644
index 0000000000..51fbdef445
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/guides/index.html
@@ -0,0 +1,115 @@
+---
+title: 教程
+slug: Mozilla/Add-ons/SDK/Guides
+tags:
+ - NeedsTranslation
+ - TopicStub
+translation_of: Archive/Add-ons/Add-on_SDK/Guides
+---
+<p>下面列出了一些文章可以加深你对SDK的理解</p>
+<hr>
+<h3 id="投稿者的教程"><a name="contributors-guide">投稿者的教程</a></h3>
+<div class="column-container">
+ <div class="column-half">
+ <dl>
+ <dt>
+ <a href="Guides/Getting_Started">起步</a></dt>
+ <dd>
+ 学会如何使用SDK : 编写代码, 调试bug, 提交补丁, 审核项目, 获得帮助.</dd>
+ <dt>
+ <a href="Guides/Modules">模块</a></dt>
+ <dd>
+ 通过SDK学会模块的使用 (以CommonJS为规范), 懂得如何使用 sandboxes 和compartments 提高安全性, 并且了解内置的 SDK module loader (被称为Cuddlefish).</dd>
+ <dt>
+ <a href="Guides/Classes_and_Inheritance">类 和 继承</a></dt>
+ <dd>
+ 学会<strong> 类</strong>和<strong>继承</strong>在JavaScript中的运行机制, 使用<strong>构造(constructors)</strong>和<strong>原型(prototypes)</strong>, 并知道如何使用SDK提供的函数帮助器简化它.</dd>
+ </dl>
+ </div>
+ <div class="column-half">
+ <dl>
+ <dt>
+ <a href="Guides/Private_Properties">私有成员</a></dt>
+ <dd>
+ 通过 前缀, 闭包, 和WeakMaps 学会私有成员如何在JavaScript中的实现, 使用 命名空间(通常指WeakMaps) 学会SDK如何支持私有成员.</dd>
+ <dt>
+ <a href="Guides/Content_Processes">脚本运行流程</a></dt>
+ <dd>
+ SDK的设计目的是为了使控制网页内容的扩展脚本可以在不同进程的环境中运行. 这篇文章强调了这一设计的特点.</dd>
+ </dl>
+ </div>
+</div>
+<hr>
+<h3 id="SDK的基础结构"><a name="sdk-infrastructure">SDK的基础结构</a></h3>
+<div class="column-container">
+ <div class="column-half">
+ <dl>
+ <dt>
+ <a href="Guides/Module_structure_of_the_SDK">SDK 模块结构</a></dt>
+ <dd>
+ SDK是可重复使用的 JavaScript 模块. 这里解释了什么是模块, 怎样加载模块, 和SDK模块树的构造.</dd>
+ <dt>
+ <a href="Guides/SDK_API_Lifecycle">SDK API 生存周期</a></dt>
+ <dd>
+ 为SDK的API定义生命周期,  包括API稳定性的排名</dd>
+ </dl>
+ </div>
+ <div class="column-half">
+ <dl>
+ <dt>
+ <a href="Guides/Program_ID">程序 ID</a></dt>
+ <dd>
+ 程序ID 是扩展独一无二的标识符. 教程解释了如何定义你自己的程序 ID.</dd>
+ <dt>
+ <a href="Guides/Firefox_Compatibility">Firefox 兼容</a></dt>
+ <dd>
+ 解决不同版本SDK生成的扩展与不同版本Firefox的兼容问题</dd>
+ </dl>
+ </div>
+</div>
+<hr>
+<h3 id="SDK_常用技巧"><a name="sdk-idioms">SDK 常用技巧</a></h3>
+<div class="column-container">
+ <div class="column-half">
+ <dl>
+ <dt>
+ <a href="Guides/Working_with_Events">善用 事件触发</a></dt>
+ <dd>
+ 通过SDK的事件触发框架 写出以事件驱动为基础的代码</dd>
+ </dl>
+ </div>
+ <div class="column-half">
+ <dl>
+ <dt>
+ <a href="Guides/Two_Types_of_Scripts">脚本的两种类型</a></dt>
+ <dd>
+ 这篇文章可以帮助你理解扩展中的API和普通脚本的区别</dd>
+ </dl>
+ </div>
+</div>
+<p> </p>
+<hr>
+<h3 id="XUL_迁移"><a name="xul-migration">XUL 迁移</a></h3>
+<div class="column-container">
+ <div class="column-half">
+ <dl>
+ <dt>
+ <a href="Guides/XUL_Migration_Guide">XUL 迁移教程</a></dt>
+ <dd>
+ 把XUL扩展迁移到SDK的技巧</dd>
+ <dt>
+ <a href="Guides/XUL_vs_SDK">XUL 与 SDK 不同</a></dt>
+ <dd>
+ 比较 传统的以XUL为基础的扩展 和 SDK 两者优点和缺点</dd>
+ </dl>
+ </div>
+ <div class="column-half">
+ <dl>
+ <dt>
+ <a href="Guides/Porting_the_Library_Detector">移植例子</a></dt>
+ <dd>
+ 一个简单地教你如何让 基于XUL的扩展 迁移到 SDK中的实例</dd>
+ </dl>
+ </div>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/guides/multiprocess_firefox_and_the_sdk/index.html b/files/zh-cn/mozilla/add-ons/sdk/guides/multiprocess_firefox_and_the_sdk/index.html
new file mode 100644
index 0000000000..c22dd0181e
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/guides/multiprocess_firefox_and_the_sdk/index.html
@@ -0,0 +1,212 @@
+---
+title: 多进程 Firefox 与 SDK
+slug: Mozilla/Add-ons/SDK/Guides/Multiprocess_Firefox_and_the_SDK
+translation_of: Archive/Add-ons/Add-on_SDK/Guides/Multiprocess_Firefox_and_the_SDK
+---
+<p>我们目前正在使 Firefox 变为多进程,它为浏览器界面使用一个操作系统进程,为运行的网页使用另一个进程来执行代码,这个项目被称为 "electrolysis" 或者 "e10s"。更多信息请参考<a href="/en-US/Firefox/Multiprocess_Firefox">多进程 Firefox 相关页面</a>。</p>
+
+<p>本文章介绍了开发者如何测试基于 SDK 的附加组件是否与多进程的 Firefox 兼容,以及如何解决出现的问题。</p>
+
+<h2 id="SDK_的合约">SDK 的合约</h2>
+
+<p>SDK 为附加组件的开发者承诺了:</p>
+
+<ul>
+ <li><a href="/en-US/Add-ons/SDK/High-Level_APIs">顶层 API</a> 对多进程 Firefox 完全工作。如果并没有,请报告为 SDK 中的 bug。</li>
+ <li><a href="/en-US/Add-ons/SDK/Low-Level_APIs">底层 API</a> 也许不工作。如果你在使用底层 API,考虑检查、测试和重构某些代码。</li>
+</ul>
+
+<p>在实践中,大多数底层 API 将正常工作,但可以直接访问网页内容的底层 API 无法正常工作。</p>
+
+<h2 id="兼容性垫片">兼容性垫片</h2>
+
+<p>举例来说,你可能认为这是行不通的:</p>
+
+<pre class="brush: js">var contentDocument = require("sdk/window/utils")
+ .getMostRecentBrowserWindow().content.document;</pre>
+
+<p>但是,Firefox 为附加组件提供了许多 API 的兼容性垫片。这意味着许多 API,包括上述例子的那个,仍然工作。虽然有两条警示需注意:</p>
+
+<ul>
+ <li>这些垫片不完美:某些附加组件在有垫片的情况下仍然不工作。举例来说,许多垫片通过为内容对象返回跨进称对象包装器来工作,并且这<a href="/en-US/Firefox/Multiprocess_Firefox/Cross_Process_Object_Wrappers#Limitations_of_CPOWs">并非始终以同样的方式</a>作为内容对象。</li>
+ <li>这些垫片可能对性能有不良影响,我们希望人们最终去除它们。</li>
+</ul>
+
+<p>We don't yet have a complete list of low-level APIs that are not multiprocess compatible: that is, will not work without the shims. Where we know that a low-level API is not multiprocess compatible, we've indicated that in the documentation page for it.</p>
+
+<h2 id="测试">测试</h2>
+
+<p>To test whether an add-on works without the shims, use the <a href="/en-US/Add-ons/SDK/Tools/package_json#permissions">"multiprocess" permission</a>.</p>
+
+<div class="note">
+<p><strong>Note</strong> that you can only do this if you are using <a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a>. You can't use the <a href="/en-US/Add-ons/SDK/Tools/package_json#permissions">"multiprocess" permission</a> if you are using <a href="/en-US/Add-ons/SDK/Tools/cfx">cfx</a>.</p>
+</div>
+
+<p>Setting this permission will disable the shims for your add-on, so you can test to see if it's really multiprocess compatible or not.</p>
+
+<p>However, there's a catch: some of the SDK's APIs themselves still depend on the shims. So by setting the <a href="/en-US/Add-ons/SDK/Tools/package_json#permissions">"multiprocess" permission</a>, your add-on might not work, even if you are only using high-level APIs. For example:</p>
+
+<pre class="brush: js">var selection = require("sdk/selection");
+
+function myListener() {
+ console.log(selection.text);
+}
+
+selection.on('select', myListener);
+</pre>
+
+<p>This add-on will not work if you've set the <a href="/en-US/Add-ons/SDK/Tools/package_json#permissions">"multiprocess" permission</a>, because <code><a href="/en-US/Add-ons/SDK/High-Level_APIs/selection">sdk/selection</a></code> depends on the shims. We're working on fixing these problems: see <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1004745">bug 1004745</a> and its dependencies.</p>
+
+<h2 id="使用框架脚本">使用框架脚本</h2>
+
+<p>If the shims don't enable your add-on to work properly, or you're trying to remove your dependency on the shims, then the solution is the same as it is for all add-ons:</p>
+
+<ul>
+ <li>factor the code that needs access to content objects into frame scripts</li>
+ <li>use the message manager to load the frame scripts into the content process</li>
+ <li>use the message manager to exchange messages with the frame scripts</li>
+</ul>
+
+<p>In the rest of this section we'll outline some SDK-specific details of using the message manager. However, you'll also need to read the main <a href="/en-US/Firefox/Multiprocess_Firefox/The_message_manager">message manager documentation</a> for the details on working with frame scripts.</p>
+
+<div class="note">
+<p>If you're used to working with content scripts in the SDK, then frame scripts might feel similar, but they're actually very different. Frame scripts are more like a part of the main add-on code that just happens to be running in the content process.</p>
+
+<p>Differences between frame scripts and content scripts include:</p>
+
+<ul>
+ <li>the <a href="/en-US/Firefox/Multiprocess_Firefox/Frame_script_environment">environment for frame scripts</a> and the <a href="/en-US/Add-ons/SDK/Guides/Two_Types_of_Scripts#API_Access_for_Add-on_Code_and_Content_Scripts">environment for content scripts</a> are totally different:
+
+ <ul>
+ <li>content scripts have a very similar environment to scripts loaded by web pages, plus the <code><a href="/en-US/Add-ons/SDK/Guides/Content_Scripts/self">self</a></code> global.</li>
+ <li>frame scripts also have access to web content, but have a different set of APIs for communicating with the chrome process, and access to the <a href="/en-US/docs/Components_object">Components object</a>, which enables them to use privileged <a href="/en-US/docs/Mozilla/Tech/XPCOM">XPCOM</a> APIs and load <a href="/en-US/docs/Mozilla/JavaScript_code_modules">JSMs</a>.</li>
+ </ul>
+ </li>
+ <li>content scripts are reloaded when a new document is loaded. Frame scripts aren't: once a frame script is loaded into a tab it remains loaded until the tab is closed. For more details, see the article on <a href="/en-US/Firefox/Multiprocess_Firefox/Message_Manager/Frame_script_loading_and_lifetime">frame script lifetime</a>.</li>
+</ul>
+</div>
+
+<h3 id="访问消息管理器">访问消息管理器</h3>
+
+<h4 id="全局消息管理器">全局消息管理器</h4>
+
+<p>To access the <a href="/en-US/Firefox/Multiprocess_Firefox/Message_Manager/Message_manager_overview#Global_frame_message_manager">global message manager</a>, you load the <a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager">nsIMessageListenerManager</a> service. Before you can do this in an SDK add-on, you have to <code>require("chrome")</code> to get access to the <code><a href="/en-US/docs/Components_object">Components</a></code> object:</p>
+
+<pre class="brush: js">const {Cc, Ci} = require("chrome");
+
+var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
+ .getService(Ci.nsIMessageListenerManager);</pre>
+
+<h4 id="窗口消息管理器">窗口消息管理器</h4>
+
+<p>The <a href="/en-US/Firefox/Multiprocess_Firefox/Message_Manager/Message_manager_overview#Window_message_manager">window message manager</a> is available as the <code>messageManager</code> property of a chrome window. To understand what a chrome window is, you need to distinguish three sorts of windows:</p>
+
+<ul>
+ <li>a content window is the <a href="/en-US/docs/Web/API/Window">Window</a> object familiar to Web developers as the global object for JavaScript loaded from an HTML document. This is the same window that content scripts in the SDK access.</li>
+ <li>a chrome window, also called a browser window. This is a Firefox application window, hosting the Firefox UI as well as a collection of tabs, each of which can in turn host a DOM window to display web content. This is the global for traditional overlay-based add-ons. In the SDK, the low-level <a href="/en-US/Add-ons/SDK/Low-Level_APIs/window_utils">window/utils</a> module works with these sorts of windows.</li>
+ <li>an SDK window, as made available by the high level <a href="/en-US/Add-ons/SDK/High-Level_APIs/windows">windows</a> module. Each SDK window maps to a chrome window, but omits most of the chrome window's properties, including <code>messageManager</code>. If you have an SDK window you can convert it to a chrome window using <a href="/en-US/Add-ons/SDK/High-Level_APIs/windows#Converting_to_chrome_windows">viewFor</a>.</li>
+</ul>
+
+<p>So to get a window message manager from the SDK, you have a couple of options:</p>
+
+<p>(1) Use the <a href="/en-US/Add-ons/SDK/Low-Level_APIs/window_utils">window/utils</a> module:</p>
+
+<pre class="brush: js">// Note that although this code uses window/utils,
+// it's safe to run in the chrome process because
+// it only accesses chrome objects.
+
+// get the active chrome window
+var browserWindow = require("sdk/window/utils").getMostRecentBrowserWindow();
+
+var windowMM = browserWindow.messageManager;</pre>
+
+<p>(2) Use <code>viewFor</code> to convert an SDK window to a chrome window:</p>
+
+<pre class="brush: js">// get the active SDK window
+var windows = require("sdk/windows").browserWindows;
+var activeWindow = windows.activeWindow;
+
+// convert it to a chrome window
+var browserWindow = require("sdk/view/core").viewFor(activeWindow);
+
+var windowMM = browserWindow.messageManager;</pre>
+
+<h4 id="浏览器消息管理器">浏览器消息管理器</h4>
+
+<p>The <a href="/en-US/Firefox/Multiprocess_Firefox/Message_Manager/Message_manager_overview#Browser_message_manager">browser message manager</a> is available as the <code>messageManager</code> property of an XUL <code><a href="/en-US/docs/XUL/browser">browser</a></code>.</p>
+
+<p>In the SDK, to get a <code>browser</code> for a given tab, you can use the <a href="/en-US/Add-ons/SDK/Low-Level_APIs/tabs_utils">tabs/utils</a> module's <code><a href="/en-US/Add-ons/SDK/Low-Level_APIs/tabs_utils#getBrowserForTab%28tab%29">getBrowserForTab</a></code> function. <code>getBrowserForTab</code> expects an XUL tab as an argument, so if you have an <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs">SDK tab</a> object, you'll need to convert it to an XUL tab using <code><a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs#Converting_to_XUL_tabs">viewFor</a></code>:</p>
+
+<pre class="brush: js">// get the active SDK tab
+var tab = require("sdk/tabs").activeTab;
+// convert it to an XUL tab
+var xulTab = require("sdk/view/core").viewFor(tab);
+// get the XUL browser for this tab
+var xulBrowser = require("sdk/tabs/utils").getBrowserForTab(xulTab);
+
+var browserMM = xulBrowser.messageManager;</pre>
+
+<p>Again, although this code uses tabs/utils, it's safe to run in the chrome process because it only accesses chrome objects.</p>
+
+<h3 id="载入框架脚本">载入框架脚本</h3>
+
+<p>You can load frame scripts using the message manager, passing in a chrome:// or resource:// URL pointing to the script. With the SDK, the simplest approach is to keep frame scripts under your add-on's data directory, and pass in a resource:// URL created using <a href="/en-US/Add-ons/SDK/High-Level_APIs/self#data.url(name)">self.data.url</a>:</p>
+
+<pre class="brush: js">const self = require("sdk/self");
+
+messageManager.loadFrameScript(self.data.url("frame-script.js"), false);</pre>
+
+<p>Note that unlike the APIs to load content scripts, you can only load a single frame script here.</p>
+
+<h3 id="例子">例子</h3>
+
+<p>For example, this add-on trivially accesses content directly using a low-level API:</p>
+
+<pre class="brush: js">function logContent() {
+ var contentDocument = require("sdk/window/utils")
+ .getMostRecentBrowserWindow().content.document;
+ console.log(contentDocument.body.innerHTML);
+}
+
+require("sdk/ui/button/action").ActionButton({
+ id: "log-content",
+ label: "Log Content",
+ icon: "./icon-16.png",
+ onClick: logContent
+});</pre>
+
+<p>This add-on will work by default due to the shims, but will break if you set multiprocessCompatible. So you could rewrite the add-on to use frame scripts:</p>
+
+<pre class="brush: js">/*
+frame-script.js is in the "data" directory, and has this content:
+
+sendAsyncMessage("sdk-low-level-apis-e10s@jetpack:got-content",
+ content.document.body.innerHTML);
+
+*/
+
+const self = require("sdk/self");
+
+function logContentAsync() {
+ var tab = require("sdk/tabs").activeTab;
+ var xulTab = require("sdk/view/core").viewFor(tab);
+ var xulBrowser = require("sdk/tabs/utils").getBrowserForTab(xulTab);
+
+ var browserMM = xulBrowser.messageManager;
+ browserMM.loadFrameScript(self.data.url("frame-script.js"), false);
+ browserMM.addMessageListener("sdk-low-level-apis-e10s@jetpack:got-content",
+ logContent);
+}
+
+function logContent(message) {
+ console.log(message.data);
+}
+
+require("sdk/ui/button/action").ActionButton({
+ id: "log-content",
+ label: "Log Content",
+ icon: "./icon-16.png",
+ onClick: logContentAsync
+});</pre>
+
+<p>现在附加组件能正常工作了,即使你设置了 multiprocessCompatible。</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/guides/working_with_events/index.html b/files/zh-cn/mozilla/add-ons/sdk/guides/working_with_events/index.html
new file mode 100644
index 0000000000..4c24b84e13
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/guides/working_with_events/index.html
@@ -0,0 +1,122 @@
+---
+title: Working with Events
+slug: Mozilla/Add-ons/SDK/Guides/Working_with_Events
+translation_of: Archive/Add-ons/Add-on_SDK/Guides/Working_with_Events
+---
+<p>The Add-on SDK supports event-driven programming.</p>
+<p>Objects emit events on state changes that might be of interest to add-on code, such as browser windows opening, pages loading, network requests completing, and mouse clicks. By registering a listener function to an event emitter an add-on can receive notifications of these events.</p>
+<p><span>We talk about content scripts in more detail in the <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts">Working with Content Scripts</a> guide.</span></p>
+<p>Additionally, if you're using content scripts to interact with web content, you can define your own events and use them to communicate between the main add-on code and the content scripts. In this case one end of the conversation emits the events, and the other end listens to them.</p>
+<p>So there are two main ways you will interact with the EventEmitter framework:</p>
+<ul>
+ <li>
+ <p><strong>listening to built-in events</strong> emitted by objects in the SDK, such as tabs opening, pages loading, mouse clicks</p>
+ </li>
+ <li>
+ <p><strong>sending and receiving user-defined events</strong> between content scripts and add-on code</p>
+ </li>
+</ul>
+<p>This guide only covers the first of these; the second is explained in the <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts">Working with Content Scripts</a> guide.</p>
+<h2 id="Adding_Listeners">Adding Listeners</h2>
+<p>You can add a listener to an event emitter by calling its <code>on(type, listener)</code> method.</p>
+<p>It takes two parameters:</p>
+<ul>
+ <li>
+ <p><strong><code>type</code></strong>: the type of event we are interested in, identified by a string. Many event emitters may emit more than one type of event: for example, a browser window might emit both <code>open</code> and <code>close</code> events. The list of valid event types is specific to an event emitter and is included with its documentation.</p>
+ </li>
+ <li>
+ <p><strong><code>listener</code></strong>: the listener itself. This is a function which will be called whenever the event occurs. The arguments that will be passed to the listener are specific to an event type and are documented with the event emitter.</p>
+ </li>
+</ul>
+<p>For example, the following add-on registers a listener with the <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs"><code>tabs</code></a> module to listen for the <code>ready</code> event, and logs a string to the console reporting the event:</p>
+<pre class="brush: js">var tabs = require("sdk/tabs");
+
+tabs.on("ready", function () {
+ console.log("tab loaded");
+});
+</pre>
+<p>It is not possible to enumerate the set of listeners for a given event.</p>
+<p>The value of <code>this</code> in the listener function is the object that emitted the event.</p>
+<h3 id="Listening_to_all_events">Listening to all events</h3>
+<div class="note">
+ <p>This example uses the <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action">action button</a> API, which is only available from Firefox 29 onwards.</p>
+</div>
+<p>From Firefox 28 onwards, you can pass the wildcard "*" as the <code>type</code> argument. If you do this, the listener will be called for any event emitted by that object, and its argument will be the name of the event:</p>
+<pre class="brush: js">var ui = require('sdk/ui');
+var panels = require("sdk/panel");
+var self = require("sdk/self");
+
+var panel = panels.Panel({
+ contentURL: self.data.url("panel.html")
+});
+
+panel.on("*", function(e) {
+ console.log("event " + e + " was emitted");
+});
+
+var button = ui.ActionButton({
+ id: "my-button",
+ label: "my button",
+ icon: "./icon-16.png",
+ onClick: handleClick
+});
+
+function handleClick(state) {
+ panel.show({
+ position: button
+ });
+}</pre>
+<p>This wildcard feature does not yet work for the <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs"><code>tabs</code></a> or <a href="/en-US/Add-ons/SDK/High-Level_APIs/windows"><code>windows</code></a> modules.</p>
+<h3 id="Adding_Listeners_in_Constructors">Adding Listeners in Constructors</h3>
+<p>Event emitters may be modules, as is the case for the <code>ready</code> event above, or they may be objects returned by constructors.</p>
+<p>In the latter case the <code>options</code> object passed to the constructor typically defines properties whose names are the names of supported event types prefixed with "on": for example, "onOpen", "onReady" and so on. Then in the constructor you can assign a listener function to this property as an alternative to calling the object's <code>on()</code> method.</p>
+<p>For example: the <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action"><code>ActionButton</code></a> object emits an event when the button is clicked.</p>
+<p>The following add-on creates a button and assigns a listener to the <code>onClick</code> property of the <code>options</code> object supplied to the button's constructor. The listener loads https://developer.mozilla.org/:</p>
+<pre class="brush: js">require("sdk/ui/button/action").ActionButton({
+  id: "visit-mozilla",
+  label: "Visit Mozilla",
+  icon: "./icon-16.png",
+  onClick: function() {
+    require("sdk/tabs").open("https://developer.mozilla.org/");
+  }
+});
+</pre>
+<p>This is exactly equivalent to constructing the button and then calling the button's <code>on()</code> method:</p>
+<pre class="brush: js">var button = require("sdk/ui/button/action").ActionButton({
+  id: "visit-mozilla",
+  label: "Visit Mozilla",
+  icon: "./icon-16.png"
+});
+
+button.on("click", function() {
+  require("sdk/tabs").open("https://developer.mozilla.org/");
+});
+</pre>
+<h2 id="Removing_Event_Listeners">Removing Event Listeners</h2>
+<p>Event listeners can be removed by calling <code>removeListener(type, listener)</code>, supplying the type of event and the listener to remove.</p>
+<p>The listener must have been previously been added using one of the methods described above.</p>
+<p>In the following add-on, we add two listeners to the <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs#ready"><code>tabs</code> module's <code>ready</code> event</a>. One of the handler functions removes the listener again.</p>
+<p>Then we open two tabs.</p>
+<pre class="brush: js">var tabs = require("sdk/tabs");
+
+function listener1() {
+ console.log("Listener 1");
+ tabs.removeListener("ready", listener1);
+}
+
+function listener2() {
+ console.log("Listener 2");
+}
+
+tabs.on("ready", listener1);
+tabs.on("ready", listener2);
+
+tabs.open("https://www.mozilla.org");
+tabs.open("https://www.mozilla.org");
+</pre>
+<p>We should see output like this:</p>
+<pre>info: tabevents: Listener 1
+info: tabevents: Listener 2
+info: tabevents: Listener 2
+</pre>
+<p>Listeners will be removed automatically when the add-on is unloaded.</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/base64/index.html b/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/base64/index.html
new file mode 100644
index 0000000000..bbde3e418f
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/base64/index.html
@@ -0,0 +1,65 @@
+---
+title: base64
+slug: Mozilla/Add-ons/SDK/High-Level_APIs/base64
+translation_of: Archive/Add-ons/Add-on_SDK/High-Level_APIs/base64
+---
+<p>{{AddonSidebar}}</p>
+
+<div class="note">
+<p>不稳定</p>
+</div>
+
+<p>使用Base64算法编码和解码数据</p>
+
+<pre class="brush: js">var base64 = require("sdk/base64");
+
+var encodedData = base64.encode("Hello, World");//"SGVsbG8sIFdvcmxk"
+var decodedData = base64.decode(encodedData);//"Hello, World"</pre>
+
+<h2 id="Globals">Globals</h2>
+
+<h3 id="函数">函数</h3>
+
+<h4 class="addon-sdk-api-name" id="encode(data_charset)"><code>encode(data, charset)</code></h4>
+
+<p>将数据编码成ASCII的Base64字符串。</p>
+
+<h5 id="参数">参数</h5>
+
+<p><strong>data : string</strong><br>
+ 需要被编码的字符串</p>
+
+<p><strong>charset : string</strong><br>
+ 字符串的编码字符集(可选)。唯一能接受的值<code>“UTF-8”</code>。为了进行编码和解码Unicode字符串,需要设置字符集参数:</p>
+
+<pre class="brush: js">var base64 = require("sdk/base64");
+
+var encodedData = base64.encode(unicodeString, "utf-8");
+</pre>
+
+<h5 id="返回">返回</h5>
+
+<p><strong>string</strong> : 编码后的Base64字符串。</p>
+
+<h4 class="addon-sdk-api-name" id="decode(data_charset)"><code>decode(data, charset)</code></h4>
+
+<p>解码一个已使用base-64编码的数据字符串</p>
+
+<h5 id="参数_2">参数</h5>
+
+<p><strong>data : string</strong><br>
+ 需要被解码的字符串</p>
+
+<p><strong>charset : string</strong><br>
+ 字符串的编码字符集(可选)。唯一能接受的值<code>“UTF-8”</code>。为了进行编码和解码Unicode字符串,需要设置字符集参数:</p>
+
+<pre class="brush: js">var base64 = require("sdk/base64");
+
+var decodedData = base64.decode(encodedData, "utf-8");
+</pre>
+
+<h5 id="返回_2">返回</h5>
+
+<p><strong>string</strong> : 解码后的字符串</p>
+
+<div id="xunlei_com_thunder_helper_plugin_d462f475-c18e-46be-bd10-327458d045bd"> </div>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/clipboard/index.html b/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/clipboard/index.html
new file mode 100644
index 0000000000..e56a9223cd
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/clipboard/index.html
@@ -0,0 +1,101 @@
+---
+title: clipboard(剪贴板)
+slug: Mozilla/Add-ons/SDK/High-Level_APIs/clipboard
+translation_of: Archive/Add-ons/Add-on_SDK/High-Level_APIs/clipboard
+---
+<p>{{AddonSidebar}}</p>
+
+<div class="note">
+<p>稳定版</p>
+</div>
+
+<p><span class="seoSummary">操作系统剪贴板,设置或获取其内容</span></p>
+
+<h2 id="用法">用法</h2>
+
+<p>你可以选择性地设置将要获取或设置的内容的格式. 支持一下格式:</p>
+
+<ul>
+ <li><code>text</code> (纯文本)</li>
+ <li><code>html</code> (HTML标记语言)</li>
+ <li><code>image</code> (经过base-64编码过的png图片)</li>
+</ul>
+
+<p>如果没有提供格式参数的话,剪贴板模块会自动检测。</p>
+
+<p>现在在Windows操作系统下,"image"格式并不支持透明度。</p>
+
+<h3 id="示例">示例</h3>
+
+<p>设置和获取剪贴板内容。</p>
+
+<pre class="brush: js">var clipboard = require("sdk/clipboard");
+clipboard.set("Lorem ipsum dolor sit amet");
+var contents = clipboard.get();</pre>
+
+<p>将剪贴板内容设置为某些html。</p>
+
+<pre class="brush: js">var clipboard = require("sdk/clipboard");
+clipboard.set("&lt;blink&gt;Lorem ipsum dolor sit amet&lt;/blink&gt;", "html");</pre>
+
+<p>如果剪贴板内容中包含有html,则将其在新标签页中打开。</p>
+
+<pre class="brush: js">var clipboard = require("sdk/clipboard");
+if (clipboard.currentFlavors.indexOf("html") != -1)
+ require("sdk/tabs").open("data:text/html;charset=utf-8," + clipboard.get("html"));</pre>
+
+<p>将剪贴板内容设置为一幅图片。</p>
+
+<pre class="brush: js">var clipboard = require("sdk/clipboard");
+clipboard.set("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYA" +
+ "AABzenr0AAAASUlEQVRYhe3O0QkAIAwD0eyqe3Q993AQ3cBSUKpygfsNTy" +
+ "N5ugbQpK0BAADgP0BRDWXWlwEAAAAAgPsA3rzDaAAAAHgPcGrpgAnzQ2FG" +
+ "bWRR9AAAAABJRU5ErkJggg%3D%3D");</pre>
+
+<p>如果剪贴板内容中包含图片,则将其在新标签页中打开。</p>
+
+<pre class="brush: js">var clipboard = require("sdk/clipboard");
+if (clipboard.currentFlavors.indexOf("image") != -1)
+ require("sdk/tabs").open(clipboard.get());</pre>
+
+<p>如前所述,图片的参数类型很容易被忽略,例如在网页中选中复制一张图片,得到的格式会是html而不是所预期的image。如果你是想将剪贴板的内容设置成像data URL这样的文本字符串而不是图片的话,可以通过将格式设置为text实现。</p>
+
+<pre class="brush: js">var clipboard = require("sdk/clipboard");
+
+clipboard.set("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYA" +
+ "AABzenr0AAAASUlEQVRYhe3O0QkAIAwD0eyqe3Q993AQ3cBSUKpygfsNTy" +
+ "N5ugbQpK0BAADgP0BRDWXWlwEAAAAAgPsA3rzDaAAAAHgPcGrpgAnzQ2FG" +
+ "bWRR9AAAAABJRU5ErkJggg%3D%3D", "text");</pre>
+
+<h2 id="Globals">Globals</h2>
+
+<h3 id="函数">函数</h3>
+
+<h4 class="addon-sdk-api-name" id="set(data_datatype)"><code>set(data, datatype)</code></h4>
+
+<p>将用户剪贴板上的内容用data替换。</p>
+
+<h5 id="参数">参数</h5>
+
+<p><strong>data : string</strong><br>
+ 要放入剪贴板的内容。</p>
+
+<p><strong>datatype : string</strong><br>
+ 内容的格式 ,为"text"或"html" 或 "image"。可选参数.</p>
+
+<h4 class="addon-sdk-api-name" id="get(datatype)"><code>get(datatype)</code></h4>
+
+<p>获取用户当前剪贴板的内容。</p>
+
+<h5 id="参数_2">参数</h5>
+
+<p><strong>datatype : string</strong><br>
+ 只有当剪贴板中的内容格式为datatype指定的格式时才获取 (可选).。当剪贴板中的内容非所提供的datatype指定的格式时,函数回返回null。</p>
+
+<h3 id="属性">属性</h3>
+
+<h4 class="addon-sdk-api-name" id="currentFlavors"><code>currentFlavors</code></h4>
+
+<p>剪贴板上的内容有时会是多种格式。例如,HTML内容即能匹配HTML格式(html),又能匹配纯文本格式(text)。这个属性为一个数组,数组中的元素是剪贴板内容所匹配的所有格式,如["text","html"]。</p>
+
+<div id="xunlei_com_thunder_helper_plugin_d462f475-c18e-46be-bd10-327458d045bd"> </div>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/index.html b/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/index.html
new file mode 100644
index 0000000000..d0d7bd569a
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/index.html
@@ -0,0 +1,12 @@
+---
+title: High-Level APIs
+slug: Mozilla/Add-ons/SDK/High-Level_APIs
+translation_of: Archive/Add-ons/Add-on_SDK/High-Level_APIs
+---
+<p>{{AddonSidebar}}</p>
+
+<p>此页面列出的模块使用的是高级的API:创建用户界面,与网络进行交互并与浏览器交互。</p>
+
+<p>除非文件明确说明,否则这些API是稳定的,我们避免做出不兼容的改变。
+
+{{ LandingPageListSubpages ("/en-US/Add-ons/SDK/High-Level_APIs", 5) }}</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/notifications/index.html b/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/notifications/index.html
new file mode 100644
index 0000000000..415450dca7
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/notifications/index.html
@@ -0,0 +1,129 @@
+---
+title: notifications(通知)
+slug: Mozilla/Add-ons/SDK/High-Level_APIs/notifications
+tags:
+ - Add-on SDK
+ - 通知
+translation_of: Archive/Add-ons/Add-on_SDK/High-Level_APIs/notifications
+---
+<p>{{AddonSidebar}}</p>
+
+<div class="note">
+<p>Stable</p>
+</div>
+
+<p><span class="seoSummary">向用户展示短暂的 <a href="http://en.wikipedia.org/wiki/Toast_%28computing%29">toaster</a> 风格的桌面消息。</span></p>
+
+<h2 id="用法">用法</h2>
+
+<p>本 API 支持Windows、使用<a href="http://growl.info/">Growl</a>(或者像OS X 10.9 Mavericks那样的通知中心)的 OS X 的桌面通知,以及使用 libnotify 的Linux系统</p>
+
+<p>这儿有个典型的例子。当消息被点击,控制台上回记录一个字符串。</p>
+
+<pre class="brush: js">var notifications = require("sdk/notifications");
+notifications.notify({
+ title: "Jabberwocky",
+ text: "'Twas brillig, and the slithy toves",
+ data: "did gyre and gimble in the wabe",
+ onClick: function (data) {
+ console.log(data);
+ // console.log(this.data) would produce the same result.
+ }
+});
+</pre>
+
+<p>下面这个示例用来展示一个保存在 add-on 的 <code>data</code> 目录下的图标。参看 <a href="/en-US/Add-ons/SDK/High-Level_APIs/self"><code>self</code></a> 模块文档以获取更多信息。</p>
+
+<pre class="brush: js">var notifications = require("sdk/notifications");
+var self = require("sdk/self");
+var myIconURL = self.data.url("myIcon.png");
+
+notifications.notify({
+ text: "I have an icon!",
+ iconURL: myIconURL
+});</pre>
+
+<div class="note">
+<p>从 Firefox 34 起,你能使用 <code>"./myIcon.png"</code> 作为 <code>self.data.url("myIcon.png")</code> 的别名。所以你也可以把上面的代码重写成这样:</p>
+
+<pre class="brush: js">var notifications = require("sdk/notifications");
+var myIconURL = "./myIcon.png";
+
+notifications.notify({
+ text: "I have an icon!",
+ iconURL: myIconURL
+});</pre>
+</div>
+
+<p>本模块依赖于底层系统的通知服务。如果用户的系统不支持桌面通知或者通知服务没有运行:</p>
+
+<ul>
+ <li>如果 Firefox 正常运行,通知会记录在 Firefox 的错误控制台</li>
+ <li>如果用户从命令行启动 Firefox,通知会记录到终端。</li>
+</ul>
+
+<h2 id="Globals">Globals</h2>
+
+<h3 id="函数">函数</h3>
+
+<h4 class="addon-sdk-api-name" id="notify(options)"><code>notify(options)</code></h4>
+
+<p>向用户展示一个短暂的通知</p>
+
+<h5 id="参数">参数</h5>
+
+<p><strong>options : object</strong><br>
+ 可选项:</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Name</th>
+ <th scope="col">Type</th>
+ <th scope="col"> </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>title</td>
+ <td>string</td>
+ <td>
+ <p>作为消息标题的字符串。</p>
+ </td>
+ </tr>
+ <tr>
+ <td>text</td>
+ <td>作为消息体的字符串。</td>
+ <td>
+ <p> </p>
+ </td>
+ </tr>
+ <tr>
+ <td>iconURL</td>
+ <td>string</td>
+ <td>
+ <p>消息里的图标的 URL 。可以是个远程的、本地的或者使用 <a href="/en-US/Add-ons/SDK/High-Level_APIs/self"><code>self</code></a> 模块的 URL。</p>
+ </td>
+ </tr>
+ <tr>
+ <td>onClick</td>
+ <td>function</td>
+ <td>
+ <p>用户点击消息是调用的函数。它会传递一个 <code>data</code> 值。</p>
+ </td>
+ </tr>
+ <tr>
+ <td>data</td>
+ <td>string</td>
+ <td>
+ <p>传递给 <code>onClick</code> 的字符串。</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<div id="xunlei_com_thunder_helper_plugin_d462f475-c18e-46be-bd10-327458d045bd"> </div>
+
+<div id="xunlei_com_thunder_helper_plugin_d462f475-c18e-46be-bd10-327458d045bd"> </div>
+
+<div id="xunlei_com_thunder_helper_plugin_d462f475-c18e-46be-bd10-327458d045bd"> </div>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/panel/index.html b/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/panel/index.html
new file mode 100644
index 0000000000..3a86fb0c61
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/panel/index.html
@@ -0,0 +1,899 @@
+---
+title: panel
+slug: Mozilla/Add-ons/SDK/High-Level_APIs/panel
+translation_of: Archive/Add-ons/Add-on_SDK/High-Level_APIs/panel
+---
+<div class="note">
+<p>稳定版本</p>
+</div>
+
+<p><span class="seoSummary">创建临时的 add-on's 用户界面对话框.</span></p>
+
+<h2 id="用法">用法</h2>
+
+<p>该模块导出了一个单独的构造函数函数 <code>Panel()</code> 构建一个Panel对话框 .</p>
+
+<p>面板是一个对话框。其内容是指定的HTML,你可以在它执行脚本,所以面板的外观和行为是有限的只有你可以使用HTML,CSS,JavaScript。</p>
+
+<p>下面的截图显示了一个面板,其内容是从当前打开的选项卡的列表中构建的:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/6595/panel-tabs-osx.png" style="display: block; height: 238px; margin-left: auto; margin-right: auto; width: 307px;"></p>
+
+<p>面板是呈现临时用户界面中容易忽视和解聘的用户比模态对话框的方式,是有用的,因为面板隐藏瞬间用户交互部分的应用程序接口外。</p>
+
+<p><br>
+ 面板的内容加载快作为它是创建,面板显示之前,和内容仍然加载时面板是隐藏的,所以它是可能保持面板周围的背景,更新其内容适当地准备下一次显示。</p>
+
+<p><br>
+ 您的插件可以接收通知,当面板显示或隐藏通过听其显示和隐藏事件。<br>
+ 打开面板将关闭已打开的面板。</p>
+
+<h3 id="Panel_内容">Panel 内容</h3>
+
+<p>该面板的内容指定为HTML,它是在contenturl选项面板的构造函数提供的URL加载。</p>
+
+<p><br>
+ 你可以加载远程HTML到面板:</p>
+
+<pre class="brush: js">var panel = require("sdk/panel").Panel({
+ width: 180,
+ height: 180,
+ contentURL: "https://en.wikipedia.org/w/index.php?title=Jetpack&amp;useformat=mobile"
+});
+
+panel.show();</pre>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/6597/wikipedia-jetpack-panel.png" style="display: block; height: 411px; margin-left: auto; margin-right: auto; width: 494px;"></p>
+
+<p>你也可以加载HTML已经打包你的 add-on,这可能是你将如何创建对话框。要做到这一点,在你的 add-on 的 <em><strong>data </strong></em>目录中保存的HTML 和加载使用 <strong><em><code>data.url()</code></em></strong>方法,由 <em><strong><a href="/en-US/Add-ons/SDK/High-Level_APIs/self"><code>self</code></a></strong></em> 模块导出, 像下面:</p>
+
+<pre class="brush: js">var panel = require("sdk/panel").Panel({
+ contentURL: require("sdk/self").data.url("myFile.html")
+});
+
+panel.show();</pre>
+
+<div class="note">
+<p>从Firefox 34以后, 你可以使用 <code>"./myFile.html" 作为</code><code>self.data.url("myFile.html")</code> 的<code>别名</code>. 所以你可以重写成下面的示例:</p>
+
+<pre class="brush: js">var panel = require("sdk/panel").Panel({
+ contentURL: "./myFile.html"
+});
+
+panel.show();
+</pre>
+</div>
+
+<h3 id="Panel_positioning">Panel positioning</h3>
+
+<p>By default the panel appears in the center of the currently active browser window. You can position the panel by passing a <code>position</code> to the panel's <a href="/en-US/Add-ons/SDK/High-Level_APIs/panel#Panel(options)">constructor</a> or to its <a href="/en-US/Add-ons/SDK/High-Level_APIs/panel#show(options)"><code>show()</code></a> method.</p>
+
+<h3 id="Attaching_panels_to_buttons">Attaching panels to buttons</h3>
+
+<p>You can attach a panel to a <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_toggle">toggle button</a> by passing the button itself as the <code>position</code> option to the panel's <a href="/en-US/Add-ons/SDK/High-Level_APIs/panel#show(options)"><code>show()</code></a> method or to its constructor:</p>
+
+<pre class="brush: js">var { ToggleButton } = require('sdk/ui/button/toggle');
+var panels = require("sdk/panel");
+var self = require("sdk/self");
+
+var button = ToggleButton({
+  id: "my-button",
+  label: "my button",
+  icon: {
+    "16": "./icon-16.png",
+    "32": "./icon-32.png",
+    "64": "./icon-64.png"
+  },
+  onChange: handleChange
+});
+
+var panel = panels.Panel({
+  contentURL: self.data.url("panel.html"),
+  onHide: handleHide
+});
+
+function handleChange(state) {
+  if (state.checked) {
+    panel.show({
+      position: button
+    });
+  }
+}
+
+function handleHide() {
+  button.state('window', {checked: false});
+}</pre>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/7615/panel-button.png" style="display: block; height: 332px; margin-left: auto; margin-right: auto; width: 397px;"></p>
+
+<h3 id="Updating_panel_content">Updating panel content</h3>
+
+<p>You can update the panel's content by:</p>
+
+<ul>
+ <li>sending a message to a content script that updates the DOM in the same document. This is usually the best approach.</li>
+ <li>embedding an <a href="/en-US/docs/Web/HTML/Element/iframe">iframe</a> in the panel, and changing its document</li>
+ <li>setting the panel's <code>contentURL</code> property. However, doing this will cause any content scripts to be unloaded and then reloaded, so it may be less efficient, and you'll lose any state associated with the scripts.</li>
+</ul>
+
+<h3 id="Scripting_panel_content">Scripting panel content</h3>
+
+<p>You can't directly access your panel's content from your main add-on code. To access the panel's content, you need to load a script into the panel. In the SDK these scripts are called "content scripts" because they're explicitly used for interacting with web content.</p>
+
+<p>While content scripts can access the content they're attached to, they can't use the SDK's APIs. So implementing a complete solution usually means you have to send messages between the content script and the main add-on code.</p>
+
+<ul>
+ <li>
+ <p>You can specify one or more content scripts to load into a panel using the <code>contentScript</code> or <code>contentScriptFile</code> options to the <a href="/en-US/Add-ons/SDK/High-Level_APIs/panel#Panel(options)"><code>Panel()</code> constructor</a>.</p>
+ </li>
+ <li>
+ <p>You can communicate with the script using either the <a href="/en-US/Add-ons/SDK/Guides/using_postMessage"><code>postMessage()</code></a> API or (preferably, usually) the <a href="/en-US/Add-ons/SDK/Guides/using_port"><code>port</code></a> API.</p>
+ </li>
+</ul>
+
+<p>For example, here's an add-on whose content script intercepts mouse clicks on links inside the panel, and sends the target URL to the main add-on code. The content script sends messages using <code>self.port.emit()</code> and the add-on script receives them using <code>panel.port.on()</code>.</p>
+
+<pre class="brush: js">var myScript = "window.addEventListener('click', function(event) {" +
+ " var t = event.target;" +
+ " if (t.nodeName == 'A')" +
+ " self.port.emit('click-link', t.toString());" +
+ "}, false);"
+
+var panel = require("sdk/panel").Panel({
+ contentURL: "http://www.bbc.co.uk/mobile/index.html",
+ contentScript: myScript
+});
+
+panel.port.on("click-link", function(url) {
+ console.log(url);
+});
+
+panel.show();</pre>
+
+<p>This example uses <code>contentScript</code> to supply the script as a string. It's usually better practice to use <code>contentScriptFile</code>, which is a URL pointing to a script file saved under your add-on's <code>data</code> directory.</p>
+
+<div class="warning">
+<p><strong>Warning:</strong> Unless your content script is extremely simple and consists only of a static string, don't use <code>contentScript</code>: if you do, you may have problems getting your add-on approved on AMO.</p>
+
+<p>Instead, keep the script in a separate file and load it using <code>contentScriptFile</code>. This makes your code easier to maintain, secure, debug and review.</p>
+</div>
+
+<h3 id="Getting_user_input">Getting user input</h3>
+
+<div class="note">
+<p><strong>Note:</strong> This example uses the <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action">action button</a> API, which is only available from Firefox 29 onwards.</p>
+</div>
+
+<p>The following add-on adds a button which displays a panel when clicked. The panel just contains a {{HTMLElement("textarea")}} element: when the user presses the <code>return</code> key, the contents of the <code>&lt;textarea&gt;</code> is sent to the main add-on code.</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/7647/panel.png" style="display: block; margin-left: auto; margin-right: auto;"></p>
+
+<p>The add-on consists of six files:</p>
+
+<ul>
+ <li><code>main.js</code>: the main add-on code, that creates the button and panel</li>
+ <li><code>get-text.js</code>: the content script that interacts with the panel content</li>
+ <li><code>text-entry.html</code>: the panel content itself, specified as HTML</li>
+ <li><code>icon-16.png</code>, <code>icon-32.png</code>, and <code>icon-64.png</code>: icons for the button in three different sizes</li>
+</ul>
+
+<p>"main.js" is saved in your add-on's <code>lib</code> directory, and the other files go in your add-on's <code>data</code> directory:</p>
+
+<pre>my-addon/
+ data/
+ get-text.js
+ icon-16.png
+ icon-32.png
+ icon-64.png
+ text-entry.html
+ lib/
+ main.js
+</pre>
+
+<p>The "main.js" looks like this:</p>
+
+<pre class="brush: js">var data = require("sdk/self").data;
+// Construct a panel, loading its content from the "text-entry.html"
+// file in the "data" directory, and loading the "get-text.js" script
+// into it.
+var text_entry = require("sdk/panel").Panel({
+  contentURL: data.url("text-entry.html"),
+  contentScriptFile: data.url("get-text.js")
+});
+
+// Create a button
+require("sdk/ui/button/action").ActionButton({
+  id: "show-panel",
+  label: "Show Panel",
+  icon: {
+    "16": "./icon-16.png",
+    "32": "./icon-32.png",
+    "64": "./icon-64.png"
+  },
+  onClick: handleClick
+});
+
+// Show the panel when the user clicks the button.
+function handleClick(state) {
+  text_entry.show();
+}
+
+// When the panel is displayed it generated an event called
+// "show": we will listen for that event and when it happens,
+// send our own "show" event to the panel's script, so the
+// script can prepare the panel for display.
+text_entry.on("show", function() {
+  text_entry.port.emit("show");
+});
+
+// Listen for messages called "text-entered" coming from
+// the content script. The message payload is the text the user
+// entered.
+// In this implementation we'll just log the text to the console.
+text_entry.port.on("text-entered", function (text) {
+  console.log(text);
+  text_entry.hide();
+});</pre>
+
+<p>The content script "get-text.js" looks like this:</p>
+
+<pre class="brush: js">// When the user hits return, send the "text-entered"
+// message to main.js.
+// The message payload is the contents of the edit box.
+var textArea = document.getElementById("edit-box");
+textArea.addEventListener('keyup', function onkeyup(event) {
+ if (event.keyCode == 13) {
+ // Remove the newline.
+ text = textArea.value.replace(/(\r\n|\n|\r)/gm,"");
+ self.port.emit("text-entered", text);
+ textArea.value = '';
+ }
+}, false);
+// Listen for the "show" event being sent from the
+// main add-on code. It means that the panel's about
+// to be shown.
+//
+// Set the focus to the text area so the user can
+// just start typing.
+self.port.on("show", function onShow() {
+ textArea.focus();
+});</pre>
+
+<p>Finally, the "text-entry.html" file defines the <code>&lt;textarea&gt;</code> element:<code> </code></p>
+
+<pre class="brush: html">&lt;html&gt;
+&lt;head&gt;
+    &lt;style type="text/css" media="all"&gt;
+      textarea {
+        margin: 10px;
+      }
+      body {
+        background-color: gray;
+      }
+    &lt;/style&gt;
+  &lt;/head&gt;
+&lt;body&gt;
+    &lt;textarea rows="13" cols="33" id="edit-box"&gt;&lt;/textarea&gt;
+  &lt;/body&gt;
+&lt;/html&gt;</pre>
+
+<p>Finally, save these three icon files to the "data" directory:</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><img alt="" src="https://mdn.mozillademos.org/files/7635/icon-16.png" style="height: 16px; width: 16px;"></td>
+ <td>icon-16.png</td>
+ </tr>
+ <tr>
+ <td><img alt="" src="https://mdn.mozillademos.org/files/7637/icon-32.png" style="height: 32px; width: 32px;"></td>
+ <td>icon-32.png</td>
+ </tr>
+ <tr>
+ <td><img alt="" src="https://mdn.mozillademos.org/files/7639/icon-64.png" style="height: 64px; width: 64px;"></td>
+ <td>icon-64.png</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>To learn much more about content scripts, see the <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts">Working with Content Scripts</a> guide.</p>
+
+<h3 id="Scripting_trusted_panel_content">Scripting trusted panel content</h3>
+
+<div class="note">
+<p><strong>Note:</strong> This example uses the <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action">action button</a> API, which is only available from Firefox 29 onwards.</p>
+</div>
+
+<p>We've already seen that you can package HTML files in your add-on's <code>data</code> directory and use them to define the panel's content. We can call this "trusted" content, because unlike content loaded from a source outside the add-on, the add-on author knows exactly what it's doing. To interact with trusted content you don't need to use content scripts: you can just include a script from the HTML file in the normal way, using <code>script</code> tags.</p>
+
+<p>Like a content script, these scripts can communicate with the add-on code using the <a href="/en-US/Add-ons/SDK/Guides/using_postMessage"><code>postMessage()</code></a> API or the <a href="/en-US/Add-ons/SDK/Guides/using_port"><code>port</code></a> API. The crucial difference is that these scripts access the <code>postMessage</code> and <code>port</code> objects through the <code>addon</code> object, whereas content scripts access them through the <code>self</code> object.</p>
+
+<p>To show the difference, we can easily convert the <code>text-entry</code> add-on above to use normal page scripts instead of content scripts.</p>
+
+<p>The main add-on code is exactly the same as the main add-on code in the previous example, except that we don't attach a content script:</p>
+
+<pre class="brush: js">var data = require("sdk/self").data;
+// Construct a panel, loading its content from the "text-entry.html"
+// file in the "data" directory, and loading the "get-text.js" script
+// into it.
+var text_entry = require("sdk/panel").Panel({
+  contentURL: data.url("text-entry.html")
+});
+
+// Create a button
+require("sdk/ui/button/action").ActionButton({
+  id: "show-panel",
+  label: "Show Panel",
+  icon: {
+    "16": "./icon-16.png",
+    "32": "./icon-32.png",
+    "64": "./icon-64.png"
+  },
+  onClick: handleClick
+});
+
+// Show the panel when the user clicks the button.
+function handleClick(state) {
+  text_entry.show();
+}
+
+// When the panel is displayed it generated an event called
+// "show": we will listen for that event and when it happens,
+// send our own "show" event to the panel's script, so the
+// script can prepare the panel for display.
+text_entry.on("show", function() {
+  text_entry.port.emit("show");
+});
+
+// Listen for messages called "text-entered" coming from
+// the content script. The message payload is the text the user
+// entered.
+// In this implementation we'll just log the text to the console.
+text_entry.port.on("text-entered", function (text) {
+  console.log(text);
+  text_entry.hide();
+});</pre>
+
+<p>The page script is exactly the same as the content script above, except that instead of <code>self</code>, we use <code>addon</code> to access the messaging APIs:</p>
+
+<pre class="brush: js">// When the user hits return, send the "text-entered"
+// message to main.js.
+// The message payload is the contents of the edit box.
+var textArea = document.getElementById("edit-box");
+textArea.addEventListener('keyup', function onkeyup(event) {
+  if (event.keyCode == 13) {
+    // Remove the newline.
+    text = textArea.value.replace(/(\r\n|\n|\r)/gm,"");
+    addon.port.emit("text-entered", text);
+    textArea.value = '';
+  }
+}, false);
+// Listen for the "show" event being sent from the
+// main add-on code. It means that the panel's about
+// to be shown.
+//
+// Set the focus to the text area so the user can
+// just start typing.
+addon.port.on("show", function onShow() {
+  textArea.focus();
+});</pre>
+
+<p>Finally, the HTML file now references "get-text.js" inside a {{HTMLElement("script")}} tag:</p>
+
+<pre class="brush: html">&lt;html&gt;
+&lt;head&gt;
+    &lt;style type="text/css" media="all"&gt;
+      textarea {
+        margin: 10px;
+      }
+      body {
+        background-color: gray;
+      }
+    &lt;/style&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+ &lt;script src="get-text.js"&gt;&lt;/script&gt;
+    &lt;textarea rows="13" cols="33" id="edit-box"&gt;&lt;/textarea&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
+</pre>
+
+<h3 id="Styling_panel_content">Styling panel content</h3>
+
+<p>The panel's default style is different for each operating system:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/8001/panel-styles-os.png" style="display: block; margin-left: auto; margin-right: auto;">This helps to ensure that the panel's style is consistent with the dialogs displayed by Firefox and other applications, but means you need to take care when applying your own styles.</p>
+
+<p>If the panel's content is packaged along with your add-on and specified using an HTML file in your <code>data</code> directory, you can style it by embedding CSS directly in the HTML file or by referencing a CSS file stored under <code>data</code>:</p>
+
+<pre class="brush: html">&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+ &lt;head&gt;
+ &lt;link href="panel-style.css" type="text/css" rel="stylesheet"&gt;
+ &lt;/head&gt;
+ &lt;body&gt;
+ My panel content
+ &lt;/body&gt;
+&lt;/html&gt;</pre>
+
+<p>From Firefox 31 onwards, you can style panel content using the <code>contentStyle</code> or <code>contentStyleFile</code> options. You can use these options even if the panel content is not packaged along with the add-on:</p>
+
+<pre class="brush: js">var panel = require("sdk/panel").Panel({
+ contentURL: "https://en.wikipedia.org/w/index.php?title=Jetpack&amp;useformat=mobile",
+ contentStyle: "body { border: 3px solid blue; }"
+});
+
+panel.show();</pre>
+
+<pre class="brush: js">var self = require("sdk/self");
+
+var panel = require("sdk/panel").Panel({
+ contentURL: "https://en.wikipedia.org/w/index.php?title=Jetpack&amp;useformat=mobile",
+ contentStyleFile: self.data.url("panel-style.css")
+});
+
+panel.show();</pre>
+
+<h3 id="Private_browsing">Private browsing</h3>
+
+<p>If your add-on has not <a href="/en-US/Add-ons/SDK/High-Level_APIs/private-browsing">opted into private browsing</a>, and it calls <code>panel.show()</code> when the currently active window is a <a href="/en-US/Add-ons/SDK/High-Level_APIs/private-browsing#Per-window_private_browsing">private window</a>, then the panel will not be shown.</p>
+
+<h3 id="Panel_limitations">Panel limitations</h3>
+
+<p>Although panels can host HTML documents, they are not implemented as browser tabs, so many things that work in normal web pages do not work inside panels:</p>
+
+<ul>
+ <li>Prior to Firefox 33, you don't get a context menu. From Firefox 33 you can enable a context menu by passing <code>contextMenu: true</code> to the panel's constructor.</li>
+ <li>The HTML {{HTMLElement("select")}} element doesn't work.</li>
+ <li>The HTML {{HTMLElement("datalist")}} element doesn't give you autocomplete suggestions (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=918600">bug 918600</a>).</li>
+ <li>You can't embed Flash (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=952578">bug 952578</a>).</li>
+ <li>You can't provide tooltips using <a href="/en-US/docs/Web/HTML/Global_attributes#attr-title"><code>title</code> attributes</a> (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=918600">bug 918600</a>).</li>
+ <li>Security warning pages (the <a href="https://support.mozilla.org/en-US/kb/connection-untrusted-error-message">"This Connection is Untrusted" warning</a>) does not work, so panels which trigger it will be broken (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1031554">bug 1031554</a>).</li>
+ <li>Mouse button shortcuts, such as using the middle button to open a link in a new page, don't work.</li>
+ <li>Scrolling using keyboard doesn't work properly (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1001914">bug 1001914</a>)</li>
+</ul>
+
+<h2 id="Globals">Globals</h2>
+
+<h3 id="Constructors">Constructors</h3>
+
+<h4 class="addon-sdk-api-name" id="Panel(options)"><code>Panel(options)</code></h4>
+
+<p>Creates a panel.</p>
+
+<h5 id="Parameters">Parameters</h5>
+
+<p><strong>options : object</strong><br>
+ Optional options:</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Name</th>
+ <th scope="col">Type</th>
+ <th scope="col"> </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>width</code></td>
+ <td>number</td>
+ <td>
+ <p>The width of the panel in pixels. Optional.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>height</code></td>
+ <td>number</td>
+ <td>
+ <p>The height of the panel in pixels. Optional.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>position</code></td>
+ <td>
+ <p>object, button, widget</p>
+ </td>
+ <td>
+ <p>The position of the panel. Ignored if the panel is opened by a widget.</p>
+
+ <p>This may be one of three things:</p>
+
+ <ul>
+ <li>a <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_toggle">toggle button</a>. If this is supplied the panel will be shown attached to the button. See the section on <a href="/en-US/Add-ons/SDK/High-Level_APIs/panel#Attaching_panels_to_buttons">attaching panels to buttons</a>.</li>
+ <li>a <a href="/en-US/Add-ons/SDK/High-Level_APIs/widget">widget</a> object. If this is supplied the panel will be shown attached to the widget.</li>
+ <li>an object which specifies where in the window the panel should be shown. The rest of this section describes this object.</li>
+ </ul>
+
+ <p>The position object has one or more of the following properties: <code>top</code>, <code>right</code>, <code>bottom</code> and <code>left</code>. Their values are expressed in pixels. Any other properties will be ignored.</p>
+
+ <p>The default alignment along each axis is centered: so to display a panel centred along the vertical or horizontal axis, just omit that axis:</p>
+
+ <pre class="brush: js">
+// Show the panel centered horizontally and
+// aligned to the bottom of the content area
+require("sdk/panel").Panel({
+ position: {
+ bottom: 0
+ }
+}).show();
+
+// Show the panel centered vertically and
+// aligned to the left of the content area
+require("sdk/panel").Panel({
+ position: {
+ left: 0
+ }
+}).show();
+
+// Centered panel, default behavior
+require("sdk/panel").Panel({}).show();</pre>
+
+ <p>As with the CSS <code>top</code>, <code>bottom</code>, <code>left</code>, and <code>right</code> properties, setting both <code>top</code> and <code>bottom</code> or both <code>left</code> and <code>right</code> will implicitly set the panel's <code>height</code> or <code>width</code> relative to the content window:</p>
+
+ <pre class="brush: js">
+// Show the panel centered horizontally, with:
+// - the top edge 40px from the top
+// of the content window
+// - the bottom edge 100px from the bottom
+// of the content window
+require("sdk/panel").Panel({
+ position: {
+ top: 40,
+ bottom: 100
+ }
+}).show();</pre>
+
+ <p>If you set both <code>top</code> and <code>bottom</code>, but also set the panel's height explicitly using the <code>height</code> property, then the panel will ignore <code>bottom</code>, just as CSS does for its properties with the same name:</p>
+
+ <pre class="brush: js">
+// Show the panel centered horizontally, with:
+// - the top edge 40px from the top
+// of the content window
+// - a height of 400px
+require("sdk/panel").Panel({
+ position: {
+ top: 40,
+ bottom: 100,
+ },
+ height: 400
+}).show();
+
+// This is equivalent to:
+
+require("panel").Panel({
+ position {
+ top: 40
+ },
+ height: 400
+}).show();</pre>
+
+ <p>The same principle is applied in the horizontal axis with <code>width</code>, <code>left</code> and <code>right</code>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>focus</code></td>
+ <td>boolean</td>
+ <td>
+ <p>Set to <code>false</code> to prevent taking the focus away when the panel is shown. Only turn this off if necessary, to prevent accessibility issue. Optional, default to <code>true</code>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>contentURL</code></td>
+ <td>string,URL</td>
+ <td>
+ <p>The URL of the content to load in the panel. That is, they can't refer to remote scripts. The URLs are usually constructed using <a href="/en-US/Add-ons/SDK/High-Level_APIs/self#data.url(name)"><code>self.data.url()</code></a>.</p>
+
+ <div class="note">
+ <p>From Firefox 34, you can use <code>"./my-file.html"</code> as an alias for <code>self.data.url("my-<code>file.html</code>")</code>.</p>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>allow</code></td>
+ <td>object</td>
+ <td>
+ <p>An optional object describing permissions for the content. It should contain a single key named <code>script</code> whose value is a boolean that indicates whether or not to execute script in the content. <code>script</code> defaults to true.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>contentScriptFile</code></td>
+ <td>string,array</td>
+ <td>
+ <p>A URL or an array of URLs. The URLs point to scripts to load into the panel.</p>
+
+ <p>The scripts must be packaged with the add-on under the add-on's <code>data</code> directory. That is, they can't refer to remote scripts. The URLs are usually constructed using <a href="/en-US/Add-ons/SDK/High-Level_APIs/self#data.url(name)"><code>self.data.url()</code></a>.</p>
+
+ <div class="note">
+ <p>From Firefox 34, you can use <code>"./my-script.js"</code> as an alias for <code>self.data.url("my-script.js")</code>.</p>
+ </div>
+
+ <p>Content scripts specified by this property are loaded <em>before</em> those specified by the <code>contentScript</code> property.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>contentScript</code></td>
+ <td>string,array</td>
+ <td>
+ <p>A string or an array of strings containing the texts of content scripts to load. Content scripts specified by this property are loaded <em>after</em> those specified by the <code>contentScriptFile</code> property.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>contentStyleFile</code></td>
+ <td>string, array</td>
+ <td>
+ <p>A URL or an array of URLs. The URLs point to CSS stylesheets to load into the panel.</p>
+
+ <p>The stylesheets must be packaged with the add-on under the add-on's <code>data</code> directory. That is, they can't refer to remote stylesheets. The URLs are usually constructed using <a href="/en-US/Add-ons/SDK/High-Level_APIs/self#data.url(name)"><code>self.data.url()</code></a>.</p>
+
+ <p>Stylesheets specified by this property are loaded <em>before</em> those specified by the <code>contentStyle</code> property.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>contentStyle</code></td>
+ <td>string, array</td>
+ <td>
+ <p>A string or an array of strings containing the texts of stylesheets to load. Stylesheets specified by this property are loaded <em>after</em> those specified by the <code>contentStyleFile</code> property.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>contentScriptWhen</code></td>
+ <td>string</td>
+ <td>
+ <p>When to load the content scripts. This may take one of the following values:</p>
+
+ <ul>
+ <li>"start": load content scripts immediately after the document element for the panel is inserted into the DOM, but before the DOM content itself has been loaded</li>
+ <li>"ready": load content scripts once DOM content has been loaded, corresponding to the <a href="https://developer.mozilla.org/en/Gecko-Specific_DOM_Events">DOMContentLoaded</a> event</li>
+ <li>"end": load content scripts once all the content (DOM, JS, CSS, images) for the panel has been loaded, at the time the <a href="https://developer.mozilla.org/en/DOM/window.onload">window.onload event</a> fires</li>
+ </ul>
+
+ <p>This property is optional and defaults to "end".</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>contentScriptOptions</code></td>
+ <td>object</td>
+ <td>
+ <p>Read-only value exposed to content scripts under <code>addon.options</code> property.</p>
+
+ <p>Any kind of jsonable value (object, array, string, etc.) can be used here. Optional.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>contextMenu</code></td>
+ <td>boolean</td>
+ <td>
+ <div class="geckoVersionNote">
+ <p>New in Firefox 33</p>
+ </div>
+
+ <p>Whether to show a context menu when the user context-clicks in the panel. The context menu will be the same one that's displayed in web pages. Optional, defaults to <code>false</code>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>onMessage</code></td>
+ <td>function</td>
+ <td>
+ <p>Include this to listen to the panel's <code>message</code> event.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>onShow</code></td>
+ <td>function</td>
+ <td>
+ <p>Include this to listen to the panel's <code>show</code> event.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>onHide</code></td>
+ <td>function</td>
+ <td>
+ <p>Include this to listen to the panel's <code>hide</code> event.</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Panel">Panel</h2>
+
+<p>The Panel object represents a floating modal dialog that can by an add-on to present user interface content.</p>
+
+<p>Once a panel object has been created it can be shown and hidden using its <code>show()</code> and <code>hide()</code> methods. Once a panel is no longer needed it can be deactivated using <code>destroy()</code>.</p>
+
+<p>The content of a panel is specified using the <code>contentURL</code> option. An add-on can interact with the content of a panel using content scripts which it supplies in the <code>contentScript</code> and/or <code>contentScriptFile</code> options. For example, a content script could create a menu and send the user's selection to the add-on.</p>
+
+<h3 id="Methods">Methods</h3>
+
+<h4 class="addon-sdk-api-name" id="destroy()"><code>destroy()</code></h4>
+
+<p>Destroys the panel, unloading any content that was loaded in it. Once destroyed, the panel can no longer be used. If you just want to hide the panel and might show it later, use <code>hide</code> instead.</p>
+
+<h4 class="addon-sdk-api-name" id="postMessage(message)"><code>postMessage(message)</code></h4>
+
+<p>Sends a message to the content scripts.</p>
+
+<h5 id="Parameters_2">Parameters</h5>
+
+<p><strong>message : value</strong><br>
+ The message to send. Must be stringifiable to JSON.</p>
+
+<h4 class="addon-sdk-api-name" id="show(options)"><code>show(options)</code></h4>
+
+<p>Displays the panel.</p>
+
+<p>If the <code>options</code> argument is given, it will be shallow merged with the options provided in the constructor: the <code>options</code> passed in the <code>show</code> method takes precedence.</p>
+
+<p>Passing options here is useful for making temporary changes without touching the default values.</p>
+
+<h5 id="Parameters_3">Parameters</h5>
+
+<p><strong>options : object</strong><br>
+ Optional options:</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Name</th>
+ <th scope="col">Type</th>
+ <th scope="col"> </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>width</td>
+ <td>number</td>
+ <td>
+ <p>The width of the panel in pixels. Optional.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>height</td>
+ <td>number</td>
+ <td>
+ <p>The height of the panel in pixels. Optional.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>position</td>
+ <td>object</td>
+ <td>
+ <p>The position of the panel. Optional. See <a href="/en-US/Add-ons/SDK/High-Level_APIs/panel#Panel(options)">Panel's options</a> for further details.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>focus</td>
+ <td>boolean</td>
+ <td>
+ <p>Set to <code>false</code> to prevent taking the focus away when the panel is shown.</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h4 class="addon-sdk-api-name" id="hide()"><code>hide()</code></h4>
+
+<p>Stops displaying the panel.</p>
+
+<h4 class="addon-sdk-api-name" id="resize(width_height)"><code>resize(width, height)</code></h4>
+
+<p>Resizes the panel.</p>
+
+<h5 id="Parameters_4">Parameters</h5>
+
+<p><strong>width : number</strong><br>
+ The new width of the panel in pixels.</p>
+
+<p><strong>height : number</strong><br>
+ The new height of the panel in pixels.</p>
+
+<h4 class="addon-sdk-api-name" id="on(type_listener)"><code>on(type, listener)</code></h4>
+
+<p>Registers an event listener with the panel.</p>
+
+<h5 id="Parameters_5">Parameters</h5>
+
+<p><strong>type : string</strong><br>
+ The type of event to listen for.</p>
+
+<p><strong>listener : function</strong><br>
+ The listener function that handles the event.</p>
+
+<h4 class="addon-sdk-api-name" id="removeListener(type_listener)"><code>removeListener(type, listener)</code></h4>
+
+<p>Unregisters an event listener from the panel.</p>
+
+<h5 id="Parameters_6">Parameters</h5>
+
+<p><strong>type : string</strong><br>
+ The type of event for which <code>listener</code> was registered.</p>
+
+<p><strong>listener : function</strong><br>
+ The listener function that was registered.</p>
+
+<h3 id="Properties">Properties</h3>
+
+<h4 class="addon-sdk-api-name" id="port"><code>port</code></h4>
+
+<p>EventEmitter object that allows you to:</p>
+
+<ul>
+ <li>send events to the content script using the <code>port.emit</code> function</li>
+ <li>receive events from the content script using the <code>port.on</code> function</li>
+</ul>
+
+<p>See the guide to <a href="/en-US/Add-ons/SDK/Guides/using_port"> communicating using <code>port</code></a> for details.</p>
+
+<h4 class="addon-sdk-api-name" id="isShowing"><code>isShowing</code></h4>
+
+<p>Tells if the panel is currently shown or not. This property is read-only.</p>
+
+<h4 class="addon-sdk-api-name" id="height"><code>height</code></h4>
+
+<p>The height of the panel in pixels.</p>
+
+<h4 class="addon-sdk-api-name" id="width"><code>width</code></h4>
+
+<p>The width of the panel in pixels.</p>
+
+<h4 class="addon-sdk-api-name" id="focus"><code>focus</code></h4>
+
+<p>Whether or not focus will be taken away when the panel is shown. This property is read-only.</p>
+
+<h4 class="addon-sdk-api-name" id="contentURL"><code>contentURL</code></h4>
+
+<p>The URL of content loaded into the panel. This can point to local content loaded from your add-on's "data" directory or remote content. Setting it updates the panel's content immediately.</p>
+
+<h4 class="addon-sdk-api-name" id="allow"><code>allow</code></h4>
+
+<p>An object describing permissions for the content. It contains a single key named <code>script</code> whose value is a boolean that indicates whether or not to execute script in the content.</p>
+
+<h4 class="addon-sdk-api-name" id="contentScriptFile"><code>contentScriptFile</code></h4>
+
+<p>A local file URL or an array of local file URLs of content scripts to load. Content scripts specified by this property are loaded <em>before</em> those specified by the <code>contentScript</code> property.</p>
+
+<h4 class="addon-sdk-api-name" id="contentScript"><code>contentScript</code></h4>
+
+<p>A string or an array of strings containing the texts of content scripts to load. Content scripts specified by this property are loaded <em>after</em> those specified by the <code>contentScriptFile</code> property.</p>
+
+<h4 class="addon-sdk-api-name" id="contentScriptWhen"><code>contentScriptWhen</code></h4>
+
+<p>When to load the content scripts. This may have one of the following values:</p>
+
+<ul>
+ <li>"start": load content scripts immediately after the document element for the panel is inserted into the DOM, but before the DOM content itself has been loaded</li>
+ <li>"ready": load content scripts once DOM content has been loaded, corresponding to the <a href="https://developer.mozilla.org/en/Gecko-Specific_DOM_Events">DOMContentLoaded</a> event</li>
+ <li>"end": load content scripts once all the content (DOM, JS, CSS, images) for the panel has been loaded, at the time the <a href="https://developer.mozilla.org/en/DOM/window.onload">window.onload event</a> fires</li>
+</ul>
+
+<h4 class="addon-sdk-api-name" id="contentScriptOptions"><code>contentScriptOptions</code></h4>
+
+<p>Read-only value exposed to content scripts under <code>addon.options</code> property.</p>
+
+<p>Any kind of jsonable value (object, array, string, etc.) can be used here. Optional.</p>
+
+<h3 id="Events">Events</h3>
+
+<h4 class="addon-sdk-api-name" id="show"><code>show</code></h4>
+
+<p>This event is emitted when the panel is shown.</p>
+
+<h4 class="addon-sdk-api-name" id="hide"><code>hide</code></h4>
+
+<p>This event is emitted when the panel is hidden.</p>
+
+<h4 class="addon-sdk-api-name" id="message"><code>message</code></h4>
+
+<p>If you listen to this event you can receive message events from content scripts associated with this panel. When a content script posts a message using <code>self.postMessage()</code>, the message is delivered to the add-on code in the panel's <code>message</code> event.</p>
+
+<h5 id="Arguments">Arguments</h5>
+
+<p><strong>value</strong> : Listeners are passed a single argument which is the message posted from the content script. The message can be any <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts/using_port#JSON-Serializable_Values">JSON-serializable value</a>.</p>
+
+<h4 class="addon-sdk-api-name" id="error"><code>error</code></h4>
+
+<p>This event is emitted when an uncaught runtime error occurs in one of the panel's content scripts.</p>
+
+<h5 id="Arguments_2">Arguments</h5>
+
+<p><strong>Error</strong> : Listeners are passed a single argument, the <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error">Error</a> object.</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/tabs/index.html b/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/tabs/index.html
new file mode 100644
index 0000000000..b85bb94ab3
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/tabs/index.html
@@ -0,0 +1,669 @@
+---
+title: tabs
+slug: Mozilla/Add-ons/SDK/High-Level_APIs/tabs
+translation_of: Archive/Add-ons/Add-on_SDK/High-Level_APIs/tabs
+---
+<p>{{AddonSidebar}}</p>
+
+<div class="note">
+<p>Stable</p>
+</div>
+
+<p><span class="seoSummary">打开、操作和访问标签页,以及接收标签页事件</span></p>
+
+<h2 id="用法">用法</h2>
+
+<h3 id="打开标签页">打开标签页</h3>
+
+<p>你可以注册事件监听器,以便在标签打开、关闭、完成DOM内容加载、被激活或被闲置时接收通知:</p>
+
+<pre class="brush: js">var tabs = require("sdk/tabs");
+tabs.open("http://www.example.com");</pre>
+
+<h3 id="跟踪标签页">跟踪标签页</h3>
+
+<p>You can register event listeners to be notified when tabs open, close, finish loading DOM content, or are made active or inactive:</p>
+
+<pre class="brush: js">var tabs = require("sdk/tabs");
+
+// Listen for tab openings.
+tabs.on('open', function onOpen(tab) {
+ myOpenTabs.push(tab);
+});
+
+// Listen for tab content loads.
+tabs.on('ready', function(tab) {
+ console.log('tab is loaded', tab.title, tab.url);
+});</pre>
+
+<h3 id="访问标签页">访问标签页</h3>
+
+<p>The module itself can be used as a list of all opened tabs across all windows. In particular, you can enumerate it:</p>
+
+<pre class="brush: js">var tabs = require('sdk/tabs');
+for (let tab of tabs)
+ console.log(tab.title);</pre>
+
+<p>You can also access individual tabs by index:</p>
+
+<pre class="brush: js">var tabs = require('sdk/tabs');
+
+tabs.on('ready', function () {
+ console.log('first: ' + tabs[0].title);
+ console.log('last: ' + tabs[tabs.length-1].title);
+});</pre>
+
+<p>You can access the currently active tab:</p>
+
+<pre class="brush: js">var tabs = require('sdk/tabs');
+
+tabs.on('activate', function () {
+ console.log('active: ' + tabs.activeTab.url);
+});</pre>
+
+<h3 id="跟踪单个标签页">跟踪单个标签页</h3>
+
+<p>Given a tab, you can register event listeners to be notified when the tab is closed, activated or deactivated, or when the page hosted by the tab is loaded or retrieved from the <a href="https://developer.mozilla.org/en-US/docs/Working_with_BFCache">"back-forward cache"</a>:</p>
+
+<pre class="brush: js">var tabs = require("sdk/tabs");
+
+function onOpen(tab) {
+ console.log(tab.url + " is open");
+ tab.on("pageshow", logShow);
+ tab.on("activate", logActivate);
+ tab.on("deactivate", logDeactivate);
+ tab.on("close", logClose);
+}
+
+function logShow(tab) {
+ console.log(tab.url + " is loaded");
+}
+
+function logActivate(tab) {
+ console.log(tab.url + " is activated");
+}
+
+function logDeactivate(tab) {
+ console.log(tab.url + " is deactivated");
+}
+
+function logClose(tab) {
+ console.log(tab.url + " is closed");
+}
+
+tabs.on('open', onOpen);</pre>
+
+<h3 id="操作标签页">操作标签页</h3>
+
+<p>You can get and set various properties of tabs (but note that properties relating to the tab's content, such as the URL, will not contain valid values until after the tab's <code>ready</code> event fires). By setting the <code>url</code> property you can load a new page in the tab:</p>
+
+<pre class="brush: js">var tabs = require("sdk/tabs");
+tabs.on('activate', function(tab) {
+ tab.url = "http://www.example.com";
+});</pre>
+
+<h3 id="在标签页中运行脚本">在标签页中运行脚本</h3>
+
+<p>You can attach a <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts">content script</a> to the page hosted in a tab, and use that to access and manipulate the page's content (see the <a href="/en-US/Add-ons/SDK/Tutorials/Modifying_the_Page_Hosted_by_a_Tab">Modifying the Page Hosted by a Tab</a> tutorial):</p>
+
+<pre class="brush: js">var tabs = require("sdk/tabs");
+
+tabs.on('activate', function(tab) {
+ var worker = tab.attach({
+ contentScript: 'self.port.emit("html", document.body.innerHTML);'
+ });
+ worker.port.on("html", function(message) {
+ console.log(message)
+ })
+});</pre>
+
+<p>Note that <code>tab.attach</code> is tab-centric: if the user navigates to a new page in the same tab, then the worker and content scripts will be reattached to the new page.</p>
+
+<h3 id="附加样式表">附加样式表</h3>
+
+<div class="geckoVersionNote">
+<p>Firefox 34 新增。</p>
+</div>
+
+<p>You can't attach style sheets to a tab using <code>tab.attach()</code>, but from Firefox 34 onwards you can attach and detach them using the low-level <a href="/en-US/Add-ons/SDK/Low-Level_APIs/stylesheet_style">stylesheet/style</a> and <a href="/en-US/Add-ons/SDK/Low-Level_APIs/content_mod">content/mod</a> APIs. Here's an add-on that uses a toggle button to attach a stylesheet to the active tab, and detach it again. The stylesheet is called "style.css" and is located in the add-on's "data" directory:</p>
+
+<pre class="brush: js">var tabs = require("sdk/tabs");
+var { attach, detach } = require('sdk/content/mod');
+var { Style } = require('sdk/stylesheet/style');
+var { ToggleButton } = require("sdk/ui/button/toggle");
+
+var style = Style({
+ uri: './style.css'
+});
+
+var button = ToggleButton({
+ id: "stylist",
+ label: "stylist",
+ icon: "./icon-16.png",
+ onChange: function(state) {
+ if (state.checked) {
+ attach(style, tabs.activeTab);
+ }
+ else {
+ detach(style, tabs.activeTab);
+ }
+ }
+});</pre>
+
+<h3 id="隐私窗口">隐私窗口</h3>
+
+<p>If your add-on has not opted into private browsing, then you won't see any tabs that are hosted by private browser windows.</p>
+
+<p>Tabs hosted by private browser windows won't be seen if you enumerate the <code>tabs</code> module itself, and you won't receive any events for them.</p>
+
+<p>To learn more about private windows, how to opt into private browsing, and how to support private browsing, refer to the <a href="/en-US/Add-ons/SDK/High-Level_APIs/private-browsing">documentation for the <code>private-browsing</code> module</a>.</p>
+
+<h3 id="转为XUL标签页">转为XUL标签页</h3>
+
+<p>To convert from the high-level <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs#Tab"><code>Tab</code></a> objects used in this API to the low-level <a href="/en-US/docs/Mozilla/Tech/XUL/tab">XUL <code>tab</code></a> objects used in the <a href="/en-US/Add-ons/SDK/Low-Level_APIs/tabs_utils"><code>tabs/utils</code></a> API and by traditional add-ons, use the <code>viewFor()</code> function exported by the <code>viewFor</code> module.</p>
+
+<p>To convert back the other way, from a XUL <code>tab</code> to a high-level <code>Tab</code> object, use the <code>modelFor()</code> function, exported by the <code>modelFor</code> module.</p>
+
+<p>Here's an example converting from a high-level <code>Tab</code> to a XUL <code>tab</code> and then back the other way:</p>
+
+<pre class="brush: js">var { modelFor } = require("sdk/model/core");
+var { viewFor } = require("sdk/view/core");
+
+var tabs = require("sdk/tabs");
+var tab_utils = require("sdk/tabs/utils");
+
+function mapHighLevelToLowLevel(tab) {
+  // get the XUL tab that corresponds to this high-level tab
+  var lowLevelTab = viewFor(tab);
+  // now we can, for example, access the tab's content directly
+  var browser = tab_utils.getBrowserForTab(lowLevelTab);
+  console.log(browser.contentDocument.body.innerHTML);
+  // get the high-level tab back from the XUL tab
+  var highLevelTab = modelFor(lowLevelTab);
+  console.log(highLevelTab.url);
+}
+
+tabs.on("ready", mapHighLevelToLowLevel);
+</pre>
+
+<p>Note that directly accessing XUL objects and web content like this means you're no longer protected by the compatibility guarantees made by the SDK's high-level APIs. In particular, your code might not work with <a href="http://billmccloskey.wordpress.com/2013/12/05/multiprocess-firefox/">multiprocess Firefox</a>.</p>
+
+<h2 id="全局变量">全局变量</h2>
+
+<h3 id="函数">函数</h3>
+
+<h4 class="addon-sdk-api-name" id="open(options)"><code>open(options)</code></h4>
+
+<p>Opens a new tab. The new tab will open in the active window or in a new window, depending on the <code>inNewWindow</code> option.</p>
+
+<p><strong>示例</strong></p>
+
+<pre class="brush: js">var tabs = require("sdk/tabs");
+
+// Open a new tab on active window and make tab active.
+tabs.open("http://www.mysite.com");
+
+// Open a new tab in a new window and make it active.
+tabs.open({
+ url: "http://www.mysite.com",
+ inNewWindow: true
+});
+
+// Open a new tab on active window in the background.
+tabs.open({
+ url: "http://www.mysite.com",
+ inBackground: true
+});
+
+// Open a new tab as an app tab and do something once it's open.
+tabs.open({
+ url: "http://www.mysite.com",
+ isPinned: true,
+ onOpen: function onOpen(tab) {
+ // do stuff like listen for content
+ // loading.
+ }
+});</pre>
+
+<h5 id="参数">参数</h5>
+
+<p><strong>options : object</strong><br>
+ 必选项:</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Name</th>
+ <th scope="col">Type</th>
+ <th scope="col"> </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>url</td>
+ <td>string</td>
+ <td>
+ <p>String URL to be opened in the new tab. This is a required property.</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>可选项:</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Name</th>
+ <th scope="col">Type</th>
+ <th scope="col"> </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>isPrivate</td>
+ <td>boolean</td>
+ <td>
+ <p>Boolean which will determine whether the new tab should be private or not. If your add-on does not support private browsing this will have no effect. See the <a href="/en-US/Add-ons/SDK/High-Level_APIs/private-browsing">private-browsing</a> documentation for more information. Defaults to <code>false</code>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>inNewWindow</td>
+ <td>boolean</td>
+ <td>
+ <p>If present and true, a new browser window will be opened and the URL will be opened in the first tab in that window. This is an optional property.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>inBackground</td>
+ <td>boolean</td>
+ <td>
+ <p>If present and true, the new tab will be opened to the right of the active tab and will not be active. This is an optional property.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>isPinned</td>
+ <td>boolean</td>
+ <td>
+ <p>If present and true, then the new tab will be pinned as an <a href="http://support.mozilla.com/en-US/kb/what-are-app-tabs">app tab</a>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>onOpen</td>
+ <td>function</td>
+ <td>
+ <p>A callback function that will be registered for the 'open' event. This is an optional property.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>onClose</td>
+ <td>function</td>
+ <td>
+ <p>A callback function that will be registered for the 'close' event. This is an optional property.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>onReady</td>
+ <td>function</td>
+ <td>
+ <p>A callback function that will be registered for the 'ready' event. This is an optional property.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>onLoad</td>
+ <td>function</td>
+ <td>
+ <p>A callback function that will be registered for the 'load' event. This is an optional property.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>onPageShow</td>
+ <td>function</td>
+ <td>
+ <p>A callback function that will be registered for the 'pageshow' event. This is an optional property.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>onActivate</td>
+ <td>function</td>
+ <td>
+ <p>A callback function that will be registered for the 'activate' event. This is an optional property.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>onDeactivate</td>
+ <td>function</td>
+ <td>
+ <p>A callback function that will be registered for the 'deactivate' event. This is an optional property.</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="属性">属性</h3>
+
+<h4 class="addon-sdk-api-name" id="activeTab"><code>activeTab</code></h4>
+
+<p>The currently active tab in the active window. This property is read-only. To activate a <code>Tab</code> object, call its <code>activate</code> method.</p>
+
+<p><strong>示例</strong></p>
+
+<pre class="brush: js">// Get the active tab's title.
+var tabs = require("sdk/tabs");
+console.log("title of active tab is " + tabs.activeTab.title);</pre>
+
+<h4 class="addon-sdk-api-name" id="length"><code>length</code></h4>
+
+<p>The number of open tabs across all windows.</p>
+
+<h3 id="事件">事件</h3>
+
+<h4 class="addon-sdk-api-name" id="open"><code>open</code></h4>
+
+<p>This event is emitted when a new tab is opened. This does not mean that the content has loaded, only that the browser tab itself is fully visible to the user.</p>
+
+<p>Properties relating to the tab's content (for example: <code>title</code>, <code>favicon</code>, and <code>url</code>) will not be correct at this point. If you need to access these properties, listen for the <code>ready</code> event:</p>
+
+<pre class="brush: js">var tabs = require("sdk/tabs");
+tabs.on('open', function(tab){
+ tab.on('ready', function(tab){
+ console.log(tab.url);
+ });
+});</pre>
+
+<h5 id="参数_2">参数</h5>
+
+<p><strong>Tab</strong> : Listeners are passed the tab object that just opened.</p>
+
+<h4 class="addon-sdk-api-name" id="close"><code>close</code></h4>
+
+<p>This event is emitted when a tab is closed. When a window is closed this event will be emitted for each of the open tabs in that window.</p>
+
+<h5 id="参数_3">参数</h5>
+
+<p><strong>Tab</strong> : Listeners are passed the tab object that has closed.</p>
+
+<h4 class="addon-sdk-api-name" id="ready"><code>ready</code></h4>
+
+<p>This event is emitted when the DOM for a tab's content is ready. It is equivalent to the <code>DOMContentLoaded</code> event for the given content page.</p>
+
+<p>A single tab will emit this event every time the DOM is loaded: so it will be emitted again if the tab's location changes or the content is reloaded.</p>
+
+<p>After this event has been emitted, all properties relating to the tab's content can be used.</p>
+
+<h5 id="参数_4">参数</h5>
+
+<p><strong>Tab</strong> : Listeners are passed the tab object that has loaded.</p>
+
+<h4 class="addon-sdk-api-name" id="activate"><code>activate</code></h4>
+
+<p>This event is emitted when an inactive tab is made active.</p>
+
+<h5 id="参数_5">参数</h5>
+
+<p><strong>Tab</strong> : Listeners are passed the tab object that has become active.</p>
+
+<h4 class="addon-sdk-api-name" id="deactivate"><code>deactivate</code></h4>
+
+<p>This event is emitted when the active tab is made inactive.</p>
+
+<h5 id="参数_6">参数</h5>
+
+<p><strong>Tab</strong> : Listeners are passed the tab object that has become inactive.</p>
+
+<h2 id="Tab">Tab</h2>
+
+<p>A <code>Tab</code> instance represents a single open tab. It contains various tab properties, several methods for manipulation, as well as per-tab event registration.</p>
+
+<p>Tabs emit all the events described in the Events section. Listeners are passed the <code>Tab</code> object that triggered the event.</p>
+
+<h3 id="方法">方法</h3>
+
+<h4 class="addon-sdk-api-name" id="pin()"><code>pin()</code></h4>
+
+<p>Pins this tab as an <a href="http://support.mozilla.com/en-US/kb/what-are-app-tabs">app tab</a>.</p>
+
+<h4 class="addon-sdk-api-name" id="unpin()"><code>unpin()</code></h4>
+
+<p>Unpins this tab.</p>
+
+<h4 class="addon-sdk-api-name" id="close(callback)"><code>close(callback)</code></h4>
+
+<p>Closes this tab.</p>
+
+<h5 id="参数_7">参数</h5>
+
+<p><strong>callback : function</strong><br>
+ A function to be called when the tab finishes its closing process. This is an optional argument.</p>
+
+<h4 class="addon-sdk-api-name" id="reload()"><code>reload()</code></h4>
+
+<p>Reloads this tab.</p>
+
+<h4 class="addon-sdk-api-name" id="activate()"><code>activate()</code></h4>
+
+<p>Makes this tab active, which will bring this tab to the foreground.</p>
+
+<h4 class="addon-sdk-api-name" id="getThumbnail()"><code>getThumbnail()</code></h4>
+
+<p>Returns thumbnail data URI of the page currently loaded in this tab.</p>
+
+<h4 class="addon-sdk-api-name" id="attach(options)"><code>attach(options)</code></h4>
+
+<p>Attach one or more scripts to the document loaded in the tab. Note that by attaching inside <em>ready</em> event, this becomes tab-centric: if the user navigates to a new page in the same tab, then the content scripts will be reattached to the new page.</p>
+
+<p><strong>示例</strong></p>
+
+<pre class="brush: js">var tabs = require("sdk/tabs");
+
+tabs.on('ready', function(tab) {
+ var worker = tab.attach({
+ contentScript:
+ 'document.body.style.border = "5px solid red";'
+ });
+});</pre>
+
+<h5 id="参数_8">参数</h5>
+
+<p><strong>options : object</strong><br>
+ 可选项:</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Name</th>
+ <th scope="col">Type</th>
+ <th scope="col"> </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>contentScriptFile</td>
+ <td>string,array</td>
+ <td>
+ <p>The local file URLs of content scripts to load. Content scripts specified by this option are loaded <em>before</em> those specified by the <code>contentScript</code> option. Optional.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>contentScript</td>
+ <td>string,array</td>
+ <td>
+ <p>A string or an array of strings of code to be evaluated in the context. Content scripts specified by this option are loaded <em>after</em> those specified by the <code>contentScriptFile</code> option. Optional.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>contentScriptOptions</td>
+ <td>object</td>
+ <td>
+ <p>You can use this option to define read-only values for your content scripts.</p>
+
+ <p>The option consists of an object literal listing <code>name:value</code> pairs for the values you want to provide to the content script. For example:</p>
+
+ <pre class="brush: js">
+// main.js
+
+const tabs = require("sdk/tabs");
+
+tabs.open({
+ url: "./page.html",
+ onReady: function(tab) {
+ tab.attach({
+ contentScriptFile: "./content-script.js",
+ contentScriptOptions: {
+ a: "blah"
+ }
+ });
+ }
+});</pre>
+
+ <p>The values are accessible to content scripts via the <code>self.options</code> property:</p>
+
+ <pre class="brush: js">
+// content-script.js
+
+alert(self.options.a);</pre>
+ </td>
+ </tr>
+ <tr>
+ <td>onMessage</td>
+ <td>function</td>
+ <td>
+ <p>A function called when the content worker receives a message from content scripts. Listeners are passed a single argument, the message posted from the content script. Optional.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>onError</td>
+ <td>function</td>
+ <td>A function called when the content worker receives an error from content scripts. Listeners are passed a single argument, <code>error</code>, which is the error posted from the content script and an object of type <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>. Optional</td>
+ </tr>
+ </tbody>
+</table>
+
+<h5 id="返回">返回</h5>
+
+<p><strong>Worker</strong> : <a href="/en-US/Add-ons/SDK/Low-Level_APIs/content_worker">Worker</a> 对象能够用来和内容脚本通信。查看 <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts">Content Scripts guide</a> 了解详细信息。</p>
+
+<h3 id="属性_2">属性</h3>
+
+<h4 class="addon-sdk-api-name" id="id"><code>id</code></h4>
+
+<p>The unique id for the tab. This property is read-only.</p>
+
+<h4 class="addon-sdk-api-name" id="title"><code>title</code></h4>
+
+<p>The title of the tab (usually the title of the page currently loaded in the tab) This property can be set to change the tab title.</p>
+
+<h4 class="addon-sdk-api-name" id="url"><code>url</code></h4>
+
+<p>The URL of the page currently loaded in the tab. This property can be set to load a different URL in the tab.</p>
+
+<h4 class="addon-sdk-api-name" id="favicon"><code>favicon</code></h4>
+
+<p>The URL of the favicon for the page currently loaded in the tab. This property is read-only.</p>
+
+<div class="warning">This property is deprecated. From version 1.15, use the <a href="/en-US/Add-ons/SDK/Low-Level_APIs/places_favicon">favicon module's <code>getFavicon()</code></a> function instead.</div>
+
+<h4 class="addon-sdk-api-name" id="contentType"><code>contentType</code></h4>
+
+<div class="note">
+<p><strong>This is currently an experimental API, so we might change it in future releases.</strong></p>
+
+<p>Returns the MIME type that the document currently loaded in the tab is being rendered as. This may come from HTTP headers or other sources of MIME information, and might be affected by automatic type conversions performed by either the browser or extensions. This property is read-only.</p>
+</div>
+
+<h4 class="addon-sdk-api-name" id="index"><code>index</code></h4>
+
+<p>The index of the tab relative to other tabs in the application window. This property can be set to change its relative position.</p>
+
+<h4 class="addon-sdk-api-name" id="isPinned"><code>isPinned</code></h4>
+
+<p>Whether or not this tab is pinned as an <a href="http://support.mozilla.com/en-US/kb/what-are-app-tabs">app tab</a>. This property is read-only.</p>
+
+<h4 class="addon-sdk-api-name" id="window"><code>window</code></h4>
+
+<p><code>标签页的</code><a href="/en-US/Add-ons/SDK/High-Level_APIs/windows#BrowserWindow"><code>window</code></a>对象.</p>
+
+<h4 class="addon-sdk-api-name" id="readyState"><code>readyState</code></h4>
+
+<div class="geckoVersionNote">
+<p>Firefox 33 新增。</p>
+</div>
+
+<p>A string telling you the load state of the document hosted by this tab. This corresponds directly to <a href="/en-US/docs/Web/API/document.readyState"><code>Document.readyState</code></a>. It has one of four possible values:</p>
+
+<ul>
+ <li>"uninitialized": the tab's document is not yet loading</li>
+ <li>"loading": the tab's document is still in the process of loading</li>
+ <li>"interactive": the tab's document has loaded and is parsed, but resources such as images and stylesheets may still be loading</li>
+ <li>"complete": the tab's document and all resources are fully loaded</li>
+</ul>
+
+<p>Once a tab's <code>readyState</code> has entered "interactive", you can retrieve properties such as the document's URL.</p>
+
+<h3 id="事件_2">事件</h3>
+
+<h4 class="addon-sdk-api-name" id="close_2"><code>close</code></h4>
+
+<p>This event is emitted when the tab is closed. It's also emitted when the tab's window is closed.</p>
+
+<h5 id="参数_9">参数</h5>
+
+<p><strong>Tab</strong> : Listeners are passed the tab object.</p>
+
+<h4 class="addon-sdk-api-name" id="ready_2"><code>ready</code></h4>
+
+<p>This event is emitted when the DOM for the tab's content is ready. It is equivalent to the <a href="https://developer.mozilla.org/en-US/docs/Web/Reference/Events/DOMContentLoaded"><code>DOMContentLoaded</code></a> event for the given content page. At this point the document itself is fully loaded and parsed, but resources such as stylesheets and images may still be loading.</p>
+
+<p>A single tab will emit this event every time the DOM is loaded: so it will be emitted again if the tab's location changes or the content is reloaded. After this event has been emitted, all properties relating to the tab's content can be used.</p>
+
+<h5 id="参数_10">参数</h5>
+
+<p><strong>Tab</strong> : Listeners are passed the tab object.</p>
+
+<h4 class="addon-sdk-api-name" id="load"><code>load</code></h4>
+
+<p>This event is emitted when the page for the tab's content is loaded. It is equivalent to the <a href="https://developer.mozilla.org/en-US/docs/Web/Reference/Events/load"><code>load</code></a> event for the given content page. At this point the document and its resources, such as images and stylesheets, have finished loading.</p>
+
+<p>This event can be used for pages that do not have a <code>DOMContentLoaded</code> event, like images. For pages that have a <code>DOMContentLoaded</code> event, <code>load</code> is fired after <code>ready</code>.</p>
+
+<p>A single tab will emit this event every time the page is loaded: so it will be emitted again if the tab's location changes or the content is reloaded. After this event has been emitted, all properties relating to the tab's content can be used.</p>
+
+<h5 id="参数_11">参数</h5>
+
+<p><strong>Tab</strong> : Listeners are passed the tab object.</p>
+
+<h4 class="addon-sdk-api-name" id="pageshow"><code>pageshow</code></h4>
+
+<p>The <code>pageshow</code> event is emitted when the page for a tab's content is loaded. It is equivalent to the <a href="https://developer.mozilla.org/en-US/docs/DOM/Mozilla_event_reference/pageshow"><code>pageshow</code></a> event for the given content page.</p>
+
+<p>This event is similar to the <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs#load"><code>load</code></a> and <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs#ready"><code>ready</code></a> events, except unlike <code>load</code> and <code>ready</code>, <code>pageshow</code> is triggered if the page was retrieved from the <a href="https://developer.mozilla.org/en-US/docs/Working_with_BFCache">bfcache</a>. This means that if the user loads a page, loads a new page, then moves back to the previous page using the "Back" button, the <code>pageshow</code> event is emitted when the user moves back to the previous page, while the <code>load</code> and <code>ready</code> events are not.</p>
+
+<p>This event is <em>not</em> emitted when the tab is made the active tab: to get notified about that, you need to listen to the <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs#activate"><code>activate</code></a> event.</p>
+
+<p>After this event has been emitted, all properties relating to the tab's content can be used. It is emitted after <code>load</code> and <code>ready</code>.</p>
+
+<h5 id="参数_12">参数</h5>
+
+<p><strong>Tab</strong> : Listeners are passed the tab object.</p>
+
+<p><strong>persisted</strong> : Listeners are passed a boolean value indicating whether or not the page was loaded from the <a href="https://developer.mozilla.org/en-US/docs/Working_with_BFCache">bfcache</a>.</p>
+
+<h4 class="addon-sdk-api-name" id="activate_2"><code>activate</code></h4>
+
+<p>This event is emitted when the tab is made active.</p>
+
+<p>Note that you cannot guarantee that a tab's content, or even its <code>url</code>, are initialized at the time <code>activate</code> is emitted. This is because when a new tab is opened, its <code>activate</code> event may be emitted before the content is loaded.</p>
+
+<p>You can use the tab's <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs#readyState"><code>readyState</code></a> property to determine whether the tab's content and <code>url</code> will be available: if <code>readyState</code> is <code>uninitialized</code> or <code>loading</code>, then you can't access the tab's properties and must wait for the tab's <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs#ready_2"><code>ready</code></a> event.</p>
+
+<h5 id="参数_13">参数</h5>
+
+<p><strong>Tab</strong> : Listeners are passed the tab object.</p>
+
+<h4 class="addon-sdk-api-name" id="deactivate_2"><code>deactivate</code></h4>
+
+<p>This event is emitted when the tab is made inactive.</p>
+
+<h5 id="参数_14">参数</h5>
+
+<p><strong>Tab</strong> : Listeners are passed the tab object.</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/url/index.html b/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/url/index.html
new file mode 100644
index 0000000000..f98da9baf9
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/url/index.html
@@ -0,0 +1,191 @@
+---
+title: url
+slug: Mozilla/Add-ons/SDK/High-Level_APIs/url
+translation_of: Archive/Add-ons/Add-on_SDK/High-Level_APIs/url
+---
+<div class="note">
+<p>实验性的</p>
+</div>
+
+<p><span class="seoSummary">构建,验证,解析URL</span></p>
+
+<h2 id="Globals">Globals</h2>
+
+<h3 id="构造函数">构造函数</h3>
+
+<h4 class="addon-sdk-api-name" id="URL(source_base)"><code>URL(source, base)</code></h4>
+
+<p>URL构造函数可以创建一个URL对象,并验证提供的字符串是否是有效的URL。SDK中,任何接受URL参数的API,除非特殊说明,均接受的是此对象而不是字符串。</p>
+
+<h5 id="参数">参数</h5>
+
+<p><strong>source : string</strong><br>
+ 一个表示URL的字符串,如果接受的参数不是有效的URL字符串,此构造函数会抛出一个异常。</p>
+
+<p><strong>base : string</strong><br>
+ 一个设置的字符串,用来表示一个相对路径的源。</p>
+
+<h4 class="addon-sdk-api-name" id="DataURL(uri)"><code>DataURL(uri)</code></h4>
+
+<p>DataURL构造函数创建一个data: URL对象, 并验证提供的字符串是否是一个有效的data: URL。</p>
+
+<h5 id="参数_2">参数</h5>
+
+<p><strong>uri : string</strong><br>
+ 一个表示Data URL的字符串。如果它不是一个合法的URL字符串,此构造函数会抛出一个错误。</p>
+
+<h3 id="函数">函数</h3>
+
+<h4 class="addon-sdk-api-name" id="toFilename(url)"><code>toFilename(url)</code></h4>
+
+<p>尝试将给定的URL转换成本地文件路径。这个方法会自动尝试解决非文件协议, such as the <code>resource:</code> protocol, to their place on the file system. 除非URL无法转换,否则,本方法会将本地路径作为字符串返回。</p>
+
+<h5 id="参数_3">参数</h5>
+
+<p><strong>url : string</strong><br>
+ 字符串格式的URL。</p>
+
+<h5 id="返回">返回</h5>
+
+<p><strong>string</strong> : 转换后的本地路径字符串</p>
+
+<h4 class="addon-sdk-api-name" id="fromFilename(path)"><code>fromFilename(path)</code></h4>
+
+<p>讲一个给定的路径转换成 <code>file:</code> URL.</p>
+
+<h5 id="参数_4">参数</h5>
+
+<p><strong>path : string</strong><br>
+ 需要被转换的本地文件路径字符串。</p>
+
+<h5 id="Returns">Returns</h5>
+
+<p><strong>string</strong> : 转换后的字符串。</p>
+
+<h4 class="addon-sdk-api-name" id="isValidURI(uri)"><code>isValidURI(uri)</code></h4>
+
+<p>检查一个URL字符串是合法。 <code>isValidURI("http://mozilla.org")</code> 将返回 <code>true</code>, 而 <code>isValidURI("mozilla.org")</code> 将返回 <code>false</code>。</p>
+
+<h5 id="参数_5">参数</h5>
+
+<p><strong>uri : string</strong><br>
+ 需要被测试的URL。</p>
+
+<h5 id="Returns_2">Returns</h5>
+
+<p><strong>boolean</strong> : 代表字符串是否有效的布尔值。</p>
+
+<h4 class="addon-sdk-api-name" id="getTLD(url)"><code>getTLD(url)</code></h4>
+
+<p>返回给定域名的顶级域名: 内部使用的是 <a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIEffectiveTLDService#getPublicSuffix()"><code>getPublicSuffix()</code></a> 。</p>
+
+<pre class="brush: js">var urls = require("sdk/url");
+console.log(urls.getTLD("http://www.bbc.co.uk/")); // "co.uk"
+console.log(urls.getTLD("https://developer.mozilla.org/")); // "org"</pre>
+
+<h5 id="参数_6">参数</h5>
+
+<p><strong>url : string</strong><br>
+ 给定的URL字符串</p>
+
+<h5 id="返回_2">返回</h5>
+
+<p><strong>string</strong> : 对应的顶级域名。</p>
+
+<h2 id="URL">URL</h2>
+
+<h3 id="方法">方法</h3>
+
+<h4 class="addon-sdk-api-name" id="toString()"><code>toString()</code></h4>
+
+<p>返回URL的字符表示形式。</p>
+
+<h5 id="返回_3">返回</h5>
+
+<p><strong>string</strong> : 字符串格式的URL。</p>
+
+<h3 id="属性">属性</h3>
+
+<h4 class="addon-sdk-api-name" id="scheme"><code>scheme</code></h4>
+
+<p>URL使用的协议</p>
+
+<h4 class="addon-sdk-api-name" id="userPass"><code>userPass</code></h4>
+
+<p>URL中的username:password 部分,<code>null</code> 表示不存在。</p>
+
+<h4 class="addon-sdk-api-name" id="host"><code>host</code></h4>
+
+<p>URL的主机部分。 <code>null</code> 表示无此部分。例子:</p>
+
+<pre class="brush: js">var url = require("sdk/url").URL("https://developer.mozilla.org/en-US/Add-ons");
+console.log(url.host); // developer.mozilla.org</pre>
+
+<h4 class="addon-sdk-api-name" id="port"><code>port</code></h4>
+
+<p>URL使用的端口。 <code>null</code> 表示不存在。</p>
+
+<h4 class="addon-sdk-api-name" id="path"><code>path</code></h4>
+
+<p>URL的路径部分,例子:</p>
+
+<pre class="brush: js">var url = require("sdk/url").URL("https://developer.mozilla.org/en-US/Add-ons");
+console.log(url.path); // /en-US/Add-ons</pre>
+
+<h4 class="addon-sdk-api-name" id="hostname"><code>hostname</code></h4>
+
+<p>表示URL的域的字符串。参见 <a href="/en-US/docs/Web/API/URLUtils.hostname"><code>window.location.hostname</code></a>。</p>
+
+<h4 class="addon-sdk-api-name" id="pathname"><code>pathname</code></h4>
+
+<p>从 <code>'/'</code>开始的路径字符串。参见 <a href="/en-US/docs/Web/API/URLUtils.pathname"><code>window.location.pathname</code></a>。</p>
+
+<h4 class="addon-sdk-api-name" id="hash"><code>hash</code></h4>
+
+<p>从 <code>'#'</code> 开始的hash字符串,参见 <a href="/en-US/docs/Web/API/URLUtils.hash"><code>window.location.hash</code></a>。</p>
+
+<h4 class="addon-sdk-api-name" id="href"><code>href</code></h4>
+
+<p>整个URL字符串,参见 <a href="/en-US/docs/Web/API/URLUtils.href"><code>window.location.href</code></a>。</p>
+
+<h4 class="addon-sdk-api-name" id="origin"><code>origin</code></h4>
+
+<p>该URL的源的字符串,参见 <a href="/en-US/docs/Web/API/URLUtils.origin"><code>window.location.origin</code></a>。</p>
+
+<h4 class="addon-sdk-api-name" id="protocol"><code>protocol</code></h4>
+
+<p>该URL使用的协议字符串,包括最后的<code>':',参见</code> <a href="/en-US/docs/Web/API/URLUtils.protocol"><code>window.location.protocol</code></a>。</p>
+
+<h4 class="addon-sdk-api-name" id="search"><code>search</code></h4>
+
+<p>以'?'开始的URL的参数段,包括最开始的<code>'?'</code>。 <code>参见</code><a href="/en-US/docs/Web/API/URLUtils.search"><code>window.location.search</code></a>.</p>
+
+<h2 id="DataURL">DataURL</h2>
+
+<h3 id="方法_2">方法</h3>
+
+<h4 class="addon-sdk-api-name" id="toString()_2"><code>toString()</code></h4>
+
+<p>返回数据的URL字符串形式。如果是 <code>base64</code> 的URL,数据会以base64编码方式编码。</p>
+
+<h5 id="返回_4">返回</h5>
+
+<p><strong>string</strong> : URL字符串</p>
+
+<h3 id="属性_2">属性</h3>
+
+<h4 class="addon-sdk-api-name" id="mimeType"><code>mimeType</code></h4>
+
+<p>数据的MIME类型,默认为空字符串。</p>
+
+<h4 class="addon-sdk-api-name" id="parameters"><code>parameters</code></h4>
+
+<p>一个HashMap的数据包含URL参数。默认情况下是一个空对象。</p>
+
+<h4 class="addon-sdk-api-name" id="base64"><code>base64</code></h4>
+
+<p><span>定义了</span><span>数据</span><span>属性</span><span>值</span><span>的编码。</span></p>
+
+<h4 class="addon-sdk-api-name" id="data"><code>data</code></h4>
+
+<p>包含数据的URL字符串。如果<code>URI</code>给构造函数包含<code>Base64</code>参数,这个字符串会被解码。</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/widget/index.html b/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/widget/index.html
new file mode 100644
index 0000000000..3d374a0752
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/high-level_apis/widget/index.html
@@ -0,0 +1,839 @@
+---
+title: widget
+slug: Mozilla/Add-ons/SDK/High-Level_APIs/widget
+tags:
+ - ZH
+translation_of: Archive/Add-ons/Add-on_SDK/High-Level_APIs/widget
+---
+<p>{{LegacyAddonsNotice}}{{AddonSidebar}}</p>
+
+<div class="warning">
+<p>Deprecated in Firefox 29 and removed in Firefox 38.</p>
+
+<p>The widget API is deprecated from Firefox 29 onwards. Please see the <a href="/en-US/Add-ons/SDK/High-Level_APIs/ui">ui module</a> for replacements. In particular, for a simple button, try the <a href="/en-US/Add-ons/SDK/High-Level_APIs/ui#ActionButton">action button</a> or <a href="/en-US/Add-ons/SDK/High-Level_APIs/ui#ToggleButton">toggle button</a> APIs, and for a more complex widget try the <a href="/en-US/Add-ons/SDK/High-Level_APIs/ui#Toolbar">toolbar</a> or <a href="/en-US/Add-ons/SDK/High-Level_APIs/ui#Sidebar">sidebar</a> APIs.</p>
+</div>
+
+<p><span class="seoSummary">Create a simple user interface for an add-on in Firefox's add-on bar.</span></p>
+
+<h2 id="Usage">Usage</h2>
+
+<p>"Widgets" are small pieces of content that live in the Firefox 4 <a href="https://developer.mozilla.org/en/The_add-on_bar">add-on bar</a>. They can be simple icons or complex web pages. You can attach <a href="/en-US/Add-ons/SDK/High-Level_APIs/panel">panels</a> to them that open when they're clicked, or you can define a custom click handler to perform some other action, like opening a web page in a tab.</p>
+
+<p>There are a few advantages to using widgets over an ad hoc user interface. First, your users will be accustomed to interacting with add-ons via widgets and the add-on bar. Second, it allows Firefox to treat your interface as a first-class citizen. For example, in the future Firefox may allow the user to drag widgets from the add-on bar to other toolbars. By exposing your interface as a widget, your add-on would automatically inherit such functionality.</p>
+
+<h3 id="Creation_and_content">Creation and content</h3>
+
+<p>Widgets can contain images or arbitrary web content. You can include this content inline as a string by using the <code>content</code> property, or point to content using a URL with the <code>contentURL</code> property.</p>
+
+<p>Upon creation, the widget is automatically added to the add-on bar. You can set the width of a widget, but the height is fixed so as to fit in the add-on bar. If the content is an image, it is automatically scaled to be 16x16 pixels.</p>
+
+<p>For example, this widget contains an image, so it looks like a simple icon:</p>
+
+<pre class="brush: js">require("sdk/widget").Widget({
+ id: "mozilla-icon",
+ label: "My Mozilla Widget",
+ contentURL: "http://www.mozilla.org/favicon.ico"
+});</pre>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/6695/widget-mozilla.png" style="display: block; height: 184px; margin-left: auto; margin-right: auto; width: 464px;">You can make <code>contentURL</code> point to an HTML or icon file which you have packaged inside your add-on. Just save the file in your add-on's <code>data</code> directory, and reference it using the <code>data.url()</code> method of the <a href="/en-US/Add-ons/SDK/High-Level_APIs/self"><code>self</code></a> module:</p>
+
+<pre class="brush: js">var data = require("sdk/self").data;
+
+require("sdk/widget").Widget({
+ id: "my-widget",
+ label: "My Widget",
+ contentURL: data.url("my-content.html")
+});</pre>
+
+<p>This widget contains an entire web page:</p>
+
+<pre class="brush: js">require("sdk/widget").Widget({
+ id: "hello-display",
+ label: "My Hello Widget",
+ content: "Hello!",
+ width: 50
+});</pre>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/6605/widget-hello-text.png" style="display: block; height: 132px; margin-left: auto; margin-right: auto; width: 282px;">Widgets are quite small by default, so this example used the <code>width</code> property to grow it in order to show all the text.</p>
+
+<h3 id="Scripting_widget_content">Scripting widget content</h3>
+
+<p>To interact with the widget's content you need to load a separate script into the panel. In the SDK these scripts are called "content scripts" because they're explicitly used for interacting with web content.</p>
+
+<p>While content scripts can access the content they're attached to, they can't use the SDK's APIs. So implementing a complete solution usually means you have to send messages between the content script and the main add-on code.</p>
+
+<ul>
+ <li>
+ <p>You can specify one or more content scripts to load into the widget using the <code>contentScript</code> or <code>contentScriptFile</code> options to the <a href="/en-US/Add-ons/SDK/High-Level_APIs/widget#Widget(options)"><code>Widget()</code> constructor</a>.</p>
+ </li>
+ <li>
+ <p>You can communicate with the script using either the <a href="/en-US/Add-ons/SDK/Guides/using_postMessage"><code>postMessage()</code></a> API or (preferably, usually) the <a href="/en-US/Add-ons/SDK/Guides/using_port"><code>port</code></a> API.</p>
+ </li>
+</ul>
+
+<div class="warning">
+<p>Unless your content script is extremely simple and consists only of a static string, don't use <code>contentScript</code>: if you do, you may have problems getting your add-on approved on AMO.</p>
+
+<p>Instead, keep the script in a separate file and load it using <code>contentScriptFile</code>. This makes your code easier to maintain, secure, debug and review.</p>
+</div>
+
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/6607/widget-player-buttons.png" style="float: right; height: 132px; width: 282px;">For example, suppose we want to implement a media player as an add-on. We could implement the main user interface as a widget hosting an array of buttons to control play/pause/stop functions.</p>
+
+<p>We can then use a content script to listen for clicks on those buttons. But because content scripts can't use the SDK's APIs, we'll want the content script to send messages to the main add-on code, which can then implement the media player functions using the SDK.</p>
+
+<p>The widget's content is specified using HTML like this:</p>
+
+<pre class="brush: html"><code class="brush: js">&lt;html&gt;
+ &lt;body&gt;
+ &lt;img src="play.png" id="play-button"&gt;
+ &lt;img src="pause.png" id="pause-button"&gt;
+ &lt;img src="stop.png" id="stop-button"&gt;
+ &lt;/body&gt;
+&lt;/html&gt;</code></pre>
+
+<p>We just include three icons, and assign an ID to each one. This HTML file, and the icon files it references, are saved in the add-on's <code>data</code> directory.</p>
+
+<p>Next, we write a content script that listens for click events on each icon and sends the corresponding message to the main add-on code:</p>
+
+<pre class="brush: js">var play_button = document.getElementById("play-button");
+play_button.onclick = function() {
+ self.port.emit("play");
+}
+
+var pause_button = document.getElementById("pause-button");
+pause_button.onclick = function() {
+ self.port.emit("pause");
+}
+
+var stop_button = document.getElementById("stop-button");
+stop_button.onclick = function() {
+ self.port.emit("stop");
+}</pre>
+
+<p>We save this file in the add-on's <code>data</code> directory as "button-script.js". Finally. in the add-on's "main.js" file, we create the widget, assign it the HTML file and the content script, and listen for events from the content script:</p>
+
+<pre class="brush: js">const widgets = require("sdk/widget");
+const data = require("sdk/self").data;
+
+var player = widgets.Widget({
+ id: "player",
+ width: 72,
+ label: "Player",
+ contentURL: data.url("buttons.html"),
+ contentScriptFile: data.url("button-script.js")
+});
+
+player.port.on("play", function() {
+ console.log("playing");
+});
+
+player.port.on("pause", function() {
+ console.log("pausing");
+});
+
+player.port.on("stop", function() {
+ console.log("stopping");
+});</pre>
+
+<p>To learn much more about content scripts, see the <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts">Working with Content Scripts</a> guide.</p>
+
+<h3 id="Scripting_trusted_widget_content">Scripting trusted widget content</h3>
+
+<p>We've already seen that you can package HTML files in your add-on's <code>data</code> directory and use them to define the widget's content. We can call this "trusted" content, because unlike content loaded from a source outside the add-on, the add-on author knows exactly what it's doing. To interact with trusted content you don't need to use content scripts: you can just include a script from the HTML file in the normal way, using <code>script</code> tags.</p>
+
+<p>Like a content script, these scripts can communicate with the add-on code using the <a href="/en-US/Add-ons/SDK/Guides/using_postMessage"><code>postMessage()</code></a> API or the <a href="/en-US/Add-ons/SDK/Guides/using_port"><code>port</code></a> API. The crucial difference is that these scripts access the <code>postMessage</code> and <code>port</code> objects through the <code>addon</code> object, whereas content scripts access them through the <code>self</code> object.</p>
+
+<p>To show the difference, convert the <code>player</code> add-on above to use normal page scripts instead of content scripts.</p>
+
+<p>First, in the content script, change <code>self</code> to <code>addon</code>, and wrap it in a function:</p>
+
+<pre class="brush: js">function init() {
+ var play_button = document.getElementById("play-button");
+ play_button.onclick = function() {
+ addon.port.emit("play");
+ }
+
+ var pause_button = document.getElementById("pause-button");
+ pause_button.onclick = function() {
+ addon.port.emit("pause");
+ }
+
+ var stop_button = document.getElementById("stop-button");
+ stop_button.onclick = function() {
+ addon.port.emit("stop");
+ }
+}</pre>
+
+<p>Next, add a <code>script</code> tag to reference "button-script.js", and call its <code>init()</code> function on load:</p>
+
+<pre class="brush: html">&lt;html&gt;
+ &lt;head&gt;
+ &lt;script src="button-script.js"&gt;&lt;/script&gt;
+ &lt;/head&gt;
+ &lt;body onLoad="init()"&gt;
+ &lt;img src="play.png" id="play-button"&gt;
+ &lt;img src="pause.png" id="pause-button"&gt;
+ &lt;img src="stop.png" id="stop-button"&gt;
+ &lt;/body&gt;
+&lt;/html&gt;
+</pre>
+
+<p>Finally, remove the line attaching the content script from "main.js":</p>
+
+<pre class="brush: js">const widgets = require("sdk/widget");
+const data = require("sdk/self").data;
+
+var player = widgets.Widget({
+ id: "player",
+ width: 72,
+ label: "Player",
+ contentURL: data.url("buttons.html")
+});
+
+player.port.emit("init");
+
+player.port.on("play", function() {
+ console.log("playing");
+});
+
+player.port.on("pause", function() {
+ console.log("pausing");
+});
+
+player.port.on("stop", function() {
+ console.log("stopping");
+});</pre>
+
+<h3 id="Attaching_panels_to_widgets">Attaching panels to widgets</h3>
+
+<p>You can supply a <a href="/en-US/Add-ons/SDK/High-Level_APIs/panel">panel</a> to the widget's constructor: if you do this, the panel is automatically displayed when the user clicks the widget.</p>
+
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/6609/widget-panel-clock.png" style="float: right; height: 222px; width: 214px;"></p>
+
+<pre class="brush: js">data = require("sdk/self").data
+
+var clockPanel = require("sdk/panel").Panel({
+ width:215,
+ height:160,
+ contentURL: data.url("clock.html")
+});
+
+require("sdk/widget").Widget({
+ id: "open-clock-btn",
+ label: "Clock",
+ contentURL: data.url("History.png"),
+ panel: clockPanel
+});</pre>
+
+<p>Note that this is, at the moment, the only way you can attach a panel to a widget.</p>
+
+<p>You must supply the panel in the widget's constructor for it to work. If you assign the panel to the widget after construction, the panel can still be shown but will not be anchored to the widget:</p>
+
+<pre class="brush: js">data = require("sdk/self").data
+
+var clockPanel = require("sdk/panel").Panel({
+ width:215,
+ height:160,
+ contentURL: data.url("clock.html")
+});
+
+widget = require("sdk/widget").Widget({
+ id: "open-clock-btn",
+ label: "Clock",
+ contentURL: data.url("History.png")
+});
+
+widget.panel = clockPanel;
+
+// Will not be anchored
+widget.panel.show();</pre>
+
+<p>Also, if you try to call <code>panel.show()</code> inside your widget's <code>click</code> event listener, the panel will not be anchored:</p>
+
+<pre class="brush: js">data = require("sdk/self").data
+
+var clockPanel = require("sdk/panel").Panel({
+ width:215,
+ height:160,
+ contentURL: data.url("clock.html")
+});
+
+require("sdk/widget").Widget({
+ id: "open-clock-btn",
+ label: "Clock",
+ contentURL: data.url("History.png"),
+ panel: clockPanel,
+ onClick: function() {
+ // Will not be anchored
+ this.panel.show();
+ }
+});</pre>
+
+<p>See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=638142">bug 638142</a>.</p>
+
+<h3 id="Private_windows">Private windows</h3>
+
+<p>If your add-on has not opted into private browsing, then your widget will not appear in any private browser windows.</p>
+
+<p>To learn more about private windows, how to opt into private browsing, and how to support private browsing, refer to the <a href="/en-US/Add-ons/SDK/High-Level_APIs/private-browsing">documentation for the <code>private-browsing</code> module</a>.</p>
+
+<h3 id="Examples">Examples</h3>
+
+<p>For conciseness, these examples create their content scripts as strings and use the <code>contentScript</code> property. In your own add-ons, you will probably want to create your content scripts in separate files and pass their URLs using the <code>contentScriptFile</code> property. See <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts">Working with Content Scripts</a> for more information.</p>
+
+<pre class="brush: js">var widgets = require("sdk/widget");
+
+// A basic click-able image widget.
+widgets.Widget({
+ id: "google-link",
+ label: "Widget with an image and a click handler",
+ contentURL: "http://www.google.com/favicon.ico",
+ onClick: function() {
+ require("sdk/tabs").activeTab.url = "http://www.google.com/";
+ }
+});</pre>
+
+<pre class="brush: js">// A widget that changes display on mouseover.
+widgets.Widget({
+ id: "mouseover-effect",
+ label: "Widget with changing image on mouseover",
+ contentURL: "http://www.yahoo.com/favicon.ico",
+ onMouseover: function() {
+ this.contentURL = "http://www.bing.com/favicon.ico";
+ },
+ onMouseout: function() {
+ this.contentURL = "http://www.yahoo.com/favicon.ico";
+ }
+});</pre>
+
+<pre class="brush: js">// A widget that updates content on a timer.
+widgets.Widget({
+ id: "auto-update-widget",
+ label: "Widget that updates content on a timer",
+ content: "0",
+ contentScript: 'setTimeout(function() {' +
+ ' document.body.innerHTML++;' +
+ '}, 2000)',
+ contentScriptWhen: "ready"
+});</pre>
+
+<pre class="brush: js">// A widget created with a specified width, that grows.
+var myWidget = widgets.Widget({
+ id: "widget-effect",
+ label: "Wide widget that grows wider on a timer",
+ content: "I'm getting longer.",
+ width: 50,
+});
+require("sdk/timers").setInterval(function() {
+ myWidget.width += 10;
+}, 1000);</pre>
+
+<pre class="brush: js">// A widget communicating bi-directionally with a content script.
+var widget = widgets.Widget({
+ id: "message-test",
+ label: "Bi-directional communication!",
+ content: "&lt;foo&gt;bar&lt;/foo&gt;",
+ contentScriptWhen: "ready",
+ contentScript: 'self.on("message", function(message) {' +
+ ' alert("Got message: " + message);' +
+ '});' +
+ 'self.postMessage("ready");',
+ onMessage: function(message) {
+ if (message == "ready")
+ widget.postMessage("me too");
+ }
+});</pre>
+
+<h2 id="Globals">Globals</h2>
+
+<h3 id="Constructors">Constructors</h3>
+
+<h4 class="addon-sdk-api-name" id="Widget(options)"><code>Widget(options)</code></h4>
+
+<p>Creates a new widget. The widget is immediately added to the add-on bar.</p>
+
+<h5 id="Parameters">Parameters</h5>
+
+<p><strong>options : object</strong><br>
+ Required options:</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Name</th>
+ <th scope="col">Type</th>
+ <th scope="col"> </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>label</td>
+ <td>string</td>
+ <td>
+ <p>A string description of the widget used for accessibility, title bars, and error reporting.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>id</td>
+ <td>string</td>
+ <td>
+ <p>A string used to identify your widget in order to save its location when the user moves it in the browser. This string has to be unique and must not be changed over time.</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>Optional options:</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Name</th>
+ <th scope="col">Type</th>
+ <th scope="col"> </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>content</td>
+ <td>string</td>
+ <td>
+ <p>An optional string value containing the displayed content of the widget. It may contain HTML. Widgets must have either the <code>content</code> property or the <code>contentURL</code> property set.</p>
+
+ <p>If the content is an image, it is automatically scaled to be 16x16 pixels.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>contentURL</td>
+ <td>string</td>
+ <td>
+ <p>An optional string URL to content to load into the widget. This can be local content or remote content, an image or web content. Widgets must have either the <code>content</code> property or the <code>contentURL</code> property set.</p>
+
+ <p>If the content is an image, it is automatically scaled to be 16x16 pixels.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>panel</td>
+ <td>Panel</td>
+ <td>
+ <p>An optional <a href="/en-US/Add-ons/SDK/High-Level_APIs/panel">panel</a> to open when the user clicks on the widget. Note: If you also register a "click" listener, it will be called instead of the panel being opened. However, you can show the panel from the listener by calling <code>this.panel.show()</code>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>width</td>
+ <td>integer</td>
+ <td>
+ <p>Optional width in pixels of the widget. If not given, a default width is used.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>onClick</td>
+ <td>function</td>
+ <td>
+ <p>Include this to listen to the widget's <code>click</code> event.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>onMessage</td>
+ <td>function</td>
+ <td>
+ <p>Include this to listen to the widget's <code>message</code> event.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>onMouseover</td>
+ <td>function</td>
+ <td>
+ <p>Include this to listen to the widget's <code>mouseover</code> event.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>onMouseout</td>
+ <td>function</td>
+ <td>
+ <p>Include this to listen to the widget's <code>mouseout</code> event.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>onAttach</td>
+ <td>function</td>
+ <td>
+ <p>Include this to listen to the widget's <code>attach</code> event.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>tooltip</td>
+ <td>string</td>
+ <td>
+ <p>Optional text to show when the user's mouse hovers over the widget. If not given, the <code>label</code> is used.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>allow</td>
+ <td>object</td>
+ <td>
+ <p>An optional object describing permissions for the content. It should contain a single key named <code>script</code> whose value is a boolean that indicates whether or not to execute script in the content. <code>script</code> defaults to true.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>contentScriptFile</td>
+ <td>string,array</td>
+ <td>
+ <p>A local file URL or an array of local file URLs of content scripts to load. Content scripts specified by this property are loaded <em>before</em> those specified by the <code>contentScript</code> property.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>contentScript</td>
+ <td>string,array</td>
+ <td>
+ <p>A string or an array of strings containing the texts of content scripts to load. Content scripts specified by this property are loaded <em>after</em> those specified by the <code>contentScriptFile</code> property.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>contentScriptWhen</td>
+ <td>string</td>
+ <td>
+ <p>When to load the content scripts. This may take one of the following values:</p>
+
+ <ul>
+ <li>"start": load content scripts immediately after the document element for the widget is inserted into the DOM, but before the DOM content itself has been loaded</li>
+ <li>"ready": load content scripts once DOM content has been loaded, corresponding to the <a href="https://developer.mozilla.org/en/Gecko-Specific_DOM_Events">DOMContentLoaded</a> event</li>
+ <li>"end": load content scripts once all the content (DOM, JS, CSS, images) for the widget has been loaded, at the time the <a href="https://developer.mozilla.org/en/DOM/window.onload">window.onload event</a> fires</li>
+ </ul>
+
+ <p>This property is optional and defaults to "end".</p>
+ </td>
+ </tr>
+ <tr>
+ <td>contentScriptOptions</td>
+ <td>object</td>
+ <td>
+ <p>Read-only value exposed to content scripts under <code>self.options</code> property.</p>
+
+ <p>Any kind of jsonable value (object, array, string, etc.) can be used here. Optional.</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Widget">Widget</h2>
+
+<p>Represents a widget object.</p>
+
+<h3 id="Methods">Methods</h3>
+
+<h4 class="addon-sdk-api-name" id="destroy()"><code>destroy()</code></h4>
+
+<p>Removes the widget from the add-on bar.</p>
+
+<h4 class="addon-sdk-api-name" id="postMessage(data)"><code>postMessage(data)</code></h4>
+
+<p>Sends a message to the widget's content scripts.</p>
+
+<h5 id="Parameters_2">Parameters</h5>
+
+<p><strong>data : value</strong><br>
+ The message to send. The message can be any <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts/using_port#JSON-Serializable_Values">JSON-serializable value</a>.</p>
+
+<h4 class="addon-sdk-api-name" id="on(type_listener)"><code>on(type, listener)</code></h4>
+
+<p>Registers an event listener with the widget.</p>
+
+<h5 id="Parameters_3">Parameters</h5>
+
+<p><strong>type : string</strong><br>
+ The type of event to listen for.</p>
+
+<p><strong>listener : function</strong><br>
+ The listener function that handles the event.</p>
+
+<h4 class="addon-sdk-api-name" id="removeListener(type_listener)"><code>removeListener(type, listener)</code></h4>
+
+<p>Unregisters an event listener from the widget.</p>
+
+<h5 id="Parameters_4">Parameters</h5>
+
+<p><strong>type : string</strong><br>
+ The type of event for which <code>listener</code> was registered.</p>
+
+<p><strong>listener : function</strong><br>
+ The listener function that was registered.</p>
+
+<h4 class="addon-sdk-api-name" id="getView(window)"><code>getView(window)</code></h4>
+
+<p>Retrieve a <code>WidgetView</code> instance of this widget relative to a browser window.</p>
+
+<h5 id="Parameters_5">Parameters</h5>
+
+<p><strong>window : BrowserWindow</strong><br>
+ The <a href="/en-US/Add-ons/SDK/High-Level_APIs/windows#BrowserWindow">BrowserWindow</a> instance to match.</p>
+
+<h5 id="Returns">Returns</h5>
+
+<p><strong>WidgetView</strong> : A <code>WidgetView</code> instance associated with the browser window. Any changes subsequently applied to this object will only be applied to the widget attached to that window.</p>
+
+<h3 id="Properties">Properties</h3>
+
+<h4 class="addon-sdk-api-name" id="label"><code>label</code></h4>
+
+<p>The widget's label. Read-only.</p>
+
+<h4 class="addon-sdk-api-name" id="content"><code>content</code></h4>
+
+<p>A string containing the widget's content. It can contain HTML. Setting it updates the widget's appearance immediately. However, if the widget was created using <code>contentURL</code>, then this property is meaningless, and setting it has no effect.</p>
+
+<h4 class="addon-sdk-api-name" id="contentURL"><code>contentURL</code></h4>
+
+<p>The URL of content to load into the widget. This can point to local content loaded from your add-on's "data" directory or remote content, an image or web content. Setting it updates the widget's appearance immediately. However, if the widget was created using <code>content</code>, then this property is meaningless, and setting it has no effect.</p>
+
+<p>Setting the <code>contentURL</code> property will break the channel of communication between this widget and any content scripts it contains. Messages sent from the content script will no longer be received by the main add-on code, and vice versa. This issue is currently tracked as <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=825434">bug 825434</a>.</p>
+
+<h4 class="addon-sdk-api-name" id="panel"><code>panel</code></h4>
+
+<p>A <a href="/en-US/Add-ons/SDK/High-Level_APIs/panel">panel</a> to open when the user clicks on the widget.</p>
+
+<h4 class="addon-sdk-api-name" id="width"><code>width</code></h4>
+
+<p>The widget's width in pixels. Setting it updates the widget's appearance immediately.</p>
+
+<h4 class="addon-sdk-api-name" id="tooltip"><code>tooltip</code></h4>
+
+<p>The text of the tooltip that appears when the user hovers over the widget.</p>
+
+<h4 class="addon-sdk-api-name" id="allow"><code>allow</code></h4>
+
+<p>A object describing permissions for the content. It contains a single key named <code>script</code> whose value is a boolean that indicates whether or not to execute script in the content.</p>
+
+<h4 class="addon-sdk-api-name" id="contentScriptFile"><code>contentScriptFile</code></h4>
+
+<p>A local file URL or an array of local file URLs of content scripts to load.</p>
+
+<h4 class="addon-sdk-api-name" id="contentScript"><code>contentScript</code></h4>
+
+<p>A string or an array of strings containing the texts of content scripts to load.</p>
+
+<h4 class="addon-sdk-api-name" id="contentScriptWhen"><code>contentScriptWhen</code></h4>
+
+<p>When to load the content scripts. This may have one of the following values:</p>
+
+<ul>
+ <li>"start": load content scripts immediately after the document element for the widget is inserted into the DOM, but before the DOM content itself has been loaded</li>
+ <li>"ready": load content scripts once DOM content has been loaded, corresponding to the <a href="https://developer.mozilla.org/en/Gecko-Specific_DOM_Events">DOMContentLoaded</a> event</li>
+ <li>"end": load content scripts once all the content (DOM, JS, CSS, images) for the widget has been loaded, at the time the <a href="https://developer.mozilla.org/en/DOM/window.onload">window.onload event</a> fires</li>
+</ul>
+
+<h4 class="addon-sdk-api-name" id="contentScriptOptions"><code>contentScriptOptions</code></h4>
+
+<p>Read-only value exposed to content scripts under <code>self.options</code> property.</p>
+
+<p>Any kind of jsonable value (object, array, string, etc.) can be used here. Optional.</p>
+
+<h4 class="addon-sdk-api-name" id="port"><code>port</code></h4>
+
+<p>Object that allows you to:</p>
+
+<ul>
+ <li>send events to the content script using the <code>port.emit</code> function</li>
+ <li>receive events from the content script using the <code>port.on</code> function</li>
+</ul>
+
+<p>See the guide to <a href="/en-US/Add-ons/SDK/Guides/using_port"> communicating using <code>port</code></a> for details.</p>
+
+<h3 id="Events">Events</h3>
+
+<h4 class="addon-sdk-api-name" id="attach"><code>attach</code></h4>
+
+<p>This event is emitted when a browser window is opened and a new <code>WidgetView</code> object is created. If the widget has a content script, this event is fired only when the content script is applied according to the <code>contentScriptWhen</code> attribute.</p>
+
+<h5 id="Arguments">Arguments</h5>
+
+<p><strong>WidgetView</strong> : The related <code>WidgetView</code> object.</p>
+
+<h4 class="addon-sdk-api-name" id="click"><code>click</code></h4>
+
+<p>This event is emitted when the widget is clicked.</p>
+
+<h5 id="Arguments_2">Arguments</h5>
+
+<p><strong>WidgetView</strong> : Listeners are passed a single argument which is the <code>WidgetView</code> that triggered the click event.</p>
+
+<h4 class="addon-sdk-api-name" id="message"><code>message</code></h4>
+
+<p>If you listen to this event you can receive message events from content scripts associated with this widget. When a content script posts a message using <code>self.postMessage()</code>, the message is delivered to the add-on code in the widget's <code>message</code> event.</p>
+
+<h5 id="Arguments_3">Arguments</h5>
+
+<p><strong>value</strong> : Listeners are passed a single argument which is the message posted from the content script. The message can be any <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts/using_port#JSON-Serializable_Values">JSON-serializable value</a>.</p>
+
+<h4 class="addon-sdk-api-name" id="mouseover"><code>mouseover</code></h4>
+
+<p>This event is emitted when the user moves the mouse over the widget.</p>
+
+<h4 class="addon-sdk-api-name" id="mouseout"><code>mouseout</code></h4>
+
+<p>This event is emitted when the user moves the mouse away from the widget.</p>
+
+<h2 id="WidgetView">WidgetView</h2>
+
+<p>Represents a widget instance specific to one browser window.</p>
+
+<p>Anything you do to an instance of this object will only be applied to the instance attached to its browser window: widget instances attached to other browser windows will be unaffected.</p>
+
+<p>By contrast, any changes you make to an instance of the normal <code>Widget</code> class will be applied across all browser windows.</p>
+
+<p>This class has all the same methods, attributes and events as the <code>Widget</code> class except for the <code>getView</code> method and the <code>attach</code> event.</p>
+
+<p>In this example <code>WidgetView</code> is used to display different content for <code>http</code> and <code>https</code> schemes:</p>
+
+<pre class="brush: js">// A widget that update its content specifically to each window.
+var tabs = require("sdk/tabs");
+var windows = require("sdk/windows").browserWindows;
+var widget = require("sdk/widget").Widget({
+ id: "window-specific-test",
+ label: "Widget with content specific to each window",
+ content: " ",
+ width: 50
+});
+// Observe tab switch or document changes in each existing tab:
+function updateWidgetState(tab) {
+ var view = widget.getView(tab.window);
+ if (!view) return;
+ // Update widget displayed text:
+ view.content = tab.url.match(/^https/) ? "Secured" : "Unsafe";
+}
+tabs.on('ready', updateWidgetState);
+tabs.on('activate', updateWidgetState);</pre>
+
+<h3 id="Methods_2">Methods</h3>
+
+<h4 class="addon-sdk-api-name" id="destroy()_2"><code>destroy()</code></h4>
+
+<p>Removes the widget view from the add-on bar.</p>
+
+<h4 class="addon-sdk-api-name" id="postMessage(data)_2"><code>postMessage(data)</code></h4>
+
+<p>Sends a message to the widget view's content scripts.</p>
+
+<h5 id="Parameters_6">Parameters</h5>
+
+<p><strong>data : value</strong><br>
+ The message to send. The message can be any <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts/using_port#JSON-Serializable_Values">JSON-serializable value</a>.</p>
+
+<h4 class="addon-sdk-api-name" id="on(type_listener)_2"><code>on(type, listener)</code></h4>
+
+<p>Registers an event listener with the widget view.</p>
+
+<h5 id="Parameters_7">Parameters</h5>
+
+<p><strong>type : string</strong><br>
+ The type of event to listen for.</p>
+
+<p><strong>listener : function</strong><br>
+ The listener function that handles the event.</p>
+
+<h4 class="addon-sdk-api-name" id="removeListener(type_listener)_2"><code>removeListener(type, listener)</code></h4>
+
+<p>Unregisters an event listener from the widget view.</p>
+
+<h5 id="Parameters_8">Parameters</h5>
+
+<p><strong>type : string</strong><br>
+ The type of event for which <code>listener</code> was registered.</p>
+
+<p><strong>listener : function</strong><br>
+ The listener function that was registered.</p>
+
+<h3 id="Properties_2">Properties</h3>
+
+<h4 class="addon-sdk-api-name" id="label_2"><code>label</code></h4>
+
+<p>The widget view's label. Read-only.</p>
+
+<h4 class="addon-sdk-api-name" id="content_2"><code>content</code></h4>
+
+<p>A string containing the widget view's content. It can contain HTML. Setting it updates the widget view's appearance immediately. However, if the widget view was created using <code>contentURL</code>, then this property is meaningless, and setting it has no effect.</p>
+
+<h4 class="addon-sdk-api-name" id="contentURL_2"><code>contentURL</code></h4>
+
+<p>The URL of content to load into the widget. This can point to local content loaded from your add-on's "data" directory or remote content, an image or web content. Setting it updates the widget's appearance immediately. However, if the widget was created using <code>content</code>, then this property is meaningless, and setting it has no effect.</p>
+
+<p>Setting the <code>contentURL</code> property will break the channel of communication between this widget and any content scripts it contains. Messages sent from the content script will no longer be received by the main add-on code, and vice versa. This issue is currently tracked as <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=825434">bug 825434</a>.</p>
+
+<h4 class="addon-sdk-api-name" id="panel_2"><code>panel</code></h4>
+
+<p>A <a href="/en-US/Add-ons/SDK/High-Level_APIs/panel">panel</a> to open when the user clicks on the widget view.</p>
+
+<h4 class="addon-sdk-api-name" id="width_2"><code>width</code></h4>
+
+<p>The widget view's width in pixels. Setting it updates the widget view's appearance immediately.</p>
+
+<h4 class="addon-sdk-api-name" id="tooltip_2"><code>tooltip</code></h4>
+
+<p>The text of the tooltip that appears when the user hovers over the widget view.</p>
+
+<h4 class="addon-sdk-api-name" id="allow_2"><code>allow</code></h4>
+
+<p>A object describing permissions for the content. It contains a single key named <code>script</code> whose value is a boolean that indicates whether or not to execute script in the content.</p>
+
+<h4 class="addon-sdk-api-name" id="contentScriptFile_2"><code>contentScriptFile</code></h4>
+
+<p>A local file URL or an array of local file URLs of content scripts to load.</p>
+
+<h4 class="addon-sdk-api-name" id="contentScript_2"><code>contentScript</code></h4>
+
+<p>A string or an array of strings containing the texts of content scripts to load.</p>
+
+<h4 class="addon-sdk-api-name" id="contentScriptWhen_2"><code>contentScriptWhen</code></h4>
+
+<p>When to load the content scripts. This may have one of the following values:</p>
+
+<ul>
+ <li>"start": load content scripts immediately after the document element for the widget view is inserted into the DOM, but before the DOM content itself has been loaded</li>
+ <li>"ready": load content scripts once DOM content has been loaded, corresponding to the <a href="https://developer.mozilla.org/en/Gecko-Specific_DOM_Events">DOMContentLoaded</a> event</li>
+ <li>"end": load content scripts once all the content (DOM, JS, CSS, images) for the widget view has been loaded, at the time the <a href="https://developer.mozilla.org/en/DOM/window.onload">window.onload event</a> fires</li>
+</ul>
+
+<h4 class="addon-sdk-api-name" id="contentScriptOptions_2"><code>contentScriptOptions</code></h4>
+
+<p>Read-only value exposed to content scripts under <code>self.options</code> property.</p>
+
+<p>Any kind of jsonable value (object, array, string, etc.) can be used here. Optional.</p>
+
+<h4 class="addon-sdk-api-name" id="port_2"><code>port</code></h4>
+
+<p>Object that allows you to:</p>
+
+<ul>
+ <li>send events to the content script using the <code>port.emit</code> function</li>
+ <li>receive events from the content script using the <code>port.on</code></li>
+</ul>
+
+<p>See the guide to <a href="/en-US/Add-ons/SDK/Guides/using_port"> communicating using <code>port</code></a> for details.</p>
+
+<h3 id="Events_2">Events</h3>
+
+<h4 class="addon-sdk-api-name" id="detach"><code>detach</code></h4>
+
+<p>The <code>detach</code> event is fired when the widget view is removed from its related window. This can occur if the window is closed, Firefox exits, or the add-on is disabled.</p>
+
+<h4 class="addon-sdk-api-name" id="click_2"><code>click</code></h4>
+
+<p>This event is emitted when the widget view is clicked.</p>
+
+<h4 class="addon-sdk-api-name" id="message_2"><code>message</code></h4>
+
+<p>If you listen to this event you can receive message events from content scripts associated with this widget view. When a content script posts a message using <code>self.postMessage()</code>, the message is delivered to the add-on code in the widget view's <code>message</code> event.</p>
+
+<h5 id="Arguments_4">Arguments</h5>
+
+<p><strong>value</strong> : Listeners are passed a single argument which is the message posted from the content script. The message can be any <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts/using_port#JSON-Serializable_Values">JSON-serializable value</a>.</p>
+
+<h4 class="addon-sdk-api-name" id="mouseover_2"><code>mouseover</code></h4>
+
+<p>This event is emitted when the user moves the mouse over the widget view.</p>
+
+<h4 class="addon-sdk-api-name" id="mouseout_2"><code>mouseout</code></h4>
+
+<p>This event is emitted when the user moves the mouse away from the widget view.</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/index.html b/files/zh-cn/mozilla/add-ons/sdk/index.html
new file mode 100644
index 0000000000..3c6398ed48
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/index.html
@@ -0,0 +1,104 @@
+---
+title: 附加组件 SDK
+slug: Mozilla/Add-ons/SDK
+tags:
+ - More Example
+ - Need Tanslate
+ - TopicStub
+translation_of: Archive/Add-ons/Add-on_SDK
+---
+<div class="warning">
+<p>Support for extensions using XUL/XPCOM or the Add-on SDK was removed in Firefox 57, released November 2017. As there is no supported version of Firefox enabling these technologies, this page will be removed by December 2020.</p>
+
+<p>Add-ons using the techniques described in this document are considered a legacy technology in Firefox. Don't use these techniques to develop new add-ons. Use <a href="/en-US/Add-ons/WebExtensions">WebExtensions</a> instead. If you maintain an add-on which uses the techniques described here, consider migrating it to use WebExtensions.</p>
+
+<p><strong>Starting from <a href="https://wiki.mozilla.org/RapidRelease/Calendar">Firefox 53</a>, no new legacy add-ons will be accepted on addons.mozilla.org (AMO) for desktop Firefox and Firefox for Android.</strong></p>
+
+<p><strong>Starting from <a href="https://wiki.mozilla.org/RapidRelease/Calendar">Firefox 57</a>, only extensions developed using WebExtensions APIs will be supported on Desktop Firefox and Firefox for Android. </strong></p>
+
+<p>Even before Firefox 57, changes coming up in the Firefox platform will break many legacy extensions. These changes include multiprocess Firefox (e10s), sandboxing, and multiple content processes. Legacy extensions that are affected by these changes should migrate to use WebExtensions APIs if they can. See the <a href="https://blog.mozilla.org/addons/2017/02/16/the-road-to-firefox-57-compatibility-milestones/">"Compatibility Milestones" document</a> for more information.</p>
+
+<p>A wiki page containing <a href="https://wiki.mozilla.org/Add-ons/developer/communication">resources, migration paths, office hours, and more</a>, is available to help developers transition to the new technologies.</p>
+</div>
+
+<p>你可以使用Add-on SDK来开发Firefox的附加组件。你可以使用各种各样的标准Web技术:JavaScript, HTML和CSS。该SDK不仅包括一些用来创建附加组件的 JavaScript API,还提供了开发、运行、测试、打包附加组件的一些工具。</p>
+
+<hr>
+<h3 id="教程">教程</h3>
+
+<div class="column-container">
+<div class="column-half">
+<dl>
+ <dt><code><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials#getting-started">快速入门</a></code></dt>
+ <dd>如何<a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/SDK/Tools/jpm">安装SDK</a>并<a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Getting_started">使用jpm工具</a>开发、测试、打包附加组件</dd>
+ <dt><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials#interact-with-the-browser">与浏览器交互</a></dt>
+ <dd><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Open_a_Web_Page">打开网页</a>,<a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Listen_for_Page_Load">监听页面加载</a>,<a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/List_Open_Tabs">列出打开的标签页</a>。</dd>
+ <dt><a href="/zh-CN/Add-ons/SDK/Tutorials#development-techniques">开发技术</a></dt>
+ <dd>学习常用开发技术,如<a href="/zh-CN/Add-ons/SDK/Tutorials/Unit_testing">单元测试</a>,<a href="/zh-CN/Add-ons/SDK/Tutorials/Logging">日志</a>,<a href="/zh-CN/Add-ons/SDK/Tutorials/Creating_Reusable_Modules">创建可复用模块</a>,<a href="/zh-CN/Add-ons/SDK/Tutorials/l10n">本地化</a>,<a href="/zh-CN/Add-ons/SDK/Tutorials/Mobile_development">移动开发</a></dd>
+</dl>
+</div>
+
+<div class="column-half">
+<dl>
+ <dt><a href="/zh-CN/Add-ons/SDK/Tutorials#create-user-interfaces">创建用户界面组件</a></dt>
+ <dd>创建用户界面组件如<a href="/zh-CN/Add-ons/SDK/Tutorials/Adding_a_Button_to_the_Toolbar">工具条按钮</a>, <a href="/zh-CN/Add-ons/SDK/Tutorials/Add_a_Context_Menu_Item">上下文菜单</a>,<a href="/zh-CN/Add-ons/SDK/Tutorials/Add_a_Menu_Item_to_Firefox">菜单项</a>,<a href="/zh-CN/Add-ons/SDK/Tutorials/Display_a_Popup">对话框</a>。</dd>
+ <dt><a href="/zh-CN/Add-ons/SDK/Tutorials#modify-web-pages">修改网页</a></dt>
+ <dd>
+ <p>通过<a href="/zh-CN/docs//zh-CN/Add-ons/SDK/Tutorials/Modifying_Web_Pages_Based_on_URL">URL匹配</a>修改页面或者动态<a href="/zh-CN/docs//zh-CN/Add-ons/SDK/Tutorials/Modifying_the_Page_Hosted_by_a_Tab">修改某个tab选项卡</a>。</p>
+ </dd>
+ <dt><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Annotator">将其组合在一起</a></dt>
+ <dd>关于注释器的附加组件的例子演示.</dd>
+</dl>
+</div>
+</div>
+
+<hr>
+<h3 id="指南">指南</h3>
+
+<div class="column-container">
+<div class="column-half">
+<dl>
+ <dt><a href="/zh-CN/Add-ons/SDK/Guides#contributors-guide"><span class="short_text" id="result_box" lang="zh-CN"><span class="op_dict_text2">贡献者</span><span>指南</span></span></a></dt>
+ <dd>学习<a href="/zh-CN/Add-ons/SDK/Guides/Getting_Started">如何开始构建</a> SDK和关于SDK最重要的术语, 如 <a href="/zh-CN/Add-ons/SDK/Guides/Modules">模块</a>, <a href="/zh-CN/Add-ons/SDK/Guides/Classes_and_Inheritance"> 类和继承</a>, <a href="/zh-CN/Add-ons/SDK/Guides/Private_Properties">私有属性</a>, <a href="/zh-CN/Add-ons/SDK/Guides/Content_Processes">内容处理</a>.</dd>
+ <dt><a href="/zh-CN/Add-ons/SDK/Guides#sdk-infrastructure">SDK的基础构建</a></dt>
+ <dd>SDK的底层技术方面: <a href="/zh-CN/Add-ons/SDK/Guides/Module_structure_of_the_SDK">模块</a>,<a href="/zh-CN/Add-ons/SDK/Guides/Program_ID">程序ID</a>, <a href="/zh-CN/Add-ons/SDK/Guides/Firefox_Compatibility">Firefox 兼容</a>的规则定义.</dd>
+ <dt><a href="/zh-CN/Add-ons/SDK/Guides/Content_Scripts"><span class="short_text" id="result_box" lang="zh-CN"><span>内容</span><span>脚本</span></span></a></dt>
+ <dd>
+ <div class="output-bd" dir="ltr">
+ <p class="ordinary-output target-output"><span>一个详细的</span><span>指南</span><span>内容脚本</span></p>
+ </div>
+ </dd>
+</dl>
+</div>
+
+<div class="column-half">
+<dl>
+ <dt><a href="/zh-CN/Add-ons/SDK/Guides#sdk-idioms">SDK语法</a></dt>
+ <dd>SDK的事件框架和插件的脚本和内容脚本之间的区别。</dd>
+ <dd>SDK的 <a href="/zh-CN/Add-ons/SDK/Guides/Working_with_Events">事件框架</a> 和 <a href="/zh-CN/Add-ons/SDK/Guides/Two_Types_of_Scripts">add-on scripts 和 content scripts 的</a>区别.</dd>
+ <dt><a href="/zh-CN/Add-ons/SDK/Guides/XUL_Migration_Guide">XUL 迁移</a></dt>
+ <dd>指导  <a href="/zh-CN/Add-ons/SDK/Guides/XUL_Migration_Guide">移植 XUL add-ons 到 SDK</a>. 本指南包括 <a href="/zh-CN/Add-ons/SDK/Guides/XUL_vs_SDK">两工具</a> 和 一个 <a href="/zh-CN/Add-ons/SDK/Guides/Porting_the_Library_Detector">工作实例</a> 比较 XUL 和 add-on.</dd>
+</dl>
+</div>
+</div>
+
+<hr>
+<h3 id="参考"><span class="short_text" id="result_box" lang="zh-CN"><span>参考</span></span></h3>
+
+<div class="column-container">
+<div class="column-half">
+<dl>
+ <dt><a href="/zh-CN/Add-ons/SDK/High-Level_APIs">高级API</a></dt>
+ <dd>高级SDK API的参考文档.</dd>
+ <dt><a href="/zh-CN/Add-ons/SDK/Tools">工具参考</a></dt>
+ <dd>用于 <a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tools/jpm">jpm工具</a> 开发的参考文档, 测试, 打包add-ons, 全局 <a href="/zh-CN/Add-ons/SDK/Tools/console">控制台</a>记录, 和<a href="/zh-CN/Add-ons/SDK/Tools/package_json">package.json</a> 文件.</dd>
+</dl>
+</div>
+
+<div class="column-half">
+<dl>
+ <dt><a href="/zh-CN/Add-ons/SDK/Low-Level_APIs">低级API</a></dt>
+ <dd>低级SDK API的参考文档.</dd>
+</dl>
+</div>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/low-level_apis/index.html b/files/zh-cn/mozilla/add-ons/sdk/low-level_apis/index.html
new file mode 100644
index 0000000000..673c369430
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/low-level_apis/index.html
@@ -0,0 +1,26 @@
+---
+title: 低层 API
+slug: Mozilla/Add-ons/SDK/Low-Level_APIs
+translation_of: Archive/Add-ons/Add-on_SDK/Low-Level_APIs
+---
+<p>{{AddonSidebar}}</p>
+
+<p>本节的模块实现了低层的 API,这些模块大至分为三类:</p>
+
+<ul>
+ <li>
+ <p>基础工具,比如 <a href="/en-US/Add-ons/SDK/Low-Level_APIs/util_collection">collection</a>。很多 add-ons 都有可能使用这个类别的模块。</p>
+ </li>
+ <li>
+ <p>为高层模块构建分块,比如 <a href="/en-US/Add-ons/SDK/Low-Level_APIs/event_core">events</a> 和 <a href="/en-US/Add-ons/SDK/Low-Level_APIs/content_worker">worker</a>。你更有可能使用它们构建你自己德尔模块,来扩展 SDK 本身。</p>
+ </li>
+ <li>
+ <p>权限模块,露出强大的低层功能,比如<a href="/en-US/Add-ons/SDK/Low-Level_APIs/window_utils">window/utils</a> 和 <a href="/en-US/Add-ons/SDK/Low-Level_APIs/net_xhr">net/xhr</a>。你可以使用这些模块,但是应该意识到获取访问权限的代价是必须采取更加详尽的预防措施。大部分情况下这些模块在"高层API中"有着简单的更加严格的同类模块。(例如,<a href="/en-US/Add-ons/SDK/High-Level_APIs/windows">windows</a> 或 <a href="/en-US/Add-ons/SDK/High-Level_APIs/request">request</a>)。</p>
+ </li>
+</ul>
+
+<p>这些模块仍在开发中,我们预期在将来发布的版本中会做出不兼容的变更。</p>
+
+<p>{{ LandingPageListSubpages ("/zh-CN/Add-ons/SDK/Low-Level_APIs", 5) }}</p>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/low-level_apis/test_assert/index.html b/files/zh-cn/mozilla/add-ons/sdk/low-level_apis/test_assert/index.html
new file mode 100644
index 0000000000..5f7537ec42
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/low-level_apis/test_assert/index.html
@@ -0,0 +1,283 @@
+---
+title: test/assert
+slug: Mozilla/Add-ons/SDK/Low-Level_APIs/test_assert
+translation_of: Archive/Add-ons/Add-on_SDK/Low-Level_APIs/test_assert
+---
+<p>{{LegacyAddonsNotice}}{{AddonSidebar}}</p>
+
+<div class="note">
+<p>Unstable</p>
+</div>
+
+<p>实现在 <a href="http://wiki.commonjs.org/wiki/Unit_Testing/1.1">CommonJS Unit Testing specification version 1.1</a> 其中定义的断言接口。</p>
+
+<h2 id="Usage">Usage</h2>
+
+<p>To use the <code>assert</code> module, write a set of unit tests following the instructions in the <a href="/en-US/Add-ons/SDK/Tutorials/Unit_testing">unit testing tutorial</a>. Each test will be passed an <code>Assert</code> object when you run the tests using <a href="/en-US/Add-ons/SDK/Tools/jpm"><code>jpm test</code></a>. You can use this object to make assertions about your program's state.</p>
+
+<p>For example:</p>
+
+<pre class="brush: js">var a = 1;
+
+exports["test value of a"] = function(assert) {
+ assert.ok(a == 1, "test that a is 1");
+}
+
+require("sdk/test").run(exports);</pre>
+
+<h2 id="Globals">Globals</h2>
+
+<h3 id="Constructors">Constructors</h3>
+
+<h4 class="addon-sdk-api-name" id="Assert(logger)"><code>Assert(logger)</code></h4>
+
+<p>Create a new Assert object. This function is only called by the unit test framework, and not by unit tests themselves.</p>
+
+<h5 id="Parameters">Parameters</h5>
+
+<p><strong>logger : object</strong><br>
+ Object used to log the results of assertions.</p>
+
+<h2 id="Assert">Assert</h2>
+
+<p>An object used to make assertions about a program's state in order to implement unit tests.</p>
+
+<p>The <code>Assert</code> object's interface is defined by the <a href="http://wiki.commonjs.org/wiki/Unit_Testing/1.1">CommonJS Unit Testing specification, version 1.1</a>.</p>
+
+<h3 id="Methods">Methods</h3>
+
+<h4 class="addon-sdk-api-name" id="ok(guard_message)"><code>ok(guard, message)</code></h4>
+
+<p>Tests whether an expression evaluates to true.</p>
+
+<pre class="brush: js">assert.ok(a == 1, "test that a is equal to one");</pre>
+
+<p>This is equivalent to:</p>
+
+<pre class="brush: js">assert.equal(a == 1, true, "test that a is equal to one");</pre>
+
+<h5 id="Parameters_2">Parameters</h5>
+
+<p><strong>guard : expression</strong><br>
+ The expression to evaluate.</p>
+
+<p><strong>message : string</strong><br>
+ Optional message to log, providing extra information about the test.</p>
+
+<h4 class="addon-sdk-api-name" id="equal(actual_expected_message)"><code>equal(actual, expected, message)</code></h4>
+
+<p>Tests shallow, coercive equality with <code>==</code>:</p>
+
+<pre class="brush: js">assert.equal(1, 1, "test that one is one");</pre>
+
+<h5 id="Parameters_3">Parameters</h5>
+
+<p><strong>actual : object</strong><br>
+ The actual result.</p>
+
+<p><strong>expected : object</strong><br>
+ The expected result.</p>
+
+<p><strong>message : string</strong><br>
+ Optional message to log, providing extra information about the test.</p>
+
+<h4 class="addon-sdk-api-name" id="notEqual(actual_expected_message)"><code>notEqual(actual, expected, message)</code></h4>
+
+<p>Tests that two objects are not equal, using <code>!=</code>:</p>
+
+<pre class="brush: js">assert.notEqual(1, 2, "test that one is not two");</pre>
+
+<h5 id="Parameters_4">Parameters</h5>
+
+<p><strong>actual : object</strong><br>
+ The actual result.</p>
+
+<p><strong>expected : object</strong><br>
+ The expected result.</p>
+
+<p><strong>message : string</strong><br>
+ Optional message to log, providing extra information about the test.</p>
+
+<h4 class="addon-sdk-api-name" id="deepEqual(actual_expected_message)"><code>deepEqual(actual, expected, message)</code></h4>
+
+<p>Tests that two objects have a deep equality relation. Deep equality is defined in the <a href="http://wiki.commonjs.org/wiki/Unit_Testing/1.0#Assert">CommonJS specification for Assert</a>, item 7, which is quoted here:</p>
+
+<div class="quote">
+<ol>
+ <li>All identical values are equivalent, as determined by ===.</li>
+ <li>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.</li>
+ <li>Other pairs that do not both pass typeof value == "object", equivalence is determined by ==.</li>
+ <li>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.</li>
+</ol>
+</div>
+
+<pre class="brush: js">assert.deepEqual({ a: "foo" }, { a: "foo" }, "equivalent objects");</pre>
+
+<h5 id="Parameters_5">Parameters</h5>
+
+<p><strong>actual : object</strong><br>
+ The actual result.</p>
+
+<p><strong>expected : object</strong><br>
+ The expected result.</p>
+
+<p><strong>message : string</strong><br>
+ Optional message to log, providing extra information about the test.</p>
+
+<h4 class="addon-sdk-api-name" id="notDeepEqual(actual_expected_message)"><code>notDeepEqual(actual, expected, message)</code></h4>
+
+<p>Tests that two objects do not have a deep equality relation, using the negation of the test for deep equality:</p>
+
+<pre class="brush: js">assert.notDeepEqual({ a: "foo" }, Object.create({ a: "foo" }),
+ "object's inherit from different prototypes");</pre>
+
+<h5 id="Parameters_6">Parameters</h5>
+
+<p><strong>actual : object</strong><br>
+ The actual result.</p>
+
+<p><strong>expected : object</strong><br>
+ The expected result.</p>
+
+<p><strong>message : string</strong><br>
+ Optional message to log, providing extra information about the test.</p>
+
+<h4 class="addon-sdk-api-name" id="strictEqual(actual_expected_message)"><code>strictEqual(actual, expected, message)</code></h4>
+
+<p>Tests that two objects are equal, using the strict equality operator <code>===</code>:</p>
+
+<pre class="brush: js">// This test will pass, because "==" will perform type conversion
+exports["test coercive equality"] = function(assert) {
+ assert.equal(1, "1", "test coercive equality between 1 and '1'");
+}
+
+// This test will fail, because the types are different
+exports["test strict equality"] = function(assert) {
+ assert.strictEqual(1, "1", "test strict equality between 1 and '1'");
+}</pre>
+
+<h5 id="Parameters_7">Parameters</h5>
+
+<p><strong>actual : object</strong><br>
+ The actual result.</p>
+
+<p><strong>expected : object</strong><br>
+ The expected result.</p>
+
+<p><strong>message : string</strong><br>
+ Optional message to log, providing extra information about the test.</p>
+
+<h4 class="addon-sdk-api-name" id="notStrictEqual(actual_expected_message)"><code>notStrictEqual(actual, expected, message)</code></h4>
+
+<p>Tests that two objects are not equal, using the negation of the strict equality operator <code>===</code>:</p>
+
+<pre class="brush: js">// This test will fail, because "==" will perform type conversion
+exports["test coercive equality"] = function(assert) {
+ assert.notEqual(1, "1", "test coercive equality between 1 and '1'");
+}
+
+// This test will pass, because the types are different
+exports["test strict equality"] = function(assert) {
+ assert.notStrictEqual(1, "1", "test strict equality between 1 and '1'");
+}</pre>
+
+<h5 id="Parameters_8">Parameters</h5>
+
+<p><strong>actual : object</strong><br>
+ The actual result.</p>
+
+<p><strong>expected : object</strong><br>
+ The expected result.</p>
+
+<p><strong>message : string</strong><br>
+ Optional message to log, providing extra information about the test.</p>
+
+<h4 class="addon-sdk-api-name" id="throws(block_error_message)"><code>throws(block, error, message)</code></h4>
+
+<p>Assert that a block of code throws the expected exception.</p>
+
+<p>This method takes an optional <code>Error</code> argument:</p>
+
+<ul>
+ <li>
+ <p>to check that the exception thrown is of the expected type, pass a constructor function: the exception thrown must be an instance of the object returned by that function.</p>
+ </li>
+ <li>
+ <p>to check that the exception thrown contains a specific message, pass a regular expression here: the <code>message</code> property of the exception thrown must match the regular expression</p>
+ </li>
+</ul>
+
+
+<p>For example, suppose we define two different custom exceptions:</p>
+
+<pre class="brush: js">function MyError(message) {
+ this.name = "MyError";
+ this.message = message || "Default Message";
+}
+
+MyError.prototype = new Error();
+MyError.prototype.constructor = MyError;
+
+function AnotherError(message) {
+ this.name = "AnotherError";
+ this.message = message || "Default Message";
+ console.log(this.message);
+}
+
+AnotherError.prototype = new Error();
+AnotherError.prototype.constructor = AnotherError;</pre>
+
+<p>We can check the type of exception by passing a function as the <code>Error</code> argument:</p>
+
+<pre class="brush: js">exports["test exception type 1 expected to pass"] = function(assert) {
+ assert.throws(function() {
+ throw new MyError("custom message");
+ },
+ MyError,
+ "test throwing a specific exception");
+}
+
+exports["test exception type 2 expected to fail"] = function(assert) {
+ assert.throws(function() {
+ throw new MyError("custom message");
+ },
+ AnotherError,
+ "test throwing a specific exception");
+}</pre>
+
+<p>We can check the message by passing a regular expression:</p>
+
+<pre class="brush: js">exports["test exception message 1 expected to pass"] = function(assert) {
+ assert.throws(function() {
+ throw new MyError("custom message");
+ },
+ /custom message/,
+ "test throwing a specific message");
+}
+
+exports["test exception message 2 expected to pass"] = function(assert) {
+ assert.throws(function() {
+ throw new AnotherError("custom message");
+ },
+ /custom message/,
+ "test throwing a specific exception");
+}
+
+exports["test exception message 3 expected to fail"] = function(assert) {
+ assert.throws(function() {
+ throw new MyError("another message");
+ },
+ /custom message/,
+ "test throwing a specific message");
+}</pre>
+
+<h5 id="Parameters_9">Parameters</h5>
+
+<p><strong>block : block</strong><br>
+ The block of code to test.</p>
+
+<p><strong>error : function|RegExp</strong><br>
+ Either a constructor function returning the type of exception expected, or a regular expression expected to match the exception's <code>message</code> property.</p>
+
+<p><strong>message : string</strong><br>
+ Optional message to log, providing extra information about the test.</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/low-level_apis/ui_button_action/index.html b/files/zh-cn/mozilla/add-ons/sdk/low-level_apis/ui_button_action/index.html
new file mode 100644
index 0000000000..d826b15d7f
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/low-level_apis/ui_button_action/index.html
@@ -0,0 +1,526 @@
+---
+title: ui/button/action
+slug: Mozilla/Add-ons/SDK/Low-Level_APIs/ui_button_action
+translation_of: Archive/Add-ons/Add-on_SDK/Low-Level_APIs/ui_button_action
+---
+<div class="note">
+ <p>实验性的(译者备注:暂不翻译,可能会废弃)</p>
+</div>
+<p><span class="seoSummary">Add a button to the Firefox user interface.</span> With this module you can create buttons that display icons and can respond to click events.</p>
+<h2 id="Usage">Usage</h2>
+<h3 id="Creating_buttons"><br>
+ Creating buttons</h3>
+<p>To create a button you must give it an ID, an icon, and a label:</p>
+<pre class="brush: js">var { ActionButton } = require("sdk/ui/button/action");
+
+var button = ActionButton({
+    id: "my-button",
+    label: "my button",
+    icon: {
+      "16": "./firefox-16.png",
+      "32": "./firefox-32.png"
+    },
+    onClick: function(state) {
+        console.log("button '" + state.label + "' was clicked");
+    }
+  });</pre>
+<p>By default, the button appears in the Firefox toolbar:</p>
+<p><img alt="" src="https://mdn.mozillademos.org/files/6803/action-button-toolbar.png" style="width: 381px; height: 201px; display: block; margin-left: auto; margin-right: auto;">However, users can move it to the Firefox menu panel using the <a href="https://support.mozilla.org/en-US/kb/customize-firefox-controls-buttons-and-toolbars">toolbar customization feature</a>:</p>
+<p><img alt="" src="https://mdn.mozillademos.org/files/6809/action-button-menu.png" style="width: 381px; height: 573px; display: block; margin-left: auto; margin-right: auto;"></p>
+<h3 id="Badged_buttons">Badged buttons</h3>
+<div class="geckoVersionNote">
+ <p>New in Firefox 36.</p>
+</div>
+<p>You can add a "badge" to a button using its <code>badge</code> property. This can be a number or a string, and you can update it at any time. By default the badge's color is red, but you can set your own color using the <code>badgeColor</code> property, specified as a CSS <a href="/en-US/docs/Web/CSS/color_value"><code>&lt;color&gt;</code></a> value:</p>
+<pre class="brush: js">var { ToggleButton } = require("sdk/ui/button/toggle");
+
+var button = ToggleButton({
+    id: "my-button1",
+    label: "my button1",
+    icon: "./icon-16.png",
+    onChange: changed,
+    badge: 0,
+    badgeColor: "#00AAAA"
+  });
+
+function changed(state) {
+  button.badge = state.badge + 1;
+  if (state.checked) {
+    button.badgeColor = "#AA00AA";
+  }
+  else {
+    button.badgeColor = "#00AAAA";
+  }
+}</pre>
+<p><img alt="" src="https://mdn.mozillademos.org/files/9067/badge.png" style="width: 383px; height: 202px; display: block; margin-left: auto; margin-right: auto;"></p>
+<h3 id="Specifying_multiple_icons">Specifying multiple icons</h3>
+<p>You can specify just one icon, or multiple icons in different sizes.</p>
+<p>If you specify multiple icons, Firefox will select the best-fitting icon based on the device screen resolution and the place the icon appears. For example, in the screenshots above, Firefox uses the small icon when the button is in the toolbar and the large icon when the button is in the menu panel. Read more about specifying icons in the reference documentation for the <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#ActionButton(options)"><code>ActionButton</code> constructor</a>.</p>
+<h3 id="Responding_to_click_events">Responding to click events</h3>
+<p>You can respond to click events by assigning a listener to the button's <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#click"><code>click</code></a> event. You can do this in the button's constructor, by assigning the listener to the <code>onClick</code> option. You can also add, or change, the listener afterwards:</p>
+<pre class="brush: js">var { ActionButton } = require("sdk/ui/button/action");
+
+var button = ActionButton({
+ id: "my-button",
+ label: "my button",
+ icon: {
+ "16": "./firefox-16.png",
+ "32": "./firefox-32.png"
+ },
+ onClick: firstClick
+ });
+
+function firstClick(state) {
+ console.log("You clicked '" + state.label + "'");
+ button.removeListener("click", firstClick);
+ button.on("click", subsequentClicks);
+}
+
+function subsequentClicks(state) {
+ console.log("You clicked '" + state.label + "' again");
+}</pre>
+<p>The listener is passed a <code>state</code> object that contains all the button's <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#Properties">properties</a>.</p>
+<p>You can generate click events programmatically with the button's <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#click()"><code>click()</code></a> method.</p>
+<h3 id="Disabling_buttons">Disabling buttons</h3>
+<p>You can disable a button by setting its <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#disabled"><code>disabled</code></a> property to <code>true</code>. A disabled button will not generate click events and its icon will appear disabled:</p>
+<p><img alt="" src="https://mdn.mozillademos.org/files/6805/action-button-toolbar-disabled.png" style="width: 381px; height: 201px; display: block; margin-left: auto; margin-right: auto;"></p>
+<h3 id="Updating_state">Updating state</h3>
+<p>You can update all the button's <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#Properties">properties</a> except for its <code>id</code>.</p>
+<p>By default, the button has global state: that is, its properties are the same across all open windows and tabs, and updating them updates the button's state across all open windows and tabs.</p>
+<p>You can set state to be specific to a window or tab using the button's <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#state()"><code>state()</code></a> method. To set state like this, call <code>state()</code> with 2 parameters:</p>
+<ul>
+ <li>the first parameter is a <a href="/en-US/Add-ons/SDK/High-Level_APIs/windows"><code>window</code></a> or <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs#Tab"><code>tab</code></a> object or as a shorthand, the string "window" for the currently active window, or the string "tab" for the currently active tab</li>
+ <li>the second parameter is an object containing the state properties you wish to update.</li>
+</ul>
+<p>Here's an add-on with a button that disables itself when you click it, but only for the currently active window:</p>
+<pre class="brush: js">var { ActionButton } = require("sdk/ui/button/action");
+
+var button = ActionButton({
+ id: "my-button",
+ label: "my button",
+ icon: {
+ "16": "./firefox-16.png",
+ "32": "./firefox-32.png"
+ },
+ onClick: disableForThisWindow
+ });
+
+function disableForThisWindow(state) {
+ button.state("window", {
+ disabled: true
+ });
+}</pre>
+<p>To fetch the state for a specific window or tab, call <code>state()</code>, passing in the window or tab you are interested in, and it will return the state:</p>
+<pre class="brush: js">var labelForActiveTab = button.state("tab").label;</pre>
+<p>To learn more about this, see the API documentation for <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#state()"><code>state()</code></a>.</p>
+<h3 id="Destroying_buttons">Destroying buttons</h3>
+<p>When you've finished with a button, destroy it by calling its <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#destroy()"><code>destroy()</code></a> method. After that, any attempts to access any of its properties or to call any of its methods will throw exceptions.</p>
+<h2 id="Globals">Globals</h2>
+<h3 id="Constructors">Constructors</h3>
+<h4 class="addon-sdk-api-name" id="ActionButton(options)"><code>ActionButton(options)</code></h4>
+<p>Creates an action button.</p>
+<h5 id="Parameters">Parameters</h5>
+<p><strong>options : object</strong><br>
+ Required options:</p>
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Name</th>
+ <th scope="col">Type</th>
+ <th scope="col"> </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>id</td>
+ <td>string</td>
+ <td>
+ <p>The button's ID. This is used internally to keep track of this button. The ID must be unique within your add-on.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>label</td>
+ <td>string</td>
+ <td>
+ <p>The button's human-readable label. When the button is in the toolbar, this appears in a tooltip, and when the button is in the menu, it appears underneath the button as a legend.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>icon</td>
+ <td>url, string, object</td>
+ <td>
+ <p>One or more icons for the button. You can specify this in one of three ways: </p>
+ <ul>
+ <li><strong>as a resource:// URL</strong> pointing at an icon file in your add-on's "data" directory, typically constructed using <em><code>self.data.url(iconfile)</code></em></li>
+ <li><strong>as a relative path</strong>: a string in the form "./iconfile", where "iconfile" is a relative path to the icon file beginning in your add-on's "data" directory</li>
+ <li><strong>as an object, or dictionary of key-value pairs</strong>. Here you can specify a range of sizes for your button's icon. Each key-value pair specifies an icon:
+ <ul>
+ <li>each value specifies an image file as a resource:// URL or relative path.</li>
+ <li>each key must be a numeric string such as "16", or "32", which represents the size in pixels of the corresponding image.</li>
+ </ul>
+ </li>
+ </ul>
+ <pre class="brush: js">
+var { ActionButton } = require('sdk/ui/button/action');
+var self = require("sdk/self");
+
+var button1 = ActionButton({
+    id: "my-button1",
+    label: "my button1",
+    icon: self.data.url("firefox-16.png")
+  });
+
+var button2 = ActionButton({
+    id: "my-button2",
+    label: "my button2",
+    icon: "./firefox-16.png"
+  });
+
+var button3 = ActionButton({
+    id: "my-button3",
+    label: "my button3",
+    icon: {
+      "16" : "./firefox-16.png",
+      "32" : "./firefox-32.png",
+      "64" : "./firefox-64.png"
+    }
+  });</pre>
+ <p>If you use the final form, Firefox will automatically choose the best-fit icon for your button, depending on the device screen resolution and where the button is in the UI. On a device with a "normal" screen resolution, the toolbar has space for 18 x 18 pixels and the menu panel has space for 32 x 32 pixels. On a high resolution screen (such as a <a href="https://en.wikipedia.org/wiki/Retina_Display">HiDPI</a> display), these are doubled to 36 x 36 and 64 x 64 pixels, respectively. So you can supply three icon files:</p>
+ <pre class="brush: js">
+icon: {
+ "16": "./addon16.png",
+ "32": "./addon32.png",
+ "64": "./addon64.png"
+}</pre>
+ <p>This will look fine in both toolbar and menu panel, and for both screen resolutions. However, the icons in the toolbar will not quite fill the space available, so you can instead supply four icons:</p>
+ <pre class="brush: js">
+icon: {
+ "18": "./addon18.png", // toolbar icon non HiDPI
+ "32": "./addon32.png", // menu panel icon non HiDPI
+ "36": "./addon36.png", // toolbar icon HiDPI
+ "64": "./addon64.png" // menu panel icon HiDPI
+}
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>Optional options:</p>
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Name</th>
+ <th scope="col">Type</th>
+ <th scope="col"> </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>disabled</td>
+ <td>boolean</td>
+ <td>
+ <p>Determines whether the button is disabled. Disabled buttons appear disabled in the UI, and do not respond to clicks. Defaults to false.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>onClick</td>
+ <td>function</td>
+ <td>
+ <p>Click handler for the button.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>badge</td>
+ <td>Number or String</td>
+ <td>
+ <div class="geckoVersionNote">
+ <p>New in Firefox 36.</p>
+ </div>
+ <p><a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#Badged_buttons">Badge</a> to attach to the button.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>badgeColor</td>
+ <td>CSS <a href="/en-US/docs/Web/CSS/color_value">&lt;color&gt;</a> value</td>
+ <td>
+ <div class="geckoVersionNote">
+ <p>New in Firefox 36.</p>
+ </div>
+ <p>Color for the <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#Badged_buttons">badge</a>. If <code>badgeColor</code> is omitted and <code>badge</code> is specified, then the badge is red.</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="ActionButton">ActionButton</h2>
+<h3 id="Methods">Methods</h3>
+<h4 class="addon-sdk-api-name" id="click()"><code>click()</code></h4>
+<p>Click the button. This will cause the button to generate the <code>click</code> event:</p>
+<pre class="brush: js">var { ActionButton } = require('sdk/ui/button/action');
+
+var button = ActionButton({
+ id: "my-button",
+ label: "my button",
+ icon: {
+ "16": "./firefox-16.png",
+ "32": "./firefox-32.png"
+ },
+ onClick: function(state) {
+ console.log("You clicked '" + state.label + "'");
+ }
+});
+
+button.click();
+</pre>
+<h4 class="addon-sdk-api-name" id="state()"><code>state()</code></h4>
+<p>Get or set the button's state for a specific window or tab.</p>
+<p>By default, a button's properties are global, meaning that they are the same across all open windows and tabs, and that if you update these properties, then they are updated across all windows and tabs. But sometimes you want a button attached to one window (or tab) to have a different state to a button attached to a different window (or tab). That's what <code>state()</code> is for.</p>
+<p>To set a button's properties for a specific window or tab, call <code>state()</code>, passing it the <a href="/en-US/Add-ons/SDK/High-Level_APIs/windows"><code>window</code></a> or <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs"><code>tab</code></a> you want the property to apply to, and the property value to set. A special shortcut allows you to pass the string "window" or "tab" to select the currently active window or tab.</p>
+<p>For example, if you have a button like this:</p>
+<pre class="brush: js">var { ActionButton } = require('sdk/ui/button/action');
+
+var button = ActionButton({
+ id: "my-button",
+ label: "default",
+ icon: "./firefox-16.png"
+});</pre>
+<p>You can change its label for only the currently active window like this:</p>
+<pre class="brush: js">button.state("window", {
+ "label" : "window-specific label"
+});</pre>
+<p>You can change its label for only the currently active tab like this:</p>
+<pre class="brush: js">button.state("tab", {
+ "label" : "tab-specific label"
+});
+</pre>
+<p>To fetch the button state for a specific window or tab, call <code>state()</code>, passing it the window or tab you're interested in, and it will return a state object containing all the <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#Properties">properties</a> for the button associated with that window or tab. Again. you can use the strings "window" or "tab" as shortcuts. For example, this add-on:</p>
+<ul>
+ <li>creates a button with a default label</li>
+ <li>opens a new tab</li>
+ <li>sets a new label only for the new tab</li>
+ <li>logs the result of accessing the global label, the window-specific label, and each of the 2 tab-specific labels</li>
+</ul>
+<pre class="brush: js">var { ActionButton } = require('sdk/ui/button/action');
+var tabs = require("sdk/tabs");
+
+var button = ActionButton({
+  id: "my-button",
+  label: "default label",
+  icon: "./firefox-16.png"
+});
+
+tabs.open({
+  url: "https://mozilla.org/",
+  onOpen: onNewTab
+});
+
+function onNewTab(tab) {
+  // Modify the label only for the new tab
+  button.state(tab, {
+    "label" : "tab-specific label"
+  });
+
+  // access the global label -&gt; "default label"
+  console.log(button.label);
+
+  // access the window's label -&gt; "default label"
+  console.log(button.state("window").label);
+
+  // access the first tab's label -&gt; "default label"
+  console.log(button.state(tabs[0]).label);
+
+  // access the second tab's label -&gt; "tab-specific label"
+  console.log(button.state(tabs[1]).label);
+}</pre>
+<p>Setting a property won't affect a more-specific property setting. For example, if you have a window with two tabs, and you set a tab-specific label, then set the window-specific label, this will not overwrite the tab-specific label:</p>
+<pre class="brush: js">var { ActionButton } = require('sdk/ui/button/action');
+var tabs = require("sdk/tabs");
+
+var button = ActionButton({
+  id: "my-button",
+  label: "default label",
+  icon: "./firefox-16.png"
+});
+
+tabs.open({
+  url: "https://mozilla.org/",
+  onOpen: onNewTab
+});
+
+function onNewTab(tab) {
+  // Modify the label only for the new tab
+  button.state(tab, {
+    "label" : "tab-specific label"
+  });
+
+  // Modify the label for the window
+  button.state("window", {
+    "label" : "window-specific label"
+  });
+
+  // access the global label -&gt; "default label"
+  console.log(button.label);
+
+  // access the window's label -&gt; "window-specific label"
+  console.log(button.state("window").label);
+
+  // access the first tab's label -&gt; "window-specific label"
+  console.log(button.state(tabs[0]).label);
+
+  // access the second tab's label -&gt; "tab-specific label"
+  console.log(button.state(tabs[1]).label);
+}</pre>
+<p>The best way to think of this is as a tree: the global state is the root, followed by the state for each window, followed by the state for each tab in a window. If a property value for a node in the tree has not been set explicitly using <code>state()</code>, then it inherits its value from the next level up. So if you have one window containing two tabs, and have set the button's <code>label</code> only for tab A, then tab B will inherit <code>label</code>'s value from the window, and changing the value for the window will implicitly change the value for tab B.</p>
+<p>To delete a tab- or window-specific state, assign <code>null</code> to the property. After that, the property will inherit its value from the less-specific state as before:</p>
+<pre class="brush: js">var { ActionButton } = require('sdk/ui/button/action');
+var tabs = require("sdk/tabs");
+
+var button = ActionButton({
+ id: "my-button",
+ label: "default label",
+ icon: "./firefox-16.png"
+});
+
+tabs.open({
+ url: "https://mozilla.org/",
+ onOpen: onNewTab
+});
+
+function onNewTab(tab) {
+ // Modify the label only for the new tab
+ button.state(tab, {
+ "label" : "tab-specific label"
+ });
+
+ // Modify the label for the window
+ button.state("window", {
+ "label" : "window-specific label"
+ });
+
+ // access the global label -&gt; "default label"
+ console.log(button.label);
+
+ // access the window's label -&gt; "window-specific label"
+ console.log(button.state("window").label);
+
+ // access the first tab's label -&gt; "window-specific label"
+ console.log(button.state(tabs[0]).label);
+
+ // access the second tab's label -&gt; "tab-specific label"
+ console.log(button.state(tabs[1]).label);
+
+ // Reset the tab-specific state
+ button.state(tab, null);
+
+ // access the second tab's label -&gt; "window-specific label"
+ console.log(button.state(tabs[1]).label);
+}</pre>
+<p>Finally, you can pass the button itself into <code>state()</code>. This is an alternative way to set or get the global state. The reason for using this, rather than setting properties individually, is that you can define an object with the properties to set in one place, then apply it to the global state with a single line:</p>
+<pre class="brush: js">const defaultState = {
+  "label": "default label",
+  "icon": "./default.png",
+}
+
+const differentState = {
+  "label": "different label",
+  "icon": "./different.png",
+}
+
+var { ActionButton } = require("sdk/ui/button/action");
+
+var button = ActionButton({
+    id: "default-label",
+    label: "default label",
+    icon: "./default.png",
+    onClick: function(state) {
+      if (button.label == "default label") {
+        button.state(button, differentState);
+      }
+      else {
+        button.state(button, defaultState);
+      }
+      console.log(button.state(button).label);
+      console.log(button.state(button).icon);
+    }
+  });
+</pre>
+<h5 id="Parameters_2">Parameters</h5>
+<p><strong>target : button, tab, window, string</strong></p>
+<ul>
+ <li>To set or get the global state, this needs to be the <code>button</code> instance.</li>
+ <li>To get or set window-specific state, this needs to be the <a href="/en-US/Add-ons/SDK/High-Level_APIs/windows"><code>window</code></a> object for which you wish to set a specific state, or the string "window" to select the currently active window.</li>
+ <li>To get or set tab-specific state this needs to be the <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs"><code>tab</code></a> object for which you wish to set a specific state, or the string "tab" to select the currently active tab.</li>
+</ul>
+<p><strong>state : object, null</strong><br>
+ Include this parameter only if you are setting state. It is an object containing all the properties you wish to set. For example:</p>
+<pre class="brush: js">button.state("tab", {
+ "label" : "tab-specific label",
+ "icon": "./tab-specific-icon.ico"
+});</pre>
+<p>To reset state, pass null:</p>
+<pre class="brush: js">button.state("tab", null);</pre>
+<h5 id="Returns">Returns</h5>
+<p><strong>state</strong> : if you have passed the second <code>state</code> argument to make this function a setter, it returns <code>undefined</code>. Otherwise, it functions as a getter and returns the button's state for the specified object. This logs the state for the button associated with the currently active tab:</p>
+<pre class="brush: js">console.log(button.state("tab"));</pre>
+<p>This object represents a snapshot of the state at the time <code>state()</code> is called. It is not kept up to date with changes made to the button:</p>
+<pre class="brush: js">button.label = "foo";
+var state = button.state(button);
+button.label = "bar";
+console.log(state.label) // foo</pre>
+<h4 class="addon-sdk-api-name" id="on()"><code>on()</code></h4>
+<p>Add a listener to an event emitted by the button. The button only emits one type of event, <code><a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#click">click</a></code>:</p>
+<pre class="brush: js">button.on("click", handleClick)
+
+function handleClick(state) {
+ console.log("button '" + state.label + "' was clicked");
+}</pre>
+<h5 id="Parameters_3">Parameters</h5>
+<p><strong>event : string</strong><br>
+ The event to listen for. Action buttons only emit one type of event, "<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#click"><code>click</code></a>".</p>
+<p><strong>listener : function</strong><br>
+ Function that will be called on click.</p>
+<h4 class="addon-sdk-api-name" id="once()"><code>once()</code></h4>
+<p>Assign a listener to the first occurrence only of an event emitted by the button. The button only emits one type of event, <code><a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#click">click</a></code>. The listener is automatically removed after the first time the event is emitted.</p>
+<h5 id="Parameters_4">Parameters</h5>
+<p><strong>event : string</strong><br>
+ The event to listen for. Action buttons only emit one type of event, "<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#click"><code>click</code></a>".</p>
+<p><strong>listener : function</strong><br>
+ Function that will be called on click.</p>
+<h4 class="addon-sdk-api-name" id="removeListener()"><code>removeListener()</code></h4>
+<p>Removes an event listener. For example, this code is equivalent to <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#once()"><code>once()</code></a>:</p>
+<pre class="brush: js">button.on("click", handleClick)
+
+function handleClick(state) {
+ console.log("button '" + state.label + "' was clicked");
+ button.removeListener("click", handleClick);
+} </pre>
+<h5 id="Parameters_5">Parameters</h5>
+<p><strong>event : string</strong><br>
+ The event to listener is listening for. Action buttons only emit one type of event, "<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#click"><code>click</code></a>".</p>
+<p><strong>listener : function</strong><br>
+ The listener to remove.</p>
+<h4 class="addon-sdk-api-name" id="destroy()"><code>destroy()</code></h4>
+<p>Destroy the button. After calling this function, the button will no longer appear in the UI, and accessing any of its properties or methods will throw an error.</p>
+<h3 id="Properties">Properties</h3>
+<h4 class="addon-sdk-api-name" id="id"><code>id</code></h4>
+<p>The button's unique ID. This is read-only.</p>
+<h4 class="addon-sdk-api-name" id="label"><code>label</code></h4>
+<p>The button's label.</p>
+<h4 class="addon-sdk-api-name" id="icon"><code>icon</code></h4>
+<p>The button's icon or icons, as a URL, relative path, or object containing a set of key-value pairs.</p>
+<h4 class="addon-sdk-api-name" id="disabled"><code>disabled</code></h4>
+<p>Boolean property indicating whether or not the button is disabled.</p>
+<h4 class="addon-sdk-api-name" id="badge"><code>badge</code></h4>
+<div class="geckoVersionNote">
+ <p>New in Firefox 36.</p>
+</div>
+<p>Value to attach to the button as a <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#Badged_buttons">badge</a>. May be a number or a string.</p>
+<h4 class="addon-sdk-api-name" id="badgeColor"><code>badgeColor</code></h4>
+<div class="geckoVersionNote">
+ <p>New in Firefox 36.</p>
+</div>
+<p>Color for the <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#Badged_buttons">badge</a>, specified as a CSS <a href="/en-US/docs/Web/CSS/color_value">&lt;color&gt;</a> value.</p>
+<h3 id="Events">Events</h3>
+<h4 class="addon-sdk-api-name" id="click"><code>click</code></h4>
+<p>This event is emitted when a user clicks the button or your add-on calls the button's <code>click()</code> method.</p>
+<h5 id="Arguments">Arguments</h5>
+<p><strong>state</strong> : The button's state. This contains all the button's <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#Properties">properties</a>.</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tools/index.html b/files/zh-cn/mozilla/add-ons/sdk/tools/index.html
new file mode 100644
index 0000000000..8c67b4644e
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tools/index.html
@@ -0,0 +1,14 @@
+---
+title: Tools
+slug: Mozilla/Add-ons/SDK/Tools
+tags:
+ - Add-on SDK
+ - CFX
+ - JPM
+ - NeedsTranslation
+ - TopicStub
+translation_of: Archive/Add-ons/Add-on_SDK/Tools
+---
+<p>Articles listed here provide a reference for the SDK's tools:</p>
+
+<p>{{ LandingPageListSubpages ("/en-US/Add-ons/SDK/Tools", 7) }}</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tools/jpm/index.html b/files/zh-cn/mozilla/add-ons/sdk/tools/jpm/index.html
new file mode 100644
index 0000000000..db429ef078
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tools/jpm/index.html
@@ -0,0 +1,652 @@
+---
+title: jpm
+slug: Mozilla/Add-ons/SDK/Tools/jpm
+tags:
+ - Add-on SDK
+ - JPM
+translation_of: Archive/Add-ons/Add-on_SDK/Tools/jpm
+---
+<p>{{AddonSidebar}}</p>
+
+<div class="note">
+<p>你能在Firefox 38或更高的版本中使用jpm。</p>
+
+<p>本文为jpm参考。</p>
+</div>
+
+<p><span class="seoSummary"><a href="/en-US/Add-ons/SDK/Tools/cfx">cfx</a> 的Node版本允许你测试、运行以及打包扩展。</span></p>
+
+<p>你也可以阅读 <a href="/en-US/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29">jpm教程</a> 开始学习。</p>
+
+<p>jpm 用法:</p>
+
+<pre class="brush: bash">jpm [command] [options]
+</pre>
+
+<p>jpm支持以下全局参数:</p>
+
+<pre class="brush: bash">-h, --help - 显示帮助信息并退出
+-V, --version - 打印出jpm版本号
+--addon-dir - 源代码目录,默认为当前目录
+</pre>
+
+<h2 id="安装">安装</h2>
+
+<p>jpm发布在node包管理器 <a class="external external-icon" href="https://www.npmjs.org/package/jpm">npm</a> 上。</p>
+
+<h3 id="安装npm">安装npm</h3>
+
+<p>有两种方法来获取npm。</p>
+
+<ul>
+ <li>访问 <a href="http://nodejs.org/">nodejs.org</a> 下载并安装Node.js。Node.js 包含npm。</li>
+ <li>或者,如果你的系统有像 APT 这种包管理器,就用它来安装。例如,在 Ubuntu 或者 Debian 的终端窗口里,输入<code>sudo apt-get install nodejs nodejs-legacy npm</code></li>
+</ul>
+
+<p>要测试安装是否成功,运行:</p>
+
+<pre class="brush: bash">​/usr/bin/env node -v</pre>
+
+<p>如果出现错误提示  <em>/usr/bin/env: node: No such file or directory</em> 并且你的 nodejs 是通过包管理的方式安装的,那你的 nodejs 很有可能安装为其它的名字。为了保证jpm的兼容,PATH之中必须是以node为可执行文件名的。在Debian和Ubuntu系统上,你可以通过安装兼容包nodejs-legacy来解决这个问题:</p>
+
+<pre class="brush: bash"><code>sudo apt-get install nodejs-legacy</code></pre>
+
+<p><font face="Consolas, Liberation Mono, Courier, monospace">在其它的发行版中,你或许必须手动创建一共本地符号链接:​</font></p>
+
+<pre><code>sudo ln -s "$(which nodejs)" /usr/local/bin/node</code></pre>
+
+<h3 id="安装jpm"><code>安装jpm</code></h3>
+
+<p>在你安装好npm并且将其加入你的PATH中后,你可以像安装其他npm包一样来安装jpm。</p>
+
+<h4 id="全局安装jpm">全局安装jpm</h4>
+
+<pre><code>npm install jpm --global</code></pre>
+
+<p>取决于你的安装,你可能需要管理员权限执行:</p>
+
+<pre class="brush: bash"><code>sudo npm install jpm --global</code></pre>
+
+<h4 id="局部安装jpm"><code>局部安装jpm</code></h4>
+
+<p><code>如果你不想,或者不能够全局安装jpm,你或许可以只为你安装它:</code></p>
+
+<pre><code>npm install jpm</code></pre>
+
+<p><code>在局部安装的情况下,为了在终端中运行jpm,你必须首先将目录</code>"$HOME/node_modules/.bin/"添加到你的终端PATH中。将下行中的命令添加到$HOME/.profile的末尾来实现永久添加(.profile将在每次运行一个新终端时被执行):</p>
+
+<pre><code>export PATH="$HOME/node_modules/.bin/:$PATH"</code></pre>
+
+<h4 id="通过git来安装jpm">通过git来安装jpm</h4>
+
+<p>另外,你也可以通过git安装jpm的最新版本</p>
+
+<pre>git clone https://github.com/mozilla-jetpack/jpm.git
+cd jpm
+npm install
+npm link
+</pre>
+
+<h3 id="jpm安装完毕后">jpm安装完毕后</h3>
+
+<p><span style="line-height: 1.5;">在全部搞定后,在命令行窗口中输入:</span></p>
+
+<pre class="brush: bash"><code>jpm</code></pre>
+
+<p>屏幕上显示了一系列可用的 jpm 命令。不同于 cfx,当在安装时使用了 --global 参数,你能在任何路径下启动的命令提示符中使用 jpm 命令。</p>
+
+<h3 id="还有问题?">还有问题?</h3>
+
+<p>如果你看不懂本文,要寻求帮助。SDK 用户和项目团队成员在<a class="external external-icon" href="http://groups.google.com/group/mozilla-labs-jetpack/topics">项目邮件列表</a>中讨论问题和建议。其他人也许会和你有一样的问题,所以试着搜索一下列表。也欢迎你发表一个新问题。你也可以在 <a class="external external-icon" href="http://irc.mozilla.org/">Mozilla 的 IRC 网络</a> 的 <a class="external external-icon" href="http://mibbit.com/?channel=%23jetpack&amp;server=irc.mozilla.org">#jetpack</a> 房间里和其他SDK的用户聊天。</p>
+
+<h2 id="命令参考">命令参考</h2>
+
+<p>有六个命令:</p>
+
+<table>
+ <tbody>
+ <tr>
+ <td><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#jpm_init"><code>jpm init</code></a></td>
+ <td>创建一个基本的 add-on 作为你 add-on 的开端。</td>
+ </tr>
+ <tr>
+ <td><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#jpm_run"><code>jpm run</code></a></td>
+ <td>运行一个带有你的 add-on 的 Firefox 实例。</td>
+ </tr>
+ <tr>
+ <td><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#jpm_test"><code>jpm test</code></a></td>
+ <td>运行你插件的单元测试</td>
+ </tr>
+ <tr>
+ <td><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#jpm_xpi"><code>jpm xpi</code></a></td>
+ <td>将你的插件打包为 <a href="https://developer.mozilla.org/zh-CN/docs/XPI">XPI</a> 文件(火狐的插件扩展文件名)</td>
+ </tr>
+ <tr>
+ <td><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#jpm_post"><code>jpm post</code></a></td>
+ <td>把你的 add-on 打包成 <a href="https://developer.mozilla.org/zh-CN/docs/XPI">XPI</a> 文件,然后发送到某一个URL。</td>
+ </tr>
+ <tr>
+ <td><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#jpm_watchpost"><code>jpm watchpost</code></a></td>
+ <td>无论是否有文件变更,把你的 add-on 打包成 <a href="https://developer.mozilla.org/zh-CN/docs/XPI">XPI</a> 文件发送到某一个URL。</td>
+ </tr>
+ <tr>
+ <td><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#jpm_sign"><code>jpm sign</code></a></td>
+ <td>将你的插件打包为 <a href="https://developer.mozilla.org/zh-CN/docs/XPI">XPI</a> 文件并且取回一个由Mozilla签名的新XPI文件。</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="jpm_init">jpm init</h3>
+
+<p>这个命令从头开始初始化一个新的 add-on。</p>
+
+<p>新建一个目录,转到该目录下,然后运行 <code>jpm init</code>。</p>
+
+<pre><code>mkdir my-addon
+cd my-addon
+jpm init</code></pre>
+
+<p>然后你会被要求提供关于你的 add-on 的一些信息:这会用来创建 <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json">package.json</a> 文件。</p>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#title">title</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#name">name</a>: 默认是你运行 <code>jpm init 的目录名。除非</code>package.json里有 <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#id"><code>id</code></a> 字段, jpm 在name前面加个<code>"@"</code>用作 <a href="https://developer.mozilla.org/en-US/Add-ons/Install_Manifests#id">add-on 安装清单的 <code>id</code> 字段</a>.</li>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#version">version</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#description">description</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#main">entry point</a> (映射向package.json中的 "main")</li>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#author">author</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#engines">engines</a> (支持哪些应用程序)</li>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#license">license</a></li>
+</ul>
+
+<p>大部分字段都有一个默认值,显示在那些问题的后面的括号里。如果你按了回车,那么你的 add-on 就用那个默认值。</p>
+
+<p>一旦你提供了一个值或者接受了默认值,你会看到"package.json"的完整内容,并被询问是否接受。</p>
+
+<p>然后 jpm 创建一个基本的 add-on,作为你开发的起点,文件结构如下:</p>
+
+<ul>
+ <li>my-addon
+ <ul>
+ <li>index.js</li>
+ <li>package.json</li>
+ <li>test
+ <ul>
+ <li>test-index.js</li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+</ul>
+
+<h3 id="jpm_run">jpm run</h3>
+
+<p>此命令运行一个新的装有你的 add-on 的 Firefox实例:</p>
+
+<pre><code>jpm run</code></pre>
+
+<p><code>jpm run</code> 有以下选项:</p>
+
+<table>
+ <tbody>
+ <tr>
+ <td><code>-b --binary BINARY</code></td>
+ <td>
+ <p>指定二进制文件,使用该版本的火狐。可以用全路径,也可以用相对路径。</p>
+
+ <pre>
+<code>jpm run -b /path/to/Firefox/Nightly</code></pre>
+ 参看<a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#Selecting_a_browser_version">选择浏览器版本</a>。</td>
+ </tr>
+ <tr>
+ <td><code>--binary-args CMDARGS</code></td>
+ <td>
+ <p>传递<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options">附件参数</a>到 Firefox。</p>
+
+ <p>例如,为了传递 <code>-jsconsole</code>参数给 Firefox 并打开<a href="https://developer.mozilla.org/en-US/docs/Tools/Browser_Console">浏览器</a>,试试下面命令:</p>
+
+ <pre>
+<code>jpm run --binary-args -jsconsole</code></pre>
+
+ <p>要传递多个参数,或者参数中间有空格,就把他们用引号括起来:</p>
+
+ <pre>
+<code>jpm run --binary-args '-url mzl.la -jsconsole'</code></pre>
+ </td>
+ </tr>
+ <tr>
+ <td><code>--debug</code></td>
+ <td>运行这个 add-on 的<a href="https://developer.mozilla.org/en-US/Add-ons/Add-on_Debugger">Add-on 调试器</a>。</td>
+ </tr>
+ <tr>
+ <td><code>-o --overload PATH</code></td>
+ <td>
+ <p>不再使用 Firefox 内建的 SDK 模块,使用指定 PATH 路径下的模块。如果加了 <code>-o</code> 但 PATH 没有指定,jpm 会寻找 JETPACK_ROOT 环境变量用作路径</p>
+
+ <p>参看<a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#Overloading_the_built-in_modules">重载内建模块</a>以获取更多信息</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>-p --profile=<code> PROFILE</code></code></td>
+ <td>
+ <p>在你每次调用jpm run时,jpm 默认使用一个干净的临时的 Firefox <a href="http://support.mozilla.com/en-US/kb/profiles">配置文件(profile)</a>。使用<code>--profile</code> 选项以使得 jpm 使用已有的配置文件来打开 Firefox。</p>
+
+ <p>PROFILE的值可以是一个profile的名字或路径。</p>
+
+ <p>参看 <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#Using_profiles">使用 profile</a> 以获取更多信息。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>-v --verbose</code></td>
+ <td>(查看)详细操作</td>
+ </tr>
+ <tr>
+ <td><code>--no-copy</code></td>
+ <td>
+ <div class="warning">小心使用,因为 <code>jpm run|test</code> 会改变很多配置,不要和你的主配置文件一起使用。</div>
+
+ <div class="note">只有使用 <code>--profile</code> 的时候回生效</div>
+ 禁止配置文件的拷贝,允许重用配置。</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="jpm_test">jpm test</h3>
+
+<p>这个命令用来运行 add-on 的单元测试。命令:</p>
+
+<ul>
+ <li>查找在当前目录(或者 <code>--addon-dir</code> 目录)下的test文件夹。</li>
+ <li>打开所有名字以 "test-" 开头的文件。注意文件名中"test"后面的连字符号。<code>jpm test</code> 包含一个 "test-myCode.js" 文件,但会排除"test_myCode.js"或"test_myCode.js"。</li>
+ <li>调用文件中所有export的、以"test"开头的函数。</li>
+</ul>
+
+<pre><code>jpm test</code></pre>
+
+<p>查看 <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Unit_testing">单元测试教程</a> 和 <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/test_assert"> <code>assert</code> 模块参考文档</a>获取更多具体内容。</p>
+
+<p><code>jpm test</code> 接受一下选项:</p>
+
+<table>
+ <tbody>
+ <tr>
+ <td><code>-b --binary BINARY</code></td>
+ <td>
+ <p>指定所用 Firefox 的版本。BINARY 可被指定为绝对路径或者基于当前路径的相对路径。</p>
+
+ <pre>
+<code>jpm test -b /path/to/Firefox/Nightly</code></pre>
+
+ <p>请查看<a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#Selecting_a_browser_version">选择一个浏览器版本</a>。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>--binary-args CMDARGS</code></td>
+ <td>
+ <p>传递<a href="http://kb.mozillazine.org/Command_line_arguments">附件参数</a>给 Firefox。</p>
+
+ <p>例如,传递 <code>-jsconsole</code> 参数,它会打开<a href="https://developer.mozilla.org/en-US/docs/Tools/Browser_Console">浏览器控制台</a>,试试下面的命令:</p>
+
+ <pre>
+<code>jpm test --binary-args -jsconsole</code></pre>
+
+ <p>传递多个参数,或者参数间有空格,请将它们用引号括起来:</p>
+
+ <pre>
+<code>jpm test --binary-args '-url mzl.la -jsconsole'</code></pre>
+ </td>
+ </tr>
+ <tr>
+ <td><code>--debug</code></td>
+ <td>运行 <a href="https://developer.mozilla.org/en-US/Add-ons/Add-on_Debugger">add-on debugger</a> 附件到当前 add-on 上。</td>
+ </tr>
+ <tr>
+ <td><code>-f --filter FILE[:TEST]</code></td>
+ <td>
+ <p>只运行名字和 FILE 匹配的测试文件,且名字匹配 TEST(可选)的测试函数。</p>
+
+ <pre>
+<code>jpm test --filter base64:btoa</code></pre>
+
+ <p>上面的命令值会运行名字中含有"base64"的文件,在这些文件中只会运行名字中含有"btoa"的测试函数。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>-o --overload PATH</code></td>
+ <td>
+ <p>不使用 Firefox 内建的模块,而使用 PATH 路径下的模块。如果 <code>-o</code> 指定而 PATH 被忽略,jpm会查找 JETPACK_ROOT 环境变量并将其用作路径。</p>
+
+ <p>查看<a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#Overloading_the_built-in_modules">重载内建模块</a>以获取更多信息。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>-p --profile<code> PROFILE</code></code></td>
+ <td>
+ <p>你每次运行jpm call时,默认地,jpm使用一个干净的临时 Firefox <a href="http://support.mozilla.com/en-US/kb/profiles">配置文件</a>。使用<code>--profile</code> 选项来让 jpm 使用一个现有配置文件来打开火狐。</p>
+
+ <p>PROFILE 的值可以是配置文件的名称或者指向配置文件的路径。</p>
+
+ <p>查看<a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#Using_profiles">使用配置文件</a>来获取更多信息。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>--stop-on-error</code></td>
+ <td>
+ <p>即使测试失败,jpm test 默认还会继续运行测试。指定 <code>--stop-on-error</code> 的话,会在第一次失败后停止运行测试</p>
+
+ <pre>
+<code>jpm test --stop-on-error</code></pre>
+ </td>
+ </tr>
+ <tr>
+ <td><code>--tbpl</code></td>
+ <td>用<a href="https://treeherder.mozilla.org/">Treeherder</a> 格式打印 test 的输出</td>
+ </tr>
+ <tr>
+ <td><code>--times NUMBER</code></td>
+ <td>
+ <p>运行几遍 test:</p>
+
+ <pre>
+<code>jpm test --times 2</code></pre>
+ </td>
+ </tr>
+ <tr>
+ <td><code>-v --verbose</code></td>
+ <td>详细操作。</td>
+ </tr>
+ <tr>
+ <td><code>--no-copy</code></td>
+ <td>
+ <p>小心使用,因为 <code>jpm run|test</code> 会修改许多首选项,这些首选项在你的主配置文件中从未用过。</p>
+
+ <p>这仅仅在使用 <code>--profile</code> 时生效。</p>
+ 禁用配置未经的拷贝,允许用户重用配置文件。</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="jpm_xpi">jpm xpi</h3>
+
+<p>这个命令将 add-on 打包为一个 <a href="https://developer.mozilla.org/en/XPI">XPI</a> 文件,这是 Mozilla 附加组件的安装文件的格式。</p>
+
+<pre><code>jpm xpi</code></pre>
+
+<p>它会在当前目录(或者 <code>--addon-dir</code> 指定的目录)查找 <code>package.json</code> 文件,并创建相关的 XPI 文件。它忽略任何 ZIP 或 XPI文件(译者注:OSX 上测试下来不会默认忽略这些文件,若要忽略请编辑.jpmignore文件),以及任何测试文件。它会包含其他所有文件。如果你想排除其他文件,查看 <a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/SDK/Tools/en-US/Add-ons/SDK/Tools/jpmignore">.jpmignore 文件</a>。</p>
+
+<p>一旦你构建了一个 XPI 文件,你可以通过提交到 <a href="http://addons.mozilla.org/">addons.mozilla.org</a> 来分发你的附加组件。</p>
+
+<p><code>jpm xpi</code> 接受下列选项:</p>
+
+<table>
+ <tbody>
+ <tr>
+ <td><code>-v --verbose</code></td>
+ <td>
+ <p>打印详细操作:</p>
+
+ <pre>
+<code>jpm xpi -v</code></pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="jpm_post">jpm post</h3>
+
+<p>这个命令把附加组件打包为 <a href="https://developer.mozilla.org/en/XPI">XPI</a> 后 post 到某个URL。</p>
+
+<pre><code>jpm post</code></pre>
+
+<p>查找当前目录(或 <code>--addon-dir</code>)下的<code>package.json</code> 文件,创建 XPI 文件,post 到 <code>--post-url</code>。</p>
+
+<p><code>jpm post</code> 接受以下选项:</p>
+
+<table>
+ <tbody>
+ <tr>
+ <td><code>--post-url URL</code></td>
+ <td>
+ <p>创建 XPI 文件后,将扩展 post 到这个URL。</p>
+
+ <pre>
+<code>jpm post --post-url http://localhost:8888/</code></pre>
+
+ <p>查看<a href="https://www.npmjs.com/package/jpm#using-post-and-watchpost">使用 Post 和 Watchpost</a> 获取更多信息。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>-v --verbose</code></td>
+ <td>
+ <p>打印详细操作:</p>
+
+ <pre>
+<code>jpm post --post-url http://localhost:8888/ -v</code></pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="jpm_watchpost">jpm watchpost</h3>
+
+<p>这个命令在打包附件组件为 <a href="https://developer.mozilla.org/en/XPI">XPI</a> 文件后,无论文件是否改变都将其 post 到某个URL。</p>
+
+<pre><code>jpm watchpost</code></pre>
+
+<p>无论文件是否改变,在当前目录(或 <code>--addon-dir</code>)下创建一个 XPI并将其post到 <code>--post-url</code>。</p>
+
+<p><code>jpm watchpost</code> 接受以下选项:</p>
+
+<table>
+ <tbody>
+ <tr>
+ <td><code>--post-url URL</code></td>
+ <td>
+ <p>创建 XPI 文件后,将扩展 post 到这个URL。</p>
+
+ <pre>
+<code>jpm watchpost --post-url http://localhost:8888/</code></pre>
+
+ <p>查看 <a href="https://www.npmjs.com/package/jpm#using-post-and-watchpost">Using Post 和 Watchpost</a> 获取更多信息。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>-v --verbose</code></td>
+ <td>
+ <p>打印详细信息:</p>
+
+ <pre>
+<code>jpm watchpost --post-url http://localhost:8888/ -v</code></pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="jpm_sign">jpm sign</h3>
+
+<p>此特性仅从 jpm 1.0.4 起被支持。</p>
+
+<p>此命令为你的附加组件重新生成一个新的被Mozilla签名的 <a href="https://developer.mozilla.org/en-US/docs/XPI">XPI</a> 文件。这就允许你<a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#Supporting_updates_for_self-hosted_add-ons">自己托管你的 add-on</a>,这样用户可以在安装时避免 <a href="https://wiki.mozilla.org/Add-ons/Extension_Signing">signed add-ons are required</a> 错误。在用这个命令之前,你需要<a href="https://addons.mozilla.org/en-US/developers/addon/api/key/">在 addons.mozilla.org 创建 API 证书</a>。</p>
+
+<p>你可以为你已经生成的 XPI 文件签名,就像如下,通过传递 XPI 文件给 <code>--xpi</code>参数:</p>
+
+<pre id="comment_text_2"><code>jpm sign --api-key ${AMO_API_KEY} --api-secret ${AMO_API_SECRET} --xpi &lt;xpi file&gt;</code></pre>
+
+<p>或者,你可以省略 <code>--xpi</code> 参数,这样 <code>jpm sign</code> 会从当前目录(或者 <code>--addon-dir</code>)生成一个XPI文件。</p>
+
+<pre><code>jpm sign --api-key ${AMO_API_KEY} --api-secret ${AMO_API_SECRET}</code></pre>
+
+<p>上面提交了一个 <a href="https://developer.mozilla.org/en-US/docs/XPI/">XPI</a> 到 <a href="https://addons.mozilla.org/">addons.mozilla.org</a> <a href="http://olympia.readthedocs.org/en/latest/topics/api/signing.html">签名g API</a>,如果通过验证,然后下载一个签名后的 XPI 文件到工作目录。</p>
+
+<p>下面是一些运行 <code>sign</code> 命令的结果:</p>
+
+<ul>
+ <li>你的 add-on 通过验证,被 Mozilla 签名,并且一个新的签名后的 <a href="https://developer.mozilla.org/en-US/docs/XPI">XPI</a> 文件被下载到你的工作目录。</li>
+ <li>你的 add-on 没有通过验证,没有签名,你获取到一个详细报告的链接。修复验证错误以后,你可以再次运行这个命令。</li>
+ <li>你的 add-on 公公验证,但是它不能自动签名,因为你的 add-on 是<a href="https://developer.mozilla.org/en-US/Add-ons/Distribution">列表上的</a>。列表上的 add-ons 需要人工复核才能被签名。</li>
+ <li>你的 add-on 已经存在某个版本号了,所以它没有被签名。增加 <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json">package.json</a> 文件中的版本号并且再次运行命令。</li>
+</ul>
+
+<p>在底层,<code>jpm sign</code> 在<a href="https://addons.mozilla.org/">addons.mozilla.org</a>里创建了一个不会被列出的附加组件,这就意味着你必须自己把XPI文件分发给你的用户来安装。如果你需要创建一个在列表中的附加组件,只要<a href="https://addons.mozilla.org/en-US/developers/addon/submit/2">直接将它提交到 addons.mozilla.org</a>,在那里它自动会被签名。如果你在安装一个已签名的附加组件时遇到困难,参看<a href="https://developer.mozilla.org/en-US/docs/Extension_Versioning%2C_Update_and_Compatibility#Debugging_and_solving_problems">调试</a>一节。</p>
+
+<p><code>jpm sign</code> 接收以下参数:</p>
+
+<table>
+ <tbody>
+ <tr>
+ <td><code>--api-key=API_KEY</code></td>
+ <td>
+ <p><a href="https://addons.mozilla.org/en-US/developers/addon/api/key/">addons.mozilla.org key管理页面</a>生成的API访问key(字符串)。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>--api-secret=API_SECRET</code></td>
+ <td>
+ <p><a href="https://addons.mozilla.org/en-US/developers/addon/api/key/">addons.mozilla.org key 管理页面</a>生成的API访问密钥(字符串)。这个值应该被小心保密并且永远不要记录到版本控制中。如果你的密钥被破解,另一个开发者就能上传附加组件到你的账号上。你应该立即撤销泄露的API证书并且重新生成一份。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>--api-url-prefix=http://.../api</code></td>
+ <td>
+ <p>可选的API URL前缀,如果你想使用一个试用签名的API。</p>
+
+ <p>例如,你可以通过<code>https://addons-dev.allizom.org/api/v3</code>的认证来使用<a href="https://addons.mozilla.org/">addons.mozilla.org</a>的开发者版本。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>--xpi=/path/to/file.xpi</code></td>
+ <td>
+ <p>需要签名的<a href="https://developer.mozilla.org/en-US/docs/XPI">XPI</a>文件。如果没指定文件,一个新的XPI会在当前目录(或者<code>--addon-dir</code>)中生成。</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="一些技巧">一些技巧</h2>
+
+<h3 id="选择浏览器版本">选择浏览器版本</h3>
+
+<p>默认地,<code>jpm run</code> 和 <code>jpm test</code> 运行 release 版本的 FireFox。你可以有一两种办法来告诉 jpm 使用一个不同的版本:</p>
+
+<ul>
+ <li>
+ <p>你可以使用 <code>-b</code> 或者 <code>--binary</code> 选项来告诉 jpm 去使用一个不同版本的 Firefox。你可以提供一个指定二进制文件的路径:</p>
+
+ <pre><code>jpm run -b /path/to/Firefox/Nightly</code></pre>
+
+ <p>有个简化的方法,你可以传递"nightly"、"aurora"、"beta"或者"firefox"然后jpm会在默认位置寻找这些 Firefox 的版本:</p>
+
+ <pre><code>jpm run -b nightly</code></pre>
+ </li>
+ <li>
+ <p>你可以设置 <code>JPM_FIREFOX_BINARY</code> 环境变量为你想运行的 Firefox 版本的路径。在你调用 <code>jpm run</code> 或 <code>jpm test</code> 而不带 <code>-b</code> 选项时,jpm 首先检查 <code>JPM_FIREFOX_BINARY</code>,并且将其当做已设置的路径来用。</p>
+ </li>
+</ul>
+
+<h3 id="使用_.jpmignore_来忽略文件">使用 <code>.jpmignore</code> 来忽略文件</h3>
+
+<p>使用 <code>.jpmignore</code> 就像使用 <code>git</code> 的<code>.gitignore</code>,Mercurial 的 <code>.hgignore</code>,或者 npm 的 <code>.npmignore</code>。通过使用这个文件,你可以在使用 <code>jpm xpi</code> 编译 <code>.xpi</code> 文件时,让 <code>jpm</code> 知道你想要忽略哪些文件。</p>
+
+<p>这是个例子:</p>
+
+<pre><code># Ignore .DS_Store files created by mac
+.DS_Store
+
+# Ignore any zip or xpi files
+*.zip
+*.xpi</code></pre>
+
+<p>有着以上内容的 <code>.jpmignore</code> 文件会忽略所有的 zip 文件和 <code>.DS_Store</code> 文件,这些文件不会包括在 <code>jpm xpi</code> 所生成的 xpi 文件中。</p>
+
+<h3 id="使用配置"><a name="Using_profiles">使用配置</a></h3>
+
+<p>默认地,<code>jpm run</code> 每次都会使用一个新的配置。这就意味着前一次运行 <code>jpm</code> 时的任何配置,默认都不会在下一次中使用。</p>
+
+<p>这其中包括,比如你安装的任何附加组件,或者你的历史记录,或者任何使用 <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/simple-storage">simple-storage</a> API 存储的数据。</p>
+
+<p>为了让 <code>jpm</code> 使用一个特定的配置,传递 <code>--profile</code> 选项,设定你想使用的配置文件的名字,或者是配置文件的路径。</p>
+
+<pre><code>jpm run --profile boogaloo</code></pre>
+
+<pre><code>jpm run --profile path/to/boogaloo</code></pre>
+
+<p>如果你提供了 <code>--profile</code> 但是它的参数不是一个已有配置文件的名字或路径,jpm 会打开 <a href="https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles">配置文件管理器</a> 让你选择一个已有的配置文件或者创建一个新的配置文件:</p>
+
+<pre><code>jpm run --profile i-dont-exist</code></pre>
+
+<h3 id="开发时不用重启浏览器">开发时不用重启浏览器</h3>
+
+<p>因为每次调用 <code>jpm run</code> 时都会重启浏览,如果你十分频繁地修改附加组件,这就可能有点笨重了。一个替代的开发模型是使用 <a href="https://addons.mozilla.org/en-US/firefox/addon/autoinstaller/" rel="noreferrer">扩展自动安装器</a>附加组件:它会在特定端口监听新 XPI 文件并且自动安装它们。这样,你就能测试新的改动,而不用重启浏览器:</p>
+
+<ul>
+ <li>修改附件组件</li>
+ <li>运行 <code>jpm post --post-url http://localhost:8888/</code>,来创建 XPI 文件并提交。</li>
+</ul>
+
+<p>你甚至可以用一个简单的脚本来自动化这一工作流程。例如:</p>
+
+<pre><code>jpm watchpost --post-url http://localhost:8888/</code></pre>
+
+<p>注意,比起使用 <code>jpm run</code> 运行附加组件时的日志级别,你在使用这个方法时控制台定义的日志级别是不一样的。这意味着,如果你想看到 <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Logging" rel="noreferrer"><code>console.log()</code></a> 消息的输出,你必须微调一下配置。查看 <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/console#Logging_Levels" rel="noreferrer">logging levels</a> 文档以获取这方面的详细信息。</p>
+
+<h3 id="重载内建模块">重载内建模块</h3>
+
+<p>你用来实现你的附加组件的SDK模快是 Firefox 内建的。当你使用 <code>jpm run</code> 或 <code>jpm xpi</code> 来运行或者打包附加组件时,附加组件使用其所在的 Firefox 版本中的模块版本。</p>
+
+<p>作为附件组件开发者,这一般就是你想要的。但是如果你在开发 SDK 模块本身,这就不合适了。这时你需要:</p>
+
+<ul>
+ <li>获取你想要的 SDK 模块的本地拷贝:一般来说就是从 <a href="https://github.com/mozilla/addon-sdk" rel="noreferrer">GitHub 仓库</a>中检出SDK。</li>
+ <li>设置 <code>JETPACK_ROOT</code> 环境变量,指向你的本地拷贝</li>
+ <li>传递 <code>-o</code> 选项到 <code>jpm run</code> 或 <code>jpm xpi</code>:</li>
+</ul>
+
+<pre><code>jpm run -o</code></pre>
+
+<p>这会通知 jpm 去使用 SDK 模块的本地拷贝,而不是 Firefox 内部的模块。如果你不想设置 <code>JETPACK_ROOT</code> 环境变量,你可以使用 <code>-o</code> 传递SDK模块本地拷贝的位置:</p>
+
+<pre><code>jpm run -o "/path/to/addon-sdk/"</code></pre>
+
+<p>路径必须是一个绝对路径并且指向 SDK 的根目录(不是 addon-sdk/sdk 或 addon-sdk/sdk/lib)。</p>
+
+<h3 id="支持自托管附加组件的更新">支持自托管附加组件的更新</h3>
+
+<p>此特性仅被 jpm 1.0.3 及之后版本支持,</p>
+
+<p>当你给你的附加组件来添加特性或者修复 bug 时,你想让之前安装好的附加组件将自己从老版本更新到新版本。</p>
+
+<p>如果你在 <a href="https://addons.mozilla.org/">addons.mozilla.org</a> 上列出你的附加组件,那么你要做的只是提交一个新的版本;附加组件默认会检查它们在 <a href="https://addons.mozilla.org/">addons.mozilla.org</a> 上的新版本。好了,你不用继续往下看这一节了。</p>
+
+<p>如果你没有在 <a href="https://addons.mozilla.org/">addons.mozilla.org</a> 上列出你的附加组件,你需要生成一个 Mozilla 签名的 XPI 文件并告诉 Firefox 哪里可以找到这个附加组件的新版本。方法就是:</p>
+
+<ul>
+ <li>每次你想要创建一个新版本时,你运行 <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#jpm_sign">jpm sign</a></li>
+ <li>当你需要更新时,更新由你托管的签名好的附加组件</li>
+ <li>你维护一个“更新清单”,包含了指向那个 XPI 的URL</li>
+ <li>你的附加组件告诉 Firefox 哪里可以找到更新清单</li>
+</ul>
+
+<p>为了达到这个目的,package.json中需要包含两个额外的key :</p>
+
+<ul>
+ <li><code><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#updateURL">updateURL</a></code>:这个 URL 包含在 <code>jpm xpi</code> 所编译的 XPI 文件的<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/Install_Manifests">安装清单</a>中。他指向了你的更新清单。<code>updateURL</code> 值<em>可以</em>是HTTPS的。如果不是,那么你也可以签名的更新清单,并且使用 package.json 文件中的 <code><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#updateKey">updateKey</a></code> 字段来包含其公钥。参看 <a href="https://developer.mozilla.org/en-US/docs/Extension_Versioning%2C_Update_and_Compatibility#Securing_Updates">安全地更新</a> 以获取这方面更多信息</li>
+ <li><code><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#updateLink">updateLink</a></code>:这个 URL 包含在那个更新清单文件中。它指向了 XPI,并且<em>必须</em>是一个 HTTPS URL。</li>
+</ul>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/11847/addons-update.svg" title="[https://mdn.mozillademos.org]"></p>
+
+<p>如果你设置了 <code>updateURL</code> 和 <code>updateLink</code>(如果 <code>updateKey</code> 不是 HTTPS 的,那也要包括 <code>updateKey</code>),那么 <code>jpm xpi</code> 会:</p>
+
+<ul>
+ <li>生成 XPI 文件时将 <code>updateURL</code> 设置为你提供的值。</li>
+ <li>和 XPI 文件一起,生成更新清单,并将清单中的 <code>updateURL</code> 设置为你提供的值。</li>
+</ul>
+
+<p>然后你将更新清单托管到 <code>updateURL</code>,并且将新版 XPI 托管到 <code>updateLink</code>。</p>
+
+<p>获取更多这方面的详细信息,参看<a href="https://developer.mozilla.org/en-US/docs/Extension_Versioning,_Update_and_Compatibility#Automatic_Add-on_Update_Checking">自动检查附件组件更新</a>。</p>
+
+<div id="xunlei_com_thunder_helper_plugin_d462f475-c18e-46be-bd10-327458d045bd"> </div>
+
+<div id="xunlei_com_thunder_helper_plugin_d462f475-c18e-46be-bd10-327458d045bd"> </div>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tools/package_json/index.html b/files/zh-cn/mozilla/add-ons/sdk/tools/package_json/index.html
new file mode 100644
index 0000000000..cd08ff2b64
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tools/package_json/index.html
@@ -0,0 +1,312 @@
+---
+title: package.json
+slug: Mozilla/Add-ons/SDK/Tools/package_json
+translation_of: Archive/Add-ons/Add-on_SDK/Tools/package_json
+---
+<p>{{AddonSidebar}}</p>
+
+<p><span class="seoSummary">The <code>package.json</code> file contains manifest data for your add-on, providing not only descriptive information about the add-on for presentation in the Add-ons Manager, but other metadata required of add-ons.</span></p>
+
+<p>一些条目, 比如<a href="/en-US/Add-ons/SDK/Tools/package_json#icon"><code>icon</code></a>, <a href="/en-US/Add-ons/SDK/Tools/package_json#name"><code>name</code></a>和<a href="/en-US/Add-ons/SDK/Tools/package_json#description"><code>description</code></a>, 有类似<a href="https://developer.mozilla.org/en-US/docs/Install_Manifests">install manifest</a>的格式, 并且<code>package.json会写入</code>install manifest, 当使用<a href="/en-US/Add-ons/SDK/Tools/jpm#jpm_xpi"><code>jpm xpi</code></a><code>的时候.</code></p>
+
+<p>Others, such as <a href="/en-US/Add-ons/SDK/Tools/package_json#lib"><code>lib</code></a>, <a href="/en-US/Add-ons/SDK/Tools/package_json#permissions"><code>permissions</code></a>, and <a href="/en-US/Add-ons/SDK/Tools/package_json#preferences"><code>preferences</code></a>, represent instructions to the <a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a> tool itself to generate and include particular code and data structures in your add-on.</p>
+
+<p>其他如<a href="/en-US/Add-ons/SDK/Tools/package_json#lib"><code>lib</code></a>, <a href="/en-US/Add-ons/SDK/Tools/package_json#permissions"><code>permissions</code></a>和<a href="/en-US/Add-ons/SDK/Tools/package_json#preferences"><code>preferences</code></a>表示使用<a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a>工具的步骤, 生成你扩展包含的特殊代码和数据结构.</p>
+
+<h2 id="创建manifest">创建manifest</h2>
+
+<p><code>package.json起初是通过运行</code><a href="/en-US/Add-ons/SDK/Tools/jpm#jpm_init"><code>jpm init</code></a>生成的<code>,通常在扩展的根目录.比如下面(假设扩展目录是</code>"my-addon"<code>)</code></p>
+
+<pre class="brush: json">{
+ "name": "my-addon",
+ "title": "my-addon",
+  "id": "jid1-1FERGV45e4f4f",
+ "description": "a basic add-on",
+ "author": "",
+ "license": "MPL-2.0",
+ "version": "0.1"
+}</pre>
+
+<p>如果你使用新的<a href="/en-US/Add-ons/SDK/Tools/jpm">jpm tool</a>话,可以方便的从package.json获取manifest数据, 通过require其他模块的方式:</p>
+
+<pre class="brush: js" id="comment_text_1">var title = require("./package.json").title;</pre>
+
+<h2 id="Key_reference">Key reference</h2>
+
+<p><code>package.json</code> may contain the following keys:</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td id="author"><code>author</code></td>
+ <td>
+ <p>The name of the package's original author; this could be the name of a person or a company. Defaults to an empty string. It may include a optional URL in parentheses and an email address in angle brackets.</p>
+
+ <p>This value will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#creator"><code>em:creator</code></a> element in the <code>install.rdf</code> file generated by <code>cfx</code>.</p>
+
+ <div class="note"><strong>Note:</strong> <a href="https://developer.mozilla.org/Add-ons/SDK/Tools/jpm">jpm</a> supports <a href="https://docs.npmjs.com/files/package.json#people-fields-author-contributors">NodeJS people fields</a>.</div>
+ </td>
+ </tr>
+ <tr>
+ <td id="contributors"><code>contributors</code></td>
+ <td>
+ <p>An array of additional <a href="/en-US/Add-ons/SDK/Tools/package_json#author"><code>author</code></a> strings, identifying other contributors to the add-on.</p>
+
+ <p>These values will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#contributor"><code>em:contributor</code></a> elements in its <code>install.rdf</code>.</p>
+
+ <div class="note"><strong>Note:</strong> This is deprecated along with <code>cfx</code>; it's not available when using <a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a>.</div>
+ </td>
+ </tr>
+ <tr>
+ <td id="dependencies"><code>dependencies</code></td>
+ <td>
+ <p>A string or an array of strings specifying the names of packages that this add-on requires in order to function properly.</p>
+ </td>
+ </tr>
+ <tr>
+ <td id="description"><code>description</code></td>
+ <td>
+ <p>The add-on's description; this is a human-readable message describing what the add-on does. This defaults to the text "a basic add-on".</p>
+
+ <p>This value will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#description"><code>em:description</code></a> element in its <code>install.rdf</code>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td id="engines"><code>engines</code></td>
+ <td>
+ <p>Object with supported applications (key) and required version numbers (value).</p>
+
+ <ul>
+ <li><code>firefox</code>: Firefox Desktop</li>
+ <li><code>fennec</code>: Firefox for Android</li>
+ </ul>
+
+ <p>Example:</p>
+
+ <pre>
+<code> "engines": {
+ "firefox": "&gt;=38.0a1",
+ "fennec": "&gt;=38.0a1"
+ }</code></pre>
+ </td>
+ </tr>
+ <tr>
+ <td id="fullName"><code>fullName</code> {{deprecated_inline}}</td>
+ <td>
+ <div class="note"><strong>Note:</strong> This is deprecated along with <code>cfx</code>; it's not available when using <a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a>.</div>
+
+ <p>The full name of the package. It can contain spaces.</p>
+
+ <p>If this key is present its value will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#name"><code>em:name</code></a> element in its <code>install.rdf</code>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td id="harnessClassID"><code>harnessClassID</code> {{deprecated_inline}}</td>
+ <td>
+ <div class="note"><strong>Note:</strong> This is deprecated along with <code>cfx</code>; it's not available when using <a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a>.</div>
+
+ <p>String in the <a href="https://developer.mozilla.org/en-US/docs/Generating_GUIDs">GUID format</a>.</p>
+
+ <p>This is used as a <a href="https://developer.mozilla.org/en-US/docs/Creating_XPCOM_Components/An_Overview_of_XPCOM#CID"><code>classID</code></a> of the "harness service" XPCOM component. Defaults to a random GUID generated by <code>cfx</code>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td id="homepage"><code>homepage</code></td>
+ <td>
+ <p>The URL of the add-on's website.</p>
+
+ <p>This value will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#homepageURL"><code>em:homepageURL</code></a> element in its <code>install.rdf</code>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td id="icon"><code>icon</code></td>
+ <td>
+ <p>The path to an image file containing the icon for the add-on. Defaults to <code>icon.png</code>. If no icon is specified, the standard add-on icon will be used by default.</p>
+
+ <div class="warning">
+ <p>When using <a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a>, relative path to the data directory (to make it re-usable for add-on HTML content) does not currently work. Instead you have to use following syntax:</p>
+
+ <p>resource://ID/data/icon-name.png</p>
+
+ <p>ID is the value from the <code>id </code>field. If it does <strong>not</strong> begin with the <code>@</code>-character, then <code>@</code> has to be escaped as <code>-at-</code> and <code>.</code> as <code>-dot-</code>. If the ID is a GUID, the curly braces used in the <code>id</code> field are <strong>not</strong> included.</p>
+ </div>
+
+ <p>This value will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#iconURL"><code>em:iconURL</code></a> element in its <code>install.rdf</code>.</p>
+
+ <p>The icon may be up to 48x48 pixels in size (although a bigger icon is tolerated here too)</p>
+ </td>
+ </tr>
+ <tr>
+ <td id="icon64"><code>icon64</code> {{deprecated_inline}}</td>
+ <td>
+ <div class="note">
+ <p><strong>Note:</strong> This is deprecated along with <code>cfx</code>; it's not available when using <a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a>.</p>
+ </div>
+
+ <p><span style="background-color: rgba(212, 221, 228, 0.14902);">The path to an image</span> containing the large icon for the add-on. Defaults to <code>icon64.png</code>. If you don't provide an icon here, the same icon as specified by <code>icon</code> will be used.</p>
+
+ <p>This value will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#icon64URL"><code>em:icon64URL</code></a> element in its <code>install.rdf</code>.</p>
+
+ <p>The icon may be up to 64x64 pixels in size.</p>
+ </td>
+ </tr>
+ <tr>
+ <td id="id"><code>id</code></td>
+ <td>
+ <p>A globally unique identifier for the add-on.</p>
+
+ <p>This value will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#id"><code>em:id</code></a> element in its <code>install.rdf</code>.</p>
+
+ <p>See the <a href="/en-US/Add-ons/SDK/Guides/Program_ID">Program ID documentation</a>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>lib</code></td>
+ <td>
+ <p>String representing the top-level module directory provided in this add-on. Defaults to "lib".</p>
+
+ <div class="note">
+ <p><strong>Note:</strong> This is deprecated along with <code>cfx</code> and is not available when using <a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a>.</p>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td id="license"><code>license</code></td>
+ <td>
+ <p>The name of the license under which the add-on is distributed, with an optional URL in parentheses. Defaults to <code>"MPL-2.0"</code>.</p>
+
+ <div class="note">
+ <p><strong>Note</strong>: It is recommend that you use an <a href="https://spdx.org/licenses/">SPDX license ID</a>.</p>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td id="main"><code>main</code></td>
+ <td>
+ <p>A string representing the name of a program module that is located in one of the top-level module directories specified by <a href="/en-US/Add-ons/SDK/Tools/package_json#lib"><code>lib</code></a>. Defaults to <code>"main"</code>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td id="name"><code>name</code></td>
+ <td>
+ <p>The add-on's name. This name cannot contain spaces or periods, and defaults to the name of the parent directory.</p>
+
+ <p>When the add-on is built as an XPI, if the <a href="/en-US/Add-ons/SDK/Tools/package_json#fullName"><code>fullName</code></a> and <a href="/en-US/Add-ons/SDK/Tools/package_json#title"><code>title</code></a> keys are not present, <code>name</code> is used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#name"><code>em:name</code></a> element in its <code>install.rdf</code>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td id="packages"><code>packages</code></td>
+ <td>
+ <div class="note">
+ <p><strong>Note:</strong> This is deprecated along with <code>cfx</code> and is not available when using <a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a>.</p>
+ </div>
+
+ <p>A string pointing to a directory containing additional packages. Defaults to <code>"packages"</code>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td id="permissions"><code>permissions</code></td>
+ <td>
+ <p>A set of permissions that the add-on needs.</p>
+
+ <p><strong><code>private-browsing</code></strong>: a boolean indicating whether or not the add-on supports private browsing. If this value is not <code>true</code> or is omitted, then the add-on will not see any private windows or objects, such as tabs, that are associated with private windows. See the documentation for the <a href="/en-US/Add-ons/SDK/High-Level_APIs/private-browsing"><code>private-browsing</code> module</a>.</p>
+
+ <p><strong><code>cross-domain-content</code></strong>: a list of domains for which content scripts are given cross-domain privileges to access content in iframes or to make XMLHTTPRequests. See the documentation for <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts/Cross_Domain_Content_Scripts">enabling cross-domain content scripts</a>.</p>
+
+ <p><strong><code>multiprocess</code></strong>: a Boolean value declaring whether this add-on is, or is not, compatible with <a href="/en-US/Add-ons/Working_with_multiprocess_Firefox">multiprocess Firefox</a>.</p>
+
+ <div class="note">
+ <p><strong>Note</strong> the <code>multiprocess</code> permission is not supported by <a href="/en-US/Add-ons/SDK/Tools/cfx">cfx</a>.</p>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td id="preferences"><code>preferences</code></td>
+ <td>
+ <p>An array of <a href="/en-US/docs/Glossary/JSON">JSON</a> objects that use the following keys: <code>name</code>,<code>type</code>, <code>value</code>, <code>title</code>, and <code>description</code>. These JSON objects will be used to create a preferences interface for the add-on in the Add-ons Manager.</p>
+
+ <p>See the documentation for the <a href="/en-US/Add-ons/SDK/High-Level_APIs/simple-prefs"><code>simple-prefs</code> module</a>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td id="preferences-branch"><code>preferences-branch</code></td>
+ <td>Use this to specify an alternative branch for your add-on's simple-prefs. See <a href="/en-US/Add-ons/SDK/High-Level_APIs/simple-prefs#Simple-prefs_in_the_preferences_system">"Simple-prefs in the preferences system"</a> for more details.</td>
+ </tr>
+ <tr>
+ <td id="title"><code>title</code></td>
+ <td>
+ <p>The human-readable title of the package; this can contain spaces.</p>
+
+ <p>If this key is present its value will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#name"><code>em:name</code></a> element in its <code>install.rdf</code>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td id="translators"><code>translators</code></td>
+ <td>
+ <p>An array of strings listing the people who contributed to the localization of this add-on.</p>
+
+ <p>These values will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#translator"><code>em:translator</code></a> elements in its <code>install.rdf</code>.</p>
+
+ <div class="note"><strong>Note:</strong> <a href="https://developer.mozilla.org/Add-ons/SDK/Tools/jpm">jpm</a> supports <a href="https://docs.npmjs.com/files/package.json#people-fields-author-contributors">NodeJS people fields</a>.</div>
+ </td>
+ </tr>
+ <tr>
+ <td id="unpack"><code>unpack</code></td>
+ <td>
+ <p>Same as the <code><a href="/en-US/Add-ons/Install_Manifests#unpack">unpack</a></code> in an <code>install.rdf</code> file.</p>
+
+ <p>Useful when the extension contains binaries.</p>
+ </td>
+ </tr>
+ <tr>
+ <td id="updateKey"><code>updateKey</code></td>
+ <td>
+ <p>Same as the <code><a href="/en-US/Add-ons/Install_Manifests#updateKey">updateKey</a></code> in an <code>install.rdf</code> file.</p>
+
+ <p>See <a href="/en-US/Add-ons/SDK/Tools/jpm#Supporting_updates_for_self-hosted_add-ons">Supporting updates for self-hosted add-ons</a>.</p>
+
+ <div class="note">
+ <p><strong>Note:</strong> This key is only available with <a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a>.</p>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td id="updateLink"><code>updateLink</code></td>
+ <td>
+ <p>Same as the <code><a href="/en-US/docs/Extension_Versioning%2C_Update_and_Compatibility#Securing_Updates">updateLink</a></code> for an <code>update.rdf</code> file. Previously was <code><a href="/en-US/Add-ons/SDK/Tools/cfx#updateURL_and_updateLink">--update-link in cfx</a></code>.</p>
+
+ <p>See <a href="/en-US/Add-ons/SDK/Tools/jpm#Supporting_updates_for_self-hosted_add-ons">Supporting updates for self-hosted add-ons</a>.</p>
+
+ <div class="note">
+ <p><strong>Note:</strong> This key is only available with <a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a>.</p>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td id="updateURL"><code>updateURL</code></td>
+ <td>
+ <p>Same as the <code><a href="/en-US/Add-ons/Install_Manifests#updateURL">updateURL</a></code> for an <code>install.rdf</code> file.</p>
+
+ <p>See <a href="/en-US/Add-ons/SDK/Tools/jpm#Supporting_updates_for_self-hosted_add-ons">Supporting updates for self-hosted add-ons</a>.</p>
+
+ <div class="note">
+ <p><strong>Note:</strong> This key is only available with <a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a>.</p>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td id="version"><code>version</code></td>
+ <td>
+ <p>String representing the version of the add-on. Defaults to "0.0.1".</p>
+
+ <p>This value is used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#version"><code>em:version</code></a> element in its <code>install.rdf</code>.</p>
+
+ <div class="note">
+ <p><strong>Note:</strong> For <a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a> the version must be a valid <a href="http://semver.org/">semver</a>.</p>
+ </div>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/add_a_menu_item_to_firefox/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/add_a_menu_item_to_firefox/index.html
new file mode 100644
index 0000000000..29348bbabb
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/add_a_menu_item_to_firefox/index.html
@@ -0,0 +1,92 @@
+---
+title: Add a Menu Item to Firefox
+slug: Mozilla/Add-ons/SDK/Tutorials/Add_a_Menu_Item_to_Firefox
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/Add_a_Menu_Item_to_Firefox
+---
+<div class="note">
+ <p>学习本模块你需要 <a href="/en-US/Add-ons/SDK/Installation">安装SDK</a> 学习基础工具<a href="/en-US/Add-ons/SDK/Getting_Started_With_cfx"><code>cfx</code></a>.</p>
+</div>
+<div class="note">
+ <p>如果你使用 <a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a> 替代cfx, 使用第三方模块的方式是不同的, 你应该阅读 <a href="/en-US/Add-ons/SDK/Tutorials/Using_third-party_modules_%28jpm%29">jpm</a>的相应版本替代本教程.</p>
+ <p>给予Python可能未来废弃,使用JPM基于nodejs(译者备注).</p>
+</div>
+<p class="ordinary-output target-output"><span>SDK还不能为<span>火狐浏览器</span>提供一个API添加新的菜单项。</span><span>但它是可扩展的设计,所以任何人都可以建立和发布模块,使用插件开发者。</span><span>幸运的是</span><span>,</span><span>埃里克</span><span>沃尔德</span><span>写的</span><a href="https://github.com/mykmelez/menuitems-jplib"><span>MenuItems</span></a><span>模块,</span><span>能够使我们</span><span>添加菜单项</span><span>。</span></p>
+<p class="ordinary-output target-output"><span>本教程有双重的责任。</span><span>它描述的一般</span><span>方法,</span><span>使用一个外部的</span><span>,</span><span>在你的</span><span>插件</span><span>的第三方</span><span>模块</span><span>,</span><span>并</span><span>描述了如何</span><span>使用</span><span>特别的</span><span>MenuItems</span><span>模块</span><span>添加一个菜单项</span><span>。</span></p>
+<p class="ordinary-output target-output"><span>首先,创建一个新的扩展程序。</span><span>创建一个</span><span>目录名称为</span><span>“</span><span>clickme</span><span>”</span><span>(名称随意)</span><span>,</span><span>找到它并运行</span><code>cfx init</code><span>初始化</span><span>。</span></p>
+<pre>mkdir clickme
+cd clickme
+cfx init
+</pre>
+<p>通常将创建目录结构:</p>
+<ul>
+ <li>clickme
+ <ul>
+ <li>data</li>
+ <li>docs
+ <ul>
+ <li>main.md</li>
+ </ul>
+ </li>
+ <li>lib
+ <ul>
+ <li>main.js</li>
+ </ul>
+ </li>
+ <li>package.json</li>
+ <li>README.md</li>
+ <li>tests
+ <ul>
+ <li>test-main.js</li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+</ul>
+<div>
+  </div>
+<h2 id="安装_menuitems"><code>安装 menuitems</code></h2>
+<p>在 "clickme"下创建一个名称为"packages"的目录. 从 <a href="https://github.com/mykmelez/menuitems-jplib/zipball/4d6ae5b410d79cc16c9c76920fbaa8a367e44ca7">https://github.com/mykmelez/menuitems-jplib</a>  下载 <code>menuitems 并展开到刚才创建的</code>"packages" 目录下:</p>
+<pre>mkdir packages
+cd packages
+tar -xf ../erikvold-menuitems-jplib-d80630c.zip
+</pre>
+<h2 id="模块依赖">模块依赖</h2>
+<p class="ordinary-output target-output"><span>如果</span><span>第三方模块</span><span>只</span><span>取决于</span><span>SDK</span><span>模块</span><span>,</span><span>你</span><span>可以马上</span><span>使用它们</span><span>,</span><span>但如果</span><span>他们依赖于其他</span><span>第三方模块</span><span>,</span><span>你需要安装</span><span>的</span><span>依赖</span><span>以及</span><span>。</span></p>
+<p><span class="high-light-bg">在软件包的主目录,你会发现一个叫做</span> "package.json"的文件.  <span>打开它,看看一个</span>名称"dependencies"的入口.  <code>menuitems</code> 包的入口:</p>
+<pre>"dependencies": ["vold-utils"]
+</pre>
+<p>这告诉我们需要安装 <code>vold-utils</code> 包, 我们可以从<a href="https://github.com/mykmelez/vold-utils-jplib/zipball/a321447dc5d613df33023165854957c181dc3174">https://github.com/mykmelez/vold-utils-jplib</a> 下载,并添加到 <code>packages</code> 目录<code>下的旁边的menuitems</code>.</p>
+<h2 id="使用menuitems"><code>使用menuitems</code></h2>
+<p> <a href="https://github.com/mykmelez/menuitems-jplib/blob/master/docs/menuitems.md"><code>Menuitems</code>模块文档</a> <code>告诉使用MenuItem()创建一个新的菜单项</code>. <code>MenuItem()可接受的附加选项</code>, 我们将使用最迷你的配置:</p>
+<ul>
+ <li><code>id</code>: 菜单项标示符</li>
+ <li><code>label</code>:菜单项线上的文本</li>
+ <li><code>command</code>: 用户选择菜单项的响应函数</li>
+ <li><code>menuid</code>: 菜单项的父类标示符</li>
+ <li><code>insertbefore</code>: 我们希望出现的标示符之前的位置</li>
+</ul>
+<div>
+ <div>
+ <pre class="brush: js">var menuitem = require("menuitems").Menuitem({
+ id: "clickme",
+ menuid: "menu_ToolsPopup",
+ label: "Click Me!",
+ onCommand: function() {
+ console.log("clicked");
+ },
+ insertbefore: "menu_pageInfo"
+});</pre>
+ <div>
+  </div>
+ </div>
+</div>
+<p>接下来, 我们将<code>声明menuitems</code>的依赖包. 在你的add-on's <code>package.json文件添加一行</code>:</p>
+<pre>"dependencies": "menuitems"
+</pre>
+<p>Note that due to <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=663480">bug 663480</a>, if you add a <code>dependencies</code> line to <code>package.json</code>, and you use any modules from the SDK, then you must also declare your dependency on that built-in package, like this:</p>
+<pre>"dependencies": ["menuitems", "addon-sdk"]
+</pre>
+<p class="ordinary-output target-output"><span>现在我们要做的。</span><span>运行</span><span>插件</span><span>,</span><span>你会</span><span>看到新的项目</span><span>出现在工具</span><span>菜单:</span><span>选择它,</span><span>你会看到</span><code>info: clicked </code><span>出现在</span><span>控制台</span><span>。</span></p>
+<h2 id="Caveats">Caveats</h2>
+<p class="ordinary-output target-output"><span>第三方</span><span>模块</span><span>使用</span><span>不直接支持的</span><span>SDK功能</span><span>的好方法,</span><span>但由于</span><span>第三方模块</span><span>通常使用</span><span>低级别的</span><span>API</span><span>,</span><span>它们可以通过</span><span>Firefox的</span><span>新版本</span><span>了</span><span>。</span></p>
+<p> </p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/adding_a_button_to_the_toolbar/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/adding_a_button_to_the_toolbar/index.html
new file mode 100644
index 0000000000..8e4438f818
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/adding_a_button_to_the_toolbar/index.html
@@ -0,0 +1,83 @@
+---
+title: 在工具栏上添加按钮
+slug: Mozilla/Add-ons/SDK/Tutorials/Adding_a_Button_to_the_Toolbar
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/Adding_a_Button_to_the_Toolbar
+---
+<div class="note">
+<p>动手之前,必须先<a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/安装">安装SDK</a>并学习<a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Getting_Started_With_cfx"><code>cfx</code>基础</a>.</p>
+
+<p>这篇教程使用<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action">动作按钮</a>API,需要Firefox 29或更新版本。</p>
+</div>
+
+<p>如果要给工具栏添加一个按钮,需要使用<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action">动作按钮</a>或<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_toggle">切换按钮</a>模块。</p>
+
+<p>新建一个目录,打开它,执行<code>cfx init</code>。</p>
+
+<p>然后,把这三个图标保存到data文件夹:</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><img alt="" src="https://mdn.mozillademos.org/files/7635/icon-16.png" style="height: 16px; width: 16px;"></td>
+ <td>icon-16.png</td>
+ </tr>
+ <tr>
+ <td><img alt="" src="https://mdn.mozillademos.org/files/7637/icon-32.png" style="height: 32px; width: 32px;"></td>
+ <td>icon-32.png</td>
+ </tr>
+ <tr>
+ <td><img alt="" src="https://mdn.mozillademos.org/files/7639/icon-64.png" style="height: 64px; width: 64px;"></td>
+ <td>icon-64.png</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>随后打开lib目录下的main.js文件,添加如下代码:</p>
+
+<pre class="brush: js">var buttons = require('sdk/ui/button/action');
+var tabs = require("sdk/tabs");
+
+var button = buttons.ActionButton({
+  id: "mozilla-link",
+  label: "Visit Mozilla",
+  icon: {
+    "16": "./icon-16.png",
+    "32": "./icon-32.png",
+    "64": "./icon-64.png"
+  },
+  onClick: handleClick
+});
+
+function handleClick(state) {
+  tabs.open("https://www.mozilla.org/");
+}</pre>
+
+<p>现在输入<code>cfx run</code>来执行附加组件。按钮添加到了浏览器顶部的工具栏上:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/7641/mozilla-button.png" style="display: block; height: 221px; margin-left: auto; margin-right: auto; width: 382px;">你无法设置按钮的初始位置,但是用回可以使用浏览器的自定义功能移动它。其中的<code>id</code>属性是必需的,用来记录按钮的位置,因此,你最好不要在后续版本中修改它。</p>
+
+<p>单击按钮,<a href="https://www.mozilla.org/en-US/">https://www.mozilla.org/</a>将会在新的标签页中加载。</p>
+
+<h2 id="设定图标">设定图标</h2>
+
+<p>icon属性可以设定单个或是一组不同大小图标。如果你用的是一组不同大小的图标,浏览器将会自动选择最适合当前屏幕分辨率的,然后显示在浏览器界面的按钮上。<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#ActionButton(options)">更多内容,参考设定多个图标</a>。</p>
+
+<p>图标文件必须打包在附加组件内:它不可以指向一个远程文件。</p>
+
+<p>你只要正确地设置了按钮的<code>icon</code>属性,它就会立刻生效。你可以改变全局的,在特定窗口的或者是特定标签页中显示的图标或者是其他状态属性。<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#Updating_state">更多内容,参考更新状态</a>。</p>
+
+<h2 id="附加一个面板">附加一个面板</h2>
+
+<p>如果你想把一个面板附加到按钮上,使用<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_toggle">切换按钮</a>API。这就和动作按钮API类似,只不过多了一个boolean值属性,表示按钮是否被<code>checked</code>。附加面板,要把按钮传递给面板的<a href="https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/panel#show(options)"><code>show()</code></a>方法。<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_toggle#Attaching_panels_to_buttons">更多细节,参考切换按钮文档</a>。</p>
+
+<h2 id="显示更多样的内容">显示更多样的内容</h2>
+
+<p>添加按钮做不到的复杂界面功能,需要使用<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_toolbar">工具栏</a>API。 使用工具栏API你可以得到一个用户界面内容的水平条。可以添加按钮或者是可以包含HTML,CSS,javaScript的<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_frame">frame</a>到工具栏上。</p>
+
+<h2 id="进一步学习">进一步学习</h2>
+
+<ul>
+ <li><a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action">动作按钮参考</a></li>
+ <li><a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_toggle">切换按钮参考</a></li>
+ <li><a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_toolbar">工具栏参考</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/annotator/implementing_the_widget/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/annotator/implementing_the_widget/index.html
new file mode 100644
index 0000000000..04e4a75d23
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/annotator/implementing_the_widget/index.html
@@ -0,0 +1,92 @@
+---
+title: 实现控件
+slug: Mozilla/Add-ons/SDK/Tutorials/Annotator/Implementing_the_widget
+tags:
+ - 附加组件
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/Annotator/Implementing_the_widget
+---
+<p>我们想要控件做两件事:</p>
+
+<ul>
+ <li>点击鼠标左键,控件应当启用或禁用注释器。</li>
+ <li>点击鼠标右键,控件应当显示用户创建注释的清单。</li>
+</ul>
+
+<p>因为控件无法区分鼠标左右键的点击,我们应当使用内容脚本来捕获单击事件并发送相应的消息到附加组件。</p>
+
+<p>控件将有两个图标:一个在注释器启用时显示,一个在禁用时显示。</p>
+
+<p>因此,我们需要创建三个文件:控件的内容脚本和两个图标。</p>
+
+<p>在data子目录创建一个widget子目录,我们将把控件的文件保存在这里(注意,这个不是强制性的:你可以仅仅把它们放在data里,但分类放置会更加整洁)。</p>
+
+<h2 id="控件的内容脚本">控件的内容脚本</h2>
+
+<p>控件的内容脚本仅仅监听鼠标的左右单击并发送相应的消息到附加组件代码:</p>
+
+<pre class="brush: js">this.addEventListener('click', function(event) {
+ if(event.button == 0 &amp;&amp; event.shiftKey == false)
+ self.port.emit('left-click');
+
+ if(event.button == 2 || (event.button == 0 &amp;&amp; event.shiftKey == true))
+ self.port.emit('right-click');
+ event.preventDefault();
+}, true);</pre>
+
+<p>把它保存在data/widget并命名为widget.js。</p>
+
+<h2 id="控件图标">控件图标</h2>
+
+<p>你可以从这里复制图标:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/6673/pencil-off.png"><img alt="" src="https://mdn.mozillademos.org/files/6675/pencil-on.png" style="width: 32px; height: 32px;"></p>
+
+<p>或者自己动手做你觉得有创造性的图标。把它们保存在data/widget目录。</p>
+
+<h2 id="main.js">main.js</h2>
+
+<p>现在在lib目录创建main.js并添加下列内容:</p>
+
+<pre class="brush: js">var widgets = require('sdk/widget');
+var data = require('sdk/self').data;
+
+var annotatorIsOn = false;
+
+function toggleActivation() {
+ annotatorIsOn = !annotatorIsOn;
+ return annotatorIsOn;
+}
+
+exports.main = function() {
+
+ var widget = widgets.Widget({
+ id: 'toggle-switch',
+ label: 'Annotator',
+ contentURL: data.url('widget/pencil-off.png'),
+ contentScriptWhen: 'ready',
+ contentScriptFile: data.url('widget/widget.js')
+ });
+
+ widget.port.on('left-click', function() {
+ console.log('activate/deactivate');
+ widget.contentURL = toggleActivation() ?
+ data.url('widget/pencil-on.png') :
+ data.url('widget/pencil-off.png');
+ });
+
+ widget.port.on('right-click', function() {
+ console.log('show annotation list');
+ });
+}</pre>
+
+<p>注释器默认禁用。它创建控件并通过切换注释器的活动状态来回应来自控件内容脚本的消息。注意,由于<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=626326">bug 626326</a>,附加组件状态栏的环境菜单会显示,尽管在控件的内容脚本中调用了event.preventDefault()。由于我们没有任何代码来显示注释,所以我们们仅仅记录右击事件到控制台。</p>
+
+<p>现在在注释器目录输入cfx run,你应该看见在附加组件状态栏的控件:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/6679/widget-icon.png" style="width: 405px; height: 166px; display: block; margin-left: auto; margin-right: auto;"></p>
+
+<p>左击和右击应当产生合适的调试输出,同时左击应当改变控件的图标为启用状态。</p>
+
+<p> </p>
+
+<p>下一步,我们将添加代码来<a href="/en-US/Add-ons/SDK/Tutorials/Annotator/Creating_annotations">创建注释器</a>。</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/annotator/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/annotator/index.html
new file mode 100644
index 0000000000..4f76d67802
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/annotator/index.html
@@ -0,0 +1,36 @@
+---
+title: 注释器(Annotator)
+slug: Mozilla/Add-ons/SDK/Tutorials/Annotator
+tags:
+ - 附加组件
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/Annotator
+---
+<div class="warning">
+<p>请注意教程中Widget API适合的浏览器版本。(译者注)</p>
+</div>
+
+<p>在这个教程中,我们将构建一个使用许多SDK高级API的附加组件.</p>
+
+<p>这个附加组件是一个注释器:它可以让用户选择网页的元素并输入有关的笔记(注释).注释器储存笔记.无论用户何时载入包含被注释元素的页面,这些元素都将会高亮显示,并且用户若把鼠标移动到被注释元素的上面,将会显示它的注释.</p>
+
+<p>接着我们将给出这个注释器设计的快速简介,然后一步步的讨论如何实现.</p>
+
+<p>如果你想参阅完整的附加组件,你可以在<a href="https://github.com/mozilla/addon-sdk/tree/master/examples/annotator">SDK例子目录</a>找到它.</p>
+
+<ul>
+ <li>
+ <p><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Annotator/Overview">设计概述</a></p>
+ </li>
+ <li>
+ <p><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Annotator/Implementing_the_widget">实现控件</a></p>
+ </li>
+ <li>
+ <p><a href="/en-US/Add-ons/SDK/Tutorials/Annotator/Creating_annotations">创建注释</a></p>
+ </li>
+ <li>
+ <p><a href="/en-US/Add-ons/SDK/Tutorials/Annotator/Storing_annotations">保存注释</a></p>
+ </li>
+ <li>
+ <p><a href="/en-US/Add-ons/SDK/Tutorials/Annotator/Displaying_annotations">显示注释</a></p>
+ </li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/annotator/overview/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/annotator/overview/index.html
new file mode 100644
index 0000000000..da94f8142a
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/annotator/overview/index.html
@@ -0,0 +1,54 @@
+---
+title: 概述
+slug: Mozilla/Add-ons/SDK/Tutorials/Annotator/Overview
+tags:
+ - addon sdk example
+ - annotator example
+ - 附加组件
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/Annotator/Overview
+---
+<p>注释器使用内容脚本(content scripts)来构建用户界面,得到用户输入,并检查用户载入页面的DOM。</p>
+
+<p>同时,主要模块包括程序逻辑和调节不同SDK对象的交互。</p>
+
+<p>我们可以描述在主要模块和不同内容脚本的交互,像这样:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/6671/annotator-design.png" style="display: block; margin-left: auto; margin-right: auto;"></p>
+
+<h2 id="用户界面">用户界面</h2>
+
+<p>注释器的主要用户界面由一个控件和三个面板组成。</p>
+
+<ul>
+ <li><a href="/en-US/Add-ons/SDK/High-Level_APIs/widget">控件(widget)</a>用来选择打开或关闭注释器,显示所有已经储存的注释列表。</li>
+ <li><strong>注释编辑器(annotation-editor)</strong><a href="/en-US/Add-ons/SDK/High-Level_APIs/panel">面板</a>用来让用户输入注释。</li>
+ <li><strong>注释列表(annotation-list)</strong>面板用来显示保存的注释清单。</li>
+ <li><strong>注释(annotation)</strong>面板显示单条注释。</li>
+</ul>
+
+<p>除此之外,我们使用 <a href="/en-US/Add-ons/SDK/High-Level_APIs/notifications">notifications</a> 模块来告知用户附加组件的储存限额已满。</p>
+
+<h2 id="用DOM工作">用DOM工作</h2>
+
+<p>我们将使用 <a href="/en-US/Add-ons/SDK/High-Level_APIs/page-mod">page-mods</a> 来和用户打开的网页的DOM进行交互。</p>
+
+<ul>
+ <li>
+ <p><strong>选择器(selector)</strong>让用户选择一个元素来注释。它识别符合注释条件的页面元素,当鼠标在他们上方时高亮显示,并在用户点击高亮元素时通知主要的附加组件代码。</p>
+ </li>
+ <li>
+ <p><strong>匹配器(matcher)</strong>用来寻找被注释的元素:它初始化注释列表并网页中和注释相关连的元素。高亮网页上找到的关联元素,并高亮显示。当鼠标移动到已注释元素的上面,匹配器将通知显示注释面板的主要附加组件代码。</p>
+ </li>
+</ul>
+
+<h2 id="处理数据">处理数据</h2>
+
+<p>我们将使用<a href="/en-US/Add-ons/SDK/High-Level_APIs/simple-storage">simple-storage</a>模块来储存数据。</p>
+
+<p>由于我们将记录潜在的敏感信息,我们想阻止用户在隐私浏览模式下创建注释,最简单的方式是删除附加组件中“package.json“文件的<a href="/en-US/Add-ons/SDK/Tools/package_json#permissions">”private-browsing"键</a>。这样,附加组件就不能看见任何隐私浏览窗口,同时注释器的控件也将不再出现。</p>
+
+<h2 id="开始行动">开始行动</h2>
+
+<p>现在让我们来创建叫“注释器”的目录。Navigate to it and type <code>cfx init</code>.</p>
+
+<p>下一步,我们将<a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Annotator/Implementing_the_widget">实现控件</a>。</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/display_a_popup/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/display_a_popup/index.html
new file mode 100644
index 0000000000..9bec4966d4
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/display_a_popup/index.html
@@ -0,0 +1,135 @@
+---
+title: 显示弹出对话框
+slug: Mozilla/Add-ons/SDK/Tutorials/Display_a_Popup
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/Display_a_Popup
+---
+<div class="note">
+ <p>动手之前,必须先<a href="/en-US/Add-ons/SDK/Installation">安装SDK</a>并学习<a href="/en-US/Add-ons/SDK/Getting_Started_With_cfx"><code>cfx</code>基础知识</a>.</p>
+ <p>T这篇教程使用<a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action">动作按钮</a>API需要Firefox 29或更新版本。</p>
+</div>
+<p>可以使用<a href="/en-US/Add-ons/SDK/High-Level_APIs/panel"><code>面板(panel)</code></a>模块来显示弹出对话框。面板的内容通过HTML编写。你可以在面板上运行content script:尽管在面板里的脚本无法直接访问插件代码,但是你可以在面板脚本和插件代码间交换信息。</p>
+<p>这里,我们做了一个会在单击时显示面板的<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action">动作按钮</a>。面板上有一个<code>&lt;textarea&gt;</code>元素:用户按下<code>return</code>键时,<code>&lt;textarea&gt;</code>的内容会被发送给插件代码主程序。插件代码主程序会<a href="/en-US/Add-ons/SDK/Tutorials/Logging">在控制台输出日志</a>。.</p>
+<p><img alt="" src="https://mdn.mozillademos.org/files/7647/panel.png" style="display: block; margin-left: auto; margin-right: auto;">The add-o插件由六个文件组成n consists of six files:</p>
+<ul>
+ <li><code>main.js</code>:插件主程序,在这里创建按钮和面板</li>
+ <li><code>get-text.js</code>:与面板内容交互的content脚本</li>
+ <li><code>text-entry.html</code>:面板的内容,由HTML编写</li>
+ <li><code>icon-16.png</code>,<code>icon-32.png</code>和<code>icon-64.png</code>:三种不同大小的图标</li>
+</ul>
+<p>"main.js"像这样:</p>
+<pre class="brush: js">var data = require("sdk/self").data;
+// 构造面板,从"data"目录的"text-entry.html"加载
+// 内容,然后加载"get-text.js"脚本。
+var text_entry = require("sdk/panel").Panel({
+  contentURL: data.url("text-entry.html"),
+  contentScriptFile: data.url("get-text.js")
+});
+
+// 创建按钮
+require("sdk/ui/button/action").ActionButton({
+  id: "show-panel",
+  label: "Show Panel",
+  icon: {
+    "16": "./icon-16.png",
+    "32": "./icon-32.png",
+    "64": "./icon-64.png"
+  },
+  onClick: handleClick
+});
+
+// 在用户点击按钮时显示面板。
+function handleClick(state) {
+  text_entry.show();
+}
+
+<code class="language-js"><span class="token comment">// When the panel is displayed it generated an event called
+</span><span class="token comment">// "show": we will listen for that event and when it happens,
+</span><span class="token comment">// send our own "show" event to the panel's script, so the
+</span><span class="token comment">// script can prepare the panel for display.</span></code>
+text_entry.on("show", function() {
+  text_entry.port.emit("show");
+});
+
+// 监听来自content脚本的text-entered消息。消息主体L是用户输入的文本。
+// 此实现,我们只在控制台显示日志。
+text_entry.port.on("text-entered", function (text) {
+  console.log(text);
+  text_entry.hide();
+});</pre>
+<p>content脚本"get-text.js"像这样:</p>
+<div>
+ <pre class="brush: js">// 用户按下回车,发送text-entered消息给main.js。
+// 消息主体是编辑框的内容。
+var textArea = document.getElementById("edit-box");
+textArea.addEventListener('keyup', function onkeyup(event) {
+ if (event.keyCode == 13) {
+ // Remove the newline.
+ text = textArea.value.replace(/(\r\n|\n|\r)/gm,"");
+ self.port.emit("text-entered", text);
+ textArea.value = '';
+ }
+}, false);
+// 监听由插件主程序发送的show事件。表示面板将要显示。
+//
+// 焦点放在textarea上,这样用户可以直接开始输入。
+self.port.on("show", function onShow() {
+ textArea.focus();
+});</pre>
+ <div>
+  </div>
+</div>
+<p>最后,"text-entry.html"文件定义了<code>&lt;textarea&gt;</code>元素:</p>
+<div>
+ <div>
+ <pre class="brush: html">&lt;html&gt;
+&lt;head&gt;
+    &lt;style type="text/css" media="all"&gt;
+      textarea {
+        margin: 10px;
+      }
+      body {
+        background-color: gray;
+      }
+    &lt;/style&gt;
+  &lt;/head&gt;
+&lt;body&gt;
+    &lt;textarea rows="13" cols="33" id="edit-box"&gt;&lt;/textarea&gt;
+  &lt;/body&gt;
+&lt;/html&gt;</pre>
+ <div>
+  </div>
+ </div>
+</div>
+<p>最后,把这三个图标文件保存在"data"目录:</p>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><img alt="" src="https://mdn.mozillademos.org/files/7635/icon-16.png" style="width: 16px; height: 16px;"></td>
+ <td>icon-16.png</td>
+ </tr>
+ <tr>
+ <td><img alt="" src="https://mdn.mozillademos.org/files/7637/icon-32.png" style="width: 32px; height: 32px;"></td>
+ <td>icon-32.png</td>
+ </tr>
+ <tr>
+ <td><img alt="" src="https://mdn.mozillademos.org/files/7639/icon-64.png" style="width: 64px; height: 64px;"></td>
+ <td>icon-64.png</td>
+ </tr>
+ </tbody>
+</table>
+<p>试用以下:保存在<code>lib</code>目录,其他五个文件存放在插件的<code>data</code>目录:</p>
+<pre>my-addon/
+ data/
+ get-text.js
+ icon-16.png
+ icon-32.png
+ icon-64.png
+ text-entry.html
+ lib/
+ main.js
+</pre>
+<p>运行插件,点击按钮,你就会看见一个面板。输入几行文本,然后按下回车,你就会看见控制台里的输出。</p>
+<p>自Firefox 30起,如果你使用<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_toggle">切换按钮</a>,就可以<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_toggle#Attaching_panels_to_buttons">给它附加一个面板</a>。</p>
+<h2 id="进一步学习">进一步学习</h2>
+<p>学习<code>panel</code>模块的更多内容,见<a href="/en-US/Add-ons/SDK/High-Level_APIs/panel"><code>panel</code> API参考</a>。</p>
+<p>学习关于按钮的更多内容,见<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action">动作按钮</a>和<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_toggle">切换按钮</a>API参考。</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/getting_started/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/getting_started/index.html
new file mode 100644
index 0000000000..225739de76
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/getting_started/index.html
@@ -0,0 +1,172 @@
+---
+title: 快速入门
+slug: Mozilla/Add-ons/SDK/Tutorials/Getting_started
+tags:
+ - add-on sdk开发
+ - cfx工具基础使用教程
+ - 火狐扩展程序
+translation_of: Mozilla/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29
+---
+<p>{{AddonSidebar}}</p>
+
+<div class="note">
+<p>Add-on SDK 里包含了一个命令行工具,你可以用此工具来初始化、运行、测试以及打包 add on。 这个工具称为 jpm,基于 <a href="http://nodejs.org/">Node.js</a> 。它替代了以前的cfx工具。</p>
+
+<p>你可以在 Firefox 38或之后的版本中使用。</p>
+
+<p>本文阐述如何使用 jpm 开发。</p>
+</div>
+
+<p>本教程会过一遍使用 SDK 创建一个简单 add-on 的过程。</p>
+
+<h2 id="准备">准备</h2>
+
+<p>要使用 SDK 创建 add-on,你需要:</p>
+
+<ul>
+ <li>Firefox 38或以后版本。如果你需要在早期版本的 Firefox 上开发,你就要使用老的 cfx 工具。参看 <a href="/en-US/Add-ons/SDK/Tutorials/Getting_started_(cfx)">cfx 快速入门</a>的说明。</li>
+ <li>命令行 jpm 工具。参看 <a href="/en-US/Add-ons/SDK/Tools/jpm#Installation">jpm 安装</a>的说明。一旦你已经完成这些工作,你就会在一个命令行提示符下。</li>
+</ul>
+
+<h2 id="初始化空的_add-on">初始化空的 add-on</h2>
+
+<p>在命令行提示符下,创建一个新目录。进入新文件夹,键入 <code>jpm init</code>,然后敲回车</p>
+
+<pre>mkdir my-addon
+cd my-addon
+jpm init
+</pre>
+
+<p>接着你会被要求提供一些关于你的 add-on 的信息:这会用来创建 <a href="/en-US/Add-ons/SDK/Tools/package_json">package.json</a> 文件。如果光按回车的话,就表示接受属性的默认值。关于 <code>jpm init</code> 的更多信息,参看 <a href="/en-US/Add-ons/SDK/Tools/jpm#Command_reference">jpm command reference</a>.</p>
+
+<p>一旦你设置了这些属性的值或者接受默认值,你会看到 "package.json" 的完整内容并被询问是否接受这些设置。</p>
+
+<h2 id="实现_add-on">实现 add-on</h2>
+
+<p>现在你可以写 add-on 的代码了。除非你修改了"entry point"的值(package.json 中的 "<a href="/en-US/Add-ons/SDK/Tools/package_json#main">main</a>"),一般情况将从你的 add-on 的根目录下的"index.js"文件开始。这个文件就是在之前步骤中创建的。打开这个文件并且添加以下代码:</p>
+
+<pre class="brush: js">var buttons = require('sdk/ui/button/action');
+var tabs = require("sdk/tabs");
+
+var button = buttons.ActionButton({
+ id: "mozilla-link",
+ label: "Visit Mozilla",
+ icon: {
+ "16": "./icon-16.png",
+ "32": "./icon-32.png",
+ "64": "./icon-64.png"
+ },
+ onClick: handleClick
+});
+
+function handleClick(state) {
+ tabs.open("http://www.mozilla.org/");
+}
+</pre>
+
+<div class="note">
+<p>注意在jpm中"entry point"的默认值为"index.js",意思是你的主文件是"index.js",且在你的 add-on的根目录下。</p>
+
+<p>cfx中,入口默认是"main.js",并且在"lib"目录下</p>
+</div>
+
+<p>保存文件</p>
+
+<p>接下来,在根目录下创建目录<strong>"data"</strong>。</p>
+
+<pre>mkdir data
+</pre>
+
+<p>并保存这三个图标文件到<strong>"data"</strong>目录:</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><img alt="" src="https://mdn.mozillademos.org/files/7635/icon-16.png" style="height: 16px; width: 16px;"></td>
+ <td>icon-16.png</td>
+ </tr>
+ <tr>
+ <td><img alt="" src="https://mdn.mozillademos.org/files/7637/icon-32.png" style="height: 32px; width: 32px;"></td>
+ <td>icon-32.png</td>
+ </tr>
+ <tr>
+ <td><img alt="" src="https://mdn.mozillademos.org/files/7639/icon-64.png" style="height: 64px; width: 64px;"></td>
+ <td>icon-64.png</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>返回命令行,键入:</p>
+
+<pre>jpm run</pre>
+
+<p>这个 jpm 命令会运行一个带有你的 add-on 的 Firefox 的新实例。</p>
+
+<p>如果找不到 Firefox,你可能要为它提供一个路径(如在Ubuntu中):</p>
+
+
+<pre>jpm run -b /usr/bin/firefox</pre>
+
+<p>Firefox 启动以后,在浏览器右上角你能看到一个 Firefox logo 的图标。点击该图标,就会打开一个新标签页 <a href="http://www.mozilla.org/" rel="noreferrer">http://www.mozilla.org/</a>。</p>
+
+<p>这就是这个 add-on 的全部功能了。它用到了 SDK 的两个模块:<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action">action button</a> 模块,使你能加个按钮到浏览器上,以及 <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs" rel="noreferrer">tabs</a> 模块,使你能完成对标签页的基本操作。本例中,我们以及创建了一个图标是Firefox图标的按钮,并添加一个点击处理程序,可以在新标签页中打开 Mozilla 页面。</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/7643/mozilla-button.png" style="display: block; height: 221px; margin-left: auto; margin-right: auto; width: 382px;">试着编辑这个文件。例如,我们可以改变加载的页面:</p>
+
+<pre class="brush: js">var buttons = require('sdk/ui/button/action');
+var tabs = require("sdk/tabs");
+
+var button = buttons.ActionButton({
+ id: "mozilla-link",
+ label: "Visit Mozilla",
+ icon: {
+ "16": "./icon-16.png",
+ "32": "./icon-32.png",
+ "64": "./icon-64.png"
+ },
+ onClick: handleClick
+});
+
+function handleClick(state) {
+ tabs.open("https://developer.mozilla.org/");
+}</pre>
+
+<p>在命令行提示符下,再次执行 <code>jpm run</code>。这次点击按钮,它会带你到 <a href="https://developer.mozilla.org/">https://developer.mozilla.org/</a> 页面。</p>
+
+<h2 id="打包_add-on">打包 add-on</h2>
+
+<p>当你完成了 add-on 并准备发布它,你会需要把它打包为 XPI 文件。你能自己分发 XPI 文件,也可以把它们发布到 <a href="https://addons.mozilla.org" rel="noreferrer">https://addons.mozilla.org</a>,这样其他用户就能下载并按照它们。</p>
+
+<p>要构建 XPI,只要在 add-on 的根目录下运行命令 <code>jpm xpi</code>:</p>
+
+<pre>jpm xpi
+</pre>
+
+<p>你应该看到像这样的信息:</p>
+
+<pre>JPM info Successfully created xpi at /path/to/my-addon/@my-addon-0.0.1.xpi
+</pre>
+
+<p>要测试附加组件是否能正常运行,可以尝试在你自己的火狐中安装 XPI 文件。你可以在 Firefox 中按 Ctrl+O 组合键(Mac 中是 Cmd+O),或者选择"文件"菜单里的“打开”。这样会弹出一个文件选择对话框:转到"@my-addon.xpi"文件,打开并按照提示安装 add-on。</p>
+
+<p>注意 Firefox 默认需要 add-on 有签名,即使是本地开发的 add-on。安装完后他们会在已安装的 add-on 列表中出现,只因没有签名而被禁用。开发的时候,又或者你不准备发布,你可以打开 <a>about:config</a> 设置 <em>xpinstall.signatures.required</em> 为 <em>false</em> 来运行未经签名的组件。这个设置会应用到所有的 add-on,所以要十分小心,不要一不当心从别的地方安装了恶意组件。</p>
+
+<p>要发布你的 add-on,请<a href="https://addons.mozilla.org/en-US/developers/addon/submit/2">提交 XPI 文件到 addons.mozilla.org</a> 或者如果你想在你自己的服务器上发布,运行 <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#jpm_sign">jpm sign</a>。</p>
+
+<h2 id="总结">总结</h2>
+
+<p>本教程中我们使用了下面三个命令来构建和打包 add-on :</p>
+
+<ul>
+ <li><code>jpm init</code> 初始化一个空的 add-on 模板</li>
+ <li><code>jpm run</code> 运行一个装有 add-on 的新 Firefox 实例,所以我们可以试用它</li>
+ <li><code>jpm xpi</code> 打包 add-on 为 XPI 文件,用来发布</li>
+</ul>
+
+<p>这是你在开发SDK add-on会用到的三个主要命令。完全的<a href="/en-US/Add-ons/SDK/Tools/jpm" rel="noreferrer">参考文档</a>包含了所以你能使用的命令,以及这些命令的可选项。</p>
+
+<p>这次开发的add-on 的代码用到了两个 SDK 模块,<a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action">action button</a> 和 <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs" rel="noreferrer">tabs</a>。这儿有参考文档,描述 SDK 中所有<a href="/en-US/Add-ons/SDK/High-Level_APIs" rel="noreferrer">高层次</a>和<a href="/en-US/Add-ons/SDK/Low-Level_APIs" rel="noreferrer">低层次</a>的 API。</p>
+
+<h2 id="下一步">下一步?</h2>
+
+<p>要了解你能用 SDK API 做些什么,试着继续阅读<a href="/en-US/Add-ons/SDK/Tutorials" rel="noreferrer">教程</a>。</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/getting_started_(jpm)/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/getting_started_(jpm)/index.html
new file mode 100644
index 0000000000..e09d6d4e55
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/getting_started_(jpm)/index.html
@@ -0,0 +1,162 @@
+---
+title: JPM 入门!
+slug: Mozilla/Add-ons/SDK/Tutorials/Getting_Started_(jpm)
+tags:
+ - JPM
+ - add-on
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/Getting_Started_(jpm)
+---
+<div class="note">
+<p>该附加SDK包含一个用于初始化,运行,测试和打包加载项的命令行工具。当前工具称为jpm,并且基于  <a href="http://nodejs.org/">Node.js</a> .它替代了旧的cfx工具。</p>
+
+<p>Firefox 38 以上的版本才可以使用jpm。</p>
+
+<p>本文介绍如何使用jpm开发。</p>
+</div>
+
+<p>本教程将介绍使用SDK创建一个简单的附加组件。</p>
+
+<h2 id="先决条件">先决条件</h2>
+
+<p>要使用SDK为Firefox创建附加组件,您需要:</p>
+
+<ul>
+ <li>备好 Firefox 38 或更高版本浏览器,否则抱着你亲爱的cfx古董去死吧,出门左转 <a href="/en-US/Add-ons/SDK/Tutorials/Getting_started">getting started with cfx</a> 不谢。</li>
+ <li>命令行 JPM 工具,至 <a href="/en-US/Add-ons/SDK/Tools/jpm#Installation">installing jpm</a> 此处领取。// 后面这句是废话不翻译</li>
+</ul>
+
+<h2 id="初始化一个空的附加组件">初始化一个空的附加组件</h2>
+
+<p>在命令提示符下,创建一个新目录。导航到它,键入 <code>jpm init, </code>然后按Enter键<code>:</code></p>
+
+<pre>mkdir my-addon
+cd my-addon
+jpm init
+</pre>
+
+<p>You'll then be asked to supply some information about your add-on: this will be used to create your add-on's <a href="/en-US/Add-ons/SDK/Tools/package_json">package.json</a> file. For now, just press Enter to accept the default for each property. For more information on <code>jpm init</code>, see the <a href="/en-US/Add-ons/SDK/Tools/jpm#Command_reference">jpm command reference</a>.</p>
+
+<p>Once you've supplied a value or accepted the default for these properties, you'll be shown the complete contents of "package.json" and asked to accept it.</p>
+
+<h2 id="实现附加组件">实现附加组件</h2>
+
+<p>Now you can write the add-on's code. Unless you've changed the value of "entry point" ("<a href="/en-US/Add-ons/SDK/Tools/package_json#main">main</a>" in package.json), this goes in "index.js" file in the root of your add-on. This file was created for you in the previous step. Open it and add the following code:</p>
+
+<pre class="brush: js">var buttons = require('sdk/ui/button/action');
+var tabs = require("sdk/tabs");
+
+var button = buttons.ActionButton({
+ id: "mozilla-link",
+ label: "Visit Mozilla",
+ icon: {
+ "16": "./icon-16.png",
+ "32": "./icon-32.png",
+ "64": "./icon-64.png"
+ },
+ onClick: handleClick
+});
+
+function handleClick(state) {
+ tabs.open("http://www.mozilla.org/");
+}
+</pre>
+
+<div class="note">
+<p>Note that "entry point" defaults to "index.js" in jpm, meaning that your main file is "index.js", and it is found directly in your add-on's root.</p>
+
+<p>In cfx, the entry point defaults to "main.js", and is located in the "lib" directory under the add-on's root.</p>
+</div>
+
+<p>Save the file.</p>
+
+<p>Next, create a directory called "data" in your add-on's root, and save these three icon files to the "data" directory:</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><img alt="" src="https://mdn.mozillademos.org/files/7635/icon-16.png" style="height: 16px; width: 16px;"></td>
+ <td>icon-16.png</td>
+ </tr>
+ <tr>
+ <td><img alt="" src="https://mdn.mozillademos.org/files/7637/icon-32.png" style="height: 32px; width: 32px;"></td>
+ <td>icon-32.png</td>
+ </tr>
+ <tr>
+ <td><img alt="" src="https://mdn.mozillademos.org/files/7639/icon-64.png" style="height: 64px; width: 64px;"></td>
+ <td>icon-64.png</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>Back at the command prompt, type:</p>
+
+<pre>jpm run</pre>
+
+<p>This is the jpm command to run a new instance of Firefox with your add-on installed.</p>
+
+<p>If Firefox can not be located, you may need to provide the path to it (example in Ubuntu):</p>
+
+
+<pre>jpm run -b /usr/bin/firefox</pre>
+
+<p>When Firefox launches, in the top-right corner of the browser you'll see an icon with the Firefox logo. Click the icon, and a new tab will open with <a href="http://www.mozilla.org/" rel="noreferrer">http://www.mozilla.org/</a> loaded into it.</p>
+
+<p>That's all this add-on does. It uses two SDK modules: the <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action">action button</a> module, which enables you to add buttons to the browser, and the <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs" rel="noreferrer">tabs</a> module, which enables you to perform basic operations with tabs. In this case, we've created a button whose icon is the Firefox icon, and added a click handler that loads the Mozilla home page in a new tab.</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/7643/mozilla-button.png" style="display: block; height: 221px; margin-left: auto; margin-right: auto; width: 382px;">Try editing this file. For example, we could change the page that gets loaded:</p>
+
+<pre class="brush: js">var buttons = require('sdk/ui/button/action');
+var tabs = require("sdk/tabs");
+
+var button = buttons.ActionButton({
+ id: "mozilla-link",
+ label: "Visit Mozilla",
+ icon: {
+ "16": "./icon-16.png",
+ "32": "./icon-32.png",
+ "64": "./icon-64.png"
+ },
+ onClick: handleClick
+});
+
+function handleClick(state) {
+ tabs.open("https://developer.mozilla.org/");
+}</pre>
+
+<p>At the command prompt, execute <code>jpm run</code> again. This time clicking it takes you to <a href="https://developer.mozilla.org/">https://developer.mozilla.org/</a>.</p>
+
+<h2 id="Packaging_the_add-on">Packaging the add-on</h2>
+
+<p>When you've finished the add-on and are ready to distribute it, you'll need to package it as an XPI file. This is the installable file format for Firefox add-ons. You can distribute XPI files yourself or publish them to <a href="https://addons.mozilla.org" rel="noreferrer">https://addons.mozilla.org</a> so other users can download and install them.</p>
+
+<p>To build an XPI, just execute the command <code>jpm xpi</code> from the add-on's directory:</p>
+
+<pre>jpm xpi
+</pre>
+
+<p>You should see a message like:</p>
+
+<pre>JPM info Successfully created xpi at /path/to/getting-started/@getting-started.xpi
+</pre>
+
+<p>To test that this worked, try installing the XPI file in your own Firefox installation. You can do this by pressing the Ctrl+O key combination (Cmd+O on Mac) from within Firefox, or selecting the "Open" item from Firefox's "File" menu. This will bring up a file selection dialog: navigate to the "@getting-started.xpi" file, open it and follow the prompts to install the add-on.</p>
+
+<h2 id="Summary">Summary</h2>
+
+<p>In this tutorial we've built and packaged an add-on using three commands:</p>
+
+<ul>
+ <li><code>jpm init</code> to initialize an empty add-on template</li>
+ <li><code>jpm run</code> to run a new instance of Firefox with the add-on installed, so we can try it out</li>
+ <li><code>jpm xpi</code> to package the add-on into an XPI file for distribution</li>
+</ul>
+
+<p>These are the three main commands you'll use when developing SDK add-ons. There's comprehensive <a href="/en-US/Add-ons/SDK/Tools/jpm" rel="noreferrer">reference documentation</a> covering all the commands you can use and all the options they take.</p>
+
+<p>The add-on code itself uses two SDK modules, <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action">action button</a> and <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs" rel="noreferrer">tabs</a>. There's reference documentation for all the <a href="/en-US/Add-ons/SDK/High-Level_APIs" rel="noreferrer">high-level</a> and <a href="/en-US/Add-ons/SDK/Low-Level_APIs" rel="noreferrer">low-level</a> APIs in the SDK.</p>
+
+<h2 id="What's_next">What's next?</h2>
+
+<p>To get a feel for some of the things you can do with the SDK APIs, try working through some of the <a href="/en-US/Add-ons/SDK/Tutorials" rel="noreferrer">tutorials</a>.</p>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/index.html
new file mode 100644
index 0000000000..03173c3219
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/index.html
@@ -0,0 +1,144 @@
+---
+title: 教程
+slug: Mozilla/Add-ons/SDK/Tutorials
+tags:
+ - 插件SDK
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials
+---
+<p>{{LegacyAddonsNotice}}{{AddonSidebar}}</p>
+
+<p>本文列出了许多关于如何通过SDK完成特定任务要求的实际动手的文章。</p>
+
+<hr>
+<h3 id="开发之旅"><a name="getting-started">开发之旅</a></h3>
+
+<div class="column-container">
+<div class="column-half">
+<dl>
+ <dt><a href="/zh-CN/Add-ons/SDK/Tutorials/Installation">安装</a></dt>
+ <dd>在Windows, OS X和Linux上下载,安装,初始化SDK工具。</dd>
+</dl>
+
+<dl>
+ <dt><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Troubleshooting">常见问题</a></dt>
+ <dd>解决常见问题的建议和获取更多帮助。</dd>
+</dl>
+</div>
+
+<div class="column-half">
+<dl>
+ <dt><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Getting_started">快速开始</a></dt>
+ <dd>走马观花地使用SDK开发一个简单的扩展</dd>
+</dl>
+</div>
+</div>
+
+<hr>
+<h3 id="创建用户交互界面"><a name="create-user-interfaces">创建用户交互界面</a></h3>
+
+<div class="column-container">
+<div class="column-half">
+<dl>
+ <dt><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Adding_a_Button_to_the_Toolbar">添加一个工具按钮</a></dt>
+ <dd>添加一个按钮到火狐Add-on工具栏。</dd>
+ <dt><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Add_a_Menu_Item_to_Firefox">添加一个菜单选项到火狐</a></dt>
+ <dd>添加多个菜单选项到火狐主菜单。</dd>
+</dl>
+</div>
+
+<div class="column-half">
+<dl>
+ <dt><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Display_a_Popup">显示一个弹出对话框</a></dt>
+ <dd>通过HTML和JavaScript实现并显示一个弹窗对话框。</dd>
+ <dt><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/添加一个菜单项">添加一个上下文菜单</a></dt>
+ <dd>添加一个上下文菜单(一般都是右键菜单)到火狐浏览器</dd>
+</dl>
+</div>
+</div>
+
+<hr>
+<h3 id="与浏览器交互"><a name="interact-with-the-browser">与浏览器交互</a></h3>
+
+<div class="column-container">
+<div class="column-half">
+<dl>
+ <dt><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Open_a_Web_Page">打开Web页面</a></dt>
+ <dd>在一个新的浏览器选项卡里打开一个Web页面或窗口使用tabs模块并获取内容。</dd>
+ <dt><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Listen_for_Page_Load">监听页面加载</a></dt>
+ <dd>当新页面载入时使用tabs模块得到通知并获取页面内容。</dd>
+</dl>
+</div>
+
+<div class="column-half">
+<dl>
+ <dt><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/List_Open_Tabs">获取打开的选项卡(Tab)列表</a></dt>
+ <dd>使用tabs模块遍历当前打开的tab,并获取其内容。</dd>
+</dl>
+</div>
+</div>
+
+<hr>
+<h3 id="更改网页"><a name="modify-web-pages">更改网页</a></h3>
+
+<div class="column-container">
+<div class="column-half">
+<dl>
+ <dt><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Modifying_Web_Pages_Based_on_URL">更改网页通过URL</a></dt>
+ <dd>基于URL过滤网页:当载入的页面的URL与过滤器匹配时执行特定的脚本。</dd>
+</dl>
+</div>
+
+<div class="column-half">
+<dl>
+ <dt><a href="/zh-CN/Add-ons/SDK/Tutorials/Modifying_the_Page_Hosted_by_a_Tab">修改页面内容</a></dt>
+ <dd>动态加载脚本到当前页面。</dd>
+</dl>
+</div>
+</div>
+
+<hr>
+<h3 id="开发技术"><a name="development-techniques">开发技术</a></h3>
+
+<div class="column-container">
+<div class="column-half">
+<dl>
+ <dt><a href="/zh-CN/Add-ons/SDK/Tutorials/日志">日志</a></dt>
+ <dd>在终端中记录日志以便调试。</dd>
+ <dt><a href="/zh-CN/Add-ons/SDK/Tutorials/Creating_reusable_modules">创建可复用的模块</a></dt>
+ <dd>拆分扩展程序为多个分离的模块,可以使开发调试和维护更加简单。封装你的模块使其成为可复用的包,以便其他开发者可以再次使用。</dd>
+ <dt><a href="/zh-CN/Add-ons/SDK/Tutorials/Unit_testing">单元测试</a></dt>
+ <dd>使用SDK的测试框架书写和进行单元测试。</dd>
+ <dt><a href="/zh-CN/Add-ons/SDK/Tutorials/Chrome_authority">Chrome授权 </a></dt>
+ <dd>获得Components对象,使你的扩展程序能够加载和使用任何XPCOM对象。</dd>
+ <dt><a href="/zh-CN/Add-ons/SDK/Tutorials/Creating_event_targets">创建事件目标</a></dt>
+ <dd>使你定义的对象能够响应相关事件。</dd>
+</dl>
+</div>
+
+<div class="column-half">
+<dl>
+ <dt><a href="/zh-CN/Add-ons/SDK/Tutorials/Listening_for_load_and_unload">监听载入和卸载</a></dt>
+ <dd>当你的扩展程序被加载和卸载时获得通知,并从终端传递参数给扩展程序。</dd>
+ <dt><a href="/zh-CN/Add-ons/SDK/Tutorials/Add_a_Menu_Item_to_Firefox">使用第三方模块</a></dt>
+ <dd>安装和使用与SDK无关额外的模块</dd>
+ <dt><a href="/zh-CN/Add-ons/SDK/Tutorials/l10n">本地化</a></dt>
+ <dd>书写本地化代码.</dd>
+ <dt><a href="/zh-CN/Add-ons/SDK/Tutorials/Mobile_development">移动开发</a></dt>
+ <dd>为Andriod上的火狐浏览器开发扩展程序。</dd>
+ <dt><a href="/zh-CN/Add-ons/Add-on_Debugger">扩展调试</a></dt>
+ <dd>调试扩展应用的JavaScript。</dd>
+</dl>
+</div>
+</div>
+
+<hr>
+<h3 id="打包"><a name="putting-it-together">打包</a></h3>
+
+<div class="column-container">
+<div class="column-half">
+<dl>
+ <dt><a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Annotator">扩展应用:Annotator</a></dt>
+ <dd>一起开发一个相对复杂的扩展应用。</dd>
+</dl>
+</div>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/installation/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/installation/index.html
new file mode 100644
index 0000000000..4313836979
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/installation/index.html
@@ -0,0 +1,135 @@
+---
+title: 安装
+slug: Mozilla/Add-ons/SDK/Tutorials/Installation
+tags:
+ - cfx安装
+ - 配置cfx环境
+translation_of: Mozilla/Add-ons/SDK/Tools/jpm#Installation
+---
+<h2 id="先决条件">先决条件</h2>
+
+<p><span style="color: #ff0000;">请不要把任何相关的开发工具和扩展程序(命名推荐小写英文和数字,不推荐特殊符号等),放到有空格的目录(如Progaram Files\Python),会导致意想不到的错误,无法进行后续操作。(最新开发SDK可能修复了该错误,参见https://github.com/mozilla/addon-sdk/pull/1738)</span></p>
+
+<p>开发 Add-on SDK,你需要:</p>
+
+<ul>
+ <li>
+ <p><a href="http://www.python.org/">Python</a> 2.5,2.6 或 2.7。 <span class="short_text" id="result_box" lang="zh-CN"><span>需要注意的是在任何平台<span class="short_text" id="result_box" lang="zh-CN"><span>都是不支持</span></span></span></span> <span class="short_text" id="result_box" lang="zh-CN"><span>Python</span><span>3.x版本的</span></span> 。确保你已经安装过Python。</p>
+ </li>
+ <li>
+ <p>Firefox火狐浏览器(本教程针对最新的浏览器)。</p>
+ </li>
+ <li>
+ <p><span class="short_text" id="result_box" lang="zh-CN"><span>SDK本身</span><span>:</span><span>可以获取</span><span>SDK的最新</span><span>稳定版本</span><span>为</span></span> <a href="https://ftp.mozilla.org/pub/mozilla.org/labs/jetpack/jetpack-sdk-latest.tar.gz">tarball压缩包</a> 或 <a href="https://ftp.mozilla.org/pub/mozilla.org/labs/jetpack/jetpack-sdk-latest.zip">zip 文件</a>。</p>
+ </li>
+</ul>
+
+<p>另外,<span class="short_text" id="result_box" lang="zh-CN"><span>你</span><span>可以从它</span><span>的<a href="https://github.com/mozilla/addon-sdk">GitHub repository</a></span><span>库中</span><span>得到最新的</span><span>开发版本</span></span>。</p>
+
+<h2 id="为AMO开发扩展">为AMO开发扩展</h2>
+
+<p>如果提交到AMO只有最新发布或许使用。</p>
+
+<p class="ordinary-output target-output"><span>git</span><span> archive </span><span>需要扩展</span><span>一些Git</span><span>属性</span><span>占位符</span><span>。</span></p>
+
+<pre class="language-html">git checkout 1.16
+
+git archive 1.16 python-lib/cuddlefish/_version.py | tar -xvf -</pre>
+
+<h2 id="通过Homebrew自动安装到Mac_OS_X">通过Homebrew自动安装到Mac OS X</h2>
+
+<p><span class="short_text" id="result_box" lang="zh-CN"><span>使用以下命令</span><span>通过</span></span> <a href="http://brew.sh/">homebrew</a><span class="short_text" id="result_box" lang="zh-CN"><span>来安装</span><span>SDK<span class="short_text" id="result_box" lang="zh-CN"><span><span class="short_text" id="result_box" lang="zh-CN"><span>插件</span></span></span></span>工具:</span></span></p>
+
+<pre>brew install mozilla-addon-sdk</pre>
+
+<h2 id="安装到Mac_OS_XLinux">安装到Mac OS X/Linux</h2>
+
+<p><span class="short_text" id="result_box" lang="zh-CN"><span><span class="short_text" id="result_box" lang="zh-CN"><span>无论你</span><span>选择哪个方式都要</span></span>解压缩</span><span>文件的内容</span><span>作为根路径,</span><span>并通过</span><span>shell</span><span>/</span><span>命令提示符切换到</span><span>SDK的</span><span>根目录下</span><span>。</span><span>例如:</span></span></p>
+
+<pre>tar -xf addon-sdk.tar.gz
+cd addon-sdk
+</pre>
+
+<p>如果你是<span class="short_text" id="result_box" lang="zh-CN"><span>Bash的</span><span>用户,则继续运行</span></span>(大多数人都是的):</p>
+
+<pre>source bin/activate
+</pre>
+
+<p><span class="short_text" id="result_box" lang="zh-CN"><span>如果你是</span><span>一个非</span><span>Bash的</span><span>用户</span><span>,</span><span>你应该运行</span><span>:</span></span></p>
+
+<pre>bash bin/activate
+</pre>
+
+<p><span class="short_text" id="result_box" lang="zh-CN"><span>命令提示符</span><span>现在应该</span><span>有一个包含</span><span>SDK的</span><span>根</span><span>目录名称</span><span>的新的前缀</span><span>:</span></span></p>
+
+<pre>(addon-sdk)~/mozilla/addon-sdk &gt;
+</pre>
+
+<h2 id="安装到Windows">安装到Windows</h2>
+
+<p>同样解压缩文件,并通过命令符进入到SDK根目录下,例如:</p>
+
+<pre>7z.exe x addon-sdk.zip
+cd addon-sdk
+</pre>
+
+<p>接着运行激活命令:</p>
+
+<pre>bin\activate
+</pre>
+
+<p><span class="short_text" id="result_box" lang="zh-CN"><span>同样可以看到命令提示符</span><span>现在应该</span><span>有一个包含</span><span>SDK的</span><span>根</span><span>目录名称</span><span>的<span class="short_text" id="result_box" lang="zh-CN"><span>新的</span></span>前缀</span><span>:</span></span></p>
+
+<pre>(C:\Users\mozilla\sdk\addon-sdk) C:\Users\Work\sdk\addon-sdk&gt;
+</pre>
+
+<h2 id="SDK_的虚拟环境">SDK 的虚拟环境</h2>
+
+<p><span id="result_box" lang="zh-CN"><span><span id="result_box" lang="zh-CN"><span>当命令</span><span>提示符</span></span>出现新的</span><span>前缀</span><span>表明</span><span>你的</span><span>已经搭建好了SDK的</span><span>运行环境</span><span>,那么你就可以使用</span><span>Add</span><span class="atn">-</span><span>on SDK来开发</span><span>的</span><span>命令行工具</span><span>。</span></span></p>
+
+<p>任何时候,你都可以通过运行 <code>deactivate 命令停用虚拟环境</code>.</p>
+
+<p class="ordinary-output target-output"><span>配置好的虚拟环境是特定于这个特定的命令提示符。</span><span>如果您关闭命令提示符, 它会关闭运行环境,你需要<code>source bin/activate</code>或<code> bin\activate 在</code>一个新的命令提示符重新激活它。</span><span>如果你</span><span>打开一个新命令提示符</span><span>,</span><span id="result_box" lang="zh-CN"><span>SDK将</span><span>不会被激活</span><span>在新的提示</span></span><span>。</span></p>
+
+<p><span id="result_box" lang="zh-CN"><span>可以</span><span>将SDK</span><span>的多个副本</span><span>拷贝在</span><span>磁盘上的</span><span>不同位置</span><span>,并</span><span>在它们之间切换</span><span>,甚至可以</span><span>让他们<span id="result_box" lang="zh-CN"><span>同时</span><span>激活</span></span>运行在</span><span>不同的命令</span><span>提示</span><span>符</span><span>。</span></span></p>
+
+<h3 id="制作启动项">制作启动项</h3>
+
+<p><span id="result_box" lang="zh-CN"><span>所有 </span><code>activate </code><span>的作用是通过设置环境变量,<span id="result_box" lang="zh-CN"><span>使位于</span><span>顶层</span><code> bin </code><span>目录下</span><span>的脚本</span></span></span><span> </span><span>位于当前命令符下</span><span>,制作的启动项 ,</span><span>通过永久</span><span>环境中的这些</span><span>变量</span><span>设置,以便</span><span>每一个新的</span><span>命令提示符下</span><span>都能读取它们</span><span>。</span><span>那么</span><span>就不需要每次都去打开新的命令提示符来激活</span><span><code> activate </code>。</span></span></p>
+
+<p class="ordinary-output target-output"><span>因为变量精确设置可能随SDK发布新版本的变化,所以最好是指激活脚本来确定哪些变量需要设置。</span><span>激活</span><span>使用不同的</span><span>脚本</span><span>设置</span><span>bash</span><span>环境</span><span>不同的变量</span><span>(</span><span>Linux</span><span>和</span><span>MAC</span><span> OS X</span><span>和Windows</span><span>环境</span><span>)</span><span>。</span></p>
+
+<h4 id="Windows">Windows</h4>
+
+<p><span id="result_box" lang="zh-CN"><span>在Windows上,</span><span>使用</span><span> <code>bin\activate\</code><code>activate.bat</code></span><span>批处理脚本,也可以</span><span>使用命令行</span><code>setx</code><span>工具或</span><span>控制面板</span><span>激活</span><span>永久</span><span>使用</span><span>。</span></span></p>
+
+<h4 id="LinuxMac_OS_X">Linux/Mac OS X</h4>
+
+<p>在 Linux 和 Mac OS X,<span id="result_box" lang="zh-CN"><span>使用</span></span><code>source bin/activate</code>/<code>activate</code> bash 脚本, 你可以 <code>~/.bashrc</code> ( Linux) <code>或~/.bashprofile</code> (Mac OS X) 来激活。</p>
+
+<p><span class="short_text" id="result_box" lang="zh-CN"><span>作为替代</span><span>,你</span><span>可以在</span><code> ~/bin </code><span class="hps">目录中</span><span>创建到</span><span>cfx </span><span>程序</span><span>的符号链接</span><span>:</span></span></p>
+
+<pre>ln -s PATH_TO_SDK/bin/cfx ~/bin/cfx
+</pre>
+
+<h2 id="完整性检查"><span class="short_text" id="result_box" lang="zh-CN"><span>完整性检查</span></span></h2>
+
+<p><span class="short_text" id="result_box" lang="zh-CN"><span>在shell提示符</span></span>运行:</p>
+
+<pre>cfx
+</pre>
+
+<p>它会产生下面信息,这里是第一行内容,后面<span>是</span><span>大量的</span><span>使用信息</span><span>:</span></p>
+
+<pre>Usage: cfx [options] [command]
+</pre>
+
+<p><span id="result_box" lang="zh-CN"><span>这是</span></span> <a href="/en-US/Add-ons/SDK/Tools/cfx"><span id="result_box" lang="zh-CN"><span>CFX</span><span>命令行程序</span></span></a>, <span id="result_box" lang="zh-CN"><span>是</span><span>主</span><span>界面</span><span>加载项</span><span>的SDK</span></span>,<span id="result_box" lang="zh-CN"><span>可以使用</span><span>它来</span><span>启动Firefox</span><span>和测试</span><span>插件,</span><span>打包</span><span>附加</span><span>分发</span><span>,查看</span><span>​​文档和</span><span>运行单元测试</span><span>。</span></span></p>
+
+<h2 id="出现问题">出现问题?</h2>
+
+<p>尝试通过<a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Troubleshooting">故障排除页面</a>来解决遇到的问题。</p>
+
+<h2 id="下一步">下一步</h2>
+
+<p>接下来, 开始学习 <a href="/en-US/Add-ons/SDK/Tutorials/Getting_Started_With_cfx">cfx</a> 教程, <span class="short_text" id="result_box" lang="zh-CN"><span>其中</span><span>介绍了如何</span><span>使用</span><span>CFX的</span><span>工具来创建</span><span>附加组件</span><span>。</span></span></p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/l10n/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/l10n/index.html
new file mode 100644
index 0000000000..5083be5b5c
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/l10n/index.html
@@ -0,0 +1,381 @@
+---
+title: Localization
+slug: Mozilla/Add-ons/SDK/Tutorials/l10n
+tags:
+ - Add-on SDK
+ - 本地化
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/l10n
+---
+<p>该SDK支持本地化字符串出现在:</p>
+
+<ul>
+ <li><a href="/en-US/Add-ons/SDK/Tutorials/l10n#Using_Localized_Strings_in_JavaScript">你的主附加组件Add-on的 JavaScript代码</a></li>
+ <li><a href="/en-US/Add-ons/SDK/Tutorials/l10n#Using_Localized_Strings_in_HTML">你的附加组件一起打包的HTML文件</a></li>
+ <li><a href="/en-US/Add-ons/SDK/Tutorials/l10n#Using_Localized_Strings_in_Preferences">你的附加组件首选项中的 title 标题和 description 描述域</a></li>
+</ul>
+
+<p>目前为止还不支持本地化CSS和content scripts。</p>
+
+<h2 id="本地化字符串">本地化字符串</h2>
+
+<p>翻译后的字符串都保存在你的add-on扩展目录下一个名为 "locale"的目录 ,每个本地化地域对应一个文件。这些文件:</p>
+
+<ul>
+ <li>使用文件<a href="http://en.wikipedia.org/wiki/.properties"><code>.properties</code> 格式</a></li>
+ <li>被命名为 "xx-YY.properties", 这里的 "xx-YY" 是 <a href="https://wiki.mozilla.org/L10n:Locale_Codes"> </a> <a href="https://wiki.mozilla.org/L10n:Locale_Codes">name of the locale(本地化区域的名称)</a></li>
+ <li>包含所有你想要本地化的字符串,其中由一个本地化字符串标识ID和对应的本地化翻译字符串以 <code>"标识ID=本地化翻译的字符串</code>" 的格式组成。(contain one entry for each string you want to localize, consisting of an identifier for the string and its translation in that locale, in the format <code>identifier=translation</code>.)</li>
+ <li>需要使用没有BOM的UTF-8格式来编码(need to use UTF-8 without BOM encoding)</li>
+</ul>
+
+<p>假设你的附加组件包含一个单一的本地化字符串,用英语表示为“Hello!”,你想提供英语和法语的本地化支持。</p>
+
+<p>你需要添加两个文件到"locale"目录:</p>
+
+<pre>my-addon/
+ data
+ lib
+ locale/
+ en-US.properties
+ fr-FR.properties
+</pre>
+
+<p>"en-US.properties" 文件中内容:</p>
+
+<pre>hello_id= Hello!
+</pre>
+
+<p>"fr-FR.properties" 文件中内容:</p>
+
+<pre>hello_id= Bonjour !
+</pre>
+
+<p>现在,每当你的JavaScript或HTML向本地化系统请求hello_id标识的翻译,它将获得与当前区域语言一致的翻译。</p>
+
+<h2 id="在HTML中使用本地化字符串">在HTML中使用本地化字符串</h2>
+
+<div class="note">
+<p>本例使用的 <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action">action button</a> API需要 Firefox 29 或者更高版本。</p>
+</div>
+
+<p>要从HTML中引用本地化字符串,需要添加一个 <code>data-l10n-id</code> 的属性,到你想本地化的字符串所属的HTML标签中,然后为该属性指定一个ID值(To reference localized strings from HTML, add a <code>data-l10n-id</code> attribute to the HTML tag where you want the localized string to appear, and assign the identifier to it):</p>
+
+<pre class="brush: html">&lt;html&gt;
+  &lt;body&gt;
+    &lt;h1 data-l10n-id="hello_id"&gt;&lt;/h1&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
+</pre>
+
+<p>然后你就可以使用这个HTML文件来建立你的界面, 比如插入一个 panel 面板:</p>
+
+<pre class="brush: js">var button = require("sdk/ui/button/action").ActionButton({
+  id: "localized-hello",
+  label: "Localized hello",
+  icon: "./icon-16.png",
+  onClick: function() {
+    hello.show();
+  }
+});
+
+var hello = require("sdk/panel").Panel({
+  height: 75,
+  width: 150,
+  contentURL: require("sdk/self").data.url("my-panel.html")
+});</pre>
+
+<p>“en-US”和“fr-FR”提供了翻译标识为hello_id字符串的本地化文件,面板将根据当前区域语言设置,显示“Hello!”或者“Bonjour!”:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/7663/bonjour.png" style="width: 255px; height: 160px;"><img alt="" src="https://mdn.mozillademos.org/files/7665/hello.png" style="width: 255px; height: 160px;"></p>
+
+<p>翻译文本会插入到具有data-l10n-id属性集的节点中。任何之前存在的内容只是被替换掉了。(The translation is inserted into the node which has the <code>data-l10n-id</code> attribute set. Any previously existing content is just replaced.)</p>
+
+<p>本地化字符串只能作为text文本插入, 所以你不能使用下面的语句插入HTML:</p>
+
+<pre>hello_id= &lt;blink&gt;Hello!&lt;/blink&gt;
+</pre>
+
+<h3 id="Localizing_Element_Attributes">Localizing Element Attributes</h3>
+
+<div class="geckoVersionNote">这是 Firefox 39 上的新功能</div>
+
+<p><br>
+ 你可以在properties文件中,通过设置 l10n-id.attributeName 的值,本地化某些具有 l10n-id属性的元素的属性值。像这样(You can localize certain attributes of elements with an l10n-id by setting its value with l10n-id.attributeName in the properties file like):<br>
+  </p>
+
+<pre>hello_id.accesskey= H</pre>
+
+<p>可以支持以下几个属性:</p>
+
+<ul>
+ <li><strong>accesskey</strong></li>
+ <li><strong>alt</strong></li>
+ <li><strong>label</strong></li>
+ <li><strong>title</strong></li>
+ <li><strong>placeholder</strong></li>
+</ul>
+
+<p>更多的<a href="/en-US/docs/Web/Accessibility/ARIA"> ARIA</a> 属性<strong>aria-label</strong>, <strong>aria-valuetext</strong> 和 <strong>aria-moz-hint</strong> 的本地化将通过在Firefox OS上同样的别名被支持(Further the localization of the <a href="/en-US/docs/Web/Accessibility/ARIA">ARIA</a> attributes <strong>aria-label</strong>, <strong>aria-valuetext</strong> and <strong>aria-moz-hint</strong> are supported with the same aliases as on Firefox OS):</p>
+
+<ul>
+ <li><strong>ariaLabel</strong></li>
+ <li><strong>ariaValueText</strong></li>
+ <li><strong>ariaMozHint</strong></li>
+</ul>
+
+<h2 id="在JavaScript代码中使用本地化字符串">在JavaScript代码中使用本地化字符串</h2>
+
+<p>为了在主附加组件代码中引用本地化字符串,你需要这样做:</p>
+
+<pre class="brush: js">var _ = require("sdk/l10n").get;
+console.log(_("hello_id!"));</pre>
+
+<p><span>指定的 "_" 并不是必需的,但是作为<a href="https://www.gnu.org/software/gettext/gettext.html"> gettext </a>工具的默认约定,这能更好的配合其他默认使用 "_" 来表示本地化字符串的现有工具。</span></p>
+
+<ol>
+ <li>导入 <code>l10n</code> 模块,然后指定 "_" (下划线)为模块的 <code>get</code> 函数。</li>
+ <li>把所有涉及本地化的字符串放到 <code>_()</code> 函数中包括起来。</li>
+</ol>
+
+<p>如果你运行它,你会看到输出为预期的当前设置的区域语言:</p>
+
+<pre>info: Hello!
+</pre>
+
+<pre>info: Bonjour !
+</pre>
+
+<p>注意你不能在content scripts中 <code>require()</code> 一个模块,所以目前还不能在content script 中引用本地化字符串。</p>
+
+<h3 id="复数">复数</h3>
+
+<p> <code>l10n</code> 模快支持复数形式,不同的语言有不同的复数形态。例如,英语有两种形式:相对于"one"的单数形式,和对于"everything else, including zero"的复数形式:</p>
+
+<pre>one tomato
+no tomatoes
+two tomatoes
+</pre>
+
+<p>但是俄罗斯语对于以 1 结尾(除了11)的数字、以 2-4 结尾(除了12-14)的数字和其他数字,有着不同的复数形态:</p>
+
+<pre>один помидор // one tomato
+два помидора // two tomatoes
+пять помидоров // five tomatoes
+</pre>
+
+<p>SDK使用 <a href="http://cldr.unicode.org/index">Unicode CLDR</a> 数据描述由不同的语言使用的不同复数形式。</p>
+
+<h4 id="Unicode_CLDR_复数形式">Unicode CLDR 复数形式</h4>
+
+<p>Unicode CLDR项目定义了用于描述一个特定语言的多个规则的一种方案。在这个方案中一种语言对应最多有六种不同的范围的数字,有以下类别区分:<em>zero(零个),one(一个),two(两个),few(几个),many(很多),</em>和<em>other(其他)</em>。(The Unicode CLDR project defines a scheme for describing a particular language's plural rules. In this scheme a language maps each distinct range of numbers on to one of up to six forms, identified by the following categories: <em>zero</em>, <em>one</em>, <em>two</em>, <em>few</em>, <em>many</em>, and <em>other</em>.)</p>
+
+<p>英语有两种复数形式,可以表示为 "1" 映射到 "one" 和 "everything else" 映射到 "other"的形式(English has two forms, which can be described by mapping "1" to "one" and "everything else" to "other"):</p>
+
+<pre>one → n is 1;
+other → everything else
+</pre>
+
+<p>俄罗斯语有四种形式,可以使用以下方式表示:</p>
+
+<pre>one → n mod 10 is 1 and n mod 100 is not 11;
+few → n mod 10 in 2..4 and n mod 100 not in 12..14;
+many → n mod 10 is 0 or n mod 10 in 5..9 or n mod 100 in 11..14;
+other → everything else
+</pre>
+
+<p>所有语言的多个规则可以在CLDR的 <a href="http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html">语言复数规则</a> 页面查到 (即使这个规则表相对于 <a href="http://unicode.org/repos/cldr/trunk/common/supplemental/plurals.xml">CLDR XML source</a> 已经过时了).</p>
+
+<h4 id="SDK中的复数形式">SDK中的复数形式</h4>
+
+<p>代码中,在 <code>_()</code>函数中的本地化ID参数之后提供一个额外的参数,用来表示代表多少个项的本地化字符串(In the code, you supply an extra parameter alongside the identifier, describing how many items there are):</p>
+
+<pre class="brush: js">var _ = require("sdk/l10n").get;
+console.log(_("tomato_id"));
+console.log(_("tomato_id", 1));
+console.log(_("tomato_id", 2));
+console.log(_("tomato_id", 5));
+console.log(_("tomato_id", .5));</pre>
+
+<p>在 <code>.properties</code> 文件中通过使用 CLDR 关键字,对于每种语言可能的复数形式你可以自定义不同的本地化字符串。所以对于英语可以有两种本地化(注意"other" 分类不是 CDLR 关键字)。(In the <code>.properties</code> file for each language you can define a different localization for each plural form possible in that language, using the CLDR keywords. So in English we could have two plural localizations (note that the "other" category does <strong>not</strong> take the CLDR keyword))</p>
+
+<pre># en-US translations
+tomato_id[one]= %d tomato
+tomato_id= %d tomatoes
+</pre>
+
+<p>俄罗斯语中可以定义四种本地化的复数形式:</p>
+
+<pre># ru-RU translations
+tomato_id[one]= %d помидор
+tomato_id[few]= %d помидора
+tomato_id[many]= %d помидоров
+tomato_id= %d помидоры
+</pre>
+
+<p>The localization module itself understands the CLDR definitions for each language, enabling it to map between, for example, "2" in the code and "few" in the <code>ru-RU.properties</code> file. Then it retrieves and returns the localization appropriate for the count you supplied.</p>
+
+<h3 id="Placeholders">Placeholders</h3>
+
+<p>The <code>l10n</code> module supports placeholders, allowing you to insert a string which should not be localized into one which is. The following "en-US" and "fr-FR" ".properties" files include placeholders:</p>
+
+<pre># en-US translations
+hello_id= Hello %s!
+</pre>
+
+<pre># fr-FR translations
+hello_id= Bonjour %s !
+</pre>
+
+<p>To use placeholders, supply the placeholder string after the identifier:</p>
+
+<pre class="brush: js">var _ = require("sdk/l10n").get;
+console.log(_("hello_id", "Bob"));
+console.log(_("hello_id", "Alice"));</pre>
+
+<p>In the "en-US" locale, this gives us:</p>
+
+<pre>info: Hello Bob!
+info: Hello Alice!
+</pre>
+
+<p>In "fr-FR" we get:</p>
+
+<pre>info: Bonjour Bob !
+info: Bonjour Alice !
+</pre>
+
+<h3 id="Ordering_Placeholders">Ordering Placeholders</h3>
+
+<p>When a localizable string can take two or more placeholders, translators can define the order in which placeholders are inserted, without affecting the code.</p>
+
+<p>Primarily, this is important because different languages have different rules for word order. Even within the same language, though, translators should have the freedom to define word order.</p>
+
+<p>For example, suppose we want to include a localized string naming a person's home town. There are two placeholders: the name of the person and the name of the home town:</p>
+
+<pre class="brush: js">var _ = require("sdk/l10n").get;
+console.log(_("home_town_id", "Bob", "London"));</pre>
+
+<p>An English translator might want to choose between the following:</p>
+
+<pre>"&lt;town_name&gt; is &lt;person_name&gt;'s home town."
+</pre>
+
+<pre>"&lt;person_name&gt;'s home town is &lt;town_name&gt;"
+</pre>
+
+<p>To choose the first option, the <code>.properties</code> file can order the placeholders as follows:</p>
+
+<pre>home_town_id= %2s is %1s's home town.
+</pre>
+
+<p>This gives us the following output:</p>
+
+<pre>info: London is Bob's home town.
+</pre>
+
+<h2 id="在首选项设置中的本地化字符串">在首选项设置中的本地化字符串</h2>
+
+<p>通过加入一个 <a href="/en-US/Add-ons/SDK/High-Level_APIs/simple-prefs">"preferences" 字段的结构到你的附加组件的 "package.json" 文件</a>中,你可以为你的附加组件定义首选项选项,用户可以在Firefox的 <a href="https://support.mozilla.org/en-US/kb/Using%20extensions%20with%20Firefox#w_how-to-change-extension-settings">Add-ons Manager</a> 看到和编辑它。</p>
+
+<p>Preferences (首选项)有一个必需的title标题项和一个可选的description描述项 这些字符串将出现在 Add-ons Manager中,来帮助向用户解释各个首选项设置的意义。</p>
+
+<ul>
+ <li>
+ <p>要对preferences中的title标题部分进行本地化,所有在"properties"文件中,形式为preferences中的name后面接着 <code>_title</code> 的本地化标识ID,其对应的值就是标题的本地化字符串。(To provide the localized form of the preference title, include an entry in your "properties" file whose identifier is the preference name followed by <code>_title</code>, and whose value is the localized title.)</p>
+ </li>
+ <li>
+ <p>要对preferences中的description描述部分进行本地化,所有在"properties"文件中,形式为preferences中的name后面接着 <code>_description</code> 的本地化标识ID,其对应的值就是描述的本地化字符串。(To provide the localized form of the preference description, include an entry in your "properties" file whose identifier is the preference name followed by <code>_description</code>, and whose value is the localized description.)</p>
+ </li>
+</ul>
+
+<p>例如, 假设你的 "package.json" 中只定义了一个设置选项:</p>
+
+<pre>{
+ "preferences": [
+ {
+ "type": "string",
+ "name": "monster_name",
+ "value": "Gerald",
+ "title": "Name"
+ }
+ ],
+ "name": "monster-builder",
+ "license": "MPL 2.0",
+ "author": "me",
+ "version": "0.1",
+ "fullName": "Monster Builder",
+ "id": "monster-builder@me.org",
+ "description": "Build your own monster"
+}
+</pre>
+
+<p>在你的"en-US.properties"文件中, 应该包括下面两个项:</p>
+
+<pre>monster_name_title= Name
+monster_name_description= What is the monster's name?
+</pre>
+
+<p>在你的"fr-FR.properties"文件中, 应该包括下面两个法语的翻译项:</p>
+
+<pre>monster_name_title= Nom
+monster_name_description= Quel est le nom du monstre ?
+</pre>
+
+<p>现在,当浏览器的区域设置为 "en-US", 用户会在 Add-ons Manager看到这样:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/6525/preference-us.png" style="width: 571px; height: 77px;"></p>
+
+<p>当浏览器区域设置为 "fr-FR", 用户会看到:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/6523/preference-french.png"></p>
+
+<p>下拉菜单<code>menulist</code>和单选按钮<code>radio</code>的类型有多个选项,每一个选项的标签属性都会展示给用户。如果本地化文件中有一项是以前缀是"{name} _options" 为键的键值对,其中"{name}"是选项的标签名字,该键值对的值就是一个选项标签的本地化字符串。(The <code>menulist</code> and the <code>radio</code> preference types have options. The <code>label</code> attribute of each option is displayed to the user. If the locale file has a entry with the value of the <code>label</code> attribute prefixed with "{name}_options." as its key, where {name} is the name of the preference, its value is used as a localized label.)</p>
+
+<h2 id="Using_Identifiers">Using Identifiers</h2>
+
+<p>If the localization system can't find an entry for a particular identifier using the current locale, then it just returns the identifier itself.</p>
+
+<p>This has the nice property that you can write localizable, fully functional add-ons without having to write any locale files. You can just use the default language strings as your identifier, and subsequently supply <code>.properties</code> files for all the additional locales you want to support.</p>
+
+<p>For example, in the case above you could use "Hello!" as the identifier, and just have one <code>.properties</code> file for the "fr-FR" locale:</p>
+
+<pre>Hello!= Bonjour !
+</pre>
+
+<p>Then when the locale is "en-US", the system would fail to find a <code>.properties</code> file, and return "Hello!".</p>
+
+<p>However, this approach makes it difficult to maintain an add-on which has many localizations, because you're using the default language strings both as user interface strings and as keys to look up your translations. This means that if you want to change the wording of a string in the default language, or fix a typo, then you break all your locale files.</p>
+
+<h2 id="Locale_Updater">Locale Updater</h2>
+
+<p>The <a href="https://github.com/downloads/ochameau/locale-updater/locale-updater.xpi">locale updater</a> add-on makes it easier to update locale files. Once you've installed it, open the Add-on Manager, and you'll see a see a new button labeled "Update l10n" next to each add-on you've installed:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/6515/locale-updater.png"></p>
+
+<p>Click the button and you'll be prompted for a new <code>.properties</code> file for that add-on. If you provide a new file, the add-on's locale data will be updated with the new file.</p>
+
+<h2 id="Limitations">Limitations</h2>
+
+<p>The current localization support is a first step towards full support, and contains a number of limitations.</p>
+
+<ul>
+ <li>
+ <p>There's no support for content scripts or CSS files: at the moment, you can only localize strings appearing in JavaScript files that can <code>require()</code> SDK modules and in HTML.</p>
+ </li>
+ <li>
+ <p>The set of locale files is global across an add-on. This means that a module isn't able to override a more general translation: so a module <code>informal.js</code> can't specify that "hello_id" occurring in its code should be localized to "Hi!".</p>
+ </li>
+ <li>
+ <p>The SDK tools compile the locale files into a JSON format when producing an XPI. This means that translators can't localize an add-on given the XPI alone, but must be given access to the add-on source.</p>
+ </li>
+ <li>
+ <p>The add-on developer must manually assemble the set of localizable strings that make up the locale files. In a future release we'll add a command to <code>cfx</code> that scans the add-on for localizable strings and builds a template <code>.properties</code> file listing all the strings that need to be translated.</p>
+ </li>
+</ul>
+
+<h2 id="See_Also_-_for_developers_looking_to_localize_non-SDK_add-ons">See Also - for developers looking to localize non-SDK add-ons</h2>
+
+<ul>
+ <li>How to localize html pages, xul files, and js/jsm files from bootstrapped add-ons: <a href="/en-US/Add-ons/Bootstrapped_extensions#Localization_%28L10n%29">Bootstrapped Extensions :: Localization (L10n)</a></li>
+ <li>XUL School Localization Tutorial: <a href="/en-US/docs/Mozilla/Tech/XUL/Tutorial/Localization">DTD/Entities method</a> and <a href="/en-US/docs/Mozilla/Tech/XUL/Tutorial/Property_Files">Properties method</a></li>
+ <li><a href="/en-US/docs/Mozilla/Localization/Localizing_an_extension">Localizing an extension</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/list_open_tabs/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/list_open_tabs/index.html
new file mode 100644
index 0000000000..8a4985806e
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/list_open_tabs/index.html
@@ -0,0 +1,72 @@
+---
+title: 列出打开的标签页
+slug: Mozilla/Add-ons/SDK/Tutorials/List_Open_Tabs
+tags:
+ - Add-on SDK
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/List_Open_Tabs
+---
+<p>{{AddonSidebar}}</p>
+
+<div class="note">
+<p><span>学习本教程之前你需要学习 <a href="/en-US/docs/Mozilla/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29"><code>jpm</code> 基础</a>。</span></p>
+</div>
+
+<p>列出打开的标签页,你可以遍历 <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs"><code>tabs</code></a> 对象本身。</p>
+
+<p>下面的 add-on 添加一个 <a href="/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action">action button</a> 当用户单击该按钮时,该日志将在打开的标签页中记录:</p>
+
+<pre class="brush: js">require("sdk/ui/button/action").ActionButton({
+ id: "list-tabs",
+ label: "List Tabs",
+ icon: "./icon-16.png",
+ onClick: listTabs
+});
+
+function listTabs() {
+ var tabs = require("sdk/tabs");
+ for (let tab of tabs)
+ console.log(tab.url);
+}
+</pre>
+
+<div class="note">
+<p>注意:为此你需要一个按钮图标,以"icon-16.png"的文件名保存到你的 add-on 的"data"目录下。你可以从这里下载图标:<img alt="" src="https://mdn.mozillademos.org/files/7649/icon-16.png" style="height: 16px; width: 16px;">。</p>
+</div>
+
+<p>运行该 add-on,加载一对标签页,并点击按钮,你会看到在<a href="/en-US/Add-ons/SDK/Tutorials/Logging">控制台</a>输出如下的内容:</p>
+
+<pre>info: http://www.mozilla.org/en-US/about/
+info: http://www.bbc.co.uk/
+</pre>
+
+<div class="warning">
+<p>你不能直接访问到标签页中的任何宿主内容(具体概念请查阅相关内容:<span class="tcnt">JavaScript 本地对象、内置对象、宿主对象</span> )。</p>
+
+<p>为了访问标签页的内容,你需要使用 tab.attach() 添加一个脚本,此 add-on 加载加载一个页面,然后将一个脚本附加到所有打开的标签页,该脚本将向标签页的文档添加红色边框:</p>
+</div>
+
+<pre class="brush: js">require("sdk/ui/button/action").ActionButton({
+ id: "list-tabs",
+ label: "List Tabs",
+ icon: "./icon-16.png",
+ onClick: listTabs
+});
+
+function listTabs() {
+ var tabs = require("sdk/tabs");
+ for (let tab of tabs)
+ runScript(tab);
+}
+
+function runScript(tab) {
+ tab.attach({
+ contentScript: "document.body.style.border = '5px solid red';"
+ });
+}
+</pre>
+
+<h2 id="学习更多">学习更多</h2>
+
+<p>要了解更多关于SDK中标签如何工作, 查看 <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs"><code>tabs</code> API reference</a>。</p>
+
+<p>要了解更多关于在标签中运行脚本, 查看 <a href="/en-US/Add-ons/SDK/Tutorials/Modifying_the_Page_Hosted_by_a_Tab">tutorial on using <code>tab.attach()</code></a>。</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/listen_for_page_load/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/listen_for_page_load/index.html
new file mode 100644
index 0000000000..815cfd42c5
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/listen_for_page_load/index.html
@@ -0,0 +1,42 @@
+---
+title: 监听页面加载
+slug: Mozilla/Add-ons/SDK/Tutorials/Listen_for_Page_Load
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/Listen_for_Page_Load
+---
+<p>{{AddonSidebar}}</p>
+
+<div class="note"><span>学习本教程之前你需要了解 <a href="/en-US/docs/Mozilla/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29"><code>jpm</code> 基础</a>。</span></div>
+
+<p>你可以使用 <a href="/zh-CN/Add-ons/SDK/High-Level_APIs/tabs"><code>tabs</code></a> 模块来获取关于新页面加载的通知。下面的附加组件监听标签页内建的 <code>ready</code> 事件,并且记录下每一个标签加载时的URL:</p>
+
+<pre class="brush: js">require("sdk/tabs").on("ready", logURL);
+
+function logURL(tab) {
+ console.log(tab.url);
+}
+</pre>
+
+<div class="note">
+<p>你会在<a href="/zh-CN/docs/Tools/Browser_Console">浏览器控制台</a>,而非 <a href="/zh-CN/docs/Tools/Web_Console">Web 控制台</a>中,找到这些输出的内容。</p>
+</div>
+
+<p>你不能直接访问标签页里面的内容。</p>
+
+<p>为了访问标签页内容,你需要使用 <code>tab.attach()</code> 把一个脚本附到标签页上。这个示例给每一个打开后的标签页附上了一个脚本。这个脚本给标签页的 document 加上了一个红色边框:</p>
+
+<pre class="brush: js">require("sdk/tabs").on("ready", runScript);
+
+function runScript(tab) {
+ tab.attach({
+ contentScript: "if (document.body) document.body.style.border = '5px solid red';"
+ });
+}
+</pre>
+
+<p>(本示例仅仅表示:可以像这样实现一些功能,而你应当使用 <a href="/zh-CN/Add-ons/SDK/High-Level_APIs/page-mod"><code>page-mod</code></a>,并且指定匹配模式为 "*"。)</p>
+
+<h2 id="了解更多">了解更多</h2>
+
+<p>想要了解更多关于如何在SDK中处理标签页的内容,请看 <a href="/zh-CN/Add-ons/SDK/High-Level_APIs/tabs"><code>tabs</code> API 参考</a>。你能够监听其他一些标签页事件,包括 <code>open</code>、<code>close</code>、和 <code>activate</code>。</p>
+
+<p>想要了解更多关于在标签页中运行脚本的事情,请看 <a href="/en-US/Add-ons/SDK/Tutorials/Modifying_the_Page_Hosted_by_a_Tab"><code>tab.attach() 使用教程</code></a>。</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/modifying_the_page_hosted_by_a_tab/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/modifying_the_page_hosted_by_a_tab/index.html
new file mode 100644
index 0000000000..5fd51fd8f7
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/modifying_the_page_hosted_by_a_tab/index.html
@@ -0,0 +1,109 @@
+---
+title: 修改标签页中页面
+slug: Mozilla/Add-ons/SDK/Tutorials/Modifying_the_Page_Hosted_by_a_Tab
+tags:
+ - Add-on SDK
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/Modifying_the_Page_Hosted_by_a_Tab
+---
+<div class="note">
+<p>为了进一步学习本教程,你需要安装 <a href="/en-US/Add-ons/SDK/Tutorials/Installation">Add-on SDK</a> 和学习 <a href="/en-US/Add-ons/SDK/Tutorials/Getting_Started_With_cfx">cfx的基本使用</a></p>
+
+<p>这篇教程使用<a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action">动作按钮</a>API,需要Firefox 29或更新版本。</p>
+</div>
+
+<p>为了修改特定标签页中的页面, 可以使用<code> <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/tabs">tab</a></code>对象的<code>attach()</code> 方法加载一个script脚本到页面中。因为他们的工作是和Web内容进行交互,所以这些脚本被称为content scripts(内容脚本)。</p>
+
+<p>这是个简单的示例:</p>
+
+<pre class="brush: js">var button = require("sdk/ui/button/action").ActionButton({
+  id: "style-tab",
+  label: "Style Tab",
+  icon: "./icon-16.png",
+  onClick: function() {
+    require("sdk/tabs").activeTab.attach({
+      contentScript: 'document.body.style.border = "5px solid red";'
+    });
+  }
+});</pre>
+
+<p>要运行这个示例你必须保存一个名为”icon-16.png“的图标文件在你的Add-on目录下的”data”目录下。你可以下载这个图标: <img alt="" src="https://mdn.mozillademos.org/files/7661/icon-16.png" style="width: 16px; height: 16px;">。</p>
+
+<p>这个插件创建一个按钮,其中包含Mozilla的图标作为一个图标。这个按钮产生一个点击事件处理程序,处理事件中将获取当前活动标签页和加载一个脚本到该标签页中的页面。使用<code>contentscript</code>选项指定加载的脚本,该脚本只绘制一个红色边框页。</p>
+
+<p>然后在浏览器窗口中打开任何网页,点击按钮 。你会看到一个红色的边界出现在页面中, 就像这样:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/6531/tabattach-bbc.png" style="display: block; margin-left: auto; margin-right: auto;"></p>
+
+<h2 id="保持Content_Script在一个单独的文件中">保持Content Script在一个单独的文件中</h2>
+
+<p>在上面的例子中我们的<code>content script</code>作为一个字符串来直接使用.除非脚本非常简单,你应该保持脚本作为一个单独的文件。这使得代码更容易维护、调试和审查。</p>
+
+<p>比如,我们把上面的脚本代码保存在Add-on目录下的data目录中并取名为<code>my-script.js</code>,在代码中可以这样加载脚本:</p>
+
+<pre class="brush: js">var self = require("sdk/self");
+
+var button = require("sdk/ui/button/action").ActionButton({
+  id: "style-tab",
+  label: "Style Tab",
+  icon: "./icon-16.png",
+  onClick: function() {
+    require("sdk/tabs").activeTab.attach({
+      contentScriptFile: self.data.url("my-script.js")
+    });
+  }
+});
+</pre>
+
+<p>你可以加载多个脚本,同时这些脚本可以直接相互作用。所以你可以加载 <a href="http://jquery.com/">jQuery</a>, 然后在你的其他 content script使用它。</p>
+
+<h2 id="与Content_Script传递信息">与Content Script传递信息</h2>
+
+<p>你的扩展插件脚本Add-on script和内容脚本content script 不能直接访问对方的变量和函数,但他们之间可以互相发送消息。</p>
+
+<p>从一方发送消息到另外一方, 发送方需要调用 <code>port.emit()发送消息,</code> 同时接收方使用<code>port.on()</code>接收消息。</p>
+
+<ul>
+ <li>在 content script 中, <code>port</code> 是全局对象 <code>self</code> 的属性之一.</li>
+ <li>在 content script 中, <code>tab.attach()</code> 返回一个其中包含 <code>port</code> 属性的 <a href="/en-US/Add-ons/SDK/Low-Level_APIs/content_worker">worker</a> 对象,你可以使用它来向 content script 发送消息</li>
+</ul>
+
+<p>让我们重写上面的例子来从附加内容脚本 content script 传递一个消息。现在content script 需要像下面这样:</p>
+
+<pre class="brush: js">// "self" is a global object in content scripts
+// Listen for a "drawBorder"
+self.port.on("drawBorder", function(color) {
+ document.body.style.border = "5px solid " + color;
+});
+</pre>
+
+<p>在 add-on script 扩展脚本中,我们使用 <code>attach()方法返回的对象向 content script</code> 中发送一个“drawBorder”消息:</p>
+
+<pre class="brush: js">var self = require("sdk/self");
+var tabs = require("sdk/tabs");
+
+var button = require("sdk/ui/button/action").ActionButton({
+  id: "style-tab",
+  label: "Style Tab",
+  icon: "./icon-16.png",
+  onClick: function() {
+    var worker = tabs.activeTab.attach({
+      contentScriptFile: self.data.url("my-script.js")
+    });
+    worker.port.emit("drawBorder", "red");
+  }
+});
+</pre>
+
+<p>名为 <code>drawBorder</code> 的消息并不是一个内置的消息, 而是通过 <code>port.emit()方法自定义的。</code></p>
+
+<h2 id="注入_CSS">注入 CSS</h2>
+
+<p>不像 <a href="/en-US/Add-ons/SDK/High-Level_APIs/page-mod"><code>page-mod</code></a> API, <code>tab.attach()</code> 不允许你直接注入CSS到页面中。</p>
+
+<p>你需要使用 JavaScript 来修改页面的样式,就像前面的示例那样。</p>
+
+<h2 id="学习更多">学习更多</h2>
+
+<p>要了解更多关于在SDK中标签页的使用, 可以查看<a href="/en-US/Add-ons/SDK/Tutorials/Open_a_Web_Page">打开一个网页</a>教程,  <a href="/en-US/Add-ons/SDK/Tutorials/List_Open_Tabs">列出打开的标签页</a>教程, 和<a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs"><code>tabs</code> API 参考手册</a>.</p>
+
+<p>要学习更多关于content scripts, 查看 <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts">content scripts guide</a>.</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/modifying_web_pages_based_on_url/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/modifying_web_pages_based_on_url/index.html
new file mode 100644
index 0000000000..6e5e46c532
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/modifying_web_pages_based_on_url/index.html
@@ -0,0 +1,210 @@
+---
+title: Modifying Web Pages Based on URL
+slug: Mozilla/Add-ons/SDK/Tutorials/Modifying_Web_Pages_Based_on_URL
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/Modifying_Web_Pages_Based_on_URL
+---
+<div class="note">开始本教程之前,您必须安装好 <em><strong>SDK</strong></em>,并且学习 <strong><em>cfx </em></strong>的基本的使用方法。</div>
+
+<p>要修改任何页面匹配特定的模式(比如,“http://example.org/”)当它们加载后,使用<a href="/en-US/Add-ons/SDK/High-Level_APIs/page-mod">page-mod</a>模块。</p>
+
+<p>要创建 <strong><em>page-mod</em></strong>,您必须指定两件事:</p>
+
+<ul>
+ <li>一个或多个 <em><strong>content scripts</strong></em> 运行,它们的工作将和网站内容进行交互</li>
+ <li>一个或多个 <strong><em>patterns</em> </strong>去匹配您要修改的页面的 URLs</li>
+</ul>
+
+<div class="note">
+<p>content scripts为内容脚本,只能使用普通浏览器支持的 JS,不能使用 add-on 的API</p>
+</div>
+
+<p>这里有一个范例。内容脚本提供contentScript选项,地址样本提供include选项:</p>
+
+<pre class="brush: js">// Import the page-mod API
+var pageMod = require("sdk/page-mod");
+
+// Create a page mod
+// It will run a script whenever a ".org" URL is loaded
+// The script replaces the page contents with a message
+pageMod.PageMod({
+ include: "*.org",
+ contentScript: 'document.body.innerHTML = ' +
+ ' "&lt;h1&gt;Page matches ruleset&lt;/h1&gt;";'
+});
+</pre>
+
+<p>试试吧:</p>
+
+<ul>
+ <li>创建新的目录并转到该目录下</li>
+ <li>运行 <code>cfx init</code></li>
+ <li>打开 <code>lib/main.js</code> 文件,添加以上的代码</li>
+ <li>运行 <code>cfx run</code></li>
+ <li>在打开的浏览器窗口中打开 <a href="http://www.ietf.org">ietf.org</a></li>
+</ul>
+
+<p>您将看到:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/6537/pagemod-ietf.png" style="display: block; margin-left: auto; margin-right: auto;"></p>
+
+<h2 id="指定匹配模式">指定匹配模式</h2>
+
+<p>匹配模式使用 <a href="/en-US/Add-ons/SDK/Low-Level_APIs/util_match-pattern"><code>match-pattern</code></a> 语法。您可以通过单一的匹配字符串,或者数组。</p>
+
+<h2 id="把内容脚本放在独立的文件中">把内容脚本放在独立的文件中</h2>
+
+<p>在上面的范例中我们通过字符串来实现内容脚本。除非是用作简单的例子,通常情况下您应该将内容脚本放在独立文件中,这将使您的代码更易维护、调式和查看。</p>
+
+<p>要这样做,您需要:</p>
+
+<ul>
+ <li>将脚本文件保存在 data 目录下</li>
+ <li>使用 <code>contentScriptFile</code> 选项代替 <code>contentScript 选项,并且指定脚本的路径</code>。路径用 <code>self.data.url()</code> 取得</li>
+</ul>
+
+<p>例如,如果我们将内容脚本保存在 data 目录下,命名为 my-script.js,在main.js中,我们应该这么写:</p>
+
+<pre class="brush: js">// Import the page-mod API
+var pageMod = require("sdk/page-mod");
+// Import the self API
+var self = require("sdk/self");
+
+// Create a page mod
+// It will run a script whenever a ".org" URL is loaded
+// The script replaces the page contents with a message
+pageMod.PageMod({
+ include: "*.org",
+ contentScriptFile: self.data.url("my-script.js")
+});</pre>
+
+<h2 id="加载多个Content_Scripts">加载多个Content Scripts</h2>
+
+<p>您可以加载更多脚本,且脚本可以相互交互。所以,您可以使用jQuery重写 my-script.js:</p>
+
+<pre class="brush: js">$("body").html("&lt;h1&gt;Page matches ruleset&lt;/h1&gt;");
+</pre>
+
+<p>然后下载 jQuery 库到您的扩展开发目录的 data 目录下,并且将 jQuery 和 my-script 一起加载(确保先加载 jQuery 库):</p>
+
+<pre class="brush: js">// Import the page-mod API,加载 add-on 的 page-mod API
+var pageMod = require("sdk/page-mod");
+// Import the self API, 加载 add-on 的 self API
+var self = require("sdk/self");
+
+// Create a page mod
+// It will run a script whenever a ".org" URL is loaded
+// The script replaces the page contents with a message
+// 创建 page mod,匹配 “.org” URL
+pageMod.PageMod({
+ include: "*.org",
+ contentScriptFile: [self.data.url("jquery-1.7.min.js"), self.data.url("my-script.js")]
+});
+</pre>
+
+<p>您也可以在同一 page-mod 中同时使用 <code>contentScript</code> 和 <code>contentScriptFile</code> 。如果您这么做的话,contentScript的脚本将会先加载。(应该是contentScriptFile的先加载吧?)</p>
+
+<pre class="brush: js">// Import the page-mod API
+var pageMod = require("sdk/page-mod");
+// Import the self API
+var self = require("sdk/self");
+
+// Create a page mod
+// It will run a script whenever a ".org" URL is loaded
+// The script replaces the page contents with a message
+pageMod.PageMod({
+ include: "*.org",
+ contentScriptFile: self.data.url("jquery-1.7.min.js"),
+ contentScript: '$("body").html("&lt;h1&gt;Page matches ruleset&lt;/h1&gt;");'
+});
+</pre>
+
+<p>注意,您不能直接加载网站上的脚本。脚本必须从 data 目录中加载。</p>
+
+<h2 id="与_Content_Script_通信">与 Content Script 通信</h2>
+
+<p>Your add-on script and the content script can't directly access each other's variables or call each other's functions, but they can send each other messages.</p>
+
+<p>从 Content Script 与 main.js 通信,发送方使用 <code>port.emit()</code> ,接收方使用 <code>port.on()</code> 监听.</p>
+
+<ul>
+ <li>In the content script, <code>port</code> is a property of the global <code>self</code> object.</li>
+ <li>In the add-on script, you need to listen for the <code>onAttach</code> event to get passed a <a href="/en-US/Add-ons/SDK/Low-Level_APIs/content_worker">worker</a> object that contains <code>port</code>.</li>
+</ul>
+
+<p>Let's rewrite the example above to pass a message from the add-on to the content script. The message will contain the new content to insert into the document. The content script now needs to look like this:</p>
+
+<pre class="brush: js">// "self" is a global object in content scripts
+// Listen for a message, and replace the document's
+// contents with the message payload.
+self.port.on("replacePage", function(message) {
+ document.body.innerHTML = "&lt;h1&gt;" + message + "&lt;/h1&gt;";
+});
+</pre>
+
+<p>In the add-on script, we'll send the content script a message inside <code>onAttach</code>:</p>
+
+<pre class="brush: js">// Import the page-mod API
+var pageMod = require("sdk/page-mod");
+// Import the self API
+var self = require("sdk/self");
+
+// Create a page mod
+// It will run a script whenever a ".org" URL is loaded
+// The script replaces the page contents with a message
+pageMod.PageMod({
+ include: "*.org",
+ contentScriptFile: self.data.url("my-script.js"),
+ // Send the content script a message inside onAttach
+ onAttach: function(worker) {
+ worker.port.emit("replacePage", "Page matches ruleset");
+ }
+});
+</pre>
+
+<p>The <code>replacePage</code> message isn't a built-in message: it's a message defined by the add-on in the <code>port.emit()</code> call.</p>
+
+<h2 id="注入_CSS">注入 CSS</h2>
+
+<div class="warning">
+<p><strong>请注意,本节中描述的功能是实验性的:我们很可能继续支持的功能,但可能需要改变的细节。</strong></p>
+</div>
+
+<p>Rather than injecting JavaScript into a page, you can inject CSS by setting the page-mod's <code>contentStyle</code> option:</p>
+
+<pre class="brush: js">var pageMod = require("sdk/page-mod").PageMod({
+ include: "*",
+ contentStyle: "body {" +
+ " border: 5px solid green;" +
+ "}"
+});
+</pre>
+
+<p>As with <code>contentScript</code>, there's a corresponding <code>contentStyleFile</code> option that's given the URL of a CSS file in your "data" directory, and it is good practice to use this option in preference to <code>contentStyle</code> if the CSS is at all complex:</p>
+
+<pre class="brush: js">var pageMod = require("sdk/page-mod").PageMod({
+ include: "*",
+ contentStyleFile: require("sdk/self").data.url("my-style.css")
+});
+</pre>
+
+<p>You can't currently use relative URLs in style sheets loaded with <code>contentStyle</code> or <code>contentStyleFile</code>. If you do, the files referenced by the relative URLs will not be found.</p>
+
+<p>To learn more about this, and read about a workaround, see the <a href="/en-US/Add-ons/SDK/High-Level_APIs/page-mod#PageMod(options)">relevant section in the page-mod API documentation</a>.</p>
+
+<h2 id="Learning_More">Learning More</h2>
+
+<p>To learn more about <code>page-mod</code>, see its <a href="/en-US/Add-ons/SDK/High-Level_APIs/page-mod">API reference page</a>. In particular, the <code>PageMod</code> constructor takes several additional options to control its behavior:</p>
+
+<ul>
+ <li>
+ <p>By default, content scripts are not attached to any tabs that are already open when the page-mod is created, and are attached to iframes as well as top-level documents. To control this behavior use the <code>attachTo</code> option.</p>
+ </li>
+ <li>
+ <p>Define read-only values accessible to content scripts using the <code>contentScriptOptions</code> option.</p>
+ </li>
+ <li>
+ <p>By default, content scripts are attached after all the content (DOM, JS, CSS, images) for the page has been loaded, at the time the <a href="/en-US/docs/Web/API/GlobalEventHandlers.onload">window.onload event</a> fires. To control this behavior use the <code>contentScriptWhen</code> option.</p>
+ </li>
+</ul>
+
+<p>To learn more about content scripts in general, see the <a href="/en-US/Add-ons/SDK/Guides/Content_Scripts">content scripts guide</a>.</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/open_a_web_page/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/open_a_web_page/index.html
new file mode 100644
index 0000000000..7ff9ba7883
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/open_a_web_page/index.html
@@ -0,0 +1,52 @@
+---
+title: 打开Web页面
+slug: Mozilla/Add-ons/SDK/Tutorials/Open_a_Web_Page
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/Open_a_Web_Page
+---
+{{AddonSidebar}}
+
+<div class="note"><span>学习本教程之前你需要学习 <a href="/zh-CN/docs/Mozilla/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29"><code>jpm</code> 基础</a>。</span></div>
+
+<p>打开一个新的网页,你可以使用 <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs"><code>tabs</code></a> 模块:</p>
+
+<pre class="brush: js">var tabs = require("sdk/tabs");
+tabs.open({
+"http://www.example.com");
+</pre>
+
+<p>这个函数是异步的,所以你不能立即获取一个可以检查的标签对象。要做到这一点,通过一个回调函数为open()。将回调函数赋值给 onready 属性,并将通过标签作为参数:</p>
+
+<pre class="brush: js">var tabs = require("sdk/tabs");
+tabs.open({
+ url: "http://www.example.com",
+ onReady: function onReady(tab) {
+ console.log(tab.title);
+ }
+});
+</pre>
+
+<div class="warning">
+<p>尽管这样,你还是不能直接访问到标签页中的任何宿主内容(具体概念请查阅相关内容:<span class="tcnt">JavaScript 本地对象、内置对象、宿主对象</span> )。</p>
+</div>
+
+<p>
+要访问标签页的内容,你需要使用 tab.attach()把一个脚本添加到该标签页。此add-on加载加载一个页面,然后将一个脚本附加到该页,该将向页面添加红色边框:</p>
+
+<pre class="brush: js">var tabs = require("sdk/tabs");
+tabs.open({
+ url: "http://www.example.com",
+ onReady: runScript
+});
+
+function runScript(tab) {
+ tab.attach({
+ contentScript: "document.body.style.border = '5px solid red';"
+ });
+}
+</pre>
+
+<h2 id="学习更多">学习更多</h2>
+
+<p>要了解更多关于SDK中标签如何工作, 查看 <a href="/en-US/Add-ons/SDK/High-Level_APIs/tabs"><code>tabs</code> API reference</a>.</p>
+
+<p>要了解更多关于在标签中运行脚本, 查看 <a href="/en-US/Add-ons/SDK/Tutorials/Modifying_the_Page_Hosted_by_a_Tab">tutorial on using <code>tab.attach()</code></a>.</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/troubleshooting/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/troubleshooting/index.html
new file mode 100644
index 0000000000..afa3cc0cd3
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/troubleshooting/index.html
@@ -0,0 +1,39 @@
+---
+title: Troubleshooting
+slug: Mozilla/Add-ons/SDK/Tutorials/Troubleshooting
+tags:
+ - add-on sdk 安装指南
+ - add-on sdk安装解惑
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/Troubleshooting
+---
+<p>{{AddonSidebar}}</p>
+
+<p>如果你的SDK安装和运行遇到了问题,不要慌!本页面列出了一些基本点,来帮助你追踪你的问题。</p>
+
+<h2 id="检查你的_Firefox">检查你的 Firefox</h2>
+
+<p><code>jpm</code> 会搜索你系统中 Firefox 常见的地址,<code>jpm</code> 也许不能找到火狐安装在哪,或者你有多个地方安装了火狐,<code>jpm</code> 也许找错了地方。这种情况下,你需要使用 <code>jpm</code> 的 <code>--binary</code> 选项。参看 <code><a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a></code> 指南以获取更多信息</p>
+
+<p>当你运行 <code>jpm</code> 来测试你的 add-on 或者运行单元测试时,它会打印出 Firefox 或 XULRunner 二进制文件的地址,所有你可以检查一下它的输出内容来做确认。</p>
+
+<h2 id="检查你的文本控制台">检查你的文本控制台</h2>
+
+<p>当你的代码代码和SKD的API产生错误时,他们会被记录到文本控制台。这应该和你运行 <code>jpm</code> 命令的是同一控制台或shell</p>
+
+<h2 id="搜索已知的问题">搜索已知的问题</h2>
+
+<p>也许有人已经遇到过和你一样的问题了。其他用户经常发布问题到 <a href="http://groups.google.com/group/mozilla-labs-jetpack/topics">项目邮件列表</a>。你也可以浏览<a href="https://bugzilla.mozilla.org/buglist.cgi?order=Bug%20Number&amp;resolution=---&amp;resolution=DUPLICATE&amp;query_format=advanced&amp;product=Add-on%20SDK">已知问题</a>列表或者<a href="https://bugzilla.mozilla.org/query.cgi?format=advanced&amp;product=Add-on%20SDK">搜索</a>特定的关键词。</p>
+
+<h2 id="与项目团队和用户组交流">与项目团队和用户组交流</h2>
+
+<p>SDK的用户和项目团队成员对问题和建议在 <a href="http://groups.google.com/group/mozilla-labs-jetpack/topics">项目的邮件列表</a>.  别人可能有与你相同的问题,所以试着搜索列表。也欢迎你发表问题.</p>
+
+<p>你也可以与其他SDK用户在 <a href="http://irc.mozilla.org/">Mozilla的 IRC 网络</a> 的 <a href="http://mibbit.com/?channel=%23jetpack&amp;server=irc.mozilla.org">#jetpack</a> 聊天室聊天.</p>
+
+<p>如果你想<a href="https://bugzilla.mozilla.org/enter_bug.cgi?product=Add-on%20SDK&amp;component=General">报告SDK的bug</a><span>,我们非常欢迎!您将需要创建一个 Bugzilla 的帐号,Bugzilla 是 Mozilla 的 bug 追踪系统。</span></p>
+
+<div id="xunlei_com_thunder_helper_plugin_d462f475-c18e-46be-bd10-327458d045bd"> </div>
+
+<div id="xunlei_com_thunder_helper_plugin_d462f475-c18e-46be-bd10-327458d045bd"> </div>
+
+<div id="xunlei_com_thunder_helper_plugin_d462f475-c18e-46be-bd10-327458d045bd"> </div>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/unit_testing/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/unit_testing/index.html
new file mode 100644
index 0000000000..63cd86da13
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/unit_testing/index.html
@@ -0,0 +1,102 @@
+---
+title: Unit Testing
+slug: Mozilla/Add-ons/SDK/Tutorials/Unit_testing
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/Unit_testing
+---
+<div class="note">
+ <p><span>学习本教程你将需要<a href="/en-US/Add-ons/SDK/Tutorials/Installation">安装SDK</a>, 学习 <a href="/en-US/Add-ons/SDK/Tutorials/Getting_Started_With_cfx">基本操作<code>cfx</code></a>,和学习过<a href="/en-US/Add-ons/SDK/Tutorials/Creating_reusable_modules">编写可重复模块(writing reusable modules)</a>.</span></p>
+</div>
+<div class="note">
+ <p>如果你在使用 <a href="/en-US/Add-ons/SDK/Tools/jpm">jpm</a> 而不是 cfx, 请看关于cfx, 而且重点看<a href="/en-US/Add-ons/SDK/Tools/cfx_to_jpm#Requiring_modules_from_test_code">加载测试模块(loading modules from test code)</a>.</p>
+</div>
+<p>SDK提供了一个框架,为你的代码创建和运行单元测试.接下来我们将演示如何写一个关于<a href="http://en.wikipedia.org/wiki/Base64">Base64</a> 模块的单元测试.</p>
+<h2 id="一个Base64模块例子">一个Base64模块例子</h2>
+<p>在一个网页中, 你可以进行Base64的加密和解密,通过使用函数<code>btoa()</code> and <code>atob()</code> .不幸的是这些函数依附在<code>window</code>对象: 由于这个对象在你的add-on(插件) main 的代码里不是有效对象,所以 <code>atob()</code> and <code>btoa()</code> 也不是有效的. 因此我们将展示如何在这个平台上创建一个<code>base64</code>模块 .</p>
+<p>To begin with, create a new directory, navigate to it, and run <code>cfx init</code>. Now create a new file in "lib" called "base64.js", and give it the following contents:</p>
+<pre class="brush: js">const { atob, btoa } = require("chrome").Cu.import("resource://gre/modules/Services.jsm", {});
+
+exports.atob = a =&gt; atob(a);
+exports.btoa = b =&gt; btoa(b);
+</pre>
+<p>This code exports two functions, which just call the platform's <code>btoa()</code> and <code>atob()</code> functions. To show the module in use, edit the "main.js" file as follows:</p>
+<pre class="brush: js">var base64 = require("./base64");
+
+var button = require("sdk/ui/button/action").ActionButton({
+  id: "base64",
+  label: "base64",
+  icon: "./icon-16.png",
+  onClick: function() {
+    encoded = base64.btoa("hello");
+    console.log(encoded);
+    decoded = base64.atob(encoded);
+    console.log(decoded);
+  }
+});</pre>
+<p>To run this example you'll also have to have an icon file named "icon-16.png" saved in your add-ons "data" directory. You could download this icon: <img alt="" src="https://mdn.mozillademos.org/files/7661/icon-16.png" style="width: 16px; height: 16px;">.</p>
+<p>Now "main.js" imports the base64 module and calls its two exported functions. If we run the add-on and click the button, we should see the following logging output:</p>
+<pre>info: aGVsbG8=
+info: hello
+</pre>
+<h2 id="Testing_the_Base64_Module">Testing the Base64 Module</h2>
+<p>Navigate to the add-on's <code>test</code> directory and delete the <code>test-main.js</code> file. In its place create a file called <code>test-base64.js</code> with the following contents:</p>
+<pre class="brush: js">var base64 = require("./base64");
+
+exports["test atob"] = function(assert) {
+ assert.ok(base64.atob("aGVsbG8=") == "hello", "atob works");
+}
+
+exports["test btoa"] = function(assert) {
+ assert.ok(base64.btoa("hello") == "aGVsbG8=", "btoa works");
+}
+
+exports["test empty string"] = function(assert) {
+ assert.throws(function() {
+ base64.atob();
+ },
+ "empty string check works");
+}
+
+require("sdk/test").run(exports);
+</pre>
+<p>This file: exports three functions, each of which expects to receive a single argument which is an <code>assert</code> object. <code>assert</code> is supplied by the <a href="/en-US/Add-ons/SDK/Low-Level_APIs/test_assert"><code>test/assert</code></a> module and implements the <a href="http://wiki.commonjs.org/wiki/Unit_Testing/1.1">CommonJS Unit Testing specification</a>.</p>
+<ul>
+ <li>
+ <p>The first two functions call <code>atob()</code> and <code>btoa()</code> and use <a href="/en-US/Add-ons/SDK/Low-Level_APIs/test_assert#ok(guard.2C_message)"><code>assert.ok()</code></a> to check that the output is as expected.</p>
+ </li>
+ <li>
+ <p>The second function tests the module's error-handling code by passing an empty string into <code>atob()</code> and using <a href="/en-US/Add-ons/SDK/Low-Level_APIs/test_assert#throws(block.2C_error.2C_message)"><code>assert.throws()</code></a> to check that the expected exception is raised.</p>
+ </li>
+</ul>
+<p>At this point your add-on ought to look like this:</p>
+<pre> /base64
+ package.json
+ README.md
+ /doc
+ main.md
+ /lib
+ main.js
+ base64.js
+ /test
+ test-base64.js
+</pre>
+<p>Now execute <code>cfx --verbose test</code> from the add-on's root directory. You should see something like this:</p>
+<pre>Running tests on Firefox 13.0/Gecko 13.0 ({ec8030f7-c20a-464f-9b0e-13a3a9e97384}) under darwin/x86.
+info: executing 'test-base64.test atob'
+info: pass: atob works
+info: executing 'test-base64.test btoa'
+info: pass: btoa works
+info: executing 'test-base64.test empty string'
+info: pass: empty string check works
+
+3 of 3 tests passed.
+Total time: 5.172589 seconds
+Program terminated successfully.
+</pre>
+<p>What happens here is that <code>cfx test</code>:</p>
+<p><span>Note the hyphen after "test" in the module name. <code>cfx test</code> will include a module called "test-myCode.js", but will exclude modules called "test_myCode.js" or "testMyCode.js".</span></p>
+<ul>
+ <li>looks in the <code>test</code> directory of your package</li>
+ <li>loads any modules whose names start with the word <code>test-</code></li>
+ <li>calls each exported function whose name starts with "test", passing it an <a href="/en-US/Add-ons/SDK/Low-Level_APIs/test_assert#Assert"><code>assert</code></a> object as its only argument.</li>
+</ul>
+<p>Obviously, you don't have to pass the <code>--verbose</code> option to <code>cfx</code> if you don't want to; doing so just makes the output easier to read.</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/日志/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/日志/index.html
new file mode 100644
index 0000000000..e581a0811c
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/日志/index.html
@@ -0,0 +1,62 @@
+---
+title: 日志
+slug: Mozilla/Add-ons/SDK/Tutorials/日志
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/Logging
+---
+<p>{{AddonSidebar}}</p>
+
+<div class="note"><span>学习本教程之前你需要学习 </span><span><a href="/en-US/docs/Mozilla/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29">jpm 基础</a>. </span></div>
+
+<p><span style="background-color: rgb(243, 242, 238); color: rgb(31, 9, 9); display: inline !important; float: none; font-family: pt serif,times new roman,times; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap;"><a href="https://developer.mozilla.org/en/DOM/console">DOM console</a> 对象对调试 Javascript 非常有帮助。但是由于扩展程序无法访问 DOM 对象,sdk 提供了一个拥有大部分 DOM console 对象方法的全局 console 对象,包括打印错误日车、警告和数据信息的方法。你无需 require() 任何模块,就可以直接使用 console 对象。</span></p>
+
+<p><span style="background-color: rgb(243, 242, 238); color: rgb(31, 9, 9); display: inline !important; float: none; font-family: pt serif,times new roman,times; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap;">使用 console.log() 方法来打印信息:</span></p>
+
+<pre class="brush: js">console.log("Hello World");
+</pre>
+
+<p style="margin-bottom: 1.5em; width: inherit; position: relative; color: rgb(31, 9, 9); font-family: 'PT Serif', 'Times New Roman', Times; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap;"><span class="md-line" style="display: block; width: 516px;"><span class="md-expand" style="">尝试:</span></span></p>
+
+<ul style="margin: -1em 0px 1.5em 1.5em; color: rgb(31, 9, 9); font-family: 'PT Serif', 'Times New Roman', Times; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap;">
+ <li style="margin: 0px; position: relative; list-style-type: disc;">
+ <p style="margin: 0.5rem 0px; width: inherit; position: relative;"><span class="md-line" style="display: block; width: 452px;"><span style="">新建一个目录,打开它</span></span></p>
+ </li>
+ <li style="margin: 0px; position: relative; list-style-type: disc;">
+ <p style="margin: 0.5rem 0px; width: inherit; position: relative;"><span class="md-line" style="display: block; width: 452px;"><span style="">执行 </span><span style=""><code style="font-family: monospace, monospace; font-size: 0.875em; text-align: left; padding-left: 1ch; padding-right: 1ch; line-height: 1.71428em; background-color: rgb(218, 218, 218);">jpm init</code></span><span style="">,接受所有默认设置</span></span></p>
+ </li>
+ <li style="margin: 0px; position: relative; list-style-type: disc;">
+ <p style="margin: 0.5rem 0px; width: inherit; position: relative;"><span class="md-line" style="display: block; width: 452px;"><span style="">打开 "index.js",并在文件内添加上面的代码</span></span></p>
+ </li>
+ <li style="margin: 0px; position: relative; list-style-type: disc;">
+ <p style="margin: 0.5rem 0px; width: inherit; position: relative;"><span class="md-focus md-line" style="display: block; width: 452px;"><span style="">执行 </span><span style=""><code style="font-family: monospace, monospace; font-size: 0.875em; text-align: left; padding-left: 1ch; padding-right: 1ch; line-height: 1.71428em; background-color: rgb(218, 218, 218);">jpm run</code></span></span></p>
+ </li>
+</ul>
+
+<p><span class="md-expand" style="background-color: rgb(243, 242, 238); color: rgb(31, 9, 9); font-family: pt serif,times new roman,times; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap;">Firefox 将会启动,并在你执行 </span><span style="background-color: rgb(243, 242, 238); color: rgb(31, 9, 9); font-family: pt serif,times new roman,times; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap;"><code style="font-family: monospace, monospace; font-size: 0.875em; text-align: left; padding-left: 1ch; padding-right: 1ch; line-height: 1.71428em; background-color: rgb(218, 218, 218);">jpm run</code></span><span style="background-color: rgb(243, 242, 238); color: rgb(31, 9, 9); font-family: pt serif,times new roman,times; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap;"> 的命令行窗口显示下面的信息:</span></p>
+
+<pre>console.log: console: Hello world
+</pre>
+
+<h2 id="在内容脚本(conent_script)中使用_console"><code>在内容脚本(conent script)中使用 console</code></h2>
+
+<p><span class="md-expand" style="background-color: rgb(243, 242, 238); color: rgb(31, 9, 9); font-family: pt serif,times new roman,times; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap;">与 addon 主代码一样,你可以在<a href="/en-US/Add-ons/SDK/Guides/Content_Scripts">内容脚本</a>中直接使用 console 对象。下面这个扩展在内容脚本中调用了 </span><span style="background-color: rgb(243, 242, 238); color: rgb(31, 9, 9); font-family: pt serif,times new roman,times; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap;"><code style="font-family: monospace, monospace; font-size: 0.875em; text-align: left; padding-left: 1ch; padding-right: 1ch; line-height: 1.71428em; background-color: rgb(218, 218, 218);">console.log()</code></span><span style="background-color: rgb(243, 242, 238); color: rgb(31, 9, 9); font-family: pt serif,times new roman,times; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap;"> 方法,作用是在控制台打印出每个打开的标签页内的 HTML 内容:</span></p>
+
+<pre class="brush: js">require("sdk/tabs").on("ready", function(tab) {
+ tab.attach({
+ contentScript: "console.log(document.body.innerHTML);"
+ });
+});
+</pre>
+
+<h2 id="控制台输出"><span style="">控制台输出</span></h2>
+
+<p style="margin-bottom: 1.5em; width: inherit; position: relative; color: rgb(31, 9, 9); font-family: 'PT Serif', 'Times New Roman', Times; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap;"><span class="md-line" style="display: block; width: 516px;"><span style="">如果你是在命令行启动你的扩展(例如:执行 </span><span style=""><code style="font-family: monospace, monospace; font-size: 0.875em; text-align: left; padding-left: 1ch; padding-right: 1ch; line-height: 1.71428em; background-color: rgb(218, 218, 218);">jpm run</code></span><span style=""> 或 </span><span style=""><code style="font-family: monospace, monospace; font-size: 0.875em; text-align: left; padding-left: 1ch; padding-right: 1ch; line-height: 1.71428em; background-color: rgb(218, 218, 218);">jpm test</code></span><span style="">),那么控制台信息将在你使用的命令行界面中显示。</span></span></p>
+
+<p style="margin-bottom: 1.5em; width: inherit; position: relative; color: rgb(31, 9, 9); font-family: 'PT Serif', 'Times New Roman', Times; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap;"><span class="md-line" style="display: block; width: 516px;"><span style="">如果你将扩展安装到了 Firefox 中,控制台信息将显示在 Firefox <a href="/en-US/docs/Tools/Browser_Console">浏览器控制台</a>中。</span></span></p>
+
+<p style="margin-bottom: 1.5em; width: inherit; position: relative; color: rgb(31, 9, 9); font-family: 'PT Serif', 'Times New Roman', Times; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap;"><span class="md-line" style="display: block; width: 516px;"><span style="">但请注意,<strong>默认情况下,任何已经安装的扩展不会在错误控制台中输出任何信息</strong>,包括使用扩展构建程序安装的扩展或者使用其它工具例如:<a href="https://addons.mozilla.org/en-US/firefox/addon/autoinstaller/">Extension Auto-installer</a>。</span></span></p>
+
+<p style="margin-bottom: 1.5em; width: inherit; position: relative; color: rgb(31, 9, 9); font-family: 'PT Serif', 'Times New Roman', Times; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap;"><span class="md-focus md-line" style="display: block; width: 516px;"><span style="">关于此项内容的更多信息请参阅控制台参考文档 “<a href="/en-US/Add-ons/SDK/Tools/console#Logging_Levels">日志等级</a>”。</span></span></p>
+
+<h2 id="更多">更多</h2>
+
+<p><span style="background-color: rgb(243, 242, 238); color: rgb(31, 9, 9); display: inline !important; float: none; font-family: pt serif,times new roman,times; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap;">完整的 console API,请看 </span> <a href="/en-US/Add-ons/SDK/Tools/console">API 参考文档</a>。</p>
diff --git a/files/zh-cn/mozilla/add-ons/sdk/tutorials/添加一个菜单项/index.html b/files/zh-cn/mozilla/add-ons/sdk/tutorials/添加一个菜单项/index.html
new file mode 100644
index 0000000000..77d743e806
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/sdk/tutorials/添加一个菜单项/index.html
@@ -0,0 +1,49 @@
+---
+title: 添加菜单项
+slug: Mozilla/Add-ons/SDK/Tutorials/添加一个菜单项
+translation_of: Archive/Add-ons/Add-on_SDK/Tutorials/Add_a_Context_Menu_Item
+---
+<div class="note">
+ <p>学习本章前,您要先 <a href="/en-US/Add-ons/SDK/Installation">安装SDK</a> 和学习 <a href="/en-US/Add-ons/SDK/Getting_Started_With_cfx"><code>cfx</code>的基本用法 </a></p>
+</div>
+<p>用<a href="/en-US/Add-ons/SDK/High-Level_APIs/context-menu"><code>右键菜单</code></a>模块添加右键菜单项或子菜单</p>
+<p>下面的例子是增加了一个新的上下文菜单项。当页面被选中时才会显示该菜单项,选择的部分会被发送到main.js的add-on代码中,它只是记录:</p>
+<pre class="brush: js">var contextMenu = require("sdk/context-menu");
+ var menuItem = contextMenu.Item({
+ label: "Log Selection",
+ context: contextMenu.SelectionContext(),
+ contentScript: 'self.on("click", function () {' +
+ ' var text = window.getSelection().toString();' +
+ ' self.postMessage(text);' +
+ '});',
+ onMessage: function (selectionText) {
+ console.log(selectionText);
+ }
+});</pre>
+<p>Try it: run the add-on, load a web page, select some text and right-click. You should see the new item appear:</p>
+<p>试一试:运行该扩展,加载一个网页,选中一些文本并右键单击。你应该能看到新的项目出现:</p>
+<p><img src="https://mdn.mozillademos.org/files/6513/context-menu-selection.png" style="display: block; margin-left: auto; margin-right: auto;"></p>
+<p>点击,选中的文本<a href="/en-US/Add-ons/SDK/Tutorials/Logging">记录到控制台</a>:</p>
+<pre>info: elephantine lizard
+</pre>
+<h2 id="细节">细节</h2>
+<p><br>
+ 这个add-on所有的操作是构建一个上下文菜单项。你不需要添加它:一旦你已经建立了项目,它会自动添加在正确的上下文。在这种情况下,构造函数接受四个选项:<code>label</code>,<code>context</code>,和contentscript,onMessage。</p>
+<h3 id="label">label</h3>
+<p><br>
+ 标签是字符串的显示。</p>
+<h3 id="context">context</h3>
+<p><br>
+ 上下文应该在不同的情境中显示它该做的显示。上下文菜单模块提供了一些简单的内置的上下文,包括selectioncontext(),这意味着:当页面被选中的时候将会显示菜单项。<br>
+ 如果这些简单的背景是不够的,你可以使用脚本定义更复杂的环境。</p>
+<h3 id="contentScript">contentScript</h3>
+<p>这将一个脚本项目。在这种情况下,脚本侦听用户点击该项目,然后选定文本用消息发送到add-on。</p>
+<h3 id="onMessage">onMessage</h3>
+<p>onMessage属性提供附加的代码来响应来自连接到上下文菜单项脚本报文的一种方法。在这种情况下,它只是记录选定的文本。</p>
+<p>所以:<br>
+ 用户点击项目<br>
+ 内容脚本的点击事件触发,和内容脚本检索选定的文本和发送邮件的附件<br>
+ 附加的消息事件触发,并附加代码的处理函数是通过选定的文本,它的日志<br>
+  </p>
+<h2 id="获取更多">获取更多</h2>
+<p>如果想获取更多信息关于<code>context-menu</code>模块,查看<a href="/en-US/Add-ons/SDK/High-Level_APIs/context-menu"><code>context-menu</code> API reference</a>.</p>
diff --git a/files/zh-cn/mozilla/add-ons/setting_up_extension_development_environment/index.html b/files/zh-cn/mozilla/add-ons/setting_up_extension_development_environment/index.html
new file mode 100644
index 0000000000..9790442e3c
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/setting_up_extension_development_environment/index.html
@@ -0,0 +1,58 @@
+---
+title: 扩展开发环境设置
+slug: Mozilla/Add-ons/Setting_up_extension_development_environment
+tags:
+ - Extensions
+translation_of: Archive/Add-ons/Setting_up_extension_development_environment
+---
+<p>本文给出了关于如何为扩展开发配置Mozilla应用程序的建议.</p>
+<h2 id=".E5.BC.80.E5.8F.91.E9.85.8D.E7.BD.AE" name=".E5.BC.80.E5.8F.91.E9.85.8D.E7.BD.AE">开发配置</h2>
+<p>为了避免由于设置了开发相关的预定义选项导致的性能上的问题,以及避免破坏你的个人数据,建议你可以创建一个新的Profile,而不是使用默认的进行开发工作.</p>
+<p>如果你使用<code>-no-remote</code>参数启动Firefox,你可以用不同的Profile运行两个Firefox实例.例如,不管是否"正常"的Firefox是否运行,下面的命令将运行你的开发Profile(假设你的开发Profile命名为"dev").</p>
+<pre class="eval">start "" "%ProgramFiles%\Mozilla Firefox\firefox.exe" -no-remote -P dev
+</pre>
+<p>用默认的Profile允许Firefox通常仅仅是"firefox"或者"firefox -P default".</p>
+<p>你可以使用Firefox稳定版本和开发版本来检查扩展的兼容性(<a class="external" href="http://forums.mozillazine.org/viewtopic.php?t=613873">Installing Firefox 3 or Minefield while keeping Firefox 2</a>).</p>
+<h2 id=".E5.BC.80.E5.8F.91.E9.A2.84.E5.AE.9A.E4.B9.89.E9.80.89.E9.A1.B9" name=".E5.BC.80.E5.8F.91.E9.A2.84.E5.AE.9A.E4.B9.89.E9.80.89.E9.A1.B9">开发预定义选项</h2>
+<p>这些已定义参数使在低性能的情况下使调试更容易.</p>
+<p>查看<a class="external" href="http://www.mozilla.org/support/firefox/edit">编辑配置文件</a>关于设置预定义选项的信息.注意某些设置默认不存在与abount:config中.所以你需要创建一个新的(boolean)的项.</p>
+<p>要这样做, 添加下面的代码行到你的Profile目录的 <code>user.js</code> 文件中,如果文件不存在,创建之:</p>
+<pre class="eval">user_pref("nglayout.debug.disable_xul_cache",true);
+user_pref("browser.dom.window.dump.enabled",true);
+</pre>
+<p>注意: 对于Firefox 版本 3.0"user.js" 已被 "prefs.js" 替换.</p>
+<p>See below under "Development Profile" to setup a separate development profile before you make these changes.</p>
+<ul>
+ <li><strong>javascript.options.showInConsole</strong> = <strong>true</strong>. Logs errors in chrome files to the <a href="/cn/Error_Console" title="cn/Error_Console">Error Console</a>.</li>
+ <li><strong>nglayout.debug.disable_xul_cache</strong> = <strong>true</strong>. Disables the XUL cache so that changes to windows and dialogs do not require a restart. This assumes you're <a href="#Using_directories_rather_than_JARs">using directories rather than JARs</a>. Changes to XUL overlays will still require reloading of the document overlaid.</li>
+ <li><strong>browser.dom.window.dump.enabled</strong> = <strong>true</strong>. Enables the use of the dump() statement to print to the standard console. See {{ Domxref("window.dump") }} for more info. You can also use {{ Interface("nsIConsoleService") }} from privileged script.</li>
+ <li><strong>javascript.options.strict</strong> = <strong>true</strong>. Enables strict JavaScript warnings in the Error Console. Note that since many people have this setting turned off when developing, you will see lots of warnings for problems with their code in addition to warnings for your own extension. You can filter those with <a class="link-https" href="https://addons.mozilla.org/en-US/firefox/addon/1815">Console<sup>2</sup></a>.</li>
+ <li><strong>extensions.logging.enabled</strong> = <strong>true</strong>. This will send more detailed information about installation and update problems to the Error Console.</li>
+</ul>
+<h2 id=".E5.BC.80.E5.8F.91.E6.89.A9.E5.B1.95" name=".E5.BC.80.E5.8F.91.E6.89.A9.E5.B1.95">开发扩展</h2>
+<p>这些扩展可以帮组你进行扩展开发.</p>
+<ul>
+ <li>DOM 检查器, 自定义安装的一个选项.</li>
+ <li><a class="link-https" href="https://addons.mozilla.org/firefox/addon/216">Venkman</a>, 一个JavaScript 调试器.</li>
+ <li><a class="link-https" href="https://addons.mozilla.org/en-US/firefox/addon/7434/">扩展开发者的扩展</a></li>
+ <li><a class="link-https" href="https://addons.mozilla.org/firefox/addon/1815">Console<sup>2</sup></a></li>
+ <li><a class="link-https" href="https://addons.mozilla.org/firefox/addon/4453">Chrome 清单</a></li>
+ <li><a class="link-https" href="https://addons.mozilla.org/firefox/addon/1843">Firebug</a></li>
+ <li><a class="link-https" href="https://addons.mozilla.org/firefox/addon/1729">Execute JS</a></li>
+ <li><a class="external" href="http://xpcomviewer.mozdev.org">XPCOMViewer</a>, 一个XPCOM 检查器</li>
+</ul>
+<h2 id=".E8.87.AA.E5.AE.9A.E4.B9.89.E4.BB.A3.E7.A0.81.E4.BD.8D.E7.BD.AE" name=".E8.87.AA.E5.AE.9A.E4.B9.89.E4.BB.A3.E7.A0.81.E4.BD.8D.E7.BD.AE">扩展开发目录设定</h2>
+<p>每次因遇到某些变更而不得不重新添加扩展部分的时候,以及,为了保护您的"扩展源文件"不受到卸载过程中被意外删除的风险,其实您可以把"扩展插件目录"从"标准用户配置目录"中移出到你自己想要的文件目录中进行开发。具体操作步骤如下:</p>
+<ol>
+ <li>找到扩展ID:从install.rdf中找到你的扩展ID号,install.rdf就安装在扩展插件的根目录中;</li>
+ <li>建立文件:在“用户配置目录/extensions/”目录下,用你的扩展插件ID号作为文件名新建一个文件。 (比如: `用户配置目录/extensions/{46D1B3C0-DB7A-4b1a-863A-6EE6F77ECB58}`) (<a class="external" href="http://kb.mozillazine.org/Profile_folder">找到你的用户配置目录所在位置</a>),记得没有文件扩展名。(为了方便说明暂把这个文件称作“扩展外链定位文件” )</li>
+ <li>设定文件内容:“扩展外链定位文件”里要包含一个路径,这个路径是指向扩展程序的install.rdf所在目录的路径。(例如:`/full/path/to/yourExtension`. Windows用户注意,用大写书写驱动器名以及反斜杠而不是正斜杠,比如:`C:\full\path\to\yourExtension` Here is an example 'C:\sam\workspace\toolbar\helloWorldtoolbar\'). 在Firefox3中, 如果你是通过XPI包安装的扩展,`用户配置目录`下部分或者所有extensions.*的文件可能会被重新设置。虽然这些文件系统会自动重新生成的,还是备份一下先。</li>
+ <li>把“扩展外链定位文件”放在你的用户配置目录中的扩展目录(`用户配置目录/extension`)下,重启Firefox。</li>
+</ol>
+<h2 id=".E4.BD.BF.E7.94.A8.E7.9B.AE.E5.BD.95.E8.80.8C.E9.9D.9EJAR" name=".E4.BD.BF.E7.94.A8.E7.9B.AE.E5.BD.95.E8.80.8C.E9.9D.9EJAR">使用目录而非JAR</h2>
+<p>无论你是否选择将你的扩展 chrome打包成JAR或是目录,在目录下开发会更简单。如果你选择了一个用于分发的JAR,你仍然可以通过编辑chrome.manifest工作在目录形式下。比如下面的例子</p>
+<pre class="eval">content myExtension jar:chrome/myExtension.jar!/content/
+</pre>
+<p>不如</p>
+<pre class="eval">content myExtension chrome/content/
+</pre>
diff --git a/files/zh-cn/mozilla/add-ons/submitting_an_add-on_to_amo/index.html b/files/zh-cn/mozilla/add-ons/submitting_an_add-on_to_amo/index.html
new file mode 100644
index 0000000000..5ffb14d889
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/submitting_an_add-on_to_amo/index.html
@@ -0,0 +1,24 @@
+---
+title: 向AMO提交一个附加组件
+slug: Mozilla/Add-ons/Submitting_an_add-on_to_AMO
+translation_of: Mozilla/Add-ons/Distribution
+---
+<p>当你为基于Mozilla的软件(如Firefox,Thunderbird等)制作出了一个全新的附加组件时,你一定希望其他人能够找,到下载并使用它。</p>
+<p>Mozilla provides the <a class="external" href="http://addons.mozilla.org" rel="freelink">http://addons.mozilla.org</a> (AMO) web site to provide a repository for add-ons for Mozilla software. When users click the "Get Extensions" link in the <strong>Add-ons</strong> window in Firefox, for example, they are directed to this site.</p>
+<p>That makes AMO a great way to get your add-ons to the public. This article provides details on how to submit your article to AMO for distribution.</p>
+<div class="note">
+ <strong>Not</strong><strong>e:</strong> Attaching your add-on to articles on the Mozilla Developer Center web site won't do you a lot of good, as we delete them.  This is not the right place to post your add-ons; please follow the instructions here instead.</div>
+<h2 id="Step_1:_Write_your_add-on" name="Step_1:_Write_your_add-on">第一步:编写你的附加组件</h2>
+<p>This is important. It's hard to get an add-on accepted into AMO if you don't write it first. Really hard.</p>
+<h2 id="Step_2:_Test_your_add-on" name="Step_2:_Test_your_add-on">第二步:测试你的附加组件</h2>
+<p>Make sure it works before you submit it. You should try it out on every product you claim to support. In other words, you don't want to advertise that it works in both Firefox and Thunderbird if you haven't tested it in both. Make sure it works in every version you claim to support, too.</p>
+<h2 id="Step_3:_Package_your_add-on" name="Step_3:_Package_your_add-on">第三步:打包你的附加组件</h2>
+<p>Add-ons distributed by AMO need to be packaged properly as XPI files. See <a href="/en/Extension_Packaging" title="en/Extension_Packaging">Extension Packaging</a> for information on how to do this.</p>
+<h2 id="Step_4:_Get_an_AMO_account" name="Step_4:_Get_an_AMO_account">第四部:注册一个AMO账户</h2>
+<p>You'll need to have an AMO account so that you can make submissions. To get one, visit the <a class="link-https" href="https://addons.mozilla.org/en-US/firefox/users/register">Register</a> link at the top of any page on the AMO website. Fill out the form and follow the instructions to activate your account.</p>
+<p>Obviously, you can skip this step if you already have an AMO account.</p>
+<h2 id="Step_5:_Submit_your_add-on" name="Step_5:_Submit_your_add-on">第五步:提交你的附加组件</h2>
+<p>To submit an add-on, go to the <a class="link-https" href="https://addons.mozilla.org/developers" title="https://addons.mozilla.org/developers">Developer Control Panel</a>.</p>
+<p>You will then be asked to supply a file, as well as information about the add-on.</p>
+<p>Once the add-on has been reviewed, it will be made available for downloading. Reviews can take a varying amount of time depending on how many pending submissions there are and the availability of people to perform the reviews.</p>
+<h2 id="languages(_fr_frSoumettre_un_module_sur_AMO_)">{{ languages( { "fr": "fr/Soumettre_un_module_sur_AMO" } ) }}</h2>
diff --git a/files/zh-cn/mozilla/add-ons/themes/index.html b/files/zh-cn/mozilla/add-ons/themes/index.html
new file mode 100644
index 0000000000..e7c28ba50c
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/themes/index.html
@@ -0,0 +1,65 @@
+---
+title: 主题
+slug: Mozilla/Add-ons/Themes
+tags:
+ - Themes
+translation_of: Mozilla/Add-ons/Themes
+---
+<p>
+</p>
+<div class="callout-box"><b><a href="cn/Creating_a_Skin_for_Firefox">Getting Started</a></b><br>
+介绍如何为Firefox开发主题。</div>
+<div><b>主题</b>指的是程序的皮肤,通过它可以改变程序的外观,满足不同人的不同需要。一个主题可以只改变界面的颜色,也可以改变界面相关的所有元素。</div>
+<table class="topicpage-table">
+<tbody><tr>
+<td>
+<h4 id="Documentation" name="Documentation"> <a>Documentation</a> </h4>
+<dl><dt> <a href="cn/%e5%88%9b%e5%bb%ba%e4%b8%80%e5%a5%97_Firefox_%e7%9a%ae%e8%82%a4">创建一套 Firefox 皮肤</a>
+</dt><dd> <small>介绍如何为Firefox创建新的主题。</small>
+</dd></dl>
+<p><span class="comment">一般style翻译成样式</span>
+</p>
+<dl><dt> <a href="cn/%e4%b8%bb%e9%a2%98%e6%89%93%e5%8c%85">主题打包</a>
+</dt><dd> <small>如何将Firefox和Thunderbird的主题打包。</small>
+</dd></dl>
+<dl><dt> <a href="cn/Theme_changes_in_Firefox_3"> Firefox 2.0 和 3.0 间的主题变更</a>
+</dt></dl>
+<dl><dt> <a href="cn/Theme_changes_in_Firefox_2"> Firefox 1.5 和 2.0 间的主题变更</a>
+</dt><dd> <small> Firefox 发行版1.5和2.0之间的主题全部变更清单。</small>
+</dd></dl>
+<dl><dt> <a class="external" href="http://forums.mozillazine.org/viewtopic.php?t=197434">Firefox 1.5 和 2.0 间的主题变更 (forum post)</a>
+</dt><dd> <small>A forum post at <a class="external" href="http://www.mozillazine.org">MozillaZine</a> outlining the basic theme-related changes between Firefox 1.0 and 1.5.</small>
+</dd></dl>
+<dl><dt> <a class="external" href="http://cheeaun.phoenity.com/weblog/2004/12/first-steps-in-theme-design.html">主题设计的第一步</a>
+</dt><dd> <small>A somewhat aged article discussing theme design for Firefox.</small>
+</dd></dl>
+<p><span class="alllinks"><a>View All...</a></span>
+</p>
+</td><td>
+<h4 id="Community" name="Community"> Community </h4>
+<ul><li> View Mozilla forums...
+</li></ul>
+<p>{{ DiscussionList("dev-themes", "mozilla.dev.themes") }}
+</p>
+<ul><li> <a class="link-irc" href="irc://irc.mozilla.org/#themedev">#themedev IRC channel</a>
+</li><li> <a class="external" href="http://forums.mozillazine.org/viewforum.php?f=18">MozillaZine Themes forum</a>
+</li></ul>
+<h4 id="Tools" name="Tools"> Tools </h4>
+<ul><li> <a href="cn/DOM_Inspector">DOM Inspector</a>
+</li><li> <a class="link-https" href="https://addons.mozilla.org/firefox/63/">InspectorWidget</a>
+</li><li> <a class="external" href="http://www.extensionsmirror.nl/index.php?showtopic=21">ChromeEdit extension</a>
+</li></ul>
+<p><span class="alllinks"><a>View All...</a></span>
+</p>
+<h4 id="Related_Topics" name="Related_Topics"> Related Topics </h4>
+<dl><dd> <a href="cn/CSS">CSS</a>
+</dd></dl>
+</td></tr></tbody></table>
+<p><span class="comment">Categories</span>
+</p><p><span class="comment">Interwiki Language Links</span>
+</p><p><br>
+</p><p><br>
+</p>
+<div class="noinclude">
+</div>
+{{ languages( { "de": "de/Themes", "en": "en/Themes", "es": "es/Temas", "fr": "fr/Th\u00e8mes", "ja": "ja/Themes", "pl": "pl/Motywy", "zh-tw": "zh_tw/\u4f48\u666f\u4e3b\u984c" } ) }}
diff --git a/files/zh-cn/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/index.html b/files/zh-cn/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/index.html
new file mode 100644
index 0000000000..2301b757e7
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/index.html
@@ -0,0 +1,28 @@
+---
+title: 创建一套_Firefox_皮肤
+slug: Mozilla/Add-ons/Themes/Obsolete/Creating_a_Skin_for_Firefox
+tags:
+ - Themes
+translation_of: Archive/Themes/Creating_a_Skin_for_Firefox
+---
+<p> </p>
+<h3 id=".E8.AF.B4.E6.98.8E" name=".E8.AF.B4.E6.98.8E">说明</h3>
+<p>为了为 Firefox 创建一套皮肤, 你必须知道三件事:如何编辑图像、如何释放zip文件、以及如何更改CSS。Firefox 的按钮图标使用标准的gif、png、和 jpeg 图像并使用 CSS 来定义界面上的一切。</p>
+<p><b>什么是皮肤?</b></p>
+<p>皮肤不会改版总体的界面;相反的,它仅仅定义了界面看上去的样子。你无法改版用户右击一个图像时发生什么事情,但你可以改版右键菜单的外观(例如使其变为带有粉色圆点装饰)。如果你想更改Firefox的功能,你不得不去改变chrome,这不在本文讨论的范围之内。</p>
+<h3 id=".E5.86.85.E5.AE.B9" name=".E5.86.85.E5.AE.B9">内容</h3>
+<ul>
+ <li><a href="cn/%e5%88%9b%e5%bb%ba%e4%b8%80%e5%a5%97Firefox%e7%9a%ae%e8%82%a4/%e4%bb%8e%e8%bf%99%e9%87%8c%e5%bc%80%e5%a7%8b">从这里开始</a></li>
+</ul>
+<div class="originaldocinfo">
+ <h3 id=".E6.96.87.E7.AB.A0.E5.8E.9F.E5.A7.8B.E4.BF.A1.E6.81.AF" name=".E6.96.87.E7.AB.A0.E5.8E.9F.E5.A7.8B.E4.BF.A1.E6.81.AF">文章原始信息</h3>
+ <ul>
+ <li>作者:Neil Marshall 和 Tucker Lee</li>
+ <li>其它贡献者 (建议/校正):Brent Marshall, CDN (<a class="external" href="http://themes.mozdev.org" rel="freelink">http://themes.mozdev.org</a>), JP Martin, Boris Zbarsky, Asa Dotzler, WeSaySo, David James, Dan Mauch, Anders Conbere, Tim Regula (<a class="external" href="http://www.igraphics.nn.cx" rel="freelink">http://www.igraphics.nn.cx</a>)</li>
+ <li>版权信息:Copyright 2002-2003 Neil Marshall, permission given to MDC to migrate into the wiki April 2005 via email.</li>
+ <li>原始链接:<a class="external" href="http://www.eightlines.com/neil/mozskin" rel="freelink">http://www.eightlines.com/neil/mozskin</a></li>
+ </ul>
+</div>
+<div class="noinclude">
+  </div>
+<p>{{ languages( { "de": "de/Theme_erstellen", "es": "es/Creando_un_tema_para_Firefox", "fr": "fr/Cr\u00e9er_un_th\u00e8me_pour_Firefox", "ja": "ja/Creating_a_Skin_for_Firefox", "pl": "pl/Tworzenie_sk\u00f3rek_dla_Firefoksa" } ) }}</p>
diff --git a/files/zh-cn/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/uuid/index.html b/files/zh-cn/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/uuid/index.html
new file mode 100644
index 0000000000..37280321a1
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/themes/obsolete/creating_a_skin_for_firefox/uuid/index.html
@@ -0,0 +1,6 @@
+---
+title: 创建一套Firefox皮肤
+slug: Mozilla/Add-ons/Themes/Obsolete/Creating_a_Skin_for_Firefox/UUID
+translation_of: Archive/Themes/Creating_a_Skin_for_Firefox/UUID
+---
+<p>{{wiki.localize('System.API.page-generated-for-subpage')}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/themes/obsolete/index.html b/files/zh-cn/mozilla/add-ons/themes/obsolete/index.html
new file mode 100644
index 0000000000..d420b6ebf0
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/themes/obsolete/index.html
@@ -0,0 +1,10 @@
+---
+title: Obsolete
+slug: Mozilla/Add-ons/Themes/Obsolete
+tags:
+ - NeedsTranslation
+ - TopicStub
+translation_of: Mozilla/Add-ons/Themes/Obsolete
+---
+<p>This page collects theme docs that we don't expect will ever be updated, but which we're keeping for the time being as potential source material for updated docs.</p>
+<p>{{ ListSubPages ("/en-US/Add-ons/Themes/Obsolete", 5) }}</p>
diff --git a/files/zh-cn/mozilla/add-ons/themes/obsolete/theme_changes_in_firefox_3/index.html b/files/zh-cn/mozilla/add-ons/themes/obsolete/theme_changes_in_firefox_3/index.html
new file mode 100644
index 0000000000..595058f253
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/themes/obsolete/theme_changes_in_firefox_3/index.html
@@ -0,0 +1,92 @@
+---
+title: Firefox 3 的界面改动
+slug: Mozilla/Add-ons/Themes/Obsolete/Theme_changes_in_Firefox_3
+tags:
+ - Themes
+translation_of: Archive/Themes/Theme_changes_in_Firefox_3
+---
+<p>{{ Fx_minversion_header(3) }} {{ Draft() }}</p>
+<p>本文包含了更新FireFox主题以使其可以在<a href="cn/Firefox_3">Firefox 3</a>下良好表现所需进行的一些改动。</p>
+<div class="note">
+ <b>Note:</b> We could use an article called <a href="cn/Updating_themes_for_Firefox_3">Updating themes for Firefox 3</a> that would serve as a how-to guide for updating themes. If anyone with theming experience would like to write one, please do!</div>
+<h2 id=".E9.BB.98.E8.AE.A4.E4.B8.BB.E9.A2.98.E7.9A.84.E6.94.B9.E5.8A.A8" name=".E9.BB.98.E8.AE.A4.E4.B8.BB.E9.A2.98.E7.9A.84.E6.94.B9.E5.8A.A8">默认主题的改动</h2>
+<p>下表列出了Firefox 3默认主题的一些改动。你可以对照此表,确认你所需要做出的改动。</p>
+<h3 id=".E6.89.80.E6.9C.89.E6.96.87.E4.BB.B6" name=".E6.89.80.E6.9C.89.E6.96.87.E4.BB.B6">所有文件</h3>
+<h4 id=".E6.89.80.E6.9C.89.E5.B9.B3.E5.8F.B0" name=".E6.89.80.E6.9C.89.E5.B9.B3.E5.8F.B0">所有平台</h4>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">文件</td>
+ <td class="header">变更</td>
+ </tr>
+ <tr>
+ <td>&lt;tt&gt;browser/themes/*/browser/browser.css&lt;/tt&gt;</td>
+ <td>The width of the drag and drop indicator is no longer calculated during the drag (tabbrowser.xml). Instead a '-moz-margin-start' property must be added to .tab-drop-indicator-bar, with a value that is half of the width of the indicator image. Also, the visibility of the indicator is now controlled by setting collapsed in tabbrowser.xml. As a result, the 'display' property should be removed from .tab-drop-indicator-bar (including for dragging="true").</td>
+ </tr>
+ </tbody>
+</table>
+<h4 id="Mac_OS_X" name="Mac_OS_X">Mac OS X</h4>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">文件</td>
+ <td class="header">变动信息</td>
+ </tr>
+ <tr>
+ <td>&lt;tt&gt;browser/themes/pinstripe/browser/tabbrowser/tabDragIndicator.png&lt;/tt&gt;</td>
+ <td>删除了图片边缘多余的空白,现在图片尺寸变小。也许会对其他使用此图片的Mac平台下的主题产生影响。</td>
+ </tr>
+ <tr>
+ <td>&lt;tt&gt;browser/themes/pinstripe/browser/browser.css&lt;/tt&gt;</td>
+ <td>.tabbrowser-tab{{ mediawiki.external('first-tab=\"true\"') }} &gt; .tab-image-left不再具有margin-left属性,现在使用定义了相同宽度的.tabs-left元素来替代。在FireFox 2的默认皮肤Winstripe中已经作此处理。</td>
+ </tr>
+ </tbody>
+</table>
+<h3 id="browser.E7.9A.84.E6.94.B9.E5.8A.A8" name="browser.E7.9A.84.E6.94.B9.E5.8A.A8">&lt;tt&gt;browser&lt;/tt&gt;的改动</h3>
+<h3 id="global.E7.9A.84.E6.94.B9.E5.8A.A8" name="global.E7.9A.84.E6.94.B9.E5.8A.A8">&lt;tt&gt;global&lt;/tt&gt;的改动</h3>
+<h4 id=".E6.89.80.E6.9C.89.E5.B9.B3.E5.8F.B0_2" name=".E6.89.80.E6.9C.89.E5.B9.B3.E5.8F.B0_2">所有平台</h4>
+<p>“跳转到”按钮现在被放置在地址栏内部,所以此按钮所用的图片(&lt;tt&gt;<a class="external" rel="freelink">chrome://browser/skin/Go-arrow.png</a>&lt;/tt&gt;)需要设计的小一些。控制“跳转到”及其他地址栏中所用到的按钮的显示及隐藏的CSS规则为:</p>
+<pre class="eval">#urlbar[pageproxystate="invalid"] &gt; #urlbar-icons &gt; :not(#go-button) ,
+#urlbar[pageproxystate="valid"] &gt; #urlbar-icons &gt; #go-button {
+ visibility: collapse;
+}
+</pre>
+<h5 id=".E5.A2.9E.E5.8A.A0.E7.9A.84.E5.9B.BE.E7.89.87" name=".E5.A2.9E.E5.8A.A0.E7.9A.84.E5.9B.BE.E7.89.87">增加的图片</h5>
+<p>增加了以下图片:</p>
+<dl>
+ <dt>
+ &lt;tt&gt;<a class="external" rel="freelink">chrome://global/skin/icons/information-16.png</a>&lt;/tt&gt;</dt>
+ <dd>
+ Used when presenting information notices。</dd>
+ <dt>
+ &lt;tt&gt;<a class="external" rel="freelink">chrome://global/skin/icons/warning-16.png</a>&lt;/tt&gt;</dt>
+ <dd>
+ 用作显示警告窗口。</dd>
+</dl>
+<h5 id=".E7.A7.BB.E9.99.A4.E7.9A.84.E5.9B.BE.E7.89.87" name=".E7.A7.BB.E9.99.A4.E7.9A.84.E5.9B.BE.E7.89.87">移除的图片</h5>
+<p>以下图片被移除:</p>
+<dl>
+ <dt>
+ &lt;tt&gt;<a class="external" rel="freelink">chrome://mozapps/skin/extensions/question.png</a>&lt;/tt&gt;</dt>
+ <dd>
+ 不再使用。</dd>
+</dl>
+<h4 id="Mac_OS_X_2" name="Mac_OS_X_2">Mac OS X</h4>
+<p>为Mac OS X平台上的Firefox 3制作的皮肤需要在&lt;tt&gt;<a class="external" rel="freelink">chrome://global/skin/wizard.css</a>&lt;/tt&gt;末尾增加两条CSS规则:</p>
+<pre class="eval">.wizard-buttons-btm {
+ padding:<i>X</i>px;
+}
+
+.wizard-label-box {
+ display: none;
+}
+</pre>
+<p>此处的数字
+ <i>
+ X</i>
+ ,即&lt;tt&gt;.wizard-buttons-btm&lt;/tt&gt;中的padding值,需要和&lt;tt&gt;.wizard-buttons-box-2&lt;/tt&gt;中的margin值相同。</p>
+<h5 id=".E5.9B.BE.E7.89.87.E5.8F.98.E5.8A.A8" name=".E5.9B.BE.E7.89.87.E5.8F.98.E5.8A.A8">图片变动</h5>
+<p><a class="external" rel="freelink">chrome://global/skin/icons/loading_16.gif</a> 被chrome://global/skin/icons/loading_16.png 替代。</p>
+<h3 id="mozapps.E7.9A.84.E6.94.B9.E5.8A.A8" name="mozapps.E7.9A.84.E6.94.B9.E5.8A.A8">&lt;tt&gt;mozapps&lt;/tt&gt;的改动</h3>
+<h2 id=".E5.8F.82.E8.80.83.E6.96.87.E7.AB.A0" name=".E5.8F.82.E8.80.83.E6.96.87.E7.AB.A0">参考文章</h2>
+<p><a href="cn/Theme_changes_in_Firefox_2">Theme changes in Firefox 2</a></p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/add_a_button_to_the_toolbar/index.html b/files/zh-cn/mozilla/add-ons/webextensions/add_a_button_to_the_toolbar/index.html
new file mode 100644
index 0000000000..64ec49a146
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/add_a_button_to_the_toolbar/index.html
@@ -0,0 +1,220 @@
+---
+title: Add a button to the toolbar
+slug: Mozilla/Add-ons/WebExtensions/Add_a_button_to_the_toolbar
+translation_of: Mozilla/Add-ons/WebExtensions/Add_a_button_to_the_toolbar
+---
+<div>{{AddonSidebar}}</div>
+
+<div>工具栏按钮是webextensions的一种主要UI组件,它在浏览器的工具栏中作为图标显示。当用户点击图标时,就会发生下面两种事件中的一样:</div>
+
+<ul>
+ <li>如果按钮有弹出菜单,则显示该弹出。 弹出菜单是一个临时对话,它必须使用HTML,CSS,JavaScript语言表示。</li>
+ <li>如果没有弹出菜单, 则生成一个单击事件, 你可以在代码中监听该事件并执行其他响应。</li>
+</ul>
+
+<p>在WebExtensions中这种按钮被称为浏览器行为按钮,它们可以像下面这样生成:</p>
+
+<ul>
+ <li>manifest.json 文件中的键 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_action">browser_action</a></code> 被用来定义按钮。</li>
+ <li>JavaScript 接口 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserAction">browserAction</a></code> 被用来监听单击和更改按钮,或通过代码执行操作。</li>
+</ul>
+
+<h2 id="一个简单的按钮">一个简单的按钮</h2>
+
+<p>在这一节中我们将创建一个工具栏按钮的 WebExtension 。当用户单击按钮时,会打开一个<a href="https://developer.mozilla.org">https://developer.mozilla.org</a> 的新标签页.</p>
+
+<p>首先,新建名为 "button"的文件夹, 在该文件夹下创建名为"manifest.json" 的文件,内容如下:</p>
+
+<pre class="brush: json">{
+
+ "description": "Demonstrating toolbar buttons",
+ "manifest_version": 2,
+ "name": "button-demo",
+ "version": "1.0",
+
+ "background": {
+ "scripts": ["background.js"]
+ },
+
+ "browser_action": {
+ "default_icon": {
+ "16": "icons/page-16.png",
+ "32": "icons/page-32.png"
+ }
+ }
+
+}</pre>
+
+<p>上面内容显示有一个名为“ background .js ”后台脚本,以及在“ icons ”文件夹下的浏览器行为按钮图标。</p>
+
+<div class="pull-aside">
+<div class="moreinfo">These icons are from the <a href="https://www.iconfinder.com/iconsets/bitsies">bitsies!</a> iconset created by Recep Kütük.</div>
+</div>
+
+<p>接下来,在"buttons" 文件夹下创建 "icons" 文件夹,在该文件夹下存放下面的图标文件 :</p>
+
+<ul>
+ <li>"page-16.png" (<img alt="" src="https://mdn.mozillademos.org/files/13476/page-16.png" style="height: 16px; width: 16px;">)</li>
+ <li>"page-32.png" (<img alt="" src="https://mdn.mozillademos.org/files/13478/page-32.png" style="height: 32px; width: 32px;">).</li>
+</ul>
+
+<div style=""> </div>
+
+<p>我们有两个图标,大图标用于在高分辨率状态下显示。浏览器会自动选择合适的图标。</p>
+
+<p>接着,在附加组件的根目录下创建 "background.js"文件 , 内容如下:</p>
+
+<pre class="brush: js">function openPage() {
+ browser.tabs.create({
+ url: "https://developer.mozilla.org"
+ });
+}
+
+browser.browserAction.onClicked.addListener(openPage);</pre>
+
+<p>该文件用来监听浏览器单击事件。当单击事件发生时运行 <code>openPage()</code> 函数,这个函数通过使用<code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs">tabs</a></code> 接口加载指定的页面。</p>
+
+<p>现在完整的附加组件看上去应该像下面这样:</p>
+
+<pre class="line-numbers language-html"><code class="language-html">button/
+ icons/
+ page-16.png
+ page-32.png
+ background.js
+ manifest.json</code></pre>
+
+<p>安装这个<a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Temporary_Installation_in_Firefox">WebExtension</a> ,然后单击按钮:</p>
+
+<p>{{EmbedYouTube("kwwTowgT-Ys")}}</p>
+
+<h2 id="添加一个弹出菜单">添加一个弹出菜单</h2>
+
+<p>尝试在按钮上添加一个弹出菜单。 修改 "manifest.json"如下:</p>
+
+<pre class="brush: json">{
+
+ "description": "Demonstrating toolbar buttons",
+ "manifest_version": 2,
+ "name": "button-demo",
+ "version": "1.0",
+
+ "browser_action": {
+ "browser_style": true,
+ "default_popup": "popup/choose_page.html",
+ "default_icon": {
+ "16": "icons/page-16.png",
+ "32": "icons/page-32.png"
+ }
+ }
+
+}</pre>
+
+<p>我们把原文件做了三处改变:</p>
+
+<ul>
+ <li>我们不需要引用“ background.js ”文件,因为会在弹出菜单的脚本中处理该行为 (你也可以使用“background.js“来运行一个弹出窗口,只是现在我们不需要这么做).</li>
+ <li>我们添加了<code>"browser_style": true</code>, 使弹出样式看上去更像是浏览器的一部分。</li>
+ <li>最后,我们添加 <code>"default_popup": "popup/choose_page.html"</code>, 告诉浏览器按钮被单击时弹出菜单,菜单的内容则在"popup/choose_page.html"页面中.</li>
+</ul>
+
+<p>现在我们要创建弹出菜单。新建名为 "popup" 的文件夹,然后在文件夹内创建"choose_page.html" 文件,该文件内容如下:</p>
+
+<pre class="brush: html">&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+ &lt;head&gt;
+ &lt;meta charset="utf-8"&gt;
+ &lt;link rel="stylesheet" href="choose_page.css"/&gt;
+ &lt;/head&gt;
+
+&lt;body&gt;
+ &lt;div class="page-choice"&gt;developer.mozilla.org&lt;/div&gt;
+ &lt;div class="page-choice"&gt;support.mozilla.org&lt;/div&gt;
+ &lt;div class="page-choice"&gt;addons.mozilla.org&lt;/div&gt;
+ &lt;script src="choose_page.js"&gt;&lt;/script&gt;
+&lt;/body&gt;
+
+&lt;/html&gt;</pre>
+
+<p>你会发现这是一个普通的HTML页面,它包含三个 {{htmlelement("div")}}元素,在每个元素中有一个Mozilla页面地址。另外还包括一个 CSS文件和一个JavaScript文件,我们会在后面添加它们。</p>
+
+<p>在 "popup" 文件夹下,创建名为 "choose_page.css" 的文件,内容如下:</p>
+
+<pre class="brush: css">html, body {
+ width: 300px;
+}
+
+.page-choice {
+ width: 100%;
+ padding: 4px;
+ font-size: 1.5em;
+ text-align: center;
+ cursor: pointer;
+}
+
+.page-choice:hover {
+ background-color: #CFF2F2;
+}</pre>
+
+<p>这是我们弹出菜单的部分样式。</p>
+
+<p>接着,在 "popup" 文件夹下,创建名为 "choose_page.js" 的文件,内容如下:</p>
+
+<pre class="brush: js">document.addEventListener("click", function(e) {
+ if (!e.target.classList.contains("page-choice")) {
+ return;
+ }
+
+ var chosenPage = "https://" + e.target.textContent;
+ browser.tabs.create({
+ url: chosenPage
+ });
+
+});</pre>
+
+<p>在我们的脚本中,我们会监听单击的弹出项。首先检查单击的对象是否在给出的页面选择项中,如果不在,则不做任何处理;如果在,则从单击的页面选择项中获取URL地址,然后打开一个对应页面的新标签页。注意:我们在弹出脚本中使用WebExtension接口,和在后台脚本中使用接口一样。</p>
+
+<p>附加组件的结构最后看上去应该像下面这样:</p>
+
+<pre>button/
+ icons/
+ page-16.png
+ page-32.png
+ popup/
+ choose_page.css
+ choose_page.html
+ choose_page.js
+ manifest.json</pre>
+
+<p>重新加载附加组件,再次单击按钮,并尝试在弹出菜单中单击某个选择项:</p>
+
+<p>{{EmbedYouTube("QPEh1L1xq0Y")}}</p>
+
+<h2 id="页面行为">页面行为</h2>
+
+<p>页面行为<a href="/en-US/Add-ons/WebExtensions/User_interface_components#Page_actions">(Page actions)</a> 类似浏览器行为,只是页面行为仅针对特定页面,而浏览器行为则全局有效。</p>
+
+<p>由于浏览器行为总是发生,而页面行为只在特定页面显示。所以页面行为按钮在URL地址栏中显示,而浏览器行为按钮则在浏览器工具栏中显示。</p>
+
+<h2 id="了解更多">了解更多</h2>
+
+<ul>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_action">browser_action</a></code> manifest key</li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserAction">browserAction</a></code> API</li>
+ <li>Browser action examples:
+ <ul>
+ <li><a href="https://github.com/mdn/webextensions-examples/tree/master/beastify">beastify</a></li>
+ <li><a class="external external-icon" href="https://github.com/mdn/webextensions-examples/tree/master/bookmark-it">Bookmark it!</a></li>
+ <li><a class="external external-icon" href="https://github.com/mdn/webextensions-examples/tree/master/favourite-colour">favourite-colour</a></li>
+ <li><a class="external external-icon" href="https://github.com/mdn/webextensions-examples/tree/master/inpage-toolbar-ui">inpage-toolbar-ui</a></li>
+ <li><a class="external external-icon" href="https://github.com/mdn/webextensions-examples/tree/master/open-my-page-button">open-my-page-button</a></li>
+ </ul>
+ </li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/page_action">page_action</a></code> manifest key</li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/pageAction">pageAction</a></code> API</li>
+ <li>Page action examples:
+ <ul>
+ <li><a href="https://github.com/mdn/webextensions-examples/tree/master/chill-out">chill-out</a></li>
+ </ul>
+ </li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/anatomy_of_a_webextension/index.html b/files/zh-cn/mozilla/add-ons/webextensions/anatomy_of_a_webextension/index.html
new file mode 100644
index 0000000000..a405ac2f87
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/anatomy_of_a_webextension/index.html
@@ -0,0 +1,148 @@
+---
+title: 剖析拓展
+slug: Mozilla/Add-ons/WebExtensions/Anatomy_of_a_WebExtension
+tags:
+ - WebExtension
+ - 拓展
+ - 拓展开发
+translation_of: Mozilla/Add-ons/WebExtensions/Anatomy_of_a_WebExtension
+---
+<div>{{AddonSidebar}}</div>
+
+<p>拓展是指一个包含若干文件的安装包,可直接分发至用户。本文中,我们快速地介绍一遍安装包内可能出现的文件。</p>
+
+<h2 id="manifest.json">manifest.json</h2>
+
+<p>这是唯一一个在每个 WebExtension 里面必须存在的文件。它包含了关于这个扩展插件基本的元数据(metadata),比如它的名字、版本和所需权限。并且,它也对 WebExtension 中其他文件进行了链接。</p>
+
+<p>这个 manifest 文件还可以指向其它一些类型的文件:</p>
+
+<ul>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Background_scripts">background pages</a>: 执行一个长时间运行的逻辑</li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Content_scripts">content scripts</a>: 与网页进行交互(注意:这与JavaScript在页面中的 {{HTMLElement("script")}} 元素不一样)</li>
+ <li><a href="https://developer.mozilla.org/zh-CN/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Browser_actions_2">browser action files</a>: 在工具栏中添加按钮</li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Page_actions">page action files</a>: 在地址栏添加按钮</li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Options_pages">options pages</a>: 为用户定义一个可浏览的UI界面,可以改变插件的设置</li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Web_accessible_resources">web-accessible resources</a>: 使打包好的内容可用于网页与目录脚本</li>
+</ul>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/12954/webextension-anatomy.svg" style="display: block; height: 581px; margin-left: auto; margin-right: auto; width: 600px;"></p>
+
+<p>浏览其他的详细信息请到 <a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a> 。</p>
+
+<p>除了这些 manifest 引用的文件之外,扩展也可以携带额外的 <a href="https://developer.mozilla.org/zh-CN/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Extension_pages">Extension pages</a> 。</p>
+
+<h2 id="后台脚本">后台脚本</h2>
+
+<p>扩展常常需要独立于任何浏览器窗口或特定网页来维持一种长期的状态或者执行长期的操作。这就是后台脚本(background scripts)的职责。</p>
+
+<p>后台脚本将在拓展加载完毕后开始运行,直到拓展被禁用或卸载。只要获得了相应的<a href="/zh-CN/Add-ons/WebExtensions/manifest.json/permissions">权限</a>,你就可以在脚本中使用任何 <a href="/zh-CN/Add-ons/WebExtensions/API">WebExtension API</a>。</p>
+
+<h3 id="指定后台脚本">指定后台脚本</h3>
+
+<p>你可以通过在 manifest.json 中添加关键字 <code>background</code> 来引入后台脚本:</p>
+
+<pre class="brush: json">// manifest.json
+
+"background": {
+ "scripts": ["background-script.js"]
+}</pre>
+
+<p>可以添加多份后台脚本:而且,就像同一个网页中的多个脚本一样,它们将会运行在同一上下文环境中。</p>
+
+<p> </p>
+
+<p>与此同时,你也可以先引入一个后台页面,再在后台页面中引入脚本。这样做能为后台脚本添加 ES 6 模块支持,算是一个优势。</p>
+
+<p style="margin-bottom: 0em;"><strong>manifest.json</strong></p>
+
+<pre class="brush: json line-numbers language-json"><code class="language-json"><span class="comment token">// manifest.json</span>
+
+<span class="key token">"background":</span> <span class="punctuation token">{</span>
+ <span class="key token">"page":</span> <span class="string token">"background-page.html"</span>
+<span class="punctuation token">}</span></code></pre>
+
+<p style="margin-bottom: 0em;"><strong>background-page.html</strong></p>
+
+<pre class="brush: html line-numbers language-html"><code class="language-html"><span class="doctype token">&lt;!DOCTYPE html&gt;</span>
+<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>html</span> <span class="attr-name token">lang</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"zh-CN</span><span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span>
+ <span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>head</span><span class="punctuation token">&gt;</span></span>
+ <span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>meta</span> <span class="attr-name token">charset</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>utf-8<span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span>
+ <span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>script</span> <span class="attr-name token">type</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>module<span class="punctuation token">"</span></span> <span class="attr-name token">src</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>background-script.js<span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span><span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>script</span><span class="punctuation token">&gt;</span></span>
+ <span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>head</span><span class="punctuation token">&gt;</span></span>
+<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>html</span><span class="punctuation token">&gt;</span></span></code></pre>
+
+<p> </p>
+
+<h3 id="后台脚本的运行环境">后台脚本的运行环境</h3>
+
+<h4 id="DOM_API">DOM API</h4>
+
+<p>后台脚本在一个被称为后台页面的特殊页面的上下文环境中运行。此环境为其提供了全局变量 <code><a href="/zh-CN/docs/Web/API/Window">window</a></code> ,也提供了所有的标准 DOM API。</p>
+
+<h4 id="WebExtension_API">WebExtension API</h4>
+
+<p>只要扩展获得了必要的<a href="/zh-CN/Add-ons/WebExtensions/manifest.json/permissions">权限</a>,后台脚本就可以使用所有的 <a href="/zh-CN/Add-ons/WebExtensions/API">WebExtension API</a>。</p>
+
+<h4 id="跨域访问">跨域访问</h4>
+
+<p>后台脚本可以向任何拥有<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#%E4%B8%BB%E6%9C%BA%E6%9D%83%E9%99%90">主机权限</a>的主机发送 XHR 请求。</p>
+
+<h4 id="网页内容">网页内容</h4>
+
+<p>后台脚本没有直接访问页面的权限。不过,他们可以在页面中加载<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">内容脚本</a>(content scripts),并且可以<a href="/zh-CN/Add-ons/WebExtensions/Content_scripts#Communicating_with_background_scripts">通过 message-passing API 与内容脚本通信</a>。</p>
+
+<h4 id="内容安全策略">内容安全策略</h4>
+
+<p>根据一个内容安全策略(Content Security Policy),后台脚本不能执行一些可能有危险的操作,例如使用 <code><a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/eval">eval()</a></code>。 详情请参考<a href="/zh-CN/Add-ons/WebExtensions/Content_Security_Policy">内容安全策略</a>。</p>
+
+<h2 id="侧边栏,弹出窗口,选项页面">侧边栏,弹出窗口,选项页面</h2>
+
+<p>您的扩展程序可以包含各种用户界面组件,其内容通过 HTML 文件来定义:</p>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Sidebars">侧边栏</a>是一个窗格,它被显示在浏览器窗口左侧,就在网页旁边</li>
+ <li><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Popups">弹出窗口</a>是一个对话框,可以在用户单击<a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Browser_action">工具栏按钮</a>或<a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Page_actions">地址栏按钮</a>时显示该对话框</li>
+ <li><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Options_pages">选项页面</a>是当用户访问拓展在拓展管理器内置的拓展选项页面时内嵌显示的页面。</li>
+</ul>
+
+<p>对于这些组件,你可以创建一个 HTML 文件,并使用 <a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a> 中的特定属性指向它。HTML 文件可以引用 CSS 和 JavaScript 文件,就像普通的网页一样。</p>
+
+<p>所有这些都是<a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Extension_pages">扩展页面</a>的一种,与普通网页不同的是,你可以在其 JavaScript 中使用所有有权限使用的 WebExtension API。 它们甚至可以通过 {{WebExtAPIRef("runtime.getBackgroundPage()")}} 直接访问后台页面中的变量。</p>
+
+<h2 id="扩展页面">扩展页面</h2>
+
+<p>您也可以在扩展中包含HTML文档,这些文档不附加到某个预定义的用户界面组件。与您可能为侧边栏,弹出窗口或选项页面提供的文档不同,它们在manifest.json中没有条目。但是,他们也可以访问所有与您的后台脚本相同的特权WebExtension API。</p>
+
+<p>你通常可以使用 {{WebExtAPIRef("windows.create()")}} 或 {{WebExtAPIRef("tabs.create()")}}加载一个页面.</p>
+
+<p>若想了解更多,请参考 <a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Extension_pages">扩展页面</a>。</p>
+
+<h2 id="内容脚本">内容脚本</h2>
+
+<p>一般使用内容脚本来访问和操作页面。内容脚本会被加载到页面中并运行在页面的特定环境下。</p>
+
+<p>内容脚本是由扩展提供的脚本,与页面本身的脚本以及 {{HTMLElement("script")}} 标签中的脚本是不同的。</p>
+
+<p>内容脚本可以像普通脚本一样获取、操作页面的 DOM。</p>
+
+<p>与普通的页面内脚本不同,Content scripts可以:</p>
+
+<ul>
+ <li>执行跨域访问</li>
+ <li>使用 <a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API">WebExtension APIs </a>的子集</li>
+ <li>通过与后台脚本交换信息的方式,间接地使用所有<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API">WebExtension APIs </a></li>
+</ul>
+
+<p>内容脚本无法直接访问普通网页中的脚本,但是可以通过 <code><a href="/zh-CN/docs/Web/API/Window/postMessage">window.postMessage()</a></code> API 来与之传递信息。</p>
+
+<p>通常情况下,当我们讨论内容脚本时,是在指(一类)使用 JavaScript 编写的脚本,但是你也可以用同样的机制来注入 CSS 文件。(译者注:不讨论含有编译器的情况。例如,若你事先引入了可编译 TypeScript 的 JavaScript 内容脚本,不论性能问题,你也很可能可以引入使用 TypeScript 编写的内容脚本:类似这样的情况,在此不计。)</p>
+
+<p>若想了解更多,请参考<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">内容脚本</a>。</p>
+
+<h2 id="Web_accessible_resources">Web accessible resources</h2>
+
+<p>Web accessible resources 是指像图片、HTML、CSS 和 JavaScript 之类的、被引入插件并且想要获得访问权限的内容脚本和页面脚本。这些 web-accessible 的资源可以在页面脚本和内容脚本中通过使用特定的URL方案来引用。<br>
+ 举个例子来说,如果一个内容脚本想要把一些图片插入网页,你可以在插件中引入它们并且使他们成为web-accseeible。接下来内容脚本就可以创建并追加包含 <code>src</code> 属性的 <a href="/zh-CN/docs/Web/HTML/Element/img">img</a> 标签了。</p>
+
+<p>若想了解更多,请参考 manifest.json key 的文档:<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/web_accessible_resources">web_accessible_resources</a>。</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/alarms/create/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/alarms/create/index.html
new file mode 100644
index 0000000000..ac3bafecc4
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/alarms/create/index.html
@@ -0,0 +1,127 @@
+---
+title: alarms.create()
+slug: Mozilla/Add-ons/WebExtensions/API/alarms/create
+tags:
+ - API
+ - WebExtensions
+ - alarms
+ - 创建
+ - 参考
+ - 拓展
+ - 方法
+ - 附件
+ - 非标准
+translation_of: Mozilla/Add-ons/WebExtensions/API/alarms/create
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>创建一个新的alarm.</p>
+
+<h2 id="使用语法">使用语法</h2>
+
+<pre class="syntaxbox brush:js">browser.alarms.create(
+ name, // 可选的字符串(string)类型
+ alarmInfo // 可选的对象(object)类型
+)
+</pre>
+
+<h3 id="参数介绍">参数介绍</h3>
+
+<dl>
+ <dt><code>name</code>{{optional_inline}}</dt>
+ <dd><code>字符串(string)类型。</code>alarm的名称。默认为空的字符串。</dd>
+ <dd>alarm的名称可以在{{WebExtAPIRef('alarms.get()')}}方法和{{WebExtAPIRef('alarms.clear()')}}方法中引用。同时它也可以通过{{WebExtAPIRef('alarms.onAlarm')}}监听方法传入的参数对象{{WebExtAPIRef('alarms.Alarm')}}的name属性访问到。</dd>
+ <dd>Alarm的名称是唯一的 (在单个附件范围内). 如果传入了已经在这个附件存在的名称, 原来的同名alarm会被移除并且没有警告。</dd>
+ <dt><code>alarmInfo</code>{{optional_inline}}</dt>
+ <dd>
+ <p><code>对象(object)类型</code>. 你可以对过它来指定什么时间alarm会开始触发,其值可以是一个具体的时间值或者是一个延时(从alarm设置开始)。为了让alarm能复现,需要指定<code>periodInMinutes。</code></p>
+
+ <p>在Chrome浏览器上,除非附件以非打包(unpackaged)方式加载,alarm的创建每分钟不允许超过一次。如果附件尝试设置<code>delayInMinutes</code><code>为小于1的值,alarm只能在到达1分钟之后才会触发,并且会变成每分钟触发一次。</code></p>
+
+ <p><code>alarmInfo对象</code>可以设置以下属性:</p>
+ </dd>
+ <dd>
+ <dl class="reference-values">
+ <dt><code>when</code>{{optional_inline}}</dt>
+ <dd><code>double类型</code>. alarm第一次触发的时间,值为自1970-01-01 00:00:00 UTC过去的毫秒数。请使用<code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now">Date.now()</a>来获取</code>1970-01-01 00:00:00 UTC到<code>当前时间过去的毫秒数。如果你设置了when属性,请不要设置delayInMinutes属性。</code></dd>
+ <dt><code>delayInMinutes</code>{{optional_inline}}</dt>
+ <dd><code>double类型</code>. alarm设置好到第一次触发之间的分钟数。如果你设置了<code>delayInMinutes属性,请不要设置when属性。</code></dd>
+ <dt><code>periodInMinutes</code>{{optional_inline}}</dt>
+ <dd><code>double类型</code>. 如果设置此属性,alarm会从第一次触发开始每隔<code>periodInMinutes分钟再次触发。如果你没有设置when及delayInMinutes属性,alarm会在alarm设置好之后periodInMinutes分钟第一次触发。如果periodInMinutes属性没有设置,则alarm只会触发一次。</code></dd>
+ </dl>
+ </dd>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.alarms.create")}}</p>
+
+<h2 id="示例">示例</h2>
+
+<p>Create a one-time delay-based alarm with "" for the name:</p>
+
+<pre class="brush: js">const delayInMinutes = 5;
+
+<span class="pl-smi">browser</span>.<span class="pl-smi">alarms</span>.<span class="pl-en">create</span>({
+ delayInMinutes
+});</pre>
+
+<p>Create a periodic delay-based alarm named "my-periodic-alarm":</p>
+
+<pre class="brush: js">const delayInMinutes = 5;
+const periodInMinutes = 2;
+
+browser.alarms.create("my-periodic-alarm", {
+ delayInMinutes,
+ periodInMinutes
+});</pre>
+
+<p>Create a periodic absolute alarm named "my-periodic-alarm":</p>
+
+<pre class="brush: js">const when = 1545696000;
+const periodInMinutes = 2;
+
+browser.alarms.create("my-periodic-alarm", {
+ when,
+ periodInMinutes
+});</pre>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/alarms"><code>chrome.alarms</code></a> API.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/alarms/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/alarms/index.html
new file mode 100644
index 0000000000..66b7c52339
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/alarms/index.html
@@ -0,0 +1,58 @@
+---
+title: alarms
+slug: Mozilla/Add-ons/WebExtensions/API/alarms
+translation_of: Mozilla/Add-ons/WebExtensions/API/alarms
+---
+<div>{{AddonSidebar}}</div>
+
+<p>在未来一个特定的时间运行的计划任务代码。这很像<code><a href="/zh-CN/docs/Web/API/WindowTimers/setTimeout">setTimeout()</a></code>和<code><a href="/zh-CN/docs/Web/API/WindowTimers/setInterval">setInterval()</a></code>,不过这些函数仅可以按需使用而不能在后台页面工作。</p>
+
+<p>想要使用这个API,您需要获取"alarms"的<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a>。</p>
+
+<h2 id="类型">类型</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("alarms.Alarm")}}</dt>
+ <dd>Information about a particular alarm.</dd>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("alarms.create()")}}</dt>
+ <dd>创建新的alarm.</dd>
+ <dt>{{WebExtAPIRef("alarms.get()")}}</dt>
+ <dd>通过名称获取指定的alarm.</dd>
+ <dt>{{WebExtAPIRef("alarms.getAll()")}}</dt>
+ <dd>获取所有的alarm.</dd>
+ <dt>{{WebExtAPIRef("alarms.clear()")}}</dt>
+ <dd>清除指定名称的alarm.</dd>
+ <dt>{{WebExtAPIRef("alarms.clearAll()")}}</dt>
+ <dd>清除所有的alarm.</dd>
+</dl>
+
+<h2 id="事件">事件</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("alarms.onAlarm")}}</dt>
+ <dd>当alarm发生的时候触发.</dd>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("webextensions.api.alarms")}}</p>
+
+<div class="hidden note">
+<p>The "Chrome incompatibilities" section is included from <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities"> https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a> using the <a href="/en-US/docs/Template:WebExtChromeCompat">WebExtChromeCompat</a> macro.</p>
+
+<p>If you need to update this content, edit <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities">https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a>, then shift-refresh this page to see your changes.</p>
+</div>
+
+<p> {{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/alarms"><code>chrome.alarms</code></a> API.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/bookmarks/bookmarktreenode/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/bookmarks/bookmarktreenode/index.html
new file mode 100644
index 0000000000..bec868a18d
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/bookmarks/bookmarktreenode/index.html
@@ -0,0 +1,81 @@
+---
+title: bookmarks.BookmarkTreeNode
+slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/BookmarkTreeNode
+translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/BookmarkTreeNode
+---
+<p>{{AddonSidebar()}}</p>
+
+<p>代表书签树中的一个节点(书签或文件夹),子节点在它们的父文件夹中按顺序排列。</p>
+
+<h2 id="类型">类型</h2>
+
+<p>这种类型的值都是对象。它们包含以下属性:</p>
+
+<dl class="reference-values">
+ <dt><code>id</code></dt>
+ <dd><code>string</code>. 节点的唯一标识符。唯一标识符在当前用户配置文件中保证唯一,并且在浏览器重新启动后仍然有效。</dd>
+ <dt><code>parentId</code>{{optional_inline}}</dt>
+ <dd><code>string</code>. 父节点的标识符(id)。根节点没有此属性。</dd>
+ <dt><code>index</code>{{optional_inline}}</dt>
+ <dd><code>integer</code>. 该节点在父文件夹中的位置(从 0 开始)。</dd>
+ <dt><code>url</code>{{optional_inline}}</dt>
+ <dd><code>string</code>. 当用户单击书签时打开的URL。文件夹没有此属性。</dd>
+ <dt><code>title</code></dt>
+ <dd><code>string</code>. 该节点显示的文字。</dd>
+ <dt><code>dateAdded</code>{{optional_inline}}</dt>
+ <dd><code>number</code>. 该节点创建的时间,表示为自 1970 年 1 月 1 日午夜至今所经过的毫秒数(new Date(dateAdded))。</dd>
+ <dt><code>dateGroupModified</code>{{optional_inline}}</dt>
+ <dd><code>number</code>. 该文件夹内容的上一次修改时间,表示为自 1970 年 1 月 1 日午夜至今所经过的毫秒数。</dd>
+ <dt><code>unmodifiable</code>{{optional_inline}}</dt>
+ <dd>{{WebExtAPIRef('bookmarks.BookmarkTreeNodeUnmodifiable')}}. 表示该节点不可修改的原因,"<var>managed</var>"表示该节点由系统管理员配置。如果该节点可以由用户和扩展程序修改(默认)则省略。</dd>
+ <dt><code>children</code>{{optional_inline}}</dt>
+ <dd><code>array</code> of <code>{{WebExtAPIRef('bookmarks.BookmarkTreeNode')}}</code>. 该节点的所有子节点(已排序)。</dd>
+</dl>
+
+<p> </p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.bookmarks.BookmarkTreeNode", 10)}}</p>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/bookmarks#type-BookmarkTreeNode"><code>chrome.bookmarks</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/bookmarks/gettree/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/bookmarks/gettree/index.html
new file mode 100644
index 0000000000..10571a1642
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/bookmarks/gettree/index.html
@@ -0,0 +1,120 @@
+---
+title: bookmarks.getTree()
+slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/getTree
+tags:
+ - API
+ - WebExtensions
+ - getTree
+ - 书签
+ - 参考
+ - 拓展
+ - 方法
+ - 附件
+ - 非标准
+translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/getTree
+---
+<div>{{AddonSidebar()}}</div>
+
+<p><strong><code>bookmarks.getTree()</code></strong> 返回一个数组,该数组每一项为{{WebExtAPIRef("bookmarks.BookmarkTreeNode")}}对象,作为书签树的根节点。</p>
+
+<p>如果它们是文件夹的话,你可以通过其<code>children属性及其后代的children属性</code>递归地访问整个树。</p>
+
+<p>这是一个异步的函数,返回<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>。</code></p>
+
+<h2 id="使用格式">使用格式</h2>
+
+<pre class="syntaxbox brush:js">var gettingTree = browser.bookmarks.getTree()
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<p>无。</p>
+
+<h3 id="返回值">返回值</h3>
+
+<p><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>对象,该对象未来会得到一个填充代表根节点的</code><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/bookmarks/BookmarkTreeNode" title="An object of type bookmarks.BookmarkTreeNode represents a node in the bookmark tree, where each node is a bookmark or bookmark folder. Child nodes are ordered by an index within their respective parent folders.">bookmarks.BookmarkTreeNode</a>对象的数组。</code></p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p> </p>
+
+<p>{{Compat("webextensions.api.bookmarks.getTree")}}</p>
+
+<p> </p>
+
+<h2 id="示例">示例</h2>
+
+<p>这个示例会打印出整个书签树:</p>
+
+<pre class="brush: js">function makeIndent(indentLength) {
+ return ".".repeat(indentLength);
+}
+
+function logItems(bookmarkItem, indent) {
+ if (bookmarkItem.url) {
+ console.log(makeIndent(indent) + bookmarkItem.url);
+ } else {
+ console.log(makeIndent(indent) + "Folder");
+ indent++;
+ }
+ if (bookmarkItem.children) {
+ for (child of bookmarkItem.children) {
+ logItems(child, indent);
+ }
+ }
+ indent--;
+}
+
+function logTree(bookmarkItems) {
+ logItems(bookmarkItems[0], 0);
+}
+
+function onRejected(error) {
+  console.log(`An error: ${error}`);
+}
+
+var gettingTree = browser.bookmarks.getTree();
+gettingTree.then(logTree, onRejected);
+</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/bookmarks#method-getTree"><code>chrome.bookmarks</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/bookmarks/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/bookmarks/index.html
new file mode 100644
index 0000000000..06155a5972
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/bookmarks/index.html
@@ -0,0 +1,128 @@
+---
+title: bookmarks
+slug: Mozilla/Add-ons/WebExtensions/API/bookmarks
+translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks
+---
+<div>{{AddonSidebar}}</div>
+
+<p>此<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions">WebExtensions</a> {{WebExtAPIRef("bookmarks")}} API允许一个附加组件和浏览器的书签系统交互和操作。您可以用它给页面加书签,获取已有的书签,以及编辑,移除和管理书签。</p>
+
+<p>欲使用此API,一个附件组件必须请求"bookmarks" <a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a>在它的<code><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a></code>文件当中。</p>
+
+<h2 id="类型">类型</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("bookmarks.BookmarkTreeNode")}}</dt>
+ <dd>表示在书签树中的一个书签或者文件夹。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.BookmarkTreeNodeType")}}</dt>
+ <dd>一个描述在树中的一个节点是否是一个书签,一个文件夹或是一个分割符的 {{jsxref("String")}} 枚举类型。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.BookmarkTreeNodeUnmodifiable")}}</dt>
+ <dd>一个说明了为什么一个书签或者文件夹是不可修改的 {{jsxref("String")}} 枚举类型。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.CreateDetails")}}</dt>
+ <dd>当创建一个新书签时,包含被传递给这个 {{WebExtAPIRef("bookmarks.create()")}} 函数的信息。</dd>
+</dl>
+
+<dl>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("bookmarks.create()")}}</dt>
+ <dd>创建一个书签或文件夹。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.get()")}}</dt>
+ <dd>获得一个或者多个{{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode")}},提供一个书签的编号或者一个书签编号的数组。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.getChildren()")}}</dt>
+ <dd>获取指定{{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode")}}节点的所有子节点。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.getRecent()")}}</dt>
+ <dd>获取最近添加的几个书签。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.getSubTree()")}}</dt>
+ <dd>获取从指定节点开始的部分书签树。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.getTree()")}}</dt>
+ <dd>获取整个书签树。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.search()")}}</dt>
+ <dd>搜索书签树节点,找出匹配的结果。如果以对象方式指定查询,得到的 BookmarkTreeNodes 匹配所有指定的属性。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.create()")}}</dt>
+ <dd>在指定的上一级文件夹下创建新的书签或文件夹。如果 url 为 null 或者省略,则创建文件夹。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.move()")}}</dt>
+ <dd>将指定的书签树节点移到指定位置</dd>
+ <dt>{{WebExtAPIRef("bookmarks.update()")}}</dt>
+ <dd>更新书签或文件夹的属性。只需要指定您需要更改的属性,未指定的属性不会更改。注意:目前只支持“title”和“url”属性。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.remove()")}}</dt>
+ <dd>删除书签或者空文件夹。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.removeTree()")}}</dt>
+ <dd>删除整个书签文件夹。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.import()")}}</dt>
+ <dd>从一个html书签文件导入书签</dd>
+ <dt>{{WebExtAPIRef("bookmarks.export()")}}</dt>
+ <dd>导出书签为一个html书签文件</dd>
+</dl>
+
+<h2 id="事件">事件</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("bookmarks.onCreated")}}</dt>
+ <dd>当书签或文件夹创建时产生。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.onRemoved")}}</dt>
+ <dd>当删除书签或文件夹时产生。当删除整个文件夹(包括其中所有内容)时,仅为该文件夹发送通知,不为其中任何内容发送通知。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.onChanged")}}</dt>
+ <dd>一个书签或文件夹更改时发生。注意:目前只有标题和URL更改时会触发这一事件。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.onMoved")}}</dt>
+ <dd>当书签或文件夹移动到另一个父文件夹中时产生。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.onChildrenReordered")}}</dt>
+ <dd>文件夹中的子节点在用户界面中调整顺序时产生。调用 move() 不会触发该事件。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.onImportBegan")}}</dt>
+ <dd>开始导入书签时产生。复杂的事件处理函数在这一事件产生后不应该再处理 onCreated 事件,直到 onImportEnded 事件产生,在此过程中其他事件仍然应该立即处理。</dd>
+ <dt>{{WebExtAPIRef("bookmarks.onImportEnded")}}</dt>
+ <dd>书签导入结束时产生。</dd>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("webextensions.api.bookmarks")}}</p>
+
+<div class="hidden note">
+<p>The "Chrome incompatibilities" section is included from <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities"> https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a> using the <a href="/en-US/docs/Template:WebExtChromeCompat">WebExtChromeCompat</a> macro.</p>
+
+<p>If you need to update this content, edit <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities">https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a>, then shift-refresh this page to see your changes.</p>
+</div>
+
+<p>{{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/bookmarks"><code>chrome.bookmarks</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/bookmarks/remove/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/bookmarks/remove/index.html
new file mode 100644
index 0000000000..ee23ed285e
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/bookmarks/remove/index.html
@@ -0,0 +1,106 @@
+---
+title: bookmarks.remove()
+slug: Mozilla/Add-ons/WebExtensions/API/bookmarks/remove
+tags:
+ - API
+ - Add-ons
+ - Bookmarks
+ - Method
+ - remove
+ - 书签
+ - 参考文档
+ - 扩展
+ - 方法
+ - 移除
+translation_of: Mozilla/Add-ons/WebExtensions/API/bookmarks/remove
+---
+<div>{{AddonSidebar()}}</div>
+
+<p> <strong><code>bookmarks.remove()</code></strong> 方法用于删除单个书签或一个空的书签文件夹。</p>
+
+<div class="blockIndicator warning">
+<p>如果你的扩展尝试从书签树的根节点中移除一个书签,该调用将会引发一个“书签根不能被修改的”的错误信息并且这个书签不会被移除。</p>
+</div>
+
+<p><code>这是一个异步方法,返回<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>对象。</code></p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox brush:js">var removingBookmark = browser.bookmarks.remove(
+ id // 字符串
+)
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>id</code></dt>
+ <dd>{{jsxref("string")}} 要删除的书签或空书签文件夹的id标识</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>若方法执行完成,返回一个无参的 <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>对象。</code></p>
+
+<p>若未找到该书签或该空书签文件夹,将返回一个带有错误信息的<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>对象。</code></p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.bookmarks.remove")}}</p>
+
+<h2 id="例子">例子</h2>
+
+<pre class="brush: js">function onRemoved() {
+ console.log("Removed!");
+}
+
+function onRejected(error) {
+ console.log(`An error: ${error}`);
+}
+
+var bookmarkId = "abcdefghijkl";
+
+var removingBookmark = browser.bookmarks.remove(bookmarkId);
+removingBookmark.then(onRemoved, onRejected);</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/bookmarks#method-remove"><code>chrome.bookmarks</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/bookmarks.json"><code>bookmarks.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/browseraction/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/browseraction/index.html
new file mode 100644
index 0000000000..2d49dff094
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/browseraction/index.html
@@ -0,0 +1,116 @@
+---
+title: browserAction
+slug: Mozilla/Add-ons/WebExtensions/API/browserAction
+translation_of: Mozilla/Add-ons/WebExtensions/API/browserAction
+---
+<div>{{AddonSidebar}}</div>
+
+<p>添加按钮到浏览器的工具栏。</p>
+
+<p>您可以为该按钮指派一个弹出窗。弹出窗可采用 HTML、CSS 和 JavaScript 编写,就像是一个普通的网页。运行在该弹出窗中的 JavaScript 可以同您的后台脚本一样访问所有的 WebExtension API,但它的全局上下文是该弹出窗,而不是浏览器中的当前页面。要影响网页,您需要通过<a href="/en-US/Add-ons/WebExtensions/Modify_a_web_page#Messaging">消息</a>通信。</p>
+
+<p>如果您指定了弹出窗,它将显示——内容将在用户点击该图标时被加载。如果您没有指定一个弹出窗,用户单击该图标的事件将派发到您的扩展。</p>
+
+<p>您可以用 manifest.json 中的 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_action">browser_action</a></code> 键值声明定义大多数浏览器动作属性。</p>
+
+<p>使用 <code>browserAction</code> API,您可以:</p>
+
+<ul>
+ <li>使用 {{WebExtAPIRef("browserAction.onClicked")}} 监听该图标的点击事件。</li>
+ <li>获取和设置该图标的属性——图标、标题、弹出窗等。 You can get and set these globally across all tabs, or for a specific tab by passing the tab ID as an additional argument.</li>
+</ul>
+
+<p>另见<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/User_interface_components">用户界面组件</a>中的浏览器动作章节。</p>
+
+<h2 id="类型">类型</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("browserAction.ColorArray")}}</dt>
+ <dd>0-255范围内的四个整数的数组,定义RGBA颜色。</dd>
+ <dt>{{WebExtAPIRef("browserAction.ImageDataType")}}</dt>
+ <dd>一个图像的像素数据。必须为一个 <code><a href="/en-US/docs/Web/API/ImageData">ImageData</a></code> 对象(例如,来自一个 {{htmlelement("canvas")}} 元素)。</dd>
+</dl>
+
+<h2 id="函数">函数</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("browserAction.setTitle()")}}</dt>
+ <dd>设置浏览器动作的标题。这将在工具提示(鼠标悬停时)显示。</dd>
+ <dt>{{WebExtAPIRef("browserAction.getTitle()")}}</dt>
+ <dd>获取浏览器动作的标题。</dd>
+ <dt>{{WebExtAPIRef("browserAction.setIcon()")}}</dt>
+ <dd>设置浏览器动作的图标。</dd>
+ <dt>{{WebExtAPIRef("browserAction.setPopup()")}}</dt>
+ <dd>设置 HTML 文档作为浏览器动作图标被用户点击时显示的弹出窗。</dd>
+ <dt>{{WebExtAPIRef("browserAction.getPopup()")}}</dt>
+ <dd>获取作为浏览器动作的弹出窗的 HTML 文档。</dd>
+ <dt>{{WebExtAPIRef("browserAction.setBadgeText()")}}</dt>
+ <dd>设置浏览器动作的徽章文本。该徽章显示在图标上方。</dd>
+ <dt>{{WebExtAPIRef("browserAction.getBadgeText()")}}</dt>
+ <dd>获取浏览器动作的徽章文本。</dd>
+ <dt>{{WebExtAPIRef("browserAction.setBadgeBackgroundColor()")}}</dt>
+ <dd>设置徽章的后台颜色。</dd>
+ <dt>{{WebExtAPIRef("browserAction.getBadgeBackgroundColor()")}}</dt>
+ <dd>获取徽章的后台颜色。</dd>
+ <dt>{{WebExtAPIRef("browserAction.enable()")}}</dt>
+ <dd>为一个标签页启用浏览器动作。默认情况下,浏览器动作为所有标签页启用。</dd>
+ <dt>{{WebExtAPIRef("browserAction.disable()")}}</dt>
+ <dd>为一个标签页禁用浏览器动作,使该标签页为活动时无法单击它。</dd>
+</dl>
+
+<h2 id="事件">事件</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("browserAction.onClicked")}}</dt>
+ <dd>在浏览器动作图标点击时被触发。如果浏览器动作有弹出窗,则该事件不会触发。</dd>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("webextensions.api.browserAction")}}</p>
+
+<div class="hidden note">
+<p>"Chrome兼容性"是从 <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities"> https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a> 包含,使用<a href="/en-US/docs/Template:WebExtChromeCompat">WebExtChromeCompat</a>宏。</p>
+
+<p>如果你需要更新此章节,编辑 <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities">https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a>,然后刷新查看更改。</p>
+</div>
+
+<p>{{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>致谢</strong>
+
+<p>此 API 基于 Chromium 的 <a href="https://developer.chrome.com/extensions/browserAction"><code>chrome.browserAction</code></a> API。此文档派生自 Chromium 代码中的 <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/browser_action.json"><code>browser_action.json</code></a>。</p>
+
+<p>Microsoft Edge 兼容性数据由微软公司提供,并以 知识共享 署名 3.0 美国版 许可。</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/captiveportal/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/captiveportal/index.html
new file mode 100644
index 0000000000..f58017fba8
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/captiveportal/index.html
@@ -0,0 +1,90 @@
+---
+title: captivePortal
+slug: Mozilla/Add-ons/WebExtensions/API/captivePortal
+tags:
+ - API
+ - Add-ons
+ - Extensions
+ - NeedsTranslation
+ - Non-standard
+ - Reference
+ - TopicStub
+ - WebExtensions
+ - captivePortal
+translation_of: Mozilla/Add-ons/WebExtensions/API/captivePortal
+---
+<div>{{AddonSidebar}}</div>
+
+<p>Determine the captive portal state of the user’s connection. A captive portal is a web page displayed when a user first connects to a Wi-Fi network. The user provides information or acts on the captive portal web page to gain broader access to network resources, such as accepting terms and conditions or making a payment. </p>
+
+<p>To use this API you need to have the "captivePortal" <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a>.</p>
+
+<h2 id="Properties">Properties</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("captivePortal.canonicalURL")}}</dt>
+ <dd>Return the canonical URL of the captive-portal detection page. Read-only.</dd>
+</dl>
+
+<h2 id="Functions">Functions</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("captivePortal.getLastChecked()")}}</dt>
+ <dd>Returns the time, in milliseconds, since the last request was completed.</dd>
+ <dt>{{WebExtAPIRef("captivePortal.getState()")}}</dt>
+ <dd>Returns the portal state as one of <code>unknown</code>, <code>not_captive</code>, <code>unlocked_portal</code>, or <code>locked_portal</code>.</dd>
+</dl>
+
+<h2 id="Events">Events</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("captivePortal.onConnectivityAvailable")}}</dt>
+ <dd>Fires when the captive portal service determines that the user can connect to the internet.</dd>
+ <dt>{{WebExtAPIRef("captivePortal.onStateChanged")}}</dt>
+ <dd>
+ <p>Fires when the captive portal state changes.</p>
+ </dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{Compat("webextensions.api.captivePortal")}}</p>
+
+<div class="hidden note">
+<p>The "Chrome incompatibilities" section is included from <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities"> https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a> using the <a href="/en-US/docs/Template:WebExtChromeCompat">WebExtChromeCompat</a> macro.</p>
+
+<p>If you need to update this content, edit <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities">https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a>, then shift-refresh this page to see your changes.</p>
+</div>
+
+<p>{{WebExtExamples("h2")}}</p>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/captiveportal/onstatechanged/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/captiveportal/onstatechanged/index.html
new file mode 100644
index 0000000000..3211026253
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/captiveportal/onstatechanged/index.html
@@ -0,0 +1,94 @@
+---
+title: onStateChanged
+slug: Mozilla/Add-ons/WebExtensions/API/captivePortal/onStateChanged
+translation_of: Mozilla/Add-ons/WebExtensions/API/captivePortal/onStateChanged
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>Fires when the captive portal state changes.</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox brush:js">browser.captivePortal.onStateChanged.addListener(callback)
+browser.captivePortal.onStateChanged.removeListener(listener)
+browser.captivePortal.onStateChanged.hasListener(listener)
+</pre>
+
+<p>Events have three functions:</p>
+
+<dl>
+ <dt><code>addListener(callback)</code></dt>
+ <dd>Adds a listener to this event.</dd>
+ <dt><code>removeListener(listener)</code></dt>
+ <dd>Stop listening to this event. The <code>listener</code> argument is the listener to remove.</dd>
+ <dt><code>hasListener(listener)</code></dt>
+ <dd>Check whether <code>listener</code> is registered for this event. Returns <code>true</code> if it is listening, <code>false</code> otherwise.</dd>
+</dl>
+
+<h2 id="addListener_syntax">addListener syntax</h2>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt><code>callback</code></dt>
+ <dd>
+ <p>Function that is called when this event occurs. The function is passed the following arguments:</p>
+
+ <dl class="reference-values">
+ <dt><code>details</code></dt>
+ <dd>
+ <p><code>string</code> The captive portal state, being one of <code>unknown</code>, <code>not_captive</code>, <code>unlocked_portal</code>, or <code>locked_portal</code>.</p>
+ </dd>
+ </dl>
+ </dd>
+</dl>
+
+<h2 id="Examples">Examples</h2>
+
+<p>Handle a change in captive portal status:</p>
+
+<pre class="brush: js">function handlePortalStatus(portalstatusInfo) {
+ console.log("The portal status is now: " + portalstatusInfo.details);
+}
+
+browser.captivePortal.onStateChanged.addListener(handlePortalStatus)
+</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.captivePortal.onStateChanged")}}</p>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/contentscripts/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/contentscripts/index.html
new file mode 100644
index 0000000000..544b32d556
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/contentscripts/index.html
@@ -0,0 +1,41 @@
+---
+title: contentScripts
+slug: Mozilla/Add-ons/WebExtensions/API/contentScripts
+tags:
+ - API
+ - WebExtensions
+translation_of: Mozilla/Add-ons/WebExtensions/API/contentScripts
+---
+<div>{{AddonSidebar}}</div>
+
+<p>使用此 API 以注册内容脚本。“注册内容脚本”意味着浏览器会将给定的内容脚本插入到每个与给定的 URL 模式相匹配的页面中。</p>
+
+<p>此 API 与 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a></code> 的  <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts">"content_scripts"</a></code> 键非常相似,但  <code>"content_scripts"</code> 键所能注册的内容脚本是固定的,自拓展安装后便不可更改。但<span class="seoSummary">通过 <code>contentScripts</code> API,拓展可以在运行时动态地注册或取消注册脚本。</span></p>
+
+<p>To use the API, call {{WebExtAPIRef("contentScripts.register()")}} passing in an object defining the scripts to register, the URL patterns, and other options. This returns a <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> that is resolved with a {{WebExtAPIRef("contentScripts.RegisteredContentScript")}} object.</p>
+
+<p>The <code>RegisteredContentScript</code> object represents the scripts that were registered in the <code>register()</code> call. It defines an <code>unregister()</code> method that you can use to unregister the content scripts. Content scripts are also unregistered automatically when the page that created them is destroyed. For example, if they are registered from the background page they will be unregistered automatically when the background page is destroyed, and if they are registered from a sidebar or a popup, they will be unregistered automatically when the sidebar or popup is closed.</p>
+
+<p>没有与 <code>contentScripts</code> API 相关联的权限,但是拓展必须拥有与其试图通过 <code>register()</code> 注册的脚本的匹配模式相对应的<a href="/zh-CN/Add-ons/WebExtensions/manifest.json/permissions#Host_permissions">主机权限</a>,才能实现注入。</p>
+
+<h2 id="类型">类型</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("contentScripts.RegisteredContentScript")}}</dt>
+ <dd>
+ <p>{{WebExtAPIRef("contentScripts.register()")}} 函数会返回一个持有此类型的对象。它表示被通过调用此函数注册的内容脚本,可被用于取消注册对应的内容脚本。</p>
+ </dd>
+</dl>
+
+<h2 id="函数">函数</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("contentScripts.register()")}}</dt>
+ <dd>注册给定的内容脚本。</dd>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("webextensions.api.contentScripts", 10, 1)}}</p>
+
+<p>{{WebExtExamples("h2")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/contextmenus/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/contextmenus/index.html
new file mode 100644
index 0000000000..ffcb6ce7b7
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/contextmenus/index.html
@@ -0,0 +1,191 @@
+---
+title: contextMenus
+slug: Mozilla/Add-ons/WebExtensions/API/contextMenus
+tags:
+ - API
+ - WebExtensions
+ - contextMenus
+translation_of: Mozilla/Add-ons/WebExtensions/API/menus
+---
+<div>{{AddonSidebar}}</div>
+
+<div>在浏览器菜单中添加条目。</div>
+
+<div></div>
+
+<div>此API基于Chrome的“contextMenus”API构建,该API可让Chrome扩展程序将项目添加到浏览器的上下文菜单中。 <code>browser.menus</code> API为Chrome的API添加了一些功能,特别是可以将项目添加到浏览器的“工具”菜单以及上下文菜单中。</div>
+
+<div></div>
+
+<div>在Firefox 55之前,这个API最初也被命名为<code>contextMenus</code>,并且这个名字被保留为别名,所以你可以使用<code>contextMenus</code>编写在Firefox和其他浏览器中工作的代码。</div>
+
+<div></div>
+
+<div>你需要拥有“menus”(或别名" contextMenus ")权限来使用此API。</div>
+
+<h2 id="创建菜单项">创建菜单项</h2>
+
+<p>使用 {{WebExtAPIRef("menus.create()")}}方法创建一个菜单项。你需要传递一个包含条目选项的对象,它包括条目的id,类型,和需要显示出来的文本值。</p>
+
+<p>绑定一个监听器到{{WebExtAPIRef("contextMenus.onClicked")}}事件来监听你菜单项目的点击事件。此监听器会传递一个{{WebExtAPIRef("contextMenus.OnClickData")}},它包含该事件的详细信息。</p>
+
+<p>你可以根据在调用<code>create()</code>时所传递的参数中使用不同的<code>type</code>值来创建四种不同类型的菜单:</p>
+
+<ul>
+ <li>"normal":只显示为一个标签的菜单项</li>
+ <li>"checkbox":一个表示二进制状态的菜单项。 它在菜单项旁边显示一个复选标记。 点击该菜单项切换复选标记。监听器会被传递两个额外的属性:“checked”,指示当前是否被选中,以及“wasChecked”,指示在此点击事件发生前是否被选中。</li>
+ <li>"radio":表示一组选项之一的上下文菜单项。 类似于复选框,它也在菜单项旁边显示一个复选标记,监听它的监听器也会被传递“checked”和“wasChecked”。 但是,如果您创建多个单选项,则这些项目将作为一组单选:组内只能选择一项,点击菜单项来选中它。</li>
+ <li>"separator":用于分割菜单的分割线。</li>
+</ul>
+
+<p>如果您创建了多个上下文菜单项目或多个工具菜单项目,则这些项目将被放置在子菜单中。 子菜单的父项将标有扩展名。 例如,下面是一个名为“Menu Demo”的扩展,添加了两个上下文菜单项:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/15431/menus-1.png" style="display: block; height: 501px; margin-left: auto; margin-right: auto; width: 700px;"></p>
+
+<h2 id="图标">图标</h2>
+
+<p>如果你使用 <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/icons">"icons" manifest key</a> 为你的扩展指定一个图标,你的菜单项的旁边就会显示一个指定的图标。浏览器会尝试在普通分辨率下使用16 x 16像素的图标,在高分辨率下使用32 x 32像素的图标:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/15433/menus-2.png" style="display: block; height: 409px; margin-left: auto; margin-right: auto; width: 500px;"> 你可以通过调用 {{WebExtAPIRef("menus.create()")}} 时指定icons选项来给子菜单项设置图标。</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/15435/menus-3.png" style="display: block; height: 396px; margin-left: auto; margin-right: auto; width: 500px;"></p>
+
+<h2 id="例子">例子</h2>
+
+<p>下面是一个包含四个项目的菜单,他们分别是:一个普通选项,两个周围有分割线的单选,和一个复选框。单选框使用了自定义图标。</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/15437/menus-4.png" style="display: block; height: 790px; margin-left: auto; margin-right: auto; width: 500px;"></p>
+
+<p>你可以使用以下代码创建一个这样的子菜单:</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js">browser<span class="punctuation token">.</span>menus<span class="punctuation token">.</span><span class="function token">create</span><span class="punctuation token">(</span><span class="punctuation token">{</span>
+ id<span class="punctuation token">:</span> <span class="string token">"remove-me"</span><span class="punctuation token">,</span>
+ title<span class="punctuation token">:</span> browser<span class="punctuation token">.</span>i18n<span class="punctuation token">.</span><span class="function token">getMessage</span><span class="punctuation token">(</span><span class="string token">"menuItemRemoveMe"</span><span class="punctuation token">)</span><span class="punctuation token">,</span>
+ contexts<span class="punctuation token">:</span> <span class="punctuation token">[</span><span class="string token">"all"</span><span class="punctuation token">]</span>
+<span class="punctuation token">}</span><span class="punctuation token">,</span> onCreated<span class="punctuation token">)</span><span class="punctuation token">;</span>
+
+browser<span class="punctuation token">.</span>menus<span class="punctuation token">.</span><span class="function token">create</span><span class="punctuation token">(</span><span class="punctuation token">{</span>
+ id<span class="punctuation token">:</span> <span class="string token">"separator-1"</span><span class="punctuation token">,</span>
+ type<span class="punctuation token">:</span> <span class="string token">"separator"</span><span class="punctuation token">,</span>
+ contexts<span class="punctuation token">:</span> <span class="punctuation token">[</span><span class="string token">"all"</span><span class="punctuation token">]</span>
+<span class="punctuation token">}</span><span class="punctuation token">,</span> onCreated<span class="punctuation token">)</span><span class="punctuation token">;</span>
+
+browser<span class="punctuation token">.</span>menus<span class="punctuation token">.</span><span class="function token">create</span><span class="punctuation token">(</span><span class="punctuation token">{</span>
+ id<span class="punctuation token">:</span> <span class="string token">"greenify"</span><span class="punctuation token">,</span>
+ type<span class="punctuation token">:</span> <span class="string token">"radio"</span><span class="punctuation token">,</span>
+ title<span class="punctuation token">:</span> browser<span class="punctuation token">.</span>i18n<span class="punctuation token">.</span><span class="function token">getMessage</span><span class="punctuation token">(</span><span class="string token">"menuItemGreenify"</span><span class="punctuation token">)</span><span class="punctuation token">,</span>
+ contexts<span class="punctuation token">:</span> <span class="punctuation token">[</span><span class="string token">"all"</span><span class="punctuation token">]</span><span class="punctuation token">,</span>
+ checked<span class="punctuation token">:</span> <span class="keyword token">true</span><span class="punctuation token">,</span>
+ icons<span class="punctuation token">:</span> <span class="punctuation token">{</span>
+ <span class="string token">"16"</span><span class="punctuation token">:</span> <span class="string token">"icons/paint-green-16.png"</span><span class="punctuation token">,</span>
+ <span class="string token">"32"</span><span class="punctuation token">:</span> <span class="string token">"icons/paint-green-32.png"</span>
+ <span class="punctuation token">}</span>
+<span class="punctuation token">}</span><span class="punctuation token">,</span> onCreated<span class="punctuation token">)</span><span class="punctuation token">;</span>
+
+browser<span class="punctuation token">.</span>menus<span class="punctuation token">.</span><span class="function token">create</span><span class="punctuation token">(</span><span class="punctuation token">{</span>
+ id<span class="punctuation token">:</span> <span class="string token">"bluify"</span><span class="punctuation token">,</span>
+ type<span class="punctuation token">:</span> <span class="string token">"radio"</span><span class="punctuation token">,</span>
+ title<span class="punctuation token">:</span> browser<span class="punctuation token">.</span>i18n<span class="punctuation token">.</span><span class="function token">getMessage</span><span class="punctuation token">(</span><span class="string token">"menuItemBluify"</span><span class="punctuation token">)</span><span class="punctuation token">,</span>
+ contexts<span class="punctuation token">:</span> <span class="punctuation token">[</span><span class="string token">"all"</span><span class="punctuation token">]</span><span class="punctuation token">,</span>
+ checked<span class="punctuation token">:</span> <span class="keyword token">false</span><span class="punctuation token">,</span>
+ icons<span class="punctuation token">:</span> <span class="punctuation token">{</span>
+ <span class="string token">"16"</span><span class="punctuation token">:</span> <span class="string token">"icons/paint-blue-16.png"</span><span class="punctuation token">,</span>
+ <span class="string token">"32"</span><span class="punctuation token">:</span> <span class="string token">"icons/paint-blue-32.png"</span>
+ <span class="punctuation token">}</span>
+<span class="punctuation token">}</span><span class="punctuation token">,</span> onCreated<span class="punctuation token">)</span><span class="punctuation token">;</span>
+
+browser<span class="punctuation token">.</span>menus<span class="punctuation token">.</span><span class="function token">create</span><span class="punctuation token">(</span><span class="punctuation token">{</span>
+ id<span class="punctuation token">:</span> <span class="string token">"separator-2"</span><span class="punctuation token">,</span>
+ type<span class="punctuation token">:</span> <span class="string token">"separator"</span><span class="punctuation token">,</span>
+ contexts<span class="punctuation token">:</span> <span class="punctuation token">[</span><span class="string token">"all"</span><span class="punctuation token">]</span>
+<span class="punctuation token">}</span><span class="punctuation token">,</span> onCreated<span class="punctuation token">)</span><span class="punctuation token">;</span>
+
+<span class="keyword token">var</span> checkedState <span class="operator token">=</span> <span class="keyword token">true</span><span class="punctuation token">;</span>
+
+browser<span class="punctuation token">.</span>menus<span class="punctuation token">.</span><span class="function token">create</span><span class="punctuation token">(</span><span class="punctuation token">{</span>
+ id<span class="punctuation token">:</span> <span class="string token">"check-uncheck"</span><span class="punctuation token">,</span>
+ type<span class="punctuation token">:</span> <span class="string token">"checkbox"</span><span class="punctuation token">,</span>
+ title<span class="punctuation token">:</span> browser<span class="punctuation token">.</span>i18n<span class="punctuation token">.</span><span class="function token">getMessage</span><span class="punctuation token">(</span><span class="string token">"menuItemUncheckMe"</span><span class="punctuation token">)</span><span class="punctuation token">,</span>
+ contexts<span class="punctuation token">:</span> <span class="punctuation token">[</span><span class="string token">"all"</span><span class="punctuation token">]</span><span class="punctuation token">,</span>
+ checked<span class="punctuation token">:</span> checkedState
+<span class="punctuation token">}</span><span class="punctuation token">,</span> onCreated<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+
+<h2 id="类型">类型</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("contextMenus.ContextType")}}</dt>
+ <dd>菜单里可以出现的不同内容。可能的值有:"all", "audio", "browser_action", "editable", "frame", "image", "link", "page", "page_action", "password", "selection", "tab", "video".</dd>
+ <dt>{{WebExtAPIRef("contextMenus.ItemType")}}</dt>
+ <dd>菜单项的类别有: "normal", "checkbox", "radio", "separator".</dd>
+ <dt>{{WebExtAPIRef("contextMenus.OnClickData")}}</dt>
+ <dd>当菜单项被点击时发送的信息。</dd>
+</dl>
+
+<h2 id="属性">属性</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("contextMenus.ACTION_MENU_TOP_LEVEL_LIMIT")}}</dt>
+ <dd>可以被添加进上下文菜单项的顶级扩展项的最大值,其ContextType可以是"browser_action" 或者 "page_action".</dd>
+</dl>
+
+<h2 id="函数">函数</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("contextMenus.create()")}}</dt>
+ <dd>创建一个新的上下文菜单项目。</dd>
+ <dt>{{WebExtAPIRef("contextMenus.update()")}}</dt>
+ <dd>更新一个已经创建了的上下文菜单项目。</dd>
+ <dt>{{WebExtAPIRef("contextMenus.remove()")}}</dt>
+ <dd>删除一个上下文菜单项目。</dd>
+ <dt>{{WebExtAPIRef("contextMenus.removeAll()")}}</dt>
+ <dd>移除该插件创建的所有上下文菜单项目。</dd>
+</dl>
+
+<h2 id="事件">事件</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("contextMenus.onClicked")}}</dt>
+ <dd>当一个上下文菜单项被点击时触发。</dd>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{ Compat("webextensions.api.menus", 1, "true") }}</p>
+
+<p>{{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>致谢</strong>
+
+<p>此API基于Chromium的 <a href="https://developer.chrome.com/extensions/contextMenus"><code>chrome.contextMenus</code></a> API. 此文档来自于Chromium代码中的<a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/context_menus.json"><code>context_menus.json</code></a>。</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/cookies/cookie/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/cookies/cookie/index.html
new file mode 100644
index 0000000000..1a5c4dfdd4
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/cookies/cookie/index.html
@@ -0,0 +1,121 @@
+---
+title: cookies.Cookie
+slug: Mozilla/Add-ons/WebExtensions/API/cookies/Cookie
+translation_of: Mozilla/Add-ons/WebExtensions/API/cookies/Cookie
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>The <code>Cookie</code> type of the {{WebExtAPIRef("cookies")}} API represents information about an HTTP cookie.</p>
+
+<h2 id="类型">类型</h2>
+
+<p>这玩意是一个 Object,可以包含以下的属性:</p>
+
+<dl class="reference-values">
+ <dt><code>domain</code></dt>
+ <dd>储存这个 cookie 对应网站的字符串 (例如 "www.tengxun.com")。</dd>
+ <dt><code>expirationDate</code>{{optional_inline}}</dt>
+ <dd>A <code>number</code> representing the expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies.</dd>
+ <dt><code>firstPartyDomain</code></dt>
+ <dd>A <code>string</code> representing the first-party domain associated with the cookie. This will be an empty string if the cookie was set while first-party isolation was off. See <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/cookies#First-party_isolation">First-party isolation</a>.</dd>
+ <dt><code>hostOnly</code></dt>
+ <dd>A <code>boolean</code>, <code>true</code> if the cookie is a host-only cookie (i.e. the request's host must exactly match the domain of the cookie), or <code>false</code> otherwise.</dd>
+ <dt><code>httpOnly</code></dt>
+ <dd>A <code>boolean</code>, <code>true</code> if the cookie is marked as HttpOnly (i.e. the cookie is inaccessible to client-side scripts), or <code>false</code> otherwise.</dd>
+ <dt><code>name</code></dt>
+ <dd>A <code>string</code> representing the name of the cookie.</dd>
+ <dt><code>path</code></dt>
+ <dd>A <code>string</code> representing the path of the cookie.</dd>
+ <dt><code>secure</code></dt>
+ <dd>A <code>boolean</code>, <code>true</code> if the cookie is marked as secure (i.e. its scope is limited to secure channels, typically HTTPS), or <code>false</code> otherwise.</dd>
+ <dt><code>session</code></dt>
+ <dd>A <code>boolean</code>, <code>true</code> if the cookie is a session cookie, or <code>false</code> if it is a persistent cookie with an expiration date.</dd>
+ <dt><code>sameSite</code></dt>
+ <dd>A {{WebExtAPIRef("cookies.SameSiteStatus")}} value that indicates the SameSite state of the cookie.</dd>
+ <dt><code>storeId</code></dt>
+ <dd>A <code>string</code> representing the ID of the cookie store containing this cookie, as provided by {{WebExtAPIRef("cookies.getAllCookieStores()")}}.</dd>
+ <dt><code>value</code></dt>
+ <dd>代表 cookie 的值的一个字符串。</dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.cookies.Cookie")}}</p>
+
+<h2 id="举例">举例</h2>
+
+<p>Cookies API中的大多数方法都将 <code>Cookie</code> 对象用作输入参数或用作返回值的一部分。例如调用 {{WebExtAPIRef("cookies.getAll()")}} 将会返回一个 <code>Cookie</code> 对象的数组。</p>
+
+<p>在下面的例子中我们将会获取所有的 cookie ,然后 <code>console.log()</code> 出这些 <code>Cookie</code> 对象所对应的值。</p>
+
+<pre class="brush: js notranslate">function logCookies(cookies) {
+ for (cookie of cookies) {
+ console.log(`Domain: ${cookie.domain}`);
+ console.log(`Name: ${cookie.name}`);
+ console.log(`Value: ${cookie.value}`);
+ console.log(`Persistent: ${!cookie.session}`);
+ }
+}
+
+var gettingAll = browser.cookies.getAll({});
+gettingAll.then(logCookies);</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>声明</strong>
+
+<p>这 API 是基于 Chromium 的 <a href="https://developer.chrome.com/extensions/cookies#type-Cookie"><code>chrome.cookies</code></a> API 的。 这个文档来自于 Chromium code 中的 <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/cookies.json"><code>cookies.json</code></a> 。</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre class="notranslate">// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
+
+<div id="simple-translate">
+<div>
+<div class="simple-translate-button isShow" style="height: 22px; width: 22px; top: 2528px; left: 464px;"></div>
+
+<div class="simple-translate-panel " style="width: 300px; height: 200px; top: 0px; left: 0px; font-size: 16px; background-color: rgb(17, 17, 17);">
+<div class="simple-translate-result-wrapper" style="overflow: hidden;">
+<div class="simple-translate-move"></div>
+
+<div class="simple-translate-result-contents">
+<p class="simple-translate-result" style="color: rgb(234, 234, 234);"></p>
+
+<p class="simple-translate-candidate" style="color: rgb(195, 195, 195);"></p>
+</div>
+</div>
+</div>
+</div>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/cookies/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/cookies/index.html
new file mode 100644
index 0000000000..4011b4fe56
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/cookies/index.html
@@ -0,0 +1,151 @@
+---
+title: cookies
+slug: Mozilla/Add-ons/WebExtensions/API/cookies
+tags:
+ - API
+ - Add-ons
+ - Cookies
+ - Extensions
+ - WebExtensions
+translation_of: Mozilla/Add-ons/WebExtensions/API/cookies
+---
+<div>{{AddonSidebar}}</div>
+
+<p>使用 WebExtensions 获取或设置 cookies, 并且在修改时能够获得通知。</p>
+
+<p>你需要在 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a> 文件中开启“cookies”<a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#API_permissions">API 权限</a>,并且需要对应站点的 <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#Host_permissions">主机权限</a> 才能设置指定站点的cookie。详细信息查看 <a href="/en-US/Add-ons/WebExtensions/API/cookies#Permissions">cookie 权限</a>.</p>
+
+<h2 id="类型">类型</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("cookies.Cookie")}}</dt>
+ <dd>代表一个HTTP cookie的信息。</dd>
+ <dt>{{WebExtAPIRef("cookies.CookieStore")}}</dt>
+ <dd>代表一个保存在浏览器中的 cookie。</dd>
+ <dt>{{WebExtAPIRef("cookies.OnChangedCause")}}</dt>
+ <dd>代表 cookie 改变的原因。</dd>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("cookies.get()")}}</dt>
+ <dd>返回一个单独的 cookie 的信息。</dd>
+ <dt>{{WebExtAPIRef("cookies.getAll()")}}</dt>
+ <dd>返回所有符合筛选条件的 cookies。</dd>
+ <dt>{{WebExtAPIRef("cookies.set()")}}</dt>
+ <dd>根据给定cookie数据设置一个cookie;如果同样的cookie存在讲会覆盖。</dd>
+ <dt>{{WebExtAPIRef("cookies.remove()")}}</dt>
+ <dd>根据名字删除cookie。</dd>
+ <dt>{{WebExtAPIRef("cookies.getAllCookieStores()")}}</dt>
+ <dd>列出所有保存的cookie。</dd>
+</dl>
+
+<h2 id="事件句柄">事件句柄</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("cookies.onChanged")}}</dt>
+ <dd>当设置或删除cookie时触发。</dd>
+</dl>
+
+<h2 id="权限">权限</h2>
+
+<p>为了使用这个API,插件必须在它的manifest中指定"cookies" <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#API_permissions">API 权限</a>,和它想要使用cookie的任何网站的 <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#Host_permissions">host 权限</a> 。插件将能读取或写入host权限中所匹配的URL可以读取或写入的任何cookie。例如:</p>
+
+<dl>
+ <dt><code>http://*.example.com/</code></dt>
+ <dd>
+ <p>拥有这个host权限的插件将可以:</p>
+
+ <ul>
+ <li>读取一个<code>www.example.com</code>任意路径下的不安全cookie。</li>
+ <li>写入一个<code>www.example.com</code>任意路径下的不安全cookie。</li>
+ </ul>
+
+ <p><em>它不能:</em></p>
+
+ <ul>
+ <li>读取<code>www.example.com</code>的安全cookie。</li>
+ </ul>
+ </dd>
+ <dt><code>http://www.example.com/</code></dt>
+ <dd>
+ <p>拥有这个host权限的插件将可以:</p>
+
+ <ul>
+ <li>读取 <code>www.example.com</code>任意路径下的不安全cookie。</li>
+ <li>读取 <code>.example.com</code> 任意路径下的不安全cookie。</li>
+ <li>写入 <code>www.example.com</code> 任意路径下的安全和不安全cookie。</li>
+ <li>写入 <code>.example.com</code> 任意路径下的安全和不安全cookie。</li>
+ </ul>
+
+ <p>它不能:</p>
+
+ <ul>
+ <li>读取或写入 <code>foo.example.com</code> 的cookie。</li>
+ <li>读取或写入 <code>foo.www.example.com</code> 的cookie。</li>
+ </ul>
+ </dd>
+ <dt><code>*://*.example.com/</code></dt>
+ <dd>
+ <p>拥有这个host权限的插件将可以:</p>
+
+ <ul>
+ <li>读取或写入 <code>www.example.com</code> 任意路径下安全的和不安全的cookie。</li>
+ </ul>
+ </dd>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("webextensions.api.cookies")}}</p>
+
+<div class="hidden note">
+<p>The "Chrome incompatibilities" section is included from <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities"> https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a> using the <a href="/en-US/docs/Template:WebExtChromeCompat">WebExtChromeCompat</a> macro.</p>
+
+<p>If you need to update this content, edit <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities">https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a>, then shift-refresh this page to see your changes.</p>
+</div>
+
+<h3 id="Edge_不兼容">Edge 不兼容</h3>
+
+<p>在 Edge 中不支持 Promises,使用 callbacks 代替。</p>
+
+<p>{{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>这个API 基于 Chromium 的 <a href="https://developer.chrome.com/extensions/cookies"><code>chrome.cookies</code></a> API. 这篇文档来源于Chromium 代码的 <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/cookies.json"><code>cookies.json</code></a> 。</p>
+
+<p>Microsoft Edge 兼容性数据由 Microsoft Corporation 提供,并包含在 Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/devtools.inspectedwindow/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/devtools.inspectedwindow/index.html
new file mode 100644
index 0000000000..d59f29ffde
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/devtools.inspectedwindow/index.html
@@ -0,0 +1,72 @@
+---
+title: devtools.inspectedWindow
+slug: Mozilla/Add-ons/WebExtensions/API/devtools.inspectedWindow
+translation_of: Mozilla/Add-ons/WebExtensions/API/devtools.inspectedWindow
+---
+<div>{{AddonSidebar}}</div>
+
+<div class="note">
+<p>This page describes the WebExtensions devtools APIs as they exist in Firefox 54. Although the APIs are based on the <a href="https://developer.chrome.com/extensions/devtools">Chrome devtools APIs</a>, there are still many features that are not yet implemented in Firefox, and therefore are not documented here. To see which features are currently missing please see <a href="/en-US/Add-ons/WebExtensions/Using_the_devtools_APIs#Limitations_of_the_devtools_APIs">Limitations of the devtools APIs</a>.</p>
+</div>
+
+<p>The <code>devtools.inspectedWindow</code> API lets a devtools extension interact with the window that the developer tools are attached to.</p>
+
+<p>Like all the <code>devtools</code> APIs, this API is only available to code running in the document defined in the <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/devtools_page">devtools_page</a> manifest.json key, or in other devtools documents created by the extension (such as the document hosted by a panel the extension created). See <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Extending_the_developer_tools">Extending the developer tools</a> for more.</p>
+
+<h2 id="Properties">Properties</h2>
+
+<dl>
+ <dt><code><a href="/en-US/Add-ons/WebExtensions/API/devtools.inspectedWindow/tabId">devtools.inspectedWindow.tabId</a></code></dt>
+ <dd>The ID of the window that the developer tools are attached to.</dd>
+</dl>
+
+<h2 id="Functions">Functions</h2>
+
+<dl>
+ <dt><code><a href="/en-US/Add-ons/WebExtensions/API/devtools.inspectedWindow/eval">devtools.inspectedWindow.eval()</a></code></dt>
+ <dd>Evaluate some JavaScript in the target window.</dd>
+ <dt><code><a href="/en-US/Add-ons/WebExtensions/API/devtools.inspectedWindow/reload">devtools.inspectedWindow.reload()</a></code></dt>
+ <dd>Reload the target window's document.</dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{Compat("webextensions.api.devtools.inspectedWindow")}}{{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/devtools_inspectedWindow"><code>chrome.devtools.inspectedWindow</code></a> API.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/downloads/download/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/downloads/download/index.html
new file mode 100644
index 0000000000..c7b6216ee8
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/downloads/download/index.html
@@ -0,0 +1,144 @@
+---
+title: downloads.download()
+slug: Mozilla/Add-ons/WebExtensions/API/downloads/download
+tags:
+ - API
+ - Add-ons
+ - Extensions
+ - Method
+ - WebExtensions
+ - download
+ - downloads
+translation_of: Mozilla/Add-ons/WebExtensions/API/downloads/download
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>{{WebExtAPIRef("downloads")}} API 的 <strong><code>download()</code></strong> 函数根据给出的URL和其他首选项下载一个文件。</p>
+
+<ul>
+ <li>如果指定的 <code>url</code> 使用HTTP或者HTTPS协议, 那么下载请求将会包含当前为该域名所设置的所有cookie。</li>
+ <li>如果<code>filename</code> 和 <code>saveAs</code> 都已经指定,那么将会弹出“保存为” 对话框,并且默认名称显示为<code>filename</code>.</li>
+</ul>
+
+<p>这是一个异步函数,其返回值为 <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>.</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox brush:js">var downloading = browser.downloads.download(
+ options // object
+)
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>options</code></dt>
+ <dd>一个 <code>object</code> ,用来指定你想要下载的文件和其他想要在下载时设置的首选项。可以包含以下属性:</dd>
+ <dd>
+ <dl class="reference-values">
+ <dt><code>allowHttpErrors</code>{{optional_inline}}</dt>
+ <dd>一个 <code>boolean</code>,启用后即使遇到HTTP错误仍然继续下载。 例如,可以使用该标志下载服务错误页面。默认值为<code>false</code>. 当设置为以下值时:
+ <ul>
+ <li><code>false</code>,遇到HTTP错误时下载会被取消。</li>
+ <li><code>true</code>, 即使遇到HTTP错误也会继续下载,并且不会弹出HTTP服务错误报告。但是,如果下载失败的原因是文件相关,网络相关,用户相关,或者说其他错误,仍然会报错。<span style="display: none;"> </span></li>
+ </ul>
+ </dd>
+ <dt><code>body</code>{{optional_inline}}</dt>
+ <dd>一个 <code>string</code>,代表请求的内容。</dd>
+ <dt><code>conflictAction</code>{{optional_inline}}</dt>
+ <dd>一个字符串,表示如果存在命名冲突时你希望进行的操作,字符串内容所代表的类型由 {{WebExtAPIRef('downloads.FilenameConflictAction')}} 定义(未指定时默认为 "uniquify" )。</dd>
+ <dt><code>filename</code>{{optional_inline}}</dt>
+ <dd>一个 <code>string</code> ,表示相对默认保存位置的文件路径——这里提供你希望文件保存的位置,和你想要使用的文件名。绝对路径,空路径,以及包含反向引用的路径 (<code>../</code>) 会导致错误产生。 如果省略,该值将默认为已经提供给下载文件的文件名,并且直接保存到下载文件夹中。</dd>
+ <dt><code>headers</code>{{optional_inline}}</dt>
+ <dd>如果URL使用HTTP或者HTTPS协议, 保存在 <code>array</code> 中的一系列 <code>objects</code> 表示与请求一起发送的额外HTTP请求头。每一个请求头表示为字典对象,包含有关键字 <code>name</code> 还有 <code>value</code>或<code>binaryValue</code>中的一个。 无法指定 <code>XMLHttpRequest</code>和 <code>fetch</code>禁止的请求头,但是 Firefox 70 之后允许使用<code>Referer</code>请求头。尝试使用被禁止的请求头会产生一个错误。</dd>
+ <dt><code>incognito</code>{{optional_inline}}</dt>
+ <dd>一个 <code>boolean</code>:如果被设置为 true,那么这次下载会建立一个隐私浏览会话。 这意味着它只会出现在当前打开的任意隐私窗口的下载管理器。</dd>
+ <dt><code>method</code>{{optional_inline}}</dt>
+ <dd>一个 <code>string</code>,表示<code>url</code>使用HTTP[S] 协议时使用的HTTP方法。其值可能是 "GET" 或 "POST"。</dd>
+ <dt><code>saveAs</code>{{optional_inline}}</dt>
+ <dd>
+ <p>一个<code>boolean</code> 指定是(<code>true</code>)否(<code>false</code>)提供一个文件选择对话框允许用户选择文件名。.</p>
+
+ <p>如果该选项省略, 浏览器会根据用户对于该行为的偏好设置决定是否提供一个文件选择对话框 (在火狐这项设置标签在about:preferences里为"每次都问您要存到哪" ,或者about:config里 <code>browser.download.useDownloadDir</code> )。</p>
+
+ <div class="note">
+ <p><strong>Note</strong>: 如果 <code>saveAs</code> 被设置为 <code>true</code>,Firefox for Android 将会引发一个错误。 当 <code>saveAs</code> 为 <code>false</code> 或空时这个参数会被忽略.</p>
+ </div>
+ </dd>
+ <dt><code>url</code></dt>
+ <dd>一个 <code>string</code>,表示需要下载的链接地址。</dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>一个 <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>. 如果成功开始下载,promise会被新创建的{{WebExtAPIRef("downloads.DownloadItem")}} 的 <code>id</code> 填充。否则 promise 会被拒绝并产生一条{{WebExtAPIRef("downloads.InterruptReason")}}错误信息.</p>
+
+<p>如果你使用 <a href="/en-US/docs/Web/API/URL/createObjectURL">URL.createObjectURL()</a> 下载由 JavaScript 创建的数据并且之后想要(使用 <a href="/en-US/docs/Web/API/URL/revokeObjectURL">revokeObjectURL</a>)撤销对象链接(并且强烈推荐这么做),你必须在下载完成后再这么做。监听 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/downloads/onChanged">downloads.onChanged</a> 事件来判断是否下载完成。</p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.downloads.download")}}</p>
+
+<h2 id="例子">例子</h2>
+
+<p>下面这段代码尝试下载一个example文件,同时指定文件名和保存位置,还有 <code>uniquify</code> <code>conflictAction</code> 选项。</p>
+
+<pre class="brush: js">function onStartedDownload(id) {
+ console.log(`Started downloading: ${id}`);
+}
+
+function onFailed(error) {
+ console.log(`Download failed: ${error}`);
+}
+
+var downloadUrl = "https://example.org/image.png";
+
+var downloading = browser.downloads.download({
+ url : downloadUrl,
+ filename : 'my-image-again.png',
+ conflictAction : 'uniquify'
+});
+
+downloading.then(onStartedDownload, onFailed);</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>这个 API 基于 Chromium的 <a href="https://developer.chrome.com/extensions/downloads#method-download"><code>chrome.downloads</code></a> API.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/downloads/downloaditem/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/downloads/downloaditem/index.html
new file mode 100644
index 0000000000..ce523d15af
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/downloads/downloaditem/index.html
@@ -0,0 +1,101 @@
+---
+title: downloads.DownloadItem
+slug: Mozilla/Add-ons/WebExtensions/API/downloads/DownloadItem
+translation_of: Mozilla/Add-ons/WebExtensions/API/downloads/DownloadItem
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>{{WebExtAPIRef("downloads")}} API 的 <code>DownloadItem</code> 类代表了一个被下载的文件。</p>
+
+<h2 id="Type">Type</h2>
+
+<p>这个类型的值是对象,包含了以下属性:</p>
+
+<dl class="reference-values">
+ <dt><code>byExtensionId</code>{{optional_inline}}</dt>
+ <dd>一个代表了触发此下载的扩展的 ID 的 <code>string</code> (如果是被扩展触发的话)。一旦设置,不会改变。如果下载不是由扩展触发的,则为 undefined。</dd>
+ <dt><code>byExtensionName</code>{{optional_inline}}</dt>
+ <dd>一个代表了触发此下载的扩展的名字的 <code>string</code> (如果是被扩展触发的话)。如果用户改变了扩展的语言环境,则这个属性的值也可能变化。如果下载不是由扩展触发的,则为 undefined。</dd>
+ <dt><code>bytesReceived</code></dt>
+ <dd>一个代表了在下载过程中从主机接收到的字节数的 <code>number</code> ;不考虑文件压缩。</dd>
+ <dt><code>canResume</code></dt>
+ <dd>一个标识当前中断(例如暂停)的下载是否可以从当前位置恢复的 <code>boolean</code>。</dd>
+ <dt><code>danger</code></dt>
+ <dd>一个标识这个下载是否通过一个不安全的或已知的可疑的站点。可能被设置为 {{WebExtAPIRef('downloads.DangerType')}} 类型。</dd>
+ <dt><code>endTime</code>{{optional_inline}}</dt>
+ <dd>A <code>string</code> (in <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format) representing the number of milliseconds between the UNIX epoch and when this download ended. This is undefined if the download has not yet finished.</dd>
+ <dt><code>error</code>{{optional_inline}}</dt>
+ <dd>A string indicating why a download was interrupted. Possible values are defined in the {{WebExtAPIRef('downloads.InterruptReason')}} type. This is undefined if an error has not occurred.</dd>
+ <dt><code>estimatedEndTime</code>{{optional_inline}}</dt>
+ <dd>A <code>string</code> (in <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format) representing the estimated number of milliseconds between the UNIX epoch and when this download is estimated to be completed. This is undefined if it is not known (in particular, it is undefined in the <code>DownloadItem</code> that's passed into {{WebExtAPIRef("downloads.onCreated")}}).</dd>
+ <dt><code>exists</code></dt>
+ <dd>A <code>boolean</code> indicating whether a downloaded file still exists (<code>true</code>) or not (<code>false</code>). This information might be out-of-date, as browsers do not automatically watch for file removal — to check whether a file exists, call the {{WebExtAPIRef('downloads.search()')}} method, filtering for the file in question.</dd>
+ <dt><code>filename</code></dt>
+ <dd>A <code>string</code> representing the file's absolute local path.</dd>
+ <dt><code>fileSize</code></dt>
+ <dd>A <code>number</code> indicating the total number of bytes in the whole file, after decompression. A value of -1 here means that the total file size is unknown.</dd>
+ <dt><code>id</code></dt>
+ <dd>An <code>integer</code> representing a unique identifier for the downloaded file that is persistent across browser sessions.</dd>
+ <dt><code>incognito</code></dt>
+ <dd>A <code>boolean</code> that indicates whether the download is recorded in the browser's history (<code>false</code>), or not (<code>true</code>).</dd>
+ <dt><code>mime</code></dt>
+ <dd>A <code>string</code> representing the downloaded file's MIME type.</dd>
+ <dt><code>paused</code></dt>
+ <dd>A <code>boolean</code> indicating whether the download is paused, i.e. if the download has stopped reading data from the host but has kept the connection open. If so, the value is <code>true</code>, <code>false</code> if not.</dd>
+ <dt><code>referrer</code></dt>
+ <dd>A <code>string</code> representing the downloaded file's referrer.</dd>
+ <dt><code>startTime</code></dt>
+ <dd>A <code>string</code> (in <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format) representing the number of milliseconds between the UNIX epoch and when this download began.</dd>
+ <dt><code>state</code></dt>
+ <dd>A <code>string</code> Indicating whether the download is progressing, interrupted, or complete. Possible values are defined in the {{WebExtAPIRef('downloads.State')}} type.</dd>
+ <dt><code>totalBytes</code></dt>
+ <dd>A <code>number</code> indicating the total number of bytes in the file being downloaded. This does not take file compression into consideration. A value of -1 here means that the total number of bytes is unknown.</dd>
+ <dt><code>url</code></dt>
+ <dd>A <code>string</code> representing the absolute URL from which the file was downloaded.</dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.downloads.DownloadItem")}}</p>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/downloads#type-DownloadItem"><code>chrome.downloads</code></a> API.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/downloads/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/downloads/index.html
new file mode 100644
index 0000000000..a2074471b7
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/downloads/index.html
@@ -0,0 +1,134 @@
+---
+title: downloads
+slug: Mozilla/Add-ons/WebExtensions/API/downloads
+tags:
+ - API
+ - Add-ons
+ - Extensions
+ - Interface
+ - NeedsTranslation
+ - Non-standard
+ - Reference
+ - TopicStub
+ - WebExtensions
+ - downloads
+translation_of: Mozilla/Add-ons/WebExtensions/API/downloads
+---
+<div>{{AddonSidebar}}</div>
+
+<div>启用与浏览器的下载管理器交互的扩展。你可以使用这个 API 模块来下载文件、取消、暂停、恢复下载和在文件管理器中显示下载的文件。</div>
+
+<p>为使用此 API,你需要在你的 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a> 文件中声明 "downloads" <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#API_permissions">API 权限</a>。</p>
+
+<h2 id="Types">Types</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("downloads.FilenameConflictAction")}}</dt>
+ <dd>定义当一个下载的文件与现存的文件命名冲突时要做什么。</dd>
+ <dt>{{WebExtAPIRef("downloads.InterruptReason")}}</dt>
+ <dd>定义一系列中断下载的可能理由。</dd>
+ <dt>{{WebExtAPIRef("downloads.DangerType")}}</dt>
+ <dd><span class="tlid-translation translation" lang="zh-CN"><span title="">定义一组与可下载文件相关的潜在危险的常见警告。</span></span></dd>
+ <dt>{{WebExtAPIRef("downloads.State")}}</dt>
+ <dd><span class="tlid-translation translation" lang="zh-CN"><span title="">定义当前下载可能处于的不同状态。</span></span></dd>
+ <dt>{{WebExtAPIRef("downloads.DownloadItem")}}</dt>
+ <dd>代表下载的文件。</dd>
+ <dt>{{WebExtAPIRef("downloads.StringDelta")}}</dt>
+ <dd><span class="tlid-translation translation" lang="zh-CN"><span title="">表示两个字符串之间的差异。</span></span></dd>
+ <dt>{{WebExtAPIRef("downloads.DoubleDelta")}}</dt>
+ <dd>代表两个双精度浮点数之间的差异。</dd>
+ <dt>{{WebExtAPIRef("downloads.BooleanDelta")}}</dt>
+ <dd>代表两个布尔数之间的差异。</dd>
+ <dt>{{WebExtAPIRef("downloads.DownloadTime")}}</dt>
+ <dd>代表一个下载将会花费的时间。</dd>
+ <dt>{{WebExtAPIRef("downloads.DownloadQuery")}}</dt>
+ <dd><span class="tlid-translation translation" lang="zh-CN"><span title="">定义一组参数,可用于在下载管理器中搜索一组特定的下载。</span></span></dd>
+</dl>
+
+<h2 id="Functions">Functions</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("downloads.download()")}}</dt>
+ <dd>下载一个文件,给出它的 URL 和其他可选的参数。</dd>
+ <dt>{{WebExtAPIRef("downloads.search()")}}</dt>
+ <dd>查询 {{WebExtAPIRef("downloads.DownloadItem", "DownloadItems")}} 是否在浏览器的下载管理器中可用,返回匹配指定的搜索标准的条目。</dd>
+ <dt>{{WebExtAPIRef("downloads.pause()")}}</dt>
+ <dd>暂停一个下载。</dd>
+ <dt>{{WebExtAPIRef("downloads.resume()")}}</dt>
+ <dd>恢复一个暂停的下载。</dd>
+ <dt>{{WebExtAPIRef("downloads.cancel()")}}</dt>
+ <dd>取消一个下载。</dd>
+ <dt>{{WebExtAPIRef("downloads.getFileIcon()")}}</dt>
+ <dd><span class="tlid-translation translation" lang="zh-CN"><span title="">检索指定下载的图标。</span></span></dd>
+ <dt>{{WebExtAPIRef("downloads.open()")}}</dt>
+ <dd>用下载的文件相关联的程序打开它。</dd>
+ <dt>{{WebExtAPIRef("downloads.show()")}}</dt>
+ <dd>打开当前平台的文件管理应用来在它包含的文件夹中显示下载的文件。</dd>
+ <dt>{{WebExtAPIRef("downloads.showDefaultFolder()")}}</dt>
+ <dd>用当前平台的文件管理应用显示默认下载文件夹。</dd>
+ <dt>{{WebExtAPIRef("downloads.erase()")}}</dt>
+ <dd>擦除浏览器的下载历史中匹配 {{WebExtAPIRef("downloads.DownloadItem", "DownloadItems")}} 的下载记录,不会在磁盘中删除文件。</dd>
+ <dt>{{WebExtAPIRef("downloads.removeFile()")}}</dt>
+ <dd>从磁盘中移除下载的文件,但不从浏览器的下载历史中去除。</dd>
+ <dt>{{WebExtAPIRef("downloads.acceptDanger()")}}</dt>
+ <dd><span class="tlid-translation translation" lang="zh-CN"><span title="">提示用户接受或取消危险的下载。</span></span></dd>
+ <dt>{{WebExtAPIRef("downloads.drag()")}}</dt>
+ <dd>   <span class="tlid-translation translation" lang="zh-CN"><span title="">将下载的文件拖动到另一个应用程序。</span></span></dd>
+ <dt>{{WebExtAPIRef("downloads.setShelfEnabled()")}}</dt>
+ <dd><span class="tlid-translation translation" lang="zh-CN"><span title="">启用或禁用与当前浏览器配置文件关联的每个窗口底部的灰色架子。</span> <span title="">只要至少一个扩展名已禁用该架子,它就会被禁用。</span></span></dd>
+</dl>
+
+<h2 id="Events">Events</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("downloads.onCreated")}}</dt>
+ <dd>当一个下载开始时被 {{WebExtAPIRef("downloads.DownloadItem", "DownloadItem")}} 对象触发。</dd>
+ <dt>{{WebExtAPIRef("downloads.onErased")}}</dt>
+ <dd>当一个下载从历史中擦除时被 Fires with the <code>downloadId</code> 触发。</dd>
+ <dt>{{WebExtAPIRef("downloads.onChanged")}}</dt>
+ <dd>当任意一个 {{WebExtAPIRef("downloads.DownloadItem", "DownloadItem")}} 的属性期望 <code>bytesReceived</code> 改变时,此事件被这个 `downloadId` 和包含了变化属性的对象触发。</dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{Compat("webextensions.api.downloads")}}</p>
+
+<p>{{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/downloads"><code>chrome.downloads</code></a> API.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/find/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/find/index.html
new file mode 100644
index 0000000000..cda583e456
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/find/index.html
@@ -0,0 +1,25 @@
+---
+title: find
+slug: Mozilla/Add-ons/WebExtensions/API/find
+translation_of: Mozilla/Add-ons/WebExtensions/API/find
+---
+<div><font><font>{{AddonSidebar}}</font></font></div>
+
+<p><font><font>在网页中查找文本,并突出显示匹配项。</font></font></p>
+
+<p><font><font>要使用此API,您需要具有“查找” </font></font><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions"><font><font>权限</font></font></a><font><font>。</font></font></p>
+
+<h2 id="功能"><font><font>功能</font></font></h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("find.find()")}}</dt>
+ <dd><font><font>在网页中查找文本。</font></font></dd>
+ <dt>{{WebExtAPIRef("find.highlightResults()")}}</dt>
+ <dd><font><font>突出显示找到的最后一组匹配项。</font></font></dd>
+ <dt>{{WebExtAPIRef("find.removeHighlighting()")}}</dt>
+ <dd><font><font>删除所有突出显示。</font></font></dd>
+</dl>
+
+<h2 id="浏览器兼容性"><font><font>浏览器兼容性</font></font></h2>
+
+<p>{{Compat("webextensions.api.find", 1, 1)}} {{WebExtExamples("h2")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/history/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/history/index.html
new file mode 100644
index 0000000000..7412530cb6
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/history/index.html
@@ -0,0 +1,134 @@
+---
+title: history
+slug: Mozilla/Add-ons/WebExtensions/API/history
+tags:
+ - API
+ - Add-ons
+ - Extensions
+ - History
+ - Interface
+ - NeedsTranslation
+ - Non-standard
+ - Reference
+ - TopicStub
+ - WebExtensions
+translation_of: Mozilla/Add-ons/WebExtensions/API/history
+---
+<div>{{AddonSidebar}}</div>
+
+<p>使用 <code>history</code> API与浏览器历史记录进行交互。</p>
+
+<div class="note">
+<p>注意:下载也被当做一个 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/history/HistoryItem" title="A HistoryItem object provides information about a page in the browser history."><code>HistoryItem</code></a> 对象。因此,<code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/history/onVisited" title="Fired each time the user visits a page. A history.HistoryItem object is passed to the listener. This event fires before the page has loaded.">history.onVisited</a></code>等事件也会被下载所触发。</p>
+</div>
+
+<p>浏览器历史记录是对用户所访问的页面按时间顺序进行的记录和保存。history API 可以帮你实现以下功能:</p>
+
+<ul>
+ <li><a href="/en-US/Add-ons/WebExtensions/API/history/search">查找浏览器历史记录中出现过的页面</a></li>
+ <li><a href="/en-US/Add-ons/WebExtensions/API/history/deleteUrl">移除浏览器历史记录中的单个页面</a></li>
+ <li><a href="/en-US/Add-ons/WebExtensions/API/history/addUrl">向浏览器历史记录中添加页面</a></li>
+ <li><a href="/en-US/Add-ons/WebExtensions/API/history/deleteAll">移除所有浏览器历史记录中的页面</a></li>
+</ul>
+
+<p>然而,用户可能多次访问单个页面,因此API中有访问集合“visits”的概念。所以,该API还可以做如下使用:</p>
+
+<ul>
+ <li><a href="/en-US/Add-ons/WebExtensions/API/history/getVisits">获取用户对单个页面的所有访问记录的集合</a></li>
+ <li><a href="/en-US/Add-ons/WebExtensions/API/history/deleteRange">移除给定期间内任意页面的访问记录的集合</a></li>
+</ul>
+
+<p>使用该API之前,扩展程序必须在其 <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a></code> 文件中获取history的<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">许可</a>。</p>
+
+<h2 id="类型">类型</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("history.TransitionType")}}</dt>
+ <dd>描述浏览器如何转到特定页面。</dd>
+ <dt>{{WebExtAPIRef("history.HistoryItem")}}</dt>
+ <dd>
+ <p>提供浏览器历史记录中单个特定页面的详细信息。</p>
+ </dd>
+ <dt>{{WebExtAPIRef("history.VisitItem")}}</dt>
+ <dd>
+ <p>描述对一个页面的单次访问。</p>
+ </dd>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("history.search()")}}</dt>
+ <dd>在浏览器历史记录中查找符合给定条件的<code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/History/HistoryItem" title="A HistoryItem object provides information about one result from a history query.">history.HistoryItem</a></code></dd>
+ <dt>{{WebExtAPIRef("history.getVisits()")}}</dt>
+ <dd>获取指定页面的访问集信息。</dd>
+ <dt>{{WebExtAPIRef("history.addUrl()")}}</dt>
+ <dd>为浏览器历史记录添加一个指定页面的访问。</dd>
+ <dt>{{WebExtAPIRef("history.deleteUrl()")}}</dt>
+ <dd>移除浏览器历史记录中所有对指定URL的访问。</dd>
+ <dt>{{WebExtAPIRef("history.deleteRange()")}}</dt>
+ <dd>移除指定时间段内对用户指定页面的访问。</dd>
+ <dt>{{WebExtAPIRef("history.deleteAll()")}}</dt>
+ <dd>移除浏览器历史记录中的所有访问。</dd>
+</dl>
+
+<h2 id="事件">事件</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("history.onTitleChanged")}}</dt>
+ <dd>
+ <div>当用户访问的页面标题被记录时触发。</div>
+ </dd>
+ <dt>{{WebExtAPIRef("history.onVisited")}}</dt>
+ <dd>每次用户访问页面时会触发,并提供该页面的 {{WebExtAPIRef("history.HistoryItem")}} 数据。</dd>
+ <dt>{{WebExtAPIRef("history.onVisitRemoved")}}</dt>
+ <dd>
+ <p>当一个URL被彻底从浏览器历史记录中移除时触发。</p>
+ </dd>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.history")}}</p>
+
+<p>{{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>致谢</strong>
+
+<p>该 API 基于Chromium的<a href="https://developer.chrome.com/extensions/history"><code>chrome.history</code></a> API。该文档由Chromium代码中的<a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/history.json"><code>history.json</code></a>衍生而来。</p>
+
+<p>微软 Edge 兼容性数据由微软公司提供并包含在如下证书中—— Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/history/ontitlechanged/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/history/ontitlechanged/index.html
new file mode 100644
index 0000000000..bf79b4c6d7
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/history/ontitlechanged/index.html
@@ -0,0 +1,111 @@
+---
+title: history.onTitleChanged
+slug: Mozilla/Add-ons/WebExtensions/API/history/onTitleChanged
+tags:
+ - History
+translation_of: Mozilla/Add-ons/WebExtensions/API/history/onTitleChanged
+---
+<div>{{AddonSidebar()}}</div>
+
+<div>当document的标题更改时触发</div>
+
+<div> </div>
+
+<div>你可以使用 {{WebExtAPIRef("history.onVisited")}}去进行监听. However, the {{WebExtAPIRef("history.HistoryItem")}} that this event passes to its listener does not include the page title, because the page title is typically not known at the time <code>history.onVisited</code> is sent.</div>
+
+<div> </div>
+
+<div>Instead, the stored {{WebExtAPIRef("history.HistoryItem")}} is updated with the page title after the page has loaded, once the title is known. The history.onTitleChanged event is fired at that time. So if you need to know the titles of pages as they are visited, listen for <code>history.onTitleChanged</code>.</div>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox brush:js">browser.history.onTitleChanged.addListener(listener)
+browser.history.onTitleChanged.removeListener(listener)
+browser.history.onTitleChanged.hasListener(listener)
+</pre>
+
+<p>Events have three functions:</p>
+
+<dl>
+ <dt><code>addListener(listener)</code></dt>
+ <dd>Adds a listener to this event.</dd>
+ <dt><code>removeListener(listener)</code></dt>
+ <dd>Stop listening to this event. The <code>listener</code> argument is the listener to remove.</dd>
+ <dt><code>hasListener(listener)</code></dt>
+ <dd>Check whether <code>listener</code> is registered for this event. Returns <code>true</code> if it is listening, <code>false</code> otherwise.</dd>
+</dl>
+
+<h2 id="addListener_syntax">addListener syntax</h2>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt><code>callback</code></dt>
+ <dd>
+ <p>Function that will be called when this event occurs. The function will be passed an object with the following properties:</p>
+
+ <dl class="reference-values">
+ <dt><code>url</code></dt>
+ <dd><code>String</code>. URL of the page visited.</dd>
+ <dt><code>title</code></dt>
+ <dd><code>String</code>. Title of the page visited.</dd>
+ </dl>
+ </dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.history.onTitleChanged")}}</p>
+
+<h2 id="Examples">Examples</h2>
+
+<p>Listen for title change events, and log the URL and title of the visited pages.</p>
+
+<pre class="brush: js">function handleTitleChanged(item) {
+ console.log(item.title);
+ console.log(item.url);
+}
+
+browser.history.onTitleChanged.addListener(handleTitleChanged);</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/history#event-onVisited"><code>chrome.history</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/history.json"><code>history.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/i18n/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/i18n/index.html
new file mode 100644
index 0000000000..73897ac0ea
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/i18n/index.html
@@ -0,0 +1,85 @@
+---
+title: i18n
+slug: Mozilla/Add-ons/WebExtensions/API/i18n
+translation_of: Mozilla/Add-ons/WebExtensions/API/i18n
+---
+<div>{{AddonSidebar}}</div>
+
+<p>国际化扩展的函数。您可以使用这些 api 从与扩展打包在一起的本地化文件中获取本地化字符串,查找浏览器的当前语言,并查找其 <a href="/zh-CN/docs/Web/HTTP/Content_negotiation#The_Accept-Language_header">Accept-Language header</a>头的值。</p>
+
+<p id="See_also">有关对扩展使用 i18n 的详细信息,请参阅:</p>
+
+<ul>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Internationalization">Internationalization</a>国际化: 使用 WebExtension i18n 系统的指南</li>
+ <li><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/i18n/Locale-Specific_Message_reference">Locale-Specific Message reference</a>: 扩展在 <code>messages.json</code>文件中提供特定于语言环境的字符串。 <font>此网页介绍</font><code>messages.json</code></li>
+</ul>
+
+<h2 id="类型">类型</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("i18n.LanguageCode")}}</dt>
+ <dd>一个<a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.10">语言标记</a> 例如 <code>"en-US"</code> 或者 "<code>fr</code>".</dd>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("i18n.getAcceptLanguages()")}}</dt>
+ <dd>得到浏览器 <a href="/en-US/docs/Web/HTTP/Content_negotiation#The_Accept-Language_header">支持的语言</a> 。这与浏览器使用的区域设置不同。要获得区域设置,请使用{{WebExtAPIRef('i18n.getUILanguage')}}.</dd>
+ <dt>{{WebExtAPIRef("i18n.getMessage()")}}</dt>
+ <dd>获取指定消息的本地化字符串。</dd>
+ <dt>{{WebExtAPIRef("i18n.getUILanguage()")}}</dt>
+ <dd>获取浏览器的用户界面语言。 这与返回首选的用户语言 {{WebExtAPIRef('i18n.getAcceptLanguages')}} 不同。</dd>
+ <dt>{{WebExtAPIRef("i18n.detectLanguage()")}}</dt>
+ <dd>使用 <a href="https://github.com/CLD2Owners/cld2">Compact Language Detector</a>属性检测所提供文本的语言。</dd>
+</dl>
+
+<dl>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("webextensions.api.i18n")}}</p>
+
+<p>{{WebExtExamples("h2")}}</p>
+
+<dl>
+</dl>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>这个 API 是基于 Chromium 的 <a href="https://developer.chrome.com/extensions/i18n"><code>chrome.i18n</code></a> API,这个文档源自 Chromium 代码中的  <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/i18n.json"><code>history.json</code></a> 。</p>
+
+<p>微软 Edge 的兼容性数据由微软公司提供,并在这里收录在《知识共享3.0美国许可证》中。</p>
+</div>
+
+<div class="hidden">
+<pre class="notranslate">// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/idle/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/idle/index.html
new file mode 100644
index 0000000000..a6160bc90d
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/idle/index.html
@@ -0,0 +1,97 @@
+---
+title: idle
+slug: Mozilla/Add-ons/WebExtensions/API/idle
+tags:
+ - API
+ - Idle
+ - WebExtensions
+ - requestIdleCallback
+ - 性能优化
+translation_of: Mozilla/Add-ons/WebExtensions/API/idle
+---
+<div>{{AddonSidebar}}</div>
+
+<p>找出用户系统何时处于空闲,锁定或活动状态。</p>
+
+<p>要使用此API,您需要具有“空闲”<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">权限</a>。</p>
+
+<h2 id="类型">类型</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("idle.IdleState")}}</dt>
+ <dd>
+ <p>描述设备空闲状态的字符串。</p>
+ </dd>
+</dl>
+
+<h2 id="函数">函数</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("idle.queryState()")}}</dt>
+ <dd>如果系统被锁定则返回“已锁定”,如果用户未在指定的秒数内生成任何输入,则返回“空闲”,否则返回“活动”。</dd>
+ <dt>{{WebExtAPIRef("idle.setDetectionInterval()")}}</dt>
+ <dd>设置用于确定系统何时处于 {{WebExtAPIRef("idle.onStateChanged")}}  事件的空闲状态的时间间隔。</dd>
+</dl>
+
+<h2 id="事件">事件</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("idle.onStateChanged")}}</dt>
+ <dd>当系统改变状态时触发。</dd>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("webextensions.api.idle")}}</p>
+
+<p>{{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>确认</strong>
+
+<p>此 API基于 Chromium 的 <a href="https://developer.chrome.com/extensions/idle"><code>chrome.idle</code></a> API。本文档源自 Chromium代码中的 <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/idle.json"><code>idle.json</code></a> 。</p>
+
+<p>Microsoft Edge 兼容性数据由 Microsoft Corporation提供,并包含在Creative Commons Attribution 3.0 United States License下。</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
+
+<div></div>
+
+<h3 id="了解更多">了解更多:</h3>
+
+<div><a href="https://developer.mozilla.org/zh-CN/docs/Web/API/Window/requestIdleCallback">https://developer.mozilla.org/zh-CN/docs/Web/API/Window/requestIdleCallback </a></div>
+
+<div></div>
+
+<div></div>
+
+<div>...</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/index.html
new file mode 100644
index 0000000000..a469192447
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/index.html
@@ -0,0 +1,50 @@
+---
+title: API
+slug: Mozilla/Add-ons/WebExtensions/API
+tags:
+ - NeedsTranslation
+ - TopicStub
+translation_of: Mozilla/Add-ons/WebExtensions/API
+---
+<div>{{AddonSidebar}}</div>
+
+<div>
+<p>WebExtension JavaScript API 可以在附加组件的<a href="https://developer.mozilla.org/zh-CN/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Background_scripts">后台脚本</a>和附加组件定义的任何<a href="https://developer.mozilla.org/zh-CN/Add-ons/WebExtensions/User_interface_components#Browser_actions">浏览器动作</a>或<a href="https://developer.mozilla.org/zh-CN/Add-ons/WebExtensions/User_interface_components#Page_actions">页面动作</a>中使用。这里的部分API也可以通过附加组件的<a href="https://developer.mozilla.org/zh-CN/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Content_scripts">内容脚本</a>访问(见<a href="https://developer.mozilla.org/zh-CN/Add-ons/WebExtensions/Content_scripts#WebExtension_APIs">内容脚本指南列表</a>)。</p>
+
+<p>要使用更强大的 API,您需要在您的 manifest.json 中<a href="https://developer.mozilla.org/zh-CN/Add-ons/WebExtensions/manifest.json/permissions">申请权限</a>。</p>
+
+<p>您可以使用 <code>browser</code> 命名空间访问这些 API。</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js">function logTabs(tabs) {
+ console.log(tabs);
+}
+
+browser.tabs.query({currentWindow: true}, logTabs);</code></pre>
+</div>
+
+<div>
+<p>许多 API 为异步,返回一个 <code><a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>:</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js">function logCookie(c) {
+ console.log(c);
+}
+
+function logError(e) {
+ console.error(e);
+}
+
+var setCookie = browser.cookies.set(
+ {url: "https://developer.mozilla.org/"}
+);
+setCookie.then(logCookie, logError);</code></pre>
+</div>
+
+<div>
+<p>请注意,这不同于 Google Chrome 的扩展系统,它使用 <code>chrome</code> 而非 <code>browser</code> 名字空间,并且对异步函数使用回调而不是 promises。为辅助移植,Firefox 实现的 WebExtensions 支持 <code>chrome</code> 和回调以及 <code>browser</code> 和 promises。Mozilla 也写了一个 polyfill 使使用 <code>browser</code> 和 promises 的代码能不经修改的在 Chrome 中使用:<a class="external external-icon" href="https://github.com/mozilla/webextension-polyfill">https://github.com/mozilla/webextension-polyfill</a>。</p>
+
+<p>微软 Edge 使用 <code>browser</code> 名字空间,但尚不支持基于 promise 的异步API。目前在 Edge 中,异步 API 必须使用回调。</p>
+
+<p>并非所有浏览器都支持这里的所有 API:详情见<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Browser_support_for_JavaScript_APIs">浏览器对 JavaScript API 的支持</a>。</p>
+</div>
+
+<div>{{SubpagesWithSummaries}}</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/permissions/contains/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/permissions/contains/index.html
new file mode 100644
index 0000000000..c701942058
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/permissions/contains/index.html
@@ -0,0 +1,94 @@
+---
+title: permissions.contains()
+slug: Mozilla/Add-ons/WebExtensions/API/permissions/contains
+tags:
+ - Contains
+ - permissions.contains()
+translation_of: Mozilla/Add-ons/WebExtensions/API/permissions/contains
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>检查扩展名是否具有给定 {{WebExtAPIRef("permissions.Permissions")}}  对象中列出的权限。</p>
+
+<p>The <code>Permissions</code> argument may contain either an origins property, which is an array of <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#Host_permissions">host permissions</a>, or a <code>permissions</code> property, which is an array of <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#API_permissions">API permissions</a>, or both.</p>
+
+<p>This is an asynchronous function that returns a <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>. The promise is fulfilled with true only if all the extension currently has all the given permissions. For host permissions, if the extension's permissions <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns">pattern-match</a> the permissions listed in <code>origins</code>, then they are considered to match.</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox brush:js notranslate">var getContains = browser.permissions.contains(
+ permissions // Permissions object
+)
+</pre>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt><code>permissions</code></dt>
+ <dd>A {{WebExtAPIRef("permissions.Permissions")}} object.</dd>
+</dl>
+
+<h3 id="Return_value">Return value</h3>
+
+<p>A <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> that will be fulfilled with <code>true</code> if the extension already has all the permissions listed in the <code>permissions</code> argument, or <code>false</code> otherwise.</p>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.permissions.contains")}}</p>
+
+<h2 id="Examples">Examples</h2>
+
+<pre class="brush: js notranslate">// Extension permissions are:
+// "webRequest", "tabs", "*://*.mozilla.org/*"
+
+var testPermissions1 = {
+ origins: ["*://mozilla.org/"],
+ permissions: ["tabs"]
+};
+
+browser.permissions.contains(testPermissions1).then((result) =&gt; {
+ console.log(result); // true
+});
+
+var testPermissions2 = {
+  origins: ["*://mozilla.org/"],
+  permissions: ["tabs", "alarms"]
+};
+
+browser.permissions.contains(testPermissions2).then((result) =&gt; {
+ console.log(result); // false, "alarms" doesn't match
+});
+
+var testPermissions3 = {
+  origins: ["https://developer.mozilla.org/"],
+  permissions: ["tabs", "webRequest"]
+};
+
+browser.permissions.contains(testPermissions3).then((result) =&gt; {
+ console.log(result); // true: "https://developer.mozilla.org/"
+}); // matches: "*://*.mozilla.org/*"
+
+var testPermissions4 = {
+  origins: ["https://example.org/"]
+};
+
+browser.permissions.contains(testPermissions4).then((result) =&gt; {
+ console.log(result); // false, "https://example.org/"
+}); // does not match
+
+</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/permissions"><code>chrome.permissions</code></a> API.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div id="gtx-trans" style="position: absolute; left: 677px; top: 46px;">
+<div class="gtx-trans-icon"></div>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/permissions/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/permissions/index.html
new file mode 100644
index 0000000000..df6c1c8e5c
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/permissions/index.html
@@ -0,0 +1,93 @@
+---
+title: permissions
+slug: Mozilla/Add-ons/WebExtensions/API/permissions
+tags:
+ - API
+ - Add-ons
+ - Extensions
+ - NeedsTranslation
+ - Permissions
+ - Reference
+ - TopicStub
+ - WebExtensions
+translation_of: Mozilla/Add-ons/WebExtensions/API/permissions
+---
+<div>{{AddonSidebar}}</div>
+
+<div>Enables extensions to request extra permissions at runtime, after they have been installed.</div>
+
+<div></div>
+
+<p>Extensions need permissions to access more powerful WebExtension APIs. They can ask for permissions at install time, by including the permissions they need in the <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permissions</a></code> manifest.json key. The main advantages of asking for permissions at install time are:</p>
+
+<ul>
+ <li>The user is only asked once, so it's less disruptive for them, and a simpler decision.</li>
+ <li>The extension can rely on the access to the APIs it needs, because if already running, the permissions have been granted.</li>
+</ul>
+
+<p>There is not yet a simple GUI, for users to view permissions of their installed WebExtension Add-ons.  Users must use about:debugging, go to the Add-ons section, then use the "Manifest Url" link for this Add-on. This shows raw json, which includes a "permissions" block, showing the permissions used by this addon.</p>
+
+<p>With the permissions API, an extension can ask for additional permissions at runtime. These permissions need to be listed in the <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_permissions">optional_permissions</a></code> manifest.json key. Note that some permissions are not allowed in <code>optional_permissions</code>. The main advantages of this are:</p>
+
+<ul>
+ <li>The extension can run with a smaller set of permissions, except when it actually needs them.</li>
+ <li>The extension can handle permission denial in a graceful manner, instead of presenting the user with a global "all or nothing" choice at install time. You can still get a lot out of that map extension, without giving it access to your location, for example.</li>
+ <li>
+ <p>The extension may need <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#Host_permissions">host permissions</a>, but not know at install time which host permissions it needs. For example, the list of hosts may be a user setting. In this scenario, asking for a more specific range of hosts at runtime, can be an alternative to asking for "&lt;all_urls&gt;" at install time.</p>
+ </li>
+</ul>
+
+<div>To use the permissions API, decide which permissions your extension can request at runtime, and list them in <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_permissions">optional_permissions</a></code>. After this, you can request any permissions that were included in <code>optional_permissions</code>. Requests may only be made in the handler for a user action (for example, a click handler).</div>
+
+<div></div>
+
+<div>For advice on designing your request for runtime permissions, to maximize the likelihood that users grant them, see <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Request_the_right_permissions#Request_permissions_at_runtime">Request permissions at runtime</a>.</div>
+
+<h2 id="Types">Types</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("permissions.Permissions")}}</dt>
+ <dd>Represents a set of permissions.</dd>
+</dl>
+
+<h2 id="Methods">Methods</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("permissions.contains()")}}</dt>
+ <dd>Discover an extension's given set of permissions.</dd>
+ <dt>{{WebExtAPIRef("permissions.getAll()")}}</dt>
+ <dd>Get all the permissions this extension currently has.</dd>
+ <dt>{{WebExtAPIRef("permissions.remove()")}}</dt>
+ <dd>Give up a set of permissions.</dd>
+ <dt>{{WebExtAPIRef("permissions.request()")}}</dt>
+ <dd>Ask for a set of permissions.</dd>
+</dl>
+
+<h2 id="Event_handlers">Event handlers</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("permissions.onAdded")}}</dt>
+ <dd>Fired when a new permission is granted.</dd>
+ <dt>{{WebExtAPIRef("permissions.onRemoved")}}</dt>
+ <dd>Fired when a permission is removed.</dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{Compat("webextensions.api.permissions")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><code>manifest.json</code> <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permissions</a></code> property</li>
+ <li><code>manifest.json</code> <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_permissions">optional_permissions</a></code> property</li>
+</ul>
+
+<p>{{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/permissions"><code>chrome.permissions</code></a> API.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/proxy/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/proxy/index.html
new file mode 100644
index 0000000000..e259cf65fc
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/proxy/index.html
@@ -0,0 +1,65 @@
+---
+title: proxy
+slug: Mozilla/Add-ons/WebExtensions/API/proxy
+translation_of: Mozilla/Add-ons/WebExtensions/API/proxy
+---
+<div>{{AddonSidebar}}</div>
+
+<div></div>
+
+<div class="blockIndicator warning">
+<p><strong>Warning</strong><br>
+ 不推荐使用 {{WebExtAPIRef("proxy.register()")}} 或者 {{WebExtAPIRef("proxy.unregister()")}} 方法使用 <a href="/en-US/Add-ons/WebExtensions/API/proxy/register#PAC_file_specification">Proxy Auto-Configuration (PAC) file</a>. 这个 API 将会在 Firefox 68 中废弃并且在 Firefox 71中删除.</p>
+</div>
+
+<p>使用proxy API来代理web请求。你可以使用<code><strong>{{WebExtAPIRef("proxy.onRequest")}}</strong></code>事件监听器来拦截web请求,并且返回一个可以描述是否代理并且怎样代理它们的对象。</p>
+
+<p>{{WebExtAPIRef("proxy.onRequest")}}的好处在于,用于实现你拦截策略的代码在你的扩展的后台脚本运行,所以,它可以让<code><strong>WebExtension APIs</strong></code>能够完全的访问你的扩展(举例来说,可以访问你扩展的<code>storage</code>和像dns等类似的网络api)</p>
+
+<p>除了这个api,扩展也能够使用<strong><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserSettings/proxyConfig">browserSettings.proxyConfig</a></code></strong>属性来重新编辑你全局的<code>proxy</code>设置</p>
+
+<p>Chrome浏览器提供了一个叫做<code><a href="https://developer.chrome.com/extensions/proxy">'proxy'</a>的</code>api扩展,它的功能跟这个api类似,在chrome的api中也可以用来实现一个<code>拦截策略。</code>然而,Chrome 的API的设计跟这个API设计完全不同。因为这个API跟谷歌的<code>proxy</code>的<font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.5);">API完全不同, 这个API只能通过'browser'命名空间访问</span></font></p>
+
+<p>如果你想用这个API你需要得到'<code>proxy</code>'的<a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a>.并且,如果你想拦截一个请求,你同样也需要当前拦截请求的url的 <a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">host permission</a>。</p>
+
+<h2 id="Types">Types</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("proxy.ProxyInfo")}}</dt>
+ <dd>Describes a proxy.</dd>
+ <dt>{{WebExtAPIRef("proxy.RequestDetails")}}</dt>
+ <dd>
+ <p>Contains information about a web request that the browser is about to make.</p>
+ </dd>
+</dl>
+
+<h2 id="Properties">Properties</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("proxy.settings")}}</dt>
+ <dd>Get and set proxy settings.</dd>
+</dl>
+
+<h2 id="Functions">Functions</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("proxy.register()")}} {{Deprecated_Inline}}</dt>
+ <dd>Registers the given proxy script.</dd>
+ <dt>{{WebExtAPIRef("proxy.unregister()")}} {{Deprecated_Inline}}</dt>
+ <dd>Unregisters the proxy script.</dd>
+</dl>
+
+<h2 id="Events">Events</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("proxy.onError")}}</dt>
+ <dd>Fired when the system encounters an error running the PAC script or the <code>onRequest</code> listener.</dd>
+ <dt>{{WebExtAPIRef("proxy.onRequest")}}</dt>
+ <dd>Fired when a web request is about to be made, giving the extension an opportunity to proxy it.</dd>
+</dl>
+
+<p>{{WebExtExamples("h2")}}</p>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{Compat("webextensions.api.proxy")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/connectnative/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/connectnative/index.html
new file mode 100644
index 0000000000..d3d4d9a14d
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/connectnative/index.html
@@ -0,0 +1,114 @@
+---
+title: 连接本地应用程序方法 - runtime.connectNative()
+slug: Mozilla/Add-ons/WebExtensions/API/runtime/connectNative
+tags:
+ - 附加组件连接本地应用程序
+translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/connectNative
+---
+<div>{{AddonSidebar()}}</div>
+
+<div>该方法能够把附加组件和用户计算机上的一个本地应用程序相连接.</div>
+
+<div> </div>
+
+<div>同时我们需要本地应用程序的名称作为参数. 当启动本地应用程序的时候会返回一个{{WebExtAPIRef("runtime.Port")}} 对象给调用者.</div>
+
+<div> </div>
+
+<div>之后可以通过该对象的 Port.onMessage() 和 Port.postMessage()方法来和本地应用程序进行信息交互.</div>
+
+<div> </div>
+
+<div>本地应用程序会一直运行直到退出, 除非调用了 <code>Port.disconnect()</code>方法, 亦或创建该Port对象的页面被摧毁了. 一旦Port对象断开连接, 浏览器会给该进程几秒的时间以便安全优雅的退出和释放, 之后如果发现该进程没退出的话就直接暴力干掉.</div>
+
+<div> </div>
+
+<p>更多信息, 请查看 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging">Native messaging</a>.</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox brush:js">var port = browser.runtime.connectNative(
+ application // 这是一个字符串
+)
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>application</code></dt>
+ <dd><code>值类型为string</code>. 该参数的值为要连接的本地应用程序的名称. 必须要跟 <a href="/en-US/Add-ons/WebExtensions/Native_messaging#App_manifest">native application's manifest file</a> 中的"name"特性的值一致.</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>是一个 {{WebExtAPIRef('runtime.Port')}} 对象. 该对象是用来跟本地应用程序进行消息交互的.</p>
+
+<h2 id="浏览器的兼容性">浏览器的兼容性</h2>
+
+<p class="hidden">本页中的兼容性表格是通过结构化后的数据生成的. 如果你想提供更多的兼容性数据, 请检出 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 添加修改后再给我们发送一个pull请求.</p>
+
+<p>{{Compat("webextensions.api.runtime.connectNative")}}</p>
+
+<h2 id="示例">示例</h2>
+
+<p>本示例中连接了本地应用程序"ping_pong"并且启动了监听以便接收消息. 当用户单击浏览器上的操作按钮时它会发送一个本地应用程序的消息:</p>
+
+<pre class="brush: js">/*
+启动时, 连接"ping_pong"本地应用程序.
+*/
+var port = <code class="language-js">browser</code>.runtime.connectNative("ping_pong");
+
+/*
+监听(接收)来自"ping_pong"本地应用程序的消息.
+*/
+port.onMessage.addListener((response) =&gt; {
+ console.log("Received: " + response);
+});
+
+/*
+当浏览器上的单击操作被触发时, 发送一个消息给本地应用程序.
+*/
+<code class="language-js">browser</code>.browserAction.onClicked.addListener(() =&gt; {
+ console.log("Sending: ping");
+ port.postMessage("ping");
+});</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>万分感谢</strong>
+
+<p>该 API 是基于 Chromium 的 <a href="https://developer.chrome.com/extensions/runtime#method-connectNative"><code>chrome.runtime</code></a> API. 本文档采自 Chromium 代码中的 <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a>.</p>
+
+<p>Microsoft Edge 的兼容性数据由微软公司提供, 并被列入以下许可证 Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/getmanifest/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/getmanifest/index.html
new file mode 100644
index 0000000000..77870d7010
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/getmanifest/index.html
@@ -0,0 +1,79 @@
+---
+title: 读取主文件信息方法 - runtime.getManifest()
+slug: Mozilla/Add-ons/WebExtensions/API/runtime/getManifest
+tags:
+ - 读取主文件信息方法
+ - 附加组件
+translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/getManifest
+---
+<div>{{AddonSidebar()}}</div>
+
+<div>该方法会获取一个完整的主文件 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json </a>, 并返回一个序列化后的 JSON 对象.</div>
+
+<div> </div>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox brush:js">browser.runtime.getManifest()
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<p>无.</p>
+
+<h3 id="返回值">返回值</h3>
+
+<p>是一个能表示主文件所有信息的 JSON 对象.</p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.runtime.getManifest")}}</p>
+
+<h2 id="示例">示例</h2>
+
+<p>取得主文件中的 name 特性的值, 并输出到控制台:</p>
+
+<pre class="brush: js">var manifest = browser.runtime.getManifest();
+console.log(manifest.name);</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/runtime#method-getManifest"><code>chrome.runtime</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/index.html
new file mode 100644
index 0000000000..5a1618e9e7
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/index.html
@@ -0,0 +1,181 @@
+---
+title: runtime
+slug: Mozilla/Add-ons/WebExtensions/API/runtime
+tags:
+ - API
+ - Add-ons
+ - Extensions
+ - Interface
+ - NeedsTranslation
+ - Non-standard
+ - Reference
+ - TopicStub
+ - WebExtensions
+ - runtime
+translation_of: Mozilla/Add-ons/WebExtensions/API/runtime
+---
+<div>{{AddonSidebar}}</div>
+
+<p>该模块提供关于附加组件以及运行环境的信息。</p>
+
+<p>它提供一组消息通信API,允许你:</p>
+
+<ul>
+ <li>在附加组件的不同模块间通信。</li>
+ <li>和其它的附加组件通信。</li>
+ <li>和native应用通信。</li>
+</ul>
+
+<h2 id="Types">Types</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("runtime.Port")}}</dt>
+ <dd>表示两个特定上下文之间的连接的一端,可用于交换消息。</dd>
+ <dt>{{WebExtAPIRef("runtime.MessageSender")}}</dt>
+ <dd>
+ <div class="trans-right">
+ <div class="output-wrap small-font">
+ <div class="output-mod ordinary-wrap">
+ <div class="output-bd" dir="ltr" style="padding-bottom: 0px;">
+ <p class="ordinary-output target-output clearfix"><span>包含有关消息或连接请求的发件人的信息。</span></p>
+ </div>
+ </div>
+ </div>
+ </div>
+ </dd>
+ <dt>{{WebExtAPIRef("runtime.PlatformOs")}}</dt>
+ <dd>标识浏览器的操作系统。</dd>
+ <dt>{{WebExtAPIRef("runtime.PlatformArch")}}</dt>
+ <dd>标识浏览器的处理器架构。</dd>
+ <dt>{{WebExtAPIRef("runtime.PlatformInfo")}}</dt>
+ <dd>包含有关浏览器正在运行的平台的信息。</dd>
+ <dt>{{WebExtAPIRef("runtime.RequestUpdateCheckStatus")}}</dt>
+ <dd>{{WebExtAPIRef("runtime.requestUpdateCheck()")}} 的返回结果。</dd>
+ <dt>{{WebExtAPIRef("runtime.OnInstalledReason")}}</dt>
+ <dd>{{WebExtAPIRef("runtime.onInstalled")}} 事件被触发的原因。</dd>
+ <dt>{{WebExtAPIRef("runtime.OnRestartRequiredReason")}}</dt>
+ <dd>{{WebExtAPIRef("runtime.onRestartRequired")}} 事件被触发的原因。</dd>
+</dl>
+
+<h2 id="Properties">Properties</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("runtime.lastError")}}</dt>
+ <dd>当异步方法执行时发生了错误,它需要向其调用方报告时,该值会被设置。</dd>
+ <dt>{{WebExtAPIRef("runtime.id")}}</dt>
+ <dd>当前扩展的ID。</dd>
+</dl>
+
+<h2 id="Functions">Functions</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("runtime.getBackgroundPage()")}}</dt>
+ <dd>取得当前扩展的后台页的 <a href="https://wiki.developer.mozilla.org/zh-CN/docs/Web/API/Window">Window</a> 对象。</dd>
+ <dt>{{WebExtAPIRef("runtime.openOptionsPage()")}}</dt>
+ <dd>
+ <p>打开你的扩展的 <a href="/zh-CN/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Options_pages">选项页面</a>。</p>
+ </dd>
+ <dt>{{WebExtAPIRef("runtime.getManifest()")}}</dt>
+ <dd>获得完整的 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a> 声明文件的序列化对象。</dd>
+ <dt>{{WebExtAPIRef("runtime.getURL()")}}</dt>
+ <dd>给定某个打包在扩展中的资源的基于 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a> 相对路径,返回一个完整有效的 URL。</dd>
+ <dt>{{WebExtAPIRef("runtime.setUninstallURL()")}}</dt>
+ <dd>指定一个此扩展被卸载后打开的 URL。</dd>
+ <dt>{{WebExtAPIRef("runtime.reload()")}}</dt>
+ <dd>重新加载此扩展。</dd>
+ <dt>{{WebExtAPIRef("runtime.requestUpdateCheck()")}}</dt>
+ <dd>检查此扩展的更新。</dd>
+ <dt>{{WebExtAPIRef("runtime.connect()")}}</dt>
+ <dd>建立一个页面脚本到扩展主进程,或扩展主进程到页面脚本之间的通信连接。</dd>
+ <dt>{{WebExtAPIRef("runtime.connectNative()")}}</dt>
+ <dd>
+ <div>建立一个浏览器扩展与用户电脑上的原生应用的通信连接。</div>
+ </dd>
+ <dt>{{WebExtAPIRef("runtime.sendMessage()")}}</dt>
+ <dd>发送一条消息到此扩展或其他扩展的事件监听器,类似于  {{WebExtAPIRef('runtime.connect')}} 但只能发送一条消息,以及可选的响应处理函数。</dd>
+ <dt>{{WebExtAPIRef("runtime.sendNativeMessage()")}}</dt>
+ <dd>从扩展发送一条消息到原生应用。</dd>
+ <dt>{{WebExtAPIRef("runtime.getPlatformInfo()")}}</dt>
+ <dd>返回当前所在平台的信息。</dd>
+ <dt>{{WebExtAPIRef("runtime.getBrowserInfo()")}}</dt>
+ <dd>返回此扩展所在的浏览器的信息。</dd>
+ <dt>{{WebExtAPIRef("runtime.getPackageDirectoryEntry()")}}</dt>
+ <dd>返回此扩展所在目录的 DirectoryEntry。</dd>
+</dl>
+
+<h2 id="Events">Events</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("runtime.onStartup")}}</dt>
+ <dd>当一个拥有此扩展的账户第一次启动时触发,注意若处于隐私模式中则不会触发。</dd>
+ <dt>{{WebExtAPIRef("runtime.onInstalled")}}</dt>
+ <dd>当扩展第一次安装,扩展更新,浏览器更新后触发。</dd>
+ <dt>{{WebExtAPIRef("runtime.onSuspend")}}</dt>
+ <dd>当扩展将被停止前触发,使得扩展可以执行一些清理工作。</dd>
+ <dt>{{WebExtAPIRef("runtime.onSuspendCanceled")}}</dt>
+ <dd>在此事件 {{WebExtAPIRef("runtime.onSuspend")}} 后触发,表明扩展最终没有被停止。</dd>
+ <dt>{{WebExtAPIRef("runtime.onUpdateAvailable")}}</dt>
+ <dd>当扩展更新可用时触发,注意若扩展运行中,更新不会马上被安装。</dd>
+ <dt>{{WebExtAPIRef("runtime.onBrowserUpdateAvailable")}}</dt>
+ <dd>当浏览器更新可用时触发,注意浏览器需要重启才能安装更新。</dd>
+ <dt>{{WebExtAPIRef("runtime.onConnect")}}</dt>
+ <dd>与扩展进程或页面脚本(content script)建立通信连接时触发。</dd>
+ <dt>{{WebExtAPIRef("runtime.onConnectExternal")}}</dt>
+ <dd>与其他扩展建立通信连接时触发。</dd>
+ <dt>{{WebExtAPIRef("runtime.onMessage")}}</dt>
+ <dd>当收到扩展进程或页面脚本(content script)的消息时触发。</dd>
+ <dt>{{WebExtAPIRef("runtime.onMessageExternal")}}</dt>
+ <dd>当收到其他扩展的消息时触发,不能在页面脚本(content script)中使用。</dd>
+ <dt>{{WebExtAPIRef("runtime.onRestartRequired")}}</dt>
+ <dd>当设备要重启时触发。</dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{Compat("webextensions.api.runtime")}}</p>
+
+<div class="hidden note">
+<p>The "Chrome incompatibilities" section is included from <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities"> https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a> using the <a href="/en-US/docs/Template:WebExtChromeCompat">WebExtChromeCompat</a> macro.</p>
+
+<p>If you need to update this content, edit <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities">https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a>, then shift-refresh this page to see your changes.</p>
+</div>
+
+<p>{{Compat("webextensions.api.runtime")}} {{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/runtime"><code>chrome.runtime</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre class="notranslate">// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/onconnect/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/onconnect/index.html
new file mode 100644
index 0000000000..d51cb8abbc
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/onconnect/index.html
@@ -0,0 +1,228 @@
+---
+title: runtime.onConnect
+slug: Mozilla/Add-ons/WebExtensions/API/runtime/onConnect
+translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/onConnect
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>当使用扩展处理或content script建立连接时触发.</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox brush:js">browser.runtime.onConnect.addListener(listener)
+browser.runtime.onConnect.removeListener(listener)
+browser.runtime.onConnect.hasListener(listener)
+</pre>
+
+<p>事件有三个方法:</p>
+
+<dl>
+ <dt><code>addListener(callback)</code></dt>
+ <dd>为 这个事件添加一个监听器.</dd>
+ <dt><code>removeListener(listener)</code></dt>
+ <dd>停止监听这个事件. <code>listener</code> 参数就是要移除的监听器.</dd>
+ <dt><code>hasListener(listener)</code></dt>
+ <dd>检查监听器是否已经注册到这个事件上. 如果已经监听,则返回 <code>true</code> 否则返回 <code>false</code>.</dd>
+</dl>
+
+<h2 id="addListener_语法">addListener 语法</h2>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>function</code></dt>
+ <dd>
+ <p>A callback function that will be called when this event occurs. The function will be passed the following arguments:</p>
+
+ <dl class="reference-values">
+ <dt><code>port</code></dt>
+ <dd>A {{WebExtAPIRef('runtime.Port')}} object connecting the current script to the other context it is connecting to.</dd>
+ </dl>
+ </dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.runtime.onConnect")}}</p>
+
+<h2 id="Examples">Examples</h2>
+
+<p>This content script:</p>
+
+<ul>
+ <li>connects to the background script, and stores the <code>Port</code> in a variable <code>myPort</code></li>
+ <li>listens for messages on <code>myPort</code>, and logs them</li>
+ <li>sends messages to the background script, using <code>myPort</code>, when the user clicks the document</li>
+</ul>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="comment token">// content-script.js</span>
+
+<span class="keyword token">var</span> myPort <span class="operator token">=</span> browser<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span><span class="function token">connect</span><span class="punctuation token">(</span><span class="punctuation token">{</span>name<span class="punctuation token">:</span><span class="string token">"port-from-cs"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+myPort<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>greeting<span class="punctuation token">:</span> <span class="string token">"hello from content script"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+
+myPort<span class="punctuation token">.</span>onMessage<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span><span class="keyword token">function</span><span class="punctuation token">(</span>m<span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"In content script, received message from background script: "</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+ console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>m<span class="punctuation token">.</span>greeting<span class="punctuation token">)</span><span class="punctuation token">;</span>
+<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+
+document<span class="punctuation token">.</span>body<span class="punctuation token">.</span><span class="function token">addEventListener</span><span class="punctuation token">(</span><span class="string token">"click"</span><span class="punctuation token">,</span> <span class="keyword token">function</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ myPort<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>greeting<span class="punctuation token">:</span> <span class="string token">"they clicked the page!"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+
+<p>The corresponding background script:</p>
+
+<ul>
+ <li>listens for connection attempts from the content script</li>
+ <li>when it receives a connection attempt:
+ <ul>
+ <li>stores the port in a variable named <code>portFromCS</code></li>
+ <li>sends the content script a message using the port</li>
+ <li>starts listening to messages received on the port, and logs them</li>
+ </ul>
+ </li>
+ <li>sends messages to the content script, using <code>portFromCS</code>, when the user clicks the extension's browser action</li>
+</ul>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="comment token">// background-script.js</span>
+
+<span class="keyword token">var</span> portFromCS<span class="punctuation token">;</span>
+
+<span class="keyword token">function</span> <span class="function token">connected</span><span class="punctuation token">(</span>p<span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ portFromCS <span class="operator token">=</span> p<span class="punctuation token">;</span>
+ portFromCS<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>greeting<span class="punctuation token">:</span> <span class="string token">"hi there content script!"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+ portFromCS<span class="punctuation token">.</span>onMessage<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span><span class="keyword token">function</span><span class="punctuation token">(</span>m<span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"In background script, received message from content script"</span><span class="punctuation token">)</span>
+ console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>m<span class="punctuation token">.</span>greeting<span class="punctuation token">)</span><span class="punctuation token">;</span>
+ <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+<span class="punctuation token">}</span>
+
+browser<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span>onConnect<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>connected<span class="punctuation token">)</span><span class="punctuation token">;</span>
+
+browser<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span><span class="keyword token">function</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ portFromCS<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>greeting<span class="punctuation token">:</span> <span class="string token">"they clicked the button!"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
+
+<div id="SL_balloon_obj" style="display: block;">
+<div class="SL_ImTranslatorLogo" id="SL_button" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%; opacity: 1; display: none; left: -8px; top: -25px;"> </div>
+
+<div id="SL_shadow_translation_result2" style="display: none;"> </div>
+
+<div id="SL_shadow_translator" style="display: none;">
+<div id="SL_planshet">
+<div id="SL_arrow_up" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;"> </div>
+
+<div id="SL_Bproviders">
+<div class="SL_BL_LABLE_ON" id="SL_P0" title="Google">G</div>
+
+<div class="SL_BL_LABLE_ON" id="SL_P1" title="Microsoft">M</div>
+
+<div class="SL_BL_LABLE_ON" id="SL_P2" title="Translator">T</div>
+</div>
+
+<div id="SL_alert_bbl" style="display: none;">
+<div id="SLHKclose" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;"> </div>
+
+<div id="SL_alert_cont"> </div>
+</div>
+
+<div id="SL_TB">
+<table id="SL_tables">
+ <tbody>
+ <tr>
+ <td class="SL_td"><input></td>
+ <td class="SL_td"><select><option value="auto">检测语言</option><option value="eo">世界语</option><option value="zh-CN">中文简体</option><option value="zh-TW">中文繁体</option><option value="da">丹麦语</option><option value="uk">乌克兰语</option><option value="uz">乌兹别克语</option><option value="ur">乌尔都语</option><option value="hy">亚美尼亚语</option><option value="ig">伊博语</option><option value="ru">俄语</option><option value="bg">保加利亚语</option><option value="si">僧伽罗语</option><option value="hr">克罗地亚语</option><option value="is">冰岛语</option><option value="gl">加利西亚语</option><option value="ca">加泰罗尼亚语</option><option value="hu">匈牙利语</option><option value="zu">南非祖鲁语</option><option value="kn">卡纳达语</option><option value="hi">印地语</option><option value="su">印尼巽他语</option><option value="jw">印尼爪哇语</option><option value="id">印尼语</option><option value="gu">古吉拉特语</option><option value="kk">哈萨克语</option><option value="tr">土耳其语</option><option value="tg">塔吉克语</option><option value="sr">塞尔维亚语</option><option value="st">塞索托语</option><option value="cy">威尔士语</option><option value="bn">孟加拉语</option><option value="ceb">宿务语</option><option value="ne">尼泊尔语</option><option value="eu">巴斯克语</option><option value="af">布尔语(南非荷兰语)</option><option value="iw">希伯来语</option><option value="el">希腊语</option><option value="de">德语</option><option value="it">意大利语</option><option value="yi">意第绪语</option><option value="la">拉丁语</option><option value="lv">拉脱维亚语</option><option value="no">挪威语</option><option value="cs">捷克语</option><option value="sk">斯洛伐克语</option><option value="sl">斯洛文尼亚语</option><option value="sw">斯瓦希里语</option><option value="pa">旁遮普语</option><option value="ja">日语</option><option value="ka">格鲁吉亚语</option><option value="mi">毛利语</option><option value="fr">法语</option><option value="pl">波兰语</option><option value="bs">波斯尼亚语</option><option value="fa">波斯语</option><option value="te">泰卢固语</option><option value="ta">泰米尔语</option><option value="th">泰语</option><option value="ht">海地克里奥尔语</option><option value="ga">爱尔兰语</option><option value="et">爱沙尼亚语</option><option value="sv">瑞典语</option><option value="be">白俄罗斯语</option><option value="lt">立陶宛语</option><option value="so">索马里语</option><option value="yo">约鲁巴语</option><option value="my">缅甸语</option><option value="ro">罗马尼亚语</option><option value="lo">老挝语</option><option value="fi">芬兰语</option><option value="hmn">苗语</option><option value="en">英语</option><option value="nl">荷兰语</option><option value="tl">菲律宾语</option><option value="pt">葡萄牙语</option><option value="mn">蒙古语</option><option value="es">西班牙语</option><option value="ha">豪萨语</option><option value="vi">越南语</option><option value="az">阿塞拜疆语</option><option value="sq">阿尔巴尼亚语</option><option value="ar">阿拉伯语</option><option value="ko">韩语</option><option value="mk">马其顿语</option><option value="mg">马尔加什语</option><option value="mr">马拉地语</option><option value="ml">马拉雅拉姆语</option><option value="ms">马来语</option><option value="mt">马耳他语</option><option value="km">高棉语</option><option value="ny">齐切瓦语</option></select></td>
+ <td class="SL_td">
+ <div id="SL_switch_b" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="切换语言"> </div>
+ </td>
+ <td class="SL_td"><select><option value="eo">世界语</option><option value="zh-CN">中文简体</option><option value="zh-TW">中文繁体</option><option value="da">丹麦语</option><option value="uk">乌克兰语</option><option value="uz">乌兹别克语</option><option value="ur">乌尔都语</option><option value="hy">亚美尼亚语</option><option value="ig">伊博语</option><option value="ru">俄语</option><option value="bg">保加利亚语</option><option value="si">僧伽罗语</option><option value="hr">克罗地亚语</option><option value="is">冰岛语</option><option value="gl">加利西亚语</option><option value="ca">加泰罗尼亚语</option><option value="hu">匈牙利语</option><option value="zu">南非祖鲁语</option><option value="kn">卡纳达语</option><option value="hi">印地语</option><option value="su">印尼巽他语</option><option value="jw">印尼爪哇语</option><option value="id">印尼语</option><option value="gu">古吉拉特语</option><option value="kk">哈萨克语</option><option value="tr">土耳其语</option><option value="tg">塔吉克语</option><option value="sr">塞尔维亚语</option><option value="st">塞索托语</option><option value="cy">威尔士语</option><option value="bn">孟加拉语</option><option value="ceb">宿务语</option><option value="ne">尼泊尔语</option><option value="eu">巴斯克语</option><option value="af">布尔语(南非荷兰语)</option><option value="iw">希伯来语</option><option value="el">希腊语</option><option value="de">德语</option><option value="it">意大利语</option><option value="yi">意第绪语</option><option value="la">拉丁语</option><option value="lv">拉脱维亚语</option><option value="no">挪威语</option><option value="cs">捷克语</option><option value="sk">斯洛伐克语</option><option value="sl">斯洛文尼亚语</option><option value="sw">斯瓦希里语</option><option value="pa">旁遮普语</option><option value="ja">日语</option><option value="ka">格鲁吉亚语</option><option value="mi">毛利语</option><option value="fr">法语</option><option value="pl">波兰语</option><option value="bs">波斯尼亚语</option><option value="fa">波斯语</option><option value="te">泰卢固语</option><option value="ta">泰米尔语</option><option value="th">泰语</option><option value="ht">海地克里奥尔语</option><option value="ga">爱尔兰语</option><option value="et">爱沙尼亚语</option><option value="sv">瑞典语</option><option value="be">白俄罗斯语</option><option value="lt">立陶宛语</option><option value="so">索马里语</option><option value="yo">约鲁巴语</option><option value="my">缅甸语</option><option value="ro">罗马尼亚语</option><option value="lo">老挝语</option><option value="fi">芬兰语</option><option value="hmn">苗语</option><option selected value="en">英语</option><option value="nl">荷兰语</option><option value="tl">菲律宾语</option><option value="pt">葡萄牙语</option><option value="mn">蒙古语</option><option value="es">西班牙语</option><option value="ha">豪萨语</option><option value="vi">越南语</option><option value="az">阿塞拜疆语</option><option value="sq">阿尔巴尼亚语</option><option value="ar">阿拉伯语</option><option value="ko">韩语</option><option value="mk">马其顿语</option><option value="mg">马尔加什语</option><option value="mr">马拉地语</option><option value="ml">马拉雅拉姆语</option><option value="ms">马来语</option><option value="mt">马耳他语</option><option value="km">高棉语</option><option value="ny">齐切瓦语</option></select></td>
+ <td class="SL_td">
+ <div id="SL_TTS_voice" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="聆听翻译"> </div>
+ </td>
+ <td class="SL_td">
+ <div class="SL_copy" id="SL_copy" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="复制译文"> </div>
+ </td>
+ <td class="SL_td">
+ <div id="SL_bbl_font_patch"> </div>
+
+ <div class="SL_bbl_font" id="SL_bbl_font" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="字体大小"> </div>
+ </td>
+ <td class="SL_td">
+ <div id="SL_bbl_help" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="帮助"> </div>
+ </td>
+ <td class="SL_td">
+ <div class="SL_pin_off" id="SL_pin" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="固定弹出窗口"> </div>
+ </td>
+ </tr>
+ </tbody>
+</table>
+</div>
+</div>
+
+<div id="SL_shadow_translation_result" style=""> </div>
+
+<div class="SL_loading" id="SL_loading" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;"> </div>
+
+<div id="SL_player2"> </div>
+
+<div id="SL_alert100">文本转语音功能仅限200个字符</div>
+
+<div id="SL_Balloon_options" style="background: rgb(255, 255, 255) repeat scroll 0% 0%;">
+<div id="SL_arrow_down" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;"> </div>
+
+<table id="SL_tbl_opt" style="width: 100%;">
+ <tbody>
+ <tr>
+ <td><input></td>
+ <td>
+ <div id="SL_BBL_IMG" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="显示翻译器的按钮 3 秒"> </div>
+ </td>
+ <td><a class="SL_options" title="显示选项">选项</a> : <a class="SL_options" title="翻译历史记录">历史</a> : <a class="SL_options" title="反馈">反馈</a> : <a class="SL_options" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=GD9D8CPW8HFA2" title="作出一点点贡献">Donate</a></td>
+ <td><span id="SL_Balloon_Close" title="关闭">关闭</span></td>
+ </tr>
+ </tbody>
+</table>
+</div>
+</div>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/onmessage/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/onmessage/index.html
new file mode 100644
index 0000000000..afa54c1aaf
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/onmessage/index.html
@@ -0,0 +1,307 @@
+---
+title: runtime.onMessage
+slug: Mozilla/Add-ons/WebExtensions/API/runtime/onMessage
+translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/onMessage
+---
+<div>{{AddonSidebar()}}</div>
+
+<div>利用此事件来监听来自你的扩展其他部分的消息。例如,使用:</div>
+
+<div></div>
+
+<ul>
+ <li>in a <a href="/en-US/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Content_scripts">content script</a>, to listen for messages from a <a href="/en-US/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Background_scripts">background script.</a></li>
+ <li>in a background script, to listen for messages from a content script.</li>
+ <li>in an <a href="/en-US/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Options_pages">options page</a> or <a href="/en-US/Add-ons/WebExtensions/User_interface_components#Popups">popup</a> script, to listen for messages from a background script.</li>
+ <li>in a background script, to listen for messages from an options page or popup script.</li>
+</ul>
+
+<p>To send a message that is received by the <code>onMessage</code> listener, use {{WebExtAPIRef("runtime.sendMessage()")}} or (to send a message to a content script) {{WebExtAPIRef("tabs.sendMessage()")}}.</p>
+
+<div class="blockIndicator note">
+<p>Avoid creating multiple <code>onMessage</code> listeners for the same type of message, as the order in which multiple listeners will fire is not guaranteed. Where you want to guarantee the delivery of a message to a specific end point, use the <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts#Connection-based_messaging">connection-based approach to exchange messages</a>.</p>
+</div>
+
+<p>Along with the message itself, the listener is passed:</p>
+
+<ul>
+ <li>a <code>sender</code> object giving details about the message sender.</li>
+ <li>a <code>sendResponse</code> function that can be used to send a response back to the sender.</li>
+</ul>
+
+<p>You can send a synchronous response to the message by calling the <code>sendResponse</code> function inside your listener. <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/onMessage#Sending_a_synchronous_response">See an example</a>.</p>
+
+<p>To send an asynchronous response, there are two options:</p>
+
+<ul>
+ <li>return <code>true</code> from the event listener. This keeps the <code>sendResponse</code> function valid after the listener returns, so you can call it later. <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/onMessage#Sending_an_asynchronous_response_using_sendResponse">See an example</a>.</li>
+ <li>return a <code>Promise</code> from the event listener, and resolve when you have the response (or reject it in case of an error). <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/onMessage#Sending_an_asynchronous_response_using_a_Promise">See an example</a>.</li>
+</ul>
+
+<div class="warning">
+<p>Returning a <code>Promise</code> is now preferred as <code>sendResponse</code> <a href="https://github.com/mozilla/webextension-polyfill/issues/16#issuecomment-296693219">will be removed from the W3C spec</a>. The popular <a href="https://github.com/mozilla/webextension-polyfill">webextension-polyfill</a> library has already removed the <code>sendResponse</code> function from its implementation.</p>
+</div>
+
+<div class="blockIndicator note">
+<p>You can also use a <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts#Connection-based_messaging">connection-based approach to exchange messages</a>.</p>
+</div>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox brush:js">browser.runtime.onMessage.addListener(listener)
+browser.runtime.onMessage.removeListener(listener)
+browser.runtime.onMessage.hasListener(listener)
+</pre>
+
+<p>Events have three functions:</p>
+
+<dl>
+ <dt><code>addListener(callback)</code></dt>
+ <dd>Adds a listener to this event.</dd>
+ <dt><code>removeListener(listener)</code></dt>
+ <dd>Stop listening to this event. The <code>listener</code> argument is the listener to remove.</dd>
+ <dt><code>hasListener(listener)</code></dt>
+ <dd>Checks whether a <code>listener</code> is registered for this event. Returns <code>true</code> if it is listening, <code>false</code> otherwise.</dd>
+</dl>
+
+<h2 id="addListener_syntax">addListener syntax</h2>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt><code>function</code></dt>
+ <dd>
+ <p>A listener function that will be called when this event occurs. The function will be passed the following arguments:</p>
+
+ <dl class="reference-values">
+ <dt><code>message</code></dt>
+ <dd><code>object</code>. The message itself. This is a JSON-ifiable object.</dd>
+ </dl>
+
+ <dl class="reference-values">
+ <dt><code>sender</code></dt>
+ <dd>A {{WebExtAPIRef('runtime.MessageSender')}} object representing the sender of the message.</dd>
+ </dl>
+
+ <dl class="reference-values">
+ <dt><code>sendResponse</code></dt>
+ <dd>
+ <p>A function to call, at most once, to send a response to the message. The function takes a single argument, which may be any JSON-ifiable object. This argument is passed back to the message sender.</p>
+
+ <p>If you have more than one <code>onMessage</code> listener in the same document, then only one may send a response.</p>
+
+ <p>To send a response synchronously, call <code>sendResponse</code> before the listener function returns. To send a response asynchronously:</p>
+
+ <ul>
+ <li>either keep a reference to the <code>sendResponse</code> argument and return <code>true</code> from the listener function. You will then be able to call <code>sendResponse</code> after the listener function has returned.</li>
+ <li>or return a <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> from the listener function and resolve the promise when the response is ready. This is a preferred way.</li>
+ </ul>
+ </dd>
+ </dl>
+
+ <p>The listener function can return either a Boolean or a <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>.</p>
+
+ <div class="blockIndicator warning">
+ <p>Do not call <code>addListener</code> using the <code>async</code> function, as in:</p>
+
+ <pre><code>browser.runtime.onMessage.addListener(async (data, sender) =&gt; {
+ if (data.type === 'handle_me') return 'done';
+});
+</code></pre>
+
+ <p>as the listener will consume every message it receives, effectively blocking all other listeners from receiving and processing messages.</p>
+
+ <p>If you want to take an asynchronous approach, use a promise instead, as in:</p>
+
+ <pre><code>browser.runtime.onMessage.addListener(data, sender) =&gt; {
+ if (data.type === 'handle_me') return Promise.resolve('done');
+});
+</code></pre>
+ </div>
+ </dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.runtime.onMessage")}}</p>
+
+<h2 id="Examples">Examples</h2>
+
+<h3 id="Simple_example">Simple example</h3>
+
+<p>This content script listens for click events on the web page. If the click was on a link, it messages the background page with the target URL:</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="comment token">// content-script.js</span>
+
+window<span class="punctuation token">.</span><span class="function token">addEventListener</span><span class="punctuation token">(</span><span class="string token">"click"</span><span class="punctuation token">,</span> notifyExtension<span class="punctuation token">)</span><span class="punctuation token">;</span>
+
+<span class="keyword token">function</span> <span class="function token">notifyExtension</span><span class="punctuation token">(</span>e<span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ <span class="keyword token">if</span> <span class="punctuation token">(</span>e<span class="punctuation token">.</span>target<span class="punctuation token">.</span>tagName <span class="operator token">!=</span> <span class="string token">"A"</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ <span class="keyword token">return</span><span class="punctuation token">;</span>
+ <span class="punctuation token">}</span>
+ browser<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span><span class="function token">sendMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span><span class="string token">"url"</span><span class="punctuation token">:</span> e<span class="punctuation token">.</span>target<span class="punctuation token">.</span>href<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;
+}</span></code>
+</pre>
+
+<p>The background script listens for these messages and displays a notification using the <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/notifications">notifications</a></code> API:</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="comment token">// background-script.js</span>
+
+browser<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span>onMessage<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>notify<span class="punctuation token">)</span><span class="punctuation token">;</span>
+
+<span class="keyword token">function</span> <span class="function token">notify</span><span class="punctuation token">(</span>message<span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ browser<span class="punctuation token">.</span>notifications<span class="punctuation token">.</span><span class="function token">create</span><span class="punctuation token">(</span><span class="punctuation token">{</span>
+ <span class="string token">"type"</span><span class="punctuation token">:</span> <span class="string token">"basic"</span><span class="punctuation token">,</span>
+ <span class="string token">"iconUrl"</span><span class="punctuation token">:</span> browser<span class="punctuation token">.</span>extension<span class="punctuation token">.</span><span class="function token">getURL</span><span class="punctuation token">(</span><span class="string token">"link.png"</span><span class="punctuation token">)</span><span class="punctuation token">,</span>
+ <span class="string token">"title"</span><span class="punctuation token">:</span> <span class="string token">"You clicked a link!"</span><span class="punctuation token">,</span>
+ <span class="string token">"message"</span><span class="punctuation token">:</span> message<span class="punctuation token">.</span>url
+ <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+<span class="punctuation token">}</span></code></pre>
+
+<h3 id="Sending_a_synchronous_response">Sending a synchronous response</h3>
+
+<p>This content script sends a message to the background script when the user clicks on the page. It also logs any response sent by the background script:</p>
+
+<pre class="brush: js">// content-script.js
+
+function handleResponse(message) {
+ console.log(`background script sent a response: ${message.response}`);
+}
+
+function handleError(error) {
+ console.log(`Error: ${error}`);
+}
+
+function sendMessage(e) {
+ var sending = browser.runtime.sendMessage({content: "message from the content script"});
+ sending.then(handleResponse, handleError);
+}
+
+window.addEventListener("click", sendMessage);</pre>
+
+<p>Here is a version of the corresponding background script, that sends a response synchronously, from inside in the listener:</p>
+
+<pre class="brush: js">// background-script.js
+
+function handleMessage(request, sender, sendResponse) {
+ console.log(`content script sent a message: ${request.content}`);
+ sendResponse({response: "response from background script"});
+}
+
+browser.runtime.onMessage.addListener(handleMessage);</pre>
+
+<p>And here is another version, that uses Promise.resolve():</p>
+
+<pre class="brush: js">// background-script.js
+
+function handleMessage(request, sender, sendResponse) {
+ console.log(`content script sent a message: ${request.content}`);
+ return Promise.resolve({response: "response from background script"});
+}
+
+browser.runtime.onMessage.addListener(handleMessage);</pre>
+
+<h3 id="Sending_an_asynchronous_response_using_sendResponse">Sending an asynchronous response using sendResponse</h3>
+
+<p>Here is an alternative version of the background script from the previous example. It sends a response asynchronously after the listener has returned. Note <code>return true;</code> in the listener: this tells the browser that you intend to use the <code>sendResponse</code> argument after the listener has returned.</p>
+
+<pre class="brush: js">// background-script.js
+
+function handleMessage(request, sender, sendResponse) {
+ console.log(`content script sent a message: ${request.content}`);
+ setTimeout(() =&gt; {
+ sendResponse({response: "async response from background script"});
+ }, 1000);
+ return true;
+}
+
+browser.runtime.onMessage.addListener(handleMessage);
+</pre>
+
+<h3 id="Sending_an_asynchronous_response_using_a_Promise">Sending an asynchronous response using a Promise</h3>
+
+<p>This content script gets the first &lt;a&gt; link on the page and sends a message asking if the link's location is bookmarked. It expects to get a Boolean response: <code>true</code> if the location is bookmarked, <code>false</code> otherwise:</p>
+
+<pre class="brush: js">// content-script.js
+
+const firstLink = document.querySelector("a");
+
+function handleResponse(isBookmarked) {
+ if (isBookmarked) {
+ firstLink.classList.add("bookmarked");
+ }
+}
+
+browser.runtime.sendMessage({
+ url: firstLink.href
+}).then(handleResponse);</pre>
+
+<p>Here is the background script. It uses <code>{{WebExtAPIRef("bookmarks.search()")}}</code> to see if the link is bookmarked, which returns a <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>:</p>
+
+<pre class="brush: js">// background-script.js
+
+function isBookmarked(message, sender, response) {
+ return browser.bookmarks.search({
+ url: message.url
+ }).then(function(results) {
+ return results.length &gt; 0;
+ });
+}
+
+browser.runtime.onMessage.addListener(isBookmarked);</pre>
+
+<p>If the asynchronous handler doesn't return a promise, you can explicitly construct a promise. This rather contrived example sends a response after a 1-second delay, using <code><a href="/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout">Window.setTimeout()</a></code>:</p>
+
+<pre class="brush: js">// background-script.js
+
+function handleMessage(request, sender, sendResponse) {
+ return new Promise(resolve =&gt; {
+ setTimeout(() =&gt; {
+ resolve({response: "async response from background script"});
+ }, 1000);
+ });
+}
+
+browser.runtime.onMessage.addListener(handleMessage);</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/runtime#event-onMessage"><code>chrome.runtime</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/openoptionspage/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/openoptionspage/index.html
new file mode 100644
index 0000000000..701af9c2ea
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/openoptionspage/index.html
@@ -0,0 +1,92 @@
+---
+title: runtime.openOptionsPage()
+slug: Mozilla/Add-ons/WebExtensions/API/runtime/openOptionsPage
+tags:
+ - API
+ - OpenPractices
+ - WebExtensions
+translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/openOptionsPage
+---
+<div> </div>
+
+<div>假如你的页面有<a href="/en-US/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Options_pages">options page</a>(设置页面)的定义,使用此方法打开它。</div>
+
+<div> </div>
+
+<div>这是一个异步方法,返回一个 <code style="font-style: normal; font-weight: normal;"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>对象</code></div>
+
+<div> </div>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox brush:js">var openingPage = browser.runtime.openOptionsPage()
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<p>无</p>
+
+<h3 id="返回值">返回值</h3>
+
+<p><code>当设置页面成功创建,执行<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>的无参成功回调方法,否则执行<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>的失败回调方法,参数为错误信息。</code></p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.runtime.openOptionsPage")}}</p>
+
+<h2 id="例子">例子</h2>
+
+<p>当用户点击浏览器行为图标时,打开一个设置页面。</p>
+
+<pre class="brush: js">function onOpened() {
+ console.log(`Options page opened`);
+}
+
+function onError(error) {
+ console.log(`Error: ${error}`);
+}
+
+var opening = browser.runtime.openOptionsPage();
+opening.then(onOpened, onError);</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/runtime#method-openOptionsPage"><code>chrome.runtime</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/platformarch/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/platformarch/index.html
new file mode 100644
index 0000000000..0adfaf39f1
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/platformarch/index.html
@@ -0,0 +1,70 @@
+---
+title: 获取处理器架构 - runtime.PlatformArch
+slug: Mozilla/Add-ons/WebExtensions/API/runtime/PlatformArch
+tags:
+ - 获取处理器架构
+ - 附加组件
+translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/PlatformArch
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>当前浏览器所在的计算机的处理器架构.</p>
+
+<h2 id="值类型">值类型</h2>
+
+<p>该值的类型是字符串. 可能的值如下:</p>
+
+<dl>
+ <dt><code>"arm"</code></dt>
+ <dd>标识平台基于 arm 架构.</dd>
+ <dt><code>"x86-32"</code></dt>
+ <dd>表示平台基于 x86 32-bit 架构.</dd>
+ <dt><code>"x86-64"</code></dt>
+ <dd>表示平台基于 x86 64-bit 架构.</dd>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.runtime.PlatformArch")}}</p>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/runtime#type-PlatformArch"><code>chrome.runtime</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/platformos/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/platformos/index.html
new file mode 100644
index 0000000000..6c32d46b6f
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/platformos/index.html
@@ -0,0 +1,76 @@
+---
+title: 获取当前操作系统 - runtime.PlatformOs
+slug: Mozilla/Add-ons/WebExtensions/API/runtime/PlatformOs
+tags:
+ - 获取当前操作系统
+ - 附加组件
+translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/PlatformOs
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>获取当前浏览器运行所在的操作系统.</p>
+
+<h2 id="值类型">值类型</h2>
+
+<p>该值的类型是字符串. 可能的值如下:</p>
+
+<dl>
+ <dt><code>"mac"</code></dt>
+ <dd>表示底层操作系统是 Mac OS X.</dd>
+ <dt><code>"win"</code></dt>
+ <dd>表示底层操作系统是 Windows.</dd>
+ <dt><code>"android"</code></dt>
+ <dd>表示底层操作系统是 Android.</dd>
+ <dt><code>"cros"</code></dt>
+ <dd>表示底层操作系统是 Chrome OS.</dd>
+ <dt><code>"linux"</code></dt>
+ <dd>表示底层操作系统是 Linux.</dd>
+ <dt><code>"openbsd"</code></dt>
+ <dd>表示底层操作系统是 Open/FreeBSD.</dd>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.runtime.PlatformOs")}}</p>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/runtime#type-PlatformOs"><code>chrome.runtime</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/sendmessage/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/sendmessage/index.html
new file mode 100644
index 0000000000..86ec753075
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/sendmessage/index.html
@@ -0,0 +1,157 @@
+---
+title: runtime.sendMessage()
+slug: Mozilla/Add-ons/WebExtensions/API/runtime/sendMessage
+translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/sendMessage
+---
+<div>{{AddonSidebar()}}</div>
+
+<div>向你的扩展或其他扩展发送单条消息。</div>
+
+<div> </div>
+
+<div>如果想发给你自己的扩展,则省略 <code>extensionId</code> 参数。扩展中所有页面的{{WebExtAPIRef('runtime.onMessage')}}将会被触发,除了调用<code>runtime.sendMessage的页面。</code></div>
+
+<p> </p>
+
+<p>如果发送给其他扩展,则将参数 <code>extensionId</code> 设置为其他扩展的ID。其他扩展的 {{WebExtAPIRef('runtime.onMessageExternal')}} 将会被触发。</p>
+
+<p>此接口不能给 content script 发消息,如果要给 content script 发消息,请使用 {{WebExtAPIRef('tabs.sendMessage')}}。</p>
+
+<p>这是个异步方法,将返回一个 <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>。</p>
+
+<p>Syntax</p>
+
+<pre class="syntaxbox brush:js">var sending = browser.runtime.sendMessage(
+ extensionId, // optional string
+ message, // any
+ options // optional object
+)
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>extensionId</code>{{optional_inline}}</dt>
+ <dd><code>string</code>. 若你想要发给不同的扩展,这里传入接收方的扩展ID。The ID of the extension to send the message to. Include this to send the message to a different extension. If the intended recipient has set an ID explicitly using the <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/applications">applications</a> key in manifest.json, then <code>extensionId</code> should have this value. Otherwise it should be have the ID that was generated for the intended recipient.</dd>
+ <dd>若此省略此参数,则发送给自己的扩展。</dd>
+ <dt><code>message</code></dt>
+ <dd><code>any</code>. 任何可以序列化成JSON的东西。</dd>
+ <dt><code>options</code>{{optional_inline}}</dt>
+ <dd><code>object</code>.
+ <dl class="reference-values">
+ <dt><code>includeTlsChannelId</code>{{optional_inline}}</dt>
+ <dd><code>boolean</code>. Whether the TLS channel ID will be passed into {{WebExtAPIRef('runtime.onMessageExternal')}} for processes that are listening for the connection event.</dd>
+ <dt><code>toProxyScript{{optional_inline}}</code></dt>
+ <dd><code>boolean</code>. Must be True if the message is intended for a PAC file loaded using the {{WebExtAPIRef("proxy")}} API.</dd>
+ </dl>
+ </dd>
+</dl>
+
+<p>根据给出的参数不同,API遵循如下规则:</p>
+
+<ul>
+ <li><strong>只有1个参数:</strong>将会被当做 message 发送给自己的扩展。</li>
+ <li><strong>有2个参数:</strong>
+ <ul>
+ <li>若第二个参数符合下面的规则,将会被当做 <code>(message, options)</code>,将消息发送给自己的扩展:
+ <ol>
+ <li>一个合法的配置对象(也就是说这个对象只包含options参数支持的属性)</li>
+ <li>null</li>
+ <li>undefined</li>
+ </ol>
+ </li>
+ <li>否则,将会被当做 <code>(extensionId, message)。</code>消息将会给发送给 <code>extensionId</code> 指定ID的扩展</li>
+ </ul>
+ </li>
+ <li><strong>有3个参数:</strong>将会被当做 <code>(extensionId, message, options)</code>. 消息将会给发送给 <code>extensionId</code> 指定ID的扩展</li>
+</ul>
+
+<div class="note">
+<p>在Firefox 55之前,只给出2个参数时,规则会有所不同:<br>
+ Under the old rules, if the first argument was a string, it was treated as the <code>extensionId</code>, with the message as the second argument. This meant that if you called <code>sendMessage()</code> with arguments like <code>("my-message", {})</code>, then it would send an empty message to the extension identified by "my-message". Under the new rules, with these arguments you would send the message "my-message" internally, with an empty options object.</p>
+</div>
+
+<h3 id="Return_value">Return value</h3>
+
+<p>返回一个 <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>。若接收方响应,Promise将会变为 fulfilled 并且返回接收方响应的JSON对象(数字、字符串、数组、true/false都是合法的JSON对象)。否则,Promise会变为 fulfilled 但是不返回任何参数。如果发生了连接错误,Promise将会变为 rejected 并返回一个错误消息。</p>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.runtime.sendMessage")}}</p>
+
+<h2 id="Examples">Examples</h2>
+
+<p>Here's a content script that sends a message to the background script when the user clicks the content window. The message payload is <code>{greeting: "Greeting from the content script"}</code>, and the sender also expects to get a response, which is handled in the <code>handleResponse</code> function:</p>
+
+<pre class="brush: js">// content-script.js
+
+function handleResponse(message) {
+ console.log(`Message from the background script: ${message.response}`);
+}
+
+function handleError(error) {
+ console.log(`Error: ${error}`);
+}
+
+function notifyBackgroundPage(e) {
+ var sending = browser.runtime.sendMessage({
+ greeting: "Greeting from the content script"
+ });
+ sending.then(handleResponse, handleError);
+}
+
+window.addEventListener("click", notifyBackgroundPage);</pre>
+
+<p>The corresponding background script looks like this:</p>
+
+<pre class="brush: js">// background-script.js
+
+function handleMessage(request, sender, sendResponse) {
+ console.log("Message from the content script: " +
+ request.greeting);
+ sendResponse({response: "Response from background script"});
+}
+
+browser.runtime.onMessage.addListener(handleMessage);</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/runtime#method-sendMessage"><code>chrome.runtime</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/sendnativemessage/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/sendnativemessage/index.html
new file mode 100644
index 0000000000..349b7a06d0
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/runtime/sendnativemessage/index.html
@@ -0,0 +1,109 @@
+---
+title: runtime.sendNativeMessage()
+slug: Mozilla/Add-ons/WebExtensions/API/runtime/sendNativeMessage
+tags:
+ - sendNativeMessage
+ - 扩展
+ - 附加组件
+ - 非标准
+translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/sendNativeMessage
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>从 WebExtension 发送单条消息到 native application。</p>
+
+<p>它需要两个强制的参数:native application 的名字和要发送给它的JSON对象。浏览器将会加载 native application 然后发送这个消息。</p>
+
+<p>这是一个异步函数,返回一个 <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>对象。native application 发送的第一条消息将被当作<code>sendNativeMessage()</code> 的回复,并且 promise 将这个消息作为参数.。注意你不能使用 {{WebExtAPIRef("runtime.onMessage")}} 从应用获取回复:你必须使用回调函数来替代。</p>
+
+<p>每次调用 <code>runtime.sendNativeMessage()</code>都会生成一个新的实例。浏览器将会在收到回复后结束这个 native application。为了结束这个 native application,浏览器将会关闭 pipe,并给进程几秒的时间优雅的退出,如果它没有关闭就杀死它。</p>
+
+<p>更对信息,参考 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging">Native messaging</a>。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox brush:js">var sending = browser.runtime.sendNativeMessage(
+ application, // string
+ message // object
+)
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>application</code></dt>
+ <dd><code>字符串类型。</code>native application的名字。它必须和 <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Native_messaging#App_manifest">native application's manifest file</a>中的‘name’字段一致。</dd>
+ <dt><code>message</code></dt>
+ <dd><code>对象类型。一个将要发送给</code> native application的JSON对象。</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>一个 <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>对象。如果native application发送了一个回复,它将会填充回复的JSON对象作为参数。否则它不会填充参数。如果在native application连接期间发生了错误,promise将会被一个错误的消息拒绝。</p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">这个页面的兼容性表从结构性数据生成的。如果你想提供数据,请访问 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 然后提交请求。</p>
+
+<p>{{Compat("webextensions.api.runtime.sendNativeMessage")}}</p>
+
+<h2 id="示例">示例</h2>
+
+<p>这是一个 background script ,当使用者点击浏览器的browser action时,它会发送 "ping" 消息到 "ping_pong" 应用并且把回复记录下来:</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">onResponse</span><span class="punctuation token">(</span>response<span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">`Received ${</span>response}<span class="punctuation token">`)</span><span class="punctuation token">;</span>
+<span class="punctuation token">}
+
+</span></code>function onError(error) {
+  console.log(`Error: ${error}`);
+}<code class="language-js">
+
+<span class="comment token">/*
+On a click on the browser action, send the app a message.
+*/</span>
+browser<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="operator token">=</span><span class="operator token">&gt;</span> <span class="punctuation token">{</span>
+ console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Sending: ping"</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+ var sending = browser<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span><span class="function token">sendNativeMessage</span><span class="punctuation token">(</span><span class="string token">"ping_pong"</span><span class="punctuation token">,</span> <span class="string token">"ping"</span><span class="punctuation token">)</span><span class="punctuation token">;
+ sending.then(onResponse, onError);</span>
+<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>这个API 基于 Chromium 的 <a href="https://developer.chrome.com/extensions/runtime#method-sendNativeMessage"><code>chrome.runtime</code></a> API。 本文来自 Chromium 代码中的 <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> 。</p>
+
+<p>微软 Edge 的兼容性数据由 Microsoft Corporation 提供,并且包含在这里基于 Creative Commons Attribution 3.0 United States License。</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/search/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/search/index.html
new file mode 100644
index 0000000000..4a8c5e320b
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/search/index.html
@@ -0,0 +1,34 @@
+---
+title: search
+slug: Mozilla/Add-ons/WebExtensions/API/search
+tags:
+ - API
+ - Add-ons
+ - Extensions
+ - NeedsTranslation
+ - Reference
+ - Search
+ - Search Engines
+ - TopicStub
+ - WebExtensions
+translation_of: Mozilla/Add-ons/WebExtensions/API/search
+---
+<div>{{AddonSidebar}}</div>
+
+<p>Retrieves search engines and executes a search with a specific search engine.</p>
+
+<p>To use this API you need to have the <code>"search"</code> <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a>.</p>
+
+<h2 id="Functions">Functions</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("search.get()")}}</dt>
+ <dd>Retrieve all search engines.</dd>
+ <dt>{{WebExtAPIRef("search.search()")}}</dt>
+ <dd>Search using the specified search engine.</dd>
+ <dt>
+ <h2 id="Browser_compatibility">Browser compatibility</h2>
+ </dt>
+</dl>
+
+<p>{{Compat("webextensions.api.search", 1, 1)}} {{WebExtExamples("h2")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/search/search/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/search/search/index.html
new file mode 100644
index 0000000000..bb3a122a64
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/search/search/index.html
@@ -0,0 +1,93 @@
+---
+title: search.search()
+slug: Mozilla/Add-ons/WebExtensions/API/search/search
+translation_of: Mozilla/Add-ons/WebExtensions/API/search/search
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>使用指定的搜索引擎或默认搜索引擎进行搜索。</p>
+
+<p>结果将显示在一个新的选项卡中,或者如果给出了tabId参数,则显示在由此标识的选项卡中。</p>
+
+<p>要在扩展程序中使用此功能,您必须要求<code>"search"</code> <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">有明确许可</a>.</p>
+
+<p>获取安装的搜索引擎, 请使用 {{WebExtAPIRef("search.get()")}}.</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox brush:js notranslate">browser.search.search(
+ searchProperties // object
+)
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl class="reference-values">
+ <dt><code>searchProperties</code></dt>
+ <dd>
+ <p><code>object</code>. 拥有以下属性的对象:</p>
+
+ <dl class="reference-values">
+ <dt><code>query</code></dt>
+ <dd><code>字符串</code>. 进行查询的内容。</dd>
+ <dt><code>engine</code>{{optional_inline}}</dt>
+ <dd>
+ <p><code>字符串。</code>.搜索引擎的名称。 如果指定的搜索引擎名称不存在,该函数将引发错误。 如果省略此属性,则使用默认的搜索引擎。</p>
+ </dd>
+ <dt><code>tabId</code>{{optional_inline}}</dt>
+ <dd>
+ <p><font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.5);">整型。</span></font>用于显示搜索结果的选项卡。如果省略此属性,搜索结果将显示在新选项卡中。</p>
+ </dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>无.</p>
+
+<h2 id="浏览器兼容">浏览器兼容</h2>
+
+<p class="hidden">此页面中的兼容性表是根据结构化数据生成的。 如果您想贡献数据,请查看<a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> ,并向我们发送请求请求。</p>
+
+<p>{{Compat("webextensions.api.search.search", 10)}}</p>
+
+<h2 id="例子">例子</h2>
+
+<p>使用默认搜索引擎进行搜索。 结果显示在新选项卡中:</p>
+
+<pre class="brush: js no-line-numbers notranslate">function search() {
+ browser.search.search({
+ query: "styracosaurus"
+ });
+}
+
+browser.browserAction.onClicked.addListener(search);
+</pre>
+
+<p>使用维基百科进行搜索。 结果显示在新选项卡中:</p>
+
+<pre class="brush: js no-line-numbers notranslate">function search() {
+ browser.search.search({
+ query: "styracosaurus",
+ engine: "Wikipedia (en)"
+ });
+}
+
+browser.browserAction.onClicked.addListener(search);
+</pre>
+
+<p>使用维基百科进行搜索。 结果将显示在活动选项卡中:</p>
+
+<pre class="brush: js no-line-numbers notranslate">function search(tab) {
+ browser.search.search({
+ query: "styracosaurus",
+ engine: "Wikipedia (en)",
+ tabId: tab.id
+ });
+}
+
+browser.browserAction.onClicked.addListener(search);
+</pre>
+
+<p>{{WebExtExamples}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/sessions/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/sessions/index.html
new file mode 100644
index 0000000000..65afc6692b
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/sessions/index.html
@@ -0,0 +1,136 @@
+---
+title: sessions
+slug: Mozilla/Add-ons/WebExtensions/API/sessions
+tags:
+ - API
+ - Add-ons
+ - Extensions
+ - NeedsTranslation
+ - Non-standard
+ - Reference
+ - TopicStub
+ - WebExtensions
+ - sessions
+translation_of: Mozilla/Add-ons/WebExtensions/API/sessions
+---
+<div>{{AddonSidebar}}</div>
+
+<p>Use the sessions API to list, and restore, tabs and windows that have been closed while the browser has been running.</p>
+
+<p>The {{WebExtAPIRef("sessions.getRecentlyClosed()")}} function returns an array of {{WebExtAPIRef("tabs.Tab")}} and {{WebExtAPIRef("windows.Window")}} objects, representing tabs and windows that have been closed since the browser was running, up to the maximum defined in {{WebExtAPIRef("sessions.MAX_SESSION_RESULTS")}}.</p>
+
+<p>You can then restore a window or tab using the {{WebExtAPIRef("sessions.restore()")}} function. Restoring doesn't just reopen the tab: it also restores the tab's navigation history so the back/forward buttons will work.</p>
+
+<p>This API also provides a group of functions that enable an extension to store additional state associated with a tab or a window. Then, if the tab or window is closed and subsequently restored, the extension can retrieve the state. For example, a tab grouping extension might use this to remember which group a tab is in, so as to restore it into the right group if the user restores the tab.</p>
+
+<p>To use the sessions API you must have the "sessions" <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/permissions#API_permissions">API permission</a>.</p>
+
+<h2 id="Types">Types</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("sessions.Filter")}}</dt>
+ <dd>Enables you to restrict the number of {{WebExtAPIRef("sessions.Session", "Session")}} objects returned by a call to {{WebExtAPIRef("sessions.getRecentlyClosed()")}}.</dd>
+ <dt>{{WebExtAPIRef("sessions.Session")}}</dt>
+ <dd>
+ <p>Represents a tab or window that the user has closed in the current browsing session.</p>
+ </dd>
+</dl>
+
+<h2 id="Properties">Properties</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("sessions.MAX_SESSION_RESULTS")}}</dt>
+ <dd>The maximum number of sessions that will be returned by a call to <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/sessions/getRecentlyClosed" title="Returns an array Session objects, representing windows and tabs that were closed in the current browsing session (that is: the time since the browser was started)."><code>sessions.getRecentlyClosed()</code></a>.</dd>
+</dl>
+
+<h2 id="Functions">Functions</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("sessions.forgetClosedTab()")}}</dt>
+ <dd>Removes a closed tab from the browser's list of recently closed tabs.</dd>
+ <dt>{{WebExtAPIRef("sessions.forgetClosedWindow()")}}</dt>
+ <dd>Removes a closed window from the browser's list of recently closed windows.</dd>
+ <dt>{{WebExtAPIRef("sessions.getRecentlyClosed()")}}</dt>
+ <dd>Returns an array of {{WebExtAPIRef("sessions.Session", "Session")}} objects, representing windows and tabs that were closed in the current browsing session (that is: the time since the browser was started).</dd>
+ <dt>{{WebExtAPIRef("sessions.restore()")}}</dt>
+ <dd>
+ <p>Restores a closed tab or window.</p>
+ </dd>
+ <dt>{{WebExtAPIRef("sessions.setTabValue()")}}</dt>
+ <dd>
+ <p>Store a key/value pair associated with a given tab.</p>
+ </dd>
+ <dt>{{WebExtAPIRef("sessions.getTabValue()")}}</dt>
+ <dd>
+ <p>Retrieve a previously stored value for a given tab, given its key.</p>
+ </dd>
+ <dt>{{WebExtAPIRef("sessions.removeTabValue()")}}</dt>
+ <dd>
+ <p>Remove a key/value pair from a given tab.</p>
+ </dd>
+ <dt>{{WebExtAPIRef("sessions.setWindowValue()")}}</dt>
+ <dd>
+ <p>Store a key/value pair associated with a given window.</p>
+ </dd>
+ <dt>{{WebExtAPIRef("sessions.getWindowValue()")}}</dt>
+ <dd>
+ <p>Retrieve a previously stored value for a given window, given its key.</p>
+ </dd>
+ <dt>{{WebExtAPIRef("sessions.removeWindowValue()")}}</dt>
+ <dd>
+ <p>Remove a key/value pair from a given window.</p>
+ </dd>
+</dl>
+
+<h2 id="Events">Events</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("sessions.onChanged")}}</dt>
+ <dd>
+ <p>Fired when a tab or window is closed.</p>
+ </dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{Compat("webextensions.api.sessions")}}</p>
+
+<p>{{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/sessions"><code>chrome.sessions</code></a> API.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre class="notranslate">// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/sessions/session/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/sessions/session/index.html
new file mode 100644
index 0000000000..8b0c86204d
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/sessions/session/index.html
@@ -0,0 +1,78 @@
+---
+title: sessions.Session
+slug: Mozilla/Add-ons/WebExtensions/API/sessions/Session
+translation_of: Mozilla/Add-ons/WebExtensions/API/sessions/Session
+---
+<div><font><font>{{AddonSidebar()}}</font></font></div>
+
+<p><font><font>该</font></font><code>Session</code><font><font>对象表示用户在当前浏览会话中已关闭的选项卡或窗口。</font></font></p>
+
+<p><font><font>如果关闭了选项卡但未关闭其窗口,则会话以{{WebExtAPIRef("tabs.Tab", "Tab")}}对象表示:例如,因为用户单击了“关闭选项卡”按钮,并且此选项卡不是其窗口中的唯一选项卡。</font></font></p>
+
+<p><font><font>如果关闭窗口,则会话表示为{{WebExtAPIRef("windows.Window", "Window")}}对象:例如,由于用户单击“关闭窗口”按钮,或关闭了窗口中唯一打开的选项卡。</font></font></p>
+
+<p><font><font>请注意,不同的浏览器可能对会话何时为Tab和何时为Window有不同的想法。</font><font>例如:</font></font></p>
+
+<ul>
+ <li><font><font>在Chrome中,如果用户关闭包含多个标签的窗口,则会话将记录为“窗口”。</font><font>如果用户关闭了仅包含一个选项卡的窗口,则该窗口将记录为一个选项卡。</font></font></li>
+ <li><font><font>在Firefox中,如果用户关闭窗口(或该窗口中最后一个选项卡的选项卡),则将会话记录为窗口,如果用户关闭窗口中最后一个选项卡中的选项卡,则将会话记录为一个Tab。</font></font></li>
+</ul>
+
+<p><font><font>打开的选项卡的Tab对象没有</font></font><code>sessionId</code><font><font>。</font><font>关闭选项卡时,它将具有一个</font></font><code>sessionId</code><font><font>但没有选项卡</font></font><code>id</code><font><font>。</font><font>如果恢复了该标签页,它将获得一个新的标签页,</font></font><code>id</code><font><font>并且会丢失</font></font><code>sessionId</code><font><font>。</font></font></p>
+
+<h2 id="类型"><font><font>类型</font></font></h2>
+
+<p><font><font>此类型的值是对象。</font><font>它们包含以下属性:</font></font></p>
+
+<dl class="reference-values">
+ <dt><code>lastModified</code></dt>
+ <dd><code>number</code><font><font>。</font><font>选项卡或窗口关闭的时间,</font></font><a href="https://en.wikipedia.org/wiki/Unix_time"><font><font>自epoch以来的毫秒数</font></font></a><font><font>。</font></font></dd>
+ <dt><code>tab</code><font><font>{{optional_inline}}</font></font></dt>
+ <dd><code>object</code><font><font>。</font><font>如果对象表示关闭的选项卡,则此属性存在,并且将是{{WebExtAPIRef("tabs.Tab")}}对象。</font><font>仅当扩展名具有“ tabs” </font><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions"><font>许可</font></a><font>权时</font></font><code>url</code><font><font>,</font><font>它才会包含</font></font><code>title</code><font><font>和</font><font>。</font></font><code>favIconUrl</code></dd>
+ <dt><code>window</code><font><font>{{optional_inline}}</font></font></dt>
+ <dd><code>object</code><font><font>。</font><font>如果对象表示一个关闭的窗口,则此属性存在并且将是{{WebExtAPIRef("windows.Window")}}对象。</font></font></dd>
+</dl>
+
+<h2 id="浏览器兼容性"><font><font>浏览器兼容性</font></font></h2>
+
+<p class="hidden"><font><font>此页面中的兼容性表是根据结构化数据生成的。</font><font>如果您想提供数据,请查看</font></font><a href="https://github.com/mdn/browser-compat-data"><font><font>https://github.com/mdn/browser-compat-data</font></font></a><font><font>并向我们​​发送请求请求。</font></font></p>
+
+<p><font><font>{{Compat("webextensions.api.sessions.Session")}}</font></font></p>
+
+<div class="note"><strong><font><font>致谢</font></font></strong>
+
+<p><font><font>该API基于Chromium的</font></font><a href="https://developer.chrome.com/extensions/sessions"><code>chrome.sessions</code></a><font><font>API。</font></font></p>
+
+<p><font><font>Microsoft Edge兼容性数据由Microsoft Corporation提供,并在此处包含在Creative Commons Attribution 3.0美国许可证下。</font></font></p>
+</div>
+
+<div class="hidden">
+<pre class="notranslate"><font><font>//版权所有2015 The Chromium Authors。</font><font>版权所有。</font></font><font><font>
+//</font></font><font><font>
+//以或不以源代码和二进制格式重新分发和使用</font></font><font><font>
+//修改,只要满足以下条件</font></font><font><font>
+//遇到:</font></font><font><font>
+//</font></font><font><font>
+// *重新分发源代码必须保留上述版权</font></font><font><font>
+//注意,此条件列表和以下免责声明。</font></font><font><font>
+// *二进制形式的重新分发必须重现上述内容</font></font><font><font>
+//版权声明,此条件列表和以下免责声明</font></font><font><font>
+//在随附的文档和/或其他材料中</font></font><font><font>
+//分配。</font></font><font><font>
+// *无论是Google Inc.的名称还是Google Inc.的名称</font></font><font><font>
+//贡献者可用于认可或宣传由</font></font><font><font>
+//此软件未经事先特别书面许可。</font></font><font><font>
+//</font></font><font><font>
+//此软件由版权所有者和贡献者提供</font></font><font><font>
+//“按原样”以及任何明示或暗示的保证,包括但不限于</font></font><font><font>
+//仅限于对产品的适销性和适用性的默示担保</font></font><font><font>
+//不提供特殊用途。</font><font>在任何情况下,版权</font></font><font><font>
+//所有者或贡献者对任何直接,间接,偶然的,</font></font><font><font>
+//特殊,示范性或后果性损害(包括但不包括)</font></font><font><font>
+//仅限于,购买替代商品或服务;</font><font>使用损失,</font></font><font><font>
+//数据或利润;</font><font>或业务中断)</font></font><font><font>
+//责任理论,无论是合同形式,严格责任还是侵权行为</font></font><font><font>
+//(包括疏忽大意或其他原因)出于使用目的的任何方式</font></font><font><font>
+//即使已告知可能发生此类损坏,也可以使用本软件。</font></font>
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/storage/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/storage/index.html
new file mode 100644
index 0000000000..2dc4dd3131
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/storage/index.html
@@ -0,0 +1,103 @@
+---
+title: storage
+slug: Mozilla/Add-ons/WebExtensions/API/storage
+tags:
+ - Add-ons
+ - Extensions
+ - Strorage
+translation_of: Mozilla/Add-ons/WebExtensions/API/storage
+---
+<div>{{AddonSidebar}}</div>
+
+<div>使浏览器扩展能够储存及获取数据,以及监听储存的数据的变化。</div>
+
+<div></div>
+
+<p>此存储系统API基于 <a href="/en-US/docs/Web/API/Web_Storage_API">Web Storage API</a>, 并有少许不同。</p>
+
+<p>为了使用该API,您需要在<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a>文件包含"storage"<a href="https://developer.mozilla.org/zh-CN/Add-ons/WebExtensions/manifest.json/permissions">权限</a>。每一个浏览器扩展有自己的储存<font face="Consolas, Liberation Mono, Courier, monospace">区域</font>,每一个储存<font face="Consolas, Liberation Mono, Courier, monospace">区域</font>又分为几种不同的存储类型。</p>
+
+<p>虽然此API类似于{{domxref("Window.localStorage")}},但仍建议您不要在插件中使用<code>Window.localStorage。当用户由于隐私原因清除历史浏览记录及数据时,火狐会将在浏览器扩展使用</code> localStorage API存储的数据一并清除。而使用 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/local">storage.local</a>API存储的数据将会恰当保留。</code></p>
+
+<h2 id="类型">类型</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("storage.StorageArea")}}</dt>
+ <dd>代表存储<font face="Consolas, Liberation Mono, Courier, monospace">区域</font>的对象</dd>
+ <dt>{{WebExtAPIRef("storage.StorageChange")}}</dt>
+ <dd>代表改变一个储存<font face="Consolas, Liberation Mono, Courier, monospace">区域</font>的对象</dd>
+</dl>
+
+<h2 id="属性">属性</h2>
+
+<p><font face="Consolas, Liberation Mono, Courier, monospace">storage有3个属性,每一个代表不同的存储区域。</font></p>
+
+<dl>
+ <dt>{{WebExtAPIRef("storage.sync")}}</dt>
+ <dd>表示一个同步的储存区域。在此区域的数据通过浏览器进行同步,用户可通过登录使用不同的设备访问到浏览器所有可用的实例对象。</dd>
+ <dt>{{WebExtAPIRef("storage.local")}}</dt>
+ <dd>表示一个本地的存储区域。此区域的数据属于其所在的插件。</dd>
+ <dt>{{WebExtAPIRef("storage.managed")}}</dt>
+ <dd>表示管理的存储区域。此区域的数据由本域名下的管理员设置且对该插件是只读的。试图修改此区域数据会得到一个错误。</dd>
+</dl>
+
+<h2 id="事件">事件</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("storage.onChanged")}}</dt>
+ <dd>当storage有数据变化时,此事件将被触发。</dd>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("webextensions.api.storage")}}</p>
+
+<div class="hidden note">
+<p>"Chrome不兼容"这部分来源于 <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities"> https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a> 使用<a href="/en-US/docs/Template:WebExtChromeCompat">WebExtChromeCompat</a> macro.</p>
+
+<p>如果需要更新这部分,请编辑 <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities">https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a>, 然后刷新页面即可看见所做更改。</p>
+</div>
+
+<h3 id="在Edge中的不兼容">在Edge中的不兼容</h3>
+
+<p>Promises在Edge中不被支持,使用callbacks代替。</p>
+
+<p>{{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>这个API基于Chromium的 <a href="https://developer.chrome.com/extensions/storage"><code>chrome.storage</code></a> API. 这篇文档也来源于Chromium 代码中的 <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/storage.json"><code>storage.json</code></a>.</p>
+
+<p>Microsoft Edge的适配数据由Microsoft Corporation提供并且被包含在Creative Commons Attribution 3.0 United States License许可证下.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/create/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/create/index.html
new file mode 100644
index 0000000000..82921cc3ea
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/create/index.html
@@ -0,0 +1,137 @@
+---
+title: tabs.create()
+slug: Mozilla/Add-ons/WebExtensions/API/tabs/create
+tags:
+ - API
+ - 扩展
+ - 方法
+ - 标签页
+ - 页面扩展
+translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/create
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>新建一个 tab.</p>
+
+<p>这是一个异步函数,返回 <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>.</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox brush:js">var creating = browser.tabs.create(
+ createProperties // object
+)
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>createProperties</code></dt>
+ <dd><code>object</code>. Properties to give the new tab. To learn more about these properties, see the {{WebExtAPIRef("tabs.Tab")}} documentation.</dd>
+ <dd>
+ <dl class="reference-values">
+ <dt><code>active</code>{{optional_inline}}</dt>
+ <dd><code>boolean</code>. Whether the tab should become the active tab in the window. Does not affect whether the window is focused (see {{WebExtAPIRef('windows.update')}}). Defaults to <code>true</code>.</dd>
+ <dt><code>cookieStoreId</code> {{optional_inline}}</dt>
+ <dd><code>string</code>. Use this to create a tab whose cookie store ID is <code>cookieStoreId</code>. This option is only available if the extension has the <code>"cookies"</code> <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a>.</dd>
+ <dt><code>index</code>{{optional_inline}}</dt>
+ <dd><code>integer</code>. The position the tab should take in the window. The provided value will be clamped to between zero and the number of tabs in the window.</dd>
+ <dt><code>openerTabId</code>{{optional_inline}}</dt>
+ <dd><code>integer</code>. The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as the newly created tab.</dd>
+ <dt><code>openInReaderMode</code>{{optional_inline}}</dt>
+ <dd><code>boolean</code>. If <code>true</code>, open this tab in <a href="/en-US/Add-ons/WebExtensions/API/tabs/toggleReaderMode">Reader Mode</a>. Defaults to <code>false</code>.</dd>
+ <dt><code>pinned</code>{{optional_inline}}</dt>
+ <dd><code>boolean</code>. Whether the tab should be pinned. Defaults to <code>false</code>.</dd>
+ <dt><code>selected</code>{{optional_inline}}</dt>
+ <dd><code>boolean</code>. Whether the tab should become the selected tab in the window. Defaults to <code>true</code>.
+ <div class="warning">This property is deprecated, and is not supported in Firefox. Use <code>active</code> instead.</div>
+ </dd>
+ <dt><code>url</code>{{optional_inline}}</dt>
+ <dd><code>string</code>. The URL to navigate the tab to initially. Defaults to the New Tab Page.</dd>
+ <dd>Fully-qualified URLs must include a scheme (i.e. 'http://www.google.com', not 'www.google.com').</dd>
+ <dd>For security reasons, in Firefox, this may not be a privileged URL. So passing any of the following URLs will fail:</dd>
+ <dd>
+ <ul>
+ <li>chrome: URLs</li>
+ <li>javascript: URLs</li>
+ <li>data: URLs</li>
+ <li>file: URLs (i.e., files on the filesystem. However, to use a file packaged inside the extension, see below)</li>
+ <li>privileged about: URLs (for example, <code>about:config</code>, <code>about:addons</code>, <code>about:debugging</code>)<span style="display: none;"> </span>. Non-privileged URLs (e.g., <code>about:blank</code>) are allowed.</li>
+ <li>The New Tab page (<code>about:newtab</code>) can be opened if no value for URL is provided.</li>
+ </ul>
+
+ <p>To load a page that's packaged with your extension, specify an absolute URL starting at the extension's manifest.json file. For example: '/path/to/my-page.html'. If you omit the leading '/', the URL is treated as a relative URL, and different browsers may construct different absolute URLs.</p>
+ </dd>
+ <dt><code>windowId</code>{{optional_inline}}</dt>
+ <dd><code>integer</code>. The window to create the new tab in. Defaults to the current window.</dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>A <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> that will be fulfilled with a {{WebExtAPIRef('tabs.Tab')}} object containing details about the created tab. If the tab could not be created (for example, because <code>url</code> used a privileged scheme) the promise will be rejected with an error message.</p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.tabs.create", 10)}}</p>
+
+<h2 id="实例">实例</h2>
+
+<p>在新标签页打开 "https://example.org" :</p>
+
+<pre class="brush: js">function onCreated(tab) {
+ console.log(`Created new tab: ${tab.id}`)
+}
+
+function onError(error) {
+ console.log(`Error: ${error}`);
+}
+
+browser.browserAction.onClicked.addListener(function() {
+ var creating = browser.tabs.create({
+ url:"https://example.org"
+ });
+ creating.then(onCreated, onError);
+});</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/tabs#method-create"><code>chrome.tabs</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/discard/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/discard/index.html
new file mode 100644
index 0000000000..d988e6682d
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/discard/index.html
@@ -0,0 +1,108 @@
+---
+title: tabs.discard()
+slug: Mozilla/Add-ons/WebExtensions/API/tabs/discard
+translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/discard
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>丢弃一个或多个标签页。</p>
+
+<p>一些浏览器会自动“丢弃”它们认为近期不再被用户所需要的标签页。这些标签页会在标签栏中保持可见,浏览器会记住它们的状态,所以,如果用户选中了被丢弃的标签页,它会立即还原到被丢弃之前的状态。</p>
+
+<p>对于不同的浏览器,被丢弃内容的详细内容是有所不同的,但是从大体上来说,丢弃一个标签页允许浏览器释放一些该标签页所占用的内存。</p>
+
+<p>The {{WebExtAPIRef("tabs.discard()")}} API enables an extension to discard one or more tabs. It's not possible to discard the currently active tab, or a tab whose document contains a <code><a href="/en-US/docs/Web/Events/beforeunload">beforeunload</a></code> listener that would display a prompt.</p>
+
+<p>This is an asynchronous function that returns a <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>.</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox brush:js">var discarding = browser.tabs.discard(
+ tabIds // integer or integer array
+)
+</pre>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt><code>tabIds</code></dt>
+ <dd><code><code>integer</code></code> or <code><code>array</code></code> of <code><code><code>integer</code></code></code>. The IDs of the tab or tabs to discard.</dd>
+</dl>
+
+<h3 id="Return_value">Return value</h3>
+
+<p>A <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> that will be fulfilled with no arguments when all the specified tabs have been discarded. If any error occurs (for example, invalid tab IDs), the promise will be rejected with an error message.</p>
+
+<p>If the ID of the active tab is passed in, it will not be discarded, but the promise will be fulfilled and any other tabs passed in will be discarded.</p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.tabs.discard", 10)}}</p>
+
+<h2 id="示例">示例</h2>
+
+<p>丢弃一个标签页:</p>
+
+<pre class="brush: js">function onDiscarded() {
+ console.log(`Discarded`);
+}
+
+function onError(error) {
+ console.log(`Error: ${error}`);
+}
+
+var discarding = browser.tabs.discard(2);
+discarding.then(onDiscarded, onError);</pre>
+
+<p>丢弃多个标签页:</p>
+
+<pre class="brush: js">function onDiscarded() {
+ console.log(`Discarded`);
+}
+
+function onError(error) {
+ console.log(`Error: ${error}`);
+}
+
+var discarding = browser.tabs.discard([15, 14, 1]);
+discarding.then(onDiscarded, onError);</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/tabs#method-discard"><code>chrome.tabs</code></a> API.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/executescript/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/executescript/index.html
new file mode 100644
index 0000000000..f32dd6cfc6
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/executescript/index.html
@@ -0,0 +1,173 @@
+---
+title: tabs.executeScript()
+slug: Mozilla/Add-ons/WebExtensions/API/tabs/executeScript
+tags:
+ - Chrome Extensions
+ - Extensions
+ - Plugins
+ - WebExtensions
+ - executeScript
+ - tabs.executeScript()
+translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/executeScript
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>将 JavaScript 代码注入页面。</p>
+
+<p>You can inject code into pages whose URL can be expressed using a <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns">match pattern</a>: meaning, its scheme must be one of "http", "https", "file", "ftp". To do this you must have the permission for the page's URL, either explicitly as a <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/permissions#Host_permissions">host permission</a>, or via the <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#activeTab_permission">activeTab permission</a>.</p>
+
+<p>You can also inject code into pages packaged with your own extension:</p>
+
+<pre class="brush: js">browser.tabs.create({url: "/my-page.html"}).then(() =&gt; {
+ browser.tabs.executeScript({
+ code: `console.log('location:', window.location.href);`
+ });
+});</pre>
+
+<p>You don't need any special permissions to do this.</p>
+
+<p>You <em>can't</em> inject code into any of the browser's built-in pages, such as about:debugging, about:addons, or the page that opens when you open a new empty tab.</p>
+
+<p>The scripts you inject are called content scripts. <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">Learn more about content scripts</a>.</p>
+
+<p>This is an asynchronous function that returns a <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>.</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox brush:js">var executing = browser.tabs.executeScript(
+ tabId, // optional integer
+ details // object
+)
+</pre>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt><code>tabId</code> {{optional_inline}}</dt>
+ <dd><code>integer</code>. The ID of the tab in which to run the script. Defaults to the active tab of the current window.</dd>
+ <dt><code>details</code></dt>
+ <dd>An object describing the script to run. It contains the following properties:</dd>
+ <dd>
+ <dl class="reference-values">
+ <dt><code>allFrames</code> {{optional_inline}}</dt>
+ <dd><code>boolean</code>. If <code>true</code>, the code will be injected into all frames of the current page. If <code>true</code> and <code>frameId</code> is set, then it will raise an error,  frameId and allFrames are mutually exclusive. If it is <code>false</code>, code is only injected into the top frame. Defaults to <code>false</code>.</dd>
+ <dt><code>code</code> {{optional_inline}}</dt>
+ <dd><code>string</code>. Code to inject, as a text string. <strong>Warning:</strong> Don’t use this property to interpolate untrusted data into JavaScript, as this could lead to a security issue.</dd>
+ <dt><code>file</code> {{optional_inline}}</dt>
+ <dd><code>string</code>. Path to a file containing the code to inject. In Firefox, relative URLs not starting at the extension root are resolved relative to the current page URL. In Chrome, these URLs are resolved relative to the extension's base URL. To work cross-browser, you can specify the path as a relative URL, starting at the extension's root, like this: <code>"/path/to/script.js"</code>.</dd>
+ <dt><code>frameId</code> {{optional_inline}}</dt>
+ <dd><code>integer</code>. The frame where the code should be injected. Defaults to <code>0</code> (the top-level frame).</dd>
+ <dt><code>matchAboutBlank</code> {{optional_inline}}</dt>
+ <dd><code>boolean</code>. If <code>true</code>, the code will be injected into embedded "about:blank" and "about:srcdoc" frames if your extension has access to their parent document. The code cannot be inserted in top-level about: frames. Defaults to <code>false</code>.</dd>
+ <dt><code>runAt</code> {{optional_inline}}</dt>
+ <dd>{{WebExtAPIRef('extensionTypes.RunAt')}}. The soonest that the code will be injected into the tab. Defaults to "document_idle".</dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id="Return_value">Return value</h3>
+
+<p>A <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> that will be fulfilled with an array of objects, representing the result of the script in every injected frame.</p>
+
+<p>The result of the script is the last evaluated statement, which is similar to what would be output (the results, not any <code>console.log()</code> output) if you executed the script in the <a href="/en-US/docs/Tools/Web_Console">Web Console</a>. For example, consider a script like this:</p>
+
+<pre class="brush: js">var foo='my result';foo;</pre>
+
+<p>Here the results array will contain the the string "<code>my result</code>" as an element. The result values must be <a href="/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm">structured clonable</a>.</p>
+
+<p>If any error occurs the promise will be rejected with an error message.</p>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.tabs.executeScript")}}</p>
+
+<h2 id="Examples">Examples</h2>
+
+<p>This example executes a one-line code snippet in the currently active tab:</p>
+
+<pre class="brush: js">function onExecuted(result) {
+ console.log(`We made it green`);
+}
+
+function onError(error) {
+ console.log(`Error: ${error}`);
+}
+
+var makeItGreen = 'document.body.style.border = "5px solid green"';
+
+var executing = browser.tabs.executeScript({
+ code: makeItGreen
+});
+executing.then(onExecuted, onError);</pre>
+
+<p>This example executes a script from a file, packaged with the extension, called "content-script.js". The script is executed in the currently active tab. The script is executed in subframes as well as the main document:</p>
+
+<pre class="brush: js">function onExecuted(result) {
+ console.log(`We executed in all subframes`);
+}
+
+function onError(error) {
+ console.log(`Error: ${error}`);
+}
+
+var executing = browser.tabs.executeScript({
+ file: "/content-script.js",
+ allFrames: true
+});
+executing.then(onExecuted, onError);</pre>
+
+<p>This example executes a script from a file, packaged with the extension, called "content-script.js". The script is executed in the tab with an ID of 2:</p>
+
+<pre class="brush: js">function onExecuted(result) {
+ console.log(`We executed in tab 2`);
+}
+
+function onError(error) {
+ console.log(`Error: ${error}`);
+}
+
+var executing = browser.tabs.executeScript(
+ 2, {
+ file: "/content-script.js"
+});
+executing.then(onExecuted, onError);</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/tabs#method-executeScript"><code>chrome.tabs</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> in the Chromium code.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/index.html
new file mode 100644
index 0000000000..868b3e1238
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/index.html
@@ -0,0 +1,192 @@
+---
+title: tabs
+slug: Mozilla/Add-ons/WebExtensions/API/tabs
+tags:
+ - API
+ - Add-ons
+ - Extensions
+ - Interface
+ - NeedsTranslation
+ - Non-standard
+ - Reference
+ - TopicStub
+ - WebExtensions
+ - tabs
+translation_of: Mozilla/Add-ons/WebExtensions/API/tabs
+---
+<div>{{AddonSidebar}}</div>
+
+<p>与浏览器标签系统进行交互。</p>
+
+<p>你可以使用该API获取一个已打开标签的列表并且使用各种标准过滤标签,并进行 打开, 刷新,移动,重载,移除操作。该API不能直接访问标签中的主机内容,但是你可以使用 {{WebExtAPIRef("tabs.executeScript()")}} 或者 {{WebExtAPIRef("tabs.insertCSS()")}} APIs,来插入javascript和CSS。</p>
+
+<p>你可以在不需要任何特殊权限的情况下使用该APIS的大部分, 除了:</p>
+
+<ul>
+ <li>获取 <code>Tab.url</code>, <code>Tab.title</code>, and <code>Tab.favIconUrl</code>, 你需要拥有 "tabs" <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">权限</a>. 在火狐,这也意味着你需要 "tabs" ,来通过URL使用 {{WebExtAPIRef("tabs.query", "query")}}。</li>
+ <li>使用 {{WebExtAPIRef("tabs.executeScript()")}} 或者 {{WebExtAPIRef("tabs.insertCSS()")}} 你必须在目标标签拥有 <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#Host_permissions">host permission</a> 。</li>
+</ul>
+
+<p>或者你可以仅仅只为当前的活动标签临时的获取这些权限并且仅仅只响应一个显示的用户行为,请查看 <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#activeTab_permission">"activeTab" permission</a>.</p>
+
+<h2 id="枚举值">枚举值</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("tabs.MutedInfoReason")}}</dt>
+ <dd>确定一个标签静音与否的原因(用户修改,扩展修改)。</dd>
+ <dt>{{WebExtAPIRef("tabs.MutedInfo")}}</dt>
+ <dd>该对象包含一个布尔值只是该标签是否静音,以及最近一次静音的原因。</dd>
+ <dt>{{WebExtAPIRef("tabs.Tab")}}</dt>
+ <dd>该值包含了一个标签的信息。</dd>
+ <dt>{{WebExtAPIRef("tabs.TabStatus")}}</dt>
+ <dd>指示某个标签是否已经加载完成</dd>
+ <dt>{{WebExtAPIRef("tabs.WindowType")}}</dt>
+ <dd>包含该标签的窗口类型。</dd>
+ <dt>{{WebExtAPIRef("tabs.ZoomSettingsMode")}}</dt>
+ <dd>定义缩放由浏览器控制或是扩展,或者禁用。</dd>
+ <dt>{{WebExtAPIRef("tabs.ZoomSettingsScope")}}</dt>
+ <dd>定义缩放将对某个网址持续生效,或者仅仅只针对该标签。</dd>
+ <dt>{{WebExtAPIRef("tabs.ZoomSettings")}}</dt>
+ <dd>定义缩放设置。 {{WebExtAPIRef("tabs.ZoomSettingsMode", "mode")}}, {{WebExtAPIRef("tabs.ZoomSettingsScope", "scope")}}, 和默认缩放比例。</dd>
+</dl>
+
+<h2 id="属性">属性</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("tabs.TAB_ID_NONE")}}</dt>
+ <dd>给予非浏览器标签的一个特殊ID值 (比如,在开发工具中的标签)。</dd>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("tabs.connect()")}}</dt>
+ <dd>在运行于该标签的任何 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">content scripts </a> 和该扩展的后台脚本(或者其他的比如弹出菜单脚本或者设置页面脚本)间创建一个消息连接。</dd>
+ <dt>{{WebExtAPIRef("tabs.create()")}}</dt>
+ <dd>创建一个新标签。</dd>
+ <dt>{{WebExtAPIRef("tabs.captureVisibleTab()")}}</dt>
+ <dd>创意一个数据统一资源标识符解码在规定窗口中当前活动标签的可视区域重的一个图片。</dd>
+ <dt>{{WebExtAPIRef("tabs.detectLanguage()")}}</dt>
+ <dd>检查在一个标签中的主要语言。</dd>
+ <dt>{{WebExtAPIRef("tabs.duplicate()")}}</dt>
+ <dd>复制一个标签</dd>
+ <dt>{{WebExtAPIRef("tabs.executeScript()")}}</dt>
+ <dd>向一个页面注入脚本。</dd>
+ <dt>{{WebExtAPIRef("tabs.get()")}}</dt>
+ <dd>取回制定标签的详细信息。</dd>
+ <dt>{{WebExtAPIRef("tabs.getAllInWindow()")}} {{deprecated_inline}}</dt>
+ <dd>获取指定窗口所有标签的详细信息。</dd>
+ <dt>{{WebExtAPIRef("tabs.getCurrent()")}}</dt>
+ <dd>返回一个 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/Tabs/Tab" title="This type contains information about a tab."><code>tabs.Tab</code></a> 对象包含了该脚本当前的宿主标签的信息。</dd>
+ <dt>{{WebExtAPIRef("tabs.getSelected()")}} {{deprecated_inline}}</dt>
+ <dd>获取在指定窗口被选定的标签。</dd>
+ <dt>{{WebExtAPIRef("tabs.getZoom()")}}</dt>
+ <dd>获取制定标签的缩放系数。</dd>
+ <dt>{{WebExtAPIRef("tabs.getZoomSettings()")}}</dt>
+ <dd>获取指定标签的缩放设置。</dd>
+ <dt>{{WebExtAPIRef("tabs.highlight()")}}</dt>
+ <dd>高亮显示一个或多个标签。</dd>
+ <dt>{{WebExtAPIRef("tabs.insertCSS()")}}</dt>
+ <dd>向一个页面注入CSS。</dd>
+ <dt>{{WebExtAPIRef("tabs.removeCSS()")}}</dt>
+ <dd>移除之前调用{{WebExtAPIRef("tabs.insertCSS()")}} 注入的一个css。</dd>
+ <dt>{{WebExtAPIRef("tabs.move()")}}</dt>
+ <dd>移动一个或多个标签页到同一窗口的一个新的位置或是到不同窗口。</dd>
+ <dt>{{WebExtAPIRef("tabs.query()")}}</dt>
+ <dd>获取所有包含指定属性的标签,如果没有属性则获取所有标签。</dd>
+ <dt>{{WebExtAPIRef("tabs.reload()")}}</dt>
+ <dd>重在一个标签,可选的可以绕过本地缓存。</dd>
+ <dt>{{WebExtAPIRef("tabs.remove()")}}</dt>
+ <dd>关闭一个或多个标签。</dd>
+ <dt>{{WebExtAPIRef("tabs.sendMessage()")}}</dt>
+ <dd>向一个指定标签的content script 发送单个消息。</dd>
+ <dt>{{WebExtAPIRef("tabs.sendRequest()")}} {{deprecated_inline}}</dt>
+ <dd>向一个指定标签的content script 发送一个单一请求。 <strong>过时</strong>: 请使用 {{WebExtAPIRef("tabs.sendMessage()")}} 替代。</dd>
+ <dt>{{WebExtAPIRef("tabs.setZoom()")}}</dt>
+ <dd>缩放指定标签。</dd>
+ <dt>{{WebExtAPIRef("tabs.setZoomSettings()")}}</dt>
+ <dd>为一个制定标签设置缩放选项。</dd>
+ <dt>{{WebExtAPIRef("tabs.update()")}}</dt>
+ <dd>导航一个标签到新的地址,或是修改其它的属性。</dd>
+</dl>
+
+<h2 id="Events">Events</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("tabs.onActivated")}}</dt>
+ <dd>当窗口活动标签改变时触发,注意当该消息触发时,标签地址可能没有被设置。</dd>
+ <dt>{{WebExtAPIRef("tabs.onActiveChanged")}} {{deprecated_inline}}</dt>
+ <dd> <strong>已过时:</strong> 请使用 {{WebExtAPIRef("tabs.onActivated")}} 代替。</dd>
+ <dt>{{WebExtAPIRef("tabs.onAttached")}}</dt>
+ <dd>当一个标签被附加到一个窗口时触发,因为他可能在窗口间移动。</dd>
+ <dt>{{WebExtAPIRef("tabs.onCreated")}}</dt>
+ <dd>当一个标签被创建时触发,注意当该事件触发时可能没有设置地址。</dd>
+ <dt>{{WebExtAPIRef("tabs.onDetached")}}</dt>
+ <dd>当一个标签脱离一个窗口时被触发。</dd>
+ <dt>{{WebExtAPIRef("tabs.onHighlightChanged")}} {{deprecated_inline}}</dt>
+ <dd><strong>过时:</strong> 请使用 {{WebExtAPIRef("tabs.onHighlighted")}} 代替。</dd>
+ <dt>{{WebExtAPIRef("tabs.onHighlighted")}}</dt>
+ <dd>当一个标签被高亮显示或是被选中时触发。</dd>
+ <dt>{{WebExtAPIRef("tabs.onMoved")}}</dt>
+ <dd>当一个标签在一个窗口内移动时被触发。</dd>
+ <dt>{{WebExtAPIRef("tabs.onRemoved")}}</dt>
+ <dd>当一个标签关闭时被处罚。</dd>
+ <dt>{{WebExtAPIRef("tabs.onReplaced")}}</dt>
+ <dd>当一个标签因为预载取代另一个标签时被触发。</dd>
+ <dt>{{WebExtAPIRef("tabs.onSelectionChanged")}} {{deprecated_inline}}</dt>
+ <dd> <strong>以过时:</strong> 请使用 {{WebExtAPIRef("tabs.onActivated")}} 代替。</dd>
+ <dt>{{WebExtAPIRef("tabs.onUpdated")}}</dt>
+ <dd>当一个标签被更新时触发。</dd>
+ <dt>{{WebExtAPIRef("tabs.onZoomChange")}}</dt>
+ <dd>当一个标签被缩放时触发</dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{Compat("webextensions.api.tabs")}}</p>
+
+<div class="hidden note">
+<p>The "Chrome incompatibilities" section is included from <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities"> https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a> using the <a href="/en-US/docs/Template:WebExtChromeCompat">WebExtChromeCompat</a> macro.</p>
+
+<p>If you need to update this content, edit <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities">https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a>, then shift-refresh this page to see your changes.</p>
+</div>
+
+<p> {{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/tabs"><code>chrome.tabs</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/insertcss/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/insertcss/index.html
new file mode 100644
index 0000000000..5ea7d5205c
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/insertcss/index.html
@@ -0,0 +1,129 @@
+---
+title: tabs.insertCSS()
+slug: Mozilla/Add-ons/WebExtensions/API/tabs/insertCSS
+tags:
+ - 注入CSS
+translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/insertCSS
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>向一个页面注入CSS</p>
+
+<p>使用该API前你必须拥有目标页面的权限, 可以是 <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/permissions#Host_permissions">主机权限</a>, 或者使用 <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#activeTab_permission">activeTab 权限</a>.</p>
+
+<p>你只能向符合 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns">match pattern </a>的网页注入CSS: 其形式必定是 "http", "https", "file", "ftp" 之一. 你不能向任何浏览器内置页面注入CSS, 比如 about:debugging, about:addons, 或者你打开的一个新的空白页。</p>
+
+<p>当再次调用{{WebExtAPIRef("tabs.removeCSS()")}} 时,已经注入的CSS可能会被清除。</p>
+
+<p>这是一个返回<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> 的异步函数。</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox brush:js">var inserting = browser.tabs.insertCSS(
+ tabId, // optional integer
+ details // extensionTypes.InjectDetails
+)
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>tabId</code> {{optional_inline}}</dt>
+ <dd><code>integer,</code> 将要注入css的标签ID。默认为当前窗口的活动标签。</dd>
+ <dt><code>details</code></dt>
+ <dd>{{WebExtAPIRef('extensionTypes.InjectDetails')}}. 对注入的描述,包含以下属性:</dd>
+ <dd>
+ <dl class="reference-values">
+ <dt><code>allFrames</code>{{optional_inline}}</dt>
+ <dd><code>boolean</code>. 如果为真,该CSS会被注入到该页面的所有框架,如果为假,Css只会注入到最顶层框架,默认为假。</dd>
+ <dt><code>code</code>{{optional_inline}}</dt>
+ <dd><code>string</code>. 将要注入的代码。</dd>
+ <dt><code>file</code>{{optional_inline}}</dt>
+ <dd><code>string</code>. 包含将要注入代码的文件路径,在Firefox中,相对URLs 决定于当前页面的URL,在Chrome中,决定于扩展的基础URL。为了跨浏览器工作,你应该使用一个从扩展根目录开始的绝对路径,比如 : <code>"/path/to/stylesheet.css"</code>.</dd>
+ <dt><code>frameId</code>{{optional_inline}}</dt>
+ <dd><code>integer</code>. CSS应该被注入的框架. 默认为 <code>0</code> (顶层框架).</dd>
+ <dt><code>matchAboutBlank</code>{{optional_inline}}</dt>
+ <dd><code>boolean</code>. If <code>true</code>, the code will be injected into embedded "about:blank" and "about:srcdoc" frames if your add-on has access to their parent document. The code cannot be inserted in top-level about: frames. Defaults to <code>false</code>.</dd>
+ <dt><code>runAt</code>{{optional_inline}}</dt>
+ <dd>{{WebExtAPIRef('extensionTypes.RunAt')}}. The soonest that the code will be injected into the tab. Defaults to "document_idle".</dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id="Return_value">Return value</h3>
+
+<p> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> 将会在CSS成功注入时 被填充,如果有任何错误发生,promise将会被注入一个错误消息。</p>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.tabs.insertCSS")}}</p>
+
+<h2 id="例子">例子</h2>
+
+<p>下面例子将通过字符串变量形式向当前活动标签注入一段CSS代码</p>
+
+<pre class="brush: js">var css = "body { border: 20px dotted pink; }";
+
+browser.browserAction.onClicked.addListener(() =&gt; {
+
+ function onError(error) {
+ console.log(`Error: ${error}`);
+ }
+
+ var insertingCSS = browser.tabs.insertCSS({code: css});
+ insertingCSS.then(null, onError);
+});</pre>
+
+<p>下面例子将以通过加载文件形式向页面注入CSS。CSS被注入在ID为2的tab中。</p>
+
+<pre class="brush: js">browser.browserAction.onClicked.addListener(() =&gt; {
+
+ function onError(error) {
+ console.log(`Error: ${error}`);
+ }
+
+ var insertingCSS = browser.tabs.insertCSS(2, {file: "content-style.css"});
+ insertingCSS.then(null, onError);
+});</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>致谢</strong>
+
+<p>本页 API 以谷歌 Chromium的 <a href="https://developer.chrome.com/extensions/tabs#method-insertCSS"><code>chrome.tabs</code></a> API为基础. 该篇文档由Chromium 代码 <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a>衍变而来.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/onactivated/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/onactivated/index.html
new file mode 100644
index 0000000000..0ce8758760
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/onactivated/index.html
@@ -0,0 +1,110 @@
+---
+title: tabs.onActivated
+slug: Mozilla/Add-ons/WebExtensions/API/tabs/onActivated
+translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/onActivated
+---
+<div>{{AddonSidebar()}}</div>
+
+<div>当窗体的活动标签变化时触发。请注意事件触发时标签的 URL 可能尚未设置,但是你可以通过监听 {{WebExtAPIRef("tabs.onUpdated")}} 事件在 URL 被设置后得到通知。</div>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox brush:js">browser.tabs.onActivated.addListener(listener)
+browser.tabs.onActivated.removeListener(listener)
+browser.tabs.onActivated.hasListener(listener)
+</pre>
+
+<p>此事件有三个方法:</p>
+
+<dl>
+ <dt><code>addListener(callback)</code></dt>
+ <dd>向此事件添加一个监听。</dd>
+ <dt><code>removeListener(listener)</code></dt>
+ <dd>停止监听此事件。 <code>listener</code> 参数是将要移除的监听。</dd>
+ <dt><code>hasListener(listener)</code></dt>
+ <dd>检查 <code>listener</code> 是否在此事件中注册。如果正在监听返回 <code>true</code> ,否则 <code>false。</code></dd>
+</dl>
+
+<h2 id="addListener_语法">addListener 语法</h2>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>callback</code></dt>
+ <dd>
+ <p>事件发生时被执行的方法。以下参数会被传递至该方法:</p>
+
+ <dl class="reference-values">
+ <dt><code>activeInfo</code></dt>
+ <dd><a href="#activeInfo"><code>object</code></a>. 被激活标签的ID , 以及它的窗体的 ID 。</dd>
+ </dl>
+ </dd>
+</dl>
+
+<h2 id="额外的对象">额外的对象</h2>
+
+<h3 id="activeInfo">activeInfo</h3>
+
+<dl class="reference-values">
+ <dt><code>tabId</code></dt>
+ <dd><code>integer</code>. 被激活的标签的ID。</dd>
+ <dt><code>windowId</code></dt>
+ <dd><code>integer</code>. 此标签的窗体的ID。</dd>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.tabs.onActivated")}}</p>
+
+<h2 id="示例">示例</h2>
+
+<p>监听并记录标签激活事件:</p>
+
+<pre class="brush: js">function handleActivated(activeInfo) {
+ console.log("Tab " + activeInfo.tabId +
+ " was activated");
+}
+
+browser.tabs.onActivated.addListener(handleActivated);</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/tabs#event-onActivated"><code>chrome.tabs</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/sendmessage/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/sendmessage/index.html
new file mode 100644
index 0000000000..8e968a2b1b
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/sendmessage/index.html
@@ -0,0 +1,129 @@
+---
+title: tabs.sendMessage()
+slug: Mozilla/Add-ons/WebExtensions/API/tabs/sendMessage
+translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/sendMessage
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>从background scripts中发送单个消息 (or other privileged scripts, such as popup scripts or options page scripts) 到任何content scripts that belong to the extension and are running in the specified tab.</p>
+
+<p>这个消息将被content scripts中 {{WebExtAPIRef("runtime.onMessage")}} 事件的所有监听者收到,然后它们可以选择通过使用 <code>sendResponse</code> 这个方法发送一个response到background scripts。</p>
+
+<p>This is an asynchronous function that returns a <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>.</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox brush:js">var sending = browser.tabs.sendMessage(
+ tabId, // integer
+ message, // any
+ options // optional object
+)
+</pre>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt><code>tabId</code></dt>
+ <dd><code>integer</code>. ID of the tab whose content scripts we want to send a message to.</dd>
+ <dt><code>message</code></dt>
+ <dd><code>any</code>. An object that can be serialized to JSON.</dd>
+ <dt><code>options</code>{{optional_inline}}</dt>
+ <dd><code>object</code>.</dd>
+ <dd>
+ <dl class="reference-values">
+ <dt><code>frameId</code>{{optional_inline}}</dt>
+ <dd><code>integer</code>. Sends the message to a specific frame identified by <code>frameId</code> instead of all frames in the tab. Whether the content script is executed in all frames depends on the <code>all_frames</code> setting in the <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/content_scripts"><code>content_scripts</code></a> section of manifest.json.</dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id="Return_value">Return value</h3>
+
+<p>A <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> that will be fulfilled with the JSON response object sent by the handler of the message in the content script, or with no arguments if the content script did not send a response. If an error occurs while connecting to the specified tab or any other error occurs, the promise will be rejected with an error message. If several frames response to the message, the promise is resolved to one of answers.</p>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.tabs.sendMessage")}}</p>
+
+<h2 id="Examples">Examples</h2>
+
+<p>Here's an example of a background script that sends a message to the content scripts running in the active tab when the user clicks the browser action. The background script also expects the content script to send a response:</p>
+
+<pre class="brush: js">// background-script.js
+"use strict";
+
+function onError(error) {
+ console.error(`Error: ${error}`);
+}
+
+function sendMessageToTabs(tabs) {
+ for (let tab of tabs) {
+ browser.tabs.sendMessage(
+ tab.id,
+ {greeting: "Hi from background script"}
+ ).then(response =&gt; {
+ console.log("Message from the content script:");
+ console.log(response.response);
+ }).catch(onError);
+ }
+}
+
+browser.browserAction.onClicked.addListener(() =&gt; {
+ browser.tabs.query({
+ currentWindow: true,
+ active: true
+ }).then(sendMessageToTabs).catch(onError);
+});</pre>
+
+<p>Here's the corresponding content script:</p>
+
+<pre class="brush: js">// content-script.js
+"use strict";
+
+browser.runtime.onMessage.addListener(request =&gt; {
+ console.log("Message from the background script:");
+ console.log(request.greeting);
+ return Promise.resolve({response: "Hi from content script"});
+});</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/tabs#method-sendMessage"><code>chrome.tabs</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/tab/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/tab/index.html
new file mode 100644
index 0000000000..2fed2e8dd7
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/tab/index.html
@@ -0,0 +1,117 @@
+---
+title: tabs.Tab
+slug: Mozilla/Add-ons/WebExtensions/API/tabs/Tab
+tags:
+ - 扩展
+ - 标签
+ - 标签页
+ - 类型
+ - 非标准
+ - 页面扩展
+translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/Tab
+---
+<div>{{AddonSidebar()}}</div>
+
+<p> <strong><code>tabs.Tab</code></strong> 包含有关标签页的信息 . 这样可以访问有关标签页中的内容,内容有多大,特殊状态或限制有效的信息等等。</p>
+
+<h2 id="类型">类型</h2>
+
+<p>这种类型的值是对象。它包含以下属性:</p>
+
+<dl class="reference-values">
+ <dt><code>active</code></dt>
+ <dd><code>boolean</code>. 该标签页是否在其窗口中处于活动状态。即使标签的窗口当前没有被关注,也可能是true。</dd>
+ <dt><code>audible</code> {{optional_inline}}</dt>
+ <dd><code>boolean</code>. 如果标签页没有静音:标签页是否正在发出声音。如果标签页被静音:如果没有静音标签页是否会发出声音。</dd>
+ <dt><code>autoDiscardable</code> {{optional_inline}}</dt>
+ <dd><code>boolean</code>. 资源不足时浏览器是否可以自动丢弃该标签页。</dd>
+ <dt><code>cookieStoreId</code> {{optional_inline}}</dt>
+ <dd><code>string</code>. 该标签页的Cookie存储. 如果不同的标签可以有不同的cookie存储 (例如, 支持 <a href="https://wiki.mozilla.org/Security/Contextual_Identity_Project/Containers">contextual identity</a>), you can pass this as the <code>storeId</code> option into various methods of the {{WebExtAPIRef("cookies")}} API, 设置和获取与此标签页的Cookie存储关联的Cookie。 只有在扩展名具有“cookies”<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">权</a></dd>
+ <dd><code>string</code>. 该标签页的Cookie存储. 如果不同的标签可以有不同的cookie存储 (例如, 支持 <a href="https://wiki.mozilla.org/Security/Contextual_Identity_Project/Containers">contextual identity</a>), 你可以将此作为 <code>storeId</code> 选项传递给 {{WebExtAPIRef("cookies")}} API的各种方法, 设置和获取与此标签页的Cookie存储关联的Cookie。 只有在扩展具有“cookies”<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">权限</a>的情况下才会出现.</dd>
+ <dt><code>discarded</code> {{optional_inline}}</dt>
+ <dd><code>boolean</code>. 是否丢弃的标签页。被丢弃的标签页是其内容已经从内存中卸载的标签页,但在标签页条中仍可见。它的内容在下一次被激活时被重新加载。</dd>
+ <dt><code>favIconUrl</code> {{optional_inline}}</dt>
+ <dd><code>string</code>. 该标签的图标的网址。 只有在扩展具有“cookies”<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">权限</a>的情况下才会出现. 如果标签页正在加载中,该值可以为空字符串</dd>
+ <dt><code>height</code> {{optional_inline}}</dt>
+ <dd><code>integer</code>. 标签页的像素单位高度。</dd>
+ <dt><code>highlighted</code></dt>
+ <dd><code>boolean</code>. 标签页是否突出显示。</dd>
+ <dt><code>id</code> {{optional_inline}}</dt>
+ <dd><code>integer</code>. 标签页的ID. 标签 ID在浏览器的会话中是唯一的 。 在浏览器窗口中不包含内容的标签页 (例如, devtools 窗口),标签 ID 也可以设置为 {{WebExtAPIRef('tabs.TAB_ID_NONE')}} 。</dd>
+ <dt><code>incognito</code></dt>
+ <dd><code>boolean</code>. 该标签页是否在隐私浏览窗口中。</dd>
+ <dt><code>index</code></dt>
+ <dd><code>integer</code>. 窗口中的标签页从零开始的索引。</dd>
+ <dt><code>isArticle</code></dt>
+ <dd><code>boolean</code>. 如果标签页可以在<a href="/en-US/Add-ons/WebExtensions/API/tabs/toggleReaderMode"> Reader模式下呈现</a>,则返回true,否则返回false。</dd>
+ <dt><code>isInReaderMode</code></dt>
+ <dd><code>boolean</code>. 如果标签页正在<a href="/en-US/Add-ons/WebExtensions/API/tabs/toggleReaderMode"> Reader模式下呈现</a>,则返回true,否则返回false。</dd>
+ <dt><code>lastAccessed</code></dt>
+ <dd><code>double</code>. 上次访问该标签页的时间 , 参考 <a class="external external-icon" href="https://en.wikipedia.org/wiki/Unix_time">milliseconds since the epoch</a>.</dd>
+ <dt><code>mutedInfo</code> {{optional_inline}}</dt>
+ <dd>{{WebExtAPIRef('tabs.MutedInfo')}}.标签页的当前静音状态以及上次状态更改的原因。</dd>
+ <dt><code>openerTabId</code> {{optional_inline}}</dt>
+ <dd><code>integer</code>. 打开此标签页的标签页ID(如果有)。如果开启者标签页仍然存在,该属性才会出现。</dd>
+ <dt><code>pinned</code></dt>
+ <dd><code>boolean</code>. 标签页是否被固定</dd>
+ <dt><code>selected</code> {{deprecated_inline}}</dt>
+ <dd><code>boolean</code>.标签页是否被选中</dd>
+ <dt><code>sessionId</code> {{optional_inline}}</dt>
+ <dd><code>string</code>. 从{{WebExtAPIRef('sessions')}} API 获取的标签页的唯一标识会话ID.</dd>
+ <dt><code>status</code> {{optional_inline}}</dt>
+ <dd><code>string</code>.<em>加载</em> 或 <em>完成</em>.</dd>
+ <dt><code>title</code> {{optional_inline}}</dt>
+ <dd><code>string</code>. 标签页的标题. 只有当扩展具有 <code>"tabs"</code> <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">权限</a> 时才会出现.</dd>
+ <dt><code>url</code> {{optional_inline}}</dt>
+ <dd><code>string</code>. 该选项卡正在显示的文档的URL。只有当扩展具有 <code>"tabs"</code> <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">权限</a> 时才会出现.</dd>
+ <dt><code>width</code> {{optional_inline}}</dt>
+ <dd><code>integer</code>. 标签页的像素单位宽度。</dd>
+ <dt><code>windowId</code></dt>
+ <dd><code>integer</code>. 包含此标签页的窗口ID。</dd>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.tabs.Tab", 10)}}</p>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>感谢</strong>
+
+<p>此 API 基于 Chromium的 <a href="https://developer.chrome.com/extensions/tabs#type-Tab"><code>chrome.tabs</code></a> API. 本文档来源于Chromium 代码中的 <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a>.</p>
+
+<p>Microsoft Edge兼容性数据由Microsoft Corporation提供,并包含在Creative Commons Attribution 3.0美国许可证下。</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/查询/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/查询/index.html
new file mode 100644
index 0000000000..9afe6e80a8
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/tabs/查询/index.html
@@ -0,0 +1,179 @@
+---
+title: 选项卡. 查询 ()
+slug: Mozilla/Add-ons/WebExtensions/API/tabs/查询
+translation_of: Mozilla/Add-ons/WebExtensions/API/tabs/query
+---
+<div>[阿登侧边栏()]</div>
+
+<p>获取具有指定属性的所有选项卡,如果未指定任何属性,则获取所有选项卡。</p>
+
+<p><font>这是返回 的异步函数。</font><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code></p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox brush:js notranslate">let querying = browser.tabs.query(<var>queryObj</var>)
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code><var>queryObj</var></code></dt>
+ <dd>
+ <p><code>object</code><font>.函数将仅获取其属性与此处包含的属性匹配的选项卡。</font><code>query()</code></p>
+
+ <p>请参阅 \WebExtAPIRef("选项卡")。Tab")=文档以了解有关这些属性的详细信息。</p>
+
+ <dl class="reference-values">
+ <dt><code>active</code><font>[optional_inline]</font></dt>
+ <dd><code>boolean</code><font>.选项卡是否在窗口中处于活动状态。</font></dd>
+ <dt><code>audible</code><font>[optional_inline]</font></dt>
+ <dd><code>boolean</code><font>.标签是否可听见。</font></dd>
+ <dt><code>autoDiscardable</code><font>[optional_inline]</font></dt>
+ <dd><code>boolean</code><font>.当资源不足时,浏览器是否可以自动丢弃选项卡。</font></dd>
+ <dt><code>cookieStoreId</code><font>[optional_inline]</font></dt>
+ <dd><code>string</code><font>.使用此仅返回其 Cookie 存储 ID 为 的选项卡。此选项仅在加载项具有权限时<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">才可用</a>。</font><code>cookieStoreId</code><code>"cookies"</code></dd>
+ <dt><code>currentWindow</code><font>[optional_inline]</font></dt>
+ <dd><code>boolean</code><font>.选项卡是否在当前窗口中。</font></dd>
+ <dt><code>discarded</code><font>[optional_inline]</font></dt>
+ <dd><code>boolean</code><font>.是否丢弃选项卡。丢弃的选项卡是其内容已从内存中卸载,但仍在选项卡条中可见的选项卡。下次激活时,其内容将重新加载。</font></dd>
+ <dt><code>hidden</code><font>[optional_inline]</font></dt>
+ <dd><code>boolean</code><font>.选项卡是否隐藏。</font></dd>
+ <dt><code>highlighted</code><font>[optional_inline]</font></dt>
+ <dd><code>boolean</code><font>.选项卡是否突出显示。</font></dd>
+ <dt><code>index</code><font>[optional_inline]</font></dt>
+ <dd><code>integer</code><font>.选项卡在其窗口中的位置。</font></dd>
+ <dt><code>muted</code><font>[optional_inline]</font></dt>
+ <dd><code>boolean</code><font>.选项卡是否为静音。</font></dd>
+ <dt><code>lastFocusedWindow</code><font>[optional_inline]</font></dt>
+ <dd><code>boolean</code><font>.选项卡是否在上一个焦点窗口中。</font></dd>
+ <dt><code>pinned</code><font>[optional_inline]</font></dt>
+ <dd><code>boolean</code><font>.选项卡是否固定。</font></dd>
+ <dt><code>status</code><font>[optional_inline]</font></dt>
+ <dd>{WebExtAPIRef('选项卡。TabStatus ')=。选项卡是否已完成加载。</dd>
+ <dt><code>title</code><font>[optional_inline]</font></dt>
+ <dd><code>string</code><font>.将页面标题与图案匹配。</font></dd>
+ <dt><code>url</code><font>[optional_inline]</font></dt>
+ <dd><code><code>string</code></code><font>或。将选项卡与一个或多个匹配<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns">模式匹配</a>。请注意,片段标识符不匹配。</font><code><code>array</code> of <code><code>string</code></code></code></dd>
+ <dt><code>windowId</code><font>{{optional_inline}}</font></dt>
+ <dd><code>integer</code><font>. The of the parent window, or {{WebExtAPIRef('windows.WINDOW_ID_CURRENT')}} for the current window.</font><code>id</code></dd>
+ <dt><code>windowType</code><font>{{optional_inline}}</font></dt>
+ <dd>{{WebExtAPIRef('tabs.WindowType')}}. The type of window the tabs are in.</dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id="Return_value">Return value</h3>
+
+<p><font>A that will be fulfilled with an of objects, containing information about each matching tab.</font><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code><code>array</code><code>{{WebExtAPIRef('tabs.Tab')}}</code></p>
+
+<p>If any error occurs, the promise will be rejected with an error message.</p>
+
+<h2 id="Examples">Examples</h2>
+
+<p>Get all tabs:</p>
+
+<pre class="brush: js notranslate">function logTabs(tabs) {
+ for (let tab of tabs) {
+ // tab.url requires the `tabs` permission
+ console.log(tab.url);
+ }
+}
+
+function onError(error) {
+ console.log(`Error: ${error}`);
+}
+
+let querying = browser.tabs.query({});
+querying.then(logTabs, onError);</pre>
+
+<p>Get all tabs in the current window:</p>
+
+<pre class="brush: js notranslate">function logTabs(tabs) {
+ for (let tab of tabs) {
+ // tab.url requires the `tabs` permission
+ console.log(tab.url);
+ }
+}
+
+function onError(error) {
+ console.log(`Error: ${error}`);
+}
+
+let querying = browser.tabs.query({currentWindow: true});
+querying.then(logTabs, onError);</pre>
+
+<p>Get the active tab in the current window:</p>
+
+<pre class="brush: js notranslate">function logTabs(tabs) {
+ // tabs[0].url requires the `tabs` permission
+ console.log(tabs[0].url);
+}
+
+function onError(error) {
+ console.log(`Error: ${error}`);
+}
+
+let querying = browser.tabs.query({currentWindow: true, active: true});
+querying.then(logTabs, onError);</pre>
+
+<p><font>Get tabs for all HTTP and HTTPS URLs under or any of its subdomains:</font><code>"mozilla.org"</code></p>
+
+<pre class="brush: js notranslate">function logTabs(tabs) {
+ for (let tab of tabs) {
+ // tab.url requires the `tabs` permission
+ console.log(tab.url);
+ }
+}
+
+function onError(error) {
+ console.log(`Error: ${error}`);
+}
+
+let querying = browser.tabs.query({url: "*://*.mozilla.org/*"});
+querying.then(logTabs, onError);</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+
+
+<p>{{Compat("webextensions.api.tabs.query")}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/tabs#method-query"><code>chrome.tabs</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/tabs.json"><code>tabs.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre class="notranslate">// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/types/browsersetting/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/types/browsersetting/index.html
new file mode 100644
index 0000000000..46641d4f60
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/types/browsersetting/index.html
@@ -0,0 +1,85 @@
+---
+title: BrowserSetting
+slug: Mozilla/Add-ons/WebExtensions/API/types/BrowserSetting
+tags:
+ - API
+ - Add-ons
+ - BrowserSetting
+ - Extensions
+ - NeedsTranslation
+ - Reference
+ - TopicStub
+ - Type
+ - Types
+ - WebExtensions
+translation_of: Mozilla/Add-ons/WebExtensions/API/types/BrowserSetting
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>A <code>BrowserSetting</code> is an object representing a browser setting.</p>
+
+<p>It provides methods to set and get the setting's underlying value, to clear any change you've made to it, and to listen for changes to its value.</p>
+
+<p>Note that while this object is based on the <a href="https://developer.chrome.com/extensions/types#type-ChromeSetting">ChromeSetting</a> type, this object does not distinguish between setting the value in normal browsing windows and in private browsing windows. This means that all parts of the API relating to private browsing (such as the <code>scope</code> option to <code>ChromeSetting.set()</code>) are not implemented.</p>
+
+<h2 id="Methods">Methods</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("types.BrowserSetting.get()")}}</dt>
+ <dd>Get the current value of the setting, and an enumeration representing how the setting is currently controlled.</dd>
+ <dt>{{WebExtAPIRef("types.BrowserSetting.set()")}}</dt>
+ <dd>Set the setting to a new value.</dd>
+ <dt>{{WebExtAPIRef("types.BrowserSetting.clear()")}}</dt>
+ <dd>Clear any change made to the setting by this extension.</dd>
+</dl>
+
+<h2 id="Events">Events</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("types.BrowserSetting.onChange")}}</dt>
+ <dd>Fired when the setting's value changes.</dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+
+
+<p>{{Compat("webextensions.api.types.BrowserSetting")}}</p>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/types"><code>chrome.types</code></a> API.</p>
+</div>
+
+<div class="hidden">
+<pre class="notranslate">// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/types/browsersetting/set/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/types/browsersetting/set/index.html
new file mode 100644
index 0000000000..fc85b194bb
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/types/browsersetting/set/index.html
@@ -0,0 +1,118 @@
+---
+title: set()
+slug: Mozilla/Add-ons/WebExtensions/API/types/BrowserSetting/set
+translation_of: Mozilla/Add-ons/WebExtensions/API/types/BrowserSetting/set
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>Use <code>BrowserSetting.set()</code> to change the browser setting to a new value.</p>
+
+<p>There are some rules that can restrict when extensions are able to change settings:</p>
+
+<ul>
+ <li>some settings are locked, so they can't be changed by extensions at all</li>
+ <li>if multiple extensions try to modify the same setting, then extensions are given a precedence ordering based on when they were installed. More-recently installed extensions have precedence over less-recently installed extension.</li>
+</ul>
+
+<p>This means that if extension X tries to change a setting:</p>
+
+<ol>
+ <li>If the setting is locked, then the setting is not changed. However, X's change is remembered, and it is stored in a queue, ordered by X's precedence relative to any other extensions that tried to change the setting. If the setting becomes unlocked later on, the first extension in the queue gets to change the setting.</li>
+ <li>Otherwise, if no other extension has already changed the setting, then X succeeds in changing the setting, and is then said to "control" the setting.</li>
+ <li>Otherwise, if a lower-precedence extension Y has already changed the setting, then X succeeds in changing the setting, and now controls the setting. However, Y's change is remembered, and is stored in a queue in precedence order. If X subsequently clears its value, or if X is disabled or uninstalled,  the first extension in the queue gets to make its change to the setting.</li>
+ <li>Otherwise, if a higher-precedence extension Z has already changed the setting, then X does not succeed in changing the setting, but its change is queued. If Z subsequently clears its value, or if Z is disabled or uninstalled, the first extension in the queue gets to make its change to the setting.</li>
+</ol>
+
+<p>An extension can find out which of these scenarios applies by examining the "<code>levelOfControl</code>" property returned from a call to <code><a href="/en-US/Add-ons/WebExtensions/API/privacy/BrowserSetting/get">BrowserSetting.get()</a></code>.</p>
+
+<p>The <code><a href="/en-US/Add-ons/WebExtensions/API/privacy/BrowserSetting/set">BrowserSetting.set()</a></code> method returns a Promise that resolves to a boolean: if an attempt to change a setting actually results in the setting being changed (scenarios 2 and 3 above) the boolean is <code>true</code>: otherwise it is <code>false</code>.</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox brush:js notranslate">var setting = setting.set(
+ details // object
+)
+</pre>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt><code>details</code></dt>
+ <dd>An object that must contain the following property:</dd>
+ <dd>
+ <dl class="reference-values">
+ <dt><code>value</code></dt>
+ <dd><code>any</code>. The value you want to change the setting to. Its type depends on the particular setting.</dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id="Return_value">Return value</h3>
+
+<p>A <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> that will be fulfilled with a <code>boolean</code>: <code>true</code> if the setting was modified, <code>false</code> otherwise (for example, because the extension did not control the setting).</p>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>See {{WebExtAPIRef("types.BrowserSetting")}}.</p>
+
+<h2 id="Example">Example</h2>
+
+<p>Modify the <code>hyperlinkAuditingEnabled</code> setting (this requires the "privacy" permission):</p>
+
+<pre class="brush: js notranslate">function onSet(result) {
+ if (result) {
+ console.log("Value was updated");
+ } else {
+ console.log("Value was not updated");
+ }
+}
+
+browser.browserAction.onClicked.addListener(() =&gt; {
+
+ var setting = browser.privacy.websites.hyperlinkAuditingEnabled.set({
+ value: false
+ });
+ setting.then(onSet);
+
+});
+</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/types"><code>chrome.types</code></a> API.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre class="notranslate">// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/types/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/types/index.html
new file mode 100644
index 0000000000..2e35b1d6e0
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/types/index.html
@@ -0,0 +1,66 @@
+---
+title: types
+slug: Mozilla/Add-ons/WebExtensions/API/types
+tags:
+ - API
+ - Add-ons
+ - Extensions
+ - NeedsTranslation
+ - Reference
+ - TopicStub
+ - Types
+ - WebExtensions
+translation_of: Mozilla/Add-ons/WebExtensions/API/types
+---
+<div>{{AddonSidebar}}</div>
+
+<p>Defines the <code>BrowserSetting</code> type, which is used to represent a browser setting.</p>
+
+<h2 id="Types">Types</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("types.BrowserSetting")}}</dt>
+ <dd>Represents a browser setting.</dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/types"><code>chrome.types</code></a> API.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre class="notranslate">// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/webnavigation/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/webnavigation/index.html
new file mode 100644
index 0000000000..6bb5b935e5
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/webnavigation/index.html
@@ -0,0 +1,155 @@
+---
+title: webNavigation
+slug: Mozilla/Add-ons/WebExtensions/API/webNavigation
+tags:
+ - API
+ - Add-ons
+ - Extensions
+ - Interface
+ - NeedsTranslation
+ - Non-standard
+ - Reference
+ - TopicStub
+ - WebExtensions
+ - webNavigation
+translation_of: Mozilla/Add-ons/WebExtensions/API/webNavigation
+---
+<div>{{AddonSidebar}}</div>
+
+<p>Add event listeners for the various stages of a navigation. A navigation consists of a frame in the browser transitioning from one URL to another, usually (but not always) in response to a user action like clicking a link or entering a URL in the location bar.</p>
+
+<p>Compared with the {{WebExtAPIRef("webRequest")}} API: navigations usually result in the browser making web requests, but the webRequest API is concerned with the lower-level view from the HTTP layer, while the webNavigation API is more concerned with the view from the browser UI itself.</p>
+
+<p>Each event corresponds to a particular stage in the navigation. The sequence of events is like this:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/13374/we-flow.png" style="display: block; height: 562px; margin-left: auto; margin-right: auto; width: 745px;"></p>
+
+<ul>
+ <li>The primary flow is:
+ <ul>
+ <li><code>{{WebExtAPIRef("webNavigation.onBeforeNavigate", "onBeforeNavigate")}}</code></li>
+ <li><code>{{WebExtAPIRef("webNavigation.onCommitted", "onCommitted")}}</code></li>
+ <li><code>{{WebExtAPIRef("webNavigation.onDOMContentLoaded", "onDOMContentLoaded")}}</code></li>
+ <li><code>{{WebExtAPIRef("webNavigation.onCompleted", "onCompleted")}}</code>.</li>
+ </ul>
+ </li>
+ <li>Additionally:
+ <ul>
+ <li><code>{{WebExtAPIRef("webNavigation.onCreatedNavigationTarget", "onCreatedNavigationTarget")}}</code> is fired before <code>onBeforeNavigate</code> if the browser needed to create a new tab or window for the navigation (for example, because the user opened a link in a new tab).</li>
+ <li>{{WebExtAPIRef("webNavigation.onHistoryStateUpdated", "onHistoryStateUpdated")}} is fired if a page uses the <a href="http://diveintohtml5.info/history.html">history API</a> to update the URL displayed in the browser's location bar.</li>
+ <li>{{WebExtAPIRef("webNavigation.onReferenceFragmentUpdated", "onReferenceFragmentUpdated")}} is fired if the <a href="https://en.wikipedia.org/wiki/Fragment_identifier">fragment identifier</a> for a page is changed.</li>
+ <li>{{WebExtAPIRef("webNavigation.onErrorOccurred", "onErrorOccurred")}} can be fired at any point.</li>
+ </ul>
+ </li>
+</ul>
+
+<p>Each navigation is a URL transition in a particular browser frame. The browser frame is identified by a tab ID and a frame ID. The frame may be the top-level browsing context in the tab, or may be a nested browsing context implemented as an <a href="/en-US/docs/Web/HTML/Element/iframe">iframe</a>.</p>
+
+<p>Each event's <code>addListener()</code> call accepts an optional filter parameter. The filter will specify one or more URL patterns, and the event will then only be fired for navigations in which the target URL matches one of the patterns.</p>
+
+<p>The <code>onCommitted</code> event listener is passed two additional properties: a {{WebExtAPIRef("webNavigation.TransitionType","TransitionType")}} indicating the cause of the navigation (for example, because the user clicked a link, or because the user selected a bookmark), and a {{WebExtAPIRef("webNavigation.TransitionQualifier","TransitionQualifier")}} providing further information about the navigation.</p>
+
+<p>To use this API you need to have the "webNavigation" <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a>.</p>
+
+<h2 id="Types">Types</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("webNavigation.TransitionType")}}</dt>
+ <dd>Cause of the navigation: for example, the user clicked a link, or typed an address, or clicked a bookmark.</dd>
+ <dt>{{WebExtAPIRef("webNavigation.TransitionQualifier")}}</dt>
+ <dd>
+ <div>Extra information about a transition.</div>
+ </dd>
+</dl>
+
+<h2 id="Functions">Functions</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("webNavigation.getFrame()")}}</dt>
+ <dd>Retrieves information about a particular frame. A frame may be the top-level frame in a tab or a nested <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe">iframe</a>, and is uniquely identified by a tab ID and a frame ID.</dd>
+ <dt>{{WebExtAPIRef("webNavigation.getAllFrames()")}}</dt>
+ <dd>
+ <p>Given a tab ID, retrieves information about all the frames it contains.</p>
+ </dd>
+</dl>
+
+<h2 id="Events">Events</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("webNavigation.onBeforeNavigate")}}</dt>
+ <dd>
+ <p>Fired when the browser is about to start a navigation event.</p>
+ </dd>
+ <dt>{{WebExtAPIRef("webNavigation.onCommitted")}}</dt>
+ <dd>Fired when a navigation is committed. At least part of the new document has been received from the server and the browser has decided to switch to the new document.</dd>
+ <dt>{{WebExtAPIRef("webNavigation.onDOMContentLoaded")}}</dt>
+ <dd>Fired when the <a href="https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded">DOMContentLoaded</a> event is fired in the page.</dd>
+ <dt>{{WebExtAPIRef("webNavigation.onCompleted")}}</dt>
+ <dd>Fired when a document, including the resources it refers to, is completely loaded and initialized. This is equivalent to the DOM <code><a href="https://developer.mozilla.org/en-US/docs/Web/Events/load">load</a></code> event.</dd>
+ <dt>{{WebExtAPIRef("webNavigation.onErrorOccurred")}}</dt>
+ <dd>Fired when an error occurs and the navigation is aborted. This can happen if either a network error occurred, or the user aborted the navigation.</dd>
+ <dt>{{WebExtAPIRef("webNavigation.onCreatedNavigationTarget")}}</dt>
+ <dd>Fired when a new window, or a new tab in an existing window, is created to host a navigation: for example, if the user opens a link in a new tab.</dd>
+ <dt>{{WebExtAPIRef("webNavigation.onReferenceFragmentUpdated")}}</dt>
+ <dd>Fired if the <a class="external-icon external" href="https://en.wikipedia.org/wiki/Fragment_identifier">fragment identifier</a> for a page is changed.</dd>
+ <dt>{{WebExtAPIRef("webNavigation.onTabReplaced")}}</dt>
+ <dd>
+ <p>Fired when the contents of the tab is replaced by a different (usually previously pre-rendered) tab.</p>
+ </dd>
+ <dt>{{WebExtAPIRef("webNavigation.onHistoryStateUpdated")}}</dt>
+ <dd>Fired when the page used the <a class="external external-icon" href="http://diveintohtml5.info/history.html">history API</a> to update the URL displayed in the browser's location bar.</dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{Compat("webextensions.api.webNavigation")}}</p>
+
+<div class="hidden note">
+<p>The "Chrome incompatibilities" section is included from <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities"> https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a> using the <a href="/en-US/docs/Template:WebExtChromeCompat">WebExtChromeCompat</a> macro.</p>
+
+<p>If you need to update this content, edit <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities">https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a>, then shift-refresh this page to see your changes.</p>
+</div>
+
+<h3 id="Edge_incompatibilities">Edge incompatibilities</h3>
+
+<p>Promises are not supported in Edge. Use callbacks instead.</p>
+
+<p>{{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/webNavigation"><code>chrome.webNavigation</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/web_navigation.json"><code>web_navigation.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/webnavigation/ondomcontentloaded/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/webnavigation/ondomcontentloaded/index.html
new file mode 100644
index 0000000000..41a103dc8c
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/webnavigation/ondomcontentloaded/index.html
@@ -0,0 +1,137 @@
+---
+title: webNavigation.onDOMContentLoaded
+slug: Mozilla/Add-ons/WebExtensions/API/webNavigation/onDOMContentLoaded
+tags:
+ - API
+ - onDOMContentLoaded
+ - webNavigation
+ - webNavigation.onDOMContentLoaded
+translation_of: Mozilla/Add-ons/WebExtensions/API/webNavigation/onDOMContentLoaded
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>在页面中触发<a href="/en-US/docs/Web/Events/DOMContentLoaded">DOMContentLoaded</a> 事件时触发。此时,文档被加载和解析,并且DOM被完全构造,但链接的资源(例如图像,样式表和子框架(subframes))可能尚未被加载。</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox brush:js">browser.webNavigation.onDOMContentLoaded.addListener(
+ listener, // function
+ filter // optional object
+)
+browser.webNavigation.onDOMContentLoaded.removeListener(listener)
+browser.webNavigation.onDOMContentLoaded.hasListener(listener)
+</pre>
+
+<p>事件有三个方法:</p>
+
+<dl>
+ <dt><code>addListener(callback)</code></dt>
+ <dd>为此事件添加监听方法.</dd>
+ <dt><code>removeListener(listener)</code></dt>
+ <dd>停止监听此事件. <code>listener</code> 参数为需要移出的监听方法.</dd>
+ <dt><code>hasListener(listener)</code></dt>
+ <dd>检测是否有 <code>listener</code> 被注册在事件上. 如果有返回 <code>true</code> , 否则返回<code>false</code> .</dd>
+</dl>
+
+<h2 id="addListener_syntax">addListener syntax</h2>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>callback</code></dt>
+ <dd>
+ <p>为当此事件发生是需要被调用的函数. 该函数将传递以下参数:</p>
+
+ <dl class="reference-values">
+ <dt><code>details</code></dt>
+ <dd><a href="#details"><code>object</code></a>. 有关导航(navigation)事件的详细信息.</dd>
+ </dl>
+ </dd>
+ <dt><code>filter</code>{{optional_inline}}</dt>
+ <dd>
+ <p><code>object</code>. 包含单个属性 <code>url</code> 的对象,  这是一个  {{WebExtAPIRef("events.UrlFilter")}} <font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.5);">数组</span></font>对象. 如果包含此参数,则该事件将仅触发转换为与数组中至少一个<code>UrlFilter</code>匹配的URL。 在数组中。如果您省略此参数,则该事件将触发所有转换。</p>
+ </dd>
+</dl>
+
+<h2 id="Additional_objects">Additional objects</h2>
+
+<h3 id="details">details</h3>
+
+<dl class="reference-values">
+ <dt><code>tabId</code></dt>
+ <dd><code>integer</code>. The ID of the tab in which the navigation has occurred.</dd>
+ <dt><code>url</code></dt>
+ <dd><code>string</code>. The URL to which the given frame has navigated.</dd>
+ <dt><code>processId</code></dt>
+ <dd><code>integer</code>. The ID of the process in which this tab is being rendered.</dd>
+ <dt><code>frameId</code></dt>
+ <dd><code>integer</code>. Frame in which the navigation is occurring. 0 indicates that navigation happens in the tab's top-level browsing context, not in a nested <a href="/en-US/docs/Web/HTML/Element/iframe">iframe</a>. A positive value indicates that navigation happens in a nested iframe. Frame IDs are unique for a given tab and process.</dd>
+ <dt><code>timeStamp</code></dt>
+ <dd><code>number</code>. The time at which <code>DOMContentLoaded</code> was fired, in <a href="https://en.wikipedia.org/wiki/Unix_time">milliseconds since the epoch</a>.</dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.webNavigation.onDOMContentLoaded")}}</p>
+
+<h2 id="Examples">Examples</h2>
+
+<p>Logs the target URLs for <code>onDOMContentLoaded</code>, if the target URL's hostname contains "example.com" or starts with "developer".</p>
+
+<pre class="brush: js">var filter = {
+ url:
+ [
+ {hostContains: "example.com"},
+ {hostPrefix: "developer"}
+ ]
+}
+
+function logOnDOMContentLoaded(details) {
+ console.log("onDOMContentLoaded: " + details.url);
+}
+
+browser.webNavigation.<code>onDOMContentLoaded</code>.addListener(logOnDOMContentLoaded, filter);
+
+</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/webNavigation#event-onBeforeNavigate"><code>chrome.webNavigation</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/web_navigation.json"><code>web_navigation.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/webrequest/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/webrequest/index.html
new file mode 100644
index 0000000000..03b5823878
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/webrequest/index.html
@@ -0,0 +1,186 @@
+---
+title: webRequest
+slug: Mozilla/Add-ons/WebExtensions/API/webRequest
+tags:
+ - API
+ - Add-ons
+ - Extensions
+ - Interface
+ - NeedsTranslation
+ - Non-standard
+ - Reference
+ - TopicStub
+ - WebExtensions
+ - webRequest
+translation_of: Mozilla/Add-ons/WebExtensions/API/webRequest
+---
+<div>{{AddonSidebar}}</div>
+
+<div>为发出的HTTP请求在不同阶段添加事件监听器。事件监听器可以接收到请求的详细信息,也可以修改或取消请求。</div>
+
+<h2 id="概况">概况</h2>
+
+<p>每个事件都会在请求的特定阶段触发。事件的顺序大概是这样的:</p>
+
+<p>在请求过程中的任意时间,{{WebExtAPIRef("webRequest.onErrorOccurred", "onErrorOccurred")}} 可以被触发。虽然有时候触发的事件顺序不同,举个例子,在火狐浏览器中的HSTS过程,在onBeforeRequest事件执行后,onBeforeRedirect 事件会被立即触发。</p>
+
+<p>所有的事件,接受<code>onErrorOccurred事件</code>, <code>addListener()</code>有三个参数 :</p>
+
+<ul>
+ <li>监听本身</li>
+ <li>一个{{WebExtAPIRef("webRequest.RequestFilter", "filter")}} 对象, 所以你仅可以被特定请求或特定的资源类型提醒</li>
+ <li>一个可选的<code>extraInfoSpec</code>对象. 你可以使用这个对象添加特定的事件命令</li>
+</ul>
+
+<p>这个监听函数接收一个<code>details</code>对象,这个对象包含这个请求的信息。他包含一个请求ID, 在插件中这个ID可以关联唯一个请求事件. 这个ID是浏览器会话和插件上下文中唯一的。他始终在同一个请求中,贯穿着转发和授权等事件中。</p>
+
+<p>在一个给定的主机上使用webRequest API, 你必须有这个主机的相关权限,包括"webRequest" <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#API_permissions">API permission</a> 和 <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#Host_permissions">host permission</a>. 为了使用 "blocking" 特性,你必须有 "webRequestBlocking" API 权限。</p>
+
+<p>这个webRequest API不能让你进入一些安全敏感的请求,比如<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1279371">update checks and OCSP checks</a>.</p>
+
+<h3 id="Modifying_requests">Modifying requests</h3>
+
+<p>在下边这些事件中,你可以修改请求. 比如一些特别的操作:</p>
+
+<ul>
+ <li>取消请求:
+ <ul>
+ <li>{{WebExtAPIRef("webRequest.onBeforeRequest", "onBeforeRequest")}}</li>
+ <li>{{WebExtAPIRef("webRequest.onBeforeSendHeaders", "onBeforeSendHeaders")}}</li>
+ <li>{{WebExtAPIRef("webRequest.onAuthRequired", "onAuthRequired")}}</li>
+ </ul>
+ </li>
+ <li>重定向请求:
+ <ul>
+ <li>{{WebExtAPIRef("webRequest.onBeforeRequest", "onBeforeRequest")}}</li>
+ <li>{{WebExtAPIRef("webRequest.onHeadersReceived", "onHeadersReceived")}}</li>
+ </ul>
+ </li>
+ <li>修改请求头:
+ <ul>
+ <li>{{WebExtAPIRef("webRequest.onBeforeSendHeaders", "onBeforeSendHeaders")}}</li>
+ </ul>
+ </li>
+ <li>修改响应头:
+ <ul>
+ <li>{{WebExtAPIRef("webRequest.onHeadersReceived", "onHeadersReceived")}}</li>
+ </ul>
+ </li>
+ <li>加入认证功能:
+ <ul>
+ <li>{{WebExtAPIRef("webRequest.onAuthRequired", "onAuthRequired")}}</li>
+ </ul>
+ </li>
+</ul>
+
+<p>为了完成这些操作,你需要在<code>extraInfoSpec</code>参数中添加"blocking"的值到事件的<code>addListener()</code>。这将使得监听器变成同步执行。在监听器中,你可以返回一个表明需要作修改的{{WebExtAPIRef("webRequest.BlockingResponse", "BlockingResponse")}}对象:比如说,你想要发送的修改后的请求头。</p>
+
+<p>从Firefox 52开始,监听器会返回一个<code>resolve(BlockingResponse)</code> 的 <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>,而不是直接返回一个<code>BlockingResponse</code>。这使得监听器可以异步地处理请求。</p>
+
+<h2 id="Types">Types</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("webRequest.ResourceType")}}</dt>
+ <dd>Represents a particular kind of resource fetched in a web request.</dd>
+ <dt>{{WebExtAPIRef("webRequest.RequestFilter")}}</dt>
+ <dd>An object describing filters to apply to webRequest events.</dd>
+ <dt>{{WebExtAPIRef("webRequest.HttpHeaders")}}</dt>
+ <dd>An array of HTTP headers. Each header is represented as an object with two properties: <code>name</code> and either <code>value</code> or <code>binaryValue</code>.</dd>
+ <dt>{{WebExtAPIRef("webRequest.BlockingResponse")}}</dt>
+ <dd>
+ <p>An object of this type is returned by event listeners that have set <code>"blocking"</code> in their <code>extraInfoSpec</code> argument. By setting particular properties in <code>BlockingResponse</code>, the listener can modify network requests.</p>
+ </dd>
+ <dt>{{WebExtAPIRef("webRequest.UploadData")}}</dt>
+ <dd>Contains data uploaded in a URL request.</dd>
+</dl>
+
+<h2 id="Properties">Properties</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES")}}</dt>
+ <dd>The maximum number of times that <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/WebRequest/handlerBehaviorChanged" title="Suppose an add-on's job is to block web requests against a pattern, and the following scenario happens:"><code>handlerBehaviorChanged()</code></a></code> can be called in a 10 minute period.</dd>
+</dl>
+
+<h2 id="Functions">Functions</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("webRequest.handlerBehaviorChanged()")}}</dt>
+ <dd>This function can be used to ensure that event listeners are applied correctly when pages are in the browser's in-memory cache.</dd>
+</dl>
+
+<h2 id="Events">Events</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("webRequest.onBeforeRequest")}}</dt>
+ <dd>Fired when a request is about to be made, and before headers are available. This is a good place to listen if you want to cancel or redirect the request.</dd>
+ <dt>{{WebExtAPIRef("webRequest.onBeforeSendHeaders")}}</dt>
+ <dd>Fired before sending any HTTP data, but after HTTP headers are available. This is a good place to listen if you want to modify HTTP request headers.</dd>
+ <dt>{{WebExtAPIRef("webRequest.onSendHeaders")}}</dt>
+ <dd>Fired just before sending headers. If your add-on or some other add-on modified headers in <code>{{WebExtAPIRef("webRequest.onBeforeSendHeaders", "onBeforeSendHeaders")}}</code>, you'll see the modified version here.</dd>
+ <dt>{{WebExtAPIRef("webRequest.onHeadersReceived")}}</dt>
+ <dd>Fired when the HTTP response headers associated with a request have been received. You can use this event to modify HTTP response headers.</dd>
+ <dt>{{WebExtAPIRef("webRequest.onAuthRequired")}}</dt>
+ <dd>Fired when the server asks the client to provide authentication credentials. The listener can do nothing, cancel the request, or supply authentication credentials.</dd>
+ <dt>{{WebExtAPIRef("webRequest.onResponseStarted")}}</dt>
+ <dd>Fired when the first byte of the response body is received. For HTTP requests, this means that the status line and response headers are available.</dd>
+ <dt>{{WebExtAPIRef("webRequest.onBeforeRedirect")}}</dt>
+ <dd>Fired when a server-initiated redirect is about to occur.</dd>
+ <dt>{{WebExtAPIRef("webRequest.onCompleted")}}</dt>
+ <dd>Fired when a request is completed.</dd>
+ <dt>{{WebExtAPIRef("webRequest.onErrorOccurred")}}</dt>
+ <dd>Fired when an error occurs.</dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{Compat("webextensions.api.webRequest")}}</p>
+
+<div class="hidden note">
+<p>The "Chrome incompatibilities" section is included from <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities"> https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a> using the <a href="/en-US/docs/Template:WebExtChromeCompat">WebExtChromeCompat</a> macro.</p>
+
+<p>If you need to update this content, edit <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities">https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a>, then shift-refresh this page to see your changes.</p>
+</div>
+
+<h3 id="Edge_incompatibilities">Edge incompatibilities</h3>
+
+<p>Promises are not supported in Edge. Use callbacks instead.</p>
+
+<p>{{Compat("webextensions.api.webRequest")}} {{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/webRequest"><code>chrome.webRequest</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/web_request.json"><code>web_request.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre class="notranslate">// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/webrequest/requestfilter/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/webrequest/requestfilter/index.html
new file mode 100644
index 0000000000..6ac538c374
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/webrequest/requestfilter/index.html
@@ -0,0 +1,71 @@
+---
+title: webRequest.RequestFilter
+slug: Mozilla/Add-ons/WebExtensions/API/webRequest/RequestFilter
+tags:
+ - webRequest
+translation_of: Mozilla/Add-ons/WebExtensions/API/webRequest/RequestFilter
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>webRequest事件参数</p>
+
+<h2 id="Type">Type</h2>
+
+<p>该参数值是一个对象,包括以下属性:</p>
+
+<dl class="reference-values">
+ <dt><code>urls</code></dt>
+ <dd><font face="Consolas, Liberation Mono, Courier, monospace">字符串数组类型,数组内的每个字符串为<a href="https://developer.mozilla.org/zh-CN/Add-ons/WebExtensions/Match_patterns">模式匹配</a>格式。当请求地址符合给定模式时,事件监听器才会响应。需注意的是,仅支持http和HTTPS协议的参数地址,其他协议即使与该给定模式匹配也不会响应。</font></dd>
+ <dt><code>types</code>{{optional_inline}}</dt>
+ <dd>webRequest.ResourceType类型的数组,表示资源类型列表。例如:stylesheets、images、scripts。事件监听器仅响应出现在该指定列表的资源类型。</dd>
+ <dt><code>tabId</code>{{optional_inline}}</dt>
+ <dd><font face="Consolas, Liberation Mono, Courier, monospace">数值类型,与</font>{{WebExtAPIRef("tabs.Tab", "tab")}}关联,事件监听器仅响应指定了该tabId的请求。</dd>
+ <dt><code>windowId</code>{{optional_inline}}</dt>
+ <dd><font face="Consolas, Liberation Mono, Courier, monospace">数值类型,与</font>{{WebExtAPIRef("windows.Window", "window")}}关联,事件监听器仅响应指定了该<code>windowId</code>的请求。</dd>
+</dl>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.webRequest.RequestFilter")}}</p>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>告知信息</strong>
+
+<p>该API基于Chromium的 <a href="https://developer.chrome.com/extensions/webRequest#type-RequestFilter"><code>chrome.webRequest</code></a> API. 该文档来源于Chromium代码中的 <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/web_request.json"><code>web_request.json</code></a> 。</p>
+
+<p>Microsoft Edge兼容性数据由Microsoft Corporation提供,并包含在Creative Commons Attribution 3.0 United States License下。</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/windows/create/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/windows/create/index.html
new file mode 100644
index 0000000000..7673eadc83
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/windows/create/index.html
@@ -0,0 +1,169 @@
+---
+title: windows.create()
+slug: Mozilla/Add-ons/WebExtensions/API/windows/create
+translation_of: Mozilla/Add-ons/WebExtensions/API/windows/create
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>创建一个新的窗口.</p>
+
+<p>当你创建一个窗口时,你可以:</p>
+
+<ul>
+ <li>加载一个或多个新的标签到该窗口中.</li>
+ <li>将一个现有窗口的.标签移动到新的窗口中</li>
+ <li>设置窗口的大小和位置</li>
+ <li>创建一个面板样式的窗口,它没有浏览器的默认样式(地址栏,工具栏等)</li>
+ <li>设置窗口的多种属性, 像是获得焦点或是为隐私窗口.</li>
+</ul>
+
+<p>这是一个异步的方法返回一个 <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>.</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox brush:js">var creating = browser.windows.create(
+ createData // optional object
+)
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>createData</code>{{optional_inline}}</dt>
+ <dd><code>object</code>.</dd>
+ <dd>
+ <dl class="reference-values">
+ <dt><code>url</code>{{optional_inline}}</dt>
+ <dd><code><code>字符串或字符串数组</code></code>. 一个URL或都URL数组要在该窗口中打开成标签页的. 完整的需要包括scheme (像. <code>http://www.google.com</code>, not <code>www.google.com</code>). 相对路径将相对于该拓展中的当前页. 默认为打开新标签页.</dd>
+ <dt><code>tabId</code>{{optional_inline}}</dt>
+ <dd><code>integer</code>. 如果设置了该值,将该tab从一个现有的窗口中移到新窗口中.</dd>
+ <dt><code>left</code>{{optional_inline}}</dt>
+ <dd><code>integer</code>. 窗口左边到屏幕左边缘的距离.如果没有设定,新窗口将按上一个焦点窗口定位水平位置. 对于panel样式窗口,该值不起作用.</dd>
+ <dt><code>top</code>{{optional_inline}}</dt>
+ <dd>窗口顶部到屏幕的顶部距离.如果没有设定,新窗口将按上一个焦点窗口定位垂直位置. 对于panel样式窗口,该值不起作用.</dd>
+ <dt><code>width</code>{{optional_inline}}</dt>
+ <dd><code>integer</code>. 新窗口的宽度, 包含框架. 未设定则使用默认宽度。.</dd>
+ <dt><code>height</code>{{optional_inline}}</dt>
+ <dd><code>integer</code>. 新窗口的高度, 包含框架. 未设定则使用默认高度。.</dd>
+ <dt><code>focused</code>{{optional_inline}}</dt>
+ <dd><code>boolean</code>.如果 为<code>true</code>, 新窗口将获取焦点. 否则新窗口当在后台打开并且当前焦点窗口继续保持焦点.。.默认为true</dd>
+ <dt><code>incognito</code>{{optional_inline}}</dt>
+ <dd><code>boolean</code>. 是否打开为一个隐私窗口. <code>如果设定为隐私窗口并且引入了tabId</code>, 则tabId对应的标签必须是一个隐私标签— 即不能把一个不是隐私标签的标签页移动到隐私窗口中。</dd>
+ <dt><code>type</code>{{optional_inline}}</dt>
+ <dd>一{{WebExtAPIRef('windows.CreateType')}} 值,表示创建窗口的类型. <code>panel</code> 或者<code>popup</code> 样式将打开一个没有默认浏览器样式的窗口 (地址栏,工具栏等)。</dd>
+ <dt><code>state</code>{{optional_inline}}</dt>
+ <dd>一个 {{WebExtAPIRef('windows.WindowState')}} 值, 窗口的祲状态。 最小化、最大化、全屏状态不能与<code>left</code>, <code>top</code>, <code>width</code>, or <code>height</code>属性一起使用。</dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>一个 <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> 其中传入一个包含新窗口细节的 {{WebExtAPIRef('windows.Window')}} 对象。 这个{{WebExtAPIRef('windows.Window')}} 有自己的tabs属性集 ,而不像 {{WebExtAPIRef("windows.get()")}}返回的窗口对象和相似的API,  如果传递了populate项其仅仅包含tabs. 如果发生了错误 promise will be rejected with an error message.</p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">这个页面中的兼容性表是从结构化数据生成的。如果你想为数据,请参照 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 并且给我们发请求</p>
+
+<p>{{Compat("webextensions.api.windows.create", 10)}}</p>
+
+<h2 id="示例">示例</h2>
+
+<p>打开一个包含两个标签的窗口</p>
+
+<pre class="brush: js">function onCreated(windowInfo) {
+ console.log(`Created window: ${windowInfo.id}`);
+}
+
+function onError(error) {
+ console.log(`Error: ${error}`);
+}
+
+browser.browserAction.onClicked.addListener((tab) =&gt; {
+ var creating = browser.windows.create({
+ url: ["https://developer.mozilla.org",
+ "https://addons.mozilla.org"]
+ });
+ creating.then(onCreated, onError);
+});</pre>
+
+<p>当用户点击一个browser action打开一个窗口,并且将当前活跃的标签移动其中</p>
+
+<pre class="brush: js">function onCreated(windowInfo) {
+ console.log(`Created window: ${windowInfo.id}`);
+}
+
+function onError(error) {
+ console.log(`Error: ${error}`);
+}
+
+browser.browserAction.onClicked.addListener((tab) =&gt; {
+ var creating = browser.windows.create({
+ tabId: tab.id
+ });
+ creating.then(onCreated, onError);
+});</pre>
+
+<p>打开一个小面板样式的窗口,并且加载一个本地包中的文件到其中</p>
+
+<pre class="brush: js">function onCreated(windowInfo) {
+ console.log(`Created window: ${windowInfo.id}`);
+}
+
+function onError(error) {
+ console.log(`Error: ${error}`);
+}
+
+browser.browserAction.onClicked.addListener((tab) =&gt; {
+
+ var popupURL = browser.extension.getURL("popup/popup.html");
+
+ var creating = browser.windows.create({
+ url: popupURL,
+ type: "popup",
+ height: 200,
+ width: 200
+ });
+ creating.then(onCreated, onError);
+
+});</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/windows#method-create"><code>chrome.windows</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/windows.json"><code>windows.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/windows/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/windows/index.html
new file mode 100644
index 0000000000..b923176e30
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/windows/index.html
@@ -0,0 +1,116 @@
+---
+title: windows
+slug: Mozilla/Add-ons/WebExtensions/API/windows
+translation_of: Mozilla/Add-ons/WebExtensions/API/windows
+---
+<div>{{AddonSidebar}}</div>
+
+<p>与浏览器窗口互动。您可以使用此 API 获取有关已打开窗口的信息,以及打开、修改和关闭窗口。您也可以监听窗口的打开、关闭和其激活事件。</p>
+
+<h2 id="类型">类型</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("windows.WindowType")}}</dt>
+ <dd>浏览器窗口的类型。</dd>
+ <dt>{{WebExtAPIRef("windows.WindowState")}}</dt>
+ <dd>浏览器窗口的状态。</dd>
+ <dt>{{WebExtAPIRef("windows.Window")}}</dt>
+ <dd>有关一个浏览器窗口的信息。</dd>
+ <dt>{{WebExtAPIRef("windows.CreateType")}}</dt>
+ <dd>指定要创建的浏览器窗口的类型。</dd>
+</dl>
+
+<h2 id="属性">属性</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("windows.WINDOW_ID_NONE")}}</dt>
+ <dd><code>windowId</code> 值表示不存在浏览器窗口。</dd>
+ <dt>{{WebExtAPIRef("windows.WINDOW_ID_CURRENT")}}</dt>
+ <dd><code>windowId</code> 值表示当前窗口。</dd>
+</dl>
+
+<h2 id="函数">函数</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("windows.get()")}}</dt>
+ <dd>指定其 ID,获取一个窗口的细节。</dd>
+ <dt>{{WebExtAPIRef("windows.getCurrent()")}}</dt>
+ <dd>获取当前窗口。</dd>
+ <dt>{{WebExtAPIRef("windows.getLastFocused()")}}</dt>
+ <dd>获取最近获得焦点的窗口,通常它是“顶部”的窗口。</dd>
+ <dt>{{WebExtAPIRef("windows.getAll()")}}</dt>
+ <dd>获取所有窗口。</dd>
+ <dt>{{WebExtAPIRef("windows.create()")}}</dt>
+ <dd>
+ <p>创建新窗口。</p>
+ </dd>
+ <dt>{{WebExtAPIRef("windows.update()")}}</dt>
+ <dd>更新一个窗口的属性。使用此项对移动、调整大小、聚焦/取消聚焦等。</dd>
+ <dt>{{WebExtAPIRef("windows.remove()")}}</dt>
+ <dd>关闭一个窗口及其所有标签页。</dd>
+</dl>
+
+<h2 id="事件">事件</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("windows.onCreated")}}</dt>
+ <dd>一个窗口创建时触发。</dd>
+ <dt>{{WebExtAPIRef("windows.onRemoved")}}</dt>
+ <dd>一个窗口关闭时触发。</dd>
+ <dt>{{WebExtAPIRef("windows.onFocusChanged")}}</dt>
+ <dd>当前有焦点的窗口改变时触发。</dd>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("webextensions.api.windows")}}</p>
+
+<div class="hidden note">
+<p>Chrome 的不兼容 部分列在 <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities"> https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a>,为采用 <a href="/en-US/docs/Template:WebExtChromeCompat">WebExtChromeCompat</a> 宏。</p>
+
+<p>如果您需要更新此内容,编辑 <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities">https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a>,然后按住Shift并刷新此页面以查看您的变更。</p>
+</div>
+
+<h3 id="Edge_的不兼容">Edge 的不兼容</h3>
+
+<p>Edge 中不支持 Promises。需使用回调。</p>
+
+<p>{{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>声明</strong>
+
+<p>此 API 基于 Chromium 的 <a href="https://developer.chrome.com/extensions/windows"><code>chrome.windows</code></a> API。此文档基于 Chromium 代码中的<a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/windows.json"><code> windows.json</code></a>。</p>
+
+<p>Microsoft Edge 兼容性数据由微软公司提供,并包含在创作共用 署名 3.0美国许可证下。</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/windows/windowstate/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/windows/windowstate/index.html
new file mode 100644
index 0000000000..605f2cf071
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/windows/windowstate/index.html
@@ -0,0 +1,66 @@
+---
+title: windows.WindowState
+slug: Mozilla/Add-ons/WebExtensions/API/windows/WindowState
+translation_of: Mozilla/Add-ons/WebExtensions/API/windows/WindowState
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>浏览器窗口的状态。</p>
+
+<h2 id="类型">类型</h2>
+
+<p>类型的值是字符串类型。 可能的值如下:</p>
+
+<ul>
+ <li><code>"normal"</code></li>
+ <li><code>"minimized"</code></li>
+ <li><code>"maximized"</code></li>
+ <li><code>"fullscreen"</code></li>
+ <li><code>"docked"</code></li>
+</ul>
+
+<h2 id="浏览器适配">浏览器适配</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.windows.WindowState")}}</p>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>致谢</strong>
+
+<p>此API基于谷歌浏览器 <a href="https://developer.chrome.com/extensions/windows#type-WindowState"><code>chrome.windows</code></a> API。此文档源于谷歌源码 <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/windows.json"><code>windows.json</code></a> .</p>
+
+<p>微软Edge浏览器兼容性数据由微软公司提供,并包含在美国Creative Commons Attribution 3.0许可证下。</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/windows/windowtype/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/windows/windowtype/index.html
new file mode 100644
index 0000000000..6f9e5572b2
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/windows/windowtype/index.html
@@ -0,0 +1,65 @@
+---
+title: windows.WindowType
+slug: Mozilla/Add-ons/WebExtensions/API/windows/WindowType
+translation_of: Mozilla/Add-ons/WebExtensions/API/windows/WindowType
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>浏览器窗口的类型。</p>
+
+<h2 id="Type">Type</h2>
+
+<p>类型的值是字符串类型。 可能的值如下:</p>
+
+<ul>
+ <li><code>"normal"</code></li>
+ <li><code>"popup"</code></li>
+ <li><code>"panel"</code></li>
+ <li><code>"devtools"</code></li>
+</ul>
+
+<h2 id="浏览器适配">浏览器适配</h2>
+
+
+
+<p>{{Compat("webextensions.api.windows.WindowType")}}</p>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>Acknowledgements</strong>
+
+<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/windows#type-WindowType"><code>chrome.windows</code></a> API. This documentation is derived from <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/windows.json"><code>windows.json</code></a> in the Chromium code.</p>
+
+<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
+</div>
+
+<div class="hidden">
+<pre>// Copyright 2015 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/剪切板/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/剪切板/index.html
new file mode 100644
index 0000000000..5fecb4334f
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/剪切板/index.html
@@ -0,0 +1,36 @@
+---
+title: clipboard
+slug: Mozilla/Add-ons/WebExtensions/API/剪切板
+tags:
+ - 剪切板
+ - 扩展
+ - 附加组件
+translation_of: Mozilla/Add-ons/WebExtensions/API/clipboard
+---
+<div>{{AddonSidebar}}</div>
+
+<p>WebExtention 的 <code>clipboard</code> API 增加了一个将图像复制到剪贴板的函数。目前,这个 API 仅支持复制图像,但我们期望它未来支持复制文本和 HTML(译者注:原文如此,可能是指被支持复制富内容之后的标准剪贴板 API 取代)。</p>
+
+<p>这个  WebExtension API 之所以存在,主要是因为标准的 Web 剪贴板 API <a href="/zh-CN/docs/Web/API/Clipboard_API">Clipboard API</a> 不支持将图像写入剪贴板。一旦标准剪贴板 API 对非文本剪贴板内容的支持进入通用状态,则此 API 可能会被弃用。</p>
+
+<p>Reading from the clipboard is not supported by this API, because the clipboard can already be read using the standard web platform APIs. See <a href="https://wiki.developer.mozilla.org/en-US/Add-ons/WebExtensions/Interact_with_the_clipboard#Reading_from_the_clipboard">Interacting with the clipboard</a>.</p>
+
+<p>This API is based on Chrome's <code><a class="external external-icon" href="https://developer.chrome.com/apps/clipboard">clipboard</a></code> API, but that API is only available for Chrome apps, not extensions.</p>
+
+<p>To use this API you need the <code>"clipboardWrite"</code> extension <a href="https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a>.</p>
+
+<h2 id="函数">函数</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("clipboard.setImageData()")}}</dt>
+ <dd>复制图像到剪切板。</dd>
+</dl>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("webextensions.api.clipboard")}} {{WebExtExamples("h2")}}</p>
+
+<div class="note"><strong>说明</strong>
+
+<p> 此 API 基于 Chromium 的 <a href="https://developer.chrome.com/apps/clipboard"><code>chrome.clipboard</code></a> API.</p>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/剪切板/setimagedata/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/剪切板/setimagedata/index.html
new file mode 100644
index 0000000000..3cdaf45b08
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/剪切板/setimagedata/index.html
@@ -0,0 +1,79 @@
+---
+title: clipboard.setImageData()
+slug: Mozilla/Add-ons/WebExtensions/API/剪切板/setImageData
+tags:
+ - API
+ - Clipboard
+ - 剪贴板
+ - 参考
+ - 拓展
+ - 方法
+translation_of: Mozilla/Add-ons/WebExtensions/API/clipboard/setImageData
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>将图像复制到剪贴板。在将图像写入剪贴板之前,会对图像进行重新编码。如果图像无效,则不会修改剪贴板。</p>
+
+<p>图像被作为包含经过编码的图像的 <code><a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</a></code> 提供。支持 JPEG 和 PNG 格式。</p>
+
+<p>基于 Chrome 的 <code><a href="https://developer.chrome.com/apps/clipboard" rel="noopener">clipboard.setImageData()</a></code> API,但存在一些差异:</p>
+
+<ul>
+ <li>Chrome API 仅适用于应用,不适用于扩展程序。</li>
+ <li>此API需要 <code>"clipboardWrite"</code> 权限,Chrome 版本需要 <code>"clipboard"</code> 权限。</li>
+ <li>Chrome 的 API 使用回调,此 API 使用 Promise。</li>
+ <li>此 API 不支持 <code>additionalItems</code> 参数。</li>
+</ul>
+
+<p>这是一个返回 <code><a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> 的异步函数。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox brush:js">browser.clipboard.setImageData(<em>imageData</em>, <em>imageType</em>)
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>imageData</code></dt>
+ <dd>An <code><a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</a></code> containing the encoded image data to copy to the clipboard.</dd>
+ <dt><code>imageType</code></dt>
+ <dd>A {{domxref("DOMString")}} indicating the type of image contained in <code>imageData</code>: <code>"png"</code> or <code>"jpeg"</code>.</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>A <code><a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> that will be resolved with no arguments if the operation succeeded, or rejected if there was an error (for example, because the data did not represent a valid image).</p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.api.clipboard.setImageData", 10)}}</p>
+
+<h2 id="示例">示例</h2>
+
+<p>Copy a remote image:</p>
+
+<pre class="brush: js" id="ct-71"><span class="quote">// requires:
+// * the host permission for "<a href="https://cdn.mdn.mozilla.net/" rel="nofollow">https://cdn.mdn.mozilla.net/</a>*"
+// * the API permission "clipboardWrite"
+
+fetch('<a href="https://cdn.mdn.mozilla.net/static/img/favicon144.png" rel="nofollow">https://cdn.mdn.mozilla.net/static/img/favicon144.png</a>')
+.then(response =&gt; response.arrayBuffer())
+.then(buffer =&gt; browser.clipboard.setImageData(buffer, 'png'));</span></pre>
+
+<p><span class="quote">Copy an image that was bundled with the extension:</span></p>
+
+<pre class="brush: js" id="ct-70">// requires <span class="quote">the API permission </span>"clipboardWrite"
+
+fetch(browser.runtime.getURL('image.png'))
+.then(response =&gt; response.arrayBuffer())
+.then(buffer =&gt; browser.clipboard.setImageData(buffer, 'png'));</pre>
+
+<p>{{WebExtExamples}}</p>
+
+<div class="note"><strong>说明</strong>
+
+<p> 此 API 基于 Chromium 的 <a href="https://developer.chrome.com/apps/clipboard"><code>chrome.clipboard</code></a> API.</p>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/browser_support_for_javascript_apis/index.html b/files/zh-cn/mozilla/add-ons/webextensions/browser_support_for_javascript_apis/index.html
new file mode 100644
index 0000000000..f2ba32173b
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/browser_support_for_javascript_apis/index.html
@@ -0,0 +1,17 @@
+---
+title: Browser support for JavaScript APIs
+slug: Mozilla/Add-ons/WebExtensions/Browser_support_for_JavaScript_APIs
+tags:
+ - WebExtension
+translation_of: Mozilla/Add-ons/WebExtensions/Browser_support_for_JavaScript_APIs
+---
+<div>{{AddonSidebar}}</div>
+
+<div>{{WebExtAllCompatTables}}</div>
+
+<p class="hidden">此页面的兼容性表格由结构化的数据生成。如果你想为这份数据出一些力,请看看 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 并发给我们一个 pull request。</p>
+
+<div class="note"><strong>致谢</strong>
+
+<p>Microsoft Edge 的兼容性数据由 Microsoft 公司提供,依照知识共享署名 3.0 美国协议授权。</p>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/chrome_incompatibilities/index.html b/files/zh-cn/mozilla/add-ons/webextensions/chrome_incompatibilities/index.html
new file mode 100644
index 0000000000..8cc71470f9
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/chrome_incompatibilities/index.html
@@ -0,0 +1,154 @@
+---
+title: Chrome 不兼容情况
+slug: Mozilla/Add-ons/WebExtensions/Chrome_incompatibilities
+tags:
+ - WebExtensions
+translation_of: Mozilla/Add-ons/WebExtensions/Chrome_incompatibilities
+---
+<div>{{AddonSidebar}}</div>
+
+<p>使用WebExtension API构建的扩展旨在与Chrome和Opera扩展兼容:尽可能为这些浏览器编写的扩展应该在Firefox上运行,并且只需进行极少的更改。</p>
+
+<p>但是,Firefox目前仅支持Chrome和Opera支持的有限功能和API。 我们正在努力增加更多的支持,但许多功能尚未得到支持,我们可能永远不会支持某些功能。</p>
+
+<h2 id="JavaScript_APIs">JavaScript APIs</h2>
+
+<h3 id="回调与_chrome.*_命名空间">回调与 chrome.* 命名空间</h3>
+
+<p>在 Chrome 中,扩展通过使用 <code>chrome</code> 命名空间来访问私有 JavaScript API:</p>
+
+<pre class="brush: js line-numbers language-js">chrome.browserAction.setIcon({path: "path/to/icon.png"});</pre>
+
+<p>WebExtensions 通过使用 <code>browser</code> 命名空间来访问等价的 API:</p>
+
+<pre class="brush: js line-numbers language-js">browser.browserAction.setIcon({path: "path/to/icon.png"});</pre>
+
+<p>许多 API 是异步的。在 Chrome 中,异步的 API 使用回调来返回值,使用 {{WebExtAPIRef("runtime.lastError")}} 来与传达错误:</p>
+
+<pre class="brush: js line-numbers language-js">function logCookie(c) {
+ if (chrome.extension.lastError) {
+ console.error(chrome.extension.lastError);
+ } else {
+ console.log(c);
+ }
+}
+
+chrome.cookies.set(
+ {url: "https://developer.mozilla.org/"},
+ logCookie
+);</pre>
+
+<p>在 WebExtensions 中应使用 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">promises</a> 来访问等价的 API:</p>
+
+<pre class="brush: js ">function logCookie(c) {
+ console.log(c);
+}
+
+function logError(e) {
+ console.error(e);
+}
+
+var setCookie = browser.cookies.set(
+ {url: "https://developer.mozilla.org/"}
+);
+setCookie.then(logCookie, logError);
+</pre>
+
+<h3 id="Firefox_支持_chrome_和_browser_命名空间">Firefox 支持 <code>chrome</code> 和 <code>browser</code> 命名空间</h3>
+
+<p>为了帮助移植,Firefox 的 WebExtension 实现支持 <code>chrome</code> 与回调和 <code>browser</code> 与 promise。这意味着许多 Chrome 扩展无须修改就能在 Firefox 上运行。然而并不是 WebExtension 标准的一部分,也许不会被所有兼容 WebExtension的浏览器支持。</p>
+
+<p>如果你在编写 WebExtension 时确实要用到 <code>browser</code> 和 promise,我们也开发了polyfill 来保证扩展可以在 Chrome 里运行:<a href="https://github.com/mozilla/webextension-polyfill">https://github.com/mozilla/webextension-polyfill</a>.</p>
+
+<h3 id="部分受支持的_API">部分受支持的 API</h3>
+
+<p>页面 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Browser_support_for_JavaScript_APIs">JavaScript API 的浏览器支持情况</a> 包含了介绍受 Firefox 任意程度支持的 API 的兼容性表格。若对 API 的支持存在须要注意的事项,并标有星号“*”,且在 API 的参考页面会介绍注意事项。</p>
+
+<p>这些表格由 <a href="https://github.com/mdn/browser-compat-data">在 GitHub 上以 JSON 文件存储的兼容性数据</a>生成。</p>
+
+<p>本节剩余部分介绍了表格未涵盖的兼容性问题。</p>
+
+<h4 id="notifications"><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/notifications">notifications</a></h4>
+
+<ul>
+ <li>For <code>notifications.create(), with the "basic"</code> <code><a href="/en-US/Add-ons/WebExtensions/API/notifications/TemplateType">type</a></code>, <code>iconUrl</code> is optional in Firefox. It is required in Chrome.</li>
+ <li>Notifications are cleared immediately when the user clicks on them. This is not the case in Chrome.</li>
+ <li>If you call <code>notifications.create()</code> more than once in rapid succession, Firefox may end up not displaying any notification at all. Waiting to make subsequent calls until within the <code>chrome.notifications.create() callback</code> function is not a sufficiently long delay to prevent this from happening.</li>
+</ul>
+
+<h4 id="proxy"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/proxy">proxy</a></h4>
+
+<ul>
+ <li>This API is completely different to the design of the Chrome API. With Chrome's API an extension can register a PAC file, but can also define explicit proxying rules. Since this is also possible using the extended PAC files, this API only supports the PAC file approach. Because this API is incompatible with the Chrome <code>proxy</code> API, this API is only available through the <code>browser</code> namespace.</li>
+</ul>
+
+<h4 id="tabs"><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs">tabs</a></h4>
+
+<ul>
+ <li>
+ <p>In Firefox, relative URLs passed into <code>tabs.executeScript()</code> or <code>tabs.insertCSS()</code> are resolved relative to the current page URL. In Chrome, these URLs are resolved relative to the add-on's base URL. To work cross-browser, you can specify the path as an absolute URL, starting at the add-on's root, like this:</p>
+
+ <pre class="brush: html">/path/to/script.js</pre>
+ </li>
+ <li>在 Firefox 中,用 <code>tabs.query() </code>根据 URL 查询标签页需要有<code>"tabs"</code> 权限。在 Chrome 中,没有<code>"tabs"</code>权限也可以,但结果将限制在 URL 匹配主机权限的标签页。</li>
+</ul>
+
+<h4 id="webRequest"><a href="/en-US/Add-ons/WebExtensions/API/webRequest">webRequest</a></h4>
+
+<ul>
+ <li>在Firefx中,只有原网址使用 <code>http:</code> <code>或 https:</code> 协议时所请求的重定向才有效。</li>
+ <li>In Firefox, events are not fired for system requests (for example, extension upgrades or searchbar suggestions). From Firefox 57 onwards, Firefox makes an exception for extensions that need to intercept {{WebExtAPIRef("webRequest.onAuthRequired")}} for proxy authorization. See the documentation for {{WebExtAPIRef("webRequest.onAuthRequired")}}.</li>
+ <li>In Firefox, if an extension wants to redirect a public (e.g. HTTPS) URL to an <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Extension_pages">extension page</a>, the extension's manifest.json file must contain a <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/web_accessible_resources">web_accessible_resources</a> key that lists the URL for the extension page. Note that any website may then link or redirect to that url, and extensions should treat any input (POST data, for examples) as if it came from an untrusted source, just as a normal web page should.</li>
+</ul>
+
+<h4 id="windows"><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/windows">windows</a></h4>
+
+<ul>
+ <li>Firefox 中 <code>onFocusChanged</code> 对于指定的焦点变化将触发多次。</li>
+</ul>
+
+<h3 id="其他不兼容情况">其他不兼容情况</h3>
+
+<h4 id="CSS_中的_URL">CSS 中的 URL</h4>
+
+<p>Firefox 解析 CSS 中嵌入的 URL  时,若 URL 时相对地址,将是相对 CSS 文件,而不是被嵌入的网页文件。</p>
+
+<h4 id="更多不兼容情况">更多不兼容情况</h4>
+
+<p>Firefox 不支持从后台标签页使用 <code><a href="/en-US/docs/Web/API/Window/alert">alert()、</a><a href="/en-US/docs/Web/API/Window/confirm">confirm()</a></code> 或<code><a href="/en-US/docs/Web/API/Window/prompt"> prompt()</a></code>。</p>
+
+<h4 id="web_accessible_resources">web_accessible_resources</h4>
+
+<p>在 Chrome 中,若资源在 web_accessible_resources 中列出,即可通过 chrome-extension://&lt;your-extension-id&gt;/&lt;path/to/resource&gt; 访问。每个扩展的 ID 都是固定的。</p>
+
+<p>Firefox 以不同方式进行实现。它使用一个随机的 UUID,在每个 Firefox 实例中都不同:moz-extension://&lt;random-UUID&gt;/&lt;path/to/resource&gt;。这一随机性可能会让你无法实现某些东西,例如你无法将特定扩展的 URL 添加到另一个域名的 CSP 策略中。</p>
+
+<h4 id="Manifest_key_属性">Manifest "key" 属性</h4>
+
+<p>对于解包了的扩展,Chrome 允许将 <a href="https://developer.chrome.com/extensions/manifest/key">"key" 属性</a>添加到 manifest,以确保在不同机器上的扩展 ID 不变。这主要在使用 web_accessible_resources 时有用。鉴于 Firefox 为 web_accessible_resources 使用随机的 UUID,此属性不受支持。</p>
+
+<h4 id="Content_script_requests_happen_in_the_context_of_extension_not_content_page">Content script requests happen in the context of extension, not content page</h4>
+
+<p>In Chrome when request is called (for example, using <code><a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch">fetch()</a></code>) to relative URL like <code>/api</code> from content script, it will be sent to <code>https://example.com/api</code>. In Firefox you have to provide absolute URLs. </p>
+
+<h2 id="manifest.json_键">manifest.json 键</h2>
+
+<p>The main <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a> page includes a table describing browser support for manifest.json keys. Where there are caveats around support for a given key, this is indicated in the table with an asterisk "*" and in the reference page for the key, the caveats are explained.</p>
+
+<p>These tables are generated from compatibility data stored as <a href="https://github.com/mdn/browser-compat-data">JSON files in GitHub</a>.</p>
+
+<h2 id="Native_messaging">Native messaging</h2>
+
+<h3 id="Command-line_arguments">Command-line arguments</h3>
+
+<p>On Linux and Mac, Chrome passes one argument to the native app, which is the origin of the extension that started it, in the form: <code>chrome-extension://[extensionID]</code>. This enables the app to identify the extension.</p>
+
+<p>On Windows, Chrome passes two arguments: the first is the origin of the extension, and the second is a handle to the Chrome native window that started the app.</p>
+
+<h3 id="allowed_extensions">allowed_extensions</h3>
+
+<p>In Chrome, the <code>allowed_extensions</code> key in the app manifest is called <code>allowed_origins</code> instead.</p>
+
+<h3 id="App_manifest_location">App manifest location</h3>
+
+<p>Chrome expects to find the app manifest in a different place. See <a href="https://developer.chrome.com/extensions/nativeMessaging#native-messaging-host-location">Native messaging host location</a> in the Chrome docs. </p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/content_scripts/index.html b/files/zh-cn/mozilla/add-ons/webextensions/content_scripts/index.html
new file mode 100644
index 0000000000..4fe6a88055
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/content_scripts/index.html
@@ -0,0 +1,575 @@
+---
+title: Content scripts
+slug: Mozilla/Add-ons/WebExtensions/Content_scripts
+translation_of: Mozilla/Add-ons/WebExtensions/Content_scripts
+---
+<div>{{AddonSidebar}}</div>
+
+<p>Content script 是你扩展的一部分,运行于一个特定的网页环境(而并不是后台脚本,后台脚本是扩展的一部分,也不是该网页利用 {{HTMLElement("script")}} 加载的一个脚本,{{HTMLElement("script")}} 加载的脚本是网页的一部分)。</p>
+
+<p>后台脚本可以访问所有WebExtension JavaScript APIS,但是他们不能直接访问网页的内容,所以如果你需要Content Scripts来做到这点。</p>
+
+<p>就像通常的网页加载的脚本一样,Content Scripts 可以使用standard DOM APIS 读取和修改页面内容。</p>
+
+<p>Content Script 只能访问WebExtension APIS 的一个小的子集,但是它们可以使用通信系统与后台脚本进行通信,从而间接的访问WebExtension APIS。</p>
+
+<div class="note">
+<p>注意content scripts 在addons.mozilla.org现在已被禁止,如果你在这个域名尝试插入一个Content script将会失败而这个页面会LOG一个CSP错误。</p>
+</div>
+
+<h2 id="加载Content_scripts">加载Content scripts</h2>
+
+<p>你可以通过两种方法之一在一个页面加载Content script:</p>
+
+<ul>
+ <li><strong>声明式</strong>: 在你的manifest.json中使用content_scripts关键字,你可以要求浏览器每当加载一个与指定正则表达式匹配的网页时加载一个Content Script。</li>
+ <li><strong>程序式</strong>: 使用 <code><a href="/en-US/Add-ons/WebExtensions/API/Tabs/executeScript">tabs.executeScript()</a></code> API, 你可以在任何你想要的时候加载一个Content script 到一个指定的标签:比如,作为用户点击事件的回应。</li>
+</ul>
+
+<p>在每一个extension的每一个frame中,只有一个全局作用域。所以在一个content script中的变量可以被另外的content script访问到,而与content script如何被加载无关。</p>
+
+<h2 id="Content_script_环境">Content script 环境</h2>
+
+<h3 id="DOM_访问">DOM 访问</h3>
+
+<p>Content scripts 可以访问和修改页面的DOM,就像普通的页面脚本一样。他们也可以察觉页面脚本对页面做出的任何修改。</p>
+
+<p>不过,content scripts 得到的是一个“干净的DOM视图”,这意味着:</p>
+
+<ul>
+ <li>content scripts 不能看见页面脚本定义的javascript 变量。</li>
+ <li>如果一个页面脚本重定义了一个DOM内置属性,content scripts将获取到这个属性的原始版本,而不是重定义版本。</li>
+</ul>
+
+<p>在 Gecko(译者注:Gecko是由 Mozilla 工程开发出的布局引擎的名字), 这种行为被称为射线视觉。</p>
+
+<p>举个例子,考虑一个网页如下:</p>
+
+<pre class="brush: html">&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+ &lt;head&gt;
+ &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
+ &lt;/head&gt;
+
+ &lt;body&gt;
+ &lt;script src="page-scripts/page-script.js"&gt;&lt;/script&gt;
+ &lt;/body&gt;
+&lt;/html&gt;</pre>
+
+<p>脚本文件“page-script.js”如下:</p>
+
+<pre class="brush: js">// page-script.js
+
+// add a new element to the DOM
+var p = document.createElement("p");
+p.textContent = "This paragraph was added by a page script.";
+p.setAttribute("id", "page-script-para");
+document.body.appendChild(p);
+
+// define a new property on the window
+window.foo = "This global variable was added by a page script";
+
+// redefine the built-in window.confirm() function
+window.confirm = function() {
+ alert("The page script has also redefined 'confirm'");
+}</pre>
+
+<p>现在一个扩展插入一个content script 如下:</p>
+
+<pre class="brush: js">// content-script.js
+
+// can access and modify the DOM
+var pageScriptPara = document.getElementById("page-script-para");
+pageScriptPara.style.backgroundColor = "blue";
+
+// can't see page-script-added properties
+console.log(window.foo); // undefined
+
+// sees the original form of redefined properties
+window.confirm("Are you sure?"); // calls the original window.confirm()</pre>
+
+<p>相反的情况也是成立的:页面脚本不能察觉到通过content scripts 添加的JavaScript 属性。</p>
+
+<p>这意味着content script 可以依靠DOM属性获取可预期的行为</p>
+
+<p>这种行为造成的一个结果是content script不能获取任何通过页面加载的Javascript 库。所以,如果这个页面包含JQuery,content script 将不会在意它。</p>
+
+<p>如果一个content script 想要使用Javascript库,这个库本身就必须像一个content script一样在这个content script旁被插入:</p>
+
+<pre class="brush: json">"content_scripts": [
+ {
+ "matches": ["*://*.mozilla.org/*"],
+ "js": ["jquery.js", "content-script.js"]
+ }
+]</pre>
+
+<h3 id="WebExtension_APIs">WebExtension APIs</h3>
+
+<p>除了standard DOM APIS,content script还能使用以下WebExtension APIS:</p>
+
+<p>From <code><a href="/en-US/Add-ons/WebExtensions/API/extension">extension</a></code>:</p>
+
+<ul>
+ <li><code><a href="/en-US/Add-ons/WebExtensions/API/extension#getURL()">getURL()</a></code></li>
+ <li><code><a href="/en-US/Add-ons/WebExtensions/API/extension#inIncognitoContext">inIncognitoContext</a></code></li>
+</ul>
+
+<p>From <code><a href="/en-US/Add-ons/WebExtensions/API/runtime">runtime</a></code>:</p>
+
+<ul>
+ <li><code><a href="/en-US/Add-ons/WebExtensions/API/runtime#connect()">connect()</a></code></li>
+ <li><code><a href="/en-US/Add-ons/WebExtensions/API/runtime#getManifest()">getManifest()</a></code></li>
+ <li><code><a href="/en-US/Add-ons/WebExtensions/API/runtime#getURL()">getURL()</a></code></li>
+ <li><code><a href="/en-US/Add-ons/WebExtensions/API/runtime#onConnect">onConnect</a></code></li>
+ <li><code><a href="/en-US/Add-ons/WebExtensions/API/runtime#onMessage">onMessage</a></code></li>
+ <li><code><a href="/en-US/Add-ons/WebExtensions/API/runtime#sendMessage()">sendMessage()</a></code></li>
+</ul>
+
+<p>From <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/i18n">i18n</a></code>:</p>
+
+<ul>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/i18n/getMessage">getMessage()</a></code></li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/i18n/getAcceptLanguages">getAcceptLanguages()</a></code></li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/i18n/getUILanguage">getUILanguage()</a></code></li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/i18n/detectLanguage">detectLanguage()</a></code></li>
+</ul>
+
+<p>所有 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage">storage</a></code>.</p>
+
+<h3 id="跨域名权限">跨域名权限</h3>
+
+<p>content scripts 拥有与扩展剩余部分一致的权限:所以如果这个扩展已在manifest.json文件中使用permission关键字请求跨域权限,其content script将能很好获取某些跨域权限。</p>
+
+<h2 id="后台脚本通信">后台脚本通信</h2>
+
+<p>尽管content scripts 不能直接使用大部分WebExtension APIS,但他们可以通过使用messaging APIS 与扩展的后台脚本通信,然后便能够间接地调用所有的后台脚本能够调用的APIS。</p>
+
+<p>在background script和content script中有两种基本的通讯方式:你可以发送带有可选回复的一次性的消息,或者在两者之间建立一个长期活动的连接并用这个连接来进行信息交换。</p>
+
+<h3 id="一次性消息">一次性消息</h3>
+
+<p>为了发送一个带有可选回复选项的一次性消息,你能使用以下APIS:</p>
+
+<table class="fullwidth-table standard-table">
+ <thead>
+ <tr>
+ <th scope="row"> </th>
+ <th scope="col">In content script</th>
+ <th scope="col">In background script</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th scope="row">Send a message</th>
+ <td><code><a href="/en-US/Add-ons/WebExtensions/API/runtime#sendMessage()">browser.runtime.sendMessage()</a></code></td>
+ <td><code><a href="/en-US/Add-ons/WebExtensions/API/Tabs/sendMessage">browser.tabs.sendMessage()</a></code></td>
+ </tr>
+ <tr>
+ <th scope="row">Receive a message</th>
+ <td><code><a href="/en-US/Add-ons/WebExtensions/API/runtime/onMessage">browser.runtime.onMessage</a></code></td>
+ <td><code><a href="/en-US/Add-ons/WebExtensions/API/runtime#onMessage">browser.runtime.onMessage</a></code></td>
+ </tr>
+ </tbody>
+</table>
+
+<p>举例,这里是一个监听点击事件的content script,如果点击发生在一个链接上,他将会将该链接的地址发送给后台脚本:</p>
+
+<pre class="brush: js">// content-script.js
+
+window.addEventListener("click", notifyExtension);
+
+function notifyExtension(e) {
+ if (e.target.tagName != "A") {
+ return;
+ }
+ browser.runtime.sendMessage({"url": e.target.href});
+}</pre>
+
+<p>后台脚本监听这个消息然后使用<code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/notifications">notifications</a></code> API 显示一个通知:</p>
+
+<pre class="brush: js">// background-script.js
+
+browser.runtime.onMessage.addListener(notify);
+
+function notify(message) {
+ browser.notifications.create({
+ "type": "basic",
+ "iconUrl": browser.extension.getURL("link.png"),
+ "title": "You clicked a link!",
+ "message": message.url
+ });
+}
+</pre>
+
+<p>这个示范代码从Github上的 <a href="https://github.com/mdn/webextensions-examples/tree/master/notify-link-clicks-i18n">notify-link-clicks-i18n</a> 例子 修改而来.</p>
+
+<h3 id="Connection-based_messaging">Connection-based messaging</h3>
+
+<p>如果你将在一个content script 和 后台脚本间交换大量的消息,一次性消息会变得笨重而缓慢。所以一个更好的方案是在两个脚本间建立一个长久连接,然后使用该连接交换消息。</p>
+
+<p>每个脚本都有一个 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/Port">runtime.Port</a></code> 对象用以交换消息。</p>
+
+<p>建立过程::</p>
+
+<ul>
+ <li>
+ <p>在一个脚本中使用 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onConnect">runtime.onConnect</a></code> 监听连接</p>
+ </li>
+ <li>另一个脚本中调用 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/connect">tabs.connect()</a></code> (如果连接 content script) or <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/connect">runtime.connect()</a></code> (如果连接后台脚本). 这会返回一个 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/Port">runtime.Port</a></code> 对象.</li>
+ <li> <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onConnect">runtime.onConnect</a></code>  传递它自己的 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/Port">runtime.Port</a></code> 对象.</li>
+</ul>
+
+<p>每个脚本都拥有一个port,两个脚本可以使用runtime.Port.postMessage()来发送消息,runtime.Port.onMessage 来接收消息</p>
+
+<p>比如,当加载该content script时:</p>
+
+<ul>
+ <li>连接到后台脚本,存取Port对象至 <code>myPort</code></li>
+ <li>监听myPort上的消息,并记录。</li>
+ <li>当用户点击网页是发送消息至后台脚本。</li>
+</ul>
+
+<pre class="brush: js">// content-script.js
+
+var myPort = browser.runtime.connect({name:"port-from-cs"});
+myPort.postMessage({greeting: "hello from content script"});
+
+myPort.onMessage.addListener(function(m) {
+ console.log("In content script, received message from background script: ");
+ console.log(m.greeting);
+});
+
+document.body.addEventListener("click", function() {
+ myPort.postMessage({greeting: "they clicked the page!"});
+});</pre>
+
+<p>对应的后台脚本:</p>
+
+<ul>
+ <li>监听content script 的所有连接企图。</li>
+ <li>当收到连接请求后:
+ <ul>
+ <li>存贮Port对象至 <code>portFromCS</code></li>
+ <li>使用portFromCS发送一个消息到content script</li>
+ <li>开始监听消息并记录它们。</li>
+ </ul>
+ </li>
+ <li>当用户点击浏览器的某些扩展按钮或动作后,发送一个消息到content script。</li>
+</ul>
+
+<pre class="brush: js">// background-script.js
+
+var portFromCS;
+
+function connected(p) {
+ portFromCS = p;
+ portFromCS.postMessage({greeting: "hi there content script!"});
+ portFromCS.onMessage.addListener(function(m) {
+ console.log("In background script, received message from content script")
+ console.log(m.greeting);
+ });
+}
+
+browser.runtime.onConnect.addListener(connected);
+
+browser.browserAction.onClicked.addListener(function() {
+ portFromCS.postMessage({greeting: "they clicked the button!"});
+});
+</pre>
+
+<p> <a href="https://github.com/mdn/webextensions-examples/tree/master/inpage-toolbar-ui">inpage-toolbar-ui</a> 例子使用了 connection-based messaging.</p>
+
+<ul>
+</ul>
+
+<h2 id="网页通信">网页通信</h2>
+
+<p>尽管content script 通常不能获取由网页脚本创建的对象,但他们可以通过 <code><a href="/en-US/docs/Web/API/Window/postMessage">window.postMessage</a></code> 和 <code><a href="/en-US/docs/Web/API/EventTarget/addEventListener">window.addEventListener</a></code> APIs 与网页脚本进行通信.</p>
+
+<p>比如:</p>
+
+<pre class="brush: js">// page-script.js
+
+var messenger = document.getElementById("from-page-script");
+
+messenger.addEventListener("click", messageContentScript);
+
+function messageContentScript() {
+ window.postMessage({
+ direction: "from-page-script",
+ message: "Message from the page"
+ }, "*");</pre>
+
+<pre class="brush: js">// content-script.js
+
+window.addEventListener("message", function(event) {
+ if (event.source == window &amp;&amp;
+ event.data.direction &amp;&amp;
+ event.data.direction == "from-page-script") {
+ alert("Content script received message: \"" + event.data.message + "\"");
+ }
+});</pre>
+
+<p>完整的例子请访问该链接, <a href="https://mdn.github.io/webextensions-examples/content-script-page-script-messaging.html">visit the demo page on GitHub</a> 并且观看以下介绍.</p>
+
+<div class="warning">
+<p>需要注意的是当你用该方法与一些不被信任的网页进行交互式需要特别小心。WebExtensions拥有高等级权限,而一些恶意页面可以很轻松的获取这些权限。</p>
+
+<p>做一个微小的示范,假定有如下content script 代码:</p>
+
+<pre class="brush: js">// content-script.js
+
+window.addEventListener("message", function(event) {
+ if (event.source == window &amp;&amp;
+ event.data.direction &amp;&amp;
+ event.data.direction == "from-page-script") {
+ eval(event.data.message);
+ }
+});</pre>
+
+<p>现在网页脚本可以在content script 权限范围内运行任何代码。</p>
+</div>
+
+<h2 id="与页面脚本共享对象">与页面脚本共享对象</h2>
+
+<div class="note">
+<p>这个部分的技术描述只适用于49版本后的Firefox</p>
+</div>
+
+<div class="warning">
+<p>作为一个插件开发者你必须考虑脚本运行在任何伺机偷取用户个人隐私,破坏他们的电脑,或者使用其他方式攻击的网页上。</p>
+
+<p>隔离content script 和 页面脚本 便是为了使恶意网页的攻击变得更加困难。</p>
+
+<p>这部分的技术打破了这个隔离,它们从根本上是危险的而应该被谨慎使用。</p>
+</div>
+
+<p>我们在 <a href="/en-US/Add-ons/WebExtensions/Content_scripts#DOM_access">DOM access</a> 中看到content scripts不会察觉到通过网页脚本修改的某些属性. 这意味着,如果一个网页加载了一个库比如JQuery,content script 将不会使用它,而不得不加载它自己的一个复制。相反的,网页加载的脚本也不能获知content script的修改。</p>
+
+<p>然而,Firefox提供了一些APIS 可以使得content script能够:</p>
+
+<ul>
+ <li>访问页面脚本创建的Javascript 对象</li>
+ <li>暴露他们自己的JavaScript对象给页面脚本.</li>
+</ul>
+
+<h3 id="Xray_vision_in_Firefox">Xray vision in Firefox</h3>
+
+<p>在Firefox中,隔离content script 和页面脚本通过使用一种称为“Xray vision”的功能实现。 当一个处于更高权限的脚本访问一个被定义于一个更低权限版本的域中时,它将只能看见这个对象的原始版本。</p>
+
+<p>任何 <a href="/en-US/docs/Glossary/Expando">expando</a> 属性都是不可见得, 而且如果对象的任何属性被重定义,他也只能能看见原始的实现而不是重定义的实现。</p>
+
+<p>这个功能的目的是为了让低权限的脚本不至于因为重定义原始对象属性而使高权限脚本行为异常。</p>
+
+<p>让我们来举个例子,当一个content script 访问一个页面的 <a href="/en-US/docs/Web/API/Window">window</a> 类,他不会看见任何该页面脚本对这个window 添加的任何属性, 如果页面脚本重定义了任何已存在的属性,content script将只能看见该属性的原始版本。</p>
+
+<p>更多信心请查看 <a href="/en-US/docs/Mozilla/Tech/Xray_vision">Xray vision</a> 和 <a href="/en-US/docs/Mozilla/Gecko/Script_security">Script security</a>.</p>
+
+<h3 id="从content_script_中访问_页面脚本对象">从content script 中访问 页面脚本对象</h3>
+
+<p>在Firefox中,content script中的DOM对象会获得一个额外的属性 wrappedJSObject。这是一个会包含任何由页面脚本所造成修改的”未包裹“对象。</p>
+
+<p>让我们来看一个简单的例子,假定一个页面载入脚本如下:</p>
+
+<pre class="brush: html">&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+ &lt;head&gt;
+ &lt;meta charset="UTF-8"&gt;
+ &lt;/head&gt;
+ &lt;body&gt;
+ &lt;script type="text/javascript" src="main.js"&gt;&lt;/script&gt;
+ &lt;/body&gt;
+&lt;/html&gt;</pre>
+
+<p><code>这个脚本添加一个全局的属性到全局window</code>:</p>
+
+<pre class="brush: js">// main.js
+
+var foo = "I'm defined in a page script!";</pre>
+
+<p>Xray vision 意味着 如果一个content script 尝试访问foo,它将是未定义的:</p>
+
+<pre class="brush: js">// content-script.js
+
+console.log(window.foo); // undefined</pre>
+
+<p>在Firefox,content script 可以使用window.wrappedJSObject来看见全局属性:</p>
+
+<pre class="brush: js">// content-script.js
+
+console.log(window.wrappedJSObject.foo); // "I'm defined in a page script!"</pre>
+
+<p>注意因为这个原因,你最好不在依赖该对象的任何属性或方法 建立或执行某些操作,你所期望的,它们,甚至setter和getter 都可能被不被信任的代码重定义。</p>
+
+<p>同时注意unwarapping是及物的:当你使用wrappedJSObject,该未包裹对象的任何属性都是未包裹的(同时都是不可靠的),所以 一个好的建议是只在你需要时获取这个对象,重新包裹他,你能这样做:</p>
+
+<pre class="bz_comment_text" id="comment_text_38">XPCNativeWrapper(window.wrappedJSObject.foo);</pre>
+
+<p>查看 <a href="/en-US/docs/Mozilla/Tech/Xray_vision">Xray vision </a>  文档获取更多.</p>
+
+<h3 id="与页面脚本共享content_script_对象">与页面脚本共享content script 对象</h3>
+
+<p>Firefox 同样提供APIS允许content scripts 是对象对于页面脚本可用。这里是两个主要的APIS:</p>
+
+<ul>
+ <li><code><a href="/en-US/Add-ons/WebExtensions/Content_scripts#exportFunction">exportFunction()</a></code>: 导出一个函数至页面脚本</li>
+ <li><code><a href="/en-US/Add-ons/WebExtensions/Content_scripts#cloneInto">cloneInto()</a></code>: 导出一个对象至页面脚本</li>
+</ul>
+
+<h4 id="exportFunction">exportFunction</h4>
+
+<p>给予一个定义于content script中的方法,exportFunction()导出他至页面脚本域,然后脚本可以调用它。</p>
+
+<p>比如,让我们考虑一个WebExtension有一个后台脚本如下:</p>
+
+<pre class="brush: js">/*
+Execute content script in the active tab.
+*/
+function loadContentScript() {
+ browser.tabs.executeScript({
+ file: "/content_scripts/export.js"
+ });
+}
+
+/*
+Add loadContentScript() as a listener to clicks
+on the browser action.
+*/
+browser.browserAction.onClicked.addListener(loadContentScript);
+
+/*
+Show a notification when we get messages from
+the content script.
+*/
+browser.runtime.onMessage.addListener((message) =&gt; {
+ browser.notifications.create({
+ type: "basic",
+ title: "Message from the page",
+ message: message.content
+ });
+});</pre>
+
+<p>该脚本做了两件事:</p>
+
+<ul>
+ <li>当用户点击浏览器按钮时,在当前标签执行一个content script 。</li>
+ <li>监听从content script 传递的消息,并在消息到达时显示一个通知。</li>
+</ul>
+
+<p>content script 如下:</p>
+
+<pre class="brush: js">/*
+Define a function in the content script's scope, then export it
+into the page script's scope.
+*/
+function notify(message) {
+ browser.runtime.sendMessage({content: "Function call: " + message});
+}
+
+exportFunction(notify, window, {defineAs:'notify'});</pre>
+
+<p>该脚本定义了一个函数notify()用以发送其参数到后台脚本,而后他导出了这个函数至页面脚本域。现在页面脚本可以调用该函数:</p>
+
+<pre class="brush: js">window.notify("Message from the page script!");</pre>
+
+<p>更详细的信息请看, <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.exportFunction">Components.utils.exportFunction</a></code>.</p>
+
+<h4 id="cloneInto">cloneInto</h4>
+
+<p>给予一个定义于content script的对象, 该技术可以创建该对象的一个复制到页面脚本域,从而使该复制可以被页面脚本访问.通常使用 <a href="/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm">structured clone algorithm</a> 复制对象, 这意味着该对象中的方法不会被复制为了复制方法,需要传递cloneFunction选项.</p>
+
+<p>比如,这里有一个content script 定义了一个包含方法的对象,然后复制他们至页面脚本域:</p>
+
+<pre class="brush: js">/*
+Create an object that contains functions in
+the content script's scope, then clone it
+into the page script's scope.
+
+Because the object contains functions,
+the cloneInto call must include
+the `cloneFunctions` option.
+*/
+var messenger = {
+ notify: function(message) {
+ browser.runtime.sendMessage({
+ content: "Object method call: " + message
+ });
+ }
+};
+
+window.wrappedJSObject.messenger = cloneInto(
+ messenger,
+ window,
+ {cloneFunctions: true});</pre>
+
+<p><code>现在页面脚本将看到新的含有notify方法的属性</code>:</p>
+
+<pre class="brush: js">window.messenger.notify("Message from the page script!");</pre>
+
+<p>详情请看 <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.cloneInto">Components.utils.cloneInto</a></code>.</p>
+
+<h2 id="在content_script中使用_eval()">在content script中使用 eval()</h2>
+
+<p>在 Chrome中,<code>eval()</code> 总是在content script的上下文环境中运行, 而不是在页面的上下文环境中运行.</p>
+
+<p>在Firefox中:</p>
+
+<ul>
+ <li>如果你调用<code>eval()</code>,它在content script的上下文中运行</li>
+ <li>如果你调用<code>window.eval()</code>,它在页面的上下文中运行</li>
+</ul>
+
+<p>比如,有一个content script如下:</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="comment token">// content-script.js</span>
+
+window<span class="punctuation token">.</span><span class="function token">eval</span><span class="punctuation token">(</span><span class="string token">'window.x = 1;'</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+<span class="function token">eval</span><span class="punctuation token">(</span><span class="string token">'window.y = 2'</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+
+console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="template-string token"><span class="string token">`In content script, window.x: </span><span class="interpolation token"><span class="interpolation-punctuation punctuation token">${</span>window<span class="punctuation token">.</span>x<span class="interpolation-punctuation punctuation token">}</span></span><span class="string token">`</span></span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="template-string token"><span class="string token">`In content script, window.y: </span><span class="interpolation token"><span class="interpolation-punctuation punctuation token">${</span>window<span class="punctuation token">.</span>y<span class="interpolation-punctuation punctuation token">}</span></span><span class="string token">`</span></span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+
+window<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>
+ message<span class="punctuation token">:</span> <span class="string token">"check"</span>
+<span class="punctuation token">}</span><span class="punctuation token">,</span> <span class="string token">"*"</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+
+<p>这段代码仅仅通过调用<code>window.eval()</code> 和 <code>eval()</code>创建了变量x和y。然后记录它们的值并通知页面更新.</p>
+
+<p>接收到消息后页面的脚本记录下这些变量:</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js">window<span class="punctuation token">.</span><span class="function token">addEventListener</span><span class="punctuation token">(</span><span class="string token">"message"</span><span class="punctuation token">,</span> <span class="keyword token">function</span><span class="punctuation token">(</span>event<span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ <span class="keyword token">if</span> <span class="punctuation token">(</span>event<span class="punctuation token">.</span>source <span class="operator token">===</span> window <span class="operator token">&amp;&amp;</span> event<span class="punctuation token">.</span>data <span class="operator token">&amp;&amp;</span> event<span class="punctuation token">.</span>data<span class="punctuation token">.</span>message <span class="operator token">===</span> <span class="string token">"check"</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="template-string token"><span class="string token">`In page script, window.x: </span><span class="interpolation token"><span class="interpolation-punctuation punctuation token">${</span>window<span class="punctuation token">.</span>x<span class="interpolation-punctuation punctuation token">}</span></span><span class="string token">`</span></span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+ console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="template-string token"><span class="string token">`In page script, window.y: </span><span class="interpolation token"><span class="interpolation-punctuation punctuation token">${</span>window<span class="punctuation token">.</span>y<span class="interpolation-punctuation punctuation token">}</span></span><span class="string token">`</span></span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+ <span class="punctuation token">}</span>
+<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+
+<p>在Chrome中,输出类似下面所示:</p>
+
+<pre class="line-numbers language-html"><code class="language-html">In content script, window.x: 1
+In content script, window.y: 2
+In page script, window.x: undefined
+In page script, window.y: undefined</code></pre>
+
+<p>在Firefox中,输出类似下面所示:</p>
+
+<pre class="line-numbers language-html"><code class="language-html">In content script, window.x: undefined
+In content script, window.y: 2
+In page script, window.x: 1
+In page script, window.y: undefined</code></pre>
+
+<p>上述内容同样适用于 <code><a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout">setTimeout()</a></code>, <code><a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval">setInterval()</a></code>, and <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function()</a></code>.</p>
+
+<p>当在页面的上下文中运行代码时, 适用于上面所提到的"<a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Content_scripts#Sharing_objects_with_page_scripts">Sharing content script objects with page scripts</a>" 这一部分的警告: 页面的环境可能会被恶意的网页所控制,这可能会导致你所交互的对象会有意想不到的行为:</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="comment token">// page.js redefines console.log</span>
+
+<span class="keyword token">var</span> original <span class="operator token">=</span> console<span class="punctuation token">.</span>log<span class="punctuation token">;</span>
+
+console<span class="punctuation token">.</span>log <span class="operator token">=</span> <span class="keyword token">function</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ <span class="function token">original</span><span class="punctuation token">(</span><span class="keyword token">true</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+<span class="punctuation token">}</span></code></pre>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="comment token">// content-script.js calls the redefined version</span>
+
+window<span class="punctuation token">.</span><span class="function token">eval</span><span class="punctuation token">(</span><span class="string token">'console.log(false)'</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/content_security_policy/index.html b/files/zh-cn/mozilla/add-ons/webextensions/content_security_policy/index.html
new file mode 100644
index 0000000000..7ea0d2655d
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/content_security_policy/index.html
@@ -0,0 +1,107 @@
+---
+title: Content Security Policy
+slug: Mozilla/Add-ons/WebExtensions/Content_Security_Policy
+translation_of: Mozilla/Add-ons/WebExtensions/Content_Security_Policy
+---
+<div>{{AddonSidebar}}</div>
+
+<div class="summary">
+<p>使用WebExtension API 开发的插件默认应用了内容安全策略(Content Security Policy, 缩写CSP)。这限制了可以加载的<strong><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script"> </a></strong><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script">&lt;script&gt;</a> 和 <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object">&lt;object&gt;</a> 的资源来源,并且禁止了潜在的不安全用法如 <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval">eval()</a></code>.</p>
+
+<p>这篇文章简单地解释了CSP是什么,默认的策略是什么,这对插件来说意味着什么,以及插件如何改变默认CSP。</p>
+</div>
+
+<p><a href="/en-US/docs/Web/HTTP/CSP">Content Security Policy</a> (CSP) 是一种避免网站意外执行包含有恶意的内容的机制。网站通过使用服务端发送的HTTP头指定CSP。CSP主要关注指定各种内容的合法来源,如脚本和嵌入式插件。例如,网站可以使用它来告诉浏览器应该只执行来自网站自身的JavaScript,而不腻执行其他来源的脚本。CSP还可以指导浏览器禁止潜在危险行为,如<code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval">eval()</a></code>的使用。</p>
+
+<p>和网页一样,插件可以加载其他来源的内容。例如浏览器的弹出窗口可以指定为一个HTML文档,它同样可以包含不同来源的JavaScript和CSS,就像一个普通的网页一样。</p>
+
+<pre class="brush: html">&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+ &lt;head&gt;
+ &lt;meta charset="utf-8"&gt;
+ &lt;/head&gt;
+
+ &lt;body&gt;
+
+ &lt;!--Some HTML content here--&gt;
+
+ &lt;!--
+ Include a third-party script.
+ See also https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity.
+ --&gt;
+ &lt;script
+ src="https://code.jquery.com/jquery-2.2.4.js"
+ integrity="sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI="
+ crossorigin="anonymous"&gt;
+ &lt;/script&gt;
+
+ &lt;!-- Include my popup's own script--&gt;
+ &lt;script src="popup.js"&gt;&lt;/script&gt;
+ &lt;/body&gt;
+
+&lt;/html&gt;</pre>
+
+<p>和网站相比,插件可以访问特权API,因此一旦它们被恶意代码破坏,风险就更大。因此:</p>
+
+<ul>
+ <li>插件默认运行在一个相当严格的安全策略下。参考 <a href="/en-US/Add-ons/WebExtensions/Content_Security_Policy#Default_content_security_policy">default content security policy</a>.</li>
+ <li>插件的作者可以通过使用manifest.json中的 <code>content_security_policy</code> 关键词改变这种默认策略,但是允许的策略仍然有一定的限制。参考 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_security_policy">content_security_policy</a></code>.</li>
+</ul>
+
+<h2 id="默认内容安全策略">默认内容安全策略</h2>
+
+<p>对插件的默认内容安全策略如下:</p>
+
+<pre>"script-src 'self'; object-src 'self';"</pre>
+
+<p>这会被应用在任何没有明确在manifest.json中的<code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_security_policy">content_security_policy</a></code> 项设置自己的内容安全策略的插件中。它有以下几种效果:</p>
+
+<ul>
+ <li>
+ <p><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Content_Security_Policy#Location_of_script_and_object_resources">你只能将本地的 &lt;script&gt; 和 &lt;object&gt; 资源加载到插件中。</a></p>
+ </li>
+ <li>
+ <p><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Content_Security_Policy#eval()_and_friends">插件无法将字符串转换为JavaScript执行。</a></p>
+ </li>
+ <li>
+ <p><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Content_Security_Policy#Inline_JavaScript">内联JavaScript不会被执行。</a></p>
+ </li>
+</ul>
+
+<h3 id="script_和_object资源的位置">script 和 object资源的位置</h3>
+
+<p>在默认CSP下你只能加载相对插件来说本地的 <a href="/en-US/docs/Web/HTML/Element/script">&lt;script&gt;</a> 和 <a href="/en-US/docs/Web/HTML/Element/object">&lt;object&gt;</a> 资源。例如假设插件文档中存在这样一条语句:</p>
+
+<pre class="brush: html"> &lt;script src="https://code.jquery.com/jquery-2.2.4.js"&gt;&lt;/script&gt;</pre>
+
+<p>这不会加载请求的资源:它会安静地失败,并且你所期望看到的任何来自该资源的对象都不会出现。对于这种情况有两种解决办法:</p>
+
+<ul>
+ <li>
+ <p>下载该资源,打包进你的插件,然后引用它。</p>
+ </li>
+ <li>
+ <p>使用 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_security_policy">content_security_policy</a></code> 允许你所需要的资源。</p>
+ </li>
+</ul>
+
+<h3 id="eval_和friends">eval() 和friends</h3>
+
+<p>默认CSP下插件不被允许像JavaScript一样执行字符串。这意味着以下情况都被禁止:</p>
+
+<pre class="brush: js">eval("console.log('some output');");</pre>
+
+<pre class="brush: js">window.setTimeout("alert('Hello World!');", 500);</pre>
+
+<pre class="brush: js">var f = new Function("console.log('foo');");</pre>
+
+<h3 id="内联_JavaScript">内联 JavaScript</h3>
+
+<p>默认CSP下内联JavaScript不被执行。这不仅不允许将JavaScript直接放在 <code>&lt;script&gt;</code> 标签中间,也不允许内联事件句柄。即以下内容被禁止:</p>
+
+<pre class="brush: html">&lt;script&gt;console.log("foo");&lt;/script&gt;</pre>
+
+<pre class="brush: html">&lt;div onclick="console.log('click')"&gt;Click me!&lt;/div&gt;</pre>
+
+<p>如果你正在使用类似 <code>&lt;body onload="main()"&gt;</code> 的代码在页面加载时运行你的脚本,请使用监听器监听<a href="/en-US/docs/Web/Events/DOMContentLoaded">DOMContentLoaded</a> 或者 <a href="/en-US/docs/Web/Events/load">load</a> 代替。</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/embedded_webextensions/index.html b/files/zh-cn/mozilla/add-ons/webextensions/embedded_webextensions/index.html
new file mode 100644
index 0000000000..834125bb32
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/embedded_webextensions/index.html
@@ -0,0 +1,205 @@
+---
+title: Embedded WebExtensions
+slug: Mozilla/Add-ons/WebExtensions/Embedded_WebExtensions
+translation_of: Archive/Add-ons/Embedded_WebExtensions
+---
+<div>{{AddonSidebar}}</div>
+
+<div class="note">
+<p>嵌入一个 WebExtension 需要使用 Firefox 51 或更高版本。在 SDK 附加组件中嵌入一个 WebExtension 还需要 <a href="https://www.npmjs.com/package/jpm">jpm 1.2.0</a>。</p>
+</div>
+
+<p>从 Firefox 51 开始,你可以在传统附加组件类型中嵌入一个 WebExtension。</p>
+
+<p>传统附加组件可以是经典的<a href="/en-US/docs/Mozilla/Add-ons/Bootstrapped_extensions">自举扩展</a>或者<a href="/en-US/docs/Mozilla/Add-ons/SDK">Add-on SDK</a> 附加组件。嵌入式 WebExtension 的文件打包在传统附加组件中。嵌入式 WebExtension 并不直接与嵌入的附加组件共享范围,但可以使用 {{WebExtAPIRef("runtime")}} API 中定义的消息函数交换消息。</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/13895/embedded-we.png" style="display: block; height: 522px; margin-left: auto; margin-right: auto; width: 429px;"></p>
+
+<p>这意味着您可以一次性迁移传统附加组件到 WebExtensions,并且在此期间附加组件的功能完全保留。尤其是它可以让您从旧版附加组件<a href="/en-US/Add-ons/WebExtensions/Embedded_WebExtensions#Migrating_data_from_legacy_add-ons">迁移存储数据</a>到 WebExtension,通过撰写一个中间的混合式附加组件,使用旧版 API 读取数据(例如 <a href="/en-US/docs/Mozilla/Add-ons/SDK/High-Level_APIs/simple-prefs">simple-prefs</a> 或 preferences <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Services.jsm">服务</a>)并使用 WebExtension API 写入它(例如 {{WebExtAPIRef("storage")}})。</p>
+
+<p>连同本指南,我们撰写了两个例子展示如何使用嵌入式 WebExtensions 来帮助从传统附加组件迁移。<a href="https://github.com/mdn/webextensions-examples/tree/master/embedded-webextension-bootstrapped">如何从自举式附加组件迁移</a>以及<a href="https://github.com/mdn/webextensions-examples/tree/master/embedded-webextension-sdk">如何从 SDK 附加组件迁移</a>。</p>
+
+<h2 id="嵌入_WebExtension">嵌入 WebExtension</h2>
+
+<p>如果传统附加组件是一个带有<a href="/en-US/Add-ons/Install_Manifests">install.rdf</a> 的自举式扩展,在该 RDF 中加入 "hasEmbeddedWebExtension" 并设为 "true":</p>
+
+<pre>&lt;<span class="pl-ent">em</span><span class="pl-ent">:</span><span class="pl-ent">hasEmbeddedWebExtension</span>&gt;true&lt;/<span class="pl-ent">em</span><span class="pl-ent">:</span><span class="pl-ent">hasEmbeddedWebExtension</span>&gt;</pre>
+
+<div>如果旧式附加组件是一个 SDK 附加组件,在 package.json 中包含 "hasEmbeddedWebExtension" 并设为 <code>true</code>:</div>
+
+<div> </div>
+
+<pre class="brush: json"><span class="pl-s"><span class="pl-pds">"</span>hasEmbeddedWebExtension<span class="pl-pds">"</span></span>: <span class="pl-c1">true</span>
+</pre>
+
+<div>WebExtension 本身放在附加组件中的 "webextension" 顶层目录。例如:</div>
+
+<div> </div>
+
+<pre>my-boostrapped-addon/
+ chrome/
+ webextension/
+ manifest.json
+ background.js
+ ...
+ bootstrap.js
+ chrome.manifest
+ install.rdf</pre>
+
+<div> </div>
+
+<div>
+<pre>my-sdk-addon/
+ index.js
+ package.json
+ webextension/
+ manifest.json
+ background.js
+ ...</pre>
+</div>
+
+<p>Firefox 不将嵌入式 WebExtension 视为一个独立的附加组件。因此,您不应该为它指定一个<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/WebExtensions_and_the_Add-on_ID">附加组件 ID</a>。如果你这样做,那只会被忽略。</p>
+
+<p>但是,在您完成附加组件的迁移并移除旧式嵌入代码后,您必须添加一个 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/applications">applications</a> 键,设置 ID 为旧式附加组件的 ID。通过此方式,<a href="https://addons.mozilla.org/en-US/firefox/">addons.mozilla.org</a> 可以识别 WebExtension 是旧式附加组件的一个更新。</p>
+
+<h2 id="启动_WebExtension">启动 WebExtension</h2>
+
+<p>嵌入式 WebExtension 必须由被嵌入的附加组件明确启动。</p>
+
+<p>如果被嵌入的附加组件是一个自举式附加组件,那么传递到自举式扩展的 <code><a href="/en-US/Add-ons/Bootstrapped_extensions#startup">startup()</a></code> 函数的 <code>data</code> 将获得一个明确的 <code>webExtension</code>:</p>
+
+<pre class="brush: js">// bootstrapped add-on
+
+<span class="pl-k">function</span> <span class="pl-en">startup</span>({webExtension}) {
+
+...</pre>
+
+<p>如果被嵌入的附加组件是一个 SDK 附加组件,它可以使用 <code>sdk/webextension</code> 模块访问一个 WebExtension 对象:</p>
+
+<pre class="brush: js"><span class="pl-k">// SDK add-on
+
+const</span> <span class="pl-c1">webExtension</span> <span class="pl-k">=</span> <span class="pl-c1">require</span>(<span class="pl-s"><span class="pl-pds">"</span>sdk/webextension<span class="pl-pds">"</span></span>);</pre>
+
+<p>无论哪种方式,此对象都有一个 <code>startup()</code> 函数,它返回一个 <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>。该 promise 使用一个 <code>browser</code> 属性解决一个对象:这包括 {{WebExtAPIRef("runtime")}} API,被嵌入的附加组件可以用它来与嵌入式 WebExtension 交换消息:</p>
+
+<ul>
+ <li>{{WebExtAPIRef("runtime.onConnect")}}</li>
+ <li>{{WebExtAPIRef("runtime.onMessage")}}</li>
+</ul>
+
+<p>例如:</p>
+
+<pre class="brush: js">// bootstrapped add-on
+
+function startup({webExtension}) {
+ webExtension.startup().then(api =&gt; {
+ const {browser} = api;
+ browser.runtime.onMessage.addListener(handleMessage);
+ });
+}</pre>
+
+<pre class="brush: js"><span class="pl-k">// SDK add-on</span>
+
+const webExtension = require("sdk/webextension");
+
+webExtension.startup().then(api =&gt; {
+ const {browser} = api;
+ browser.runtime.onMessage.addListener(handleMessage);
+});
+</pre>
+
+<p>应注意的是,嵌入的附加组件不能启动通信,它可以使用 <code>onMessage</code> 接收(并可选响应)一次性消息,并可以使用 <code>onConnect</code> 接受连接请求。</p>
+
+<p>如果嵌入式 WebExtension 缺少一个 manifest,或者如果 manifest 无效,该 promise 会被拒绝。这种情况下,您可以在<a href="/en-US/Add-ons/WebExtensions/Debugging#Viewing_log_output">浏览器工具箱的控制台</a>中看到更多细节。</p>
+
+<h2 id="交换消息">交换消息</h2>
+
+<p>一旦嵌入式 WebExtension 处在运行,它可以使用 {{WebExtAPIRef("runtime")}} API 的子集与旧式附加组件交换消息:</p>
+
+<ul>
+ <li>它可以使用 {{WebExtAPIRef("runtime.sendMessage()")}} 发送一次性消息。</li>
+ <li>它可以使用 {{WebExtAPIRef("runtime.connect()")}} 建立一个连接。</li>
+</ul>
+
+<h3 id="无需连接的消息">无需连接的消息</h3>
+
+<p>要发送一条消息,WebExtension 可以使用 {{WebExtAPIRef("runtime.sendMessage()")}}。您可以省略 <code>extensionId</code> 参数,因为浏览器认为嵌入式 WebExtension 是被嵌入附加组件的一部分:</p>
+
+<pre class="brush: js">browser.runtime.sendMessage("message-from-webextension").then(reply =&gt; {
+ if (reply) {
+ console.log("response from legacy add-on: " + reply.content);
+ }
+});</pre>
+
+<p>被嵌入的附加组件可以使用 {{WebExtAPIRef("runtime.onMessage")}} 对象接收消息(并可选响应):</p>
+
+<pre class="brush: js">// bootstrapped add-on
+
+function startup({webExtension}) {
+ // Start the embedded webextension.
+ webExtension.startup().then(api =&gt; {
+ const {browser} = api;
+ browser.runtime.onMessage.addListener((msg, sender, sendReply) =&gt; {
+ if (msg == "message-from-webextension") {
+ sendReply({
+ content: "reply from legacy add-on"
+ });
+ }
+ });
+ });
+}</pre>
+
+<h3 id="基于连接的消息">基于连接的消息</h3>
+
+<p>要在 WebExtension 与传统附加组件间设置一个长寿命连接,WebExtension 可以使用 {{WebExtAPIRef("runtime.connect()")}}。</p>
+
+<pre class="brush: js">var port = browser.runtime.connect({name: "connection-to-legacy"});
+
+port.onMessage.addListener(function(message) {
+ console.log("Message from legacy add-on: " + message.content);
+});
+</pre>
+
+<p>旧式附加组件可以使用 {{WebExtAPIRef("runtime.onConnect")}} 监听连接尝试,双方可以使用得到的 {{webExtAPIRef("runtime.Port")}} 来交换消息:</p>
+
+<pre class="brush: js">function startup({webExtension}) {
+ // Start the embedded webextension.
+ webExtension.startup().then(api =&gt; {
+ const {browser} = api;
+ browser.runtime.onConnect.addListener((port) =&gt; {
+ port.postMessage({
+ content: "content from legacy add-on"
+ });
+ });
+ });
+}</pre>
+
+<h2 id="从传统附加组件迁移数据">从传统附加组件迁移数据</h2>
+
+<p>嵌入式 WebExtensions 的一项主要用途是迁移附加组件的存储数据。</p>
+
+<p>人们从旧式附加组件类型迁移的一个主要问题是存储数据,因为旧式附加组件不能使用 WebExtension 存储 API,WebExtensions 也不能使用旧式存储 API。例如,如果一个 SDK 附加组件使用了 SDK 的 <a href="/en-US/docs/Mozilla/Add-ons/SDK/High-Level_APIs/simple-prefs">simple-prefs</a> API 来存储首选项,WebExtension 版本不可能访问这项数据。</p>
+
+<p>使用嵌入式 WebExtensions,您可以创建一个嵌入了 WebExtension 的附加组件中间版本来迁移数据。中间版本使用旧式 API 读取存储的数据,然后使用 WebExtension API 写入数据。</p>
+
+<ul>
+ <li>在初始版本中,基于 SDK 的附加组件使用 <a href="/en-US/docs/Mozilla/Add-ons/SDK/High-Level_APIs/simple-prefs">simple-prefs</a> API 读取和写入附加组件首选项。</li>
+ <li>
+ <p>在中间版本中,SDK 附加组件启动嵌入式 WebExtension。WebExtension 要求 SDK 附加组件用 simple-prefs 检索存储的数据。WebExtension 然后使用 {{WebExtAPIRef("storage")}} API 存储数据。</p>
+
+ <div class="note">
+ <p>在某些情况下,中间版本必须在初始导入后保持数据同步。例如,<a href="/en-US/Add-ons/WebExtensions/Embedded_WebExtensions#Add-on_preferences_UI">附加组件的首选项界面仍然使用旧系统</a>,所以如果用户在这里修改了设置,它修改的是旧数据。中间的附加组件必须监听这些更改并将新数据发送到嵌入式 WebExtension。</p>
+
+ <p>有个 <a href="https://github.com/mdn/webextensions-examples/tree/master/embedded-webextension-sdk">"embedded-webextension-sdk"</a> 示例说明了这一点。</p>
+ </div>
+ </li>
+ <li>在最终版本中,附加组件只是一个 WebExtension,并且只使用存储 API。</li>
+</ul>
+
+<p>我们提供了两个例子说明此模式:<a href="https://github.com/mdn/webextensions-examples/tree/master/embedded-webextension-bootstrapped">"embedded-webextension-bootstrapped"</a> 展示了从一个自举式附加组件迁移,而 <a href="https://github.com/mdn/webextensions-examples/tree/master/embedded-webextension-sdk">"embedded-webextension-sdk"</a> 展示了从一个 SDK 附加组件迁移。</p>
+
+<h2 id="限制">限制</h2>
+
+<h3 id="调试">调试</h3>
+
+<p>如果您有一个嵌入了 WebExtension 的旧式附加组件,您不能使用新的附加组件调试器来调试它。您必须使用基于浏览器工具箱的<a href="/en-US/Add-ons/WebExtensions/Debugging_(before_Firefox_50)">旧版调试工具</a>。</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/examples/index.html b/files/zh-cn/mozilla/add-ons/webextensions/examples/index.html
new file mode 100644
index 0000000000..ce413198ea
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/examples/index.html
@@ -0,0 +1,31 @@
+---
+title: 扩展示例
+slug: Mozilla/Add-ons/WebExtensions/Examples
+tags:
+ - firefox extension
+ - firefox 扩展
+ - 扩展案例
+ - 火狐扩展
+translation_of: Mozilla/Add-ons/WebExtensions/Examples
+---
+<div>{{AddonSidebar}}</div>
+
+<p>为帮助了解如何开发扩展,我们维护了一个包含简单扩展示例的代码仓库在<a href="https://github.com/mdn/webextensions-examples">https://github.com/mdn/webextensions-examples</a>. 本文描述了仓库代码中所使用的 WebExtension APIs。</p>
+
+<p>这些示例工作在 Firefox Nightly 下: 大部分示例在 Firefox 的早期版本中也能够运行, 请检查扩展 manifest.json 文件中的 <a href="/en-US/Add-ons/WebExtensions/manifest.json/applications">strict_min_version</a> 键。</p>
+
+<p>如果你想尝试这些示例,有下面三个选择:</p>
+
+<ol>
+ <li>克隆代码库,通过 <a href="/en-US/Add-ons/WebExtensions/Temporary_Installation_in_Firefox">"临时载入附加组件"</a> 功能直接从源文件夹中载入扩展组件。再重启浏览器前该扩展将一直存在。</li>
+ <li>克隆代码库,使用 <a href="/en-US/Add-ons/WebExtensions/Getting_started_with_web-ext">web-ext</a> 命令行工具运行安装了扩展的 Firefox。</li>
+ <li>克隆代码库,进入 <a href="https://github.com/mdn/webextensions-examples/tree/master/build">build</a> 文件夹。该文件夹包含所有示例的已构建、带签名版本。你可以在Firefox中打开(菜单栏-&gt;文件-&gt;打开文件)并且永久安装这些扩展。这些扩展和直接从 <a href="https://addons.mozilla.org/en-US/firefox/">addons.mozilla.org</a> 安装的扩展别无二致。</li>
+</ol>
+
+<div class="blockIndicator warning">
+<p><strong>重要</strong>:不要提交这些关于 WebExtension 例子的示例到 AMO (addons.mozilla.org)  上去,你无需为附加组件签名就能运行 WebExtension 的示例。只要按照上面的步骤来就可以了。</p>
+</div>
+
+<p>如果你想对代码仓库贡献,<a href="https://github.com/mdn/webextensions-examples/blob/master/CONTRIBUTING.md">给我们发送 pull request!</a></p>
+
+<p>{{WebExtAllExamples}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/extending_the_developer_tools/index.html b/files/zh-cn/mozilla/add-ons/webextensions/extending_the_developer_tools/index.html
new file mode 100644
index 0000000000..cf44f0de27
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/extending_the_developer_tools/index.html
@@ -0,0 +1,164 @@
+---
+title: 扩展开发人员工具
+slug: Mozilla/Add-ons/WebExtensions/Extending_the_developer_tools
+tags:
+ - Add-ons
+ - DevTools
+ - Guide
+ - WebExtensions
+translation_of: Mozilla/Add-ons/WebExtensions/Extending_the_developer_tools
+---
+<div>{{AddonSidebar}}</div>
+
+<div class="note">
+<p>本页介绍了火狐 Firefox 55中存在的开发工具接口(dectools APIs)。 虽然该接口Api基于 Chrome 开发工具Api,仍有许多功能尚未实现在火狐中实现,因此未记录在本页内容中。产看当前缺失的功能,请参阅链接<a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Using_the_devtools_APIs#Limitations_of_the_devtools_APIs">开发工具Api的限制.</a></p>
+</div>
+
+<p>您可以使用WebExtensions API扩展浏览器的内置开发人员工具。要创建devtools扩展,请在manifest.json中包含“ devtools_page”键:</p>
+
+<pre class="brush: json notranslate">"devtools_page": "devtools/devtools-page.html"</pre>
+
+<p>此项的值是指向与您的扩展程序捆绑在一起的HTML文件的URL。该URL应相对于manifest.json文件本身。</p>
+
+<p>HTML文件在扩展中定义了一个特殊页面,称为devtools页面。</p>
+
+<h2 id="devtools页面">devtools页面</h2>
+
+<p>当打开浏览器devtools时,将加载devtools页面,并在关闭浏览器时将其卸载。请注意,由于devtools窗口与单个选项卡相关联,因此很可能同时存在多个devtools窗口-因此有多个devtools页面。</p>
+
+<p>devtools页面没有任何可见的DOM,但可以包含使用&lt;script&gt;标记的JavaScript源。源必须与扩展本身捆绑在一起。来源可以访问::</p>
+
+<ul>
+ <li>可通过全局窗口对象访问的普通DOM API</li>
+ <li>与内容脚本中相同的WebExtension API</li>
+ <li>The devtools APIs:
+ <ul>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/devtools.inspectedWindow">devtools.inspectedWindow</a></code></li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/devtools.network">devtools.network</a></code></li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/devtools.panels">devtools.panels</a></code></li>
+ </ul>
+ </li>
+</ul>
+
+<p>请注意,devtools页面无法访问任何其他WebExtension API,并且后台页面无法访问devtools API。相反,devtools页面和后台页面必须使用运行时消息传递API进行通信。这是一个例子:</p>
+
+<pre class="brush: html notranslate">&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;meta charset="utf-8"&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;script src="devtools.js"&gt;&lt;/script&gt;
+  &lt;/body&gt;
+&lt;/html&gt;</pre>
+
+<p>devtools.js文件将保存创建您的dev工具扩展的实际代码。</p>
+
+<h2 id="创建面板">创建面板</h2>
+
+<p>devtools窗口中包含许多单独的工具-JavaScript调试器,网络监视器等。顶部的一排标签可让用户在不同的工具之间切换。承载每个工具的用户界面的窗口称为“面板”</p>
+
+<p>使用devtools.panels.create()API,可以在devtools窗口中创建自己的面板:</p>
+
+<pre class="brush: js notranslate">browser.devtools.panels.create(
+ "My Panel", // title
+ "icons/star.png", // icon
+ "devtools/panel/panel.html" // content
+).then((newPanel) =&gt; {
+ newPanel.onShown.addListener(initialisePanel);
+ newPanel.onHidden.addListener(unInitialisePanel);
+});</pre>
+
+<p>这需要三个必选参数:面板的标题,图标和内容。它返回一个Promise,该Promise解析为代表新面板的devtools.panels.ExtensionPanel对象。</p>
+
+<h2 id="与目标窗口互动">与目标窗口互动</h2>
+
+<p>开发人员工具始终附加到特定的浏览器选项卡。这称为开发人员工具的“目标”或“检查的窗口”。您可以使用devtools.inspectedWindow API与检查的窗口进行交互。</p>
+
+<h3 id="Running_code_in_the_target_window">Running code in the target window</h3>
+
+<p>devtools.inspectedWindow.eval()提供了一种在检查的窗口中运行代码的方法。</p>
+
+<p>这有点像使用{{WebExtAPIRef("tabs.executeScript()")}}注入内容脚本,但有一个重要区别:</p>
+
+<ul>
+ <li>与内容脚本不同,使用devtools.inspectedWindow.eval()加载的脚本不会获得“ DOM的清晰视图”:也就是说,它们可以看到页面脚本对页面所做的更改。</li>
+</ul>
+
+<div class="note">
+<p>请注意,DOM的清晰视图是一项安全功能,旨在通过重新定义本机DOM功能的行为来帮助防止恶意页面欺骗扩展。这意味着您需要非常小心地使用eval(),并应尽可能使用普通的内容脚本。</p>
+</div>
+
+<p>devtools.inspectedWindow.eval()加载的脚本也看不到内容脚本定义的任何JavaScript变量。</p>
+
+<h3 id="Working_with_content_scripts">Working with content scripts</h3>
+
+<p>devtools文档无法直接访问{{WebExtAPIRef("tabs.executeScript()")}},因此,如果需要注入内容脚本,devtools文档必须向后台脚本发送一条消息,要求其注入剧本。 devtools.inspectedWindow.tabId提供目标选项卡的ID:devtools文档可以将其传递给后台脚本,而后台脚本又可以将其传递给{{WebExtAPIRef("tabs.executeScript()")}}:</p>
+
+<pre class="brush: js notranslate">// devtools-panel.js
+
+const scriptToAttach = "document.body.innerHTML = 'Hi from the devtools';";
+
+window.addEventListener("click", () =&gt; {
+ browser.runtime.sendMessage({
+ tabId: browser.devtools.inspectedWindow.tabId,
+ script: scriptToAttach
+ });
+});</pre>
+
+<pre class="brush: js notranslate">// background.js
+
+function handleMessage(request, sender, sendResponse) {
+ browser.tabs.executeScript(request.tabId, {
+ code: request.script
+ });
+}
+
+browser.runtime.onMessage.addListener(handleMessage);</pre>
+
+<p>如果您需要在目标窗口中运行的内容脚本和devtools文档之间交换消息,则最好使用{{WebExtAPIRef("runtime.connect()")}}和{{WebExtAPIRef("runtime.onConnect()")}},以在后台页面和devtools文档之间建立连接。然后,后台页面可以维护选项卡ID和{{WebExtAPIRef("runtime.Port")}}对象之间的映射,并使用此映射在两个作用域之间路由消息。</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/14923/devtools-content-scripts.png" style="display: block; height: 416px; margin-left: auto; margin-right: auto; width: 600px;"></p>
+
+<h2 id="devtools_API的局限性">devtools API的局限性</h2>
+
+<p>这些API基于Chrome devtools API,但与Chrome相比,许多功能仍缺失。本节列出了从Firefox 54开始尚未实现的功能。请注意,devtools API正在积极开发中,我们希望在将来的版本中增加对其中大多数功能的支持。</p>
+
+<h3 id="devtools.inspectedWindow">devtools.inspectedWindow</h3>
+
+<p>The following are not supported:</p>
+
+<ul>
+ <li><code>inspectedWindow.getResources()</code></li>
+ <li><code>inspectedWindow.onResourceAdded</code></li>
+ <li><code>inspectedWindow.onResourceContentCommitted</code></li>
+</ul>
+
+<p>None of the options to <code>inspectedWindow.eval()</code> are supported.</p>
+
+<p>使用inspectedWindow.eval()注入的脚本不能使用控制台的所有命令行帮助器功能,但是都支持$ 0和inspect(...)(从Firefox 55开始)。</p>
+
+<h3 id="devtools.panels">devtools.panels</h3>
+
+<p>The following are not supported:</p>
+
+<ul>
+ <li><code>panels.elements</code></li>
+ <li><code>panels.sources</code></li>
+ <li><code>panels.setOpenResourceHandler()</code></li>
+ <li><code>panels.openResource()</code></li>
+ <li><code>panels.ExtensionPanel.createStatusBarButton()</code></li>
+ <li><code>panels.Button</code></li>
+ <li><code>panels.ElementsPanel</code></li>
+ <li><code>panels.SourcesPanel</code></li>
+</ul>
+
+<h2 id="Examples">Examples</h2>
+
+<p>The <a href="https://github.com/mdn/webextensions-examples">webextensions-examples</a> repo on GitHub, contains several examples of extensions that use devtools panels:</p>
+
+<ul>
+ <li>
+ <p><a href="https://github.com/mdn/webextensions-examples/blob/master/devtools-panels/">devtools-panels</a> use devtools panels:</p>
+ </li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/index.html b/files/zh-cn/mozilla/add-ons/webextensions/index.html
new file mode 100644
index 0000000000..cdd473ca78
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/index.html
@@ -0,0 +1,122 @@
+---
+title: 浏览器扩展
+slug: Mozilla/Add-ons/WebExtensions
+tags:
+ - WebExtension
+ - WebExtensions
+ - firefox add-on
+ - firefox extensions
+ - web-extensions
+ - 发布
+ - 附加组件
+translation_of: Mozilla/Add-ons/WebExtensions
+---
+<div>{{AddonSidebar}}</div>
+
+<p>Extensions「扩展」 可以扩展和修改一个浏览器的能力。用于 Firefox 的 扩展使用 WebExtensions API 「一种开发扩展的跨浏览器系统」构建。该系统与 Google Chrome、Opera 和 <a href="https://browserext.github.io/browserext/">W3C 草案社区组织</a> 所支持的 <a href="https://developer.chrome.com/extensions">扩展 API </a>在很大程度上兼容。大多数情况下为这些浏览器编写的扩展<a href="/zh-CN/Add-ons/WebExtensions/Porting_from_Google_Chrome">只需少许修改</a>即可在 Firefox 或 <a href="https://developer.microsoft.com/zh-CN/microsoft-edge/platform/documentation/extensions/">Microsoft Edge</a> 中运行。这种 API 与也完全兼容 <a href="/zh-CN/Firefox/Multiprocess_Firefox">多进程 Firefox</a>。</p>
+
+<p>如果你有想法或问题,或者在使用 WebExtensions APIs 迁移旧式附加组件时需要帮助,可以在 <a href="https://mail.mozilla.org/listinfo/dev-addons">dev-addons 邮件列表</a> 或者 <a href="https://wiki.mozilla.org/IRC">IRC</a> 上的 <a href="irc://irc.mozilla.org/extdev">#extdev</a> 与我们联系。</p>
+
+<div class="row topicpage-table">
+<div class="section">
+<h2 id="新手入门">新手入门</h2>
+
+<ul>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/What_are_WebExtensions">什么是扩展?</a></li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Your_first_WebExtension">你的第一个扩展</a></li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Your_second_WebExtension">你的第二个扩展</a></li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Anatomy_of_a_WebExtension">扩展解析</a></li>
+ <li>火狐工作流概述</li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Examples">扩展示例</a></li>
+ <li>下一步</li>
+</ul>
+
+<h2 id="操作方法">操作方法</h2>
+
+<ul>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Intercept_HTTP_requests">拦截 HTTP 请求</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Modify_a_web_page">修改网页</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Add_a_button_to_the_toolbar">在工具栏添加按钮</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Implement_a_settings_page">制作一个设置页面</a></li>
+ <li><a href="/zh-CN//docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard">与剪贴板交互</a></li>
+ <li>使用页签API</li>
+ <li>使用书签API</li>
+</ul>
+
+<h2 id="用户界面">用户界面</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface">简介</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Browser_action">浏览器工具栏按钮</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Page_actions">有弹出面板的浏览器工具栏按钮</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Page_actions">地址栏按钮</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Popups">有弹出面板的地址栏按钮</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Context_menu_items">上下文菜单项</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Sidebars">侧边栏</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Options_pages">选项页面</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Bundled_web_pages">捆绑网页(Bundled web pages)</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Notifications">通知</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Omnibox">地址栏建议</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/devtools_panels">开发者工具面板</a></li>
+</ul>
+
+<h2 id="相关概念">相关概念</h2>
+
+<ul>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Using_the_JavaScript_APIs">使用 JavaScript API</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/User_interface_components">用户界面元素</a></li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Content_scripts">内容脚本</a></li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Match_patterns">模式匹配</a></li>
+ <li><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Working_with_files">处理文件</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Internationalization">国际化</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy">内容安全政策</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Native_messaging">本地消息</a></li>
+ <li><a href="https://developer.mozilla.org/zh-CN/Add-ons/WebExtensions/User_experience_best_practices">用户体验的最佳实践</a></li>
+</ul>
+
+<h2 id="扩展移植">扩展移植</h2>
+
+<ul>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Porting_from_Google_Chrome">移植 Google Chrome 扩展</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Porting_a_legacy_Firefox_add-on">移植传统的 Firefox 附加组件</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Embedded_WebExtensions">嵌入式 WebExtensions</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Comparison_with_the_Add-on_SDK">与 Firefox Add-on SDK 的差异</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Comparison_with_XUL_XPCOM_extensions">与 XUL/XPCOM 的差异</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Chrome_incompatibilities">与 Chrome 不兼容的地方</a></li>
+</ul>
+
+<h2 id="Firefox_工作流">Firefox 工作流</h2>
+
+<ul>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Temporary_Installation_in_Firefox">安装</a></li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Debugging">调试</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Getting_started_with_web-ext">开始使用 web-ext</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/web-ext_command_reference">web-ext 命令参考</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/WebExtensions_and_the_Add-on_ID">WebExtensions 与附加组件 ID</a></li>
+ <li><a href="https://developer.mozilla.org/zh-CN/Add-ons/WebExtensions/Alternative_distribution_options">其他分发选项</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Publishing_your_WebExtension">发布你的 WebExtension</a></li>
+</ul>
+</div>
+
+<div class="section">
+<h2 id="参考资料">参考资料</h2>
+
+<h3 id="JavaScript_APIs">JavaScript APIs</h3>
+
+<ul>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API">JavaScript API概况</a></li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Browser_support_for_JavaScript_APIs">JavaScript API 浏览器兼容性表格</a></li>
+</ul>
+
+<div class="twocolumns">{{ ListSubpages ("/zh-CN/Add-ons/WebExtensions/API") }}</div>
+
+<h3 id="Manifest_关键信息">Manifest 关键信息</h3>
+
+<ul>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json 概览</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Browser_compatibility_for_manifest.json">manifest.json 的浏览器兼容性</a></li>
+</ul>
+
+<div class="twocolumns">{{ ListSubpages ("/zh-CN/Add-ons/WebExtensions/manifest.json") }}</div>
+</div>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/interact_with_the_clipboard/index.html b/files/zh-cn/mozilla/add-ons/webextensions/interact_with_the_clipboard/index.html
new file mode 100644
index 0000000000..092125a9ca
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/interact_with_the_clipboard/index.html
@@ -0,0 +1,157 @@
+---
+title: Interact with the clipboard
+slug: Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard
+translation_of: Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard
+---
+<div>{{AddonSidebar}}</div>
+
+<p>有两种方式可以让浏览器扩展与系统剪贴板交互: {{domxref("Document.execCommand()")}} 方法以及现代的异步的 <a href="/en-US/docs/Web/API/Clipboard_API">Clipboard API</a>.</p>
+
+<p>{{domxref("Document.execCommand()")}} 方法常通过以下指令使用:</p>
+
+<ul>
+ <li><code>document.execCommand("copy")</code></li>
+ <li><code>document.execCommand("cut")</code></li>
+ <li><code>document.execCommand("paste")</code></li>
+</ul>
+
+<p>Clipboard API 提供了异步的连接来直接读写剪贴板内容. 例, 如此从剪贴板读取文本:</p>
+
+<pre class="brush: js">navigator.clipboard.readText().then(text =&gt; outputElem.innerText = text);</pre>
+
+<p>这将请求剪贴板内容, 并且当接收到响应时存储剪贴板文本到一个元素的 {{domxref("Node.innerText", "innerText")}}.</p>
+
+<div class="blockIndicator note">
+<p>注意: 异步的 Clipboard API 方法是一个近期新增的规范, 并且这个规范可能不适用于所有浏览器. 请在使用前测试了每一种方法的兼容性, 以确保支持满足您的需求.</p>
+</div>
+
+<h2 id="写入系统粘贴板">写入系统粘贴板</h2>
+
+<p>有两种向剪贴板写入数据的方法. 你可以使用 {{domxref("Document.execCommand", "document.execCommand()")}}  来触发 "剪切" 和 "复制" 行为, 这将用选择的数据覆盖剪贴板的当前内容. 另一个选项是使用 Clipboard API 的 {{domxref("Clipboard.writeText()")}} 或 {{domxref("Clipboard.write()")}} 方法来用指定数据覆盖剪贴板内容.</p>
+
+<h3 id="使用_execCommand()">使用 execCommand()</h3>
+
+<p>{{domxref("Document.execCommand", "document.execCommand()")}}  方法的 <code>"cut"</code> 与 <code>"copy"</code> 命令可以被用于以选中素材代替剪贴板的当前内容. 这些命令无需任何特别的权限就可以使用, 如果你在一个用于用户操作的短生存期的事件处理程序中使用他们(例如, 一次点击事件).</p>
+
+<p>例如,假设你有一个下面的弹出菜单页面:</p>
+
+<pre class="brush: html">&lt;input id="input" type="text"/&gt;
+&lt;button id="copy"&gt;Copy&lt;/button&gt;
+</pre>
+
+<p>使 "copy"按钮能复制 "input"中的文本,代码如下:</p>
+
+<pre class="brush: js">function copy() {
+ var copyText = document.querySelector("#input");
+ copyText.select();
+ document.execCommand("Copy");
+}
+
+document.querySelector("#copy").addEventListener("click", copy);</pre>
+
+<p>由于<code>execCommand()</code>命令在单击事件中,所以不需要特别的权限。</p>
+
+<p>此外,如果用警报(alarm)替换上面的命令来触发复制事件:</p>
+
+<pre class="brush: js">function copy() {
+ var copyText = document.querySelector("#input");
+ copyText.select();
+ document.execCommand("Copy");
+}
+
+browser.alarms.create({
+ delayInMinutes: 0.1
+});
+
+browser.alarms.onAlarm.addListener(copy);</pre>
+
+<p>这种触发不一定成功,它取决于浏览器是否支持。Firefox浏览器就不支持该功能,你会在浏览器控制台中看到以下信息:</p>
+
+<pre>"document.execCommand(‘cut’/‘copy’) was denied because it was not called from inside a short running user-generated event handler."</pre>
+
+<p>为了能够在这种情形下使用,你需要拥有"clipboardWrite"的权限( <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a>)。 因此,"clipboardWrite"权限能使你不通过临时事件处理程序就可以写入系统粘贴板中。</p>
+
+<h3 id="使用_Clipboard_API">使用 Clipboard API</h3>
+
+<p>Clipboard API 更加灵活, 因为你不仅可以将当前选择复制到剪贴板中, 还可以直接指定要放入剪贴板的信息.</p>
+
+<p>要使用 Clipboard API 需要在你的 <code>manifest.json</code> 文件中申请 <code>clipboardRead</code> 与 <code>clipboardWrite</code> 权限.</p>
+
+<p>对于页面脚本, 需要权限 API 的 <code>clipboard-write</code> 权限. 你可通过 {{domxref("Permissions.query", "navigator.permissions.query()")}} 来检查这个权限:</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js">navigator<span class="punctuation token">.</span>permissions<span class="punctuation token">.</span><span class="function token">query</span><span class="punctuation token">(</span><span class="punctuation token">{</span>name<span class="punctuation token">:</span> <span class="string token">"clipboard-write"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">.</span><span class="function token">then</span><span class="punctuation token">(</span>result <span class="operator token">=&gt;</span> <span class="punctuation token">{</span>
+ <span class="keyword token">if</span> <span class="punctuation token">(</span>result<span class="punctuation token">.</span>state <span class="operator token">==</span> <span class="string token">"granted"</span> <span class="operator token">||</span> result<span class="punctuation token">.</span>state <span class="operator token">==</span> <span class="string token">"prompt"</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ <span class="comment token">/* write to the clipboard now */</span>
+ <span class="punctuation token">}</span>
+<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+
+<p>这个函数使用一个字符串作为输入并且用它更新剪贴板:</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">updateClipboard</span><span class="punctuation token">(</span>newClip<span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ navigator<span class="punctuation token">.</span>clipboard<span class="punctuation token">.</span><span class="function token">writeText</span><span class="punctuation token">(</span>newClip<span class="punctuation token">)</span><span class="punctuation token">.</span><span class="function token">then</span><span class="punctuation token">(</span><span class="keyword token">function</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ <span class="comment token">/* clipboard successfully set */</span>
+ <span class="punctuation token">}</span><span class="punctuation token">,</span> <span class="keyword token">function</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ <span class="comment token">/* clipboard write failed */</span>
+ <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+<span class="punctuation token">}</span></code></pre>
+
+<h3 id="特定浏览器注意事项">特定浏览器注意事项</h3>
+
+<p> 这里涉及的剪贴板和其他API正在快速发展, 因此浏览器在工作方式上存在差异.</p>
+
+<p>在Chrome中:</p>
+
+<ul>
+ <li>你可以在所有执行上下文中写入系统粘贴板,像背景网页、内容脚本、标签页和弹出菜单。</li>
+ <li>你不需要 <code>"clipboardWrite"</code> 权限,甚至不需要在用户生成的事件处理程序中写入粘贴板</li>
+</ul>
+
+<p>在Firefox中:</p>
+
+<ul>
+ <li>除了背景网页外,你可以在所有执行上下文中使用 execCommand 写入粘贴板。在Firefox中,你无法选择文本或将输入字段聚焦在后台页面中,因此无法使用 execCommand 从后台页面写入剪贴板。</li>
+ <li>只有version 51以上才支持"clipboardWrite" 权限。</li>
+ <li>从 version 57 开始,可以使用 <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/clipboard/setImageData">clipboard.setImageData()</a></code> API 将图像复制到剪贴板。</li>
+ <li>在 Firefox 633 中添加了对 Clipboard API {{domxref("Clipboard.writeText", "navigator.clipboard.writeText()")}} 方法的支持。</li>
+ <li>当使用一个内容脚本,Clipboard API 只可用于 HTTPS 页。解决方法是,在内容脚本和后台脚本之间使用消息传递。</li>
+</ul>
+
+<h2 id="读取系统粘贴板">读取系统粘贴板</h2>
+
+<p><code>execCommand()</code> 方法提供了 <code>"paste"</code> 指令,能让你粘贴内容。你可以使用 Clipboard API 的更灵活的方法: {{domxref("Clipboard.read()")}} 和 {{domxref("Clipboard.readText()")}}。</p>
+
+<h3 id="使用_execCommand()_2">使用 execCommand()</h3>
+
+<p>首先,你需要为扩展申请 <code>"clipboardRead"</code> <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a> 。即便你在用户生成的事件处理程序 ( 例如 {{event("click")}} 或 {{event("keypress")}} ) 中使用 "paste" 指令也是如此。</p>
+
+<p>假设你的HTML页面内容如下:</p>
+
+<pre class="brush: html">&lt;input id="output" type="text"/&gt;
+&lt;button id="paste"&gt;粘贴&lt;/button&gt;
+</pre>
+
+<p>要在用户单机 id 为 <code>"paste"</code> 的 {{HTMLElement("button")}} 时从剪贴板设置 id 为 <code>"output"</code> 的 {{HTMLElement("textarea")}} 的内容,可以使用这样的代码:</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">paste</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ <span class="keyword token">var</span> pasteText <span class="operator token">=</span> document<span class="punctuation token">.</span><span class="function token">querySelector</span><span class="punctuation token">(</span><span class="string token">"#output"</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+ pasteText<span class="punctuation token">.</span><span class="function token">focus</span><span class="punctuation token">(</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+ document<span class="punctuation token">.</span><span class="function token">execCommand</span><span class="punctuation token">(</span><span class="string token">"paste"</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+ console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>pasteText<span class="punctuation token">.</span>textContent<span class="punctuation token">)</span><span class="punctuation token">;</span>
+<span class="punctuation token">}</span>
+
+document<span class="punctuation token">.</span><span class="function token">querySelector</span><span class="punctuation token">(</span><span class="string token">"#paste"</span><span class="punctuation token">)</span><span class="punctuation token">.</span><span class="function token">addEventListener</span><span class="punctuation token">(</span><span class="string token">"click"</span><span class="punctuation token">,</span> paste<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+
+<h3 id="使用_Clipboard_API_2">使用 Clipboard API</h3>
+
+<p>剪贴板 API 的 {{domxref("Clipboard.readText", "navigator.clipboard.readText()")}} 和 {{domxref("Clipboard.read", "navigator.clipboard.read()")}} 方法让你从剪贴板读取任意文本或二进制数据。这让你从剪贴板访问数据无需将它们粘贴至一个可编辑的元素中。</p>
+
+<p>一旦你通过 <a href="https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API">Permissions API</a> 获取了 <code>"clipboard-read"</code> 权限,你就可以轻松读取剪贴板:</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js">navigator<span class="punctuation token">.</span>clipboard<span class="punctuation token">.</span><span class="function token">readText</span><span class="punctuation token">(</span><span class="punctuation token">)</span><span class="punctuation token">.</span><span class="function token">then</span><span class="punctuation token">(</span>clipText <span class="operator token">=&gt;</span>
+ document<span class="punctuation token">.</span><span class="function token">getElementById</span><span class="punctuation token">(</span><span class="string token">"outbox"</span><span class="punctuation token">)</span><span class="punctuation token">.</span>innerText <span class="operator token">=</span> clipText<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+
+<p>这个代码片段从剪贴板提取文本并且用该文本替换 ID 为 <code>"outbox"</code> 的元素的当前内容。</p>
+
+<h3 id="特定浏览器注意事项_2">特定浏览器注意事项</h3>
+
+<p>Firefox 在 54 版本提供了 <code>"clipboardRead"</code> <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a> ,但是仅支持向处于 <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Editable_content">内容可编辑模式</a> 的元素粘贴,对于内容脚本,只能在 {{HTMLElement("textarea")}} 工作。对于后台脚本,任何元素都可被设置为内容可编辑模式。</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/intercept_http_requests/index.html b/files/zh-cn/mozilla/add-ons/webextensions/intercept_http_requests/index.html
new file mode 100644
index 0000000000..1e1c155db3
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/intercept_http_requests/index.html
@@ -0,0 +1,158 @@
+---
+title: 拦截HTTP请求
+slug: Mozilla/Add-ons/WebExtensions/Intercept_HTTP_requests
+tags:
+ - Add-ons
+ - Extensions
+ - WebExtensions
+translation_of: Mozilla/Add-ons/WebExtensions/Intercept_HTTP_requests
+---
+<div>{{AddonSidebar}}</div>
+
+<p>使用 {{WebExtAPIRef("webRequest")}} API可以拦截HTTP请求。该API允许开发者植入一个侦听器用以侦听各个阶段的HTTP请求。在侦听器中,你能:</p>
+
+<ul>
+ <li>获取请求及其返回的header和body</li>
+ <li>取消或重定向请求</li>
+ <li>修改请求及其返回的header</li>
+</ul>
+
+<p>本文将探究<code>webRequest</code>模型的三种用法:</p>
+
+<ul>
+ <li>登陆请求的构造</li>
+ <li>重定向请求</li>
+ <li>修改请求的header</li>
+</ul>
+
+<h2 id="记录请求的_URL">记录请求的 URL</h2>
+
+<p>新建一个名为<code>“</code>requests<code>”</code>的目录,在其中新建一个名为<code>“</code>manifest.json<code>”</code>的文件,文件包含如下 内容 :</p>
+
+<pre class="brush: json">{
+ "description": "Demonstrating webRequests",
+ "manifest_version": 2,
+ "name": "webRequest-demo",
+ "version": "1.0",
+
+ "permissions": [
+ "webRequest",
+ "&lt;all_urls&gt;"
+ ],
+
+ "background": {
+ "scripts": ["background.js"]
+ }
+}</pre>
+
+<p>接着新加一个名为<code>“</code>background.js<code>”</code>的文件,包含如下内容:</p>
+
+<pre class="brush: js">function logURL(requestDetails) {
+ console.log("Loading: " + requestDetails.url);
+}
+
+chrome.webRequest.onBeforeRequest.addListener(
+ logURL,
+ {urls: ["&lt;all_urls&gt;"]}
+);
+
+</pre>
+
+<p>这里我们在请求开始之前用{{WebExtAPIRef("webRequest.onBeforeRequest", "onBeforeRequest")}}调用<code>logURL()</code>函数。<code>logURL()</code><code>函数</code>抓取从事件对象发出的请求中的URL,然后将其打印到浏览器的控制台窗口中。<a href="/en-US/Add-ons/WebExtensions/Match_patterns">参数</a><code>{urls: ["&lt;all_urls&gt;"]}</code>表示拦截发往所有URL的HTTP请求。</p>
+
+<p>测试方法是:<a href="/en-US/Add-ons/WebExtensions/Temporary_Installation_in_Firefox">安装该WebExtension</a>, <a href="/en-US/docs/Tools/Browser_Console">打开浏览器的控制台</a>,然后开启某个网页即可。在浏览器控制台中就能见到浏览器请求所有资源的URL:</p>
+
+<p>{{EmbedYouTube("X3rMgkRkB1Q")}}</p>
+
+<h2 id="重定向请求">重定向请求</h2>
+
+<p>现在让我们用<code>webRequest</code>来重定向HTTP请求。首先将manifest.json文件内容替换如下:</p>
+
+<pre class="brush: json">{
+
+ "description": "Demonstrating webRequests",
+ "manifest_version": 2,
+ "name": "webRequest-demo",
+ "version": "1.0",
+
+ "permissions": [
+ "webRequest",
+    "webRequestBlocking",
+    "https://mdn.mozillademos.org"
+ ],
+
+ "background": {
+ "scripts": ["background.js"]
+ }
+
+}</pre>
+
+<p>这里唯一的变化是<code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">权限</a></code>里 新增了<code>“</code><code>webRequestBlocking</code><code>”</code>项。新增这个权限是为了随时都能修改请求。</p>
+
+<p>下一步替换<code>“</code>background.js<code>”</code>文件内容如下:</p>
+
+<pre class="brush: js">var pattern = "https://mdn.mozillademos.org/*";
+
+function redirect(requestDetails) {
+ console.log("Redirecting: " + requestDetails.url);
+ return {
+ redirectUrl: "https://38.media.tumblr.com/tumblr_ldbj01lZiP1qe0eclo1_500.gif"
+ };
+}
+
+chrome.webRequest.onBeforeRequest.addListener(
+ redirect,
+ {urls:[pattern], types:["image"]},
+ ["blocking"]
+);</pre>
+
+<p>此外在请求构造出来之前我们用{{WebExtAPIRef("webRequest.onBeforeRequest", "onBeforeRequest")}}事件侦听器来实现URL替换。侦听器将会用<code>redirectUrl</code>指定的内容替换原有的URL。</p>
+
+<p>这次我们不拦截所有的请求:<code>{urls:[pattern], types:["image"]}</code>选项告诉浏览器必须同时满足如下两点的请求才会被拦截:(1)在<code>“</code> https://mdn.mozillademos.org/<code>”</code>之下的URL; (2)图片资源。该功能的更多说明参见{{WebExtAPIRef("webRequest.RequestFilter")}}。</p>
+
+<p>刚才我们忽略了<code>“blocking</code><code>”</code>选项。要修改请求<code>就要用到“blocking</code><code>”</code>选项,该选项让侦听器函数阻塞住发往网络请求,浏览器将会等待侦听器返回才会继续处理。阅读{{WebExtAPIRef("webRequest.onBeforeRequest")}}以了解更多有关<code>“blocking</code> <code>”</code>的细节。.</p>
+
+<p>测试时打开MDN上的一个包含诸多图片的页面(如<a href="https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor">https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor</a> ),重新加载<a href="/en-US/Add-ons/WebExtensions/Temporary_Installation_in_Firefox#Reloading_a_temporary_add-on">WebExtension</a>,然后重新加载这个页面:</p>
+
+<p>{{EmbedYouTube("ix5RrXGr0wA")}}</p>
+
+<h2 id="修改请求报头">修改请求报头</h2>
+
+<p>最后我们将使用<code>webRequest</code>修改请求报头。在这个例子中我们将修改 "User-Agent"报头,使得在浏览" http://useragentstring.com/"网站下的网页时可以识别浏览器Opera 12.16。</p>
+
+<p>"manifest.json" 可以与上一个例子相同。</p>
+
+<p>修改"background.js" 如下:</p>
+
+<pre class="brush: js">var targetPage = "http://useragentstring.com/*";
+
+var ua = "Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16";
+
+function rewriteUserAgentHeader(e) {
+ for (var header of e.requestHeaders) {
+ if (header.name.toLowerCase() == "user-agent") {
+ header.value = ua;
+ }
+ }
+ return {requestHeaders: e.requestHeaders};
+}
+
+chrome.webRequest.onBeforeSendHeaders.addListener(
+ rewriteUserAgentHeader,
+ {urls: [targetPage]},
+ ["blocking", "requestHeaders"]
+);</pre>
+
+<p>在请求报头被发送前,我们使用 {{WebExtAPIRef("webRequest.onBeforeSendHeaders", "onBeforeSendHeaders")}} 事件监听器来运行一个函数。</p>
+
+<p>只有在向匹配的URL格式的网页发送请求时,这个监听函数才会运行。 还需注意的是,我们再次使用了<code>"blocking"</code>选项。我们还使用了<code>"requestHeaders"</code>选项,使监听器可以传递我们希望的请求报头数组。了解更多{{WebExtAPIRef("webRequest.onBeforeSendHeaders")}}的信息。</p>
+
+<p>侦听函数在请求报头数组中寻找 "User-Agent" 报头,用<code>ua</code>变量替换它的值,然后返回修改后的报头数组 。现在这个修改后的数组会被发送到服务器。</p>
+
+<p>要测试它,先打开 <a href="http://useragentstring.com/">useragentstring.com</a>网址,检查标识浏览器是否为火狐浏览器 。然后加载附加组件, 刷新网址,再次检查标识浏览器,你会发现火狐浏览器被定义为 Opera了:</p>
+
+<p>{{EmbedYouTube("SrSNS1-FIx0")}}</p>
+
+<h2 id="了解更多">了解更多</h2>
+
+<p>学习你能使用的所有<code>webRequest</code> API,查看 <a href="/en-US/Add-ons/WebExtensions/API/WebRequest">reference documentation</a>。</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/internationalization/index.html b/files/zh-cn/mozilla/add-ons/webextensions/internationalization/index.html
new file mode 100644
index 0000000000..88971977ae
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/internationalization/index.html
@@ -0,0 +1,394 @@
+---
+title: 国际化
+slug: Mozilla/Add-ons/WebExtensions/Internationalization
+translation_of: Mozilla/Add-ons/WebExtensions/Internationalization
+---
+<div>{{AddonSidebar}}</div>
+
+<p><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions">WebExtensions</a> API 有一个相当方便的模块可用于附加组件的国际化(<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/i18n">i18n</a>)。我们将在本文中探讨其功能,并为它的运作方式提供一个实例。WebExtensions 的 i18n 系统类似常见的 i18n 用途 JavaScript 库,例如 <a href="http://i18njs.com/">i18n.js</a>。</p>
+
+<div class="note">
+<p>本文中的 WebExtension 实例 <a href="https://github.com/mdn/webextensions-examples/tree/master/notify-link-clicks-i18n">notify-link-clicks-i18n</a> 可在 GitHub 上查阅。在您阅读下列章节时,可参照它的代码。</p>
+</div>
+
+<h2 id="剖析一个国际化的_WebExtension">剖析一个国际化的 WebExtension</h2>
+
+<p>一个国际化的 WebExtension 与其他 WebExtension 一样可以包含各类功能,如<a href="/en-US/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Background_scripts">后台脚本</a>、<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">内容脚本</a>等,但它也有些额外的部分,从而允许它适应不同的语言区域。目录树大致如下:</p>
+
+<ul class="directory-tree">
+ <li>webextension-根目录/
+ <ul>
+ <li>_locales
+ <ul>
+ <li>en
+ <ul>
+ <li>messages.json
+ <ul>
+ <li>英语消息(字符串)</li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>de
+ <ul>
+ <li>messages.json
+ <ul>
+ <li>德语消息(字符串)</li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>等其他语言</li>
+ </ul>
+ </li>
+ <li>manifest.json
+ <ul>
+ <li>含按语言区域而定的元数据</li>
+ </ul>
+ </li>
+ <li>myJavascript.js
+ <ul>
+ <li>含用于检索浏览器语言区域、特定语言环境的消息等的 JavaScript。</li>
+ </ul>
+ </li>
+ <li>myStyles.css
+ <ul>
+ <li>含按语言区域而定的 CSS</li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+</ul>
+
+<p>让我们逐项探讨这些新特性,因为下列每个章节都是你在国际化 WebExtension 时所要遵循的步骤。</p>
+
+<h2 id="在__locales_中提供本地化的字符串">在 _locales 中提供本地化的字符串</h2>
+
+<div class="pull-aside">
+<div class="moreinfo">你可以使用<a href="http://r12a.github.io/apps/subtags/">Language subtag lookup page</a>上的查找工具查询语言子标签。请注意,你需要搜索语言的英语名称。</div>
+</div>
+
+<p>每个 i18n 系统都需要你提供想支持的各语言区域的已翻译字符串。 在 WebExtensions 中,这些字符串放在一个名为 <code>_locales</code> 的目录中,<code>_locales</code> 目录则位于扩展的根目录。每个语言区域都有一个名叫 <code>messages.json</code> 的文件,其中包含相应的字符串(在 WebExtension 中称作“消息”),这个文件放在 <code>_locales</code> 的子目录下,子目录以对应语言区域的语言子标签来命名。</p>
+
+<p>注意,如果子标签包含一个基本语言和一个区域变种,那么语言与变种之间通常会以连字号隔开,例如 "en-US"。但作为 <code>_locales</code> 的子目录,<strong>它必须采用下划线来分隔</strong>,如 "en_US"。</p>
+
+<p>因此<a href="https://github.com/mdn/webextensions-examples/tree/master/notify-link-clicks-i18n/_locales" title="1">在我们这个示例应用</a>中,我们有如下几个目录:"en"(英语)、"de"(德语)、"nl"(荷兰语)以及 "ja"(日语)。每个目录都包含一个 <code>messages.json</code> 文件。</p>
+
+<p>现在我们来看其中一个文件(<a href="https://github.com/mdn/webextensions-examples/blob/master/notify-link-clicks-i18n/_locales/en/messages.json">_locales/en/messages.json</a>)的结构:</p>
+
+<pre class="brush: json">{
+ "extensionName": {
+ "message": "Notify link clicks i18n",
+ "description": "Name of the extension."
+ },
+
+ "extensionDescription": {
+ "message": "Shows a notification when the user clicks on links.",
+ "description": "Description of the extension."
+ },
+
+ "notificationTitle": {
+ "message": "Click notification",
+ "description": "Title of the click notification."
+ },
+
+ "notificationContent": {
+ "message": "You clicked $URL$.",
+ "description": "Tells the user which link they clicked.",
+ "placeholders": {
+      "url" : {
+        "content" : "$1",
+        "example" : "https://developer.mozilla.org"
+      }
+    }
+ }
+}</pre>
+
+<p>这个文件是一个标准的 JSON — 其中每个成员都是一个带有名称的对象,里面包含一个 <code>message</code>(消息)和一个 <code>description</code>(描述)。这些项目都是字符串。<code>$URL$</code> 是一个占位符,在 WebExtension 调用 <code>notificationContent</code> 成员时将被一个子字符串替换。你将在接下来的{{anch("从 JavaScript 检索消息字符串")}}章节中了解如何使用。</p>
+
+<div class="note">
+<p><strong>注意:</strong>你可以在 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/i18n/Locale-Specific_Message_reference">Locale-Specific Message reference</a> 里找到更多有关  <code>messages.json</code> 文件中内容的信息。</p>
+</div>
+
+<h2 id="国际化_manifest.json">国际化 manifest.json</h2>
+
+<p>要国际化你的 manifest.json,有几项任务要完成。</p>
+
+<h3 id="在_manifests_中检索本地化的字符串">在 manifests 中检索本地化的字符串</h3>
+
+<p>你的 <a href="https://github.com/mdn/webextensions-examples/blob/master/notify-link-clicks-i18n/manifest.json">manifest.json</a> 包含显示给用户的字符串,例如附加组件的名称和描述。如果你将这些字符串国际化,并将合适的翻译放到 messages.json 中,则用户将根据当前语言区域看到适当的字符串翻译。</p>
+
+<p>要将这些字符串国际化,按如下格式指定:</p>
+
+<pre class="brush: json">"name": "__MSG_extensionName__",
+"description": "__MSG_extensionDescription__",</pre>
+
+<p>我们在在这里检索到消息字符串依赖于浏览器的语言区域,而不仅仅是一个静态字符串。</p>
+
+<p>要这样调用消息字符串,你需要用的方式为:</p>
+
+<ol>
+ <li>两个下划线,接着是</li>
+ <li>字符串 "MSG",接着是</li>
+ <li>一个下划线,接着是</li>
+ <li>你想调用的在 <code>messages.json</code> 中定义的消息名称,接着是</li>
+ <li>两个下划线</li>
+</ol>
+
+<pre><strong>__MSG_</strong> + <em>messageName</em> + <strong>__</strong></pre>
+
+<h3 id="指定默认语言区域">指定默认语言区域</h3>
+
+<p>你还必须在你的 manifest.json 中指定另一个字段,它就是 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/default_locale">default_locale</a>:</p>
+
+<pre class="brush: json">"default_locale": "en"</pre>
+
+<p>如果扩展没有包含浏览器当前语言区域的本地化字符串,则会使用该字段所指定的默认语言区域。任何浏览器语言区域下不可用的消息字符串都将用默认语言区域的字符串替换。有关浏览器如何选择字符串,还有一些细节需要注意 — 详见{{anch("选择本地化的字符串")}}。</p>
+
+<h2 id="依赖语言区域的_CSS">依赖语言区域的 CSS</h2>
+
+<p>您还可以在扩展的 CSS 文件中检索本地化的字符串。例如,您可能想构建一个依赖于语言区域的 CSS 规则,如下所示:</p>
+
+<pre class="brush: css">header {
+ background-image: url(../images/__MSG_extensionName__/header.png);
+}</pre>
+
+<p>这很有用,不过在这种情况下使用{{anch("预定义消息")}}来处理或许会更好。</p>
+
+<h2 id="从_JavaScript_检索消息字符串">从 JavaScript 检索消息字符串</h2>
+
+<p>所以,您应该已经建立起您的消息字符串和 manifest。现在只需开始从 JavaScript 调用这些消息字符串,以便你的扩展尽可能多地表述适合的语言。实际上 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/i18n">i18n API</a> 相当简单,只需包含以下四个主要的方法(method):</p>
+
+<ul>
+ <li>你最常用的很可能是 {{WebExtAPIRef("i18n.getMessage()")}} — 使用此方法可以检索一个指定的语言字符串。下方有特定的用法示例。</li>
+ <li>{{WebExtAPIRef("i18n.getAcceptLanguages()")}} 和 {{WebExtAPIRef("i18n.getUILanguage()")}} 这两个方法可以在你需要根据语言区域自定义用户界面时使用 — 或许你希望根据用户想要的语言在首选项列表更高层显示首选项,或只显示和特定语言有关的文化信息,又或是按浏览器语言显示格式化过的日期。</li>
+ <li>{{WebExtAPIRef("i18n.detectLanguage()")}} 这个方法可以用来检测用户提交内容的语言,并将其正确格式化。</li>
+</ul>
+
+<p>在我们的 <a href="https://github.com/mdn/webextensions-examples/tree/master/notify-link-clicks-i18n">notify-link-clicks-i18n</a> 示例中,<a href="https://github.com/mdn/webextensions-examples/blob/master/notify-link-clicks-i18n/background-script.js">后台脚本</a>包含下列代码:</p>
+
+<pre class="brush: js">var title = browser.i18n.getMessage("notificationTitle");
+var content = browser.i18n.getMessage("notificationContent", message.url);</pre>
+
+<p>第一行是从最适合当前语言区域的可用 <code>messages.json</code> 文件中检索 <code>notificationTitle</code> <code>message</code> 字段。第二行与第一行类似,但它被传递了一个 URL 作为第二参数。怎么一回事?它就是你所指定的要替代 <code>notificationContent</code> 消息字段里 <code>$URL$</code> 占位符的内容:</p>
+
+<pre class="brush: json">"notificationContent": {
+ "message": "您点击了 $URL$。",
+ "description": "告诉用户点击了哪个链接。",
+ "placeholders": {
+ "url" : {
+ "content" : "$1",
+ "example" : "https://developer.mozilla.org"
+ }
+ }
+}
+</pre>
+
+<p><code>"placeholders"</code> 这个成员定义了所有的占位符,以及它们所检索的来源。<code>"url"</code> 这个占位符指定了其内容取自 $1,它就是<code> getMessage() 第二个参数里的第一个值。由于占位符就叫做</code> <code>"url",我们就在实际的消息字符串中用</code> <code>$URL$</code> 调用它(<code>"name"</code> 用<code> $NAME$</code> 调用也是一样的,以此类推)。对于多个占位符,你可以将其置于数组内,并作为第二个参数传递到 {{WebExtAPIRef("i18n.getMessage()")}} — <code>[a, b, c]</code> 可替换为 <code>$1</code>, <code>$2</code>, and <code>$3,以此类推,并置于</code> <code>messages.json</code> 内。</p>
+
+<p>接下来我们看一个例子:在 <code>en/messages.json 文件中</code>原始的 <code>notificationContent</code> 消息字符串如下: in the <code>en/messages.json</code> file is</p>
+
+<pre>您点击了 $URL$。</pre>
+
+<p>我们可以看到链接点击后会打开 <code>https://developer.mozilla.org。</code>在 {{WebExtAPIRef("i18n.getMessage()")}} 调用后,第二个参数的内容就变成了 messages.json 里的 <code>$1</code>,并替换定义在 <code>"url" 占位符里的</code> <code>$URL$</code> 这个占位符。所以最后的消息字符串就变成了:</p>
+
+<pre>您点击了 https://developer.mozilla.org。</pre>
+
+<h3 id="直接占位符的使用">直接占位符的使用</h3>
+
+<p>你可以直接将变量<code>($1</code>, <code>$2</code>, <code>$3</code> 等)插入消息字符串,例如我们可以将上述的<code> "notificationContent"</code> 成员重写为:</p>
+
+<pre class="brush: json">"notificationContent": {
+ "message": "你点击了 $1。",
+ "description": "告诉用户点击了哪个链接。"
+}</pre>
+
+<p>这么做看起来似乎更快捷,也没那么复杂,但另一种方法(使用 <code>"placeholders")更切实际,因为提供一个占位符名</code>(例如 <code>"url"</code>)和 example 可帮你记住占位符是什么 — 在你代码写了一个礼拜后,你很可能忘了 <code>$1</code>–<code>$8</code> 表示什么,但你或许记得起来占位符名表示什么。</p>
+
+<h3 id="替换硬编码">替换硬编码</h3>
+
+<p>也可以在占位符中包含硬编码的字符串,从而每次都使用相同的值,而不是从代码中的变量获取值。例如:</p>
+
+<pre class="brush: json">"mdn_banner": {
+ "message": "For more information on web technologies, go to $MDN$.",
+ "description": "Tell the user about MDN",
+ "placeholders": {
+ "mdn": {
+ "content": "https://developer.mozilla.org/"
+ }
+ }
+}</pre>
+
+<p>在本例中我们只是硬编码了占位符的内容,而不是从 <code>$1 这样的变量值中获取它。有时候你会遇到消息文件非常复杂,或者如果你想将文件里的不同值分离开来以便字符串可读性更好,</code>这种情况下它会很有用,这些值可通过编程来访问。</p>
+
+<p>此外,你可使用这样的替代方式指定不想被翻译的一部分字符串,例如人名或公司名。</p>
+
+<h2 id="选择本地化的字符串">选择本地化的字符串</h2>
+
+<p>语言区域可以仅使用语言代码指定,例如 <code>fr</code> 或 <code>en</code>,也可以进一步限定区域代码,例如 <code>en_US</code> 或 <code>en_GB</code>,其描述了使用相同基础语言的区域变体。当您向 i18n 系统询问一个字符串时,它将使用以下算法选择一个字符串:</p>
+
+<ol>
+ <li>如果有精确匹配当前语言区域的 <code>messages.json</code> 文件,并且它包含该字符串,则返回它。</li>
+ <li>否则,如果当前语言区域有合格区域(例如 <code>en_US</code>)并且有一个无区域限定的 <code>messages.json</code> 文件(例如 <code>en</code>)且包含该字符串,则返回它。</li>
+ <li>否则,如果 <code>manifest.json 里包含</code> <code>default_locale</code> 所对应的 <code>messages.json</code> 文件且包含该字符串,则返回它。</li>
+ <li>否则,返回一个空字符串。</li>
+</ol>
+
+<p>参见下列示例:</p>
+
+<ul class="directory-tree">
+ <li>webextension-root-directory/
+ <ul>
+ <li>_locales
+ <ul>
+ <li>en_GB
+ <ul>
+ <li>messages.json
+ <ul>
+ <li><code>{ "colorLocalised": { "message": "colour", "description": "Color." }, ... }</code></li>
+ </ul>
+ </li>
+ </ul>
+ en
+
+ <ul>
+ <li>messages.json
+ <ul>
+ <li><code>{ "colorLocalised": { "message": "color", "description": "Color." }, ... }</code></li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>fr
+ <ul>
+ <li>messages.json
+ <ul>
+ <li><code>{ "colorLocalised": { "message": "<span lang="fr">couleur</span>", "description": "Color." }, ...}</code></li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+</ul>
+
+<p>假设 <code>default_locale</code> 是设为 <code>fr</code>,而浏览器的语言环境为 <code>en_GB</code>:</p>
+
+<ul>
+ <li>如果该附加组件调用 <code>getMessage("colorLocalised")</code>,它将返回 "colour"。</li>
+ <li>如果 "colorLocalised" 没有在 <code>en_GB</code> 中提供,那么 <code>getMessage("colorLocalised")</code> 将返回 "color" 而不是 "couleur".</li>
+</ul>
+
+<h2 id="预定义消息">预定义消息</h2>
+
+<p>i18n 模块为我们提供了一些预定义的消息,我们可以用之前在 {{anch("Calling message strings from manifests and extension CSS")}} 中看到的相同的方式调用。例如:</p>
+
+<pre>__MSG_extensionName__</pre>
+
+<p>预定义的消息使用完全相同的语法,例如在消息名称之前使用 <code>@@</code></p>
+
+<pre>__MSG_@@ui_locale__</pre>
+
+<p>下表显示了各个可用的预定义消息。</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">消息名</th>
+ <th scope="col">描述</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>@@extension_id</code></td>
+ <td>扩展或应用的 ID;你可以使用该字符串构建 URL,用于扩展内部的资源。甚至未本地化的扩展也可以使用该消息。<br>
+ <strong>注意:</strong>该消息无法在 manifest 文件中使用。</td>
+ </tr>
+ <tr>
+ <td><code>@@ui_locale</code></td>
+ <td>当前的语言区域;你可以使用该字符串构建语言区域特有的 URL。</td>
+ </tr>
+ <tr>
+ <td><code>@@bidi_dir</code></td>
+ <td>当前语言区域对应的文本书写方向,可以是 "ltr",例如英语这样的从左到右书写的语言,或"rtl",例如阿拉伯语这样的从右到左书写的语言。</td>
+ </tr>
+ <tr>
+ <td><code>@@bidi_reversed_dir</code></td>
+ <td>如果 <code>@@bidi_dir</code> 是 "ltr",则是 "rtl",否则是 "ltr"。</td>
+ </tr>
+ <tr>
+ <td><code>@@bidi_start_edge</code></td>
+ <td>如果 <code>@@bidi_dir</code> 是 "ltr",则是 "left",否则是 "right"。</td>
+ </tr>
+ <tr>
+ <td><code>@@bidi_end_edge</code></td>
+ <td>如果<code> @@bidi_dir</code> 是 "ltr",则是 "right",否则是 "left"。</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>回到我们之前的例子,像下面这样写更有意义:</p>
+
+<pre class="brush: css">header {
+ background-image: url(../images/__MSG_@@ui_locale__/header.png);
+}</pre>
+
+<p>现在我们可以保存本地指定的图片,目录则可以根据所支持的不同语言区域进行匹配,例如 en、de 等 — 这样显得更有意义多了。</p>
+
+<p>让我们看看一个在 CSS 文件中使用 <code>@@bidi_*</code> 消息的例子:</p>
+
+<pre class="brush: css">body {
+ direction: __MSG_@@bidi_dir__;
+}
+
+div#header {
+ margin-bottom: 1.05em;
+ overflow: hidden;
+ padding-bottom: 1.5em;
+ padding-__MSG_@@bidi_start_edge__: 0;
+ padding-__MSG_@@bidi_end_edge__: 1.5em;
+ position: relative;
+}</pre>
+
+<p>对于从左到右语言(例如英语、中文),该 CSS 声明调用在上面预定义的消息,最终转换为下列代码:</p>
+
+<pre class="brush: css">direction: ltr;
+padding-left: 0;
+padding-right: 1.5em;
+</pre>
+
+<p>而对于从右到左语言(如阿拉伯语),则将得到:</p>
+
+<pre class="brush: css">direction: rtl;
+padding-right: 0;
+padding-left: 1.5em;</pre>
+
+<h2 id="测试你的_WebExtension">测试你的 WebExtension</h2>
+
+<p>从 Firefox 45 开始,你可以临时安装磁盘上的 WebExtensions  — 另见<a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Packaging_and_installation#Loading_from_disk">从磁盘加载。</a>按上述步骤操作,然后尝试我们的 <a href="https://github.com/mdn/webextensions-examples/tree/master/notify-link-clicks-i18n">notify-link-clicks-i18n</a> WebExtension。访问你喜欢的任何网站,然后点一下链接,查看是否有通知出现来显示所点击的链接网址。</p>
+
+<p>接下来,将 Firefox 的语言区域更改为你想测试的扩展支持的某个语言区域。</p>
+
+<ol>
+ <li>在 Firefox 中打开 "about:config",找到 <code>general.useragent.locale</code> 首选项。</li>
+ <li>双击该首选项(或按回车)以选择它,输入你想测试的语言环境的语言代码,然后点击“确定”(或按回车)。我们的示例扩展支持“en”(英语)、“de”德语()、“nl”(荷兰语)和“ja”日语。</li>
+ <li>重启你的浏览器以完成更改。</li>
+</ol>
+
+<div class="note">
+<p><strong>Note</strong>: 这个方法可以用来修改浏览器的语言区域,即使你未安装过该语言区域对应的<a href="https://addons.mozilla.org/en-US/firefox/language-tools/">语言包</a>。这样的话你就可以将浏览器用户界面调整显示为你的默认语言。</p>
+</div>
+
+<ol>
+</ol>
+
+<p>再次从磁盘临时加载该扩展,然后测试你的新语言区域:</p>
+
+<ul>
+ <li>再次访问 "about:addons" — 你现在应该看到该附加组件已列出其图标,以及相应语言的名称和描述。</li>
+ <li>再次测试你的 WebExtension。在我们的例子中,你会转到另一个网站并点击一个链接,以查看该通知现在是否以相应语言显示。</li>
+</ul>
+
+<p>{{EmbedYouTube("R7--fp5pPGg")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/author/index.html b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/author/index.html
new file mode 100644
index 0000000000..a688478298
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/author/index.html
@@ -0,0 +1,40 @@
+---
+title: 作者 - author
+slug: Mozilla/Add-ons/WebExtensions/manifest.json/author
+tags:
+ - 作者
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/author
+---
+<div>{{AddonSidebar}}</div>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <th scope="row" style="width: 30%;">值类型</th>
+ <td><code>字符串(String)</code></td>
+ </tr>
+ <tr>
+ <th scope="row">强制性</th>
+ <td>非强制</td>
+ </tr>
+ <tr>
+ <th scope="row">示例</th>
+ <td>
+ <pre class="brush: json">
+"author": "小明"</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>附加组件的作者, 用于在浏览器用户界面上显示, 这样别人下载安装使用该附加组件的时候, 就能看见你的大名了.</p>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: json">"author": "小明"</pre>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.manifest.author")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/background/index.html b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/background/index.html
new file mode 100644
index 0000000000..df4e1fc9ae
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/background/index.html
@@ -0,0 +1,88 @@
+---
+title: 后台 - background
+slug: Mozilla/Add-ons/WebExtensions/manifest.json/background
+tags:
+ - 后台
+ - 附加组件
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/background
+---
+<div>{{AddonSidebar}}</div>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <th scope="row" style="width: 30%;">Type</th>
+ <td><code>Object</code></td>
+ </tr>
+ <tr>
+ <th scope="row">强制性</th>
+ <td>不强制</td>
+ </tr>
+ <tr>
+ <th scope="row">示例</th>
+ <td>
+ <pre class="brush: json">
+"background": {
+ "scripts": ["background.js"]
+}</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>通过background 键来给您的扩展程序引入一个或者多个后台脚本文件,以及一个可选的后台页面文件。</p>
+
+<p>后台脚本放置的是需要长期保持状态,或者需要执行长期的操作,并且与任意特定网页或者浏览器窗口的生命周期无关的代码。</p>
+
+<p>后台脚本会在扩展程序被加载后立即被加载,并且一直保持被加载状态,只有在扩展程序被禁止或者卸载的时候才停止运行。只要您获得了必要的许可<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permissions</a>,您可以在该脚本中使用任意的扩展程序API。</p>
+
+<p>浏览<a href="/en-US/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Background_pages">Anatomy of a WebExtension</a>中的Background pages部分以获取更多的细节。</p>
+
+<p>background 键最多只能拥有以下的两个属性,两个属性都是可选属性:</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>"scripts"</code></td>
+ <td>
+ <p>一个字符串数组,数组中的每个字符串都是JavaScript源文件相对于manifest.json的相对路径,JavaScript源文件便是些被包含在扩展程序中的后台脚本文件。</p>
+
+ <p>脚本共享相同的全局窗口</p>
+
+ <p>脚本按照在数组中的顺序进行加载</p>
+
+ <p><strong>注意在低于Firefox 50版本的浏览器下会出现一个问题:</strong>当Firefox debugger已经打开时,脚本并不能总是按照数组中定义的顺序进行加载。若要解决这个问题,您可以使用page属性,用&lt;script&gt;标签将后台脚本文件从页面中加载进来。这个问题已经在Firefox 50中被修复。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>"page"</code></td>
+ <td>
+ <p>如果您仅仅指定了“scripts”属性,将生成一个空白的页面来运行指定的脚本。</p>
+
+ <p>如果您需要在页面中显示某些特定的内容,您可以使用“page”属性来定义自己的页面。</p>
+
+ <p dir="ltr" id="tw-target-text">如果您使用此属性,您仍然可以使用“script”属性来指定后台脚本,但您也可以就像在普通网页中一样在页面中包含自己的脚本。</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="示例">示例</h2>
+
+<p>加载2个后台脚本文件.</p>
+
+<pre class="brush: json">  "background": {
+    "scripts": ["jquery.js", "my-background.js"]
+  }</pre>
+
+<p>加载1个自定义的后台页面文件.</p>
+
+<pre class="brush: json"> "background": {
+ "page": "my-background.html"
+ }</pre>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.manifest.background", 10)}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/browser_action/index.html b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/browser_action/index.html
new file mode 100644
index 0000000000..f2e1ff07d1
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/browser_action/index.html
@@ -0,0 +1,209 @@
+---
+title: browser_action
+slug: Mozilla/Add-ons/WebExtensions/manifest.json/browser_action
+tags:
+ - Add-ons
+ - Extensions
+ - WebExtensions
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/browser_action
+---
+<div>{{AddonSidebar}}</div>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <th scope="row" style="width: 30%;">类型</th>
+ <td><code>Object</code></td>
+ </tr>
+ <tr>
+ <th scope="row">是否必须</th>
+ <td>否</td>
+ </tr>
+ <tr>
+ <th scope="row">示例</th>
+ <td>
+ <pre class="brush: json no-line-numbers">
+"browser_action": {
+ "browser_style": true,
+ "default_icon": {
+ "16": "button/geo-16.png",
+ "32": "button/geo-32.png"
+ },
+ "default_title": "Whereami?",
+ "default_popup": "popup/geo.html"
+}</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>浏览器按钮(browser action)指您的扩展在浏览器工具栏上所添加的按钮。该按钮有个图标,并可可选地拥有一个使用 HTML,CSS,和 JavaScript 指定内容的弹出窗口。</p>
+
+<p>如果您使用弹窗(popup),则该弹窗将在用户点击该按钮时打开,并且弹窗中你所提供的运行中的 JavaScript 将可处理用户与其的交互。如果您不使用弹窗,则会在用户点击该按钮时将点击事件传递给你扩展的 <a href="/zh-CN/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Background_scripts">background scripts</a> 中。</p>
+
+<p>您同样可以使用 <a href="/zh-CN/Add-ons/WebExtensions/API/browserAction">browserAction API</a> 以编程的方式创建及控制浏览器按钮。</p>
+
+<h2 id="语法">语法</h2>
+
+<p><code>browser_action</code> 键是一个可能有以下任何属性的对象,均是可选:</p>
+
+<table class="fullwidth-table standard-table">
+ <thead>
+ <tr>
+ <th scope="col">名称</th>
+ <th scope="col">类型</th>
+ <th scope="col">详细描述</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>browser_style</code></td>
+ <td><code>Boolean</code></td>
+ <td>
+ <div class="geckoVersionNote">Firefox 48 中新出现</div>
+
+ <p>可选,默认为 <code>false</code>。</p>
+
+ <p>使用此项来包含一个样式表以使其与浏览器 UI 和其它使用了 <code>browser_style</code> 属性的扩展外观上保持一致。虽然此键值默认为 <code>false</code>,还是建议您将其包含并设其为 <code>true</code>。</p>
+
+ <p>在 Firefox 中,该样式表详阅 chrome://browser/content/extension.css,OS X 系统或见于 chrome://browser/content/extension-mac.css。</p>
+
+ <p><a href="https://firefoxux.github.io/StyleGuide/#/controls">Firefox Style Guide</a> 记述了为获得特定样式您所能为弹窗中元素应用的 class。</p>
+
+ <p><a href="https://github.com/mdn/webextensions-examples/tree/master/latest-download">latest-download</a> 中的示例扩展的弹窗使用了 <code>browser_style</code>。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>default_area</code></td>
+ <td><code>String</code></td>
+ <td>
+ <div class="geckoVersionNote">Firefox 54 中新出现</div>
+
+ <p>定义浏览器最初放置该按钮的位置。该字符串可能是以下四个值中的一个:</p>
+
+ <ul>
+ <li>"navbar":按钮会被放置到浏览器主工具栏中,与 URL 栏并肩。</li>
+ <li>"menupanel":按钮会被放置到弹出面板中。</li>
+ <li>"tabstrip":按钮会被放置到包含浏览器选项卡的工具栏中。</li>
+ <li>"personaltoolbar":按钮会被放置到书签工具栏中。</li>
+ </ul>
+
+ <p>该属性只有 Firefox 支持。</p>
+
+ <p>这个属性是可选的,并默认为 "navbar"。</p>
+
+ <p>扩展不能在其被安装后主动更改其按钮的位置,但用户可以使用浏览器内置的界面定制机制来移动按钮。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>default_icon</code></td>
+ <td><code>Object</code> 或 <code>String</code></td>
+ <td>
+ <p>使用此项以指定一个或多个 browser action 之图标。该图标默认显示在浏览器工具栏里。</p>
+
+ <p>图标使用相对于 manifest.json 文件本身的 URL 指定。</p>
+
+ <p>你可以通过提供一个字符串以指定单个的图标文件:</p>
+
+ <pre class="brush: json no-line-numbers">
+"default_icon": "path/to/geo.svg"</pre>
+
+ <p>要指定多个不同大小的图标,则在此指定一个对象。每个属性的名字是以像素记的该图标的高,且其必须被转换为一个整数。值为其 URL。示例:</p>
+
+ <pre class="brush: json no-line-numbers">
+ "default_icon": {
+ "16": "path/to/geo-16.png",
+ "32": "path/to/geo-32.png"
+ }</pre>
+
+ <p>参阅 <a href="/zh-CN/Add-ons/WebExtensions/manifest.json/browser_action#选择图标大小">选择图标大小</a> 以获得此项的更多指引。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>default_popup</code></td>
+ <td><code>String</code></td>
+ <td>
+ <p>指向包含弹窗信息的 HTML 文件之路径</p>
+
+ <p>该 HTML 文件可能会使用 <code><a href="/zh-CN/docs/Web/HTML/Element/link">&lt;link&gt;</a></code> and <code><a href="/zh-CN/docs/Web/HTML/Element/script">&lt;script&gt;</a></code> 元素来包含 CSS 和 JavaScript,就像普通网页一样。</p>
+
+ <p>与普通网页不同,弹窗中运行的 JavaScript 能访问所有的 <a href="/en-US/Add-ons/WebExtensions/API">WebExtension APIs</a>(当然,仅对于拥有适当<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">权限</a>的扩展)。</p>
+
+ <p>这是一个<a href="/zh-CN/Add-ons/WebExtensions/Internationalization#国际化_manifest.json">可本地化属性</a>。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>default_title</code></td>
+ <td><code>String</code></td>
+ <td>
+ <p>按钮的工具提示,在用户将鼠标移到其上时显示。</p>
+
+ <p>这是一个<a href="/zh-CN/Add-ons/WebExtensions/Internationalization#国际化_manifest.json">可本地化属性</a>。</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="选择图标大小">选择图标大小</h2>
+
+<p>浏览器按钮的图标在不同上下文中可能需要以不同大小显示:</p>
+
+<ul>
+ <li>图标默认是在浏览器工具栏中显示,但用户能把它挪到浏览器菜单面板里(那个在用户点击 “汉堡” 图标时打开的面板)。工具栏里的图标比菜单面板里的图标小。</li>
+ <li>在像 Retina 屏的高密度显示器上,图标大要两倍。</li>
+</ul>
+
+<p>如果浏览器在给定的情况下找不到正确尺寸的图标,它就会选最匹配的并对其缩放。缩放可能会使图标模糊,所以一件很重要的事情就是小心地选择图标尺寸。</p>
+
+<p>对此有两种常用方法。你可以以 SVG 文件的形式提供单个图标,然后它就会被正确地缩放:</p>
+
+<pre class="brush: json no-line-numbers">"default_icon": "path/to/geo.svg"</pre>
+
+<p>或者,您可以提供几个不同尺寸的图标,浏览器将选择最佳匹配。</p>
+
+<p>Firefox 中:</p>
+
+<ul>
+ <li>工具栏中图标的默认宽高为 16 * <code><a href="/zh-CN/docs/Web/API/Window/devicePixelRatio">window.devicePixelRatio</a></code>。</li>
+ <li>菜单面板中图标的默认宽高为 32 * <code><a href="/zh-CN/docs/Web/API/Window/devicePixelRatio">window.devicePixelRatio</a></code>。</li>
+</ul>
+
+<p>所以你可以选定精确匹配的图标,不论普通屏还是 Retina 屏的显示,都仅需要提供三个图标文件,并把它们像这样确定下来:</p>
+
+<pre class="brush: json no-line-numbers"> "default_icon": {
+ "16": "path/to/geo-16.png",
+ "32": "path/to/geo-32.png",
+ "64": "path/to/geo-64.png"
+ }</pre>
+
+<p>如果 Firefox 找不到其需要的精确匹配的尺寸,则它会选择大于理想尺寸的已指定的最小图标。如果所有图标都小于理想尺寸,它就将选择已指定的最大图标。</p>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: json no-line-numbers">"browser_action": {
+ "default_icon": {
+ "16": "button/geo-16.png",
+ "32": "button/geo-32.png"
+ }
+}</pre>
+
+<p>只有一个图标的浏览器按钮,指定了 2 种不同大小。其扩展的 background scripts 能接收用户点击其图标时的点击事件代码大概像这样:</p>
+
+<pre class="brush: js no-line-numbers"> browser.browserAction.onClicked.addListener(handleClick);</pre>
+
+<pre class="brush: json">"browser_action": {
+ "default_icon": {
+ "16": "button/geo-16.png",
+ "32": "button/geo-32.png"
+ },
+ "default_title": "Whereami?",
+ "default_popup": "popup/geo.html"
+}</pre>
+
+<p>浏览器按钮具有一个图标,一个标题,还有一个弹窗。弹窗会在用户点击按钮时出现。</p>
+
+<p>对于一个简易,但是完整,使用了浏览器按钮的扩展,参见<a href="/zh-CN/Add-ons/WebExtensions/Your_second_WebExtension">演练教程</a>。</p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("webextensions.manifest.browser_action", 10)}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/browser_specific_settings/index.html b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/browser_specific_settings/index.html
new file mode 100644
index 0000000000..5d200de3bd
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/browser_specific_settings/index.html
@@ -0,0 +1,66 @@
+---
+title: applications
+slug: Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings
+tags:
+ - 插件
+ - 附加组件
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings
+---
+<div>{{AddonSidebar}}</div>
+
+<div class="note">
+<p>注意这个key不被Blink-based浏览器(Google Chrome和Opera)支持。如果你在插件中包含了这个key,当在这些浏览器中调用时虽然能用但是会显示警告。</p>
+</div>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <th scope="row" style="width: 30%;">类型</th>
+ <td><code>Object</code></td>
+ </tr>
+ <tr>
+ <th scope="row">强制性</th>
+ <td>通常不做强制性要求(详细参见<a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/WebExtensions_and_the_Add-on_ID#When_do_you_need_an_Add-on_ID">When do you need an Add-on ID</a><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/applications#When_do_I_need_the_applications_key">?</a>)。在Firefox 48版本之前为强制要求。</td>
+ </tr>
+ <tr>
+ <th scope="row">示例</th>
+ <td>
+ <pre class="brush: json">
+"applications": {
+ "gecko": {
+ "id": "addon@example.com",
+ "strict_min_version": "42.0"
+ }
+}</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p><code>applications</code> key包含特定于主机应用程序的键。</p>
+
+<p>目前只包含了一个key:<code>gecko</code>,其中包含了4个attributes:</p>
+
+<ul>
+ <li><code>id</code>即<a href="https://developer.mozilla.org/zh-CN/Add-ons/Install_Manifests#id">extension ID</a>。从Firefox 48起为可选项,在此之前为强制必须项。参看<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/WebExtensions_and_the_Add-on_ID">WebExtensions and the Add-on ID</a>来确认何时需要定义附加组件ID。</li>
+ <li><code>strict_min_version</code>: Gecko所能支持的最小版本号。不允许使用"*"来定义版本号。默认值为 "42a1"。{{gecko_minversion_inline("45")}}</li>
+ <li><code>strict_max_version</code>: Gecko所能支持的最大版本号。如果安装或运行附加组件的Firefox版本号高于这个最大版本号,附加组件将不能运行或不允许被安装。默认值为"*",意思为不对最大版本号做检查。{{gecko_minversion_inline("45")}}</li>
+ <li><code>update_url</code>为链接到<a href="/zh-CN/Add-ons/Updates">add-on update manifest</a>的链接。注意链接必须以"https"开头。这是为了使你自己就能够管理附加组件的更新(如不通过AMO)。{{gecko_minversion_inline("45")}}</li>
+</ul>
+
+<h2 id="Chrome不兼容性">Chrome不兼容性</h2>
+
+<p>你不能在Chrome附加组件中使用这个key。</p>
+
+<h2 id="示例">示例</h2>
+
+<p>示例中包含了所有可能的key。注意你通常不会包含<code>strict_max_version</code>或<code>update_url</code>key在大部分附加组件中。</p>
+
+<pre class="brush: json">"applications": {
+ "gecko": {
+ "id": "addon@example.com",
+ "strict_min_version": "42.0",
+    "strict_max_version": "50.*",
+ "update_url": "https://example.com/updates.json"
+ }
+}</pre>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/content_scripts/index.html b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/content_scripts/index.html
new file mode 100644
index 0000000000..9fab86d4b9
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/content_scripts/index.html
@@ -0,0 +1,216 @@
+---
+title: content_scripts
+slug: Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts
+tags:
+ - WebExtensions
+ - 扩展
+ - 附加组件
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts
+---
+<p>{{AddonSidebar}}</p>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <th scope="row" style="width: 30%;">类型</th>
+ <td>数组(<code>Array)</code></td>
+ </tr>
+ <tr>
+ <th scope="row">必要</th>
+ <td>否</td>
+ </tr>
+ <tr>
+ <th scope="row">示例</th>
+ <td>
+ <pre class="brush: json">
+"content_scripts": [
+ {
+ "matches": ["*://*.mozilla.org/*"],
+ "js": ["borderify.js"]
+ }
+]</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>让浏览器将<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">content scripts</a>加载到匹配网址的网站上</p>
+
+<p>此键(content_scripts)是一个数组,每个项目都是一个满足下列条件的对象:</p>
+
+<ul>
+ <li>
+ <p><strong>必须</strong>包含一个名为<strong><code>matches</code></strong>的键,指定要加载脚本的URL的格式</p>
+ </li>
+ <li>
+ <p><strong>可以</strong>包含一个名为<strong><code>js</code></strong>或<strong><code>css</code></strong>的键,<span>列出要加载到匹配页面的脚本</span></p>
+ </li>
+ <li>
+ <p><strong>可以</strong>包含控制如何加载、何时加载等方面更精细的属性</p>
+ </li>
+</ul>
+
+<p>下面表格列出了所有与你可以使用的键:</p>
+
+<table class="fullwidth-table standard-table">
+ <thead>
+ <tr>
+ <th scope="col">名称</th>
+ <th scope="col">类型</th>
+ <th scope="col">描述</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a id="all_frames" name="all_frames"><code>all_frames</code></a></td>
+ <td><code>Boolean</code></td>
+ <td>
+ <p><code>true</code>: 将<code><a href="#js">js</a></code>和<code><a href="#css">css</a></code>注入该页面所有的框架(frame)中</p>
+
+ <p><code>false</code>: 仅注入到顶层</p>
+
+ <p>默认为false</p>
+ </td>
+ </tr>
+ <tr>
+ <td><a id="css" name="css"><code>css</code></a></td>
+ <td><code>Array</code></td>
+ <td>
+ <p>一个数组,包含将会被注入到匹配页面的CSS文件的路径(路径相对于manifest.json)。</p>
+
+ <p>在加载DOM之前,文件将会按指定的顺序注入。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><a id="exclude_globs" name="exclude_globs"><code>exclude_globs</code></a></td>
+ <td><code>Array</code></td>
+ <td>
+ <div class="geckoVersionNote">Firefox 自48版本开始支持globs</div>
+
+ <p><span class="short_text" id="result_box" lang="zh-CN"><span>包含通配符的字符串数组。</span> <span>请参阅下面的<a href="#Matching_URL_patterns">匹配URL格式</a>。</span></span></p>
+ </td>
+ </tr>
+ <tr>
+ <td><a id="exclude_matches" name="exclude_matches"><code>exclude_matches</code></a></td>
+ <td><code>Array</code></td>
+ <td>一个<a href="/en-US/Add-ons/WebExtensions/match_patterns">match patterns</a>的数组,<span class="short_text" id="result_box" lang="zh-CN"><span>请参阅下面的<a href="#Matching_URL_patterns">匹配URL格式</a>。</span></span></td>
+ </tr>
+ <tr>
+ <td><a id="include_globs" name="include_globs"><code>include_globs</code></a></td>
+ <td><code>Array</code></td>
+ <td>
+ <div class="geckoVersionNote">Firefox 自48版本开始支持globs</div>
+ <span class="short_text" id="result_box" lang="zh-CN"><span>包含通配符的字符串数组。</span> <span>请参阅下面的<a href="#Matching_URL_patterns">匹配URL格式</a>。</span></span></td>
+ </tr>
+ <tr>
+ <td><a id="js" name="js"><code>js</code></a></td>
+ <td><code>Array</code></td>
+ <td>
+ <p>一个数组,包含将会被注入到匹配页面的JS文件的路径(路径相对于manifest.json)。</p>
+
+ <p>文件将会按指定的顺序注入。这意味着如果你想在另一个脚本中包含jQuery,可以这样做:</p>
+
+ <pre class="brush: json">
+<code>"js": ["jquery.js", "my-content-script.js"]</code></pre>
+
+ <p>接下来,<code>"my-content-script.js"</code>可以使用jQuery.</p>
+
+ <p><span class="short_text" id="result_box" lang="zh-CN"><span>文件将在<a href="#run_at">run_at</a>指定的时间注入。</span></span></p>
+ </td>
+ </tr>
+ <tr>
+ <td><a id="matches" name="matches"><code>matches</code></a></td>
+ <td><code>Array</code></td>
+ <td>
+ <p>一个<a href="/en-US/Add-ons/WebExtensions/match_patterns">match patterns</a>的数组,<span class="short_text" id="result_box" lang="zh-CN"><span>请参阅下面的<a href="#Matching_URL_patterns">匹配URL格式</a>。</span></span></p>
+
+ <p><span class="short_text" id="result_box" lang="zh-CN"><span>这是唯一的必须键。</span></span></p>
+ </td>
+ </tr>
+ <tr>
+ <td><a id="run_at" name="run_at"><code>run_at</code></a></td>
+ <td><code>String</code></td>
+ <td>
+ <p>此选项指定在<a href="#js">“js”键</a>中的脚本何时被注入。您可以使用下列的三个字符串之一,每个字符串都代表加载文档过程中的不同状态。状态直接对应于{{domxref("Document/readyState", "Document.readyState")}}:</p>
+
+ <ul>
+ <li>“<code>document_start</code>”:对应于正在加载。 <span>DOM仍在加载中。</span></li>
+ <li>“<code>document_end</code>”:对应于可交互。 <span>DOM已完成加载,但脚本和图像等资源可能仍在加载。</span></li>
+ <li>“<code>document_idle</code>”:对应完成。 <span>文档及其所有资源已完成加载。</span></li>
+ </ul>
+
+ <p>默认值为“document_idle”。</p>
+
+ <p>在所有情况下,<a href="#js">js键</a>中的文件都会在<a href="#css">css键</a>中的文件之后注入。</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="匹配URL格式">匹配URL格式</h2>
+
+<p>“content_scripts”键基于URL匹配将content scripts注入到网页上:如果网页的URL与键中的规则匹配,则将注入脚本。“content_scripts”中有四个属性,可以用于此规则:</p>
+
+<ul>
+ <li><code>matches</code>: 一个关于<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns">match patterns</a>的数组</li>
+ <li><code>exclude_matches:</code> 一个关于<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns">match patterns</a>的数组</li>
+ <li><code>include_globs</code>: 一个关于<a href="#globs">globs</a>的数组</li>
+ <li><code>exclude_globs:</code> 一个关于<a href="#globs">globs</a>的数组</li>
+</ul>
+
+<p>要匹配这些属性之一,网址必须与其数组中的至少一个项匹配。例如,指定一个属性:</p>
+
+<pre class="brush: json">"matches": ["*://*.example.org/*", "*://*.example.com/*"]</pre>
+
+<p>"http://example.org/"和"http://example.com/"都将会匹配</p>
+
+<p>由于matches是唯一的强制性键,其他三个键用于进一步限制匹配的URL。要匹配作为一个整体的键,网址必须:</p>
+
+<ol>
+ <li>匹配matches属性</li>
+ <li>并且,匹配include_globs属性(如果有)</li>
+ <li>并且,不匹配<code>exclude_matches</code>属性(如果有)</li>
+ <li>并且,不匹配<code>exclude_globs</code>属性(如果有)</li>
+</ol>
+
+<h3 id="globs">globs</h3>
+
+<div class="geckoVersionNote">Firefox 自48版本开始支持globs</div>
+
+<p>glob只是一个可以包含通配符的字符串。 有两种类型的通配符,您可以在一个glob中组合使用它们:</p>
+
+<ul>
+ <li>"*" 匹配零个或多个字符</li>
+ <li>"?" 匹配一个字符</li>
+</ul>
+
+<p><code>例如,"*na?i"</code>会匹配<code>"illuminati"和</code><code>"annunaki"</code>,但不会匹配<code>"sagnarelli"</code>.</p>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: json">"content_scripts": [
+ {
+ "matches": ["*://*.mozilla.org/*"],
+ "js": ["borderify.js"]
+ }
+]</pre>
+
+<p>这会将content脚本“borderify.js”插入到“mozilla.org”或其任何子域下的所有页面,无论是HTTP还是HTTPS。</p>
+
+<pre class="brush: json"> "content_scripts": [
+ {
+ "exclude_matches": ["*://developer.mozilla.org/*"],
+ "matches": ["*://*.mozilla.org/*"],
+ "js": ["jquery.js", "borderify.js"]
+ }
+ ]</pre>
+
+<p>这会将两个content脚本插入到“mozilla.org”及其任何子域(除“developer.mozilla.org”外)的所有页面中,无论是通过HTTP还是HTTPS。</p>
+
+<p>content脚本有相同的DOM视图,并按照它们在数组中出现的顺序注入,因此“borderify.js”可以访问由“jquery.js”添加的全局变量。</p>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.manifest.content_scripts")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/default_locale/index.html b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/default_locale/index.html
new file mode 100644
index 0000000000..9dc13eec3f
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/default_locale/index.html
@@ -0,0 +1,42 @@
+---
+title: default_locale
+slug: Mozilla/Add-ons/WebExtensions/manifest.json/default_locale
+tags:
+ - default_locale
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/default_locale
+---
+<p>{{AddonSidebar}}</p>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <th scope="row" style="width: 30%;">Type</th>
+ <td><code>String</code></td>
+ </tr>
+ <tr>
+ <th scope="row">强制性</th>
+ <td>可能发生的:如果存在_locales子目录,必须存在,否则不存在。</td>
+ </tr>
+ <tr>
+ <th scope="row">例子</th>
+ <td>
+ <pre class="brush: json">
+"default_locale": "en"</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>如果扩展名包含_locales目录,则该key必须存在,否则不得存在。它标识 _locales的一个子目录,该子目录将用于查找扩展名的默认字符串。</p>
+
+<p>见 <a href="/en-US/Add-ons/WebExtensions/Internationalization">国际化</a> 。</p>
+
+<h2 id="范例">范例</h2>
+
+<pre class="brush: json">"default_locale": "en"</pre>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.manifest.default_locale")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/description/index.html b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/description/index.html
new file mode 100644
index 0000000000..9081c82e10
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/description/index.html
@@ -0,0 +1,43 @@
+---
+title: 描述 - description
+slug: Mozilla/Add-ons/WebExtensions/manifest.json/description
+tags:
+ - 描述
+ - 附加组件
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/description
+---
+<div>{{AddonSidebar}}</div>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <th scope="row" style="width: 30%;">值类型</th>
+ <td><code>字符串</code></td>
+ </tr>
+ <tr>
+ <th scope="row">强制性</th>
+ <td>不强制</td>
+ </tr>
+ <tr>
+ <th scope="row">示例</th>
+ <td>
+ <pre class="brush: json">
+"description": "附加组件的主要功能特性的简短描述."</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>用于在用户下载安装使用界面中显示的一段简短的关于该附加组件的描述.</p>
+
+<p>关于本地化, 可查看 <a href="/en-US/Add-ons/WebExtensions/Internationalization#Internationalizing_manifest.json">localizable property</a>.</p>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: json">"description": "附加组件的主要功能特性的简短描述."</pre>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.manifest.description")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/developer/index.html b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/developer/index.html
new file mode 100644
index 0000000000..86c16d8da1
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/developer/index.html
@@ -0,0 +1,48 @@
+---
+title: developer
+slug: Mozilla/Add-ons/WebExtensions/manifest.json/developer
+tags:
+ - Developer
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/developer
+---
+<div>{{AddonSidebar}}</div>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <th scope="row" style="width: 30%;">值类型</th>
+ <td><code>对象</code></td>
+ </tr>
+ <tr>
+ <th scope="row">强制性</th>
+ <td>非强制</td>
+ </tr>
+ <tr>
+ <th scope="row">示例</th>
+ <td>
+ <pre class="brush: json">
+"developer": {
+ "name": "Walt Whitman",
+ "url": "https://en.wikipedia.org/wiki/Walt_Whitman"
+}</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>插件开发者的名字和主页地址,用于显示在浏览器的用户界面中。</p>
+
+<p>该对象的两个属性都是可选的。如果存在“name”和“url”属性,将会分别覆盖<a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/author">author</a>和<a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/homepage_url">homepage_url</a>键。这个对象仅仅允许指定一个开发者名字的主页地址。</p>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: json">"developer": {
+ "name": "Walt Whitman",
+ "url": "https://en.wikipedia.org/wiki/Walt_Whitman"
+}</pre>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.manifest.developer")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/index.html b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/index.html
new file mode 100644
index 0000000000..281382d382
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/index.html
@@ -0,0 +1,140 @@
+---
+title: manifest.json
+slug: Mozilla/Add-ons/WebExtensions/manifest.json
+tags:
+ - JSON
+ - manifest.json
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json
+---
+<div>{{AddonSidebar}}</div>
+
+<div class="blockIndicator note">
+<p>本文描述的是适用于 WebExtensions 的 manifest.json。若您正在寻找适用于 PWA 的 manifest.json 的有关信息,请参考这篇文章:<a href="/zh-CN/docs/Web/Manifest">Web App Manifest</a>。</p>
+</div>
+
+<div><code>manifest.json</code> 是每个 WebExtension 唯一必须包含的元数据文件。</div>
+
+<p>通过使用 <code>manifest.json</code>,您可以指定扩展的基本元数据,例如名称和版本,还可以指定扩展各个方面的功能(例如后台脚本,内容脚本和某些浏览器行为)。</p>
+
+
+<p>它是一个允许使用 "<code>//</code>" 撰写单行注释的、特殊的 <a href="/zh-CN/docs/Glossary/JSON">JSON</a> 文件。</p>
+
+<h2 id="manifest.json_键列表">manifest.json 键列表</h2>
+
+<p>支持的 <code>manifest.json</code> 键如下所示:</p>
+
+<h3 id="简体中文内容">简体中文内容</h3>
+
+<div class="index">{{ListSubpages("/zh-CN/Add-ons/WebExtensions/manifest.json")}}</div>
+
+<h3 id="英文内容">英文内容</h3>
+
+<div class="index">{{ListSubpages("/en-US/Add-ons/WebExtensions/manifest.json")}}</div>
+
+<ul>
+ <li><code>"manifest_version"</code>,<code>"version"</code>,和 <code>"name"</code> 是唯一的强制必填键。</li>
+ <li>如果 "_locales" 目录存在的话,"<code>default_locale"</code> 也必须相应存在,否则不应存在。</li>
+ <li>Google Chrome 不支持 <code>"browser_specific_settings"</code></li>
+</ul>
+
+<h3 id="在运行时访问_manifest.json_键">在运行时访问 manifest.json 键</h3>
+
+<p>你可以在拓展的 JavaScript 代码中通过 {{WebExtAPIRef("runtime.getManifest()")}} 函数访问拓展的 manifest 数据:</p>
+
+<pre class="brush: js; no-line-numbers">browser.runtime.getManifest().version;</pre>
+
+<h2 id="示例">示例</h2>
+
+<p>The block below shows the basic syntax for some common manifest keys.</p>
+
+<div class="blockIndicator note">
+<p><strong>Note:</strong> This is not intended to be used as a copy-paste-ready example. Selecting the keys you'll need depends on the extension you are developing.</p>
+</div>
+
+<p>For complete example extensions, see <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Examples">Example extensions</a>.</p>
+
+<pre class="brush: json;">{
+ "browser_specific_settings": {
+ "gecko": {
+ "id": "addon@example.com",
+ "strict_min_version": "42.0"
+ }
+ },
+
+ "background": {
+ "scripts": ["jquery.js", "my-background.js"],
+ },
+
+ "browser_action": {
+ "default_icon": {
+ "19": "button/geo-19.png",
+ "38": "button/geo-38.png"
+ },
+ "default_title": "Whereami?",
+ "default_popup": "popup/geo.html"
+ },
+
+ "commands": {
+ "toggle-feature": {
+ "suggested_key": {
+ "default": "Ctrl+Shift+Y",
+ "linux": "Ctrl+Shift+U"
+ },
+ "description": "Send a 'toggle-feature' event"
+ }
+ },
+
+ "content_security_policy": "script-src 'self' https://example.com; object-src 'self'",
+
+ "content_scripts": [
+ {
+ "exclude_matches": ["*://developer.mozilla.org/*"],
+ "matches": ["*://*.mozilla.org/*"],
+ "js": ["borderify.js"]
+ }
+ ],
+
+ "default_locale": "en",
+
+ "description": "...",
+
+ "icons": {
+ "48": "icon.png",
+ "96": "icon@2x.png"
+ },
+
+ "manifest_version": 2,
+
+ "name": "...",
+
+ "page_action": {
+ "default_icon": {
+ "19": "button/geo-19.png",
+ "38": "button/geo-38.png"
+ },
+ "default_title": "Whereami?",
+ "default_popup": "popup/geo.html"
+ },
+
+ "permissions": ["webNavigation"],
+
+ "version": "0.1",
+
+ "user_scripts": {
+ "api_script": "apiscript.js",
+ },
+
+ "web_accessible_resources": ["images/my-image.png"]
+}</pre>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>For a full overview of all manifest keys and their sub-keys, see the<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Browser_compatibility_for_manifest.json"> full <code>manifest.json</code> browser compatibility table</a>.</p>
+
+
+
+<p>{{Compat("webextensions.manifest")}}</p>
+
+<h2 id="参见">参见</h2>
+
+<p>{{WebExtAPIRef("permissions")}} JavaScript API</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/manifest_version/index.html b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/manifest_version/index.html
new file mode 100644
index 0000000000..9d67a37b89
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/manifest_version/index.html
@@ -0,0 +1,45 @@
+---
+title: manifest_version
+slug: Mozilla/Add-ons/WebExtensions/manifest.json/manifest_version
+tags:
+ - WebExtensions
+ - 拓展
+ - 附加组件
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/manifest_version
+---
+<p>{{AddonSidebar}}</p>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <th scope="row" style="width: 30%;">值类型</th>
+ <td><code>Number</code></td>
+ </tr>
+ <tr>
+ <th scope="row">强制性</th>
+ <td>强制</td>
+ </tr>
+ <tr>
+ <th scope="row">示例</th>
+ <td>
+ <pre class="brush: json">
+"manifest_version": 2</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>此键指定扩展使用的 manifest.json 的版本。</p>
+
+<p>目前,此值必须为 2。</p>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: json">"manifest_version": 2
+</pre>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.manifest.manifest_version")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/name/index.html b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/name/index.html
new file mode 100644
index 0000000000..3869571374
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/name/index.html
@@ -0,0 +1,43 @@
+---
+title: 名称 - name
+slug: Mozilla/Add-ons/WebExtensions/manifest.json/name
+tags:
+ - 名称
+ - 附加组件
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/name
+---
+<div>{{AddonSidebar}}</div>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <th scope="row" style="width: 30%;">值类型</th>
+ <td><code>字符串(String)</code></td>
+ </tr>
+ <tr>
+ <th scope="row">强制性</th>
+ <td>强制</td>
+ </tr>
+ <tr>
+ <th scope="row">示例</th>
+ <td>
+ <pre class="brush: json">
+"name": "附加组件的名称"</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>附加组件的名称. 用于在用户界面和 addons.mozilla.org 网站上显示标识名称.</p>
+
+<p>关于本地化, 可查看 <a href="/en-US/Add-ons/WebExtensions/Internationalization#Internationalizing_manifest.json">localizable property</a>.</p>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: json">"name": "插件的名称"</pre>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.manifest.name")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/permissions/index.html b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/permissions/index.html
new file mode 100644
index 0000000000..f26782540e
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/permissions/index.html
@@ -0,0 +1,182 @@
+---
+title: 权限 - permissions
+slug: Mozilla/Add-ons/WebExtensions/manifest.json/permissions
+tags:
+ - 权限
+ - 附加组件
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/permissions
+---
+<p>{{AddonSidebar}}</p>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <th scope="row" style="width: 30%;">值类型</th>
+ <td><code>数组</code></td>
+ </tr>
+ <tr>
+ <th scope="row">强制性</th>
+ <td>不强制</td>
+ </tr>
+ <tr>
+ <th scope="row">示例</th>
+ <td>
+ <pre class="brush: json notranslate">
+"permissions": [
+ "*://developer.mozilla.org/*",
+ "webRequest"
+]</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>使用permissions 关键字为你的扩展请求特殊的权限。该关键字为一个字符串数列,每个字符串请求一项权限。</p>
+
+<p>如果你使用该关键字请求权限,浏览器可能会在安装该扩展时通知用户该扩展需求某些权限,并询问他们是否愿意给予这些权限。在插件安装之后浏览器也可能允许用户检查扩展的权限。因为要求授予权限可能会影响用户安装你的扩展的意愿,所以请求权限需要特别小心的考虑。举个例子,你想要避免请求不必要的权限,而且可以在你的扩展描述中提供你为何需要某些权限的信息。更多关于这个话题的描述你可以参考这篇提供的文章 <a href="https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Request_the_right_permissions">请求正确的权限</a>。</p>
+
+<p>该关键字能够包含三种类型的权限:</p>
+
+<ul>
+ <li>主机权限</li>
+ <li>API 权限</li>
+ <li>活动标签权限</li>
+</ul>
+
+<h2 id="主机权限">主机权限</h2>
+
+<p> 主机权限使用 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns">match patterns </a>指定,扩展在每一个表达式指定的网址上请求额外权限。</p>
+
+<p>额外权限包括:</p>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest">XMLHttpRequest</a> 和 <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API">fetch</a> 用于访问无跨源限制的源文件(包括从content scripts发出的访问请求)</li>
+ <li>以编程方式(使用 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/executeScript">tabs.executeScript</a>)将脚本注入到来自源服务器(origins)提供的页面的功能。</li>
+ <li>使用 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest">webRequest</a> 在其主机上获取消息的能力。</li>
+ <li>使用 <a href="/en-US/Add-ons/WebExtensions/API/cookies">cookies</a> API 访问主机cookies的能力,只要 cookies api的权限也被请求。</li>
+ <li>使用无通配符(*)的全域名会绕开跟踪保护机制,但不能与 <code>&lt;all_urls&gt;</code> 共用.</li>
+</ul>
+
+<p>Firefox浏览器,自56以后的版本,扩展都会自动获取其源的主机权限,如以下形式:</p>
+
+<pre class="notranslate"><code>moz-extension://60a20a9b-1ad4-af49-9b6c-c64c98c37920/</code></pre>
+
+<p><code>60a20a9b-1ad4-af49-9b6c-c64c98c37920</code> 是扩展内部ID。编程时可使用 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/extension/getURL">extension.getURL()</a> 来返回此URL路径:</p>
+
+<ol>
+ <li>
+ <pre class="notranslate"><code>browser.extension.getURL("");
+// </code><code>moz-extension://60a20a9b-1ad4-af49-9b6c-c64c98c37920/</code></pre>
+ </li>
+</ol>
+
+<h2 id="API_权限">API 权限</h2>
+
+<p>API 权限有关键字指定,每个关键字标志着一类WebExtension API 能够被使用。</p>
+
+<p>如下关键字是当前可用的:</p>
+
+<ul>
+ <li><code>activeTab</code></li>
+ <li><code>alarms</code></li>
+ <li><code>bookmarks</code></li>
+ <li><code>browsingData</code></li>
+ <li><code>browserSettings</code></li>
+ <li><code>contextMenus</code></li>
+ <li><code>contextualIdentities</code></li>
+ <li><code>cookies</code></li>
+ <li><code>downloads</code></li>
+ <li><code>downloads.open</code></li>
+ <li><code>find</code></li>
+ <li><code>geolocation</code></li>
+ <li><code>history</code></li>
+ <li><code>identity</code></li>
+ <li><code>idle</code></li>
+ <li><code>management</code></li>
+ <li><code>menus</code></li>
+ <li><code>nativeMessaging</code></li>
+ <li><code>notifications</code></li>
+ <li><code>pkcs11</code></li>
+ <li><code>privacy</code></li>
+ <li><code>proxy</code></li>
+ <li><code>sessions</code></li>
+ <li><code>storage</code></li>
+ <li><code>tabs</code></li>
+ <li><code>theme</code></li>
+ <li><code>topSites</code></li>
+ <li><code>webNavigation</code></li>
+ <li><code>webRequest</code></li>
+ <li><code>webRequestBlocking</code></li>
+</ul>
+
+<p>在大部分情况下这种权限仅仅允许你访问API,除了以下情况:</p>
+
+<ul>
+ <li><code>tabs</code>让你可以访问 <a href="/en-US/Add-ons/WebExtensions/API/tabs"><code>一部分特权API</code></a>: <code>Tab.url</code>, <code>Tab.title</code>, and <code>Tab.faviconUrl</code>。在Firefox中你也需要<code>tabs </code>来将queryInfo中的url参数加入 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/query">tabs.query()</a></code>. 剩余的<code>tabs</code> API能在不要求任何权限的情况被使用</li>
+ <li><code>webRequestBlocking</code> 允许你是用“blocking”参数,所以你可以<a href="/en-US/Add-ons/WebExtensions/API/WebRequest"> 修改或取消requests</a>.</li>
+ <li><code>downloads.open</code> 让你使用 {{WebExtAPIRef("downloads.open()")}} API.</li>
+</ul>
+
+<h2 id="活动标签权限">活动标签权限</h2>
+
+<p>该权限被指定为<code>“activeTab”</code>。如果一个扩展拥有<code>activeTab</code>权限,当用户跟该扩展交互时,扩展仅在活动标签被赋予额外权限。</p>
+
+<p>“用户交互”包括:</p>
+
+<ul>
+ <li>用户点击扩展的浏览器按钮或者页面按钮</li>
+ <li>用户选择了扩展的上下文菜单</li>
+ <li>用户敲击了扩展定义的快捷键</li>
+</ul>
+
+<p>额外特权包括:</p>
+
+<ul>
+ <li>插入JavaScript或者CSS的能力, 使用 <code><a href="/en-US/Add-ons/WebExtensions/API/tabs/executeScript">browser.tabs.executeScript</a></code> 和 <code><a href="/en-US/Add-ons/WebExtensions/API/tabs/insertCSS">browser.tabs.insertCSS</a></code></li>
+ <li>为当前标签访问tabs API权限部分的能力,包括:Tab.url,Tab.title, 和Tab .faviconUrl。</li>
+</ul>
+
+<p>改权限的目的是为了在不给予扩展太多权限的情况下,使得扩展能够应付大部分情况。很多扩展需要在用户要求时,在当前页面做一些处理,比如,考虑一个扩展想要在用户点击一个浏览器按钮时在当前页面运行一个脚本,如果 activeTab 权限不存在,扩展将需要请求主机权限&lt;all_urls&gt;,但是这给予了扩展超过其需要的权限:现在它可以在任何任何时间标签页执行脚本任何次,而不是仅仅在活动标签而且仅仅回应用户的行为。</p>
+
+<h2 id="剪贴板访问">剪贴板访问</h2>
+
+<p>有两种权限使得WebExtentsion可以跟剪贴板交互:</p>
+
+<ul>
+ <li><code>clipboardWrite</code>: 使用<code>document.execCommand("copy")</code> 或<code>document.execCommand("cut")</code> 向剪贴板写入</li>
+ <li><code>clipboardRead</code>: 使用 <code>document.execCommand("paste")</code> 从剪贴板读取</li>
+</ul>
+
+<p>查看 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard">Interact with the clipboard</a> 获取更多</p>
+
+<h2 id="无限制存储">无限制存储</h2>
+
+<p><code>unlimitedStorage</code> 权限:</p>
+
+<ul>
+ <li>能使扩展突破{{WebExtAPIRef("storage.local")}} API设定的quota限制</li>
+ <li>Firefox浏览器中,无须提示用户授权,便可帮助扩展创建永久保存的IndexedDB数据库 <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Browser_storage_limits_and_eviction_criteria#Firefox_specifics">"persistent" IndexedDB database</a></li>
+</ul>
+
+<dl>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: json notranslate"> "permissions": ["*://developer.mozilla.org/*"]</pre>
+
+<p>请求 developer.mozilla.org 下的权限访问.</p>
+
+<pre class="brush: json notranslate"> "permissions": ["tabs"]</pre>
+
+<p>请求tabs API的权限需要部分的访问。</p>
+
+<pre class="brush: json notranslate"> "permissions": ["*://developer.mozilla.org/*", "tabs"]</pre>
+
+<p>请求以上两种访问。</p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>本页的兼容列表是从结构化数据生成的。如果你想参与修改此数据,请参考 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 并发送pull 请求。</p>
+
+<p>{{Compat("webextensions.manifest.permissions")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/short_name/index.html b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/short_name/index.html
new file mode 100644
index 0000000000..444dac6eaa
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/short_name/index.html
@@ -0,0 +1,43 @@
+---
+title: 短名称 - short_name
+slug: Mozilla/Add-ons/WebExtensions/manifest.json/short_name
+tags:
+ - 短名称
+ - 附加组件
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/short_name
+---
+<div>{{AddonSidebar}}</div>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <th scope="row" style="width: 30%;">Type</th>
+ <td><code>String</code></td>
+ </tr>
+ <tr>
+ <th scope="row">强制性</th>
+ <td>不强制</td>
+ </tr>
+ <tr>
+ <th scope="row">示例</th>
+ <td>
+ <pre class="brush: json">
+"short_name": "附加组件的短名称"</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>附加组件的短名称. 一般用在 <a href="/en-US/Add-ons/WebExtensions/manifest.json/name">name</a> 特性太长的情况下. 建议短名称的长度不要超过12个字符. 如果没有在 manifest.json 主文件中声明 short_name, 并且 name 特性的值又比较长的话, 用户界面显示的时候可能只会显示一部分. </p>
+
+<p>关于本地化, 可查看 <a href="/en-US/Add-ons/WebExtensions/Internationalization#Internationalizing_manifest.json">localizable property</a>.</p>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: json">"short_name": "附加组件的短名称"</pre>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.manifest.short_name")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/version/index.html b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/version/index.html
new file mode 100644
index 0000000000..98028f9235
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/version/index.html
@@ -0,0 +1,49 @@
+---
+title: version
+slug: Mozilla/Add-ons/WebExtensions/manifest.json/version
+tags:
+ - version
+ - 版本信息
+ - 附加组件
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/version
+---
+<p>{{AddonSidebar}}</p>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <th scope="row" style="width: 30%;">Type</th>
+ <td><code>String</code></td>
+ </tr>
+ <tr>
+ <th scope="row">强制性</th>
+ <td>强制</td>
+ </tr>
+ <tr>
+ <th scope="row">示例</th>
+ <td>
+ <pre class="brush: json">
+"version": "0.1"</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>附加组件的版本, 一般格式设置为由点分隔开来数字的ASCII字符串. 关于版本格式的详细信息, 请查看 <a href="https://developer.mozilla.org/en-US/docs/Toolkit_version_format">Version format</a> .</p>
+
+<p>需要注意的是 Chrome 浏览器的 version 格式要求(<a href="https://developer.chrome.com/extensions/manifest/version">the syntax defined for Chrome's <code>version</code></a>)比 Firefox 浏览器的 version 格式更严格一些, 这意味这:</p>
+
+<ul>
+ <li>对 Chrome 浏览器有效的 version 特性的值一定在 Firefox 浏览器中有效</li>
+ <li>但对 Firefox 浏览器有效的 version 特性的值在 Chrome 浏览器中却不一定有效</li>
+</ul>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: json">"version": "0.1"</pre>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.manifest.version")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/web_accessible_resources/index.html b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/web_accessible_resources/index.html
new file mode 100644
index 0000000000..713741a26b
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/web_accessible_resources/index.html
@@ -0,0 +1,96 @@
+---
+title: web_accessible_resources
+slug: Mozilla/Add-ons/WebExtensions/manifest.json/web_accessible_resources
+tags:
+ - 扩展应用
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/web_accessible_resources
+---
+<p>{{AddonSidebar}}</p>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <th scope="row" style="width: 30%;">类型</th>
+ <td><code>Array</code></td>
+ </tr>
+ <tr>
+ <th scope="row">是否必需</th>
+ <td>No</td>
+ </tr>
+ <tr>
+ <th scope="row">示例</th>
+ <td>
+ <pre class="brush: json no-line-numbers">
+"web_accessible_resources": [
+ "images/my-image.png"
+]</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="描述">描述</h2>
+
+<p>你有时想将资源(如图片、HTML、CSS 或 JavaScript)与你的扩展应用合并打包,让网页能够访问它们。</p>
+
+<p>举个例子,<a href="https://github.com/mdn/webextensions-examples/tree/master/beastify">Beastify example extension</a> 将用户选择的野兽图片来替换网页,这些图片与应用是经过合并打包的。该应用添加 <code><a href="/en-US/docs/Web/HTML/Element/img">&lt;img&gt;</a></code>,其 <code>src</code> 指向图片,这样就使选中的图片可见了。网页要载入图片的话,这些图片就必须可经访问。</p>
+
+<p>通过 <code>web_accessible_resources</code>, 你列出资源,让它们可经网页访问。这些资源路径相对于 manifest.json 文件.</p>
+
+<p>注意,这其中不必包括 content scripts。</p>
+
+<p>如果你的应用要用 {{WebExtAPIRef("webRequest")}} 来重定向公共 URL(如 HTTPS) 到一个该应用中的页面, 那么应用必须将该页面列入<code>web_accessible_resources</code>。</p>
+
+<h3 id="使用_web_accessible_resources">使用 web_accessible_resources</h3>
+
+<p>例如,如果你的应用含有图片,路径为 images/my-image.png,如下所示:</p>
+
+<pre class="no-line-numbers">my-extension-files/
+ manifest.json
+ my-background-script.js
+ images/
+ my-image.png</pre>
+
+<p>如果要使网页能够从元素 <code><a href="/en-US/docs/Web/HTML/Element/img">&lt;img&gt;</a></code> 的属性 <code>src</code> 指向该图片,你得写明<code>web_accessible_resources</code>,如下所示:</p>
+
+<pre class="brush: json no-line-numbers">"web_accessible_resources": ["images/my-image.png"]</pre>
+
+<p>之后,图片可通过 URL 来访问,如下所示:</p>
+
+<pre class="no-line-numbers">moz-extension://&lt;extension-UUID&gt;/images/my-image.png"</pre>
+
+<p><code>&lt;extension-UUID&gt;</code> 不是应用 ID,它随机生成,对应每个浏览器实例,以防网页查看浏览器安装的扩展应用来获取信息。</p>
+
+<div class="blockIndicator note">
+<p>Chrome 的 <code>&lt;extension-UUID&gt;</code> 是不变的。某资源如果由<code>web_accessible_resources</code> 写明,那么它可通过 <code>chrome-extension://&lt;your-extension-id&gt;/&lt;path/to/resource&gt;</code> 来访问。  </p>
+</div>
+
+<p>要获得资源的 URL,推荐用 <code><a href="/en-US/Add-ons/WebExtensions/API/runtime/getURL">runtime.getURL</a></code> 向参数传递 manifest.json 的相对路径,比如:</p>
+
+<pre class="brush: js no-line-numbers">browser.runtime.getURL("images/my-image.png");
+// something like:
+// moz-extension://944cfddf-7a95-3c47-bd9a-663b3ce8d699/images/my-image.png</pre>
+
+<p>这会返回正确的 URL,不受应用运行的浏览器影响。</p>
+
+<h3 id="通配符">通配符</h3>
+
+<p><code>web_accessible_resources</code>  中的条目还可以有通配符。比如,下面的条目匹配“images/my-image.png”:</p>
+
+<pre class="brush: json no-line-numbers"> "web_accessible_resources": ["images/*.png"]</pre>
+
+<h3 id="安全">安全</h3>
+
+<p>注意,如果你部署了一个页面,那么任一网页可能会链接或重定向至该页面,因而它应认为任意输入(比如 POST data)的来源不可信任,这与通常网页的做法一样。</p>
+
+<h2 id="Example">Example</h2>
+
+<pre class="brush: json no-line-numbers">"web_accessible_resources": ["images/my-image.png"]</pre>
+
+<p>Make the file at "images/my-image.png" web accessible.</p>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.manifest.web_accessible_resources")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/主页地址/index.html b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/主页地址/index.html
new file mode 100644
index 0000000000..01749d5ff3
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/manifest.json/主页地址/index.html
@@ -0,0 +1,42 @@
+---
+title: homepage_url
+slug: Mozilla/Add-ons/WebExtensions/manifest.json/主页地址
+translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/homepage_url
+---
+<div>{{AddonSidebar}}</div>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <th scope="row" style="width: 30%;">值类型</th>
+ <td><code>字符串(String)</code></td>
+ </tr>
+ <tr>
+ <th scope="row">强制性</th>
+ <td>非强制</td>
+ </tr>
+ <tr>
+ <th scope="row">示例</th>
+ <td>
+ <pre class="brush: json">
+"homepage_url": "https://example.org/my-addon"</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>该扩展的主页地址。</p>
+
+<p>如果 <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/developer">developer</a> 键存在且包含“url”属性,它将会覆盖 <code>homepage_url</code> 键。</p>
+
+<p>这是一个 <a href="/en-US/Add-ons/WebExtensions/Internationalization#Internationalizing_manifest.json">localizable property</a>.</p>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: json">"homepage_url": "https://github.com/mdn/webextensions-examples/tree/master/beastify"</pre>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("webextensions.manifest.homepage_url")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/match_patterns/index.html b/files/zh-cn/mozilla/add-ons/webextensions/match_patterns/index.html
new file mode 100644
index 0000000000..44df7ebb7f
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/match_patterns/index.html
@@ -0,0 +1,384 @@
+---
+title: 匹配模式
+slug: Mozilla/Add-ons/WebExtensions/Match_patterns
+tags:
+ - Match_patterns
+ - URIs
+ - urls
+translation_of: Mozilla/Add-ons/WebExtensions/Match_patterns
+---
+<div>{{AddonSidebar}}</div>
+
+<p>匹配模式是一种指定网址组的方法:: 一个匹配模式匹配特定的一组URL。 它们由WebExtensions 在几个地方使用,最明显的是指定要将<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">内容脚本</a>加载到哪些文档中,并指定要向其中添加 <a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API/webRequest">webRequest </a>侦听器的URL。</p>
+
+<p>使用匹配模板的API通常接收一个匹配模板的列表,当URL匹配任何模式时会恰当的运行. 看个例子 在manifest.json中的 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts">content_scripts</a></code> 关键字。</p>
+
+<h2 id="匹配模式结构">匹配模式结构</h2>
+
+<p>所有的匹配模式用一个字符串来定义,而且都是<a href="/en-US/Add-ons/WebExtensions/Match_patterns#%3Call_urls%3E">"&lt;all_urls&gt;"</a> 模板的一部份, 匹配模板包含三个部分: <em>scheme</em>, <em>host</em>, 和 <em>path</em>.  scheme  host 用 "://" 分隔。</p>
+
+<pre>&lt;scheme&gt;://&lt;host&gt;&lt;path&gt;</pre>
+
+<h3 id="方案">方案</h3>
+
+<p> <em>scheme</em>  可能以下两种格式之一:</p>
+
+<table class="fullwidth-table standard-table">
+ <thead>
+ <tr>
+ <th scope="col" style="width: 50%;">Form</th>
+ <th scope="col">Matches</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>"*"</td>
+ <td>Only "http" and "https".</td>
+ </tr>
+ <tr>
+ <td>One of "http", "https", "file", "ftp", "app".</td>
+ <td>Only the given scheme.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="主机">主机</h3>
+
+<p> <em>host </em>组件可以采取三种形式之一::</p>
+
+<table class="fullwidth-table standard-table">
+ <thead>
+ <tr>
+ <th scope="col" style="width: 50%;">Form</th>
+ <th scope="col">Matches</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>"*"</td>
+ <td>Any host.</td>
+ </tr>
+ <tr>
+ <td>"*." followed by part of the hostname.</td>
+ <td>The given host and any of its subdomains.</td>
+ </tr>
+ <tr>
+ <td>A complete hostname, without wildcards.</td>
+ <td>Only the given host.</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>只有当 <em>scheme</em> 是 "file" 是 <em>host</em> 可选的</p>
+
+<p>值得注意的是通配符可能只会在开头显示。</p>
+
+<h3 id="路径">路径</h3>
+
+<p><em>path </em>组件必须以“/”开头。</p>
+
+<p>之后,它可能随后包含“*”通配符和网址路径中允许的任何字符的任意组合。 与 <em>host </em>不同, <em>path </em>组件可能在中间或末尾包含“*”通配符,并且“*”通配符可以多次出现。</p>
+
+<h3 id="&lt;all_urls>">&lt;all_urls&gt;</h3>
+
+<p>特殊值“&lt;all_urls&gt;”匹配任何受支持方案下的所有URL:即, "http", "https", "file", "ftp", "app"。</p>
+
+<h2 id="范例">范例</h2>
+
+<table class="fullwidth-table standard-table">
+ <thead>
+ <tr>
+ <th scope="col" style="width: 33%;">Pattern</th>
+ <th scope="col" style="width: 33%;">Example matches</th>
+ <th scope="col" style="width: 33%;">Example non-matches</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>
+ <p><code>&lt;all_urls&gt;</code></p>
+
+ <p>Match all URLs.</p>
+ </td>
+ <td>
+ <p><code>http://example.org/</code></p>
+
+ <p><code>ftp://files.somewhere.org/</code></p>
+
+ <p><code>https://a.org/some/path/</code></p>
+ </td>
+ <td>
+ <p><code>resource://a/b/c/</code><br>
+ (unsupported scheme)</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p><code>*://*.mozilla.org/*</code></p>
+
+ <p>Match all HTTP and HTTPS URLs that are hosted at "mozilla.org" or one of its subdomains.</p>
+ </td>
+ <td>
+ <p><code>http://mozilla.org/</code></p>
+
+ <p><code>https://mozilla.org/</code></p>
+
+ <p><code>http://a.mozilla.org/</code></p>
+
+ <p><code>http://a.b.mozilla.org/</code></p>
+
+ <p><code>https://b.mozilla.org/path/</code></p>
+ </td>
+ <td>
+ <p><code>ftp://mozilla.org/</code><br>
+ (unmatched scheme)</p>
+
+ <p><code>http://mozilla.com/</code><br>
+ (unmatched host)</p>
+
+ <p><code>http://firefox.org/</code><br>
+ (unmatched host)</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p><code>*://mozilla.org/</code></p>
+
+ <p>Match all HTTP and HTTPS URLs that are hosted at exactly "mozilla.org/".</p>
+ </td>
+ <td>
+ <p><code>http://mozilla.org/</code></p>
+
+ <p><code>https://mozilla.org/</code></p>
+ </td>
+ <td>
+ <p><code>ftp://mozilla.org/</code><br>
+ (unmatched scheme)</p>
+
+ <p><code>http://a.mozilla.org/</code><br>
+ (unmatched host)</p>
+
+ <p><code>http://mozilla.org/a</code><br>
+ (unmatched path)</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p><code>ftp://mozilla.org/</code></p>
+
+ <p>Match only "ftp://mozilla.org/".</p>
+ </td>
+ <td><code>ftp://mozilla.org</code></td>
+ <td>
+ <p><code>http://mozilla.org/</code><br>
+ (unmatched scheme)</p>
+
+ <p><code>ftp://sub.mozilla.org/</code><br>
+ (unmatched host)</p>
+
+ <p><code>ftp://mozilla.org/path</code><br>
+ (unmatched path)</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p><code>https://*/path</code></p>
+
+ <p>Match HTTPS URLs on any host, whose path is "path".</p>
+ </td>
+ <td>
+ <p><code>https://mozilla.org/path</code></p>
+
+ <p><code>https://a.mozilla.org/path</code></p>
+
+ <p><code>https://something.com/path</code></p>
+ </td>
+ <td>
+ <p><code>http://mozilla.org/path</code><br>
+ (unmatched scheme)</p>
+
+ <p><code>https://mozilla.org/path/</code><br>
+ (unmatched path)</p>
+
+ <p><code>https://mozilla.org/a</code><br>
+ (unmatched path)</p>
+
+ <p><code>https://mozilla.org/</code><br>
+ (unmatched path)</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p><code>https://*/path/</code></p>
+
+ <p>Match HTTPS URLs on any host, whose path is "path/".</p>
+ </td>
+ <td>
+ <p><code>https://mozilla.org/path/</code></p>
+
+ <p><code>https://a.mozilla.org/path/</code></p>
+
+ <p><code>https://something.com/path</code>/</p>
+ </td>
+ <td>
+ <p><code>http://mozilla.org/path/</code><br>
+ (unmatched scheme)</p>
+
+ <p><code>https://mozilla.org/path</code><br>
+ (unmatched path)</p>
+
+ <p><code>https://mozilla.org/a</code><br>
+ (unmatched path)</p>
+
+ <p><code>https://mozilla.org/</code><br>
+ (unmatched path)</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p><code>https://mozilla.org/*</code></p>
+
+ <p>Match HTTPS URLs only at "mozilla.org", with any path.</p>
+ </td>
+ <td>
+ <p><code>https://mozilla.org/</code></p>
+
+ <p><code>https://mozilla.org/path</code></p>
+
+ <p><code>https://mozilla.org/another</code></p>
+
+ <p><code>https://mozilla.org/path/to/doc</code></p>
+ </td>
+ <td>
+ <p><code>http://mozilla.org/path</code><br>
+ (unmatched scheme)</p>
+
+ <p><code>https://mozilla.com/path</code><br>
+ (unmatched host)</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p><code>https://mozilla.org/a/b/c/</code></p>
+
+ <p>Match only this URL.</p>
+ </td>
+ <td><code>https://mozilla.org/a/b/c/</code></td>
+ <td>Anything else.</td>
+ </tr>
+ <tr>
+ <td>
+ <p><code>https://mozilla.org/*/b/*/</code></p>
+
+ <p>Match HTTPS URLs hosted on "mozilla.org", whose path contains a component "b" somewhere in the middle.</p>
+ </td>
+ <td>
+ <p><code>https://mozilla.org/a/b/c/</code></p>
+
+ <p><code>https://mozilla.org/d/b/f/</code></p>
+
+ <p><code>https://mozilla.org/a/b/c/d/</code></p>
+ </td>
+ <td>
+ <p><code>https://mozilla.org/b/*/</code><br>
+ (unmatched path)</p>
+
+ <p><code>https://mozilla.org/a/b/</code><br>
+ (unmatched path)</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p><code>file:///blah/*</code></p>
+
+ <p>Match any FILE URL whose path begins with "blah".</p>
+ </td>
+ <td>
+ <p><code>file:///blah/</code></p>
+
+ <p><code>file:///blah/bleh</code></p>
+ </td>
+ <td><code>file:///bleh/</code><br>
+ (unmatched path)</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="无效匹配模式">无效匹配模式</h3>
+
+<table class="fullwidth-table standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Invalid pattern</th>
+ <th scope="col">Reason</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>resource://path/</code></td>
+ <td>Unsupported scheme.</td>
+ </tr>
+ <tr>
+ <td><code>https://mozilla.org</code></td>
+ <td>No path.</td>
+ </tr>
+ <tr>
+ <td><code>https://mozilla.*.org/</code></td>
+ <td>"*" in host must be at the start.</td>
+ </tr>
+ <tr>
+ <td><code>https://*zilla.org/</code></td>
+ <td>"*" in host must by the only character or be followed by ".".</td>
+ </tr>
+ <tr>
+ <td><code>http*://mozilla.org/</code></td>
+ <td>"*" in scheme must be the only character.</td>
+ </tr>
+ <tr>
+ <td><code>file://*</code></td>
+ <td>Empty path: this should be "<code>file:///*</code>".</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="测试匹配模式">测试匹配模式</h2>
+
+<p>当制作扩展时你通常不会跟直接使用匹配模板: 通常你讲一个匹配模式传递给API,然后API构造一个匹配模式并且使用他来测试url。不过如果你正在尝试哪一种匹配模式可以被使用,或者调试一个匹配问题,那么直接创建和测试匹配模板的能力将变得有用,这个模块将解释如何做到这点。</p>
+
+<p>首先,打开开发者工具设置,并且检查 "Enable browser chrome and add-on debugging toolboxes" 被打开:</p>
+
+<p>{{EmbedYouTube("JDEe2fyFpHE")}}</p>
+
+<p>然后打开 "Browser Console":</p>
+
+<p>{{EmbedYouTube("mfuBMje6dA4")}}</p>
+
+<p>它给了你一个命令行以使你可以执行一些特权javascript代码。</p>
+
+<div class="warning">
+<p>因为运行在浏览器控制台的代码拥有系统特权,在任何时候都请你小心理解你的代码做了什么</p>
+</div>
+
+<p>现在粘贴以下代码到命令行然后按下 <kbd>enter</kbd>:</p>
+
+<pre class="brush: js">Cu.import("resource://gre/modules/MatchPattern.jsm");
+Cu.import("resource://gre/modules/BrowserUtils.jsm");</pre>
+
+<p>这做了两件事:</p>
+
+<ul>
+ <li>导入 "MatchPattern.jsm": 这是实现了匹配模板的系统模块,特别的,这个模块包含了 <code>MatchPattern</code> 对象. <code>MatchPattern</code> 对象定义了一个 <code>matches()</code> 方法, 他需要一个URL然后返回 <code>true</code> 或者 <code>false</code>.</li>
+ <li>导入 "BrowserUtils.jsm": 包含了一个方法 <code>makeURI()</code>, 他转换一个字符串为一个 <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIURI">nsIURI</a></code> 对象. <code>nsIURI</code> 是 <code>matches()</code> 方法需要接受的一个参数。</li>
+</ul>
+
+<p>现在你可以构造MatchPattern对象,构造URIs,并检查URIs 是否匹配:</p>
+
+<pre class="brush: js">var match = new MatchPattern("*://mozilla.org/");
+
+var uri = BrowserUtils.makeURI("https://mozilla.org/");
+match.matches(uri); // &lt; true
+
+uri = BrowserUtils.makeURI("https://mozilla.org/path");
+match.matches(uri); // &lt; false</pre>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/modify_a_web_page/index.html b/files/zh-cn/mozilla/add-ons/webextensions/modify_a_web_page/index.html
new file mode 100644
index 0000000000..9f4856de63
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/modify_a_web_page/index.html
@@ -0,0 +1,239 @@
+---
+title: 修改web页面
+slug: Mozilla/Add-ons/WebExtensions/Modify_a_web_page
+translation_of: Mozilla/Add-ons/WebExtensions/Modify_a_web_page
+---
+<div>{{AddonSidebar}}</div>
+
+<p>浏览器附加组件( add-on )常被用于修改网页。例如更改页面的样式,隐藏特定的DOM节点或把DOM节点注入到页面中。</p>
+
+<p>使用WebExtensions有两种方式:</p>
+
+<ul>
+ <li>声明方式:定义一个网址格式,用来匹配特定的网址,然后加载脚本到对应的网页中.</li>
+ <li>编程方式: 使用JavaScript 接口, 将脚本加载到一个指定标签页所承载的页面中</li>
+</ul>
+
+<p>无论使用上面何种方式,它们都被称为内容脚本, 与其他脚本的区别:</p>
+
+<ul>
+ <li>只能使用一部分的webextension API。</li>
+ <li>能读取加载了内容脚本的网页。</li>
+ <li>通过使用消息API与其他的webextension通信。</li>
+</ul>
+
+<p>在本文中,我们将看下加载脚本的两种方式。</p>
+
+<h2 id="修改匹配URL的页面">修改匹配URL的页面</h2>
+
+<p>首先,创建一个名为“ modify-page ”的文件夹,并在目录下创建“ manifest.json ”文件,内容如下:</p>
+
+<pre class="brush: json">{
+
+ "manifest_version": 2,
+ "name": "modify-page",
+ "version": "1.0",
+
+ "content_scripts": [
+ {
+ "matches": ["https://developer.mozilla.org/*"],
+ "js": ["page-eater.js"]
+ }
+ ]
+
+}</pre>
+
+<p>"content_scripts"指出符合 URL 格式的页面地址,然后让浏览器加载脚本(“ page-eater.js“)到匹配的URL页面(<a href="https://developer.mozilla.org/">https://developer.mozilla.org/</a> )。</p>
+
+<div class="note">
+<p><span id="result_box" lang="zh-CN"><span>由于</span></span> <code>content_scripts</code> <span lang="zh-CN"><span>的</span></span> <code>"js"</code> <span lang="zh-CN"><span>属性是一个数组,因此可以使用它将多个脚本注入匹配的页面。</span> <span>如果这样做,页面将按照数组中列出的顺序加载多个脚本。</span></span></p>
+</div>
+
+<div class="note">
+<p><code>content_scripts</code> <span class="short_text" lang="zh-CN"><span>键还具有一个</span></span> <code>"css"</code> <span class="short_text" lang="zh-CN"><span>属性,可以使用它来注入CSS样式表。</span></span></p>
+</div>
+
+<p>在 "modify-page" 文件夹下创建“ page-eater.js ”文件,内容如下:</p>
+
+<pre class="brush: js">document.body.textContent = "";
+
+var header = document.createElement('h1');
+header.textContent = "This page has been eaten";
+document.body.appendChild(header);</pre>
+
+<p>现在安装这个<a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Temporary_Installation_in_Firefox">WebExtension</a>, 然后浏览 <a href="https://developer.mozilla.org/">https://developer.mozilla.org/</a>:</p>
+
+<p>{{EmbedYouTube("lxf2Tkg6U1M")}}</p>
+
+<div class="note">
+<p><span id="result_box" lang="zh-CN"><span>请注意,虽然此视频显示在</span></span> <a href="https://addons.mozilla.org/en-US/firefox/">addons.mozilla.org</a> <span lang="zh-CN"><span>工作的</span></span> content scripts <span lang="zh-CN"><span>,但目前该网站已禁止</span></span> content scripts <span lang="zh-CN"><span>。</span></span></p>
+</div>
+
+<h2 id="通过程序修改页面">通过程序修改页面</h2>
+
+<p>如何修改程序使其在用户要求时才吞页面。现在修改上面的例子,在点击右键菜单项时才注入内容脚本。</p>
+
+<p>修改 "manifest.json" 内容如下:</p>
+
+<pre class="brush: json">{
+
+ "manifest_version": 2,
+ "name": "modify-page",
+ "version": "1.0",
+
+ "permissions": [
+ "activeTab",
+ "contextMenus"
+ ],
+
+ "background": {
+ "scripts": ["background.js"]
+ }
+
+}</pre>
+
+<p>这里我们要移除"<code>content_scripts</code>"键值,并添加两个键:</p>
+
+<ul>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permissions</a></code>:要向页面中注入脚本,就需要拥有修改页面对应的权限。<a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#activeTab_permission"><code>activeTab</code></a>可以临时获得修改当前活动标签所加载的页面的权限。 另外还通过 contextmenus 来获取添加右键菜单项的权限。</li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/background">background</a></code>: 加载名为 "background.js" 的 <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Background_scripts">"background script"</a> (长期有效的后台脚本),在该脚本中,我们将设置注入右键菜单的内容脚本。</li>
+</ul>
+
+<p>在 "modify-page" 文件夹下创建名为 "background.js"的新文件,内容如下:</p>
+
+<pre class="brush: js">browser.contextMenus.create({
+ id: "eat-page",
+ title: "Eat this page"
+});
+
+browser.contextMenus.onClicked.addListener(function(info, tab) {
+ if (info.menuItemId == "eat-page") {
+ browser.tabs.executeScript({
+ file: "page-eater.js"
+ });
+ }
+});
+</pre>
+
+<p>在该脚本中我们创建了一个右键菜单项, 给了它一个具体的 id 和标题 (将在菜单中显示的文本)。 然后又设置了一个事件侦听器,当用户点击菜单项时,检查该菜单项是否就是我们的吞页菜单项。 如果是, 就通过<code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/executeScript">tabs.executeScript()</a></code> 接口,把"page-eater.js" 注入到活动标签页中。 这个接口用标签ID做为参数:如果省略标签ID参数,就默认把脚本注入当前活动标签。</p>
+
+<p>现在,附加组件看起来像这样:</p>
+
+<pre class="line-numbers language-html"><code class="language-html">modify-page/
+ background.js
+ manifest.json
+ page-eater.js</code></pre>
+
+<p>重新加载<a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Temporary_Installation_in_Firefox#Reloading_a_temporary_add-on">WebExtension</a>, 打开页面 (这次可以是任何一个页面) 激活右键菜单,然后选择 "Eat this page":</p>
+
+<p>{{EmbedYouTube("zX4Bcv8VctA")}}</p>
+
+<div class="note">
+<p><span id="result_box" lang="zh-CN"><span>请注意,虽然此视频显示在</span></span> <a href="https://addons.mozilla.org/en-US/firefox/">addons.mozilla.org</a> <span lang="zh-CN"><span>工作的</span></span> content scripts <span lang="zh-CN"><span>,但目前该网站已禁止</span></span> content scripts <span lang="zh-CN"><span>。</span></span></p>
+</div>
+
+<h2 id="消息">消息</h2>
+
+<p>内容脚本和后台脚本不能直接相互访问,但可以通过发送消息进行通信。当一端设置一个消息侦听器时,另一个端就可以发送消息了。下面的表格总结了通信时的api接口:</p>
+
+<table class=" fullwidth-table standard-table">
+ <thead>
+ <tr>
+ <th scope="row"> </th>
+ <th scope="col">在内容脚本中</th>
+ <th scope="col">在后台脚本中</th>
+ </tr>
+ <tr>
+ <th scope="row">发送消息</th>
+ <td><code><a href="/en-US/Add-ons/WebExtensions/API/runtime#sendMessage()">browser.runtime.sendMessage()</a></code></td>
+ <td><code><a href="/en-US/Add-ons/WebExtensions/API/Tabs/sendMessage">browser.tabs.sendMessage()</a></code></td>
+ </tr>
+ <tr>
+ <th scope="row">接收消息</th>
+ <td><code><a href="/en-US/Add-ons/WebExtensions/API/runtime/onMessage">browser.runtime.onMessage</a></code></td>
+ <td><code><a href="/en-US/Add-ons/WebExtensions/API/runtime#onMessage">browser.runtime.onMessage</a></code></td>
+ </tr>
+ </thead>
+</table>
+
+<p>修改上面的示例,使得可以通过后台脚本来发送消息。</p>
+
+<p>首先,修改 "background.js" 如下:</p>
+
+<pre class="brush: js">browser.contextMenus.create({
+ id: "eat-page",
+ title: "Eat this page"
+});
+
+function messageTab(tabs) {
+ browser.tabs.sendMessage(tabs[0].id, {
+ replacement: "Message from the add-on!"
+ });
+}
+
+browser.contextMenus.onClicked.addListener(function(info, tab) {
+ if (info.menuItemId == "eat-page") {
+ browser.tabs.executeScript({
+ file: "page-eater.js"
+ });
+
+ var querying = browser.tabs.query({
+ active: true,
+ currentWindow: true
+ });
+ querying.then(messageTab);
+ }
+});
+</pre>
+
+<p> 注入 "page-eater.js"后, 通过使用 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/query">tabs.query()</a></code> 获取当前活动标签页, 然后使用<code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/sendMessage">tabs.sendMessage()</a></code> 将消息发送到该标签页中的内容脚本。 该消息的内容 <code>{replacement: "Message from the add-on!"}。</code></p>
+
+<p>接下来,修改 "page-eater.js" 如下:</p>
+
+<pre class="brush: js">function eatPage(request, sender, sendResponse) {
+ document.body.textContent = "";
+
+ var header = document.createElement('h1');
+ header.textContent = request.replacement;
+ document.body.appendChild(header);
+}
+
+browser.runtime.onMessage.addListener(eatPage);
+</pre>
+
+<p>现在,不再立即执行吞页,内容脚本将先通过使用 <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage">runtime.onMessage</a></code>来监听消息。当监听到消息时, 内容脚本才开始运作,除了来自<code>request.replacement</code>的替换文本不一样以外,其他的脚本运作本质上与之前的相同 。</p>
+
+<p>如果我们想将消息从内容脚本发送到后台页面,除了在内容脚本中使用 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/sendMessage">runtime.sendMessage()</a></code> ,其他与上面的过程相反。</p>
+
+<div class="note">
+<p><span id="result_box" lang="zh-CN"><span>这些例子注入的都是JavaScript;</span> 想</span><span lang="zh-CN"><span>注入CSS可以使用</span></span> <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/insertCSS">tabs.insertCSS()</a></code> <span lang="zh-CN"><span>函数。</span></span></p>
+</div>
+
+<h2 id="了解更多">了解更多</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">Content scripts</a> 指南</li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts">content_scripts</a></code> manifest key</li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permissions</a></code> manifest key</li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/executeScript">tabs.executeScript()</a></code></li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/insertCSS">tabs.insertCSS()</a></code></li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/sendMessage">tabs.sendMessage()</a></code></li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/sendMessage">runtime.sendMessage()</a></code></li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage">runtime.onMessage</a></code></li>
+ <li>使用<code>content_scripts</code>的例子:
+ <ul>
+ <li><a href="https://github.com/mdn/webextensions-examples/tree/master/borderify">borderify</a></li>
+ <li><a href="https://github.com/mdn/webextensions-examples/tree/master/inpage-toolbar-ui">inpage-toolbar-ui</a></li>
+ <li><a href="https://github.com/mdn/webextensions-examples/tree/master/notify-link-clicks-i18n">notify-link-clicks-i18n</a></li>
+ <li><a href="https://github.com/mdn/webextensions-examples/tree/master/page-to-extension-messaging">page-to-extension-messaging</a></li>
+ </ul>
+ </li>
+ <li>使用<code>tabs.executeScript()</code>的例子:
+ <ul>
+ <li><a class="external external-icon" href="https://github.com/mdn/webextensions-examples/tree/master/beastify">beastify</a></li>
+ <li><a class="external external-icon" href="https://github.com/mdn/webextensions-examples/tree/master/context-menu-demo">context-menu-demo</a></li>
+ </ul>
+ </li>
+</ul>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/native_manifests/index.html b/files/zh-cn/mozilla/add-ons/webextensions/native_manifests/index.html
new file mode 100644
index 0000000000..b83609fa85
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/native_manifests/index.html
@@ -0,0 +1,344 @@
+---
+title: 原生应用清单
+slug: Mozilla/Add-ons/WebExtensions/Native_manifests
+translation_of: Mozilla/Add-ons/WebExtensions/Native_manifests
+---
+<div>{{AddonSidebar}}</div>
+
+<p> </p>
+
+<p>原生应用清单是一个符合特定规则的JSON文件,它应该使用与 extension 不同的安装方式存放在用户的计算机上。举个例子,原生应用清单是由设备管理员或者通过原生应用安装器提供的。</p>
+
+<p>有三种不同的原生应用清单:</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td style="width: 40%;"><a href="#原生应用通信清单">原生应用通信清单</a></td>
+ <td>
+ <p>定义关于 <a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Native_messaging">与本地应用通信</a> 的功能:哪一个 extension 可以与本机的原生应用交换信息。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><a href="#存储管理清单">存储管理清单</a></td>
+ <td>
+ <p>定义一些 extension 可以用 {{WebExtAPIRef("storage.managed")}} 读取的只读数据。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><a href="#PKCS #11 清单">PKCS #11 清单</a></td>
+ <td>
+ <p>定义了 extension 使用 {{WebExtAPIRef("pkcs11")}} API 去枚举 PKCS #11 安全模型 并在Firefox安装它们。</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>对于所有的原生应用清单,你需要做一些工作以便于浏览器可以找到它们。这些规则在 <a href="#清单路径">清单路径</a><a href="#Manifest_location"> </a>章节。</p>
+
+<h2 id="原生应用通信清单_2">原生应用通信清单<a id="原生应用通信清单" name="原生应用通信清单"></a></h2>
+
+<p>原生应用通信清单中包含单个JSON对象,对象具有如下属性:</p>
+
+<table class="fullwidth-table standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Name</th>
+ <th scope="col">Type</th>
+ <th scope="col">Description</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>name</code></td>
+ <td>String</td>
+ <td>
+ <p>原生应用的名字</p>
+
+ <p>它必须与 extension 调用 {{WebExtAPIRef("runtime.connectNative()")}} 和 {{WebExtAPIRef("runtime.sendNativeMessage()")}} 时传入的名称保持一致。</p>
+
+ <p>在 OS X 和 Linux 中,它必须和清单文件的文件名保持一致(除.json文件扩展名外)。</p>
+
+ <p>在 Windows 中,它必须和你创建的包含原生应用清单路径的注册表一致。</p>
+
+ <p>它必须符合正则表达式  "^\w+(\.\w+)*$"。这意味着它只能包含小写字母、数字、下划线和 <code>.</code> ,并且不允许开头或结束是 <code>.</code> ,并且 <code>.</code> 后面不能是 <code>.</code> 。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>description</code></td>
+ <td>String</td>
+ <td>
+ <p>关于这个原生应用的描述。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>path</code></td>
+ <td>String</td>
+ <td>
+ <p>到原生应用的路径。</p>
+
+ <p>在 Windows 中,这可以是一个相对路径。在 OS X 和 Linux 中,必须是绝对路径。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>type</code></td>
+ <td>String</td>
+ <td>
+ <p>定义 extension 和原生应用的连接方法。</p>
+
+ <p>目前只支持一种值,那就是 stdio。该值表示应用使用标准输入(stdin)来接受消息,用标准输出(stdout)来发送消息。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>allowed_extensions</code></td>
+ <td>Array of String</td>
+ <td>
+ <p>由 <a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/WebExtensions_and_the_Add-on_ID">Add-on ID</a> 组成的数组。每个值代表允许ID为该值的 extension 与这个原生应用通信。</p>
+
+ <div class="note">
+ <p>这意味着你可能需要在你 extension 的 manifest.json 中包含 <a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/applications">applications</a> 字段,并为 extension 设置一个显示的ID,哪怕是在开发时</p>
+ </div>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>举个例子,这是 ping_pong 原生应用的原生应用通信清单:</p>
+
+<pre class="brush: json">{
+ "name": "ping_pong",
+ "description": "Example host for native messaging",
+ "path": "/path/to/native-messaging/app/ping_pong.py",
+ "type": "stdio",
+ "allowed_extensions": [ "ping_pong@example.org" ]
+}</pre>
+
+<p>清单表示:它允许ID为 ping_pong@example.org 的 extension 通过传入 ping_pong 给 {{WebExtAPIRef("runtime")}} 与自己连接。原生应用自身在 /path/to/native-messaging/app/ping_pong.py 中。</p>
+
+<h2 id="存储管理清单_2">存储管理清单<a id="存储管理清单" name="存储管理清单"></a></h2>
+
+<p>存储管理清单中包含单个JSON对象,对象具有如下属性:</p>
+
+<table class="fullwidth-table standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Name</th>
+ <th scope="col">Type</th>
+ <th scope="col">Description</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>name</code></td>
+ <td>String</td>
+ <td>
+ <p><strong>一个</strong> extension 的 ID,表示这个 extension 可以读取这个仓库。</p>
+
+ <p>给出这个ID需要你的 extension 的 manifest.json 文件包含 <a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/applications">applications</a> 字段。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>description</code></td>
+ <td>String</td>
+ <td>
+ <p>人类可读的描述,Firefox会忽略它。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>type</code></td>
+ <td>String</td>
+ <td>
+ <p>该值只能是<code>storage</code>。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>data</code></td>
+ <td>Object</td>
+ <td>
+ <p>一个JSON对象,其中可以包含任何合法的JSON值(string、number、boolean、array、object),他们将成为<code>browser.storage.managed</code>可访问的数据。</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>举个例子:</p>
+
+<pre class="brush: json line-numbers language-json"><code class="language-json"><span class="punctuation token">{</span>
+ <span class="key token">"name":</span> <span class="string token">"favourite-colour-examples@mozilla.org"</span><span class="punctuation token">,</span>
+ <span class="key token">"description":</span> <span class="string token">"ignored"</span><span class="punctuation token">,</span>
+ <span class="key token">"type":</span> <span class="string token">"storage"</span><span class="punctuation token">,</span>
+ <span class="key token">"data":</span>
+ <span class="punctuation token">{</span>
+ <span class="key token">"colour":</span> <span class="string token">"management thinks it should be blue!"</span>
+ <span class="punctuation token">}</span>
+<span class="punctuation token">}</span></code></pre>
+
+<p>在给出的清单文件中,ID 为 favourite-colour-examples@mozilla.org 的 extension 有权限使用清单中的 data 字段中的数据,代码如下:</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">var</span> storageItem <span class="operator token">=</span> browser<span class="punctuation token">.</span>storage<span class="punctuation token">.</span>managed<span class="punctuation token">.</span><span class="keyword token">get</span><span class="punctuation token">(</span><span class="string token">'colour'</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+storageItem<span class="punctuation token">.</span><span class="function token">then</span><span class="punctuation token">(</span><span class="punctuation token">(</span>res<span class="punctuation token">)</span> <span class="operator token">=</span><span class="operator token">&gt;</span> <span class="punctuation token">{</span>
+ console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="template-string token"><span class="string token">`Managed colour is: </span><span class="interpolation token"><span class="interpolation-punctuation punctuation token">${</span>res<span class="punctuation token">.</span>colour<span class="interpolation-punctuation punctuation token">}</span></span><span class="string token">`</span></span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+
+<h2 id="PKCS_11_清单">PKCS #11 清单<a id="PKCS #11 清单" name="PKCS #11 清单"></a></h2>
+
+<p>PKCS #11 清单中包含单个JSON对象,对象具有如下属性:</p>
+
+<table class="fullwidth-table standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Name</th>
+ <th scope="col">Type</th>
+ <th scope="col">Description</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>name</code></td>
+ <td>String</td>
+ <td>
+ <p>PKCS #11 模块的名字。</p>
+
+ <p>它必须和你使用 <code>pkcs11</code> API 时的名字一致。</p>
+
+ <p>在 OS X 和 Linux 中,它必须和清单文件的文件名保持一致(除文件扩展名外)</p>
+
+ <p>在 Windows 中,它必须和你创建的包含原生应用清单路径的注册表一致。</p>
+
+ <p>它必须符合正则表达式  "^\w+(\.\w+)*$"。这意味着它只能包含小写字母、数字、下划线和 <code>.</code> ,并且不允许开头或结束是 <code>.</code> ,并且 <code>.</code> 后面不能是 <code>.</code> 。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>description</code></td>
+ <td>String</td>
+ <td>
+ <p>关于该模块的描述。</p>
+
+ <p>它将被用在浏览器界面中为模块设置一个友好的名字(比如,在Firefox的“安全设备”对话框中)</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>path</code></td>
+ <td>String</td>
+ <td>
+ <p>到模块的路径。</p>
+
+ <p>在 Windows 中,这可以是一个相对路径。在 OS X 和 Linux 中,必须是绝对路径。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>type</code></td>
+ <td>String</td>
+ <td>该值只能是<code>pkcs11</code>。 This must be "pkcs11".</td>
+ </tr>
+ <tr>
+ <td><code>allowed_extensions</code></td>
+ <td>Array of String</td>
+ <td>
+ <p>由 <a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/WebExtensions/WebExtensions_and_the_Add-on_ID">Add-on ID</a> 组成的数组。每个值代表允许ID为该值的 extension 与这个模块通信。</p>
+
+ <div class="note">
+ <p>这意味着你可能需要在你 extension 的 manifest.json 中包含 <a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/applications">applications</a> 字段,并为 extension 设置一个显示的ID,哪怕是在开发时</p>
+ </div>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>举个例子:</p>
+
+<pre class="brush: json line-numbers language-json">{
+  "name": "my_module",
+  "description": "My test module",
+  "type": "pkcs11",
+  "path": "/path/to/libpkcs11testmodule.dylib",
+  "allowed_extensions": ["my-extension@mozilla.org"]
+}</pre>
+
+<p>给出的这个JSON清单,保存为 my_module.json,ID为 my-extension@mozilla.org 的 extension 就能够使用类似于如下代码安装 /path/to/libpkcs11testmodule.dylib 安全模块:</p>
+
+<pre class="brush: js line-numbers language-js">browser.pkcs11.installModule("my_module");</pre>
+
+<h2 id="清单路径_2">清单路径<a id="清单路径" name="清单路径"></a></h2>
+
+<p>在 Linux 和 Mac OS X 中,你需要将清单文件存在特定的位置。在 Windows 中,你需要创建一个注册表来指向清单文件。</p>
+
+<p>所有类型的清单的详细规则都是相同的,除了倒数第二个的 type 字段表示了清单的类型。下面的例子展示了三种不同类型的清单。在例子中,&lt;name&gt; 代表清单中的 name 字段值。</p>
+
+<h3 id="Windows">Windows</h3>
+
+<p>如果想要全局可见,使用下面的路径创建注册表:</p>
+
+<pre>HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\NativeMessagingHosts\&lt;name&gt;
+
+HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\<code class="language-html">ManagedStorage</code>\&lt;name&gt;
+
+HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\PKCS11Modules\&lt;name&gt;</pre>
+
+<p>注册表应该有单个默认值,值里存放“到清单文件的路径”。比如为原生应用通信清单建立的注册表差不多是这样:</p>
+
+<p><img alt="为原生应用通信清单建立的注册表" src="https://mdn.mozillademos.org/files/15643/native-message-regkey-exaple.png" style="height: 308px; width: 1027px;"></p>
+
+<div class="note">
+<p><em>对于原生应用清单,即使原生应用是32位的,也不能在 <a href="https://en.wikipedia.org/wiki/WoW64#Registry_and_file_system">Wow6432Node</a> 下创建注册表。浏览器将总会在 native 视图下寻找注册表的,而不是32位放在环境。确保注册表的创建在原生视图中,你可以键入KEY_WOW64_64KEY 或 KEY_WOW64_32KEY  到 RegCreateKeyEx。请参考:<a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384129(v=vs.85).aspx">Accessing an Alternate Registry View</a></em></p>
+</div>
+
+<p>如果想要用户级别的可见,使用下面的路径创建注册表:</p>
+
+<pre>HKEY_CURRENT_USER\SOFTWARE\Mozilla\NativeMessagingHosts\&lt;name&gt;
+
+HKEY_CURRENT_USER\SOFTWARE\Mozilla\<code class="language-html">ManagedStorage</code>\&lt;name&gt;
+
+HKEY_CURRENT_USER\SOFTWARE\Mozilla\PKCS11Modules\&lt;name&gt;</pre>
+
+<p>注册表应该有单个默认值,值里存放“到清单文件的路径”。</p>
+
+<h3 id="Mac_OS_X">Mac OS X</h3>
+
+<p>如果想要全局可见,将清单文件存放在:</p>
+
+<pre>/Library/Application Support/Mozilla/NativeMessagingHosts/&lt;name&gt;.json
+
+/Library/Application Support/Mozilla/<code class="language-html">ManagedStorage</code>/&lt;name&gt;.json
+
+/Library/Application Support/Mozilla/PKCS11Modules/&lt;name&gt;.json</pre>
+
+<p>如果想要用户级别的可见,将清单文件存放在:</p>
+
+<pre>~/Library/Application Support/Mozilla/NativeMessagingHosts/&lt;name&gt;.json
+
+~/Library/Application Support/Mozilla/<code class="language-html">ManagedStorage</code>/&lt;name&gt;.json
+
+~/Library/Application Support/Mozilla/PKCS11Modules/&lt;name&gt;.json
+</pre>
+
+<h3 id="Linux">Linux</h3>
+
+<p>如果想要全局可见,将清单文件存放在:</p>
+
+<pre>/usr/lib/mozilla/native-messaging-hosts/&lt;name&gt;.json
+
+/usr/lib/mozilla/<code class="language-html">managed-storage</code>/&lt;name&gt;.json
+
+/usr/lib/mozilla/pkcs11-modules/&lt;name&gt;.json
+</pre>
+
+<p>或者:</p>
+
+<pre>/usr/lib64/mozilla/native-messaging-hosts/&lt;name&gt;.json
+
+/usr/lib64/mozilla/<code class="language-html">managed-storage</code>/&lt;name&gt;.json
+
+/usr/lib64/mozilla/pkcs11-modules/&lt;name&gt;.json</pre>
+
+<p>如果想要用户级别的可见,将清单文件存放在:</p>
+
+<pre>~/.mozilla/native-messaging-hosts/&lt;name&gt;.json
+
+~/.mozilla/<code class="language-html">managed-storage</code>/&lt;name&gt;.json
+
+~/.mozilla/pkcs11-modules/&lt;name&gt;.json</pre>
+
+<p> </p>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/native_messaging/index.html b/files/zh-cn/mozilla/add-ons/webextensions/native_messaging/index.html
new file mode 100644
index 0000000000..505ba9a16a
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/native_messaging/index.html
@@ -0,0 +1,326 @@
+---
+title: 与本地应用通信
+slug: Mozilla/Add-ons/WebExtensions/Native_messaging
+translation_of: Mozilla/Add-ons/WebExtensions/Native_messaging
+---
+<div>{{AddonSidebar}}</div>
+
+<p>Native messaging 可以让 extension 与安装在用户计算机上的原生应用交换信息。 原生应用仅需给 extension 提供服务,而无需在网页中可访问。 一个常见的例子是密码管理器: 原生应用负责存储和加密你的密码,并且和 extension 通信来填充网页中的表单字段。Native messaging 可以让 extension 拥有那些WebExtensions APIs 所没有的功能,比如访问某些特定的硬件。</p>
+
+<p>原生应用的安装与管理并不是在浏览器当中的: 它应该是使用操作系统进行安装,和其他的原生应用一样。然后你需要将你的原生应用安装在指定位置,并提供一个清单。清单中描述了浏览器如何连接到你的原生应用。</p>
+
+<p>extension 必须在 manifest.json 中获得"nativeMessaging" <a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">权限</a>。 同时,原生应用也需要在其清单中的 "allowed_extensions" 字段中包含 extension 的ID来表示允许该 extension 与自己进行通信。</p>
+
+<p>经过上述操作,extension 就可以通过 {{WebExtAPIRef("runtime")}} API 与原生应用进行JSON数据通信了。原生应用可以通过标准输入/输出来接受/返回数据与 extension 通信。</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/13833/native-messaging.png" style="display: block; height: 548px; margin-left: auto; margin-right: auto; width: 672px;"></p>
+
+<p>和 Chrome 相比,WebExtensions 所支持的 native messaging 有2个主要区别:</p>
+
+<ul>
+ <li>在 WebExtensions 中,原生应用的清单中的 "allowed_extensions" 字段是一个由 extension ID 组成的数组,而在 Chrome 中,清单中的 "allowed_origins" 字段是一个由 "chrome-extension" URLs 组成的数组</li>
+ <li>原生应用清单的存储位置不一样</li>
+</ul>
+
+<p>Github 中的 <a href="https://github.com/mdn/webextensions-examples">webextensions-examples 仓库</a>有一个<a href="https://github.com/mdn/webextensions-examples/tree/master/native-messaging">完整的关于 native messaging 的例子</a>,文章中的大部分代码片段均出于此。</p>
+
+<h2 id="安装">安装</h2>
+
+<h3 id="Extension_的_manifest.json">Extension 的 manifest.json</h3>
+
+<p>如果你想让你的 extension 与原生应用进行通信,你需要:</p>
+
+<ul>
+ <li>你必须在 <a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a> 中申请 "nativeMessaging" 的 <a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">权限</a> 。</li>
+ <li>你可能需要明确自己 extension 的ID(因为在原生应用的清单中,extension ID将会在被用来识别此 extension 是否被允许与原生应用通信)</li>
+</ul>
+
+<p>这有一个 manifest.json 的例子:</p>
+
+<pre class="brush: json">{
+
+ "description": "Native messaging example extension",
+ "manifest_version": 2,
+ "name": "Native messaging example",
+ "version": "1.0",
+ "icons": {
+ "48": "icons/message.svg"
+ },
+
+ "applications": {
+ "gecko": {
+ "id": "ping_pong@example.org",
+ "strict_min_version": "50.0"
+ }
+ },
+
+ "background": {
+ "scripts": ["background.js"]
+ },
+
+ "browser_action": {
+ "default_icon": "icons/message.svg"
+ },
+
+ "permissions": ["nativeMessaging"]
+
+}</pre>
+
+<h3 id="原生应用清单">原生应用清单</h3>
+
+<p>原生应用清单描述了浏览器如何与原生应用进行连接。</p>
+
+<p>原生应用清单需要与原生应用一起安装,浏览器仅会查阅清单而不会安装或管理原生应用。因此,何时采用何种方式来安装或更新这些文件的安全模型比起使用WebExtensions APIs 更像原生应用 。(我也搞不懂这句啥意思,原文:Thus the security model for when and how these files are installed and updated is much more like that for native applications than that for extensions using WebExtension APIs.)</p>
+
+<p>关于原生应用清单的详细语法和路径规则,可参考 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_manifests">原生应用清单</a>。</p>
+
+<blockquote>
+<div class="warning">
+<p>除清单外,原生应用还<strong>必需</strong>配置路径规则,你可以参考 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_manifests">原生应用清单 </a>来配置路径。</p>
+</div>
+</blockquote>
+
+<p>这有一个例子,是关于 "ping_pong" 原生应用的清单:</p>
+
+<pre class="brush: json">{
+ "name": "ping_pong",
+ "description": "Example host for native messaging",
+ "path": "/path/to/native-messaging/app/ping_pong.py",
+ "type": "stdio",
+ "allowed_extensions": [ "ping_pong@example.org" ]
+}</pre>
+
+<p>上面的清单代表:</p>
+
+<ul>
+ <li>这个原生应用允许ID为 "ping_pong@example.org" 的 extension 连接,并通过{{WebExtAPIRef("runtime")}} API来传入信息</li>
+ <li>这个原生应用本身存放在本机的 "/path/to/native-messaging/app/ping_pong.py" 中</li>
+</ul>
+
+<div class="note">
+<p><strong>对于Windows</strong>: 在上面的例子中,原生应用是一个Python脚本,它在Windows下可能是无法运行的。一个代替方案是提供一个 .bat 文件,并且在清单中指向这个 .bat 文件:</p>
+
+<pre class="brush: json">{
+ "name": "ping_pong",
+ "description": "Example host for native messaging",
+ "path": "c:\\path\\to\\native-messaging\\app\\ping_pong_win.bat",
+ "type": "stdio",
+ "allowed_extensions": [ "ping_pong@example.org" ]
+}</pre>
+
+<p>在 .bat 文件中调用 Python 脚本:</p>
+
+<pre class="brush: bash">@echo off
+
+python -u "c:\\path\\to\\native-messaging\\app\\ping_pong.py"</pre>
+
+<p> </p>
+</div>
+
+<ul>
+</ul>
+
+<h2 id="交换信息">交换信息</h2>
+
+<p>根据上面的配置,extension已经可以和原生应用交换JSON信息了。</p>
+
+<h3 id="Extension_端">Extension 端</h3>
+
+<p>你使用过 <a href="/zh-CN/Add-ons/WebExtensions/Content_scripts#Communicating_with_background_scripts">messaging APIs</a> 与 content script 通信,与原生应用通信你应该非常熟悉,有2种方式:</p>
+
+<ul>
+ <li>基于连接的通信</li>
+ <li>无连接的通信(请求/响应 模式)</li>
+</ul>
+
+<h4 id="基于连接的通信">基于连接的通信</h4>
+
+<p>在这种方式下,你需要调用 {{WebExtAPIRef("runtime.connectNative()")}} 并传入原生应用的名称(名称在原生应用清单中的 "name" 字段定义)。这个操作将会运行原生应用(如果它之前没在运行的话)并返回一个 {{WebExtAPIRef("runtime.Port")}} 。</p>
+
+<p>当原生应用启动后,它被会传入2个参数:</p>
+
+<ul>
+ <li>到原生应用清单的完整路径</li>
+ <li>(Firefox 55+)启动它的<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/applications"> extension ID</a></li>
+</ul>
+
+<p>原生应用会一直保持运行,直到 extension 调用 <code>Port.disconnect()</code> 或连接它的记录被结束。</p>
+
+<p>使用 <code>Port</code> ,调用 <code>postMessage()</code> 传入一个JSON来发送消息,使用 <code>onMessage.addListener()</code> 来接收消息。</p>
+
+<p>下面是一个例子:background script 建立与 ping_pong 原生应用的链接,并监听原生应用发来的消息。每当browser action 点击时,发送一个 ping 的消息给原生应用。</p>
+
+<pre class="brush: js">/*
+启动,连接 ping_pong 原生应用
+*/
+var port = browser.runtime.connectNative("ping_pong");
+
+/*
+监听从原生应用发来的消息
+*/
+port.onMessage.addListener((response) =&gt; {
+ console.log("Received: " + response);
+});
+
+/*
+每当 browser action 被点击时,发送一条消息给原生应用
+*/
+browser.browserAction.onClicked.addListener(() =&gt; {
+ console.log("Sending: ping");
+ port.postMessage("ping");
+});</pre>
+
+<h4 id="无连接的通信">无连接的通信</h4>
+
+<p>在这种模式下你需要调用 {{WebExtAPIRef("runtime.sendNativeMessage()")}} 传入如下参数:</p>
+
+<ul>
+ <li>原生应用的名字</li>
+ <li>要发送是JSON数据</li>
+ <li>(可选)一个回调函数</li>
+</ul>
+
+<p>每个消息都会创建一个新的原生应用实例。当原生应用启动时会被传入2个参数:</p>
+
+<ul>
+ <li>到原生应用清单的完整路径</li>
+ <li>(Firefox 55+)启动它的<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/applications"> extension ID</a></li>
+</ul>
+
+<p>原生应用发送的第一条消息将会被作为对 <code>sendNativeMessage()</code> 响应,将会被传入回调函数中。</p>
+
+<p>这有一个例子,对在上方的代码片段进行重写,改成使用 <code>runtime.sendNativeMessage()</code> 的方式:</p>
+
+<pre class="brush: js">function onResponse(response) {
+ console.log("Received " + response);
+}
+
+function onError(error) {
+ console.log(`Error: ${error}`);
+}
+
+/*
+每当 browser action 被点击时,发送一条消息给原生应用
+*/
+browser.browserAction.onClicked.addListener(() =&gt; {
+ console.log("Sending: ping");
+ var sending = browser.runtime.sendNativeMessage(
+ "ping_pong",
+ "ping");
+ sending.then(onResponse, onError);
+});
+</pre>
+
+<h3 id="原生应用端">原生应用端</h3>
+
+<p>在原生应用端,使用标准输入来接受消息,使用标准输出来发送消息。</p>
+
+<p>每条消息将会被序列化成UTF-8格式的JSON数据,并且在消息前面有一个32位的值来表示该条消息使用本地字节序的长度。</p>
+
+<p>发送给原生应用的单条消息最大是1MB,总消息不得超越4GB。</p>
+
+<p>下面是一个用 Python 写的原生应用例子。监听 extensions 发送的消息,如果消息是 ping,则回复 pong:</p>
+
+<pre class="brush: python">#!/usr/bin/python -u
+# Note that running python with the `-u` flag is required on Windows,
+# in order to ensure that stdin and stdout are opened in binary, rather
+# than text, mode.
+
+import sys, json, struct
+
+# 从 stdin 读取解码消息
+def getMessage():
+ rawLength = sys.stdin.read(4)
+ if len(rawLength) == 0:
+ sys.exit(0)
+ messageLength = struct.unpack('@I', rawLength)[0]
+ message = sys.stdin.read(messageLength)
+ return json.loads(message)
+
+# 为了能被传输,对给定的内容进行编码
+def encodeMessage(messageContent):
+ encodedContent = json.dumps(messageContent)
+ encodedLength = struct.pack('@I', len(encodedContent))
+ return {'length': encodedLength, 'content': encodedContent}
+
+# 向 stdout 发送一个已编码的消息
+def sendMessage(encodedMessage):
+ sys.stdout.write(encodedMessage['length'])
+ sys.stdout.write(encodedMessage['content'])
+ sys.stdout.flush()
+
+while True:
+ receivedMessage = getMessage()
+ if (receivedMessage == "ping"):
+ sendMessage(encodeMessage("pong"))
+</pre>
+
+<h2 id="关闭原生应用">关闭原生应用</h2>
+
+<p>如果你通过 <code>runtime.connectNative()</code> 连接原生应用,则原生应用会一直保持运行,直到 extension 调用 <code>Port.disconnect()</code> 或连接它的记录被结束。 如果你通过 <code>runtime.sendNativeMessage()</code> 向原生应用发消息,原生应用会在回复消息后被关闭。</p>
+
+<p>关闭原生应用的过程:</p>
+
+<ul>
+ <li>在 *nix 系统比如 OS X 和Linux 中,浏览器会向原生应用发送 SIGTERM 信号让其可以优雅的退出,然后再发送 SIGKILL 信号。这些信号将会传递给每一个子进程,除非它们分裂成一个新的进程组。</li>
+ <li>在 Windows 中,浏览器会向原生应用的进程发送一个 <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms684161(v=vs.85).aspx">Job object</a> 并杀死任务,如果原生应用启动任何的额外进程并希望它们能在原生应用被杀死后继续保持运行,原生应用需要在启动进程时使用 <code><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx">CREATE_BREAKAWAY_FROM_JOB</a></code> 标记。</li>
+</ul>
+
+<h2 id="常见问题_Troubleshooting">常见问题 Troubleshooting</h2>
+
+<p>如果有什么地方出错,可以检查<a href="/en-US/Add-ons/WebExtensions/Debugging#Viewing_log_output">浏览器控制台</a>。原生应用发送的任何 stderr 都会被反应在浏览器控制台中。所以如果你已经运行了原生应用,你可以看到原生应用发出的所有错误信息。</p>
+
+<p>如果你没有配置好原生应用,你应该会看到一些错误信息。</p>
+
+<pre>"No such native application &lt;name&gt;"</pre>
+
+<ul>
+ <li>检查 <code>runtime.connectNative()</code> 传入的名称与应用程序清单中的名称一致</li>
+ <li>OS X/Linux:检查原生应用清单文件的名称是 &lt;name&gt;.json</li>
+ <li>Windows:检查注册表是否在正确的位置,并且它的名称是否与应用程序清单中的名称一致</li>
+ <li>Windows:检查注册中给出的路径是否指向的是原生应用清单</li>
+</ul>
+
+<pre>"Error: Invalid application &lt;name&gt;"</pre>
+
+<ul>
+ <li>检查原生应用的名称是否有非法字符</li>
+</ul>
+
+<pre>"'python' is not recognized as an internal or external command, ..."</pre>
+
+<ul>
+ <li>Windows:如果你的应用是一个Python script,检查你是否已经安装过Python,并为其配置好路径</li>
+</ul>
+
+<pre>"File at path &lt;path&gt; does not exist, or is not executable"</pre>
+
+<ul>
+ <li>如果你看见它,意味着应用程序清单已经被找到了</li>
+ <li>检查应用程序清单的 path 字段是正确的</li>
+ <li>Windows:检查你是否已经转移过了路径分隔符 ("c:\\path\\to\\file")</li>
+ <li>检查原生应用是否在原生应用清单中的 path 字段中指向的本地路径</li>
+ <li>检查原生应用是否可执行</li>
+</ul>
+
+<pre>"This extension does not have permission to use native application &lt;name&gt;"</pre>
+
+<ul>
+ <li>检查原生应用清单中的 "allowed_extensions" 字段中是否包含了 extension 的 ID。</li>
+</ul>
+
+<pre>"TypeError: browser.runtime.connectNative is not a function"</pre>
+
+<ul>
+ <li>检查 extension 是否已经拥有了 nativeMessaging 权限</li>
+</ul>
+
+<pre>"[object Object] NativeMessaging.jsm:218"</pre>
+
+<ul>
+ <li>这是一个启动原生应用时的问题。</li>
+</ul>
+
+<h2 id="与_Chrome_的兼容问题">与 Chrome 的兼容问题</h2>
+
+<p>{{Page("Mozilla/Add-ons/WebExtensions/Chrome_incompatibilities", "Native_messaging")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/packaging_and_installation/index.html b/files/zh-cn/mozilla/add-ons/webextensions/packaging_and_installation/index.html
new file mode 100644
index 0000000000..e0eb081cc7
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/packaging_and_installation/index.html
@@ -0,0 +1,82 @@
+---
+title: 打包和安装
+slug: Mozilla/Add-ons/WebExtensions/Packaging_and_installation
+translation_of: Mozilla/Add-ons/WebExtensions/Temporary_Installation_in_Firefox
+---
+<h2 id="打包你的扩展">打包你的扩展</h2>
+
+<p>Firefox 扩展应打包为 XPI 文件。它只是一个 ZIP 文件,但采用 <code>.xpi</code> 作为扩展名。</p>
+
+<p>最重要的一点,ZIP 文件必须是扩展文件的 ZIP 打包,<strong>不能</strong>包含一层根目录。</p>
+
+<h3 id="Windows">Windows</h3>
+
+<ol>
+ <li>打开你的扩展文件所在的文件夹。</li>
+ <li>选择所有文件。</li>
+ <li>右击并选择 发送到 → 压缩(zipped)文件夹。</li>
+ <li>将得到的文件从 <code>文件名.zip</code> 重命名为 <code>文件名.xpi</code>。</li>
+</ol>
+
+<p><img alt="Screenshot of the Windows Explorer context menu showing Send to compressed (zipped) folder" src="https://mdn.mozillademos.org/files/11717/pUF1vnr.png" style="height: 641px; width: 904px;"></p>
+
+<h3 id="Mac_OS_X">Mac OS X</h3>
+
+<ol>
+ <li>打开你的扩展文件所在的文件夹。</li>
+ <li>选择所有文件。</li>
+ <li>右击并选择 压缩 <em>n</em> 项。</li>
+ <li>将得到的文件从 <code>Archive.zip</code> 重命名为  <code>文件名.xpi</code>。</li>
+</ol>
+
+<p><img alt="Screenshot of the Finder context menu showing the Compress 15 Items option" src="https://mdn.mozillademos.org/files/11715/Screen%20Shot%202015-10-08%20at%2016.19.02.png" style="height: 460px; width: 850px;"></p>
+
+<h3 id="Linux_Mac_OS_X_终端">Linux / Mac OS X 终端</h3>
+
+<ol>
+ <li><code>cd path/to/my-extension/</code></li>
+ <li><code>zip -r ../my-extension.xpi *</code></li>
+</ol>
+
+<h2 id="安装你的扩展">安装你的扩展</h2>
+
+<ol>
+ <li>导航到 <code>about:addons</code></li>
+ <li>拖拽 XPI 到页面上,或者打开齿轮菜单,选择“从文件安装附加组件...”</li>
+ <li>点击弹出的对话框中的“安装”</li>
+</ol>
+
+<h2 id="在_Firefox_OS_上安装你的扩展">在 Firefox OS 上安装你的扩展</h2>
+
+<p><code>你可以使用 WebIDE 提供的 USB 或者 Wifi 进行安装</code></p>
+
+<h2 id="故障排除">故障排除</h2>
+
+<p>下面是几种你可能会遇到的常见问题:</p>
+
+<h3 id="此附加组件无法安装,因为它未经验证。">"此附加组件无法安装,因为它未经验证。"</h3>
+
+<ul>
+ <li>确保你正在使用 <a href="https://nightly.mozilla.org/">Nightly</a> ,并且已在 <code>about:config </code>中将 <code>xpinstall.signatures.required</code> 切换为 <code>false</code>。</li>
+ <li>在 <a href="/en-US/docs/Mozilla/Add-ons/Distribution">附加组件签名与分发</a> 了解更多信息。</li>
+</ul>
+
+<h3 id="该附加组件无法安装,因为它似乎已损坏。">"该附加组件无法安装,因为它似乎已损坏。"</h3>
+
+<ul>
+ <li>确保你是直接压缩你的附加组件文件,<strong>而不是</strong>压缩它们所在的文件夹。你的 manifest.json 文件必须在 zip 文件的根目录中。</li>
+ <li>确保你正在使用 <a href="https://nightly.mozilla.org/">Nightly</a> 版本的 Firefox。</li>
+</ul>
+
+<h3 id="完全没反应">完全没反应</h3>
+
+<ul>
+ <li>确保你的文件名称以 <code>.xpi</code> 结尾,因为某些操作系统可能会隐藏真实的文件扩展名。
+
+ <ul>
+ <li>在 Windows 上,选中 查看 → 显示 / 隐藏:文件扩展名。</li>
+ <li>在 Mac OS X 上,选中 文件 → 获取信息 → 名称和扩展名。</li>
+ </ul>
+ </li>
+ <li>还有一种可能,你不小心点击并因此驳回了安装提示。在 Nightly 中的后退按钮旁边找到一个拼图图标。点击它将重获这个弹出提示。</li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/porting_from_google_chrome/index.html b/files/zh-cn/mozilla/add-ons/webextensions/porting_from_google_chrome/index.html
new file mode 100644
index 0000000000..496abe0bd3
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/porting_from_google_chrome/index.html
@@ -0,0 +1,22 @@
+---
+title: 从 Google Chrome 移植
+slug: Mozilla/Add-ons/WebExtensions/Porting_from_Google_Chrome
+tags:
+ - WebExtensions
+translation_of: Mozilla/Add-ons/WebExtensions/Porting_a_Google_Chrome_extension
+---
+<div>{{AddonSidebar}}</div>
+
+<p>使用 WebExtension API 开发的扩展是专为跨浏览器兼容而设计的:很大程度上,该技术与 Google Chrome 和 Opera 支持的<a class="external external-icon" href="https://developer.chrome.com/extensions">扩展 API</a> 代码直接兼容。为这些浏览器编写的扩展,在大多数情况下,只需少数修改就能在 Firefox 中运行。几乎所有的<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API">扩展 API</a> 都支持使用 <code>chrome</code> 命名空间下的回调函数,跟 Chrome 一样。那些仅有的 <code>chrome</code> 命名空间不支持的 API 是故意不与 Chrome 兼容的。这些情况下,API 文档页将明确声明它仅在 <code>browser</code> 命名空间中受支持。从 Chrome 或者 Opera 移植一个扩展的过程大概这样:</p>
+
+<ol>
+ <li>检查你 manifest.json 使用的功能并了解 WebExtension API 对应的 <a href="/en-US/Add-ons/WebExtensions/Chrome_incompatibilities">Chrome 不兼容参考表</a>。如果你在使用的功能或者 API 还未被 Firefox 支持,那你可能还不能移植你的扩展。Mozilla 提供了一个服务可助您自动执行此步:<a href="https://www.extensiontest.com/">https://www.extensiontest.com/</a>。</li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Temporary_Installation_in_Firefox">安装你的扩展至 Firefox</a> 并对其进行测试。</li>
+ <li>如有任何问题,可通过 <a class="external external-icon" href="https://mail.mozilla.org/listinfo/dev-addons">dev-addons 邮件列表</a>或 <a class="external external-icon" href="https://wiki.mozilla.org/IRC">IRC</a> 上的 <a href="irc://irc.mozilla.org/webextensions">#webextensions</a> 联系我们。</li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Publishing_your_WebExtension">提交您的附加组件至 AMO 以供签名及分发</a>。</li>
+</ol>
+
+<p>如果您依赖 Chrome 命令行选项来加载解压的扩展,请参看 Firefox 中进行临时安装的 <a href="/en-US/Add-ons/WebExtensions/Getting_started_with_web-ext">web-ext</a> 工具以便开发。</p>
+
+<ul>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/prerequisites/index.html b/files/zh-cn/mozilla/add-ons/webextensions/prerequisites/index.html
new file mode 100644
index 0000000000..75abcfb904
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/prerequisites/index.html
@@ -0,0 +1,21 @@
+---
+title: 前提条件
+slug: Mozilla/Add-ons/WebExtensions/Prerequisites
+tags:
+ - firefox signature config
+ - firefox webextension config
+ - xpi signatures config
+translation_of: Mozilla/Add-ons/WebExtensions/Prerequisites
+---
+<p>要使用 WebExtension API 进行开发,你需要进行一些最基本的设置。</p>
+
+<ul>
+ <li>下载、安装和启动 <a href="https://www.mozilla.org/en-US/firefox/developer/">Firefox Developer Edition</a> 或者 <a class="external text" href="https://nightly.mozilla.org/" rel="nofollow">Firefox Nightly</a>。如果想要使用最近的更新,请使用 Nightly 版本。</li>
+ <li>调整 Firefox 是否允许你安装未签名附加组件的首选项。需注意,该首选项仅在 Firefox Developer Edition 和 Firefox Nightly 中可用。
+ <ul>
+ <li>在 Firefox 的地址栏中输入 <code>about:config</code></li>
+ <li>在搜索框中输入 <code>xpinstall.signatures.required</code></li>
+ <li>双击该首选项,或者右击并选择“切换”,将其设置为 <code>false</code>。</li>
+ </ul>
+ </li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/publishing_your_webextension/index.html b/files/zh-cn/mozilla/add-ons/webextensions/publishing_your_webextension/index.html
new file mode 100644
index 0000000000..e7792b75d4
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/publishing_your_webextension/index.html
@@ -0,0 +1,98 @@
+---
+title: 发布你的附加组件
+slug: Mozilla/Add-ons/WebExtensions/Publishing_your_WebExtension
+tags:
+ - WebExtensions
+translation_of: Mozilla/Add-ons/WebExtensions/Package_your_extension_
+---
+<div>{{AddonSidebar}}</div>
+
+<p>一般当你完成了基于WebExtension技术的附加组件的代码编写和测试, 你可能会想与其他人分享这成果(不管出于什么目的...). Mozilla旗下有一个网站: <a class="external external-icon" href="https://addons.mozilla.org">addons.mozilla.org</a> (简称AMO), 开发者们可以在这里发布附加组件, 而其他用户可以在这里找到这些附加组件并安装使用, 通过在AMO上发布你的附加组件, 你可以加入到我们的社区里来, 这里有一群用户和创造者, 说不准会发现几个使用你的附加组件的人哦.</p>
+
+<p>你编写的附加组件并不一定需要发布在AMO上, 但是、即使你不打算在AMO上发布你的附加组件, 你也必须提交你的附加组件到AMO上来进行审核以获得签名。因为火狐浏览器会拒绝安装没有AMO签名的附加组件。</p>
+
+<p>所以发布一个附加组件的流程, 可概述为:</p>
+
+<ol>
+ <li>压缩你所创建的附加组件文件</li>
+ <li>在<a href="https://addons.mozilla.org/zh-CN/">AMO</a>上创建一个属于你的账户</li>
+ <li>上传你的压缩文件到AMO来进行签名和审核, 并选择是否在AMO上进行发布</li>
+ <li>修复在审核中发现的任何问题</li>
+ <li>如果你选择不在AMO上发布, 可以恢复已签名的附件组件, 并自行发布</li>
+</ol>
+
+<p>当你准备发布附加组件的新版本时, 你可以访问 <a class="external external-icon" href="https://addons.mozilla.org">addons.mozilla.org </a>的附加组件页来更新它, 并上传新的版本.<br>
+ 需要注意的是: 你必须在这个附加组件页进行更新, 否则AMO没法知道你是要更新一个已经存在的附加组件呢, 还是要上传一个全新的附加组件呢.</p>
+
+<p>如果你选择在AMO上发布你的附加组件, 之后火狐浏览器会自动检查更新. 如果你选择自行发布,  你需要在你的manifest.json中手动设置一个<code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/applications">applications</a></code> 唯一标识, 并且需要手动设置<code>update_url属性指向你的</code><a href="/en-US/Add-ons/Updates">update manifest file</a>.</p>
+
+<div class="pull-aside">
+<div class="moreinfo">
+<p>火狐浏览器把附加组件包的后缀叫做或改为".xpi", 这只是".zip"的一个扩展.</p>
+
+<p>在上传附加组件到AMO的时候, 你不需要把压缩包的后缀改为".XPI".</p>
+</div>
+</div>
+
+<h2 id="1._使用zip压缩你的附加组件文件">1. 使用zip压缩你的附加组件文件</h2>
+
+<p>首先你的附加组件文件夹应该包含一个manifest.json和其他一些需要的文件 - javascript文件, icons文件, HTML文件等等. 你需要使用zip把它们压缩成一个文件以便上传到AMO.</p>
+
+<p>注意: 请将你的附加组件目录的的所有文件压缩为zip包,而 不要直接对附加组件根目录进行压缩(见下图所示).</p>
+
+<h3 id="Windows">Windows</h3>
+
+<ol>
+ <li>打开你的附加组件所在的文件夹.</li>
+ <li>选中所有文件.</li>
+ <li>右键并选择发送到 → 压缩到(zipped)文件夹.</li>
+</ol>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/11949/install-windows.png" style="display: block; height: 576px; margin-left: auto; margin-right: auto; width: 800px;"></p>
+
+<h3 id="Mac_OS_X">Mac OS X</h3>
+
+<ol>
+ <li>打开你的附加组件所在的文件夹.</li>
+ <li>选中所有文件.</li>
+ <li>右键并选择压缩<em>n项</em>.</li>
+</ol>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/11951/install-osx.png" style="display: block; height: 449px; margin-left: auto; margin-right: auto; width: 800px;"></p>
+
+<h3 id="Linux_Mac_OS_X_Terminal">Linux / Mac OS X Terminal</h3>
+
+<ol>
+ <li><code>cd path/to/my-addon/</code></li>
+ <li><code>zip -r ../my-addon.zip *</code></li>
+</ol>
+
+<h2 id="2._在AMO上创建一个账户">2. 在AMO上创建一个账户</h2>
+
+<p>访问<a href="https://addons.mozilla.org/">https://addons.mozilla.org/</a>. 如果你已经有一个<a href="https://support.mozilla.org/zh-CN/kb/firefox-mozilla">火狐账户</a>, 你可以直接使用它来登录. 否则, 点击"注册"并按要求创建一个火狐账户.</p>
+
+<h2 id="3._上传你的zip压缩文件">3. 上传你的zip压缩文件</h2>
+
+<p>接下来, 上传压缩后的附加组件到AMO进行签名和审查, 并选择是否发布到AMO, 更多细节, 可查看<a href="/en-US/Add-ons/Distribution#Submitting_to_AMO">Submitting to AMO</a>.</p>
+
+<div class="note">
+<p>需要注意的是一旦你上传了你的附加组件(基于WebExtension技术)到AMO, 你不能使用Add-on SDK或过时的XUL/XPCOM技术来更新该附加组件. 如果你切换到了这些技术平台之一, 必须把它做为新的附加组件并重新提交.</p>
+
+<p>总而言之: 像Add-on SDK和XUL/XPCOM等过时的技术体系在不久的将来都将被淘汰, WebExtensions才是唯一.</p>
+
+<p>在上传你的附加组件之前,请再次检查你的zip包内没有包含其他不相关的文件.</p>
+</div>
+
+<h2 id="4._修复审查中出现的问题">4. 修复审查中出现的问题</h2>
+
+<p>当你上传了附加组件, AMO服务器将运行一些基本的检查并立即通知你有关的一切问题. 这些问题分为2种类型: "错误"和"警告". 如果你有错误, 你必须修复它们并重新提交, 如果只是警告, 你最好也搞定它们(当可以也忽略警告): 然后可以继续提交.</p>
+
+<p>如果自动检查器没有报告任何错误, 该附件组件将进行更为详细的审核(复查). 你同样会收到审查结果并且需要修复所有问题, 然后重新提交.</p>
+
+<h2 id="5._发布你的附加组件">5. 发布你的附加组件</h2>
+
+<p>如果你选择了在AMO上托管你的附加组件, 这意味着发布过程的结束. AMO会对该附加组件进行签名和发布, 之后其他用户就能下载并安装使用了.</p>
+
+<p>如果你选择不在AMO上进行发布, 可以恢复已签名的附加组件, 并自行发布(比如把附件组件的压缩包直接发给别人).</p>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/safely_inserting_external_content_into_a_page/index.html b/files/zh-cn/mozilla/add-ons/webextensions/safely_inserting_external_content_into_a_page/index.html
new file mode 100644
index 0000000000..d40d36d813
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/safely_inserting_external_content_into_a_page/index.html
@@ -0,0 +1,102 @@
+---
+title: Safely inserting external content into a page
+slug: Mozilla/Add-ons/WebExtensions/Safely_inserting_external_content_into_a_page
+translation_of: Mozilla/Add-ons/WebExtensions/Safely_inserting_external_content_into_a_page
+---
+<p>{{AddonSidebar}}</p>
+
+<p>很多时候你需要从外部资源引入内容到你的插件。但是,源可能被嵌入了恶意的源代码,这些恶意的源代码可能由源的开发者或者恶意的第三方所编写。</p>
+
+<p>以RSS读取器为例子。你不知道你的插件将会打开什么RSS源也无法控制那些RSS源的内容。所以,可能用户可能订阅到一个RSS源里面包含了带有恶意脚本的标题。可能就是简单的JavaScript代码标签&lt;script&gt;&lt;/script&gt;。如果你在提取标题的时候,当作一般文本添加到一个页面的DOM,用户可能加载未知的脚本。因此,需要注意避免直接把一般文本加载为HTML。</p>
+
+<p>你还需要记住扩展有授权的上下文,例如后台的脚本backgroup scrips以及内容脚本content scripts。最坏的情况里,一个内嵌的洁白你可能运行在一个或多种上下文中,导致一些提取操作。这种情况会导致用户的浏览器暴露在远程攻击下,被注入代码访问用户的重要数据,例如密码、浏览器历史或者浏览器行为等。</p>
+
+<p>这篇文章说明如何安全的对待远端数据并添加到DOM。</p>
+
+
+
+<h2 id="处理任意字符串">处理任意字符串</h2>
+
+<p>当处理字符串时,有很多推荐的策略来安全添加他们到页面:标准的DOM节点创建方法或jQuery。</p>
+
+<h3 id="DOM节点创建方法函数">DOM节点创建方法/函数</h3>
+
+<p>一个轻量级的方法来插入字符串到页面是使用原生的DOM操纵方法/函数: <a href="/en-US/docs/Web/API/Document/createElement"><code>document.createElement</code></a>, <a href="/en-US/docs/Web/API/Element/setAttribute"><code>Element.setAttribute</code></a>, 以及<a href="/en-US/docs/Web/API/Node/textContent"><code>Node.textContent</code></a>. 安全的方法是分别创建节点并使用textContent属性赋值:</p>
+
+<pre class="brush: js example-good">var data = JSON.parse(responseText);
+var div = document.createElement("div");
+div.className = data.className;
+div.textContent = "Your favorite color is now " + data.color;
+addonElement.appendChild(div);</pre>
+
+<p>这种方法安全原因是使用<code>.textContent</code> 时会自动消除 <code>data.color</code>.中的任何远程 HTML代码。</p>
+
+<p>但是要注意,使用原生方法不能保证绝对安全,例如下面的代码:</p>
+
+<pre class="brush: js example-bad">var data = JSON.parse(responseText);
+addonElement.innerHTML = "&lt;div class='" + data.className + "'&gt;" +
+ "Your favorite color is now " + data.color +
+ "&lt;/div&gt;";</pre>
+
+<p>在其中,Here, the contents of <code>data.className</code> 或 <code>data.color</code> 的内容可能包含HTML代码使得标签提早关闭,并插入更多的HTML内容,之后关闭另一个标签。</p>
+
+<p>jQuery</p>
+
+<p>当使用jQuery的方法如 <code>attr()</code> 和 <code>text()</code> ,会清洗添加到DOM的内容。所以,上面“favorite color”例子采用jQuery实现会形如:</p>
+
+<pre class="brush: js example-good">var node = $("&lt;/div&gt;");
+node.addClass(data.className);
+node.text("Your favorite color is now " + data.color); </pre>
+
+<h2 id="处理HTML内容">处理HTML内容</h2>
+
+<p>当你知道处理外部源的内容是HTML的时候,添加到页面之前净化HTML是很关键的。净化HTML的最好办法是使用HTML净化的库或者一个带有HTML净化特性的模板引擎。在这一节,我们来看一些合适的工具以及使用方法。</p>
+
+<h3 id="HTML_净化">HTML 净化</h3>
+
+<p>An HTML sanitization library strips anything that could lead to script execution from HTML, so you can safely inject complete sets of HTML nodes from a remote source into your DOM. <a href="https://github.com/cure53/DOMPurify">DOMPurify</a>,是一个HTML净化的库,可以脱离任意会导致脚本执行的元素,以便安全注入远端源到HTML节点,这个库被很多不同的安全专家评估过,是很适合这种任务扩展的库。</p>
+
+<p><a href="https://github.com/cure53/DOMPurify">DOMPurify</a> 有一个简约版用于生产环境,purify.min.js. 你可以使用这个版本来适配你的扩展,例如你可以这样添加:</p>
+
+<pre class="brush: json">"content_scripts": [
+ {
+   "matches" : ["&lt;all_urls&gt;"],
+   "js": ["purify.min.js", "myinjectionscript.js"]
+ }
+]</pre>
+
+<p>之后,在myinjectionscript.js中你可以读取外部HTML并净化,之后添加到页面的DOM中:</p>
+
+<pre class="brush: js">var elem = document.createElement("div");
+var cleanHTML = DOMPurify.sanitize(externalHTML);
+elem.innerHTML = cleanHTML;</pre>
+
+<p>你可以使用任何方法添加净化后的HTML到DOM,例如jQuery’s <code>.html()</code> 方法。注意这种情况需要使用 Remember though that the <code>SAFE_FOR_JQUERY</code> 标记:</p>
+
+<pre class="brush: js">var elem = $("&lt;div/&gt;");
+var cleanHTML = DOMPurify.sanitize(externalHTML, { SAFE_FOR_JQUERY: true });
+elem.html(cleanHTML);</pre>
+
+<h3 id="模板引擎">模板引擎</h3>
+
+<p>另一个常见的模式是对一个页面创建本地HTML模板并通过远端的值来填空。这种方法被广泛应用,应该注意去避免构造函数的使用,可能会导致执行代码的注入。当模板引擎使用构造函数插入HTML到文档的时候会发生这种情况,如果用来注入原始HTML的变量是远端代码,这就属于上面介绍中的安全风险。</p>
+
+<p>例如,当使用<a href="https://mustache.github.io/">mustache templates</a> 你必须使用两个花括号<code>\{{variable}}</code>,来去掉任何HTML。使用三个花括号<code>\{\{{variable}}}</code> 必须避免注入原始HTML字符串到模板。</p>
+
+<p><a href="http://handlebarsjs.com/">Handlebars</a> 工作原理也是类似, <code>\{{variable}}</code> 。同时,如果创造了Handlebars helper使用 <code>Handlebars.SafeString</code> 使用<code>Handlebars.escapeExpression()</code> 来消除任何传给helper的动态参数。<code>Handlebars.SafeString</code> 的结果被认为是安全的,当插入到双handlebars的时候就不会做消除动作。</p>
+
+<p>在其他模板系统中也有类似的构造函数,需要有同样的考虑。</p>
+
+<h2 id="其他参考">其他参考</h2>
+
+<p>关于这个主题更多的信息,可以查看下面的文章</p>
+
+<ul>
+ <li>
+ <p><a href="https://owasp.org/www-community/xss-filter-evasion-cheatsheet">XSS (Cross Site Scripting) Prevention Cheat Sheet</a></p>
+ </li>
+</ul>
+
+<div id="gtx-trans" style="position: absolute; left: 220px; top: 3487px;">
+<div class="gtx-trans-icon"></div>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/user_interface/browser_action/index.html b/files/zh-cn/mozilla/add-ons/webextensions/user_interface/browser_action/index.html
new file mode 100644
index 0000000000..1ec5a5aced
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/user_interface/browser_action/index.html
@@ -0,0 +1,50 @@
+---
+title: Toolbar button
+slug: Mozilla/Add-ons/WebExtensions/user_interface/Browser_action
+translation_of: Mozilla/Add-ons/WebExtensions/user_interface/Browser_action
+---
+<div>{{AddonSidebar}}</div>
+
+<p>常说的 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserAction">浏览器动作(browser action)</a>, 指通过在工具栏上上添加新按钮,提供用户互动选项,用户可点击按钮与你的扩展进行互动。<br>
+ <img alt="" src="https://mdn.mozillademos.org/files/15751/browser-action.png" style="display: block; height: 182px; margin-left: auto; margin-right: auto; width: 350px;"></p>
+
+<p>工具栏按钮(browser action)与地址栏按钮(page action)极为相似。区分其不同点及使用,请参看 <a href="/en-US/Add-ons/WebExtensions/user_interface/Page_actions#Page_actions_and_browser_actions">Page actions and browser actions</a>.</p>
+
+<h2 id="指定浏览器动作">指定浏览器动作</h2>
+
+<p>通过manifest.json里的关键字<code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_action">browser_action</a></code> 来定义浏览器动作的属性:</p>
+
+<pre class="brush: json line-numbers language-json"><code class="language-json"><span class="key token">"browser_action":</span> <span class="punctuation token">{</span>
+ <span class="key token">"default_icon":</span> <span class="punctuation token">{</span>
+ <span class="key token">"19":</span> <span class="string token">"button/geo-19.png"</span><span class="punctuation token">,</span>
+ <span class="key token">"38":</span> <span class="string token">"button/geo-38.png"</span>
+ <span class="punctuation token">}</span><span class="punctuation token">,</span>
+ <span class="key token">"default_title":</span> <span class="string token">"Whereami?"</span>
+<span class="punctuation token">}</span></code></pre>
+
+<p>必须定义的键是 <code>default_icon</code>.</p>
+
+<p>有两种方法来指定浏览器动作:带弹出框(<a href="/en-US/Add-ons/WebExtensions/Popups">popup</a>)和不带弹出框(<a href="/en-US/Add-ons/WebExtensions/Popups">popup</a>)。</p>
+
+<p>如果不指定弹出框,当用户点击按钮时,点击事件将被发送至扩展,而扩展可用以下函数来捕获 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/BrowserAction/onClicked" title="Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup."><code>browserAction.onClicked</code></a>:</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js">browser<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleClick<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+
+<p>如果指定了弹出框,当用户点击按钮时,点击事件将不会被发送,而是显示出弹出框。用户能够通过弹出框进行互动,并且点击框外区域时弹出框会自动关闭。请参看文章 <a href="/en-US/Add-ons/WebExtensions/Popups">Popup </a>来了解更多关于创建和管理弹出框的细节。</p>
+
+<p>注意一个扩展只能指定一个浏览器动作。</p>
+
+<p>可通过<code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserAction">browserAction</a></code> API在程序里更改你的浏览器动作的属性。</p>
+
+<h2 id="图标">图标</h2>
+
+<p>想了解更多关于如何创建浏览器动作图标信息,请参看<a class="grey-90 no-underline hover-no-underline" href="https://design.firefox.com/photon/index.html">Photon Design System</a> 文档里的 <a href="https://design.firefox.com/photon/visuals/iconography.html">Iconography</a> 部分.</p>
+
+<h2 id="范例">范例</h2>
+
+<p>在Github上的扩展范例库 <a href="https://github.com/mdn/webextensions-examples">webextensions-examples</a> 中有两个实现浏览器动作的例子:</p>
+
+<ul>
+ <li><a href="https://github.com/mdn/webextensions-examples/blob/master/bookmark-it/">bookmark-it</a> uses a browser action without a popup.</li>
+ <li><a href="https://github.com/mdn/webextensions-examples/tree/master/beastify">beastify</a> uses a browser action with a popup.</li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/user_interface/browser_styles/index.html b/files/zh-cn/mozilla/add-ons/webextensions/user_interface/browser_styles/index.html
new file mode 100644
index 0000000000..e0647bc543
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/user_interface/browser_styles/index.html
@@ -0,0 +1,466 @@
+---
+title: Browser styles
+slug: Mozilla/Add-ons/WebExtensions/user_interface/Browser_styles
+tags:
+ - Browser style
+ - WebExtensions
+ - 扩展程序
+ - 指南
+ - 浏览器扩展程序
+ - 浏览器插件
+translation_of: Mozilla/Add-ons/WebExtensions/user_interface/Browser_styles
+---
+<div>{{AddonSidebar}}</div>
+
+<p>扩展程序包含的某些UI组件,例如: <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Popups">popups</a>, <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Sidebars">sidebars</a>, <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/user_interface/Options_pages">options pages</a> ,实际上可以用如下方式统一定义:</p>
+
+<ol>
+ <li>创建一个HTML文件用于描述该UI组件的页面结构</li>
+ <li>在manifest.json中添加字段 (<code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_action">browser_action</a></code>, <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/page_action">page_action</a></code>, <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action">sidebar_action</a></code>, 或 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/options_ui">options_ui</a></code>) 以指向其对应的页面</li>
+</ol>
+
+<p>这种方式面临的一个挑战是如何使用浏览器自带的样式,以使得组件的UI表现与浏览器的UI风格相符。要解决这个问题,可以在该字段的配置中增加一个可字段 <code>browser_sytle</code> ,如果设置了这个字段并且值为 <code>true</code> ,  那么该UI组件的HTML将会被插入一个或多个样式表,样式表会使你的扩展程序的UI表现与浏览器的风格一致 (并且与其它同样应用了这个字段的扩展程序一致)。</p>
+
+<p>若使用了 <code>browser_style: true</code> , 你需要在不同的浏览器主题中测试你的扩展程序,以确保其UI表现和期望的一致。 </p>
+
+<div class="blockIndicator note">
+<p><strong>谷歌浏览器Google Chrome</strong> 和 欧朋浏览器 <strong>Opera</strong> 使用字段名 <code>chrome_style</code> 而非<code>browser_style</code>, 因此如果要适配它们,你需要同时添加这两个字段。</p>
+</div>
+
+<p>在火狐浏览器中,这个样式文件可以在 <code>chrome://browser/content/extension.css</code>查看。为Mac OS X系统额外准备的样式文件也可以在  <code>chrome://browser/content/extension-mac.css</code> 查看。</p>
+
+<p>大多数样式是自动应用的,但是某些元素需要添加非标准的类名 <code style="white-space: nowrap;">browser-style</code> 来获得其样式,如下表所示:</p>
+
+<table class="fullwidth-table standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Element</th>
+ <th scope="col">Example</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code><a href="/en-US/docs/Web/HTML/Element/button">&lt;button&gt;</a></code></td>
+ <td>
+ <pre class="brush: html no-line-numbers">
+&lt;button class="browser-style"&gt;Click me&lt;/button&gt;</pre>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p><code><a href="/en-US/docs/Web/HTML/Element/select">&lt;select&gt;</a></code></p>
+ </td>
+ <td>
+ <pre class="brush: html no-line-numbers">
+&lt;select class="browser-style" name="select"&gt;
+ &lt;option value="value1"&gt;Value 1&lt;/option&gt;
+ &lt;option value="value2" selected&gt;Value 2&lt;/option&gt;
+ &lt;option value="value3"&gt;Value 3&lt;/option&gt;
+&lt;/select&gt;</pre>
+ </td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/docs/Web/HTML/Element/textarea">&lt;textarea&gt;</a></code></td>
+ <td>
+ <pre class="brush: html no-line-numbers">
+&lt;textarea class="browser-style"&gt;Write here&lt;/textarea&gt;</pre>
+ </td>
+ </tr>
+ <tr>
+ <td>Parent of an <code><a href="/en-US/docs/Web/HTML/Element/input">&lt;input&gt;</a></code></td>
+ <td>
+ <pre class="brush: html no-line-numbers">
+&lt;div class="browser-style"&gt;
+ &lt;input type="radio" id="op1" name="choices" value="op1"/&gt;
+ &lt;label for="op1"&gt;Option 1&lt;/label&gt;
+
+ &lt;input type="radio" id="op2" name="choices" value="op2"/&gt;
+ &lt;label for="op2"&gt;Option 2&lt;/label&gt;
+&lt;/div&gt;</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<div class="blockIndicator note">
+<p>查看 {{bug(1465256)}} 以了解相关修订</p>
+</div>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<div class="hidden">兼容列表由结构化文件生成,如果你想要贡献此文件,请通过 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 向我们发送pull request.</div>
+
+<p>{{Compat("webextensions.browser_style")}}</p>
+
+<h2 id="火狐面板组件Firefox_Panel_Components">火狐面板组件Firefox Panel Components</h2>
+
+<div class="blockIndicator nonStandard">
+<p><strong>非标准</strong><br>
+ 此功能不是通用标准,仅支持在firefox中使用</p>
+</div>
+
+<p><code>chrome://browser/content/extension.css</code> 样式文件中也包含了火狐面板组件的样式</p>
+
+<p><a href="https://firefoxux.github.io/StyleGuide/#/navigation">legacy Firefox Style Guide</a> 使用示例</p>
+
+<table class="fullwidth-table standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Element</th>
+ <th scope="col">Example</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>Header</td>
+ <td>
+ <pre class="brush: html">
+&lt;header class="panel-section panel-section-header"&gt;
+ &lt;div class="icon-section-header"&gt;&lt;img src="image.svg"/&gt;&lt;/div&gt;
+ &lt;div class="text-section-header"&gt;Header&lt;/div&gt;
+&lt;/header&gt;</pre>
+ </td>
+ </tr>
+ <tr>
+ <td>Footer</td>
+ <td>
+ <pre class="brush: html">
+&lt;footer class="panel-section panel-section-footer"&gt;
+ &lt;button class="panel-section-footer-button"&gt;Cancel&lt;/button&gt;
+ &lt;div class="panel-section-footer-separator"&gt;&lt;/div&gt;
+ &lt;button class="panel-section-footer-button default"&gt;Confirm&lt;/button&gt;
+&lt;/footer&gt;</pre>
+ </td>
+ </tr>
+ <tr>
+ <td>Tabs</td>
+ <td>
+ <pre class="brush: html">
+&lt;div class="panel-section panel-section-tabs"&gt;
+ &lt;button class="panel-section-tabs-button selected"&gt;Tab&lt;/button&gt;
+ &lt;div class="panel-section-tabs-separator"&gt;&lt;/div&gt;
+ &lt;button class="panel-section-tabs-button"&gt;Tab&lt;/button&gt;
+ &lt;div class="panel-section-tabs-separator"&gt;&lt;/div&gt;
+ &lt;button class="panel-section-tabs-button"&gt;Tab&lt;/button&gt;
+&lt;/div&gt;</pre>
+ </td>
+ </tr>
+ <tr>
+ <td>Form</td>
+ <td>
+ <pre class="brush: html">
+&lt;div class="panel-section panel-section-formElements"&gt;
+ &lt;div class="panel-formElements-item"&gt;
+ &lt;label for="name01"&gt;Label:&lt;/label&gt;
+ &lt;input type="text" value="Name" id="name01" /&gt;
+ &lt;/div&gt;
+ &lt;div class="panel-formElements-item"&gt;
+ &lt;label for="picker01"&gt;Label:&lt;/label&gt;
+ &lt;select id="picker01"&gt;
+ &lt;option value="value1" selected="true"&gt;Dropdown&lt;/option&gt;
+ &lt;option value="value2"&gt;List Item&lt;/option&gt;
+ &lt;option value="value3"&gt;List Item&lt;/option&gt;
+ &lt;/select&gt;
+ &lt;/div&gt;
+ &lt;div class="panel-formElements-item"&gt;
+ &lt;label for="placeholder01"&gt;Label:&lt;/label&gt;
+ &lt;input type="text" placeholder="Placeholder" id="placeholder01" /&gt;
+ &lt;button name="expander" class="expander"&gt;&lt;/button&gt;
+ &lt;/div&gt;
+&lt;/div&gt;</pre>
+ </td>
+ </tr>
+ <tr>
+ <td>Menu</td>
+ <td>
+ <pre class="brush: html">
+&lt;div class="panel-section panel-section-list"&gt;
+ &lt;div class="panel-list-item"&gt;
+ &lt;div class="icon"&gt;&lt;/div&gt;
+ &lt;div class="text"&gt;List Item&lt;/div&gt;
+ &lt;div class="text-shortcut"&gt;Ctrl-L&lt;/div&gt;
+ &lt;/div&gt;
+
+ &lt;div class="panel-list-item"&gt;
+ &lt;div class="icon"&gt;&lt;/div&gt;
+ &lt;div class="text"&gt;List Item&lt;/div&gt;
+ &lt;div class="text-shortcut"&gt;&lt;/div&gt;
+ &lt;/div&gt;
+
+ &lt;div class="panel-section-separator"&gt;&lt;/div&gt;
+
+ &lt;div class="panel-list-item disabled"&gt;
+ &lt;div class="icon"&gt;&lt;/div&gt;
+ &lt;div class="text"&gt;Disabled List Item&lt;/div&gt;
+ &lt;div class="text-shortcut"&gt;&lt;/div&gt;
+ &lt;/div&gt;
+
+ &lt;div class="panel-section-separator"&gt;&lt;/div&gt;
+
+ &lt;div class="panel-list-item"&gt;
+ &lt;div class="icon"&gt;&lt;/div&gt;
+ &lt;div class="text"&gt;List Item&lt;/div&gt;
+ &lt;div class="text-shortcut"&gt;&lt;/div&gt;
+ &lt;/div&gt;
+
+ &lt;div class="panel-list-item"&gt;
+ &lt;div class="icon"&gt;&lt;/div&gt;
+ &lt;div class="text"&gt;List Item&lt;/div&gt;
+ &lt;div class="text-shortcut"&gt;&lt;/div&gt;
+ &lt;/div&gt;
+&lt;/div&gt;</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Example">Example</h3>
+
+<h4 id="HTML">HTML</h4>
+
+<pre class="brush: html">&lt;header class="panel-section panel-section-header"&gt;
+ &lt;div class="icon-section-header"&gt;&lt;!-- An image goes here. --&gt;&lt;/div&gt;
+ &lt;div class="text-section-header"&gt;Header&lt;/div&gt;
+&lt;/header&gt;
+
+&lt;div class="panel-section panel-section-list"&gt;
+ &lt;div class="panel-list-item"&gt;
+ &lt;div class="icon"&gt;&lt;/div&gt;
+ &lt;div class="text"&gt;List Item&lt;/div&gt;
+ &lt;div class="text-shortcut"&gt;Ctrl-L&lt;/div&gt;
+ &lt;/div&gt;
+
+ &lt;div class="panel-list-item"&gt;
+ &lt;div class="icon"&gt;&lt;/div&gt;
+ &lt;div class="text"&gt;List Item&lt;/div&gt;
+ &lt;div class="text-shortcut"&gt;&lt;/div&gt;
+ &lt;/div&gt;
+
+ &lt;div class="panel-section-separator"&gt;&lt;/div&gt;
+
+ &lt;div class="panel-list-item disabled"&gt;
+ &lt;div class="icon"&gt;&lt;/div&gt;
+ &lt;div class="text"&gt;Disabled List Item&lt;/div&gt;
+ &lt;div class="text-shortcut"&gt;&lt;/div&gt;
+ &lt;/div&gt;
+
+ &lt;div class="panel-section-separator"&gt;&lt;/div&gt;
+
+ &lt;div class="panel-list-item"&gt;
+ &lt;div class="icon"&gt;&lt;/div&gt;
+ &lt;div class="text"&gt;List Item&lt;/div&gt;
+ &lt;div class="text-shortcut"&gt;&lt;/div&gt;
+ &lt;/div&gt;
+
+ &lt;div class="panel-list-item"&gt;
+ &lt;div class="icon"&gt;&lt;/div&gt;
+ &lt;div class="text"&gt;List Item&lt;/div&gt;
+ &lt;div class="text-shortcut"&gt;&lt;/div&gt;
+ &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;footer class="panel-section panel-section-footer"&gt;
+ &lt;button class="panel-section-footer-button"&gt;Cancel&lt;/button&gt;
+ &lt;div class="panel-section-footer-separator"&gt;&lt;/div&gt;
+ &lt;button class="panel-section-footer-button default"&gt;Confirm&lt;/button&gt;
+&lt;/footer&gt;</pre>
+
+<div class="hidden">
+<h4 id="CSS">CSS</h4>
+
+<pre class="brush: css">/* Global */
+html,
+body {
+ background: white;
+ box-sizing: border-box;
+ color: #222426;
+ cursor: default;
+ display: flex;
+ flex-direction: column;
+ font: caption;
+ margin: 0;
+ padding: 0;
+ -moz-user-select: none;
+}
+
+body * {
+ box-sizing: border-box;
+ text-align: start;
+}
+
+button.panel-section-footer-button,
+button.panel-section-tabs-button {
+ color: inherit;
+ background-color: unset;
+ font: inherit;
+ text-shadow: inherit;
+ -webkit-appearance: none;
+ -moz-appearance: none;
+ appearance: none;
+ border: none;
+}
+
+/* Panel Section */
+.panel-section {
+ display: flex;
+ flex-direction: row;
+}
+
+.panel-section-separator {
+ background-color: rgba(0, 0, 0, 0.15);
+ min-height: 1px;
+}
+
+/* Panel Section - Header */
+.panel-section-header {
+ border-bottom: 1px solid rgba(0, 0, 0, 0.15);
+ padding: 16px;
+}
+
+.panel-section-header &gt; .icon-section-header {
+ background-position: center center;
+ background-repeat: no-repeat;
+ height: 32px;
+ margin-right: 16px;
+ position: relative;
+ width: 32px;
+}
+
+.panel-section-header &gt; .text-section-header {
+ align-self: center;
+ font-size: 1.385em;
+ font-weight: lighter;
+}
+
+/* Panel Section - List */
+.panel-section-list {
+ flex-direction: column;
+ padding: 4px 0;
+}
+
+.panel-list-item {
+ align-items: center;
+ display: flex;
+ flex-direction: row;
+ height: 24px;
+ padding: 0 16px;
+}
+
+.panel-list-item:not(.disabled):hover {
+ background-color: rgba(0, 0, 0, 0.06);
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
+ border-top: 1px solid rgba(0, 0, 0, 0.1);
+}
+
+.panel-list-item:not(.disabled):hover:active {
+ background-color: rgba(0, 0, 0, 0.1);
+}
+
+.panel-list-item.disabled {
+ color: #999;
+}
+
+.panel-list-item &gt; .icon {
+ flex-grow: 0;
+ flex-shrink: 0;
+}
+
+.panel-list-item &gt; .text {
+ flex-grow: 10;
+}
+
+.panel-list-item &gt; .text-shortcut {
+ color: #808080;
+ font-family: "Lucida Grande", caption;
+ font-size: .847em;
+ justify-content: flex-end;
+}
+
+.panel-section-list .panel-section-separator {
+ margin: 4px 0;
+}
+
+/* Panel Section - Footer */
+.panel-section-footer {
+ background-color: rgba(0, 0, 0, 0.06);
+ border-top: 1px solid rgba(0, 0, 0, 0.15);
+ color: #1a1a1a;
+ display: flex;
+ flex-direction: row;
+ height: 41px;
+ margin-top: -1px;
+ padding: 0;
+}
+
+.panel-section-footer-button {
+ flex: 1 1 auto;
+ height: 100%;
+ margin: 0 -1px;
+ padding: 12px;
+ text-align: center;
+}
+
+.panel-section-footer-button &gt; .text-shortcut {
+ color: #808080;
+ font-family: "Lucida Grande", caption;
+ font-size: .847em;
+}
+
+.panel-section-footer-button:hover {
+ background-color: rgba(0, 0, 0, 0.06);
+}
+
+.panel-section-footer-button:hover:active {
+ background-color: rgba(0, 0, 0, 0.1);
+}
+
+.panel-section-footer-button.default {
+ background-color: #0996f8;
+ box-shadow: 0 1px 0 #0670cc inset;
+ color: #fff;
+}
+
+.panel-section-footer-button.default:hover {
+ background-color: #0670cc;
+ box-shadow: 0 1px 0 #005bab inset;
+}
+
+.panel-section-footer-button.default:hover:active {
+ background-color: #005bab;
+ box-shadow: 0 1px 0 #004480 inset;
+}
+
+.panel-section-footer-separator {
+ background-color: rgba(0, 0, 0, 0.1);
+ width: 1px;
+ z-index: 99;
+}</pre>
+
+<hr>
+<pre class="brush: css">/* Example specific – not part of chrome://browser/content/extension.css */
+body {
+ background: #fcfcfc;
+ background-clip: padding-box;
+ border: 1px solid rgba(24,26,27,.2);
+ box-shadow: 0 3px 5px rgba(24,26,27,.1),0 0 7px rgba(24,26,27,.1);
+ box-sizing: content-box;
+ margin: 2em auto .5em;
+ width: 384px;
+}
+
+html {
+ min-height: 100vh;
+}
+
+html &gt; body {
+ margin: auto;
+}
+
+.icon-section-header {
+ background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgdmlld0JveD0iMCAwIDMyIDMyIj48Y2lyY2xlIGZpbGw9IiMzNjM5NTkiIGN4PSIxNSIgY3k9IjE1IiByPSIxNSIvPjwvc3ZnPg==");
+}</pre>
+</div>
+
+<h4 id="Result若查看失败,请切回英文版查看">Result(若查看失败,请切回英文版查看)</h4>
+
+<p>{{EmbedLiveSample("Example","640","360")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/user_interface/context_menu_items/index.html b/files/zh-cn/mozilla/add-ons/webextensions/user_interface/context_menu_items/index.html
new file mode 100644
index 0000000000..2844e7319a
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/user_interface/context_menu_items/index.html
@@ -0,0 +1,48 @@
+---
+title: Context menu items
+slug: Mozilla/Add-ons/WebExtensions/user_interface/Context_menu_items
+translation_of: Mozilla/Add-ons/WebExtensions/user_interface/Context_menu_items
+---
+<div>{{AddonSidebar}}</div>
+
+<div>
+<p>This user interface option adds one or more items to a browser context menu. This is the context menu available when a user right-clicks on a web page. Tabs can have context menus also, available through the <a href="/en-US/Add-ons/WebExtensions/API/menus">browser.menus API</a>.</p>
+
+<p><img alt="Example of content menu items added by a WebExtension, from the context-menu-demo example" src="https://mdn.mozillademos.org/files/15051/context_menu_example.png" style="display: block; height: 587px; margin-left: auto; margin-right: auto; width: 573px;"></p>
+
+<p>You would use this option to expose features that are relevant to specific browser or web page contexts. For example, you could show features to open a graphic editor when the user clicks on an image or offer a feature to save page content when part of a page is selected. You can add plain menu items, checkbox items, radio button groups, and separators to menus. Once a context menu item has been added using {{WebExtAPIRef("contextMenus.create")}} it's displayed in all browser tabs, but you can hide it by removing it with {{WebExtAPIRef("contextMenus.remove")}}.</p>
+
+<h2 id="Specifying_context_menu_items">Specifying context menu items</h2>
+
+<p>You manage context menu items programmatically, using the {{WebExtAPIRef("contextMenus")}} API. However, you need to request the <code>contextMenus</code> permission in your manifest.json to be able to take advantage of the API.</p>
+
+<pre class="brush: json">"permissions": ["contextMenus"]</pre>
+
+<p>You can then add (and update or delete) the context menu items in your extension's background script. To create a menu item you specify an id, its title, and the context menus it should appear on:</p>
+
+<pre class="brush: js">browser.contextMenus.create({
+ id: "log-selection",
+ title: browser.i18n.getMessage("contextMenuItemSelectionLogger"),
+ contexts: ["selection"]
+}, onCreated);</pre>
+
+<p>Your extension then listens for clicks on the menu items. The passed information about the item clicked, the context where the click happened, and details of the tab where the click took place can then be used to invoke the appropriate extension functionality.</p>
+
+<pre class="brush: js">browser.contextMenus.onClicked.addListener(function(info, tab) {
+ switch (info.menuItemId) {
+ case "log-selection":
+ console.log(info.selectionText);
+ break;
+ ...
+ }
+})</pre>
+
+<h2 id="Examples">Examples</h2>
+
+<p>The <a class="external external-icon" href="https://github.com/mdn/webextensions-examples">webextensions-examples</a> repo on GitHub, contains several examples of extensions that use context menu items:</p>
+
+<ul>
+ <li><a href="https://github.com/mdn/webextensions-examples/tree/master/menu-demo">menu-demo</a> adds several items to the browser's context menu.</li>
+ <li><a href="https://github.com/mdn/webextensions-examples/tree/master/context-menu-copy-link-with-types">context-menu-copy-link-with-types</a> adds a context menu item to links that copies the URL to the clipboard, as plain text and rich HTML.</li>
+</ul>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/user_interface/devtools_panels/index.html b/files/zh-cn/mozilla/add-ons/webextensions/user_interface/devtools_panels/index.html
new file mode 100644
index 0000000000..8f55647526
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/user_interface/devtools_panels/index.html
@@ -0,0 +1,61 @@
+---
+title: devtools panels
+slug: Mozilla/Add-ons/WebExtensions/user_interface/devtools_panels
+translation_of: Mozilla/Add-ons/WebExtensions/user_interface/devtools_panels
+---
+<div>{{AddonSidebar}}</div>
+
+<div class="note">
+<p>This feature is available since Firefox 54.</p>
+</div>
+
+<p>When an extension provides tools that are of use to developers, it's possible to add a UI for them to the browser's developer tools as a new panel.</p>
+
+<p><img alt='Simple example showing the addition of "My panel" to the Developer Tools tabs.' src="https://mdn.mozillademos.org/files/15746/developer_panel_tab.png" style="display: block; height: 112px; margin-left: auto; margin-right: auto; width: 350px;"></p>
+
+<h2 id="Specifying_a_developer_tools_panel">Specifying a developer tools panel</h2>
+
+<p>A developer tools panel is added using the <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/devtools.panels">devtools.panels</a></code> API, which in turn needs to be run from a special devtools page.</p>
+
+<p>Add the devtools page by including the <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/devtools_page">devtools_page</a></code> key in extension's <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a> and provide the location of the page's HTML file in the extension:</p>
+
+<pre class="brush: json line-numbers language-json"><code class="language-json"><span class="key token">"devtools_page":</span> <span class="string token">"devtools-page.html"</span></code></pre>
+
+<p>From the devtools page, call a script that will add the devtools panel:</p>
+
+<pre class="brush: html">&lt;body&gt;
+  &lt;script src="devtools.js"&gt;&lt;/script&gt;
+&lt;/body&gt;</pre>
+
+<p>In the script, create the devtools panel by specifying the panel's title, icon, and HTML file that provides the panel's content:</p>
+
+<pre class="brush: js">function handleShown() {
+ console.log("panel is being shown");
+}
+
+function handleHidden() {
+ console.log("panel is being hidden");
+}
+
+browser.devtools.panels.create(
+ "My Panel", // title
+ "icons/star.png", // icon
+ "devtools/panel/panel.html" // content
+).then((newPanel) =&gt; {
+ newPanel.onShown.addListener(handleShown);
+ newPanel.onHidden.addListener(handleHidden);
+});</pre>
+
+<p>The extension can now run code in the inspected window using <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/devtools.inspectedWindow/eval"><code>devtools</code>.inspectedWindow.eval()</a></code> or by injecting a content script via the background script by passing a message. You can find more details on how to do this in <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Extending_the_developer_tools">Extending the developer tools.</a></p>
+
+<h2 id="Developer_panel_design">Developer panel design</h2>
+
+<p>For details on how to design your developer panel's web page to match the style of Firefox, see the <a class="grey-90 no-underline hover-no-underline" href="https://design.firefox.com/photon/index.html">Photon Design System</a> documentation.</p>
+
+<h2 id="Icons">Icons</h2>
+
+<p>For details on how to create icons to use with your developer tools panel, see <a href="https://design.firefox.com/photon/visuals/iconography.html">Iconography</a> in the <a class="grey-90 no-underline hover-no-underline" href="https://design.firefox.com/photon/index.html">Photon Design System</a> documentation.</p>
+
+<h2 id="Examples">Examples</h2>
+
+<p>The <a href="https://github.com/mdn/webextensions-examples">webextensions-examples</a> repository on GitHub includes the <a href="https://github.com/mdn/webextensions-examples/blob/master/devtools-panels/">devtools-panels</a> example which implements a devtools panel.</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/user_interface/index.html b/files/zh-cn/mozilla/add-ons/webextensions/user_interface/index.html
new file mode 100644
index 0000000000..f34e594284
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/user_interface/index.html
@@ -0,0 +1,92 @@
+---
+title: User interface
+slug: Mozilla/Add-ons/WebExtensions/user_interface
+translation_of: Mozilla/Add-ons/WebExtensions/user_interface
+---
+<div>{{AddonSidebar}}</div>
+
+<p>为了能给用户提供在不同场景下都具有价值的功能, WebExtensions 提供了许多的用户界面选项。下面是这些选项的摘要,在本章中将会对每个选项做出更详细的说明。</p>
+
+<div class="note">
+<p>想要使你的扩展能提供良好的用户体验吗? 请查看文章<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/User_experience_best_practices">用户体验的最佳实践</a> .</p>
+</div>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">UI 选项</th>
+ <th scope="col">描述</th>
+ <th scope="col" style="width: 350px;">实例</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Browser_action">浏览器工具栏按钮</a>(浏览器行为)</td>
+ <td>工具栏上一个可点击的按钮,点击时将事件派发到附件组件上。默认情况下,这个按钮在栏位中是可见的。</td>
+ <td><img alt="Example of a WebExtension toolbar button" src="https://mdn.mozillademos.org/files/12966/browser-action.png" style="height: 99px; width: 350px;"></td>
+ </tr>
+ <tr>
+ <td><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Page_actions">带有弹出面板的工具栏按钮</a></td>
+ <td>当这个在工具栏上的按钮被点击时,它会弹出一个面板。这个面板使用 HTML 文档编写,用于处理与用户的交互行为。</td>
+ <td><img alt="Example of a WebExtension toolbar button with a popup" src="https://mdn.mozillademos.org/files/14039/popup-shadow.png" style="height: 156px; width: 350px;"></td>
+ </tr>
+ <tr>
+ <td><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Page_actions">地址栏菜单按钮</a>(页面行为)</td>
+ <td>这个按钮位于浏览器地址栏菜单条,按钮被点击的时候可以派发一个事件出来。默认情况下,这个按钮在所有tab上都是隐藏的.</td>
+ <td><img alt="Example showing an address bar button (page action)" src="https://mdn.mozillademos.org/files/15047/address_bar_button.png" style="height: 127px; width: 350px;"></td>
+ </tr>
+ <tr>
+ <td>带有<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Popups">弹出面板</a>的地址栏菜单按钮</td>
+ <td>地址栏菜单按钮被点击时,会弹出一个面板,这个面板通过HTML文档定义,用于处理用户交互。</td>
+ <td><img alt="Example of a popup on the address bar button" src="https://mdn.mozillademos.org/files/15053/page_action_popup.png" style="height: 250px; width: 330px;"></td>
+ </tr>
+ <tr>
+ <td><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Context_menu_items">上下文菜单项</a></td>
+ <td>在一个或多个网页上下文菜单中的菜单项,复选框和单选按钮.菜单项也可以通过添加分隔栏进行分组,当一个菜单项被点击时,一个事件将会被派发至附加组件.</td>
+ <td><img alt="" src="https://mdn.mozillademos.org/files/15051/context_menu_example.png" style="height: 359px; width: 350px;"></td>
+ </tr>
+ <tr>
+ <td><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Sidebars">侧边栏</a></td>
+ <td>
+ <p dir="ltr">一个在网页边显示的HTML文档,每页都有其特定的内容. 每当扩展安装时侧边栏将会打开,但最终还是遵循用户的侧边栏可见性设置. 侧边栏内的用户交互通过HTML文档处理.</p>
+ </td>
+ <td><img alt="Example of a WebExtension's sidebar" src="https://mdn.mozillademos.org/files/14825/bookmarks-sidebar.png" style="height: 209px; width: 350px;"></td>
+ </tr>
+ <tr>
+ <td><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Options_pages">选项页面</a></td>
+ <td>一个可以使你定义可以更改的扩展首选项的页面. 用户可以从浏览器的附加组件管理器中访问此页面.</td>
+ <td><img alt="Example showing the options page content added in the favorite colors example." src="https://mdn.mozillademos.org/files/15055/options_page.png" style="height: 259px; width: 350px;"></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Bundled_web_pages">扩展页面</a></td>
+ <td>
+ <p>在单独的窗口或页面中使用扩展提供的页面来提供表单,帮助或其他任何需要的内容.</p>
+ </td>
+ <td><img alt="Example of a simple bundled page displayed as a detached panel." src="https://mdn.mozillademos.org/files/15063/bundled_page_as_panel_small.png" style="height: 180px; width: 350px;"></td>
+ </tr>
+ <tr>
+ <td><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Notifications">通知</a></td>
+ <td>通过底层操作系统的通知机制向用户显示的短暂通知. 当用户点击或者通知关闭时(用户关闭或超时关闭)派发事件到扩展程序.</td>
+ <td><img alt="Example notification from a WebExtension" src="https://mdn.mozillademos.org/files/14043/notify-shadowed.png" style="height: 95px; width: 350px;"></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Omnibox">地址栏建议</a></td>
+ <td>当用户输入关键词时提供自定义的地址栏建议.</td>
+ <td><img alt="Example showing the result of the firefox_code_search WebExtension's customization of the address bar suggestions." src="https://mdn.mozillademos.org/files/15059/omnibox_example_small.png" style="height: 242px; width: 350px;"></td>
+ </tr>
+ <tr>
+ <td><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/devtools_panels">开发者工具面板</a></td>
+ <td>在浏览器的开发者工具中显示的一个关联了HTML文档的标签.</td>
+ <td><img alt="New panel tab in the Developer Tools tab bar" src="https://mdn.mozillademos.org/files/15049/developer_panel_tab.png" style="height: 180px; width: 350px;"></td>
+ </tr>
+ </tbody>
+</table>
+
+<p>以下的操作指南提供了一些创建用户界面选项的指导;</p>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Add_a_button_to_the_toolbar">在工具栏中添加一个按钮</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Implement_a_settings_page">实现一个设置页面</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Extending_the_developer_tools">扩展开发人员工具</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/user_interface/Browser_styles">浏览器样式</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/user_interface/page_actions/index.html b/files/zh-cn/mozilla/add-ons/webextensions/user_interface/page_actions/index.html
new file mode 100644
index 0000000000..fe3901c4a8
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/user_interface/page_actions/index.html
@@ -0,0 +1,93 @@
+---
+title: 地址栏按钮
+slug: Mozilla/Add-ons/WebExtensions/user_interface/Page_actions
+translation_of: Mozilla/Add-ons/WebExtensions/user_interface/Page_actions
+---
+<div>{{AddonSideBar}}</div>
+
+<div>通常来说的page action,是添加到浏览器地址栏中的按钮。用户通过点击这个按钮与你的扩展进行交互。</div>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/15745/address_bar_button.png" style="display: block; height: 174px; margin-left: auto; margin-right: auto; width: 350px;"></p>
+
+<h2 id="地址栏按钮(Page_actions)和工具栏按钮(_browser_actions)">地址栏按钮(Page actions)和工具栏按钮( browser actions)</h2>
+
+<p>地址栏按钮(或 page action) 与工具栏按钮(或 browser action)非常相似。</p>
+
+<p>其不同之处为:</p>
+
+<ul>
+ <li>位置:
+ <ul>
+ <li>地址栏按钮是显示在浏览器的地址栏内;</li>
+ <li>工具栏按钮不是显示在地址栏内,而是在浏览器的工具栏上。</li>
+ </ul>
+ </li>
+ <li>可见性:
+ <ul>
+ <li>地址栏按钮默认是隐藏的(尽管可以通过manifest中“show_matches和hide_matches来改变),而你可以在特定tabs中调用pageAction.show()和pageAction.hide()来显示或隐藏它。</li>
+ <li>工具栏按钮总是可见的。</li>
+ </ul>
+ </li>
+</ul>
+
+<p>当动作(行为)与当前页面关联时,使用地址栏按钮,而当动作(行为)与浏览器相关或与多个页面相关时使用工具栏按钮。例如:</p>
+
+<table class="fullwidth-table standard-table">
+ <thead>
+ <tr>
+ <th scope="row">类型</th>
+ <th scope="col">书签动作</th>
+ <th scope="col">内容动作</th>
+ <th scope="col">标签操作</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th scope="row">page action</th>
+ <td>将本页面保存到书签</td>
+ <td>Reddit enhancement</td>
+ <td>Send tab</td>
+ </tr>
+ <tr>
+ <th scope="row">browser action</th>
+ <td>显示所有书签</td>
+ <td>使能ad-blocking</td>
+ <td>同步所有打开的标签</td>
+ </tr>
+ </tbody>
+</table>
+
+<p> </p>
+
+<h2 id="定义地址栏按钮">定义地址栏按钮</h2>
+
+<p>你可以在manifest.json中使用page_action键定义地址栏按钮的属性:</p>
+
+<pre class="brush: json line-numbers language-json"><code class="language-json"><span class="key token">"page_action":</span> <span class="punctuation token">{</span>
+ <span class="key token">"browser_style":</span> <span class="keyword token">true</span><span class="punctuation token">,</span>
+ <span class="key token">"default_icon":</span> <span class="punctuation token">{</span>
+ <span class="key token">"19":</span> <span class="string token">"button/geo-19.png"</span><span class="punctuation token">,</span>
+ <span class="key token">"38":</span> <span class="string token">"button/geo-38.png"</span>
+ <span class="punctuation token">}</span><span class="punctuation token">,</span>
+ <span class="key token">"default_title":</span> <span class="string token">"Whereami?"</span>
+<span class="punctuation token">}</span></code></pre>
+
+<p>仅default_icon是强制(必需)的。</p>
+
+<p>有两种方式定义地址栏按钮:带popup窗口和无popup窗口。如果你没有指定一个popup,则当用户点击此按钮时,事件被派送到使用<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/pageAction/onClicked">pageAction.onClicked</a>侦听器的扩展:</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js">browser<span class="punctuation token">.</span>pageAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleClick<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+
+<p>如果你指定了一个popup,则点击事件不被派送,在用户点击按钮时显示popup。用户可以与popup进行交互,并且当用户点击popup以外区域时,popup自动关闭。参见<a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Popups">Popup</a>可获得创建和管理popups更详细内容。</p>
+
+<p>注意你的扩展只能有一个地址栏按钮。</p>
+
+<p>通过使用<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/pageAction">pageAction</a> API,你可以以编程方式修改地址栏按钮的任何属性。</p>
+
+<h2 id="Icons">Icons</h2>
+
+<p>如何创建用于地址栏按钮的ICONS的详细内容,请参见<a href="https://design.firefox.com/photon/index.html">Photon Design System</a>文档中的<a href="https://design.firefox.com/photon/visuals/iconography.html">Iconography</a>节。</p>
+
+<h2 id="示例">示例</h2>
+
+<p>GitHub上的 <a href="https://github.com/mdn/webextensions-examples">webextensions-examples</a> 库中包括了实现无popup地址栏按钮的例子 <a href="https://github.com/mdn/webextensions-examples/tree/master/chill-out">chill-out</a> 。</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/user_interface/侧边栏/index.html b/files/zh-cn/mozilla/add-ons/webextensions/user_interface/侧边栏/index.html
new file mode 100644
index 0000000000..8d13bfaf2c
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/user_interface/侧边栏/index.html
@@ -0,0 +1,53 @@
+---
+title: 侧边栏
+slug: Mozilla/Add-ons/WebExtensions/user_interface/侧边栏
+translation_of: Mozilla/Add-ons/WebExtensions/user_interface/Sidebars
+---
+<div>{{AddonSidebar}}</div>
+
+<div>
+<p>A sidebar is a pane that is displayed at the side of the browser window, next to the web page. The browser provides a UI that enables the user to see the currently available sidebars and to select a sidebar to display. For example, Firefox has a "View &gt; Sidebar" menu. Only one sidebar can be shown at a time, and that sidebar will be displayed for all tabs and all browser windows.</p>
+
+<p>The browser may include a number of built-in sidebars. For example, Firefox includes a sidebar for interacting with bookmarks:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/15755/bookmarks-sidebar.png" style="display: block; height: 423px; margin-left: auto; margin-right: auto; width: 350px;">Using the <code>sidebar_action</code> manifest.json key, an extension can add its own sidebar to the browser. It will be listed alongside the built-in sidebars, and the user will be able to open it using the same mechanism as for the built-in sidebars.</p>
+
+<p>就像浏览器的弹出页面,侧边栏也是一个HTML文档。当用户打开侧边栏时,HTML文档载入打开的浏览器窗口。每个窗口有一个该文档的实例。打开一个新窗口时,该窗口获得自己的文档实例</p>
+
+<p>可以使用函数{{WebExtAPIRef("sidebarAction.setPanel()")}}指定侧边栏仅用于指定的某个标签,使用{{WebExtAPIRef("windows.getCurrent()")}} 侧边栏知道自己属于哪一个标签。</p>
+
+<pre class="brush: js">// sidebar.js
+browser.windows.getCurrent({populate: true}).then((windowInfo) =&gt; {
+ myWindowId = windowInfo.id;
+});</pre>
+
+<p>不同的窗口使用不同的侧边栏是非常有用的,这是一个实例 ,见<a href="https://github.com/mdn/webextensions-examples/tree/master/annotate-page">"annotate-page" example</a>.</p>
+
+<p>侧边栏俱有和后台程序以及弹出窗口相同的API权限,在非隐藏模式下,侧边栏使用API {{WebExtAPIRef("runtime.getBackgroundPage()")}} 可以直接访问后台页面,使用 API 如{{WebExtAPIRef("tabs.sendMessage()")}} 与content scripts交互,使用API 如 {{WebExtAPIRef("runtime.sendNativeMessage()")}} 与原生应用交互。</p>
+
+<p>关闭窗口或关闭侧边栏时,侧边栏文档退出。这意味着和后台页面不同,侧边栏文档不是一直住留,也不像弹出窗口,只要用户与页面交互 ,它就一直存在。</p>
+
+<p>使用侧边栏的扩展载入时,侧边栏自动打开。这是为了帮助用户知道扩展俱有侧边栏。注意不能通过编程的方式打开侧边栏:侧边栏只能由用户打开。</p>
+
+<h2 id="声明侧边栏">声明侧边栏</h2>
+
+<p>声明侧边栏,只需在manifest.json中指 定关键字  <code><a href="/en-US/Add-ons/WebExtensions/manifest.json/sidebar_action">sidebar_action</a></code>    并同时指定title 和 icon:</p>
+
+<pre class="brush: json">"sidebar_action": {
+ "default_title": "My sidebar",
+ "default_panel": "sidebar.html",
+ "default_icon": "sidebar_icon.png"
+}</pre>
+
+<p>使用API {{WebExtAPIRef("sidebarAction")}} ,你可以用编程的方式修改title panel icon。</p>
+
+<p>浏览器提供的显示侧边栏的UI中,title和icon显示给用户,如Firefox菜单栏的"View &gt; Sidebar"</p>
+
+<h2 id="Sidebar_design">Sidebar design</h2>
+
+<p>For details on how to design your sidebar's web page to match the style of Firefox, see the <a class="grey-90 no-underline hover-no-underline" href="https://design.firefox.com/photon/index.html">Photon Design System</a> documentation.</p>
+
+<h2 id="Example">Example</h2>
+
+<p>The <a href="https://github.com/mdn/webextensions-examples">webextensions-examples</a> repository on GitHub includes the <a href="https://github.com/mdn/webextensions-examples/tree/master/annotate-page">annotate-page</a> example which implements a sidebar.</p>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/walkthrough/index.html b/files/zh-cn/mozilla/add-ons/webextensions/walkthrough/index.html
new file mode 100644
index 0000000000..962e04d404
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/walkthrough/index.html
@@ -0,0 +1,488 @@
+---
+title: 你的第二个 WebExtension
+slug: Mozilla/Add-ons/WebExtensions/Walkthrough
+translation_of: Mozilla/Add-ons/WebExtensions/Your_second_WebExtension
+---
+<p>{{AddonSidebar}}</p>
+
+<p>如果你已经阅读了 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension">你的第一个扩展</a>,那么你现在已经知道如何写一个扩展了。在这篇文章,我们将写一个稍微复杂一点点的扩展来为你展示更多的一些API 。</p>
+
+<p>这个扩展会添加一个新按钮到 Firefox 的工具栏。在用户点击该按钮时,我们会显示一个弹出窗(popup)来让他们选择一种动物。在他们选择之后,我们会将当前网页替换为他所选动物的图片。</p>
+
+<p>要实现这点,我们将:</p>
+
+<ul>
+ <li><strong>定义一个浏览器动作(browser action),这用来附加一个按钮到 Firefox 的工具栏。</strong><br>
+ 对于该按钮,我们将提供:
+ <ul>
+ <li>一个文件名为 "beasts-32.png" 的图标</li>
+ <li>按钮被按下时要打开的弹出窗。该弹出窗将包含 HTML、CSS 和 JavaScript。</li>
+ </ul>
+ </li>
+ <li><strong>为扩展定义一个图标</strong>,叫做“beasts-48.png”。这个将会在Add-ons管理器中显示。</li>
+ <li><strong>写一个内容脚本 "beastify.js",用于注入到网页中。</strong><br>
+ 这是用来实际修改页面的代码。</li>
+ <li><strong>打包一些动物的图像,用以替换网页中的图像。</strong><br>
+ 我们让图像成为 “Web 可访问资源”( web accessible resources ),以便页面可以引用它们。</li>
+</ul>
+
+<p>你可以想象这样的扩展的整体结构:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/13671/Untitled-1.png"></p>
+
+<p>这是一个非常简单的扩展,但也展示了 WebExtensions API 的许多基本概念:</p>
+
+<ul>
+ <li>添加一个按钮到工具栏</li>
+ <li>定义一个将使用 HTML、CSS 和 JavaScript 的弹出窗</li>
+ <li>注入content scripts到网页</li>
+ <li>content scripts与扩展的其他部分之间的通信</li>
+ <li>打包你的扩展的资源,使其可被网页所用</li>
+</ul>
+
+<p>你可以在 GitHub 找到<a href="https://github.com/mdn/webextensions-examples/tree/master/beastify">该扩展的完整的源代码</a>。</p>
+
+<p>写这个扩展,你需要45或更高版本的firefox。</p>
+
+<h2 id="编写扩展">编写扩展</h2>
+
+<p>创建一个新目录,并切换到该目录:</p>
+
+<ol>
+ <li>
+ <pre class="brush: bash">mkdir beastify
+cd beastify</pre>
+ </li>
+</ol>
+
+<h3 id="manifest.json">manifest.json</h3>
+
+<p>现在创建一个名为 "manifest.json" 的文件,并对其添加下列内容:</p>
+
+<ol>
+ <li>
+ <pre><code>{
+
+ "manifest_version": 2,
+ "name": "Beastify",
+ "version": "1.0",
+
+ "description": "Adds a browser action icon to the toolbar. Click the button to choose a beast. The active tab's body content is then replaced with a picture of the chosen beast. See https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Examples#beastify",
+ "homepage_url": "https://github.com/mdn/webextensions-examples/tree/master/beastify",
+ "icons": {
+ "48": "icons/beasts-48.png"
+ },
+
+ "permissions": [
+ "activeTab"
+ ],
+
+ "browser_action": {
+ "default_icon": "icons/beasts-32.png",
+ "default_title": "Beastify",
+ "default_popup": "popup/choose_beast.html"
+ },
+
+ "web_accessible_resources": [
+ "beasts/frog.jpg",
+ "beasts/turtle.jpg",
+ "beasts/snake.jpg"
+ ]
+
+}</code></pre>
+ </li>
+</ol>
+
+<ul>
+ <li>最开始的三个属性: <strong><code>manifest_version</code></strong>, <strong><code>name</code></strong>, <strong><code>version</code></strong>, 是必须的并且包含了插件最基本的信息。</li>
+ <li><a href="/zh-CN/docs/Mozilla/Tech/XUL/Attribute/description">description </a>和 <a href="/Add-ons/WebExtensions/manifest.json/homepage_url">homepage_url </a>是可选的,但是推荐填写,因为它们提供关于扩展的有用信息。</li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/manifest.json/icons">icons </a>也是可选但推荐的,它决定了插件在附加组件中的图标。</li>
+ <li><strong><code>permissions</code></strong> 列出了插件所需要的权限。在这里我们仅需要 <a href="/zh-CN/Add-ons/WebExtensions/manifest.json/permissions#activeTab_permission">activeTab permission</a>。</li>
+ <li><strong><code>browser_action</code></strong> 指定了工具栏按钮。我们在这里提供了三个信息片段:
+ <ul>
+ <li><strong><code>default_icon</code></strong> 是必须的,指定了按钮的图标。</li>
+ <li><strong><code>default_title</code></strong> 是可选的,用于按钮的提示。</li>
+ <li><strong><code>default_popup</code></strong>  在你想要当用户点击按钮时显示出一个弹出窗时使用。而在这里,我们需要,所以我们列入这个键并将其指向扩展中包括的一个HTML文件。</li>
+ </ul>
+ </li>
+ <li><strong><code>web_accessible_resources</code></strong> 列出了页面可访问的资源。例如由于当前插件使用动物图像替换了页面原有的图像,当前的动物图像要可以被页面访问。</li>
+</ul>
+
+<p>需要注意,所有路径是相对于 manifest.json 。</p>
+
+<h3 id="图标">图标</h3>
+
+<p>插件应该有一个图标。这个图标被用于显示在附加组件管理器中(可以通过"about:addons"来访问)。当前插件中manifest.json指定了我们插件的图标位于"icons/beasts-48.png"。</p>
+
+<p>创建“icons”文件夹,并将图标命名为“beasts-48.png”。你可以使用我们例子中的<a href="https://github.com/mdn/webextensions-examples/blob/master/beastify/icons/beasts-48.png">图标</a>,它是从 <a href="https://www.iconfinder.com/iconsets/free-retina-icon-set">Aha-Soft’s Free Retina iconset</a> 截取的,使用需要遵循该网站的<a href="http://www.aha-soft.com/free-icons/free-retina-icon-set//zh-CN/docs/">许可证</a>。</p>
+
+<p>如果你使用自己的图标,它的尺寸应该是48<math><semantics><mo>×</mo><annotation encoding="TeX">\times</annotation></semantics></math>48像素的。同时,对于高分辨率的设备,可以提供96<math><semantics><mo>×</mo><annotation encoding="TeX">\times</annotation></semantics></math>96像素的图片。此时,manifest.json应当这样配置:</p>
+
+<ol>
+ <li>
+ <pre class="brush: json line-numbers language-json"><code class="language-json"><span class="key token">"icons":</span> <span class="punctuation token">{</span>
+ <span class="key token">"48":</span> <span class="string token">"icons/beasts-48.png"</span><span class="punctuation token">,</span>
+ <span class="key token">"96":</span> <span class="string token">"icons/beasts-96.png"</span>
+<span class="punctuation token">}</span></code></pre>
+ </li>
+</ol>
+
+
+
+<h3 id="工具栏按钮">工具栏按钮</h3>
+
+<p>工具栏按钮也需要一个图标,并且我们的 manifest.json 承诺我们会为该工具栏在 "icons/beasts-32.png" 提供一个图标。</p>
+
+<p>将一个图标命名为为 "beasts-32.png"并保存到"icons"文件夹。你可以使用例子中的<a href="https://github.com/mdn/webextensions-examples/blob/master/beastify/icons/beasts-32.png">图片</a>,它是取自 <a href="http://www.iconbeast.com/free">IconBeast Lite 图标集</a>并按其<a href="http://www.iconbeast.com/faq/">许可协议</a>授权使用。</p>
+
+<p>如果你没有弹出窗,用户点击的事件会直接分派到你的插件中。<span style="line-height: 1.5;">如果你制作了弹出窗,用户点击会直接打开这个弹出窗,而不会被分派给插件。</span><span style="line-height: 1.5;">本例中我们需要弹出窗,因此我们现在开始写它。</span></p>
+
+<h3 id="弹出窗">弹出窗</h3>
+
+<p>该弹出窗的函数是让用户选择三种动物的其中一种。</p>
+
+<p>在根目录下创建“popup”文件夹,用于存放弹出窗的代码。弹出窗由以下文件组成:</p>
+
+<ul>
+ <li><strong><code>choose_beast.html</code></strong> 定义了界面的主面板</li>
+ <li><strong><code>choose_beast.css</code></strong> 美化内容</li>
+ <li><strong><code>choose_beast.js</code></strong> 通过在当前活跃的标签页中运行内容脚本(content script)处理用户的选择</li>
+</ul>
+
+<pre class="brush: bash line-numbers language-bash"><code class="language-bash"><span class="function token">mkdir</span> popup
+<span class="function token">cd</span> popup
+<span class="function token">touch</span> choose_beast.html choose_beast.css choose_beast.js</code></pre>
+
+<h4 id="choose_beast.html">choose_beast.html</h4>
+
+<p>HTML 文件就像这样:</p>
+
+<ol>
+ <li>
+ <pre class="brush: html">&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+ &lt;head&gt;
+ &lt;meta charset="utf-8"&gt;
+ &lt;link rel="stylesheet" href="choose_beast.css"/&gt;
+ &lt;/head&gt;
+
+&lt;body&gt;
+ &lt;div id="popup-content"&gt;
+ &lt;div class="button beast"&gt;Frog&lt;/div&gt;
+ &lt;div class="button beast"&gt;Turtle&lt;/div&gt;
+ &lt;div class="button beast"&gt;Snake&lt;/div&gt;
+ &lt;div class="button reset"&gt;Reset&lt;/div&gt;
+ &lt;/div&gt;
+ &lt;div id="error-content" class="hidden"&gt;
+ &lt;p&gt;Can't beastify this web page.&lt;/p&gt;&lt;p&gt;Try a different page.&lt;/p&gt;
+ &lt;/div&gt;
+ &lt;script src="choose_beast.js"&gt;&lt;/script&gt;
+&lt;/body&gt;
+
+&lt;/html&gt;</pre>
+ </li>
+</ol>
+
+<p>我们有一个ID为 <code>"popup-content"</code> 的<a href="/zh-CN/docs/Web/HTML/Element/div">&lt;div&gt;</a>元素包含了每个动物选择。我们还有另外一个<code>&lt;div&gt;</code> 元素,它的ID为 <code>"error-content"</code> ,class为<code>"hidden"</code>。我们将会使用它以防初始化弹窗的时候出问题。</p>
+
+<p>注意我们引入了CSS和JS文件,就像网页一样。</p>
+
+<h4 id="choose_beast.css">choose_beast.css</h4>
+
+<p>CSS 固定了弹出窗的大小,确保3个选择填充满空间,并给了他们基本点样式。同时隐藏了<code>class="hidden"</code>的元素,这意味着我们的<code>"error-content"</code> <code>&lt;div&gt;</code> 将会被默认隐藏:</p>
+
+<ol>
+ <li>
+ <pre class="brush: css">html, body {
+ width: 100px;
+}
+
+.hidden {
+ display: none;
+}
+
+.button {
+ margin: 3% auto;
+ padding: 4px;
+ text-align: center;
+ font-size: 1.5em;
+ cursor: pointer;
+}
+
+.beast:hover {
+ background-color: #CFF2F2;
+}
+
+.beast {
+ background-color: #E5F2F2;
+}
+
+.reset {
+ background-color: #FBFBC9;
+}
+
+.reset:hover {
+ background-color: #EAEA9D;
+}</pre>
+ </li>
+</ol>
+
+<h4 id="choose_beast.js">choose_beast.js</h4>
+
+<p>我们在弹出窗的脚本中监听点击事件。 如果用户选择其中一个动物,我们在当前标签页中插入一段内容脚本。一旦内容脚本加载,我们发送一条有关动物选择的信息:</p>
+
+<ol>
+ <li>
+ <pre class="brush: js">/**
+ * CSS to hide everything on the page,
+ * except for elements that have the "beastify-image" class.
+ */
+const hidePage = `body &gt; :not(.beastify-image) {
+ display: none;
+ }`;
+
+/**
+ * Listen for clicks on the buttons, and send the appropriate message to
+ * the content script in the page.
+ */
+function listenForClicks() {
+ document.addEventListener("click", (e) =&gt; {
+
+ /**
+ * Given the name of a beast, get the URL to the corresponding image.
+ */
+ function beastNameToURL(beastName) {
+ switch (beastName) {
+ case "Frog":
+ return browser.extension.getURL("beasts/frog.jpg");
+ case "Snake":
+ return browser.extension.getURL("beasts/snake.jpg");
+ case "Turtle":
+ return browser.extension.getURL("beasts/turtle.jpg");
+ }
+ }
+
+ /**
+ * Insert the page-hiding CSS into the active tab,
+ * then get the beast URL and
+ * send a "beastify" message to the content script in the active tab.
+ */
+ function beastify(tabs) {
+ browser.tabs.insertCSS({code: hidePage}).then(() =&gt; {
+ let url = beastNameToURL(e.target.textContent);
+ browser.tabs.sendMessage(tabs[0].id, {
+ command: "beastify",
+ beastURL: url
+ });
+ });
+ }
+
+ /**
+ * Remove the page-hiding CSS from the active tab,
+ * send a "reset" message to the content script in the active tab.
+ */
+ function reset(tabs) {
+ browser.tabs.removeCSS({code: hidePage}).then(() =&gt; {
+ browser.tabs.sendMessage(tabs[0].id, {
+ command: "reset",
+ });
+ });
+ }
+
+ /**
+ * Just log the error to the console.
+ */
+ function reportError(error) {
+ console.error(`Could not beastify: ${error}`);
+ }
+
+ /**
+ * Get the active tab,
+ * then call "beastify()" or "reset()" as appropriate.
+ */
+ if (e.target.classList.contains("beast")) {
+ browser.tabs.query({active: true, currentWindow: true})
+ .then(beastify)
+ .catch(reportError);
+ }
+ else if (e.target.classList.contains("reset")) {
+ browser.tabs.query({active: true, currentWindow: true})
+ .then(reset)
+ .catch(reportError);
+ }
+ });
+}
+
+/**
+ * There was an error executing the script.
+ * Display the popup's error message, and hide the normal UI.
+ */
+function reportExecuteScriptError(error) {
+ document.querySelector("#popup-content").classList.add("hidden");
+ document.querySelector("#error-content").classList.remove("hidden");
+ console.error(`Failed to execute beastify content script: ${error.message}`);
+}
+
+/**
+ * When the popup loads, inject a content script into the active tab,
+ * and add a click handler.
+ * If we couldn't inject the script, handle the error.
+ */
+browser.tabs.executeScript({file: "/content_scripts/beastify.js"})
+.then(listenForClicks)
+.catch(reportExecuteScriptError);</pre>
+ </li>
+</ol>
+
+<p>从96行开始。只要弹出窗加载完,popup scrpit 就会使用 <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/executeScript">browser.tabs.executeScript()</a></code> API在活跃标签页执行 content script。如果执行 content scrpit成功,content script会在页面中一直保持,直到标签被关闭或者用户导航到其他页面。</p>
+
+<p><code>browser.tabs.executeScript()</code>调用失败的常见原因是你不能在所有页面执行content scripts。例如,你不能在特权浏览器页面执行,像about:debugging,你也不能在<a href="https://addons.mozilla.org/">addons.mozilla.org</a>域执行。如果调用失败,<code>reportExecuteScriptError()</code>会隐藏<code>"popup-content"</code> <code>&lt;div&gt;</code>,并展示<code>"error-content"</code> <code>&lt;div&gt;</code>, 然后打印一个错误到<a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Debugging">控制台</a>。</p>
+
+<p>如果成功执行 content script ,我们会调用 <code>listenForClicks()</code>。这个监听了弹窗上的点击事件。</p>
+
+<ul>
+ <li>如果点击有 <code>class="beast"</code>的按钮上,将会调用 <code>beastify()</code>.</li>
+ <li>如果点击有 <code>class="reset"</code>的按钮上,将会调用 <code>reset()</code>.</li>
+</ul>
+
+<p><code>beastify()</code> 函数做了三件事:</p>
+
+<ul>
+ <li>将被点击的按钮映射到一个指向特定动物图片的URL</li>
+ <li>通过<code><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/insertCSS">browser.tabs.insertCSS()</a></code> API 向页面注入一些CSS来隐藏整个页面的内容</li>
+ <li>通过<code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/sendMessage">browser.tabs.sendMessage()</a></code> API 向 content script 发送“beastify”信息,要求其 beastify 页面,同时向其传递一个指向动物图片的URL</li>
+</ul>
+
+<p><code>reset()</code> 函数实际上就是撤销 beastify :</p>
+
+<ul>
+ <li>通过 <code><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/removeCSS">browser.tabs.removeCSS()</a></code> API 移除我们添加的CSS</li>
+ <li>向 content script 发送“reset”信息要求其重置页面</li>
+</ul>
+
+<h3 id="The_content_script">The content script</h3>
+
+<p>在扩展的根目录下创建一个新的文件夹,叫做"content_scripts",然后在里面新建一个新的名为 "beastify.js" 的文件,内容如下:</p>
+
+<ol>
+ <li>
+ <pre class="brush: js">(function() {
+ /**
+ * Check and set a global guard variable.
+ * If this content script is injected into the same page again,
+ * it will do nothing next time.
+ */
+ if (window.hasRun) {
+ return;
+ }
+ window.hasRun = true;
+
+ /**
+ * Given a URL to a beast image, remove all existing beasts, then
+ * create and style an IMG node pointing to
+ * that image, then insert the node into the document.
+ */
+ function insertBeast(beastURL) {
+ removeExistingBeasts();
+ let beastImage = document.createElement("img");
+ beastImage.setAttribute("src", beastURL);
+ beastImage.style.height = "100vh";
+ beastImage.className = "beastify-image";
+ document.body.appendChild(beastImage);
+ }
+
+ /**
+ * Remove every beast from the page.
+ */
+ function removeExistingBeasts() {
+ let existingBeasts = document.querySelectorAll(".beastify-image");
+ for (let beast of existingBeasts) {
+ beast.remove();
+ }
+ }
+
+ /**
+ * Listen for messages from the background script.
+ * Call "beastify()" or "reset()".
+ */
+ browser.runtime.onMessage.addListener((message) =&gt; {
+ if (message.command === "beastify") {
+ insertBeast(message.beastURL);
+ } else if (message.command === "reset") {
+ removeExistingBeasts();
+ }
+ });
+
+})();</pre>
+ </li>
+</ol>
+
+<p>content script做的第一件事是检查全局变量 <code>window.hasRun</code>:如果它被设置了,脚本直接返回,否则设置<code>window.hasRun</code>并继续。原因是每次用户打开弹出窗,弹出窗就会在活跃页面执行一个content script ,所以我们可能会在单个页面运行多个脚本实例。如果是这样的话,我们需要保证只有一个实例在做所有事情。</p>
+
+<p>然后,从第40行开始,content script 监听来自弹出窗的信息,使用<code><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/onMessage">browser.runtime.onMessage</a></code> API。在上面我们看到弹出窗脚本能够发送两种不同的信息:"beastify" and "reset"。</p>
+
+<ul>
+ <li>如果信息是 "beastify",我们期待它包含一个指向动物图片的URL。我们移除先前调用添加的动物图片,然后构造并添加一个 src属性被设置动物图片URL 的<code><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img">&lt;img&gt;</a></code> 元素。</li>
+ <li>如果信息是 "reset",我们只需要移除所有被添加的动物片。</li>
+</ul>
+
+<h3 id="动物们">动物们</h3>
+
+<p>最后,我们要加入包含动物们的图像。</p>
+
+<p>创建"beasts"文件夹,之后将图片放入并命名。你可以从 <a href="https://github.com/mdn/webextensions-examples/tree/master/beastify/beasts">the GitHub repository</a>,或这里下载图片:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/11459/frog.jpg" style="display: inline-block; height: 200px; margin: 20px; width: 200px;"><img alt="" src="https://mdn.mozillademos.org/files/11461/snake.jpg" style="display: inline-block; height: 200px; margin: 20px; width: 200px;"><img alt="" src="https://mdn.mozillademos.org/files/11463/turtle.jpg" style="display: inline-block; height: 200px; margin: 20px; width: 200px;"></p>
+
+<h2 id="测试">测试</h2>
+
+<p>请仔细确认项目目录如下所示:</p>
+
+<ol>
+ <li>
+ <pre><code>beastify/
+
+ beasts/
+ frog.jpg
+ snake.jpg
+ turtle.jpg
+
+ content_scripts/
+ beastify.js
+
+ icons/
+ beasts-32.png
+ beasts-48.png
+
+ popup/
+ choose_beast.css
+ choose_beast.html
+ choose_beast.js
+
+ manifest.json</code></pre>
+ </li>
+</ol>
+
+<p>Firefox 45开始,你可以临时从硬盘中安装扩展</p>
+
+<p>在Firefox地址栏中输入:about:debugging,单击“临时载入附加组件”,然后选择你的manifest.json文件。</p>
+
+<p>然后你应该已经看到扩展图标出现在了Firefox的工具条上:</p>
+
+<p>{{EmbedYouTube("sAM78GU4P34")}}</p>
+
+<p>打开一个网页,然后点击图标,选择一个动物,然后观察网页的变化</p>
+
+<p>{{EmbedYouTube("YMQXyAQSiE8")}}</p>
+
+<h2 id="用命令行开发">用命令行开发</h2>
+
+<p>你可以通过使用 <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Getting_started_with_web-ext">web-ext</a> 工具来将临时安装的工作自动化,试试这个:</p>
+
+<ol>
+ <li>
+ <pre class="brush: bash"><code>cd beastify
+web-ext run</code></pre>
+ </li>
+</ol>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/what_are_webextensions/index.html b/files/zh-cn/mozilla/add-ons/webextensions/what_are_webextensions/index.html
new file mode 100644
index 0000000000..d327d3bd6a
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/what_are_webextensions/index.html
@@ -0,0 +1,61 @@
+---
+title: 扩展是什么?
+slug: Mozilla/Add-ons/WebExtensions/What_are_WebExtensions
+tags:
+ - Add-ons
+ - WebExtensions
+ - 拓展
+ - 附加组件
+translation_of: Mozilla/Add-ons/WebExtensions/What_are_WebExtensions
+---
+<div>{{AddonSidebar}}</div>
+
+<p>扩展为浏览器添加特性与功能。它通过熟悉的 web 技术——HTML,CSS 还有 JavaScript 来创建。扩展可以利用网页上的 JavaScript 使用同一批 API,但扩展也可以访问扩展自己专用的 JavaScript API。这意味着,和在网页里编码相比,在扩展中,可以做到更加多的事情。以下是其中一些你可以做的事情的示例:</p>
+
+<p><strong>提升或补充网站功能:</strong>用扩展来实现额外的浏览器内的特性或者来自于你网站的信息。它允许用户搜集他们访问过的页面细节来提升你所提供的服务。</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/15808/Amazon_add_on.png"></p>
+
+<p>示例: <a href="https://addons.mozilla.org/zh-CN/firefox/addon/amazon-browser-bar/">亚马逊助手</a>, <a href="https://addons.mozilla.org/zh-CN/firefox/addon/onenote-clipper/">OneNote Web Clipper</a>, 和 <a href="https://addons.mozilla.org/zh-CN/firefox/addon/grammarly-1/">Grammarly for Firefox</a></p>
+
+<p><strong>让用户展现他们的个性:</strong>浏览器扩展可以操控网页的内容;例如,让用户在每个页面上添加他们最喜欢的徽标或者图片。扩展也可以让用户更新火狐浏览器的界面,就像独立的<a href="https://developer.mozilla.org/en-US/Add-ons/Themes/Theme_concepts">主题扩展</a>一样。</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/15809/MyWeb_New_Tab_add_on.png" style="height: 398px; width: 540px;"></p>
+
+<p>示例: <a href="https://addons.mozilla.org/zh-CN/firefox/addon/myweb-new-tab/">MyWeb New Tab</a>, <a href="https://addons.mozilla.org/zh-CN/firefox/addon/tabliss/">Tabliss</a>, 和 <a href="https://addons.mozilla.org/zh-CN/firefox/addon/vivaldifox/">VivaldiFox</a></p>
+
+<p><strong>从网页中添加或删除内容:</strong>你可能想要帮助用户从网页中阻止一些侵扰的广告,当网页中提到一个国家或者城市时提供旅游指南,或者重组页面内容来提供一个统一的阅读体验。有了可以访问和更新一个页面里的 HTML 和 CSS的能力,扩展可以帮助用户以他们想要的形式来查看网页。</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/15807/ublock_origin_add_on.png" style="height: 480px; width: 640px;"></p>
+
+<p>示例: <a href="https://addons.mozilla.org/zh-CN/firefox/addon/ublock-origin/">uBlock Origin</a>, <a href="https://addons.mozilla.org/zh-CN/firefox/addon/reader/">Reader</a>, 和 <a href="https://addons.mozilla.org/zh-CN/firefox/addon/toolbox-google-play-store/">Toolbox for Google Play Store™</a></p>
+
+<p><strong>添加工具和新的浏览特性:</strong>给任务面板添加新特性,或者从URL地址,超链接,或者页面文字生成二维码。有了灵活的界面选择和 <a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions">WebExtensions APIs</a> 你可以轻松的添加新的特性到浏览器。并且,你可以提升几乎任何网站的特性或者功能,不必是你自己的网站。</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/15806/QR_Code_Image_Generator_add_on.png"></p>
+
+<p>示例: <a href="https://addons.mozilla.org/zh-CN/firefox/addon/swimlanes-for-trello/">Swimlanes for Trello</a> 和 <a href="https://addons.mozilla.org/zh-CN/firefox/addon/tomato-clock/">Tomato Clock</a></p>
+
+<p><strong>游戏:</strong>通过线下游戏的特性,或者探索新游戏的可能性来提供传统计算机游戏功能;例如,把游戏合并入每天网页浏览中。</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/15805/Asteroids_in_Popup_add_on%20.png" style="height: 438px; width: 700px;"></p>
+
+<p>示例:<a href="https://addons.mozilla.org/zh-CN/firefox/addon/solitaire-card-game-new-tab/">Solitaire Card Game New Tab</a>, 和 <a href="https://addons.mozilla.org/zh-CN/firefox/addon/2048-prime/">2048 Prime</a>.</p>
+
+<p><strong>添加开发工具:</strong>你可以提供网站开发工具给你的公司或者开发一个有用的技术或者你想分享的网站开发技术。无论哪种方式,你可以通过对开发者工具栏添加一个新的标齐那也来提升内置的 Firefox 开发者工具。</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/15804/aXe_Developer_Tools_add_on.png" style="height: 261px; width: 700px;"></p>
+
+<p>示例: <a href="https://addons.mozilla.org/zh-CN/firefox/addon/web-developer/">Web Developer</a>, <a href="https://addons.mozilla.org/zh-CN/firefox/addon/react-devtools/">Web React Developer Tools</a>, 和 <a href="https://addons.mozilla.org/zh-CN/firefox/addon/axe-devtools/">aXe Developer Tools</a></p>
+
+<p>Firefox 扩展使用 WebExtensions API,一种跨浏览器的扩展开发系统,构建而成。 在很大程度上,它与 Google Chrome 和 Opera 所支持的<a class="external-icon external" href="https://developer.chrome.com/extensions">扩展 API</a> 兼容。 在大多数情况下,为这些浏览器所写的扩展只需<a href="/zh-CN/Add-ons/WebExtensions/Porting_from_Google_Chrome">少量修改</a>便可在 FireFox 和 Microsoft Edge 上运行。这些 API 也完全兼容<a href="/zh-CN/Firefox/Multiprocess_Firefox">多线程 Firefox</a>。</p>
+
+<p>如果你有想法或问题,或者在使用 WebExtensions API 迁移旧式附加组件时需要帮助,您可以在 <a class="external-icon external" href="https://mail.mozilla.org/listinfo/dev-addons">dev-addons 邮件列表</a>或者<a class="external-icon external" href="https://wiki.mozilla.org/Matrix">Matrix</a> 上的 <a href="https://chat.mozilla.org/#/room/#addons:mozilla.org">Add-ons room</a> 与我们联系。</p>
+
+<h2 id="接下来呢?">接下来呢?</h2>
+
+<ul>
+ <li>在<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension">你的第一个扩展</a>中开始开发一个简单的扩展。</li>
+ <li>在<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Anatomy_of_a_WebExtension">解析一个扩展</a>中了解扩展的结构。</li>
+ <li>在<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Examples">扩展示例</a>中尝试一些示例扩展。</li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/what_next_/index.html b/files/zh-cn/mozilla/add-ons/webextensions/what_next_/index.html
new file mode 100644
index 0000000000..91694acf8d
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/what_next_/index.html
@@ -0,0 +1,58 @@
+---
+title: What next?
+slug: Mozilla/Add-ons/WebExtensions/What_next_
+translation_of: Mozilla/Add-ons/WebExtensions/What_next_
+---
+<div>{{AddonSidebar}}</div>
+
+<p>You will now be ready to start turning your idea for a browser extension into reality. Before you start that journey, it's worth being aware of a few things that will help to make it a smooth one.</p>
+
+<h2 id="你的开发环境">你的开发环境</h2>
+
+<p>你不需要任何特殊的开发或构建环境工具来创建浏览器扩展:只需要一个简单的文本编辑器就可以创建出很好的浏览器扩展。当然,你可能一直在做web开发有一套你想去配置的开发工具和环境。如果是这样,你需要意识到一些事情。</p>
+
+<p>如果你使用了打包压缩工具来交付你最终的代码,你需要提交你的源码到<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/What_next_$translate?tolocale=zh-CN#The_review_process"> AMO </a>审查。此外,用于压缩、混淆、构建的工具需要是开源的(或提供无限的免费使用), 并且可以在审阅者的计算机(Windows、Mac或Linux)上运行。主要是,我们的审阅者无法使用商业或基于Web的工具。</p>
+
+<p> </p>
+
+<p><a href="/en-US/Add-ons/Source_Code_Submission#About_build_tools">学习更多关于构建工具</a></p>
+
+<h2 id="Third-party_libraries">Third-party libraries</h2>
+
+<p>Third-party libraries are a great way to add complex features or functionality to your browser extensions quickly. When you submit an extension to the <a href="#The_review_processv">AMO review process</a>, the process will also consider any third-party libraries used. To streamline the review, make sure you always download third-party libraries from their official website or repository, and if the library is minified provide a link to the source code. Please note that third-party libraries cannot be modified in any way.</p>
+
+<p><a href="/en-US/Add-ons/Source_Code_Submission">Learn more about submitting source code</a></p>
+
+<h2 id="The_Firefox_Add-on_Distribution_Agreement">The Firefox Add-on Distribution Agreement</h2>
+
+<p>Browser extensions need to be signed to install into the release or beta versions of Firefox. Signing takes place in addons.mozilla.org (AMO) and is subject to the terms and conditions of the Firefox Add-on Distribution Agreement. The goal of the agreement is to ensure Firefox users get access to well supported, quality add-ons that enhance the Firefox experience.</p>
+
+<p><a href="/Add-ons/AMO/Policy/Agreement">Read the agreement</a></p>
+
+<p><a href="/en-US/Add-ons/WebExtensions/Distribution">Learn more about signing</a></p>
+
+<h2 id="The_review_process">The review process</h2>
+
+<p>When a browser extension is submitted for signing, it's subject to automated review. It may also be subject to a manual review, when the automated review determines that a manual review is needed. Your browser extension won't be signed until it’s passed the automated review and may have its signing revoked if it fails to pass the manual review. The review process follows a strict set of guidelines, so it’s easy to check and avoid any likely review problems.</p>
+
+<p><a href="/en-US/Add-ons/AMO/Policy/Reviews">Check out the review policy and guidelines</a></p>
+
+<h2 id="AMO_featured_browser_extensions">AMO featured browser extensions</h2>
+
+<p>If you choose to list your browser extension on AMO, your extension could be featured on the AMO website, in the Firefox browser’s add-on manager, or elsewhere on a Mozilla website. We've compiled a list of guidelines about how extensions are selected for featuring, by following these guidelines you give your extension the best chance of being featured.</p>
+
+<p><a href="/en-US/Add-ons/AMO/Policy/Featured">Learn more about getting your add-ons featured</a></p>
+
+<h2 id="Continue_your_learning_experience">Continue your learning experience</h2>
+
+<p>Now you know what lies ahead, it's time to dive into more details about browser extension development. In the sections that follow, you’ll discover:</p>
+
+<ul>
+ <li>More about the fundamental concepts behind browser extensions, starting with details on how to <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Using_the_JavaScript_APIs">use the JavaScript APIs</a>.</li>
+ <li>A guide to the <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface">user interface components</a> available to your browser extensions.</li>
+ <li>A collection of how-to guides on achieving key tasks in your extensions or making use of the JavaScript APIs.</li>
+ <li>Information on how to port other browser extensions to Firefox.</li>
+ <li>Details about the Firefox specific workflows you can use to develop browser extensions.</li>
+ <li>A full reference guide to the JavaScript APIs.</li>
+ <li>A full reference guide to the Manifest keys.</li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/working_with_the_tabs_api/index.html b/files/zh-cn/mozilla/add-ons/webextensions/working_with_the_tabs_api/index.html
new file mode 100644
index 0000000000..e1b5878010
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/working_with_the_tabs_api/index.html
@@ -0,0 +1,634 @@
+---
+title: Working with the Tabs API
+slug: Mozilla/Add-ons/WebExtensions/Working_with_the_Tabs_API
+tags:
+ - 选项卡
+ - 附加组件
+translation_of: Mozilla/Add-ons/WebExtensions/Working_with_the_Tabs_API
+---
+<p>{{AddonSidebar}}</p>
+
+<p><span class="tlid-translation translation" lang="zh-CN"><span title="">选项卡允许用户在其浏览器窗口中打开多个网页,然后在这些网页之间切换。</span> <span title="">使用Tabs API,您可以使用和操作这些选项卡来创建实用程序,为用户提供使用选项卡或提供扩展功能的新方法。</span></span></p>
+
+<p>在这篇how-to文章中我们将看到:</p>
+
+<ul>
+ <li><span class="tlid-translation translation" lang="zh-CN"><span title="">使用Tabs API所需的权限。</span></span></li>
+ <li><span class="tlid-translation translation" lang="zh-CN"><span title="">使用{{WebExtAPIRef("tabs.query")}}发现有关标签及其属性的更多信息。</span></span></li>
+ <li><span class="tlid-translation translation" lang="zh-CN"><span title="">创建、复制、移动、更新、重新加载和删除选项卡。</span></span></li>
+ <li><span class="tlid-translation translation" lang="zh-CN"><span title="">操纵标签的缩放大小。</span></span></li>
+ <li><span class="tlid-translation translation" lang="zh-CN"><span title="">操纵选项卡的CSS。</span></span></li>
+</ul>
+
+<p><span class="tlid-translation translation" lang="zh-CN"><span title="">最后,我们通过查看API提供的其他一些其他功能。</span></span></p>
+
+<div class="blockIndicator note">
+<p><span class="tlid-translation translation" lang="zh-CN"><span title="">注意:其他地方有一些Tab API功能。</span> <span title="">这些是可用于使用脚本操作选项卡内容的方法{{WebExtAPIRef("tabs.connect")}},{{WebExtAPIRef("tabs.sendMessage")}}和{{WebExtAPIRef("tabs.executeScript")}}</span>。<span title="">如果您需要有关这些方法的更多信息,请参阅概念文章<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">内容脚本</a>和操作指南<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Modify_a_web_page">修改网页</a>。</span></span></p>
+</div>
+
+<h2 id="权限和选项卡API"><span class="tlid-translation translation" lang="zh-CN"><span title="">权限和选项卡API</span></span></h2>
+
+<p><span class="tlid-translation translation" lang="zh-CN"><span title="">对于大多数Tabs API函数,您不需要任何权限;</span> <span title="">但是,有一些例外:</span></span></p>
+
+<ul>
+ <li><span class="tlid-translation translation" lang="zh-CN"><span title="">需要</span></span><code>"tabs"</code><span class="tlid-translation translation" lang="zh-CN"><span title="">权限才能访问Tab对象的<code>Tab.url</code>,<code>Tab.title</code>和<code>Tab.favIconUrl</code>属性。</span> <span title="">在Firefox中,您还需要</span></span><code>"tabs"</code><span class="tlid-translation translation" lang="zh-CN"><span title="">来按URL执行<a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/query">查询</a>。</span></span></li>
+ <li>{{WebExtAPIRef("tabs.executeScript")}}或{{WebExtAPIRef("tabs.insertCSS")}}需要<a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#Host_permissions">主机权限</a>。</li>
+</ul>
+
+<p>以下是您可以在扩展程序的manifest.json文件中请求<code>"tabs"</code>权限的方法:</p>
+
+<pre class="brush: json">"permissions": [
+  "&lt;all_urls&gt;",
+  "tabs"
+],
+</pre>
+
+<p>此请求允许您在用户访问的所有网站上使用所有标签API功能。 还有一种替代方法可以请求权限使用{{WebExtAPIRef("tabs.executeScript")}}或{{WebExtAPIRef("tabs.insertCSS")}},其中您不需要主机权限,形式为<a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#activeTab_permission"><code>"activeTab"</code></a>。 此权限与<code>&lt;all_urls&gt;</code>提供与<code>"tabs"</code>相同的权限,但有两个限制:</p>
+
+<ul>
+ <li><span class="tlid-translation translation" lang="zh-CN"><span title="">用户必须通过其浏览器或页面操作,上下文菜单或快捷键与扩展进行交互。</span></span></li>
+ <li><span class="tlid-translation translation" lang="zh-CN"><span title="">它仅在活动选项卡中授予权限。</span></span></li>
+</ul>
+
+<p><span class="tlid-translation translation" lang="zh-CN"><span title="">这种方法的好处是用户不会收到权限警告,也就是说您的扩展程序可以“访问所有网站的数据”。</span> <span title="">这是因为</span></span><code>&lt;all_urls&gt;</code><span class="tlid-translation translation" lang="zh-CN"><span title="">权限使扩展能够在任何选项卡中随时执行脚本,而</span></span><a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#activeTab_permission"><code>"activeTab"</code></a><span class="tlid-translation translation" lang="zh-CN"><span title="">仅限于允许扩展在当前选项卡中执行用户请求的操作。</span></span></p>
+
+<h2 id="Discovering_more_about_tabs_and_their_properties">Discovering more about tabs and their properties</h2>
+
+<p>There will be occasions when you want to get a list of all the tabs in all the browser windows. Other times you might want to find a subset of tabs that match some specific criteria, such as those opened from a specific tab or displaying pages from a particular domain. And once you have your list of tabs, you’ll probably want to know more about their properties.</p>
+
+<p>This is where {{WebExtAPIRef("tabs.query")}} comes in. Used alone to get all tabs or taking the <code>queryInfo</code> object—to specify query criteria such as whether the tab is active, in the current window, or one or more of 17 criteria—{{WebExtAPIRef("tabs.query")}} returns an array of {{WebExtAPIRef("tabs.Tab")}} objects containing information about the tabs.</p>
+
+<p>Where you want information about the current tab only, you can get a {{WebExtAPIRef("tabs.Tab")}} object for that tab using {{WebExtAPIRef("tabs.getCurrent")}}. If you have a tab’s ID, you can get its {{WebExtAPIRef("tabs.Tab")}} object using {{WebExtAPIRef("tabs.get")}}.</p>
+
+<div class="blockIndicator note">
+<p><strong>Note:</strong></p>
+
+<ul>
+ <li><strong>In Chrome,</strong> the user can select multiple tabs in a window, and the Tabs API sees these as highlighted tabs.</li>
+ <li><strong>In Firefox,</strong> the user can’t select multiple tabs, so “highlighted” and “active” are synonymous.</li>
+</ul>
+</div>
+
+<h3 id="How_to_example">How to example</h3>
+
+<p>To see how {{WebExtAPIRef("tabs.query")}} and {{WebExtAPIRef("tabs.Tab")}} are used, let’s walk through how the <a href="https://github.com/mdn/webextensions-examples/tree/master/tabs-tabs-tabs">tabs-tabs-tabs</a> example adds the list of “switch to tabs” to its toolbar button popup.</p>
+
+<p><img alt="The tabs tabs tabs toolbar menu showing the switch to tap area" src="https://mdn.mozillademos.org/files/15723/Switch_to_tab.png" style="height: 645px; width: 369px;"></p>
+
+<h3 id="manifest.json">manifest.json</h3>
+
+<p>Here is the <a href="https://github.com/mdn/webextensions-examples/blob/master/tabs-tabs-tabs/manifest.json">manifest.json</a>:</p>
+
+<pre class="brush: json">{
+  "browser_action": {
+    "browser_style": true,
+    "default_title": "Tabs, tabs, tabs",
+    "default_popup": "tabs.html"
+  },
+  "description": "A list of methods you can perform on a tab.",
+  "homepage_url": "https://github.com/mdn/webextensions-examples/tree/master/tabs-tabs-tabs",
+  "manifest_version": 2,
+  "name": "Tabs, tabs, tabs",
+  "permissions": [
+    "tabs"
+  ],
+  "version": "1.0"
+}
+</pre>
+
+<div class="blockIndicator note">
+<p>Note the following:</p>
+
+<ul>
+ <li>
+ <p><strong>tabs.html is defined as the <code>default_popup</code> in <code>browser_action</code>.</strong> It is displayed whenever the user clicks the extension’s toolbar icon.</p>
+ </li>
+ <li>
+ <p><strong>Permissions includes tabs.</strong> This is needed to support the tab list feature, as the extension reads the title of the tabs for display in the popup.</p>
+ </li>
+</ul>
+</div>
+
+<h3 id="tabs.html">tabs.html</h3>
+
+<p>tabs.html defines the content of the extension’s popup:</p>
+
+<pre class="brush: html">&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+
+ &lt;head&gt;
+    &lt;meta charset="utf-8"&gt;
+    &lt;link rel="stylesheet" href="tabs.css"/&gt;
+ &lt;/head&gt;
+
+&lt;body&gt;
+
+ &lt;div class="panel"&gt;
+    &lt;div class="panel-section panel-section-header"&gt;
+     &lt;div class="text-section-header"&gt;Tabs-tabs-tabs&lt;/div&gt;
+    &lt;/div&gt;
+
+    &lt;a href="#" id="tabs-move-beginning"&gt;Move active tab to the beginning of the window&lt;/a&gt;&lt;br&gt;
+
+
+…
+
+Define the other menu items
+…
+
+    &lt;div class="switch-tabs"&gt;
+
+     &lt;p&gt;Switch to tab&lt;/p&gt;
+
+     &lt;div id="tabs-list"&gt;&lt;/div&gt;
+
+    &lt;/div&gt;
+ &lt;/div&gt;
+
+ &lt;script src="tabs.js"&gt;&lt;/script&gt;
+
+&lt;/body&gt;
+
+&lt;/html&gt;
+</pre>
+
+<p>Here is a summary of the above does:</p>
+
+<ol>
+ <li>The menu items are declared.  </li>
+ <li>An empty <code>div</code> with the ID <code>tabs-list</code> is declared to contain the list of tabs.</li>
+ <li>tabs.js is called.</li>
+</ol>
+
+<h3 id="tabs.js">tabs.js</h3>
+
+<p>In <a href="https://github.com/mdn/webextensions-examples/blob/master/tabs-tabs-tabs/tabs.js">tabs.js</a>, we’ll see how the list of tabs is built and added to the popup.  </p>
+
+<h4 id="Creating_the_popup">Creating the popup</h4>
+
+<p>First, an event handler is added to execute <code>listTabs()</code> when tabs.html is loaded:</p>
+
+<pre class="brush: js">document.addEventListener("DOMContentLoaded", listTabs);</pre>
+
+<p>The first thing that <code>listTabs()</code> does is to call <code>getCurrentWindowTabs()</code>. This is where {{WebExtAPIRef("tabs.query")}} is used to get a {{WebExtAPIRef("tabs.Tab")}} object for the tabs in the current window:</p>
+
+<pre class="brush: js">function getCurrentWindowTabs() {
+  return browser.tabs.query({currentWindow: true});
+}
+</pre>
+
+<p>Now, <code>listTabs()</code> is ready to create the content for the popup.</p>
+
+<p>To start with:</p>
+
+<ol>
+ <li>Grab the <code>tabs-list</code> <code>div</code>.</li>
+ <li>Create a document fragment (into which the list will be built).</li>
+ <li>Set counters.</li>
+ <li>Clear the content of the <code>tabs-list</code> <code>div</code>.</li>
+</ol>
+
+<pre class="brush: js">function listTabs() {
+ getCurrentWindowTabs().then((tabs) =&gt; {
+    let tabsList = document.getElementById('tabs-list');
+    let currentTabs = document.createDocumentFragment();
+    let limit = 5;
+    let counter = 0;
+
+    tabsList.textContent = '';
+</pre>
+
+<p>Next, we’ll create the links for each tab:</p>
+
+<ol>
+ <li>Loops through the first 5 items from the {{WebExtAPIRef("tabs.Tab")}} object.</li>
+ <li>For each item, add a hyperlink to the document fragment.
+ <ul>
+ <li>The link’s label—that is, its text—is set using the tab’s title (or the ID, if it has no title).</li>
+ <li>The link’s address is set using the tab’s ID.</li>
+ </ul>
+ </li>
+</ol>
+
+<pre class="brush: js">    for (let tab of tabs) {
+     if (!tab.active &amp;&amp; counter &lt;= limit) {
+        let tabLink = document.createElement('a');
+
+        tabLink.textContent = tab.title || tab.id;
+
+       tabLink.setAttribute('href', tab.id);
+        tabLink.classList.add('switch-tabs');
+        currentTabs.appendChild(tabLink);
+     }
+
+     counter += 1;
+
+    }
+</pre>
+
+<p>Finally, the document fragment is written to the <code>tabs-list</code> div:</p>
+
+<pre class="brush: js">    tabsList.appendChild(currentTabs);
+  });
+}
+</pre>
+
+<h4 id="Working_with_the_active_tab">Working with the active tab</h4>
+
+<p>Another related example feature is the “Alert active tab” info option that dumps all the {{WebExtAPIRef("tabs.Tab")}} object properties for the active tab into an alert:</p>
+
+<pre class="brush: js"> else if (e.target.id === "tabs-alertinfo") {
+   callOnActiveTab((tab) =&gt; {
+     let props = "";
+     for (let item in tab) {
+       props += `${ item } = ${ tab[item] } \n`;
+     }
+     alert(props);
+   });
+ }
+</pre>
+
+<p>Where <code>callOnActiveTab()</code> finds the active tab object by looping through the {{WebExtAPIRef("tabs.Tab")}} objects looking for the item with active set:</p>
+
+<pre class="brush: js">document.addEventListener("click", function(e) {
+ function callOnActiveTab(callback) {
+   getCurrentWindowTabs().then((tabs) =&gt; {
+     for (var tab of tabs) {
+       if (tab.active) {
+         callback(tab, tabs);
+       }
+     }
+   });
+ }
+}
+
+</pre>
+
+<h2 id="Creating_duplicating_moving_updating_reloading_and_removing_tabs">Creating, duplicating, moving, updating, reloading, and removing tabs</h2>
+
+<p>Having gathered information about the tabs you’ll most likely want to do something with them—either to offer users features for manipulating and managing tabs or to implement functionality in your extension.</p>
+
+<p>The following functions are available:</p>
+
+<ul>
+ <li>create a new tab ({{WebExtAPIRef("tabs.create")}}).</li>
+ <li>duplicate a tab ({{WebExtAPIRef("tabs.duplicate")}}).</li>
+ <li>remove a tab ({{WebExtAPIRef("tabs.remove")}}).</li>
+ <li>move a tab ({{WebExtAPIRef("tabs.move")}}).</li>
+ <li>update the tab’s URL—effectively browse to a new page—({{WebExtAPIRef("tabs.update")}}).</li>
+ <li>reload the tab’s page ({{WebExtAPIRef("tabs.reload")}}).</li>
+</ul>
+
+<div class="blockIndicator note">
+<p><strong>NOTE: </strong></p>
+
+<p>These functions all require the ID (or IDs) of the tab they are manipulating:</p>
+
+<ul>
+ <li>{{WebExtAPIRef("tabs.duplicate")}}</li>
+ <li>{{WebExtAPIRef("tabs.remove")}}</li>
+ <li>{{WebExtAPIRef("tabs.move")}}</li>
+</ul>
+
+<p>Whereas the following functions will act on the active tab (if no tab ID is provided): </p>
+
+<ul>
+ <li>{{WebExtAPIRef("tabs.update")}}</li>
+ <li>{{WebExtAPIRef("tabs.reload")}}</li>
+</ul>
+</div>
+
+<h3 id="How_to_example_2">How to example</h3>
+
+<p>The <a href="https://github.com/mdn/webextensions-examples/tree/master/tabs-tabs-tabs">tabs-tabs-tabs</a> example exercises all of these features except for updating a tab’s URL The way in which these APIs are used is similar, so we’ll look at one of the more involved implementations, that of the “Move active tab to the beginning of the window list” option.</p>
+
+<p>But first, here is a demonstration of the feature in action:</p>
+
+<p>{{EmbedYouTube("-lJRzTIvhxo")}}</p>
+
+<h4 id="manifest.json_2"><a href="https://github.com/mdn/webextensions-examples/blob/master/tabs-tabs-tabs/manifest.json">manifest.json</a></h4>
+
+<p>None of the functions require a permission to operate, so there are no features in the manifest.json file that need to be highlighted.</p>
+
+<h4 id="tabs.html_2"><a href="https://github.com/mdn/webextensions-examples/blob/master/tabs-tabs-tabs/tabs.html">tabs.html</a></h4>
+
+<p>tabs.html defines the “menu” displayed in the popup, which includes the “Move active tab to the beginning of the window list” option, with a series of <code>&lt;a&gt;</code> tags grouped by a visual separator. Each menu item is given an ID, which is used in tabs.js to determine which menu item is being requested.</p>
+
+<pre class="brush: html">    &lt;a href="#" id="tabs-move-beginning"&gt;Move active tab to the beginning of the window&lt;/a&gt;&lt;br&gt;
+    &lt;a href="#" id="tabs-move-end"&gt;Move active tab to the end of the window&lt;/a&gt;&lt;br&gt;
+
+    &lt;div class="panel-section-separator"&gt;&lt;/div&gt;
+
+
+    &lt;a href="#" id="tabs-duplicate"&gt;Duplicate active tab&lt;/a&gt;&lt;br&gt;
+
+    &lt;a href="#" id="tabs-reload"&gt;Reload active tab&lt;/a&gt;&lt;br&gt;
+    &lt;a href="#" id="tabs-alertinfo"&gt;Alert active tab info&lt;/a&gt;&lt;br&gt;</pre>
+
+<h4 id="tabs.js_2"><a href="https://github.com/mdn/webextensions-examples/blob/master/tabs-tabs-tabs/tabs.js">tabs.js</a></h4>
+
+<p>To implement the “menu” defined in tabs.html, tabs.js includes a listener for clicks in tabs.html:</p>
+
+<pre class="brush: js">document.addEventListener("click", function(e) {
+ function callOnActiveTab(callback) {
+
+   getCurrentWindowTabs().then((tabs) =&gt; {
+     for (var tab of tabs) {
+       if (tab.active) {
+         callback(tab, tabs);
+       }
+     }
+   });
+}
+}
+</pre>
+
+<p>A series of <code>if</code> statements then look to match the ID of the item clicked.</p>
+
+<p>This code snippet is for the “Move active tab to the beginning of the window list” option:</p>
+
+<pre class="brush: js"> if (e.target.id === "tabs-move-beginning") {
+   callOnActiveTab((tab, tabs) =&gt; {
+     var index = 0;
+     if (!tab.pinned) {
+       index = firstUnpinnedTab(tabs);
+     }
+     console.log(`moving ${tab.id} to ${index}`)
+     browser.tabs.move([tab.id], {index});
+   });
+ }
+</pre>
+
+<p>It's worth noting the use of <code>console.log()</code>. This enables you to output information to the <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Debugging">debugger</a> console, which can be useful when resolving issues found during development.</p>
+
+<p><img alt="Example of the console.log output, from the move tabs feature, in the debugging console" src="https://mdn.mozillademos.org/files/15722/console.png" style="height: 329px; width: 911px;"></p>
+
+<p>The move code first calls <code>callOnActiveTab()</code> which in turn calls <code>getCurrentWindowTabs()</code> to get a {{WebExtAPIRef("tabs.Tab")}} object containing the active window’s tabs. It then loops through the object to find and return the active tab object:</p>
+
+<pre class="brush: js"> function callOnActiveTab(callback) {
+   getCurrentWindowTabs().then((tabs) =&gt; {
+     for (var tab of tabs) {
+       if (tab.active) {
+         callback(tab, tabs);
+       }
+     }
+   });
+ }
+</pre>
+
+<h5 id="Pinned_tabs">Pinned tabs</h5>
+
+<p>A feature of tabs is that the user can <dfn>pin</dfn> tabs in a window. Pinned tabs are placed at the start of the tab list and cannot be moved. This means that the earliest position a tab can move to is the first position after any pinned tabs. So, <code>firstUnpinnedTab()</code> is called to find the position of the first unpinned tab by looping through the <code>tabs</code> object:</p>
+
+<pre class="brush: js">function firstUnpinnedTab(tabs) {
+ for (var tab of tabs) {
+   if (!tab.pinned) {
+     return tab.index;
+   }
+ }
+}
+</pre>
+
+<p>We now have everything needed to move the tab: the active tab object from which we can get the tab ID and the position the tab is to be moved to. So, we can implement the move:</p>
+
+<pre class="brush: js">     browser.tabs.move([tab.id], {index});</pre>
+
+<p>The remaining functions to duplicate, reload, create, and remove tabs are implemented similarly.</p>
+
+<h2 id="Manipulating_a_tab’s_zoom_level">Manipulating a tab’s zoom level</h2>
+
+<p>The next set of functions enable you to get ({{WebExtAPIRef("tabs.getZoom")}}) and set ({{WebExtAPIRef("tabs.setZoom")}}) the zoom level within a tab. You can also retrieve the zoom settings ({{WebExtAPIRef("tabs.getZoomSettings")}}) but, at the time of writing, the ability to set the settings ({{WebExtAPIRef("tabs.setZoomSettings")}}) wasn’t available in Firefox.</p>
+
+<p>The level of zoom can be between 30% and 300% (represented as decimals <code>0.3</code> to <code>3</code>).</p>
+
+<p>In Firefox the default zoom settings are:</p>
+
+<ul>
+ <li><strong>default zoom level: </strong>100%.</li>
+ <li><strong>zoom mode:</strong> automatic (so the browser manages how zoom levels are set).</li>
+ <li><strong>scope of zoom changes:</strong> <code>"per-origin"</code>, meaning that when you visit a site again, it takes the zoom level set in your last visit.</li>
+</ul>
+
+<h3 id="How_to_example_3">How to example</h3>
+
+<p>The <a href="https://github.com/mdn/webextensions-examples/tree/master/tabs-tabs-tabs">tabs-tabs-tabs</a> example includes three demonstrations of the zoom feature: zoom in, zoom out, and reset zoom. Here is the feature in action:</p>
+
+<p>{{EmbedYouTube("RFr3oYBCg28")}}</p>
+
+<p>Let’s take a look at how the zoom in is implemented.</p>
+
+<h4 id="manifest.json_3"><a href="https://github.com/mdn/webextensions-examples/blob/master/tabs-tabs-tabs/manifest.json">manifest.json</a></h4>
+
+<p>None of the zoom functions require permissions, so there are no features in the manifest.json file that need to be highlighted.</p>
+
+<h4 id="tabs.html_3"><a href="https://github.com/mdn/webextensions-examples/blob/master/tabs-tabs-tabs/tabs.html">tabs.html</a></h4>
+
+<p>We have already discussed how the tabs.html defines the options for this extension, nothing new or unique is done to provide the zoom options.</p>
+
+<h4 id="tabs.js_3"><a href="https://github.com/mdn/webextensions-examples/blob/master/tabs-tabs-tabs/tabs.js">tabs.js</a></h4>
+
+<p>tabs.js starts by defining several constants used in the zoom code:</p>
+
+<pre class="brush: js">const ZOOM_INCREMENT = 0.2;
+const MAX_ZOOM = 3;
+const MIN_ZOOM = 0.3;
+const DEFAULT_ZOOM = 1;
+</pre>
+
+<p>It then uses the same listener we discussed earlier so it can act on clicks in tabs.html.</p>
+
+<p>For the zoom in feature, this runs:</p>
+
+<pre class="brush: js"> else if (e.target.id === "tabs-add-zoom") {
+   callOnActiveTab((tab) =&gt; {
+     var gettingZoom = browser.tabs.getZoom(tab.id);
+     gettingZoom.then((zoomFactor) =&gt; {
+       //the maximum zoomFactor is 3, it can't go higher
+       if (zoomFactor &gt;= MAX_ZOOM) {
+         alert("Tab zoom factor is already at max!");
+       } else {
+         var newZoomFactor = zoomFactor + ZOOM_INCREMENT;
+         //if the newZoomFactor is set to higher than the max accepted
+         //it won't change, and will never alert that it's at maximum
+         newZoomFactor = newZoomFactor &gt; MAX_ZOOM ? MAX_ZOOM : newZoomFactor;
+         browser.tabs.setZoom(tab.id, newZoomFactor);
+       }
+     });
+   });
+ }
+</pre>
+
+<p>This code uses <code>callOnActiveTab()</code> to get the details of the active tab, then {{WebExtAPIRef("tabs.getZoom")}} gets the tab’s current zoom factor. The current zoom is compared to the defined maximum (<code>MAX_ZOOM</code>) and an alert issued if the tab is already at the maximum zoom. Otherwise, the zoom level is incremented but limited to the maximum zoom, then the zoom is set with {{WebExtAPIRef("tabs.getZoom")}}.</p>
+
+<h2 id="Manipulating_a_tab’s_CSS">Manipulating a tab’s CSS</h2>
+
+<p>Another significant capability offered by the Tabs API is the ability to manipulate the CSS within a tab—add new CSS to a tab ({{WebExtAPIRef("tabs.insertCSS")}}) or remove CSS from a tab ({{WebExtAPIRef("tabs.removeCSS")}}).</p>
+
+<p>This can be useful, for example, if you want to highlight certain page elements or change the default layout of the page.</p>
+
+<h3 id="How_to_example_4">How to example</h3>
+
+<p>The <a href="https://github.com/mdn/webextensions-examples/tree/master/apply-css">apply-css</a> example uses these features to add a red border to the web page in the active tab. Here is the feature in action:</p>
+
+<p>{{EmbedYouTube("bcK-GT2Dyhs")}}</p>
+
+<p>Let’s walk through how it’s set up.</p>
+
+<h4 id="manifest.json_4"><a href="https://github.com/mdn/webextensions-examples/blob/master/apply-css/manifest.json">manifest.json</a></h4>
+
+<p>To use the CSS features you need either:</p>
+
+<ul>
+ <li><code>"tabs"</code> permission and <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#Host_permissions">host permission</a> or</li>
+ <li><code>"activeTab"</code> permission.</li>
+</ul>
+
+<p>The latter is the most useful, as it allows an extension to use {{WebExtAPIRef("tabs.insertCSS")}} and {{WebExtAPIRef("tabs.removeCSS")}} in the active tab when run from the extension’s browser or page action, context menu, or a shortcut.</p>
+
+<pre class="brush: json">{
+  "description": "Adds a page action to toggle applying CSS to pages.",
+
+ "manifest_version": 2,
+ "name": "apply-css",
+ "version": "1.0",
+ "homepage_url": "https://github.com/mdn/webextensions-examples/tree/master/apply-css",
+
+ "background": {
+
+    "scripts": ["background.js"]
+ },
+
+ "page_action": {
+
+    "default_icon": "icons/off.svg",
+    "browser_style": true
+ },
+
+ "permissions": [
+    "activeTab",
+    "tabs"
+ ]
+
+}
+</pre>
+
+<p>You will note that <code>"tabs"</code> permission is requested in addition to <code>"activeTab"</code>. This additional permission is needed to enable the extension’s script to access the tab’s URL, the importance of which we’ll see in a moment.</p>
+
+<p>The other main features in the manifest.json file are the definition of:</p>
+
+<ul>
+ <li><strong>a background script</strong>, which starts running as soon as the extension is loaded.</li>
+ <li><strong>a “page action”</strong>, which defines an icon to be added to the browser’s address bar.</li>
+</ul>
+
+<h4 id="background.js"><a href="https://github.com/mdn/webextensions-examples/blob/master/apply-css/background.js">background.js</a></h4>
+
+<p>On startup, background.js sets some constants to define the CSS to be applied, titles for the “page action”, and a list of protocols the extension will work in:</p>
+
+<pre class="brush: js">const CSS = "body { border: 20px solid red; }";
+const TITLE_APPLY = "Apply CSS";
+const TITLE_REMOVE = "Remove CSS";
+const APPLICABLE_PROTOCOLS = ["http:", "https:"];
+</pre>
+
+<p>When first loaded, the extension uses {{WebExtAPIRef("tabs.query")}} to get a list of all the tabs in the current browser window. It then loops through the tabs calling <code>initializePageAction()</code>.</p>
+
+<pre class="brush: js">var gettingAllTabs = browser.tabs.query({});
+
+gettingAllTabs.then((tabs) =&gt; {
+ for (let tab of tabs) {
+   initializePageAction(tab);
+ }
+});
+</pre>
+
+<p><code>initializePageAction</code> uses <code>protocolIsApplicable()</code> to determine whether the active tab’s URL is one the CSS can be applied to:</p>
+
+<pre class="brush: js">function protocolIsApplicable(url) {
+ var anchor =  document.createElement('a');
+ anchor.href = url;
+ return APPLICABLE_PROTOCOLS.includes(anchor.protocol);
+}
+</pre>
+
+<p>Then, if the example can act on the tab, <code>initializePageAction()</code> sets the tab’s <code>pageAction</code> (navigation bar) icon and title to use the “off” versions before making the <code>pageAction</code> visible:</p>
+
+<pre class="brush: js">function initializePageAction(tab) {
+
+ if (protocolIsApplicable(tab.url)) {
+   browser.pageAction.setIcon({tabId: tab.id, path: "icons/off.svg"});
+   browser.pageAction.setTitle({tabId: tab.id, title: TITLE_APPLY});
+   browser.pageAction.show(tab.id);
+ }
+}
+</pre>
+
+<p>Next, a listener on <code>pageAction.onClicked</code> waits for the <code>pageAction</code> icon to be clicked, and calls <code>toggleCSS</code> when it is.</p>
+
+<pre class="brush: js">browser.pageAction.onClicked.addListener(toggleCSS);</pre>
+
+<p><code>toggleCSS()</code> gets the title of the <code>pageAction</code> and then takes the action described:</p>
+
+<ul>
+ <li><strong>For "Apply CSS”:</strong>
+
+ <ul>
+ <li>toggles the <code>pageAction</code> icon and title to the “remove” versions.</li>
+ <li>applies the CSS using {{WebExtAPIRef("tabs.insertCSS")}}.</li>
+ </ul>
+ </li>
+ <li><strong>For “Remove CSS”:</strong>
+ <ul>
+ <li>toggles the <code>pageAction</code> icon and title to the “apply” versions.</li>
+ <li>removes the CSS using {{WebExtAPIRef("tabs.removeCSS")}}.</li>
+ </ul>
+ </li>
+</ul>
+
+<pre class="brush: js">function toggleCSS(tab) {
+
+
+ function gotTitle(title) {
+
+    if (title === TITLE_APPLY) {
+     browser.pageAction.setIcon({tabId: tab.id, path: "icons/on.svg"});
+     browser.pageAction.setTitle({tabId: tab.id, title: TITLE_REMOVE});
+     browser.tabs.insertCSS({code: CSS});
+    } else {
+     browser.pageAction.setIcon({tabId: tab.id, path: "icons/off.svg"});
+     browser.pageAction.setTitle({tabId: tab.id, title: TITLE_APPLY});
+     browser.tabs.removeCSS({code: CSS});
+    }
+ }
+
+ var gettingTitle = browser.pageAction.getTitle({tabId: tab.id});
+
+ gettingTitle.then(gotTitle);
+}
+</pre>
+
+<p>Finally, to ensure that the <code>pageAction</code> is valid after each update to the tab, a listener on {{WebExtAPIRef("tabs.onUpdated")}} calls <code>initializePageAction()</code> each time the tab is updated to check that the tab is still using a protocol to which the CSS can be applied.</p>
+
+<pre class="brush: js">browser.tabs.onUpdated.addListener((id, changeInfo, tab) =&gt; {
+ initializePageAction(tab);
+});
+</pre>
+
+<h2 id="Some_other_interesting_abilities">Some other interesting abilities</h2>
+
+<p>There are a couple of other Tabs API features that don’t fit into one of the earlier sections:</p>
+
+<ul>
+ <li>Capture the visible tab content with {{WebExtAPIRef("tabs.captureVisibleTab")}}.</li>
+ <li>Detect the primary language of the content in a tab using {{WebExtAPIRef("tabs.detectLanguage")}}. This could be used, for example, to match the language in your extension’s UI with that of the page it’s running in.</li>
+</ul>
+
+<h2 id="Learn_more">Learn more</h2>
+
+<p>If you want to learn more about the Tabs API, check out:</p>
+
+<ul>
+ <li><a href="/en-US/Add-ons/WebExtensions/API/tabs">Tabs API reference</a></li>
+ <li><a href="/en-US/Add-ons/WebExtensions/Examples">Example extensions</a> (many of which use the Tabs API)</li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/your_first_webextension/index.html b/files/zh-cn/mozilla/add-ons/webextensions/your_first_webextension/index.html
new file mode 100644
index 0000000000..b08f114ba1
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/your_first_webextension/index.html
@@ -0,0 +1,238 @@
+---
+title: 你的第一个拓展
+slug: Mozilla/Add-ons/WebExtensions/Your_first_WebExtension
+tags:
+ - WebExtentions
+ - 指南
+translation_of: Mozilla/Add-ons/WebExtensions/Your_first_WebExtension
+---
+<div>{{AddonSidebar}}</div>
+
+<p>在这篇文章中,我们将为 Firefox 创建一个扩展。这个扩展只是给从 "firefox.org" 或其任意子域名加载的任何页面添加一个红色边框。</p>
+
+<p>该示例的源代码位于 GitHub:<a href="https://github.com/mdn/webextensions-examples/tree/master/borderify">https://github.com/mdn/webextensions-examples/tree/master/borderify</a></p>
+
+<p>首先,你需要 Firefox 45 或更高版本。</p>
+
+<h2 id="编写扩展">编写扩展</h2>
+
+<p>创建一个新的目录并切换到该目录。例如,在你的命令行/终端,你可以这么做:</p>
+
+<pre class="brush: bash">mkdir borderify
+cd borderify</pre>
+
+<h3 id="manifest.json">manifest.json</h3>
+
+<p>现在,在 "borderify" 目录内直接创建文件 "manifest.json"。文件内容如下:</p>
+
+<pre class="brush: json line-numbers language-json"><code class="language-json"><span class="punctuation token">{</span>
+
+ <span class="key token">"manifest_version":</span> <span class="number token">2</span><span class="punctuation token">,</span>
+ <span class="key token">"name":</span> <span class="string token">"Borderify"</span><span class="punctuation token">,</span>
+ <span class="key token">"version":</span> <span class="string token">"1.0"</span><span class="punctuation token">,</span>
+
+ <span class="key token">"description":</span> <span class="string token">"Adds a red border to all webpages matching mozilla.org."</span><span class="punctuation token">,</span>
+
+ <span class="key token">"icons":</span> <span class="punctuation token">{</span>
+ <span class="key token">"48":</span> <span class="string token">"icons/border-48.png"</span>
+ <span class="punctuation token">}</span><span class="punctuation token">,</span>
+
+ <span class="key token">"content_scripts":</span> <span class="punctuation token">[</span>
+ <span class="punctuation token">{</span>
+ <span class="key token">"matches":</span> <span class="punctuation token">[</span><span class="string token">"*://*.mozilla.org/*"</span><span class="punctuation token">]</span><span class="punctuation token">,</span>
+ <span class="key token">"js":</span> <span class="punctuation token">[</span><span class="string token">"borderify.js"</span><span class="punctuation token">]</span>
+ <span class="punctuation token">}</span>
+ <span class="punctuation token">]</span>
+
+<span class="punctuation token">}</span></code></pre>
+
+<ul>
+ <li>前三个键:<code><a href="/zh-CN/Add-ons/WebExtensions/manifest.json/manifest_version">manifest_version</a></code>、<code><a href="/zh-CN/Add-ons/WebExtensions/manifest.json/name">name</a></code> 和 <code><a href="/zh-CN/Add-ons/WebExtensions/manifest.json/version">version</a></code> 是强制的,包含有扩展的基本元数据.</li>
+ <li><code><a href="/zh-CN/Add-ons/WebExtensions/manifest.json/description">description</a></code> 是可选的,但建议使用「该描述将显示在附加组件管理器上」.</li>
+ <li><code><a href="/zh-CN/Add-ons/WebExtensions/manifest.json/icons">icons</a></code> 是可选的,但建议使用「它允许你给扩展指定一个图标,将显示在附加组件管理器上」.</li>
+</ul>
+
+<p>这里最有意思的键是 <code><a href="/zh-CN/Add-ons/WebExtensions/manifest.json/content_scripts">content_scripts</a></code>,它告诉 Firefox 加载脚本到其 URL 匹配特定模式的网页。本例中,我们要求 Firefox 加载脚本 "borderify.js" 到任何来自 "mozilla.org" 或其子域的 HTTP 或 HTTPS 页面。</p>
+
+<ul>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Content_scripts">进一步了解内容脚本 content script</a></li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Match_patterns">进一步了解模式匹配 pattern matching</a></li>
+</ul>
+
+<div class="warning">
+<p><a href="/zh-CN/Add-ons/WebExtensions/WebExtensions_and_the_Add-on_ID#When_do_you_need_an_Add-on_ID">某些情况下,你需要给你的扩展指定一个 ID</a>。如果你需要指定一个附加组件 ID,请在 <code>manifest.json</code> 中添加 <code><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings">browser_specific_settings</a></code> 键,并设置其 <code>gecko.id</code> 属性:</p>
+
+<pre class="brush: json">"browser_specific_settings": {
+ "gecko": {
+ "id": "borderify@example.com"
+ }
+}</pre>
+</div>
+
+<h3 id="iconsborder-48.png">icons/border-48.png</h3>
+
+<p>扩展应该有一个图标。这将显示在附加组件管理器加载项的列表中。我们的 manifest.json 保证了会有一个图标 "icons/border-48.png"。</p>
+
+<p>在 "borderify" 目录下直接创建 "icons" 目录,并在 "icons" 目录下保存一个名为 "border-48.png"的图标. 你可以使用<a href="https://github.com/mdn/webextensions-examples/blob/master/borderify/icons/border-48.png">我们的示例</a>中的,来自谷歌材料设计中的图标,遵循 <a href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike</a> 协议。</p>
+
+<p>如果您选择使用自己的图标,它也应该是 48×48 像素。你也可以为高分辨率显示器提供一个 96x96 的像素图标,在 manifest.json 的 <code>icons</code> 对象中添加 <code>96</code> 属性即可:</p>
+
+<pre class="brush: json line-numbers language-json"><code class="language-json"><span class="key token">"icons":</span> <span class="punctuation token">{</span>
+ <span class="key token">"48":</span> <span class="string token">"icons/border-48.png",
+ "96": "icons/border-96.png"</span>
+<span class="punctuation token">}</span></code></pre>
+
+<p>或者,也可以在这里提供一个 SVG 文件,它会被正确地缩放。(不过:如果你正在使用 SVG 并且你的图标包含文字,有可能想要用你的 SVG 编辑器的“转换为路径”工具来拼和文字,这样图标会以一个恒定的大小/位置来缩放。)</p>
+
+<ul>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/manifest.json/icons">了解更多关于指定图标的内容</a></li>
+</ul>
+
+<h3 id="borderify.js">borderify.js</h3>
+
+<p>最后,在 "borderify" 目录下直接创建 "borderify.js" 文件,并写入下面的内容:</p>
+
+<pre class="brush: js">document.body.style.border = "5px solid red";</pre>
+
+<p>manifest.json 文件中 <code>content_scripts</code> 的键给出了一条模式匹配,该脚本便会被加载到匹配的页面中。该脚本会像页面加载自己的脚本一样被加载,可以直接访问该文档。</p>
+
+<ul>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Content_scripts">了解更多关于内容脚本的内容。</a></li>
+</ul>
+
+<h2 id="测试一下">测试一下</h2>
+
+<p>首先,仔细检查文件是否在正确的位置:</p>
+
+<pre>borderify/
+ icons/
+ border-48.png
+ borderify.js
+ manifest.json</pre>
+
+<h3 id="安装">安装</h3>
+
+<p>打开 Firefox 的 <a href="/zh-CN/docs/Tools/about:debugging">about:debugging</a> 页面,点击”This Firefox" (在新版本的Firefox里),点击 "临时加载附加组件(Load Temporary Add-on)" 按钮,并选择你的附加组件目录:</p>
+
+<p>{{EmbedYouTube("cer9EUKegG4")}}</p>
+
+<p>附加组件将会被安装,直到下次重启浏览器失效。</p>
+
+<p>或者,你可以通过 <a href="https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Getting_started_with_web-ext">web-ext</a> 工具从命令行来运行扩展。</p>
+
+<h3 id="测试">测试</h3>
+
+<p>现在尝试访问"mozilla.org", 你将会在页面上看到有个红色的边框</p>
+
+<p>{{EmbedYouTube("rxBQl2Z9IBQ")}}</p>
+
+<div class="note">
+<p>不要在 addons.mozilla.org 上尝试!内容脚本(Content Script) 当前在那个域名下是被限制的。</p>
+</div>
+
+<p>尝试一下编辑内容脚本更改边框的颜色,或做页面内容别的修改,保存内容脚本,然后通过单击 <strong>about:debugging</strong> 页面下的 “刷新” 按钮重新加载附加的文件。你可以马上看到的变化:</p>
+
+<p>{{EmbedYouTube("NuajE60jfGY")}}</p>
+
+<ul>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Temporary_Installation_in_Firefox">学习更多关于加载附加组件</a></li>
+</ul>
+
+<h2 id="打包和发布">打包和发布</h2>
+
+<p>为了给其他人使用你的插件,您需要打包,并将其提交给 Mozilla 进行签名。要了解更多有关,请参考 <a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Publishing_your_WebExtension">"发布你的扩展"</a>。</p>
+
+<h2 id="下一步">下一步</h2>
+
+<p>现在,你已经在开发 Firefox 的一个 Web 扩展的过程中得到了一些想法,尝试:</p>
+
+<ul>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Your_second_WebExtension">写一个更加复杂的WebExtension</a></li>
+ <li><a href="/zh-CN/Add-ons/WebExtensions/Anatomy_of_a_WebExtension">阅读更多关于WebExtensions的剖析</a></li>
+ <li><a href="https://wiki.developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Examples">探索更多关于扩展的示例</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/What_next_">发现开发,测试,和发布扩展需要的东西</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/What_next_#Continue_your_learning_experience">进一步的学习</a></li>
+</ul>
+
+<div id="SL_balloon_obj" style="display: block;">
+<div class="SL_ImTranslatorLogo" id="SL_button" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%; display: none; opacity: 1; left: 556px; top: 6804px;"></div>
+
+<div id="SL_shadow_translation_result2" style="display: none;"></div>
+
+<div id="SL_shadow_translator" style="display: none;">
+<div id="SL_planshet">
+<div id="SL_arrow_up" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;"></div>
+
+<div id="SL_Bproviders">
+<div class="SL_BL_LABLE_ON" id="SL_P0" title="Google">G</div>
+
+<div class="SL_BL_LABLE_ON" id="SL_P1" title="Microsoft">M</div>
+
+<div class="SL_BL_LABLE_ON" id="SL_P2" title="Translator">T</div>
+</div>
+
+<div id="SL_alert_bbl" style="display: none;">
+<div id="SLHKclose" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;"></div>
+
+<div id="SL_alert_cont"></div>
+</div>
+
+<div id="SL_TB">
+<table id="SL_tables">
+ <tbody>
+ <tr>
+ <td class="SL_td"><input></td>
+ <td class="SL_td"><select><option value="auto">检测语言</option><option value="eo">世界语</option><option value="zh-CN">中文简体</option><option value="zh-TW">中文繁体</option><option value="da">丹麦语</option><option value="uk">乌克兰语</option><option value="uz">乌兹别克语</option><option value="ur">乌尔都语</option><option value="hy">亚美尼亚语</option><option value="ig">伊博语</option><option value="ru">俄语</option><option value="bg">保加利亚语</option><option value="si">僧伽罗语</option><option value="hr">克罗地亚语</option><option value="is">冰岛语</option><option value="gl">加利西亚语</option><option value="ca">加泰罗尼亚语</option><option value="hu">匈牙利语</option><option value="zu">南非祖鲁语</option><option value="kn">卡纳达语</option><option value="hi">印地语</option><option value="su">印尼巽他语</option><option value="jw">印尼爪哇语</option><option value="id">印尼语</option><option value="gu">古吉拉特语</option><option value="kk">哈萨克语</option><option value="tr">土耳其语</option><option value="tg">塔吉克语</option><option value="sr">塞尔维亚语</option><option value="st">塞索托语</option><option value="cy">威尔士语</option><option value="bn">孟加拉语</option><option value="ceb">宿务语</option><option value="ne">尼泊尔语</option><option value="eu">巴斯克语</option><option value="af">布尔语(南非荷兰语)</option><option value="iw">希伯来语</option><option value="el">希腊语</option><option value="de">德语</option><option value="it">意大利语</option><option value="yi">意第绪语</option><option value="la">拉丁语</option><option value="lv">拉脱维亚语</option><option value="no">挪威语</option><option value="cs">捷克语</option><option value="sk">斯洛伐克语</option><option value="sl">斯洛文尼亚语</option><option value="sw">斯瓦希里语</option><option value="pa">旁遮普语</option><option value="ja">日语</option><option value="ka">格鲁吉亚语</option><option value="mi">毛利语</option><option value="fr">法语</option><option value="pl">波兰语</option><option value="bs">波斯尼亚语</option><option value="fa">波斯语</option><option value="te">泰卢固语</option><option value="ta">泰米尔语</option><option value="th">泰语</option><option value="ht">海地克里奥尔语</option><option value="ga">爱尔兰语</option><option value="et">爱沙尼亚语</option><option value="sv">瑞典语</option><option value="be">白俄罗斯语</option><option value="lt">立陶宛语</option><option value="so">索马里语</option><option value="yo">约鲁巴语</option><option value="my">缅甸语</option><option value="ro">罗马尼亚语</option><option value="lo">老挝语</option><option value="fi">芬兰语</option><option value="hmn">苗语</option><option value="en">英语</option><option value="nl">荷兰语</option><option value="tl">菲律宾语</option><option value="pt">葡萄牙语</option><option value="mn">蒙古语</option><option value="es">西班牙语</option><option value="ha">豪萨语</option><option value="vi">越南语</option><option value="az">阿塞拜疆语</option><option value="sq">阿尔巴尼亚语</option><option value="ar">阿拉伯语</option><option value="ko">韩语</option><option value="mk">马其顿语</option><option value="mg">马尔加什语</option><option value="mr">马拉地语</option><option value="ml">马拉雅拉姆语</option><option value="ms">马来语</option><option value="mt">马耳他语</option><option value="km">高棉语</option><option value="ny">齐切瓦语</option></select></td>
+ <td class="SL_td">
+ <div id="SL_switch_b" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="切换语言"></div>
+ </td>
+ <td class="SL_td"><select><option value="eo">世界语</option><option selected value="zh-CN">中文简体</option><option value="zh-TW">中文繁体</option><option value="da">丹麦语</option><option value="uk">乌克兰语</option><option value="uz">乌兹别克语</option><option value="ur">乌尔都语</option><option value="hy">亚美尼亚语</option><option value="ig">伊博语</option><option value="ru">俄语</option><option value="bg">保加利亚语</option><option value="si">僧伽罗语</option><option value="hr">克罗地亚语</option><option value="is">冰岛语</option><option value="gl">加利西亚语</option><option value="ca">加泰罗尼亚语</option><option value="hu">匈牙利语</option><option value="zu">南非祖鲁语</option><option value="kn">卡纳达语</option><option value="hi">印地语</option><option value="su">印尼巽他语</option><option value="jw">印尼爪哇语</option><option value="id">印尼语</option><option value="gu">古吉拉特语</option><option value="kk">哈萨克语</option><option value="tr">土耳其语</option><option value="tg">塔吉克语</option><option value="sr">塞尔维亚语</option><option value="st">塞索托语</option><option value="cy">威尔士语</option><option value="bn">孟加拉语</option><option value="ceb">宿务语</option><option value="ne">尼泊尔语</option><option value="eu">巴斯克语</option><option value="af">布尔语(南非荷兰语)</option><option value="iw">希伯来语</option><option value="el">希腊语</option><option value="de">德语</option><option value="it">意大利语</option><option value="yi">意第绪语</option><option value="la">拉丁语</option><option value="lv">拉脱维亚语</option><option value="no">挪威语</option><option value="cs">捷克语</option><option value="sk">斯洛伐克语</option><option value="sl">斯洛文尼亚语</option><option value="sw">斯瓦希里语</option><option value="pa">旁遮普语</option><option value="ja">日语</option><option value="ka">格鲁吉亚语</option><option value="mi">毛利语</option><option value="fr">法语</option><option value="pl">波兰语</option><option value="bs">波斯尼亚语</option><option value="fa">波斯语</option><option value="te">泰卢固语</option><option value="ta">泰米尔语</option><option value="th">泰语</option><option value="ht">海地克里奥尔语</option><option value="ga">爱尔兰语</option><option value="et">爱沙尼亚语</option><option value="sv">瑞典语</option><option value="be">白俄罗斯语</option><option value="lt">立陶宛语</option><option value="so">索马里语</option><option value="yo">约鲁巴语</option><option value="my">缅甸语</option><option value="ro">罗马尼亚语</option><option value="lo">老挝语</option><option value="fi">芬兰语</option><option value="hmn">苗语</option><option value="en">英语</option><option value="nl">荷兰语</option><option value="tl">菲律宾语</option><option value="pt">葡萄牙语</option><option value="mn">蒙古语</option><option value="es">西班牙语</option><option value="ha">豪萨语</option><option value="vi">越南语</option><option value="az">阿塞拜疆语</option><option value="sq">阿尔巴尼亚语</option><option value="ar">阿拉伯语</option><option value="ko">韩语</option><option value="mk">马其顿语</option><option value="mg">马尔加什语</option><option value="mr">马拉地语</option><option value="ml">马拉雅拉姆语</option><option value="ms">马来语</option><option value="mt">马耳他语</option><option value="km">高棉语</option><option value="ny">齐切瓦语</option></select></td>
+ <td class="SL_td">
+ <div id="SL_TTS_voice" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="聆听翻译"></div>
+ </td>
+ <td class="SL_td">
+ <div class="SL_copy" id="SL_copy" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="复制译文"></div>
+ </td>
+ <td class="SL_td">
+ <div id="SL_bbl_font_patch"></div>
+
+ <div class="SL_bbl_font" id="SL_bbl_font" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="字体大小"></div>
+ </td>
+ <td class="SL_td">
+ <div id="SL_bbl_help" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="帮助"></div>
+ </td>
+ <td class="SL_td">
+ <div class="SL_pin_off" id="SL_pin" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="固定弹出窗口"></div>
+ </td>
+ </tr>
+ </tbody>
+</table>
+</div>
+</div>
+
+<div id="SL_shadow_translation_result"></div>
+
+<div class="SL_loading" id="SL_loading" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;"></div>
+
+<div id="SL_player2"></div>
+
+<div id="SL_alert100">文本转语音功能仅限200个字符</div>
+
+<div id="SL_Balloon_options" style="background: rgb(255, 255, 255) repeat scroll 0% 0%;">
+<div id="SL_arrow_down" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;"></div>
+
+<table id="SL_tbl_opt" style="width: 100%;">
+ <tbody>
+ <tr>
+ <td><input></td>
+ <td>
+ <div id="SL_BBL_IMG" style="background: rgba(0, 0, 0, 0) repeat scroll 0% 0%;" title="显示翻译器的按钮 3 秒"></div>
+ </td>
+ <td><a class="SL_options" title="显示选项">选项</a> : <a class="SL_options" title="翻译历史记录">历史</a> : <a class="SL_options" title="反馈">反馈</a> : <a class="SL_options" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=GD9D8CPW8HFA2" title="作出一点点贡献">Donate</a></td>
+ <td><span id="SL_Balloon_Close" title="关闭">关闭</span></td>
+ </tr>
+ </tbody>
+</table>
+</div>
+</div>
+</div>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/实现一个设置页面/index.html b/files/zh-cn/mozilla/add-ons/webextensions/实现一个设置页面/index.html
new file mode 100644
index 0000000000..fe8ac2e0a7
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/实现一个设置页面/index.html
@@ -0,0 +1,203 @@
+---
+title: 实现一个设置页面
+slug: Mozilla/Add-ons/WebExtensions/实现一个设置页面
+translation_of: Mozilla/Add-ons/WebExtensions/Implement_a_settings_page
+---
+<div>{{AddonSidebar}}</div>
+
+<p>设置页面可以让用户查看,修改扩展的一些设置。</p>
+
+<p>对于WebExtensions,设置通常使用 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage">storage</a></code> API 保存. 实现一个设置页面通常包含以下三步:</p>
+
+<ul>
+ <li>制作一个HTML 文件用以显示并修改设置</li>
+ <li>写一个包含于该HTML文件的脚本,其可以使设置页面存储与存储设备中并在用户修改后更新他。</li>
+ <li>在manifest.json文件 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/options_ui">options_ui</a></code> 关键字中 设置HTML文件的路径。通过这种方式,该HTML将会被显示浏览器管理器里该插件名字和描述的旁边。</li>
+</ul>
+
+<div class="note">
+<p>你也可以使用 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/openOptionsPage">runtime.openOptionsPage()</a></code> 打开该页面。</p>
+</div>
+
+<h2 id="简单的_WebExtension">简单的 WebExtension</h2>
+
+<p>首先,我们写一个向用户访问的所有页面添加一个蓝色边框的扩展。</p>
+
+<p>创建一个新的文件夹命名为“setting”,然后创建文件“manifest.json”它包含以下内容:</p>
+
+<pre class="brush: json">{
+
+ "manifest_version": 2,
+ "name": "Settings example",
+ "version": "1.0",
+
+ "content_scripts": [
+ {
+ "matches": ["&lt;all_urls&gt;"],
+ "js": ["borderify.js"]
+ }
+ ]
+
+}</pre>
+
+<p>该扩展指示浏览器在用户访问的网站上加载一个名为"borderify.js“的Content Script。</p>
+
+<p>接下来,在"setting"目录下创建"borderify.js",然后给予他以下内容:</p>
+
+<pre class="brush: js">document.body.style.border = "10px solid blue";</pre>
+
+<p>这只是向网页加入了一一个蓝色边框</p>
+
+<p>现在 <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Temporary_Installation_in_Firefox">安装该扩展</a> 并测试它——打开任意一个网页:</p>
+
+<p>{{EmbedYouTube("E-WUhihF8fw")}}</p>
+
+<h2 id="添加设置页面">添加设置页面</h2>
+
+<p>现在让我们创建一个设置页面来允许用户设置边框的颜色。</p>
+
+<p>首先更新 "manifest.json" 使他拥有如下内容:</p>
+
+<pre class="brush: json">{
+
+ "manifest_version": 2,
+ "name": "Settings example",
+ "version": "1.0",
+
+ "content_scripts": [
+ {
+ "matches": ["&lt;all_urls&gt;"],
+ "js": ["borderify.js"]
+ }
+ ],
+
+ "options_ui": {
+ "page": "options.html"
+ },
+
+ "permissions": ["storage"]
+
+}
+</pre>
+
+<p>我们加入了两个manifest 关键字:</p>
+
+<ul>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/options_ui">options_ui</a></code>: 设置了一个HTML来作为设置页面。</li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permissions</a></code>: 我们使用 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage">storage</a></code> API 来保存设置, 所以我们需要请求权限来使用该API。</li>
+</ul>
+
+<p>接下来,因为我们承诺提供"options.html",让我们来创建他,在"setting"目录创建一个该文件并具有以下内容:</p>
+
+<pre class="brush: html">&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+ &lt;head&gt;
+ &lt;meta charset="utf-8"&gt;
+ &lt;/head&gt;
+
+ &lt;body&gt;
+
+ &lt;form&gt;
+ &lt;label&gt;Border color&lt;input type="text" id="color" &gt;&lt;/label&gt;
+ &lt;button type="submit"&gt;Save&lt;/button&gt;
+ &lt;/form&gt;
+
+ &lt;script src="options.js"&gt;&lt;/script&gt;
+
+ &lt;/body&gt;
+
+&lt;/html&gt;
+</pre>
+
+<p>这里定义了一个带有标记文字{{htmlelement("input")}}的 {{htmlelement("form")}} 和一个 提交 {{htmlelement("button")}}. 也包含了一个名为"options.js"的脚本。</p>
+
+<p>仍然在"settting"目录下创建 "options.js",并给予他以下内容:</p>
+
+<pre class="brush: js">function saveOptions(e) {
+ e.preventDefault();
+ browser.storage.local.set({
+ color: document.querySelector("#color").value
+ });
+}
+
+function restoreOptions() {
+
+ function setCurrentChoice(result) {
+ document.querySelector("#color").value = result.color || "blue";
+ }
+
+ function onError(error) {
+ console.log(`Error: ${error}`);
+ }
+
+ var getting = browser.storage.local.get("color");
+ getting.then(setCurrentChoice, onError);
+}
+
+document.addEventListener("DOMContentLoaded", restoreOptions);
+document.querySelector("form").addEventListener("submit", saveOptions);
+</pre>
+
+<p>它做了两件事:</p>
+
+<ul>
+ <li>当网页被加载它使用<code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/get">storage.local.get()</a></code> 从存贮设备中获取了名为"color”的值.如果该值未被设置其为默认值blue。</li>
+ <li>当用户点击提交按钮,使用<code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/set">storage.local.set()</a></code> 存贮颜色值。</li>
+</ul>
+
+<p>最后,更新"borderify.js" 来读取边框颜色:</p>
+
+<div class="warning">
+<p>因为 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/get">browser.storage.local.get()</a> 在火狐52版本之前的一个漏洞 ,以下代码没法起作用。为了使它生效,<code>onGot()中的 item.color 必须改为 item[0].color。</code></p>
+</div>
+
+<pre class="brush: js"> function onError(error) {
+ console.log(`Error: ${error}`);
+}
+
+function onGot(item) {
+ var color = "blue";
+ if (item.color) {
+ color = item.color;
+ }
+ document.body.style.border = "10px solid " + color;
+}
+
+var getting = browser.storage.local.get("color");
+getting.then(onGot, onError);
+</pre>
+
+<p>最后,完整的扩展看起来是这样:</p>
+
+<pre>settings/
+ borderify.js
+ manifest.json
+ options.html
+ options.js</pre>
+
+<p>现在:</p>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Temporary_Installation_in_Firefox#Reloading_a_temporary_add-on">重新载入扩展</a></li>
+ <li>加载一个网页</li>
+ <li>打开设置页面并修改边框颜色</li>
+ <li>重载网页查看变化。</li>
+</ul>
+
+<p>在火狐中你可以通过访问"about:addons"点击扩展旁边的"Preferences"按钮访问设置页面。</p>
+
+<p>{{EmbedYouTube("ECt9cbWh1qs")}}</p>
+
+<h2 id="进一步了解">进一步了解</h2>
+
+<ul>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/options_ui">options_ui</a></code> 关键字文档</li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage">storage</a></code> API 文档</li>
+ <li>使用<code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/openOptionsPage">runtime.openOptionsPage()</a></code> 直接打开你的设置页面</li>
+ <li>另一个设置页面例子:
+ <ul>
+ <li><a href="https://github.com/mdn/webextensions-examples/tree/master/favourite-colour">favourite-colour</a></li>
+ </ul>
+ </li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/构建一个跨浏览器的扩展插件/index.html b/files/zh-cn/mozilla/add-ons/webextensions/构建一个跨浏览器的扩展插件/index.html
new file mode 100644
index 0000000000..6d1a21497c
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/构建一个跨浏览器的扩展插件/index.html
@@ -0,0 +1,275 @@
+---
+title: 构建一个跨浏览器的扩展程序
+slug: Mozilla/Add-ons/WebExtensions/构建一个跨浏览器的扩展插件
+tags:
+ - Web插件
+ - 扩展
+ - 指南
+ - 插件
+translation_of: Mozilla/Add-ons/WebExtensions/Build_a_cross_browser_extension
+---
+<p>{{AddonSidebar()}}</p>
+
+<p>浏览器扩展 API 的引入为浏览器扩展的开发创造了 “一次开发跨浏览器” 的前景。然而,在使用扩展 API 的浏览器中(主要是 Chrome、 Firefox、 Opera 和 Edge) ,API 的实现和覆盖范围都存在差异。除此之外,Safari 使用了它自己的 Safari 扩展脚本系统。</p>
+
+<p>最大化兼容浏览器扩展意味着至少在两个不同的浏览器上兼容同一个扩展。本文探讨了在创建跨浏览器扩展时所面临的六个主要挑战,并在每种情况下提出了如何应对这些挑战。</p>
+
+<p>本文不讨论为 Safari 构建浏览器扩展。您可以通过 Safari 扩展共享一些资源,比如图片和 HTML 内容。然而,如果您要进行 JavaScript 部分的编程则需要作为一个单独的开发项目进行,除非您希望创建自己的 polyfill。</p>
+
+<h2 id="跨平台扩展的开发障碍">跨平台扩展的开发障碍</h2>
+
+<p>在开发跨平台扩展时,需要注意以下六个方面:</p>
+
+<ul>
+ <li>API 命名空间</li>
+ <li>API 异步事件处理</li>
+ <li>API 函数覆盖率</li>
+ <li>Manifest 的字段</li>
+ <li>打包扩展</li>
+ <li>发布扩展</li>
+</ul>
+
+<h3 id="API_命名空间">API 命名空间</h3>
+
+<p>在四大主流浏览器中,有两个 API 命名空间正在使用:</p>
+
+<ul>
+ <li><code>browser.* </code>是 Firefox 和 Edge 使用的扩展 API 的标准</li>
+ <li><code>chrome.*</code> 是 Chrome 和 Opera 使用的扩展 API 的标准</li>
+</ul>
+
+<p>Firefox 也支持 Chrome 浏览器的 <code>chrome.*</code> 名称空间,主要用于协助扩展移植。然而,首选应该使用浏览器 <code>browser.*</code> 命名空间。除了被提议的标准外, <code>browser.*</code> 使用 promises ーー一种现代化且简单的处理异步事件机制。</p>
+
+<p>只有在非常小的扩展中,命名空间才可能是唯一的跨平台问题。因此,如果你遇到了且试图专门解决这个问题的话,可能很少会有帮助。最好的方法是通过异步事件处理来解决这个问题。</p>
+
+<h3 id="API_异步事件处理">API 异步事件处理</h3>
+
+<p>在四个主要浏览器中,有两种方法可以处理异步事件:</p>
+
+<ul>
+ <li>promises 是 Firefox 使用的扩展 API 的标准</li>
+ <li>callbacks 是 Chrome、Edge 和 Opera 使用的扩展 API 的标准</li>
+</ul>
+
+<p>Firefox 还支持 <code>chrome.*</code> 命名空间中的 callbacks 风格的 API,这主要是为了便于从 Chrome <a href="https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Porting_a_Google_Chrome_extension">迁移</a>。然而,应该首选使用 promises(以及 <code>browser.*</code> 命名空间),它已被采纳为拟议标准的一部分。它极大地简化了异步事件处理,特别是在需要将事件链接在一起的情况下。</p>
+
+<div class="blockIndicator note">
+<p>如果你对这两种方法之间的差异不熟悉,可以看一下 <a href="https://medium.com/codebuddies/getting-to-know-asynchronous-javascript-callbacks-promises-and-async-await-17e0673281ee">了解异步 JavaScript: Callbacks、 Promises 和 Async/Await </a>或者 MDN 的 <a href="/en-US/docs/Web/JavaScript/Guide/Using_promises">Using promises</a> 页面。</p>
+</div>
+
+<h4 id="浏览器扩展_API_的垫片(Polyfill)">浏览器扩展 API 的垫片(Polyfill)</h4>
+
+<p>那么,当 Firefox 是唯一支持它的浏览器时,你如何轻松地使用 promises 呢?解决方案是使用 promises 为 Firefox 编程,并使用<a href="https://github.com/mozilla/webextension-polyfill/">浏览器扩展 API 的垫片(Polyfill)</a>!<br>
+ <br>
+ 这个 polyfill 解决了跨 Firefox、 Chrome 和 Opera 的 API 名称空间和异步事件处理。在撰写本报告时(2018年11月) ,Edge 的支持正在开发中。<br>
+ <br>
+ 要使用 polyfill,可以使用 npm 安装到开发环境中,或者直接从 <a href="https://github.com/mozilla/webextension-polyfill/releases">GitHub Relase</a> 页面下载。</p>
+
+<p>然后,引入 <code>browser-polyfill.js</code> 到:</p>
+
+<ul>
+ <li><code>manifest.json</code>,修改后使它可以用于 background 和 content 脚本</li>
+ <li>HTML 文件,例如 <code>browserAction</code> 弹出窗口或标签页</li>
+ <li>使用 <code>tabs.executeScript</code> 上的 <code>executeScript</code> 动态注入脚本(不需要事先在 manifest.json 的 <code>content_scripts</code> 中申明</li>
+</ul>
+
+<p>例如,这个 <code>manifest.json</code> 代码让你的后台脚本可以使用 polyfill:</p>
+
+<pre class="brush: json notranslate">{
+ // ...
+ "background": {
+ "scripts": [
+ "browser-polyfill.js",
+ "background.js"
+ ]
+ }
+}</pre>
+
+<p>您的目标是确保在任何其他扩展脚本执行 <code>browser.*</code> API 前执行 polyfill。</p>
+
+<div class="blockIndicator note">
+<p>关于如何使用模块打包器使用 polyfill 的更多细节和信息,请参阅 <a href="https://github.com/mozilla/webextension-polyfill/blob/master/README.md">GitHub 上的项目自述文件</a>。</p>
+</div>
+
+<p>还有其他的 polyfill 选项,但是在撰写本文时,没有一个提供浏览器扩展 API polyfill 的覆盖范围。所以,如果你没有把 Firefox 作为你的首选,你的选择就是接受 polyfills 的限制,移植到 Firefox 并添加跨浏览器的支持,或者开发你自己的 polyfill。</p>
+
+<h3 id="API_函数覆盖率">API 函数覆盖率</h3>
+
+<p>这四个主要浏览器提供的 API 函数的实现差异可分为三大类:</p>
+
+<ul>
+ <li><strong>缺乏对整个功能的支持。</strong>例如,在撰写本文时,Edge 没有提供对<a href="https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/privacy#Browser_compatibility">隐私</a>功能的支持。</li>
+ <li><strong>缺乏对某些特性的支持。</strong>例如,在撰写本文时,Firefox 不支持 <code>onButtonClicked</code>,而只支持 <code>onShown</code>。</li>
+ <li><strong>专有功能,支持特定于浏览器的特性。</strong>例如,在撰写本文时,容器是一个特定于 firefox 的特性,由 <code>contextualidentity</code> 函数支持。</li>
+</ul>
+
+<p>你可以在 <a href="https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Browser_support_for_JavaScript_APIs">Mozilla Developer Network 浏览器对 JavaScript API 页面的支持</a>上找到4个主要浏览器对扩展 API 的支持细节,以及 Firefox for Android 对扩展 API 的支持细节。浏览器兼容性信息也包含在每个函数及其方法、类型和事件的 Mozilla Developer Network <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API">JavaScript APIs</a> 参考页面中。</p>
+
+<h4 id="处理_API_差异">处理 API 差异</h4>
+
+<p>解决这些差异的一个简单方法是将扩展中使用的函数限制在没有 API 差异的函数范围内。在实践中,对于大多数扩展,这种方法可能限制性太强。<br>
+ <br>
+ 相反,如果 API 之间存在差异,则应该提供替代实现或降级功能。(请记住: 您可能还需要这样考虑同一浏览器的不同版本之间的 API 支持差异。)</p>
+
+<p>使用运行时检查函数特性的可用性是实现备选或降级功能的推荐方法。执行运行时检查的好处是,如果函数是可用的,您不需要更新和重新分发扩展来使用它。</p>
+
+<p>下面的代码使您能够执行运行时检查:</p>
+
+<pre class="brush: js notranslate">if (typeof &lt;function&gt; === "function") {
+ // safe to use the function
+}</pre>
+
+<h3 id="Manifest_字段">Manifest 字段</h3>
+
+<p>4个主要浏览器支持的 <code><a href="/zh-CN/docs/https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Browser_compatibility_for_manifest.json">manifest.json</a></code> 文件字段的差异大致可分为三类:</p>
+
+<ul>
+ <li><strong>扩展信息属性。</strong>例如,在撰写本文时,Firefox 和 Opera 包含和 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/author#Browser_compatibility">author</a></code> 地位相等的 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/developer#Browser_compatibility">developer</a></code> 关键字,以获取扩展的开发者和作者的详细信息。</li>
+ <li><strong>扩展功能。</strong>例如,在编写本文时,Edge 不支持扩展定义快捷键的 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/commands#Browser_compatibility">commands</a></code> 字段。</li>
+ <li><strong>字段可选性。</strong>例如,在编写本文时,在 Edge 中 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/author#Browser_compatibility">author</a></code> 字段是必需的,但在其他主要浏览器中是可选的。</li>
+</ul>
+
+<p>浏览器兼容性信息包含在 Mozilla Developer Network <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a></code> 页的每个字段中。</p>
+
+<p><code>manifest.json</code> 文件在不同浏览器之间的版本号可能有所不同,为每个浏览器创建和编辑一个静态版本号通常是最简单的方法。</p>
+
+<h3 id="扩展打包">扩展打包</h3>
+
+<p>通过浏览器扩展商店打包和分发扩展相对简单。</p>
+
+<ul>
+ <li><font>火狐、 Chrome 和 Opera 都使用简单的 zip 格式打包,同时需要 </font><code>manifest.json</code> <font>文件位于压缩包的根目录。</font></li>
+ <li><font>但是,提交到 Microsoft 扩展商店需要对扩展文件进行额外打包。</font></li>
+</ul>
+
+<p>有关打包的详细信息,请参阅相应扩展的开发人员门户网站上的指南。</p>
+
+<h3 id="扩展发布">扩展发布</h3>
+
+<p>这四种主要浏览器都维护有浏览器扩展商店。每个商店还对扩展进行审核,以检查安全漏洞。</p>
+
+<p>因此,您需要为每个商店分别添加和更新扩展。在某些情况下,您可以使用脚本上传扩展。</p>
+
+<p>下表总结了每个商店的做法和特点:</p>
+
+<table>
+ <tbody>
+ <tr>
+ <td></td>
+ <td>
+ <p>注册费</p>
+ </td>
+ <td>
+ <p>上传模块</p>
+ </td>
+ <td>
+ <p>发布审核</p>
+ </td>
+ <td>
+ <p>开发者账号需要2FA验证</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>Firefox</p>
+ </td>
+ <td>
+ <p>否</p>
+ </td>
+ <td>
+ <p><a href="/en-US/Add-ons/WebExtensions/web-ext_command_reference">web-ext</a></p>
+ </td>
+ <td>
+ <p>全自动,仅需要几秒钟<sup>1</sup></p>
+ </td>
+ <td>
+ <p>否</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>Chrome</p>
+ </td>
+ <td>
+ <p>是</p>
+ </td>
+ <td>
+ <p>是</p>
+ </td>
+ <td>
+ <p>全自动,短于一小时</p>
+ </td>
+ <td>
+ <p>是</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>Opera</p>
+ </td>
+ <td>
+ <p>否</p>
+ </td>
+ <td>
+ <p>否</p>
+ </td>
+ <td>
+ <p>人工审核,但不需要提供SLA</p>
+ </td>
+ <td>
+ <p>否</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>Edge</p>
+ </td>
+ <td>
+ <p>是</p>
+ </td>
+ <td>
+ <p>否</p>
+ </td>
+ <td>
+ <p>人工审核,需要72小时<sup>2</sup></p>
+ </td>
+ <td>
+ <p>是</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p><sup>1</sup> 在发布后会延期进行一次人工审查,如果发现了需要解决的问题,可能导致扩展被暂停。</p>
+
+<p><sup>2</sup> 在撰写本文时,微软只允许发布预先批准的扩展。</p>
+
+<h3 id="其他考虑">其他考虑</h3>
+
+<h4 id="扩展命名">扩展命名</h4>
+
+<p>Microsoft 要求扩展具有唯一的名称,并通过 Windows Dev Center 为扩展声明一个或多个名称。因此,即使您不打算立即支持 Edge,为微软保留一个扩展名可能是最谨慎的做法。</p>
+
+<h4 id="版本号指定">版本号指定</h4>
+
+<p>Firefox 和 Chrome 商店要求每个上传的扩展发布包都有一个单独的版本号。这意味着如果在线上遇到问题,就不能恢复到之前的版本号。</p>
+
+<h4 id="在不同的实现中共享资源">在不同的实现中共享资源</h4>
+
+<p>即使你要支持的平台中包括 Safari,仍然可以在对于不同浏览器的实现中共享许多资源。其中包括:</p>
+
+<ul>
+ <li>Images</li>
+ <li>HTML</li>
+ <li>CSS</li>
+</ul>
+
+<h2 id="总结">总结</h2>
+
+<p>在进行跨平台扩展开发时,可以通过对标 Firefox 和使用 <a href="https://github.com/mozilla/webextension-polyfill/">WebExtension API Polyfill</a> 来解决扩展 API 之间的根本差异。遵循这种方法,您将在使用与提议的 WebExtension API 标准紧密结合的 API 特性中受益,并使用 promises 来简单的处理异步事件。</p>
+
+<p>跨平台工作的主要重点可能是处理主要浏览器支持的 API 特性之间的差异。创建你的 <code>manifest.json</code> 文件应该是相对简单的,你可以手动完成。然后,您将需要考虑扩展包中的打包差异,以及提交到每个扩展商店的过程差异。</p>
+
+<p>您同时可以使用<a href="https://github.com/notlmn/browser-extension-template"> browser-extension-template</a> 用于快速设置、生成和发布浏览器扩展项目。</p>
+
+<p>根据本文中的建议,您现在应该能够创建一个在四种主要浏览器上都运行良好的扩展程序,使您能够将扩展功能交付给更多的人。</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/用户界面元素/index.html b/files/zh-cn/mozilla/add-ons/webextensions/用户界面元素/index.html
new file mode 100644
index 0000000000..1e99cab52c
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/用户界面元素/index.html
@@ -0,0 +1,162 @@
+---
+title: 用户界面元素
+slug: Mozilla/Add-ons/WebExtensions/用户界面元素
+translation_of: Mozilla/Add-ons/WebExtensions/user_interface
+---
+<div>{{AddonSidebar}}</div>
+
+<p>该主题概括了所有你能用来创建你扩展的用户界面的组件。</p>
+
+<h2 id="浏览器行为">浏览器行为</h2>
+
+<p>浏览器行为是一个你能添加至浏览器工具栏的按钮,用户可以点击该按钮来与你的扩展交互。</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/12966/browser-action.png" style="display: block; height: 387px; margin-left: auto; margin-right: auto; width: 782px;"></p>
+
+<p>有两种方式定义一个浏览器行为: 有一个 <a href="#Popups">弹出菜单</a>, 或者没有弹出菜单。</p>
+
+<p>当你没有定义一个弹出菜单时,用户点击按钮会导致一个消息被分发至扩展,而你可以使用 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/BrowserAction/onClicked" title="Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup."><code>browserAction.onClicked</code></a> 来监听它:</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js">browser<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>handleClick<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+
+<p>如果你定义了弹出菜单,点击事件就不会被分发取而代之的是弹出菜单会显示出来。用户可以跟弹出菜单交互而当用户点击菜单外的区域时它会自动关闭。</p>
+
+<p>值得注意的是你的扩展只能拥有一个浏览器行为。</p>
+
+<h3 id="定义浏览器行为">定义浏览器行为</h3>
+
+<p>你通过使用在manifest.json 文件中使用 <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_action">browser_action</a></code> 关键字定义浏览器行为的属性 - 图标, 标题, 弹出菜单 :</p>
+
+<pre class="brush: json line-numbers language-json"><code class="language-json"><span class="key token">"browser_action":</span> <span class="punctuation token">{</span>
+ <span class="key token">"default_icon":</span> <span class="punctuation token">{</span>
+ <span class="key token">"19":</span> <span class="string token">"button/geo-19.png"</span><span class="punctuation token">,</span>
+ <span class="key token">"38":</span> <span class="string token">"button/geo-38.png"</span>
+ <span class="punctuation token">}</span><span class="punctuation token">,</span>
+ <span class="key token">"default_title":</span> <span class="string token">"Whereami?"</span><span class="punctuation token">,</span>
+ <span class="key token">"default_popup":</span> <span class="string token">"popup/geo.html"</span>
+<span class="punctuation token">}</span></code></pre>
+
+<p>唯一必要的关键字是 <code>default_icon</code>.你可以使用 <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserAction">browserAction</a></code> API 修改任何属性.</p>
+
+<h3 id="例子">例子</h3>
+
+<p>在GITHUB上的 <a href="https://github.com/mdn/webextensions-examples">webextensions-examples</a> 资源包含了以下使用浏览行为的例子:</p>
+
+<ul>
+ <li><a href="https://github.com/mdn/webextensions-examples/blob/master/bookmark-it/">bookmark-it</a> 使用了没有弹出菜单的浏览器行为</li>
+ <li><a href="https://github.com/mdn/webextensions-examples/tree/master/beastify">beastify</a> 使用了由弹出菜单的浏览器行为</li>
+</ul>
+
+<h2 id="页面行为">页面行为</h2>
+
+<p>页面行为在很多方面类似于 <a href="#Browser_actions">browser actions</a> , 除了:</p>
+
+<ul>
+ <li>浏览器行为按钮会一直显现,并且一直可用。</li>
+ <li>页面行为只会在几个页面并且该页面处于活动标签时显示。</li>
+</ul>
+
+<p>为了强调页面行为只跟部分页面有联系,他们将其显示在地址栏内而不是工具栏:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/12960/page-action.png" style="display: block; height: 262px; margin-left: auto; margin-right: auto; width: 850px;"></p>
+
+<p>不像浏览器行为,页面行为默认是关闭的, 调用 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/PageAction/show" title="Shows the page action for a given tab. The page action is shown whenever the given tab is the active tab."><code>pageAction.show()</code></a> 和<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/PageAction/hide" title="Hides the page action for a given tab."><code>pageAction.hide()</code></a> 可以显示或隐藏页面行为。</p>
+
+<h3 id="定义页面行为">定义页面行为</h3>
+
+<p>通过在manifest.json中使用<code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/page_action">page_action</a></code> 关键字来定义页面行为的属性 —— 图标, 标题, 弹出菜单:</p>
+
+<pre class="brush: json line-numbers language-json"><code class="language-json"><span class="key token">"page_action":</span> <span class="punctuation token">{</span>
+ <span class="key token">"browser_style":</span> <span class="keyword token">true</span><span class="punctuation token">,</span>
+ <span class="key token">"default_icon":</span> <span class="punctuation token">{</span>
+ <span class="key token">"19":</span> <span class="string token">"button/geo-19.png"</span><span class="punctuation token">,</span>
+ <span class="key token">"38":</span> <span class="string token">"button/geo-38.png"</span>
+ <span class="punctuation token">}</span><span class="punctuation token">,</span>
+ <span class="key token">"default_title":</span> <span class="string token">"Whereami?"</span><span class="punctuation token">,</span>
+ <span class="key token">"default_popup":</span> <span class="string token">"popup/geo.html"</span>
+<span class="punctuation token">}</span></code></pre>
+
+<p><code>default_icon 是唯一强制要求的关键字</code>. 你可以使用 <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserAction">pageAction</a></code> API 修改所有的属性或现实或隐藏页面行为。</p>
+
+<h3 id="例子_2">例子</h3>
+
+<p> <a href="https://github.com/mdn/webextensions-examples/tree/master/chill-out">chill-out</a> 例子使用了一个页面行为。</p>
+
+<h2 id="弹出菜单">弹出菜单</h2>
+
+<p>一个弹出菜单是一个绑定至 <a href="#Browser_actions">browser action</a> 或者 <a href="#Page_actions">page action</a>  的对话框。</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/14039/popup-shadow.png" style="display: block; height: 545px; margin-left: auto; margin-right: auto; width: 700px;"></p>
+
+<p>当用户点击按钮弹出菜单显示,当用户点击弹出菜单外的任何区域弹出菜单关闭。可以使用  <code><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/close">window.close()</a></code> 来关闭弹出菜单。</p>
+
+<p>你可以使用专门的在manifest.json中使用"_execute_browser_action" 和 "_execute_page_action" 来定义一个快捷键打开浏览器行为或页面行为. 详情请看 <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/commands">commands</a></code> manifest.json 关键字。不过你不能在你的扩展脚本中通过编程打开弹出菜单 : 他只能通过用户的行为的被打开。</p>
+
+<p>弹出菜单像普通网页一样通过HTML文件被定义,你当然也可以在里面包含CSS 和 javascript文件。 而且不像普通网页, 其包含的javascript可以使用所有的已经通过<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permissions</a>获取了使用权限的 <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API">WebExtension APIs</a> 。</p>
+
+<p>你可以要求浏览器在你的弹出菜单中包含一个样式表以使其看起来与浏览器UI一致。为了达成这一目的,在你的 <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_action">browser_action</a></code> 或 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/page_action">page_action</a>  关键字中包含<code> "browser_style": true</code> 。</p>
+
+<p>弹出菜单存在一个限制其可以加载资源的源地址的安全机制, 同时不允许类似 <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval">eval()</a></code> 的做法的使用 查看 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy">Content Security Policy</a> 获取更多细节。</p>
+
+<p>你可以使用Add-on Debugger来调试弹出菜单标记和脚本,但是你需要一些技巧来设置让弹出菜单不在自动关闭。<a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Debugging#Debugging_popups"> 阅读关于调试弹出菜单</a>。</p>
+
+<h3 id="弹出菜单尺寸重新计算">弹出菜单尺寸重新计算</h3>
+
+<p>弹出菜单自动根据其内容调整尺寸。其适应算法可能因浏览器而不同。</p>
+
+<p>在火狐, 尺寸只再弹出菜单显示前被计算,而且在内容变化后至多进行每秒十次的计算。严格来说, 尺寸受 <code><a href="/en-US/docs/Web/HTML/Element/body">&lt;body&gt;</a></code> 元素放置尺寸决定。 一种怪异的说法是, 他由 <code><a href="/en-US/docs/Web/HTML/Element/html">&lt;html&gt;</a></code> 决定, Firefox 计算该元素的推荐宽度, 重新调整弹出菜单至其宽度, 然后完成尺寸调整所以这里没有上下滚动。 如果适应用户的屏幕他可能会增长到800X600px的尺寸。 如果用户 <a href="https://support.mozilla.org/en-US/kb/customize-firefox-controls-buttons-and-toolbars#w_customize-the-menu-or-the-toolbar">移动弹出菜单对应按钮到菜单面板</a> ,而后弹出菜单会在菜单栏内显示并具有合适的尺寸。</p>
+
+<h2 id="设置页面">设置页面</h2>
+
+<p>设置页面允许你定义你的扩展可以被用户修改的选项。 用户从浏览器扩展管理器中访问设置页面:</p>
+
+<p>{{EmbedYouTube("02oXAcbUv-s")}}</p>
+
+<p>每个浏览器访问该页面的方法存在区别。</p>
+
+<ul>
+</ul>
+
+<p>你可以通过调用 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/Runtime/openOptionsPage" title="If your add-on does not have an options page, or the browser failed to create one for some other reason, runtime.lastError will be set."><code>runtime.openOptionsPage()</code></a> 打开设置页面</p>
+
+<p>设置页面存在一个限制其可以加载资源的源地址的安全机制, 同时不允许类似 <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval">eval()</a></code> 的做法的使用 查看 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy">Content Security Policy</a> 获取更多细节。</p>
+
+<h3 id="定义一个设置页面:">定义一个设置页面:</h3>
+
+<p>创建一个设置页面有以下流程:</p>
+
+<ul>
+ <li>写一个HTML文件定义页面。该文件像普通网页一样可以包含CSS和Javascript 文件而且可以使用所有 <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API">WebExtension APIs</a> ,特别的你可以使用 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/Storage" title="Enables WebExtensions to store and retrieve data, and listen for changes to stored items."><code>storage</code></a> API 来保存设置。</li>
+ <li>将这些文件打包至你的扩展。</li>
+ <li>在manifest.json 文件包含 <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/options_ui">options_ui</a></code> 关键字, 并给予设置页面的URL。</li>
+</ul>
+
+<h3 id="例子_3">例子</h3>
+
+<p> <a href="https://github.com/mdn/webextensions-examples/tree/master/favourite-colour">favourite-colour</a> 使用了设置页面。</p>
+
+<h2 id="上下文菜单项">上下文菜单项</h2>
+
+<p>使用 {{WebExtAPIRef("contextMenus")}} API, 你可以按你指定的情况向浏览器上下文菜单添加项目, 比如,你可以只在用户点击图片时显示一项,或者在一个可编辑的元素上,或者被选择的页面的一部份。</p>
+
+<h3 id="指定一个上下文菜单项">指定一个上下文菜单项</h3>
+
+<p>您可以使用{{WebExtAPIRef("contextMenus")}} API来 程序化地管理上下文菜单项。</p>
+
+<h3 id="例子_4">例子</h3>
+
+<p> <a href="https://github.com/mdn/webextensions-examples/tree/master/context-menu-demo">context-menu-demo</a> 创建了几种不同的上下文菜单项。</p>
+
+<h2 id="通知">通知</h2>
+
+<p>使用 {{WebExtAPIRef("notifications")}} API,你通过使用操作系统的通知系统可以创建短时通知:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/14043/notify-shadowed.png" style="display: block; height: 334px; margin-left: auto; margin-right: auto; width: 700px;"></p>
+
+<h3 id="定义一个通知">定义一个通知</h3>
+
+<p>使用{{WebExtAPIRef("notifications")}} API 可以程序化地管理通知。</p>
+
+<h3 id="Examples">Examples</h3>
+
+<p><a href="https://github.com/mdn/webextensions-examples/tree/master/notify-link-clicks-i18n">notify-link-clicks-i18n</a> 创建了通知。</p>
diff --git a/files/zh-cn/mozilla/add-ons/working_with_multiprocess_firefox/index.html b/files/zh-cn/mozilla/add-ons/working_with_multiprocess_firefox/index.html
new file mode 100644
index 0000000000..152a15de20
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/working_with_multiprocess_firefox/index.html
@@ -0,0 +1,296 @@
+---
+title: 编写适合多进程 Firefox 的扩展
+slug: Mozilla/Add-ons/Working_with_multiprocess_Firefox
+translation_of: Archive/Add-ons/Working_with_multiprocess_Firefox
+---
+<div class="summary">
+<p>致 Firefox 开发者:本文描述如何使你开发的扩展能在多进程 Firefox 中运行。</p>
+</div>
+
+<p>目前,在桌面版 Firefox 中,Chrome 代码(Chrome Code)和内容(Content)运行在同一个进程里。因此扩展可以直接访问网页内容:</p>
+
+<pre class="brush: js">gBrowser.selectedBrowser.contentDocument.body.innerHTML = "replaced by chrome code";</pre>
+
+<p>不过呢,在多进程 Firefox(又称 Electrolysis 或 E10S)中,扩展代码(Add-on Code)和内容则在不同的进程中运行,所以上述直接访问就不一定可行了。</p>
+
+<p>在多进程 Firefox 中,扩展需要将触及内容的代码分解成单独分离的脚本,也就是所谓的框架脚本(Frame Scripts)。框架脚本在内容进程中运行,可以直接访问内容。框架脚本通过消息传递接口(Message-passing API)与扩展的剩余部分进行通讯。</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/8437/e10s-overview.png" style="display: block; margin-left: auto; margin-right: auto;">运行在 Chrome 进程中的扩展代码必须向框架脚本发送异步消息。这样做可以确保 Firefox 的用户界面不会被内容进程卡死。</p>
+
+<p>内容进程则可以向 Chrome 进程发送同步或异步消息,不过使用异步消息是再好不过了。</p>
+
+<p>关于使用消息管理器的更多细节,请参阅:<a href="/zh-CN/docs/The_message_manager">消息管理器指南</a>。接下来,本文将告诉你如何判断你开发的扩展是否会受到这方面的影响,同时简要说明需要如何进行修改。最后,通过对一些简单的样板扩展进行修改,让它们能在多进程 Firefox 中运行。</p>
+
+<h2 id="检查你的扩展是否受到影响">检查你的扩展是否受到影响</h2>
+
+<p>总体规则如下:</p>
+
+<ul>
+ <li>如果你只是使用附加组件开发工具包的<a href="https://developer.mozilla.org/zh-CN/Add-ons/SDK/High-Level_APIs">高级接口</a>,你的扩展不会受到影响(附加组件开发工具包尚未完全兼容多进程Firefox,但很快就会完全兼容)。</li>
+ <li>如果你的扩展完全不访问网络内容,它们也不会受到影响。</li>
+ <li>如果你通过直接使用<a href="https://developer.mozilla.org/zh-CN/Add-ons/Overlay_Extensions">表层扩展</a>、<a href="https://developer.mozilla.org/zh-CN/Add-ons/Bootstrapped_extensions">启动扩展</a>或<a href="https://developer.mozilla.org/zh-CN/Add-ons/SDK/Low-Level_APIs">底层开发工具包接口</a>(例如<a href="https://developer.mozilla.org/zh-CN/Add-ons/SDK/Low-Level_APIs/window_utils">窗口/工具</a>或<a href="https://developer.mozilla.org/zh-CN/Add-ons/SDK/Low-Level_APIs/tabs_utils">标签页/工具</a>)来访问网络内容,那么你的扩展有可能受到影响。</li>
+ <li>如果你在标签页中加载可扩展用户界面语言(xul),你的扩展会受到影响。</li>
+</ul>
+
+<p>为了证实是否受到影响,你还需要进一步测试,这个测试过程由两步过程构成:</p>
+
+<ul>
+ <li><strong>开启 Firefox 的多进程支持</strong>:<a href="https://nightly.mozilla.org/">Firefox 每夜版</a>(Nightly Build)支持多进程,但是默认是关闭的,而且并没有出现在选项窗口中。启用多进程的方法是访问 about:config 页面,找到名为 browser.tabs.remote.autostart 的项目,将其值设置为true,重启火狐浏览器。启用多进程功能后,标签页的标题会出现下划线以提示用户。</li>
+ <li><strong>声明你的扩展兼容多进程模式</strong>:为了便于迁移至多进程 Firefox,我们提供<a href="https://developer.mozilla.org/zh-CN/Firefox/Multiprocess_Firefox/Compatibility_shims">兼容性管理工具</a>帮助不兼容多进程的扩展工作。故此,你需要禁用兼容性管理工具以检测你的扩展是否真正兼容。禁用兼容性管理工具的方法是向你的扩展的 install.rdf 文件添加一个名为 multiprocessCompatible 的属性,值为 true。</li>
+</ul>
+
+<p>现在,你可以在多进程 Firefox 中禁用兼容性管理工具来测试你的扩展的兼容性了。可惜你还不能在开启多进程功能的时候安装新扩展,因此你必须先安装好扩展再开启多进程功能。关于这个问题,详见 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1055808">bug 1055808</a>。</p>
+
+<h2 id="更新你的代码">更新你的代码</h2>
+
+<p>更新代码的一般方法是:</p>
+
+<ul>
+ <li>将你的扩展中需要访问网络内容的部分分解为一个或数个单独的脚本。在多进程Firefox中,这被称为框架脚本。</li>
+ <li>为你的框架脚本注册 chrome:// 地址。</li>
+ <li>用<a href="https://developer.mozilla.org/zh-CN/docs/The_message_manager">消息管理器</a>来将脚本加载进 <a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/browser"><code>browser </code></a>对象。</li>
+ <li>如果你的扩展需要在主扩展代码和框架脚本之间通信,可以使用消息管理器接口来实现。</li>
+ <li>如果你需要在标签页中加载可扩展用户界面语言,可以将它们注册为 about: 地址,然后通过 about: 地址加载它们。</li>
+</ul>
+
+<p>更多细节,请参见<a href="/zh-CN/docs/The_message_manager"> message manager</a> 文档。</p>
+
+<h3 id="新应用程序接口的向前兼容能力">新应用程序接口的向前兼容能力</h3>
+
+<p>新的多进程 Firefox 的消息接口在多进程模式没有开启的情况下仍然可用。实际上它们从 Firefox 4开始就在某种程度上可用了。不过呢,最初的应用程序接口和现在的并不相同。一些已知的差异如下:</p>
+
+<ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=776825">Firefox 17 的界面发生了变化</a>。</li>
+ <li>在Firefox 19 之前的版本中,类似<code>new content.document.defaultView.XMLHttpRequest()</code>的代码会得到<code>NS_ERROR_FAILURE: Failure</code>的错误值。</li>
+</ul>
+
+<p>你不仅应该在开启了多进程支持的每夜版Firefox上测试你的扩展的变化,而且应该在你打算支持的没有开启多进程支持的发行版(Release Build)中测试。</p>
+
+<h2 id="举几个例子">举几个例子</h2>
+
+<p>这部分将演示修改几种不同的扩展的过程。这些扩展都是很简易的,意在展示基础的扩展模式在多进程Firefox中需要的不同处理方式。</p>
+
+<p>你可以在 <a href="https://github.com/mdn/e10s-example-addons">e10s-example-addons GitHub repository</a> 中找到这些例子的所有源代码。</p>
+
+<h3 id="在所有页面运行一个脚本">在所有页面运行一个脚本</h3>
+
+<div class="note">
+<p><a href="https://github.com/mdn/e10s-example-addons/tree/master/run-script-in-all-pages">查看这个例子的源代码</a></p>
+</div>
+
+<p>第一个扩展在每一个页面加载的时候运行一些代码。这些代码不和扩展的其他部分交互,它们只是对页面进行一些预设的修改。在这个例子中,扩展向文档的主体(<a href="https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/body"><code>body</code></a>)添加了一个边界。</p>
+
+<p>这个扩展通过将一种“页面加载中”代码碎片(<a href="https://developer.mozilla.org/zh-CN/docs/Code_snippets/On_page_load#Basic_onPageLoad_for_a_browser_window">"On page load" code snippet</a>)附加于可扩展用户界面语言层来实现此修改。</p>
+
+<pre class="brush: js">var myExtension = {
+ init: function() {
+ // The event can be DOMContentLoaded, pageshow, pagehide, load or unload.
+ if(gBrowser) gBrowser.addEventListener("DOMContentLoaded", this.onPageLoad, false);
+ },
+ onPageLoad: function(aEvent) {
+ var doc = aEvent.originalTarget; // doc is document that triggered the event
+ if (doc.nodeName != "#document") return; // only documents
+ // make whatever modifications you want to doc
+ doc.body.style.border = "5px solid blue";
+ }
+}
+
+window.addEventListener("load", function load(event){
+ window.removeEventListener("load", load, false); //remove listener, no longer needed
+ myExtension.init();
+},false);</pre>
+
+<p>因为这段代码直接访问网络内容,所以它不能在多进程 Firefox 中运行。<br>
+ <img alt="" src="https://mdn.mozillademos.org/files/8431/all-pages-original.png" style="display: block; margin-left: auto; margin-right: auto;"></p>
+
+<h4 id="移植到消息管理器">移植到消息管理器</h4>
+
+<p>为了使用消息管理器移植这个例子,我们可将这个扩展全部的主体部分放入一个框架脚本:</p>
+
+<pre class="brush: js">// frame-script.js
+// will run in the content process
+
+addEventListener("DOMContentLoaded", function(event) {
+ var doc = event.originalTarget;
+ if (doc.nodeName != "#document") return; // only documents
+ doc.body.style.border = "5px solid red";
+});
+</pre>
+
+<p>我们将为这个框架脚本注册一个 chrome:// URL :</p>
+
+<pre>// chrome.manifest
+
+content    modify-all-pages    chrome/content/
+</pre>
+
+<p>我们附加到XUL overlay的主体脚本,只是一个使用全局消息管理器来在每个标签页中加载框架脚本的 stub。</p>
+
+<pre class="brush: js">// chrome script
+// will run in the chrome process
+
+var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
+ .getService(Ci.nsIMessageListenerManager);
+
+globalMM.loadFrameScript("chrome://modify-all-pages/content/frame-script.js", true);</pre>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/8415/all-pages-ported.png" style="display: block; margin-left: auto; margin-right: auto;"></p>
+
+<h4 id="移植到_Add-on_SDK">移植到 Add-on SDK</h4>
+
+<p>一个好的替代这样的一个扩展的思路是将其移植到 Add-on SDK。Add-on SDK 包括一个名为 <a href="/zh-CN/Add-ons/SDK/High-Level_APIs/page-mod">page-mod</a> 的设计为在网页中加载脚本的模块。Add-on SDK 称这些脚本为内容脚本。</p>
+
+<p>这种情况下扩展的主要代码创建一个 page-mod 来加载内容脚本到用户载入的每个页面:</p>
+
+<pre class="brush: js">// main.js
+
+var pageMod = require("sdk/page-mod");
+var self = require("sdk/self");
+
+pageMod.PageMod({
+ include: "*",
+ contentScriptFile: self.data.url("modify-all-pages.js")
+});</pre>
+
+<p>内容脚本可以直接修改页面:</p>
+
+<pre class="brush: js">// modify-all-pages.js - content script
+
+document.body.style.border = "5px solid green";</pre>
+
+<h3 id="在活动标签中运行一个脚本">在活动标签中运行一个脚本</h3>
+
+<div class="note">
+<p><a href="https://github.com/mdn/e10s-example-addons/tree/master/run-script-in-active-page">查看这个例子的代码。</a></p>
+</div>
+
+<p>这个例子说明了一个扩展如何:</p>
+
+<ul>
+ <li><a href="/zh-CN/docs/The_message_manager#Types_of_message_manager">向一个特定的XUL &lt;browser&gt; 元素中加载框架脚本</a></li>
+ <li><a href="/zh-CN/docs/The_message_manager#Synchronous_messaging">从框架脚本向扩展主体发出一个同步的请求</a></li>
+</ul>
+
+<p>这个例子是一个无需重启的扩展,它使用 CustomizableUI 模块添加了一个按钮。当用户点击这个按钮,这个扩展运行一些代码来改变当前标签。其基础构造取自 <a href="https://github.com/jvillalobos/Australis-Hello-World">Jorge Villalobos 的 Australis "Hello World" 扩展</a> .<br>
+ <br>
+ 代码实际做的事是:找到任意 <code><a href="/zh-CN/docs/Web/HTML/Element/Img">&lt;img&gt;</a></code> 元素并将其 <code>src</code> 替换为从硬编码于扩展中的列表中随机抽取的无意义的 GIF 图像。 无意义的 gifs 从<a href="https://github.com/bwinton/whimsy">Whimsy extension </a>获取。</p>
+
+<p>第一个版本直接访问页面,因此其不是多进程兼容的:</p>
+
+<pre class="brush: js">// bootstrap.js
+
+let Gifinate = {
+ init : function() {
+ let io =
+ Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService);
+
+ // the 'style' directive isn't supported in chrome.manifest for bootstrapped
+ // extensions, so this is the manual way of doing the same.
+ this._ss =
+ Cc["@mozilla.org/content/style-sheet-service;1"].
+ getService(Ci.nsIStyleSheetService);
+ this._uri = io.newURI("chrome://gifinate/skin/toolbar.css", null, null);
+ this._ss.loadAndRegisterSheet(this._uri, this._ss.USER_SHEET);
+
+ // create widget and add it to the main toolbar.
+ CustomizableUI.createWidget(
+ { id : "gifinate-button",
+ defaultArea : CustomizableUI.AREA_NAVBAR,
+ label : "Gifinate",
+ tooltiptext : "Gifinate!",
+ onCommand : function(aEvent) {
+ Gifinate.replaceImages(aEvent.target.ownerDocument.defaultView.content.document);
+ }
+ });
+ },
+
+ replaceImages : function(contentDocument) {
+ let images = contentDocument.getElementsByTagName("img");
+ for (var i = 0; i &lt; images.length; ++i) {
+ let gif = this.gifs[Math.floor(Math.random() * this.gifs.length)];
+ images[i].src = gif;
+ }
+ },</pre>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/8433/gifinate-original.png" style="display: block; margin-left: auto; margin-right: auto;"></p>
+
+<h4 id="移植到消息管理器_2">移植到消息管理器</h4>
+
+<p>为了移植这个例子到消息管理器,我们将使 <code>onCommand</code> 加载一个框架脚本到当前的 <code>&lt;browser&gt;</code>,然后监听来自框架脚本的 "request-gifs" 信息。这些 "request-gifs" 信息应当包含我们在此页面上需要的 GIFs :信息监听器取回并返回这个数量的 GIFs。</p>
+
+<pre class="brush: js">// bootstrap.js
+// will run in the chrome process
+
+let Gifinate = {
+ init : function() {
+ let io =
+ Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService);
+
+ // the 'style' directive isn't supported in chrome.manifest for bootstrapped
+ // extensions, so this is the manual way of doing the same.
+ this._ss =
+ Cc["@mozilla.org/content/style-sheet-service;1"].
+ getService(Ci.nsIStyleSheetService);
+ this._uri = io.newURI("chrome://gifinate/skin/toolbar.css", null, null);
+ this._ss.loadAndRegisterSheet(this._uri, this._ss.USER_SHEET);
+
+ // create widget and add it to the main toolbar.
+ CustomizableUI.createWidget(
+ { id : "gifinate-button",
+ defaultArea : CustomizableUI.AREA_NAVBAR,
+ label : "Gifinate Button",
+ tooltiptext : "Gifinate!",
+ onCommand : function(aEvent) {
+ Gifinate.replaceImages(aEvent.target.ownerDocument);
+ }
+ });
+ },
+
+ replaceImages : function(xulDocument) {
+ var browserMM = xulDocument.defaultView.gBrowser.selectedBrowser.messageManager;
+ browserMM.loadFrameScript("chrome://gifinate/content/frame-script.js", false);
+ browserMM.addMessageListener("request-gifs", Gifinate.getGifs);
+ },
+
+ getGifs : function(message) {
+ var gifsToReturn = new Array(message.data);
+ for (var i = 0; i &lt; gifsToReturn.length; i++) {
+ let gif = this.gifs[Math.floor(Math.random() * this.gifs.length)];
+ gifsToReturn[i] = gif;
+ }
+ return gifsToReturn;
+ },
+</pre>
+
+<p>再次地,我们需要为这个框架脚本注册一个 chrome:// URL:</p>
+
+<pre>// chrome.manifest
+
+content gifinate frame-script.js</pre>
+
+<p>在框架脚本中,我们获取所有的 <code>&lt;img&gt;</code> 元素并发送 "request-gifs" 信息给扩展主体代码。 由于这是框架脚本我们可以将其变为一个同步信息,并使用其返回值更新 <code>src</code> 属性:</p>
+
+<pre class="brush: js">// frame-script.js
+// will run in the content process
+
+var images = content.document.getElementsByTagName("img");
+var response = sendSyncMessage("request-gifs", images.length);
+var gifs = response[0];
+
+for (var i = 0; i &lt; images.length; ++i) {
+ images[i].src = gifs[i];
+}</pre>
+
+<p>整个扩展的流程现在像这样:<br>
+ <img alt="" src="https://mdn.mozillademos.org/files/8411/gifinate-ported.png" style="display: block; margin-left: auto; margin-right: auto;"></p>
+
+<h2 id="已知问题">已知问题</h2>
+
+<p>这里是可能影响扩展开发者移植到多进程firefox的开放的bug列表:</p>
+
+<ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1051238"><strong>Bug 1051238</strong></a> -<span id="summary_alias_container"> 框架脚本被永久缓存,因此扩展不能在不重启浏览器的情况下正确更新</span></li>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1017320"><strong>Bug 1017320</strong></a> -<span id="summary_alias_container"> 实施兼容shims的跟踪<span id="short_desc_nonedit_display"> bug</span></span></li>
+</ul>
diff --git a/files/zh-cn/mozilla/add-ons/雷鸟/index.html b/files/zh-cn/mozilla/add-ons/雷鸟/index.html
new file mode 100644
index 0000000000..c46b242f7e
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/雷鸟/index.html
@@ -0,0 +1,131 @@
+---
+title: 雷鸟扩展
+slug: Mozilla/Add-ons/雷鸟
+translation_of: Mozilla/Thunderbird/Thunderbird_extensions
+---
+<div class="callout-box"><strong><a href="/en/Extensions/Thunderbird/Building_a_Thunderbird_extension" title="en/Building_a_Thunderbird_extension">Building a Thunderbird extension</a></strong><br>
+Step-by-step explanation on how to build an extension for Thunderbird.</div>
+
+<div>
+<p>{{AddonSidebar}}</p>
+本文档是为Mozilla公司的雷鸟邮件客户端开发扩展的教程。Although there are many similarities with <a href="/en/Extensions" title="en/Extensions">Firefox extensions</a> there are also some differences that may confound the starting developer.</div>
+
+<div><br>
+<strong>Please help!</strong> You can <a class="internal" href="/en/Extensions/Thunderbird/HowTos" title="en/Extensions/Thunderbird/HowTos">add a how-to</a> (a question or an answer or a code snippet), <a class="internal" href="/en/Extensions/Thunderbird/Useful_newsgroups_discussions" title="En/Extensions/Thunderbird/Useful newsgroups discussions">summarize and link to a relevant newsgroup discussion</a>, or create a tutorial. Need help? Contact <a class="internal" href="/User:jenzed" title="User:jenzed">jenzed</a>.</div>
+
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h2 id="Documentation" name="Documentation"><a href="/Special:Tags?tag=Extensions&amp;language=en" title="Special:Tags?tag=Extensions&amp;language=en">Documentation</a></h2>
+
+ <h3 id="Getting_started_with_Thunderbird">Getting started with Thunderbird</h3>
+
+ <p>A brave, young developer wants to develop an add-on for Thunderbird. Here's a few links to help them through this journey.</p>
+
+ <ul>
+ <li>Start by reading the tutorial and learn how to<a class="internal" href="/en/Extensions/Thunderbird/Building_a_Thunderbird_extension" title="En/Building a Thunderbird extension"> build a Thunderbird extension</a> (Outdated, still talks about overlays and the add-on builder is no longer available but the tutorial has not been updated.)</li>
+ <li>Read about the <a href="/en/Thunderbird/Main_Windows" title="Main Windows">main windows</a> so that you know what one means when they say « thread pane », « preview pane », and « folder pane ».</li>
+ <li>Read an <a class="external" href="http://blog.xulforum.org/index.php?post/2011/01/03/An-overview-of-Thunderbird-Conversations" title="http://blog.xulforum.org/index.php?post/2011/01/03/An-overview-of-Thunderbird-Conversations">overview</a> of how the various parts of Thunderbird fit together, this really helps get a better understanding of Thunderbird.</li>
+ <li>Want to do some real stuff? See <a class="external" href="http://blog.xulforum.org/index.php?post/2011/03/14/Basic-MimeMessage-demo" title="http://blog.xulforum.org/index.php?post/2011/03/14/Basic-MimeMessage-demo">how to inspect a message</a> (demo add-on included!)</li>
+ <li>Play with our other <a href="/en/Extensions/Thunderbird/Demo_Addon" title="Demo Addon">demo add-on</a> that exercises some more advanced Thunderbird-specific features</li>
+ <li>Want to do even more stuff? Don't reinvent the wheel: steal functions from the <a class="link-https" href="https://github.com/protz/thunderbird-stdlib" title="https://github.com/protz/thunderbird-stdlib">thunderbird-stdlib</a> project (doc <a class="external" href="http://protz.github.com/thunderbird-stdlib/doc/symbols/_global_.html" title="http://protz.github.com/thunderbird-stdlib/doc/symbols/_global_.html">here</a>). Functions for dealing with messages (delete them, archive them, change their tags, etc.) are included.</li>
+ <li>Haven't found what you're looking for? Read the <a class="internal" href="/en/Extensions/Thunderbird/HowTos" rel="internal" title="en/Extensions/Thunderbird/HowTos">Thunderbird how-tos</a>; they contain a lot of recipes for things extensions want to do.</li>
+ <li>Still haven't managed to do what you wanted? See the list of all <a class="external" href="http://wiki.mozilla.org/Thunderbird/CommunicationChannels" title="http://wiki.mozilla.org/Thunderbird/CommunicationChannels">Thunderbird communication channels </a>so that you know where to ask when you get stuck :-).</li>
+ <li>Feeling really brave? Read the source using a <a class="external" href="http://doxygen.db48x.net/comm-central/html/" title="http://doxygen.db48x.net/comm-central/html/">fancy interface</a>; you can often find tests that demonstrate how to do what you're trying to achieve.</li>
+ </ul>
+
+ <h3 id="The_Gloda_database">The Gloda database</h3>
+
+ <p>Thunderbird has a subsystem called Gloda. Gloda stands for « Global Database », and creates Thunderbird-wide relations between objects. Gloda provides concepts such as Conversations, Messages, Identities, Contacts. All these concepts are related together: a Conversation contains Messages which are linked to Identities (<strong>from</strong> field, <strong>to</strong> field) which are themselves part of a Contact: indeed, a contact has multiple identities.</p>
+
+ <p>Typical use cases for Gloda: find all messages whose subject matches [search term], find all messages from [person], find all messages in the same thread as [a given message], find all messages involving [person], etc. etc.</p>
+
+ <p>Gloda is extremely powerful and is used heavily by add-ons such as <a class="link-https" href="https://addons.mozilla.org/en-US/thunderbird/addon/gmail-conversation-view/" title="https://addons.mozilla.org/en-US/thunderbird/addon/gmail-conversation-view/">Thunderbird Conversations</a>. Learn more about Gloda:</p>
+
+ <ul>
+ <li>an overview of <a href="/en/Thunderbird/gloda" title="Gloda">Gloda</a></li>
+ <li>learn how to create <a href="/en/Thunderbird/Creating_a_Gloda_message_query" title="Creating a gloda message query">your first message query</a> and read the <a href="/en/Thunderbird/Gloda_examples" title="Gloda examples">gloda examples</a></li>
+ <li>learn about the Gloda internals: <a href="/en/Thunderbird/Gloda_debugging" title="Gloda debugging">Gloda debugging</a>, <a href="/en/Thunderbird/Gloda_indexing" title="Gloda indexing">Gloda indexing</a></li>
+ </ul>
+
+ <h3 id="More_Thunderbird-specific_links">More Thunderbird-specific links</h3>
+
+ <p>Some of these links may be wildly out of date, but they still provide valuable information on the codebase.</p>
+
+ <ul>
+ <li><a class="internal" href="/en/Extensions/Thunderbird/An_overview_of_the_Thunderbird_interface" title="En/Extensions/Thunderbird/An overview of the Thunderbird interface">An overview of Thunderbird components</a></li>
+ <li><a class="internal" href="/en/Extensions/Thunderbird/Thunderbird_developer_reference_docs" title="en/Extensions/Thunderbird/Thunderbird developer reference docs">Developer reference docs</a>:
+ <ul>
+ <li><a class="internal" href="/en/Folders" title="En/Folders">Folder classes</a></li>
+ <li><a class="internal" href="/en/DB_Views_(message_lists)" title="En/DB Views (message lists)">DB views (message list)</a></li>
+ <li><a class="internal" href="/en/Message_Summary_Database" title="En/Message Summary Database">Message summary database</a></li>
+ <li><a class="internal" href="/en/MailNews_Protocols" title="En/MailNews Protocols">MailNews protocols</a></li>
+ <li><a class="internal" href="/En/MailNews_Filters" rel="internal" title="En/MailNews Filters">MailNews filters</a></li>
+ <li><a class="internal" href="/en/Extensions/Thunderbird/Error_reporting_tools" title="en/Extension Library/Extensions/Thunderbird/Error reporting tools">Error reporting tools</a></li>
+ <li><a href="/en/Toolkit_API/STEEL" title="en/Toolkit API/STEEL">STEEL library</a> (not actively developed anymore, use   <a class="link-https" href="https://github.com/protz/thunderbird-stdlib" title="https://github.com/protz/thunderbird-stdlib">https://github.com/protz/thunderbird-stdlib</a>)</li>
+ <li><a class="external" href="http://quetzalcoatal.blogspot.com/2010/01/developing-new-account-types-part-0.html" title="http://quetzalcoatal.blogspot.com/2010/01/developing-new-account-types-part-0.html">Developing new account types</a> <strong>NEW!</strong></li>
+ </ul>
+ </li>
+ <li><a class="internal" href="/en/Extensions/Thunderbird/Useful_newsgroups_discussions" title="En/Extensions/Thunderbird/Useful newsgroups discussions">Useful newsgroup discussions</a> (watch out, anything that's too old should be regarded suspiciously; there's been significant API rewrite over the past years, and most of these techniques are considerably easier now) </li>
+ <li><a href="/en/Thunderbird/Thunderbird_API_documentation" title="en/Thunderbird/Thunderbird API documentation">Thunderbird API docs</a> (mostly a collection of out-of-date pages, relevance is rather dubious) </li>
+ <li><a href="/En/Thunderbird_3_for_developers" title="En/Thunderbird 3 for developers">Thunderbird 3 for developers</a> and <a href="/en/Thunderbird_3.1_for_developers" title="en/Thunderbird 3.1 for developers">Thunderbird 3.1 for developers</a> - changes in the recent Thunderbird updates affecting add-on developers. <a href="/Thunderbird_5_for_developers" title="Thunderbird 5 for developers">Thunderbird 5 for developers</a> has important information on MsgHdrToMimeMessage which is a central piece of code.</li>
+ </ul>
+
+ <h3 id="General_links">General links</h3>
+
+ <ul>
+ <li><a class="internal" href="/en/Extensions" title="en/Extensions">General information on developing extensions for Mozilla applications</a></li>
+ <li><a href="/en/Extensions/Thunderbird/Finding_the_code_for_a_feature" title="en/Extensions/Thunderbird/Finding the code for a feature">Finding the code for a feature</a></li>
+ <li><a class="external" href="http://kb.mozillazine.org/Category:Thunderbird" title="http://kb.mozillazine.org/Category:Thunderbird">Mozillazine articles on Thunderbird</a></li>
+ <li><a href="/Special:Tags?tag=Thunderbird" title="https://developer.mozilla.org/Special:Tags?tag=Thunderbird">All pages tagged with Thunderbird</a></li>
+ <li><a href="/Special:Tags?tag=MailNews" title="https://developer.mozilla.org/Special:Tags?tag=MailNews">All pages tagged with MailNews</a></li>
+ </ul>
+ </td>
+ <td>
+ <h2 id="Community" name="Community">Community</h2>
+
+ <ul>
+ <li>See the list of all <a class="external" href="http://wiki.mozilla.org/Thunderbird/CommunicationChannels" title="http://wiki.mozilla.org/Thunderbird/CommunicationChannels">Thunderbird communication channels </a>first</li>
+ <li>Among these are:</li>
+ </ul>
+
+ <p>{{ DiscussionList("dev-extensions", "mozilla.dev.extensions") }}</p>
+
+ <ul>
+ <li><a class="link-irc" href="irc://moznet/#extdev">#extdev IRC channel</a> / <a class="link-irc" href="irc://moznet/#maildev">#maildev IRC channel</a></li>
+ <li><a class="external" href="http://forums.mozillazine.org/viewforum.php?f=19">MozillaZine forum</a></li>
+ <li><a class="external" href="http://mozdev.org/mailman/listinfo/project_owners">mozdev project owners</a></li>
+ <li><a href="/en/Extensions/Community" title="en/Extensions/Community">Other community links...</a></li>
+ </ul>
+
+ <h2 id="Tools" name="Tools">Tools</h2>
+
+ <ul>
+ <li><a class="link-https" href="https://addons.mozilla.org/en-US/firefox/addon/6622" rel="external nofollow" title="https://addons.mozilla.org/en-US/firefox/addon/6622">DOM Inspector</a> edit the live DOM (Firefox and Thunderbird)</li>
+ <li><a class="link-https" href="https://addons.mozilla.org/thunderbird/addon/workspace-for-thunderbird/" title="https://addons.mozilla.org/thunderbird/addon/workspace-for-thunderbird/">Workspace for Thunderbird</a>, allows running code snippets in Thunderbird and inspecting variable structure and content</li>
+ <li><a class="external" href="http://www.hacksrus.com/~ginda/venkman/" rel="external nofollow" title="http://www.hacksrus.com/~ginda/venkman/">Venkman</a>, a JavaScript debugger (<a class="external" href="http://addons.mozilla.org/en-US/firefox/addon/216" rel="external nofollow" title="http://addons.mozilla.org/en-US/firefox/addon/216">Firefox</a>, <a class="external" href="http://addons.mozilla.org/en-US/thunderbird/addon/216" rel="external nofollow" title="http://addons.mozilla.org/en-US/thunderbird/addon/216">Thunderbird</a>)</li>
+ <li><a class="link-https" href="https://addons.mozilla.org/en-US/firefox/addon/7434/" rel="external nofollow" title="https://addons.mozilla.org/en-US/firefox/addon/7434/">Extension Developer's Extension</a> a suite of development tools</li>
+ <li><a class="external" href="http://www.gijsk.com/" rel="external nofollow" title="http://www.gijsk.com/">Chrome List</a> view files in chrome:// (<a class="external" href="http://addons.mozilla.org/en-US/firefox/addon/4453" rel="external nofollow" title="http://addons.mozilla.org/en-US/firefox/addon/4453">Firefox</a>, <a class="external" href="http://addons.mozilla.org/en-US/thunderbird/addon/4453" rel="external nofollow" title="http://addons.mozilla.org/en-US/thunderbird/addon/4453">Thunderbird</a>)</li>
+ <li><a class="external" href="http://addons.mozilla.org/en-US/developers/tools/builder" rel="external nofollow" title="http://addons.mozilla.org/en-US/developers/tools/builder">Add-on Builder</a> a web-based extension skeleton generator (Firefox and Thunderbird)</li>
+ <li><a href="/en/Mozmill" title="en/Mozmill">Mozmill</a> test tool and framework</li>
+ <li><a class="external" href="http://xpcomviewer.mozdev.org/" rel="external nofollow" title="http://xpcomviewer.mozdev.org">XPCOMViewer</a> an XPCOM inspector (Firefox and Thunderbird)</li>
+ </ul>
+
+ <p>... <a class="internal" href="/en/Setting_up_extension_development_environment#Development_extensions" title="en/Setting up extension development environment#Development extensions">more tools</a> ...</p>
+
+ <p><span class="alllinks"><a href="/Special:Tags?tag=Extensions:Tools&amp;language=en" title="Special:Tags?tag=Extensions:Tools&amp;language=en">View All...</a></span></p>
+
+ <h2 id="Related_Topics" name="Related_Topics">Related Topics</h2>
+
+ <dl>
+ <dd><a href="/en/XUL" title="en/XUL">XUL</a>, <a href="/en/JavaScript" title="en/JavaScript">JavaScript</a>, <a href="/en/XPCOM" title="en/XPCOM">XPCOM</a>, <a href="/en/Themes" title="en/Themes">Themes</a>, <a href="/En/Developer_Guide" title="en/Developing_Mozilla">Developing Mozilla</a></dd>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p><span class="comment">Categories</span></p>
+
+<p>{{ languages( { "ja": "ja/Extensions/Thunderbird" } ) }}</p>
diff --git a/files/zh-cn/mozilla/adding_a_new_event/index.html b/files/zh-cn/mozilla/adding_a_new_event/index.html
new file mode 100644
index 0000000000..1cd964fe0e
--- /dev/null
+++ b/files/zh-cn/mozilla/adding_a_new_event/index.html
@@ -0,0 +1,186 @@
+---
+title: Adding a new event
+slug: Mozilla/Adding_a_new_event
+translation_of: Mozilla/Adding_a_new_event
+---
+<div class="warning">
+<p>This document is a working draft.</p>
+</div>
+
+<h2 id="What_type_of_event_do_you_want">What type of event do you want?</h2>
+
+<p>大体上,有三种类型的事件。 First, you need to choose which type you need.</p>
+
+<p>Case 1: 简单DOM事件。通过WebIDL、<code>WidgetEvent等机制实现</code>. This type of event is useful if the event isn't handled by C++ code.</p>
+
+<p>Case 2: DOM事件。表达诸如键盘、鼠标等用户操作的本地事件。这种类型的事件能够方便的使用C++代码来处理。</p>
+
+<p>Case 3: 非DOM事件。However, C++ 代码需要分派事件到DOM树,然后在使用C++代码来处理。This is useful for widget notifying DOM tree of something or retrieving something from DOM tree.</p>
+
+<h2 id="How_to_implement_an_internal_event_class">How to implement an internal event class</h2>
+
+<div class="note">
+<p>If you're in the case 1, you can skip this section.</p>
+</div>
+
+<h3 id="Add_event_messages">Add event messages</h3>
+
+<p>You need to add event messages which are stored by <code>WidgetEvent::message</code>. All messages are defined by macro in "messages" section of <a href="http://mxr.mozilla.org/mozilla-central/source/widget/BasicEvents.h">BasicEvents.h</a>.</p>
+
+<h3 id="Define_event_class_name">Define event class name</h3>
+
+<p>You need to add an event class name in <a href="http://mxr.mozilla.org/mozilla-central/source/widget/EventClassList.h">EventClassList.h</a>.</p>
+
+<p>Use <code>NS_EVENT_CLASS</code> macro for adding it. The macro takes two arguments, <code>aPrefix</code> and <code>aName</code>.</p>
+
+<p><code>aPrefix</code> defines prefix of event class name which should be <code>Widget</code> or <code>Internal</code>. <code>Widget</code> should be used if the event class is dispatched from widget. Otherwise, i.e., the event class is just used for internal event class of a DOM event class, it should be <code>Internal</code>.</p>
+
+<p><code>aName</code> defines its event class specific name and it must end with "<code>Event</code>" or "<code>EventBase</code>". The latter is used only for abstruct super event class whose instance will never be created.</p>
+
+<p>Please note that <code>aName</code> must not be same as other event classes even if <code>aPrefix</code> is different. I.e., defining both <code>WidgetFooEvent</code> and <code>InternalFooEvent</code> is invalid.</p>
+
+<h3 id="Define_and_implement_an_event_class">Define and implement an event class</h3>
+
+<p>Then, you need to define and implement an event class. You should choose a good header file from what your event class represents.</p>
+
+<dl>
+ <dt><a href="http://mxr.mozilla.org/mozilla-central/source/widget/BasicEvents.h">BasicEvents.h</a></dt>
+ <dd>This header file should be used only for defining generic purpose event class such as a common super class of various event classes. Probably, you shouldn't use this for your class.</dd>
+ <dt><a href="http://mxr.mozilla.org/mozilla-central/source/widget/ContentEvents.h">ContentEvents.h</a></dt>
+ <dd>This header file should be used for defining internal event classes which are dispatched in content and do not represent user action. Typically, events in this header file never cross process boundary.</dd>
+ <dt><a href="http://mxr.mozilla.org/mozilla-central/source/widget/MouseEvents.h">MouseEvents.h</a></dt>
+ <dd>This header file should be used for defining input events from pointing devices such as mouse.</dd>
+ <dt><a href="http://mxr.mozilla.org/mozilla-central/source/widget/TextEvents.h">TextEvents.h</a></dt>
+ <dd>This header file should be used for defining input events from keyboard or IME and also other text edit related events like querying focused content information.</dd>
+ <dt><a href="http://mxr.mozilla.org/mozilla-central/source/widget/TouchEvents.h">TouchEvents.h</a></dt>
+ <dd>This header file should be used for defining input events from touch devices.</dd>
+ <dt><a href="http://mxr.mozilla.org/mozilla-central/source/widget/MiscEvents.h">MiscEvents.h</a></dt>
+ <dd>If the new event class isn't proper any header files above, you should use this.</dd>
+</dl>
+
+<p>Each event class should implement following methods manually.</p>
+
+<dl>
+ <dt><code>virtual <em>InternalFooEvent</em>* As<em>FooEvent</em>() MOZ_OVERRIDE</code></dt>
+ <dd>This method should just return <code>this</code>. This method is used for retrieving sub class pointer avoiding to use <code>static_cast</code>.</dd>
+ <dt><code>virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE</code></dt>
+ <dd>This method should create a new instance with copying its members except <code>widget</code>. For copying the members, this should use <code>Assign<em>FooEvent</em>Data()</code> with <code>true</code> for <code>aCopyTargets</code>. And also, <code>mFlags</code> should be just copied since <code>Assign<em>FooEvent</em>Data()</code> doesn't copy <code>mFlags</code>. This method is basically used for duplicating an internal event class instance of a DOM event when the DOM event is stored by content.</dd>
+ <dt><code>void Assign<em>FooEvent</em>Data(const <em>InternalFooEvent</em>* aEvent, bool aCopyTargets)</code></dt>
+ <dd>This method should copy members from <code>aEvent</code>. First, this method should call its super class's this method. Then, copy the additional members which are defined in the class. If <code>aCopyTargets</code> is false, don't copy its event target related members.</dd>
+</dl>
+
+<p>All new member variables of event classes must be with "<code>m</code>" prefix. Although, a lot of existing members don't have "<code>m</code>" prefix, but you shouldn't use the legacy local rules.</p>
+
+<p>If you need to add methods, it's okay to implement them as inline methods. I.e., you can implement new methods in the header files directly.</p>
+
+<p>However, if implementing method isn't small and called from a lot of places, implementing it as inline causes to increase binary size. In this case, you should implement the method in <a href="http://mxr.mozilla.org/mozilla-central/source/widget/shared/WidgetEventImpl.cpp">WidgetEventImple.cpp</a>. And also, if implementing a method needs to include other header files, you should implement it in <a href="http://mxr.mozilla.org/mozilla-central/source/widget/shared/WidgetEventImpl.cpp">WidgetEventImple.cpp</a> too for avoiding include hell.</p>
+
+<h3 id="Make_new_event_class_IPC_aware">Make new event class IPC aware</h3>
+
+<p>For example, new class is caused by native user input event and needed to be dispatch to content, the class should be able to cross process boundary. In such cases, you may need to add new ParamTraits for the new event class in <a href="http://mxr.mozilla.org/mozilla-central/source/widget/nsGUIEventIPC.h">nsGUIEventIPC.h</a>.</p>
+
+<h3 id="Modify_utility_methods_of_WidgetEvent">Modify utility methods of <code>WidgetEvent</code></h3>
+
+<p><code>WidgetEvent</code> class has some utility mehtods and all of them are implemented in <a href="http://mxr.mozilla.org/mozilla-central/source/widget/shared/WidgetEventImpl.cpp">WidgetEventImple.cpp</a>. E.g., if your event shouldn't cause DOM event, you need to modify <code>WidgetEvent::IsAllowedToDispatchDOMEvent()</code>. If your event should be fired on focused node, you need to modify <code>WidgetEvent::IsTargetedAtFocusedContent()</code>.</p>
+
+<h2 id="How_to_implement_a_DOM_event_class">How to implement a DOM event class</h2>
+
+<div class="note">
+<p>If you're in the case 3, you can skip this section.</p>
+</div>
+
+<h3 id="Create_WebIDL_of_the_event">Create WebIDL of the event</h3>
+
+<p>Write a DOM event definition with WebIDL. It should be created under <a href="http://mxr.mozilla.org/mozilla-central/source/dom/webidl/">dom/webidl/</a>. See <a href="/docs/Mozilla/WebIDL_bindings">WebIDL bindings</a> for the detail.</p>
+
+<p>If your new event shouldn't be created with event constructor such as:</p>
+
+<pre class="brush: js">var event = new FooEvent("bar", { bubbles: true, cancelable: true, detail: 5 });</pre>
+
+<p>you shouldn't define construnctor in it.</p>
+
+<h3 id="Create_XPCOM_interface_for_the_DOM_event">Create XPCOM interface for the DOM event</h3>
+
+<p>If your event class should be accessible via XPCOM interface, you should create a new nsIDOMFooEvent interface in <a href="http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/events/">dom/interfaces/events/</a>. However, in these days, this is not necessary. If all information of the event is stored by its internal event, C++ event handlers can acess them with following code:</p>
+
+<pre class="brush: cpp">NS_IMETHODIMP
+AnEventListener::HandleEvent(nsIDOMEvent* aEvent)
+{
+ InternalFooEvent* internalEvent =
+ aEvent-&gt;GetInternalNSEvent()-&gt;AsFooEvent();
+ if (NS_WARN_IF(!internalEvent)) {
+ return NS_ERROR_UNEXPECTED;
+ }
+ DoSomethingWith(internalEvent-&gt;mBar);
+ aEvent-&gt;PreventDefault();
+ return NS_OK;
+}
+</pre>
+
+<h3 id="Implement_DOM_event_class">Implement DOM event class</h3>
+
+<h4 id="Generate_DOM_event_implementation_if_it's_possible">Generate DOM event implementation if it's possible</h4>
+
+<p>If you're creating simple DOM event class, it might be generated automatically. If it's possible, you just need to add an entry to GENERATED_EVENTS_WEBIDL_FILES in <a href="http://mxr.mozilla.org/mozilla-central/source/dom/webidl/moz.build">dom/webidl/moz.build</a>.</p>
+
+<h4 id="Define_and_create_DOM_event_class_manually">Define and create DOM event class manually</h4>
+
+<p>Otherwise, you need to implement a DOM event class yourself. The best place to create <code><em>Foo</em>Event.h</code> and <code><em>Foo</em>Event.cpp</code> is in <a href="http://mxr.mozilla.org/mozilla-central/source/dom/events/">dom/events/</a>. Otherwise, you need to specify the path to the header file in <a href="http://mxr.mozilla.org/mozilla-central/source/dom/bindings/Bindings.conf">dom/bindings/Bindings.conf</a>.</p>
+
+<p>When you create a DOM event class, its name should be same as the name defined in its standard specification. And it should be in <code>mozilla::dom</code> namespace. For example, <code>KeyboardEvent</code> which is defined in DOM Level 3 Events should be implemented as <code>mozilla::dom::KeyboardEvent</code>.</p>
+
+<p>And the header file should be exported as "mozilla/dom/<em>Foo</em>Event.h". Add the header file to EXPORTS.mozilla.dom in <a href="http://mxr.mozilla.org/mozilla-central/source/dom/events/moz.build">dom/events/moz.build</a>.</p>
+
+<p>You probably need to implement a lot of methods to the event class, but this document doesn't explain all of them. Please refer existing DOM event implementation for example.</p>
+
+<p>However, there are some hints:</p>
+
+<ol>
+ <li>Set mEventIsInternal in the constructor of the most descendant class because each constructor creates dummy internal event instance at calling constructors of its super class. Therefore, super classes always set it false.</li>
+ <li>Don't override methods of its super classes as far as possible since overriding the method may cause harder to maintain.</li>
+ <li>When you need to check if the caller content or chrome, you can use <code>implicitJSContext</code> attribute in <a href="http://mxr.mozilla.org/mozilla-central/source/dom/bindings/Bindings.conf">dom/bindings/Bindings.conf</a>. Then, the method can have a pointer of <code>JSContext</code> in its argument.</li>
+</ol>
+
+<h3 id="Create_DOM_event_factory_method">Create DOM event factory method</h3>
+
+<div class="note">
+<p>If your DOM event implementation is generatable, you can skip this section.</p>
+</div>
+
+<p>In <a href="http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/events/nsIDOMEvent.idl">nsIDOMEvent.idl</a>, you need to define <code>NS_NewDOM<em>Foo</em>Event()</code>. It's last argument should be the most subclass. Then, the implementation of the DOM event can access internal event class instance safer.</p>
+
+<p>Then, the factory method should be implemented at the bottom of <em>Foo</em>Event.cpp in the global namespace.</p>
+
+<h2 id="Modify_EventDispatcherCreateEvent()">Modify <code>EventDispatcher::CreateEvent()</code></h2>
+
+<div class="note">
+<p>If your DOM event implementation is generatable or you're in case 3, you can skip this section.</p>
+</div>
+
+<p>The first half of <code>EventDispatcher::CreateEvent()</code> is a factory to create a DOM event instance from internal event instance. You need to modify this.</p>
+
+<p>The last half of it is the implementation of legacy event creator of Javascript such as:</p>
+
+<pre class="brush: js">var event = document.createEvent("FooEvent");</pre>
+
+<p>If you support this feature, you need to modify here. However, this feature shouldn't be implemented for compabitility with other browsers since web applications should use event constructor.</p>
+
+<h2 id="Register_each_event_into_EventNameList.h">Register each event into EventNameList.h</h2>
+
+<div class="note">
+<p>If you're in case 3, you can skip this section.</p>
+</div>
+
+<p><a href="http://mxr.mozilla.org/mozilla-central/source/dom/events/EventNameList.h">EventNameList.h</a> defines mapping between DOM event name, internal event message, event handler attribute owner and internal event class. See the comments of the head of the file for the detail.</p>
+
+<h2 id="Modify_tests">Modify tests</h2>
+
+<div class="note">
+<p>If you're in case 3, you can skip this section.</p>
+</div>
+
+<p>You need to modify <a href="http://mxr.mozilla.org/mozilla-central/source/dom/events/test/test_all_synthetic_events.html?force=1">test_all_synthetic_events.html</a> which tests if calling <code>getModifierState()</code> doesn't cause crash.</p>
+
+<p>You need to modify <a href="http://mxr.mozilla.org/mozilla-central/source/widget/tests/test_assign_event_data.html?force=1">test_assign_event_data.html</a> which tests if each attribute of DOM event is copied by <code>Assign<em>Foo</em>EventData()</code> properly. If your event cannot be fired easy, you should add the test but <code>canRun</code> should return false and call <code>todo()</code>.</p>
+
+<p>If the new DOM event is creatable with constructor, you need to modify <a href="http://mxr.mozilla.org/mozilla-central/source/dom/events/test/test_eventctors.html?force=1">test_eventctors.html</a> or <a href="http://mxr.mozilla.org/mozilla-central/source/dom/events/test/test_eventctors.xul">test_eventctors.xul</a> which tests the behavior of event constructor.</p>
diff --git a/files/zh-cn/mozilla/bugzilla/index.html b/files/zh-cn/mozilla/bugzilla/index.html
new file mode 100644
index 0000000000..83c9832732
--- /dev/null
+++ b/files/zh-cn/mozilla/bugzilla/index.html
@@ -0,0 +1,58 @@
+---
+title: Bugzilla
+slug: Mozilla/Bugzilla
+tags:
+ - Bugzilla
+ - Developing Mozilla
+ - 'Developing_Mozilla:Tools'
+ - NeedsTranslation
+ - QA
+ - Tools
+ - TopicStub
+translation_of: Mozilla/Bugzilla
+---
+<p><a class="link-https" href="https://bugzilla.mozilla.org/">bugzilla.mozilla.org</a> (often abbreviated b.m.o) is Mozilla.org's bug-tracking system, a database for recording bugs and enhancement requests for Firefox, Thunderbird, SeaMonkey, Camino, and other mozilla.org projects.</p>
+
+<div class="row topicpage-table">
+<div class="section">
+<h2 class="Documentation" id="Documentation" name="Documentation">Documentation about B.m.o.</h2>
+
+<dl>
+ <dt><a href="/en-US/docs/What_to_do_and_what_not_to_do_in_Bugzilla" title="en/What_to_do_and_what_not_to_do_in_Bugzilla">What to do and what not to do in Bugzilla</a></dt>
+ <dd>Tips for how to use Bugzilla, as well as things you should avoid.</dd>
+ <dt><a class="link-https" href="https://bugzilla.mozilla.org/page.cgi?id=etiquette.html">Bugzilla etiquette</a></dt>
+ <dd>A guide to etiquette; this guide will help you understand how best to conduct yourself on b.m.o. and how using proper manners and civility will help ensure your problem gets solved sooner rather than later.</dd>
+ <dt><a href="https://www.mozilla.org/quality/help/beginning-duplicate-finding.html" title="https://www.mozilla.org/quality/help/beginning-duplicate-finding.html">How to tell if a bug has already been reported</a></dt>
+ <dd>It's useful (but not mandatory) for you to check if the problem you're reporting has been already tracked. This guide will help you do so.</dd>
+ <dt><a href="/en-US/docs/Mozilla/QA" title="/en-US/docs/Mozilla/QA">Quality assurance</a></dt>
+ <dd>Documentation about quality assurance at Mozilla.</dd>
+ <dt><a href="/en-US/docs/Mozilla/QA/Bug_writing_guidelines" title="/en-US/docs/Mozilla/QA/Bug_writing_guidelines">Bug writing guidelines</a></dt>
+ <dd>A guide to writing a good, understandable, bug that will be easily followed by the development team.</dd>
+ <dt><a href="/en-US/docs/Developer_Guide/How_to_Submit_a_Patch" title="/en-US/docs/Developer_Guide/How_to_Submit_a_Patch">How to submit a patch</a></dt>
+ <dd>If you've fixed a bug, or have implemented a new feature, you'll need to get your patch into the tree so it can become part of the product. This guide will teach you how!</dd>
+</dl>
+
+<p><span class="alllinks"><a href="/en-US/docs/tag/Bugzilla" title="/en-US/docs/tag/CSS">View All...</a></span></p>
+</div>
+
+<div class="section">
+<h2 id="Other_materials">Other materials</h2>
+
+<ul>
+ <li><a class="external" href="https://www.bugzilla.org/about/">An Introduction to Bugzilla</a></li>
+ <li><a class="external" href="http://blog.johnath.com/2010/02/04/bugzilla-for-humans">Bugzilla for humans</a></li>
+ <li><a class="external" href="https://bugzilla.mozilla.org/page.cgi?id=quicksearch.html">Bugzilla QuickSearch help page</a>. QuickSearch is a quick, easy, and very effective way of quickly querying bugzilla.</li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Bugzilla/Testopia" title="https://developer.mozilla.org/en-US/docs/Mozilla/Bugzilla/Testopia">Testopia</a> - test case management extension</li>
+ <li><a class="external" href="https://www.bugzilla.org">bugzilla.org</a> - the project site</li>
+ <li>{{ interwiki('wikipedia', 'Bugzilla', 'wikipedia:Bugzilla') }} - general description of Bugzilla (not specific to Mozilla projects)</li>
+ <li><a href="https://wiki.mozilla.org/BMO">BMO on wiki.mozilla.org</a> - information about Mozilla's customized Bugzilla installation, including how to contribute to it</li>
+</ul>
+
+<h2 class="Tools" id="Tools" name="Tools">Tools</h2>
+
+<ul>
+ <li><a href="https://fitzgen.github.io/bugzilla-todos/" title="https://harthur.github.io/bugzilla-todos/">Bugzilla Todos</a> lists review and flag requests, patches to check in, unfulfilled requests you made of other people, and assigned bugs.</li>
+ <li><a href="https://rawgit.com/leif81/bzkanban/master/index.html?product=Bugzilla&amp;milestone=Bugzilla+6.0&amp;assignee=&amp;comments=false&amp;site=https%3A%2F%2Fbugzilla.mozilla.org">Bz Kanban </a>is a board to visualize the status of bugs within a milestone.</li>
+</ul>
+</div>
+</div>
diff --git a/files/zh-cn/mozilla/bugzilla/testopia/index.html b/files/zh-cn/mozilla/bugzilla/testopia/index.html
new file mode 100644
index 0000000000..638ecf9630
--- /dev/null
+++ b/files/zh-cn/mozilla/bugzilla/testopia/index.html
@@ -0,0 +1,134 @@
+---
+title: Testopia
+slug: Mozilla/Bugzilla/Testopia
+translation_of: Mozilla/Bugzilla/Testopia
+---
+<p>Testopia 是bugzilla测试用例管理扩展工具。它可以帮助测试人员跟踪管理测试用例,并将测试用例运行结果整合进bug报告。testopia设计以软件测试为核心,使之可以跟踪软件工程中的几乎任何测试。</p>
+<h2 id="Testopia_2.5">Testopia 2.5</h2>
+<p>此版本直接支持bugzilla4.2,并且不在需要bugzilla 补丁。如果用户需要升级至2.5</p>
+<p>在安装前,请卸载已安装的bugzilla补丁。安装之需要直接将tar包解压在bugzilla的根目录下,并运行checksetup即可。感谢来自bugzilla团队的LpSolit,没有它就没有这些变化。</p>
+<h2 id="Testopia_2.4_-_重要通知!">Testopia 2.4 - 重要通知!</h2>
+<p>如果用户在大小写敏感的文件系统中升级,请一定要从扩展目录中删除已有的testopia文件夹。</p>
+<p>如果用户已经修改了testopia 的源代码,用户需要将他们合并到Testopia文件夹(capital T)。如果用户使用windows系统或其它大小写不敏感的文件系统,用户仅需要重命名已有文件夹即可,例如:testopia-old ,然后解压缩tar包。在删除老版本前,用户可以合并两个文件夹。</p>
+<p><b>API USERS 请注意:</b> 不再赞成使用Positional parameters。所有参数变量现在都应形成哈希对 (struct, dict, hashmap or whatever your language of choice calls key, value pairs).</p>
+<p>虽然,努力尝试继续支持positional parameters,但请注意有些api直到用户调用时才会失败。在后续版本中也许会完全去除对它的支持。</p>
+<p>一如既往,请在安装或升级前备份你已安装的系统。</p>
+<h2 id="Integration_Points">Integration Points</h2>
+<ul>
+ <li>
+ <p style="margin-bottom: 0in;">Testopia与Bugzilla产品一体化,组件化,版本化,且里程碑式地为高级对象提供一个单一的管理界面。</p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;">Testopia 允许用户登录一个工具,使用bugzilla 组权限去限制访问,修改测试对象。</p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;">Testopia允许用户附上用例测试结果中发现的缺陷,以便于软件开发过程的集中管理。</p>
+ </li>
+</ul>
+<h2 id="Features_for_version_2.4_(Bugzilla_3.6.x)" style="margin-top: 0in; margin-bottom: 0in;">Features for version 2.4 (Bugzilla 3.6.x)</h2>
+<ul>
+ <li>Bugzilla 3.6 support</li>
+</ul>
+<h2 id="Features_for_version_2.3_(Bugzilla_3.4.x)" style="margin-top: 0in; margin-bottom: 0in;">Features for version 2.3 (Bugzilla 3.4.x)</h2>
+<ul>
+ <li>支持XML导入,导出测试计划和子计划</li>
+ <li>支持CSV到处测试用例和结果</li>
+ <li>新报告:严重缺陷汇总</li>
+ <li>可以设置indidual case运行优先级</li>
+ <li>新的clone选项</li>
+ <li>使用最新的Extjs 3.0 library</li>
+ <li>将Testopia升级为Bugzilla extension</li>
+ <li>修改了一些bugs</li>
+</ul>
+<h2 id="Features_for_version_2.2_(Bugzilla_3.2_and_3.0.x)" style="margin-top: 0in; margin-bottom: 0in;">Features for version 2.2 (Bugzilla 3.2 and 3.0.x)</h2>
+<p>此版本主要是修复了一些bug,使之更好的兼容bugzilla 3.2 和 3.0.6。请确认根据自己的bugzilla版本下载正确的安装包。</p>
+<p>To install, do the following (see the <a href="http://wiki.mozilla.org/Testopia:README">README</a> for more detailed instructions):</p>
+<ol>
+ <li>解压Testopia 2.4 tar包到用户的Bugzilla目录.</li>
+ <li>打Bugzilla补丁.<br>
+ On Linux systems it should look something like:
+ <p style="border: 1px solid red; padding: 3px; width: 250px;"><code><b>patch -p0 -i extensions/testopia/patch-3.6</b></code></p>
+ </li>
+ <li>Run checksetup.pl</li>
+</ol>
+<p>升级Testopia步骤同上。只是需要先卸载以前的老补丁即可。如果同时升级bugzilla,请先升级bugzilla,再升级testopia。</p>
+<p><code><b>patch -p0 -R -i extensions/testopia/patch-&lt;version&gt;</b></code></p>
+<p>命令中&lt;version&gt; 代表Bugzilla版本号</p>
+<h2 id="Requirements">Requirements</h2>
+<p>我们决定尝试紧跟bugzilla最新稳定版本3.4,来完成自己的开发。这给我们提供稳定的代码。为任何软件开发插件或扩展,就像射击移动目标一样。这个决定使得我们可以集中更多时间在新特性上,而不是旧特性。因此,这就意味着新特性不会再支持早先的版本,除非我们有时间这么做。当然,任何想这么做的人,都是无上欢迎的。</p>
+<ul>
+ <li>
+ <p style="margin-bottom: 0in;">Bugzilla 3.6.x</p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;">Mysql 5.0 or PostGres 8.1.x</p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;">Mozilla compatible browser ;-)</p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;">Additional Perl Modules: Text::CSV XML::Schema Validator XML::Schema::Parser (for importer) and JSON 2.10</p>
+ </li>
+</ul>
+<h2 id="TODO">TODO</h2>
+<ul>
+ <li>
+ <p style="margin-bottom: 0in;">User preferences</p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;">Notification emails</p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;">More Reports</p>
+ </li>
+</ul>
+<p>See the <a href="http://wiki.mozilla.org/Testopia:Roadmap">Roadmap</a> and <a href="https://bugzilla.mozilla.org/buglist.cgi?query_format=advanced&amp;short_desc_type=allwordssubstr&amp;short_desc=&amp;product=Testopia&amp;long_desc_type=substring&amp;long_desc=&amp;bug_file_loc_type=allwordssubstr&amp;bug_file_loc=&amp;status_whiteboard_type=allwordssubstr&amp;status_whiteboard=&amp;keywords_type=allwords&amp;keywords=&amp;bug_status=UNCONFIRMED&amp;bug_status=NEW&amp;bug_status=ASSIGNED&amp;bug_status=REOPENED&amp;emailassigned_to1=1&amp;emailtype1=exact&amp;email1=&amp;emailassigned_to2=1&amp;emailreporter2=1&amp;emailqa_contact2=1&amp;emailtype2=exact&amp;email2=&amp;bugidtype=include&amp;bug_id=&amp;votes=&amp;chfieldfrom=&amp;chfieldto=Now&amp;chfieldvalue=&amp;cmdtype=doit&amp;order=Reuse+same+sort+as+last+time&amp;field0-0-0=noop&amp;type0-0-0=noop&amp;value0-0-0=">Bug List</a> for more details.</p>
+<h2 id="Links">Links</h2>
+<ul>
+ <li>
+ <p style="margin-bottom: 0in;"><a href="http://wiki.mozilla.org/Testopia:FAQ">FAQ</a></p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;"><a href="http://wiki.mozilla.org/Testopia">Wiki</a></p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;"><a href="http://landfill.mozilla.org/testopia2/testopia/doc/Manual.pdf">Docs</a></p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;"><a href="https://bugzilla.mozilla.org/buglist.cgi?query_format=advanced&amp;product=Testopia&amp;bug_status=NEW&amp;bug_status=ASSIGNED&amp;bug_status=REOPENED&amp;bug_status=UNCONFIRMED">Bugs</a> (Please read the <a href="https://wiki.mozilla.org/Testopia:Bug_Reporting_Guide">Bug Reporting Guide)</a></p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;">Official Testopia <a href="http://testopia.blogspot.com/">Blog</a></p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;">IRC: <a href="irc://irc.mozilla.org/testopia">#testopia</a> or <a href="irc://irc.mozilla.org/mozwebtools">#mozwebtools </a></p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;">User Help <a href="mailto:support-webtools@lists.mozilla.org">support-webtools@lists.mozilla.org</a></p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;">Developers <a href="mailto:dev-apps-webtools@lists.mozilla.org">dev-apps-webtools@lists.mozilla.org</a></p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;"><a href="http://landfill.mozilla.org/testopia2/">Testopia on landfill (2.2 on Bugzilla 3.0.6)</a></p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;"><a href="http://landfill.mozilla.org/testopia/">Testopia on landfill (2.2 on Bugzilla 3.2)</a></p>
+ </li>
+</ul>
+<h2 id="Downloads">Downloads</h2>
+<ul>
+ <li>
+ <p style="margin-bottom: 0in;"><a href="ftp://ftp.mozilla.org/pub/mozilla.org/webtools/testopia/testopia-2.5-BUGZILLA-4.2.tar.gz">Download 2.5 (Bugzilla 4.2)</a></p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;"><a href="ftp://ftp.mozilla.org/pub/mozilla.org/webtools/testopia/testopia-2.4-BUGZILLA-3.6.tar.gz">Download 2.4 (Bugzilla 3.6 and 4.0)</a></p>
+ </li>
+ <li>
+ <p style="margin-bottom: 0in;"><a href="ftp://ftp.mozilla.org/pub/mozilla.org/webtools/testopia/">Archived Versions</a></p>
+ </li>
+</ul>
+<h2 id="Developers">Developers</h2>
+<p>Greg Hendricks<br>
+ Vance Baarda (former developer)<br>
+ Ed Fuentetaja (former developer)</p>
diff --git a/files/zh-cn/mozilla/chrome_registration/index.html b/files/zh-cn/mozilla/chrome_registration/index.html
new file mode 100644
index 0000000000..8e7fd85b41
--- /dev/null
+++ b/files/zh-cn/mozilla/chrome_registration/index.html
@@ -0,0 +1,229 @@
+---
+title: Chrome Registration
+slug: Mozilla/Chrome_Registration
+tags:
+ - NeedsEditorialReview
+ - Toolkit API
+translation_of: Mozilla/Chrome_Registration
+---
+<p> </p>
+
+<h3 id="What_is_Chrome.3F" name="What_is_Chrome.3F">Chrome是什么?</h3>
+
+<p><a href="cn/Chrome">Chrome</a> 是应用程序内容窗口以外一系列用户接口元素。工具栏,如菜单栏,进度栏和标题栏这些都是chrome典型的元件。</p>
+
+<h3 id="Chrome_Providers" name="Chrome_Providers">Chrome Providers</h3>
+
+<p>A supplier of chrome for a given window type (e.g. for the browser window) is called a chrome provider. The providers work together to supply a complete set of chrome for a particular window, from the images on the toolbar buttons to the files that describe the text, content and appearance of the window itself.</p>
+
+<p>There are three basic types of chrome providers:</p>
+
+<h4 id="Content" name="Content">Content</h4>
+
+<p>The main source file for a window description comes from the content provider, and it can be any file type viewable from within Mozilla. It will typically be a XUL file, since XUL is designed for describing the contents of windows and dialogs. The JavaScript files that define the user interface are also contained within the content packages, as well as most XBL binding files.</p>
+
+<h4 id="Locale" name="Locale">Locale</h4>
+
+<p>Localizable applications keep all their localized information in locale providers. This allows translators to plug in a different chrome package to translate an application without altering the rest of the source code. The two main types of localizable files are DTD files and Java-style properties files.</p>
+
+<h4 id="Skin" name="Skin">Skin</h4>
+
+<p>A skin provider is responsible for providing a complete set of files that describe the visual appearance of the chrome. Typically a skin provider will provide CSS files and images.</p>
+
+<p><em>Note</em>: Scripts (including those found in <a href="cn/XBL">XBL</a>) loaded from skin packages will not execute.</p>
+
+<h3 id="The_Chrome_Registry" name="The_Chrome_Registry">The Chrome Registry</h3>
+
+<p>The gecko runtime maintains a service known as the chrome registry that provides mappings from chrome package names to the physical location of chrome packages on disk.</p>
+
+<p>This chrome registry is configurable and persistent, and thus a user can install different chrome providers, and select a preferred skin and locale. This is accomplished through xpinstall and the extension manager.</p>
+
+<p>In order to inform the chrome registry of the available chrome, a text manifest is used: this manifest is "chrome.manifest" in the root of an extension, or theme, and chrome/*.manifest in a XULRunner application.</p>
+
+<p>The plaintext chrome manifests are in a simple line-based format. Each line is parsed individually; if the line is parseable the chrome registry takes the action identified by that line; otherwise the chrome registry ignores that line (and prints a warning message in the runtime error console).</p>
+
+<pre class="eval">locale packagename localename path/to/files
+skin packagename skinname path/to/files
+</pre>
+
+<h3 id="Manifest_Instructions" name="Manifest_Instructions">Manifest Instructions</h3>
+
+<h4 id="comments" name="comments">comments</h4>
+
+<p>A line is a comment if it begins with the character '#'; any other characters on the line are ignored.</p>
+
+<pre class="eval"># this line is a comment - you can put whatever you want here
+</pre>
+
+<h4 id="content" name="content">content</h4>
+
+<p>A content package is registered with the line</p>
+
+<pre class="eval">content<em>packagename</em><em>uri/to/files/</em><em>[flags]</em>
+</pre>
+
+<p>This will register a location to use when resolving the URI <a class="external" rel="freelink">chrome://</a><em>packagename</em> /content/.... The URI may be absolute or relative to the location of the manifest file. Note, that it must end with an '/'.</p>
+
+<h4 id="locale" name="locale">locale</h4>
+
+<p>A locale package is registered with the line</p>
+
+<pre class="eval">locale<em>packagename</em><em>localename</em><em>uri/to/files/</em><em>[flags]</em>
+</pre>
+
+<p>This will register a locale package when resolving the URI <a class="external" rel="freelink">chrome://</a><em>packagename</em> /locale/... . The<em>localename</em> is usually a plain language identifier "en" or a language-country identifier "en-US". If more than one locale is registered for a package, the chrome registry will select the best-fit locale using the user's preferences.</p>
+
+<h4 id="skin" name="skin">skin</h4>
+
+<p>A skin package is registered with the line</p>
+
+<pre class="eval">skin<em>packagename</em><em>skinname</em><em>uri/to/files/</em><em>[flags]</em>
+</pre>
+
+<p>This will register a skin package when resolving the URI <a class="external" rel="freelink">chrome://packagename/skin/</a>... . The<em>skinname</em> is an opaque string identifying an installed skin. If more than one skin is registered for a package, the chrome registry will select the best-fit skin using the user's preferences.</p>
+
+<h4 id="style" name="style">style</h4>
+
+<p>Style overlays (custom CSS which will be applied to a chrome page) are registered with the following syntax:</p>
+
+<pre class="eval">style <a class="external" rel="freelink">chrome://</a><em>URI-to-style</em> <a class="external" rel="freelink">chrome://</a><em>stylesheet-URI</em><em>[flags]</em>
+</pre>
+
+<div class="note">Note that only stylesheets at chrome URIs can be applied in this way.</div>
+
+<h4 id="override" name="override">override</h4>
+
+<p>In some cases an extension or embedder may wish to override a chrome file provided by the application or XULRunner. In order to allow for this, the chrome registration manifest allows for "override" instructions:</p>
+
+<pre class="eval">override <a class="external" rel="freelink">chrome://</a><em>package</em>/<em>type</em>/<em>original-uri.whatever</em><em>new-resolved-URI</em><em>[flags]</em>
+</pre>
+
+<p>Note: overrides are not recursive (so overriding <a class="external" rel="freelink">chrome://foo/content/bar/</a> with <a class="external" rel="freelink">file:///home/john/blah/</a> will not usually do what you want or expect it to do).</p>
+
+<div class="note">
+<p>There is a currently a bug in the Firefox 2.0.0.* series, as well as previous builds, where if you use a relative URL for the<em>new-resolved-URI</em> parameter, the override will not work. You need to provide a fully qualified URL (ie, one that is resolvable anywhere, not just in the directory the chrome manifest resides in). Given that the extension or application developer usually is unable to predict what the full path to such a file might be, currently one would normally only use this directive using another <a class="external" rel="freelink">chrome://</a> URL as the<em>new-resolved-URI</em> parameter. See {{ Bug(323455) }}.</p>
+</div>
+
+<h4 id="resource" name="resource">resource</h4>
+
+<p>{{ Fx_minversion_inline(3) }}</p>
+
+<p>When using <a href="cn/Using_JavaScript_code_modules">JavaScript code modules</a> it may be necessary to create resource protocol aliases so extensions and applications can load modules using <a href="cn/Components.utils.import">Components.utils.import</a>. Aliases can be created using the <code>resource</code> instruction:</p>
+
+<pre class="eval">resource<em>aliasname</em><em>uri/to/files/</em><em>[flags]</em>
+</pre>
+
+<p>This will create an mapping for the <code><a class="external" rel="freelink">res://</a>&lt;aliasname&gt;/</code> to the path given.</p>
+
+<div class="note">
+<p>Note that there are no security restrictions preventing web content from including content at resource uris so take care with what you make visible there.</p>
+</div>
+
+<h3 id="Manifest_Flags" name="Manifest_Flags">Manifest Flags</h3>
+
+<p>Manifest lines can have multiple, space-delimited flags added at the end of the registration line. These flags mark special attributes of chrome in that package, or limit the conditions under which the line is used.</p>
+
+<h4 id="application" name="application">application</h4>
+
+<p>Extensions may install into multiple applications. There may be chrome registration lines which only apply to one particular application. The flag</p>
+
+<pre class="eval">application=<em>app-ID</em>
+</pre>
+
+<p>indicates that the instruction should only be applied if the extension is installed into the application identified by<em>app-ID</em> is running. Multiple application flags may be included on a single line, in which case the line is applied if any of the flags match.</p>
+
+<h4 id="appversion" name="appversion">appversion</h4>
+
+<p>Extensions may install into multiple versions of an application. There may be chrome registration lines which only apply to a particular application version. The flag</p>
+
+<pre class="eval">appversion=<em>version</em>
+appversion&lt;<em>version</em>
+appversion&lt;=<em>version</em>
+appversion&gt;<em>version</em>
+appversion&gt;=<em>version</em>
+</pre>
+
+<p>indicates that the instruction should only be applied if the extension is installed into the application version identified. Multiple <code>appversion</code> flags may be included on a single line, in which case the line is applied if any of the flags match. The version string must conform to the <a href="cn/Toolkit_version_format">Toolkit version format</a>.</p>
+
+<div class="note">
+<p>Versions of Gecko before 1.8.0.13 and 1.8.1.5 contained a bug where if you use the comparisons &lt;, &gt; or = then the version string had be 2 characters or more long. If not you would get a message in the error console that the <code>appversion</code> flag was not recognized. See {{ Bug(380398) }}.</p>
+</div>
+
+<h4 id="contentaccessible" name="contentaccessible">contentaccessible</h4>
+
+<p>{{ Fx_minversion_inline(3) }} Untrusted content is no longer allowed to reference resources in chrome packages. If this needs to be explicitly allowed, set the contentaccessible flag to yes for behavior as found in older versions.</p>
+
+<p>The contentaccessible flag applies only to content packages: it is not recognized for locale or skin registration. However, the matching locale and skin packages will also be exposed to content. <span class="comment">Changed for Firefox 3 RC 1 for {{ bug(292789) }}.</span></p>
+
+<h4 id="os" name="os">os</h4>
+
+<p>{{ Fx_minversion_inline(3) }} Extensions (or themes) may offer different features depending on the operating system on which Firefox is running. The value is compared to the value of <a href="cn/OS_TARGET">OS_TARGET</a> for the platform.</p>
+
+<pre class="eval">os=WINNT
+os=Darwin
+</pre>
+
+<p>See <a href="cn/OS_TARGET">OS_TARGET</a> for a more complete list of os names. The os name is case insensitive.</p>
+
+<h4 id="osversion" name="osversion">osversion</h4>
+
+<p>{{ Fx_minversion_inline(3) }} An extension or theme may need to operate differently depending on which version of an operating system is running. For example, a theme may wish to adopt a different look on Mac OS X 10.5 than 10.4:</p>
+
+<pre class="eval">osversion&gt;=10.5
+</pre>
+
+<h4 id="platform_.28Platform-specific_packages.29" name="platform_.28Platform-specific_packages.29">platform (Platform-specific packages)</h4>
+
+<p>Some packages are marked with a special flag indicating that they are platform specific. Some parts of content, skin, locales may be different based on the platform being run. These packages contain three different sets of files, for Windows and OS/2, Macintosh, and Unix-like platforms. For example, the order of the "OK" and "Cancel" buttons in a dialog is different, as well as the names of some items.</p>
+
+<p>The "platform" modifier is only parsed for content registration, it is not recognized for locale or skin registration. However it applies to content, locale, and skin parts of the package, when specified.</p>
+
+<p>To indicate that a package is platform-specific, add the "platform" modifier to the "content" line after the path, for example:</p>
+
+<pre class="eval">content global-platform jar:toolkit.jar!/toolkit/content/global-platform/ platform
+</pre>
+
+<p>Once that is specified in your manifest you then ensure that under the directory global-platform are subdirectories <code>win</code> (Windows/OS2), <code>mac</code> (OS9/OSX), or <code>unix</code> (Everything Else). Anything residing outside of these subdirectories will be ignored.</p>
+
+<h4 id="xpcnativewrappers" name="xpcnativewrappers">xpcnativewrappers</h4>
+
+<p>Chrome packages can decide whether to use the xpcnativewrappers security mechanism to protect their code against malicious content that they might access. See <a href="cn/Safely_accessing_content_DOM_from_chrome">Safely accessing content DOM from chrome</a> for details.</p>
+
+<p>As of Firefox 1.5 alpha releases (Deer Park alphas), this flag is *off* by default, and must be explicitly enabled by specifying xpcnativewrappers=yes.</p>
+
+<p>As of the first Firefox 1.5 beta release, this flag will be enabled by default, and extensions that need insecure access to the content objects will be required to specify xpcnativewrappers=no.</p>
+
+<p>The xpcnativewrappers flag applies only to content packages: it is not recognized for locale or skin registration.</p>
+
+<p> </p>
+
+<h3 id="Example_Chrome_Manifest" name="Example_Chrome_Manifest">Example Chrome Manifest</h3>
+
+<pre class="eval">content necko jar:comm.jar!/content/necko/ xpcnativewrappers=yes
+locale necko en-US jar:en-US.jar!/locale/en-US/necko/
+content xbl-marquee jar:comm.jar!/content/xbl-marquee/
+content pipnss jar:pipnss.jar!/content/pipnss/
+locale pipnss en-US jar:en-US.jar!/locale/en-US/pipnss/
+# Firefox-only
+overlay <a class="external" rel="freelink">chrome://browser/content/pageInfo.xul</a> <a class="external" rel="freelink">chrome://pippki/content/PageInfoOverlay.xul</a> application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
+overlay <a class="external" rel="freelink">chrome://communicator/content/pref/preftree.xul</a> <a class="external" rel="freelink">chrome://pippki/content/PrefOverlay.xul</a>
+overlay <a class="external" rel="freelink">chrome://navigator/content/pageInfo.xul</a> <a class="external" rel="freelink">chrome://pippki/content/PageInfoOverlay.xul</a> <a class="link-mailto" href="mailto:application=seamonkey@applications.mozilla.org" rel="freelink">application=seamonkey@applications.mozilla.org</a>
+content pippki jar:pippki.jar!/content/pippki/ xpcnativewrappers=yes
+locale pippki en-US jar:en-US.jar!/locale/en-US/pippki/
+content global-platform jar:toolkit.jar!/content/global-platform/ platform
+skin global classic/1.0 jar:classic.jar!/skin/classic/global/
+override <a class="external" rel="freelink">chrome://global/content/netError.xhtml</a> jar:embedder.jar!/global/content/netError.xhtml
+content inspector jar:inspector.jar!/content/inspector/ xpcnativewrappers=no
+</pre>
+
+<h3 id="Debugging_a_Chrome_Manifest_file" name="Debugging_a_Chrome_Manifest_file">Debugging a Chrome Manifest file</h3>
+
+<p>The <a class="link-https" href="https://addons.mozilla.org/firefox/4453">Chrome List</a> extension shows all registered chrome. This is very helpful when trying to write a <code>chrome.manifest</code> file as you can inspect where the files are being mapped from (jar files, local directory, etc.)</p>
+
+<h3 id="Old-style_contents.rdf_manifests" name="Old-style_contents.rdf_manifests">Old-style contents.rdf manifests</h3>
+
+<p>Before the plaintext manifests were introduced (which happened in Firefox 1.5, Toolkit 1.8), RDF manifests named "contents.rdf" were used to register chrome. This format is deprecated; however, the Mozilla Suite (SeaMonkey) does not support the plaintext manifest format yet, so contents.rdf manifests are required for extensions that wish to maintain backwards compatibility with Firefox 1.0 or the suite.</p>
+
+<h3 id="Official_References_for_Toolkit_API" name="Official_References_for_Toolkit_API">Official References for <a href="cn/Toolkit_API">Toolkit API</a></h3>
+
+<p>{{ page("zh-CN/docs/Toolkit_API/Official_References") }}</p>
diff --git a/files/zh-cn/mozilla/command_line_options/index.html b/files/zh-cn/mozilla/command_line_options/index.html
new file mode 100644
index 0000000000..347a35bdb1
--- /dev/null
+++ b/files/zh-cn/mozilla/command_line_options/index.html
@@ -0,0 +1,407 @@
+---
+title: 命令行选项
+slug: Mozilla/Command_Line_Options
+translation_of: Mozilla/Command_Line_Options
+---
+<p>命令行选项用于为 Mozilla 应用程序指定各种启动选项。例如,您可以使用命令行配置选项来绕过配置档管理器并打开一个特定的配置档(如果您有多个配置档)。您也可以控制 Mozilla 应用程序如何打开,初始打开哪个组件以及当组件打开时要做什么。这个页面描述常用的选项和如何使用它们。</p>
+
+<h3 id="Syntax_Rules" name="Syntax_Rules">语法规则</h3>
+
+<p>首先,让我们描述一下适用于所有选项的语法规则。</p>
+
+<ul>
+ <li>包含空格的命令参数必须以引号括起;例如 "Joel User"。</li>
+ <li>命令操作是不区分大小写的。</li>
+ <li>命令参数,除了配置档名称外都是不区分大小写的。</li>
+ <li>空格( )用于间隔多个命令和参数。</li>
+ <li>每条消息选项都遵循语法 <code><var>字段</var>=<var>值</var></code>,例如:
+ <ul>
+ <li><code>to=</code><span class="nowiki"><code>foo@nowhere.net</code></span></li>
+ <li><code>subject=cool page</code></li>
+ <li><code>attachment=www.mozilla.org</code></li>
+ <li><code>attachment='<span class="nowiki">file:///c:/test.txt</span>'</code></li>
+ <li><code>body=check this page</code></li>
+ </ul>
+ </li>
+ <li>多个消息选项用逗号(,)间隔,例如: <code>"<span class="nowiki">to=foo@nowhere.net,subject=cool page</span>"。逗号分隔符一定不能尾随或前缀空格</code>( )。要指派多个值给一个字段,使用单引号(')闭合值,例如: <code>"<span class="nowiki">to='foo@nowhere.net,foo@foo.de',subject=cool page</span>"</code> 。</li>
+</ul>
+
+<h3 id="How_to_use_command_options" name="How_to_use_command_options">使用命令行选项</h3>
+
+<p>命令行选项在启动应用程序的命令后输入。某些选项选项有参数。它们在命令行选项后输入。某些选项有缩写替代。例如,命令行选项 "-editor" 可以缩写为 "-edit"。(其中可用的缩写将会在下面的文本中阐述) 在某些情况下,选项参数必须用引号括起。(这会在以下的选项描述中注明。) 可以指定多个命令行选项。通常,语法如下:</p>
+
+<pre>应用程序 -选项 -选项 "参数" -选项 参数
+</pre>
+
+<h4 id="示例">示例</h4>
+
+<p>下列示例显示 "-ProfileManager" 命令的使用,它将会在启动 Firefox 或 Thunderbird 前打开配置档管理器:</p>
+
+<h5 id="Windows">Windows</h5>
+
+<p>从 Windows 开始菜单中选择运行,输入:</p>
+
+<pre class="eval">firefox -ProfileManager
+</pre>
+
+<h5 id="Mac_OS_X">Mac OS X</h5>
+
+<p>转到 Applications &gt; Utilities,打开终端并输入:</p>
+
+<pre class="eval">cd /Applications/Firefox.app/Contents/MacOS
+./firefox -ProfileManager
+</pre>
+
+<h5 id="Linux">Linux</h5>
+
+<p>打开终端并输入:</p>
+
+<pre class="eval">cd <em>Thunderbird</em><var> 安装目录</var>
+./thunderbird -ProfileManager
+</pre>
+
+<p>以上示例调用 "-ProfileManager" 命令行选项用于 Mozilla 的 Thunderbird 邮件客户端。</p>
+
+<h3 id="User_Profile" name="User_Profile">用户配置档</h3>
+
+<h4 id="-CreateProfile_profile_name" name="-CreateProfile_profile_name"><code>-CreateProfile <var>profile_name</var></code></h4>
+
+<p>创建一个名为<var>profile_name</var> 的配置档,而不启动程序。<var>profile_name</var> 一定不能包含空格( )。</p>
+
+<pre class="eval">firefox -CreateProfile JoelUser
+</pre>
+
+<h4 id="-CreateProfile_.22profile_name_profile_dir.22" name="-CreateProfile_.22profile_name_profile_dir.22"><code>-CreateProfile "<var>profile_name</var> <var>profile_dir</var>"</code></h4>
+
+<p>在目录 <var>profile_dir</var> 中创建一个名为 <var>profile_name</var> 的配置档而不启动应用程序。注意 <var>profile_name</var> 和 <var>profile_dir</var> 必须括在一起。(在 <strong>SeaMonkey1.x</strong> 中未有)</p>
+
+<p>注: <var>profile_dir</var> 必须存在而且您必须还未有称为 <var>profile_name</var> 的配置档。</p>
+
+<pre class="eval">firefox -CreateProfile "JoelUser c:\internet\moz-profile"
+</pre>
+
+<h4 id="-ProfileManager_or_-P" name="-ProfileManager_or_-P"><code>-ProfileManager</code></h4>
+
+<p>使用配置档管理器启动。</p>
+
+<h4 id="-SelectProfile" name="-SelectProfile"><code>-SelectProfile</code></h4>
+
+<p>使用配置档选择对话框启动。仅用于 <strong>SeaMonkey1.x</strong>。</p>
+
+<h4 id="-ProfileWizard" name="-ProfileWizard"><code>-ProfileWizard</code></h4>
+
+<p>使用配置档向导启动。仅用于 <strong>SeaMonkey1.x</strong>。</p>
+
+<h4 id="-P_.22profile_name.22" name="-P_.22profile_name.22"><code>-P "<var>profile_name</var>"</code></h4>
+
+<p>绕过配置档管理器并使用名为<var>profile_name</var> 的配置档启动。对于处理多个配置档很有用。注意<var>profile_name</var> 是区分大小写的。如果您未指定一个配置档名称,那么就会打开配置档管理器。在 L:inux 上,您必须使用大写字母 P,因为小写调用 Purify 模式(内存和泄露探测)。其它平台大小写都接受。</p>
+
+<pre class="eval">firefox -P "Joel User"
+</pre>
+
+<h4 id="-profile_.22.2Fpath.2Fto.2Fprofile.22" name="-profile_.22.2Fpath.2Fto.2Fprofile.22"><code>-profile "<var>profile_path</var>"</code></h4>
+
+<p>使用给出路径的配置档启动。仅用于 <strong>Firefox</strong>、<strong>Thunderbird</strong> 和 <strong>SeaMonkey2.x</strong>。</p>
+
+<p><code>"profile_path"</code> 可以是一个绝对路径(<code>"<var>/path/to/profile</var>"</code>) 或一个相对路径<code>("<var>path/to/profile</var>"</code>).</p>
+
+<div class="note">在 Mac OS X 上,从 Firefox 4.0 和以上,由于 regression 的原因,不在支持给出相对路径,查看{{ bug(673955) }}.</div>
+
+<h4 id="-no-remote" name="-no-remote"><code>-no-remote</code></h4>
+
+<p>允许同一事件打开多个应用程序副本。(在 <strong>SeaMonkey1.x</strong> 中无效,它仅支持 <code>MOZ_NO_REMOTE=1</code>)。</p>
+
+<pre class="eval">firefox -no-remote -P "另一个配置档"
+</pre>
+
+<h4 id="-migration" name="-migration"><code>-migration</code></h4>
+
+<p>使用导入向导启动。(<strong>SeaMonkey1.x</strong> 中无效)</p>
+
+<h4 id="-installer" name="-installer"><code>-installer</code></h4>
+
+<p>使用 Netscape 4.x 迁移窗口启动。仅用于 <strong>SeaMonkey1.x</strong>。</p>
+
+<h4 id="-resetPref_preference" name="-resetPref_preference"><code>-resetPref <var>preference</var></code></h4>
+
+<p>重置指定的<var>首选项</var>(逗号间隔)为默认值。仅用于 <strong>SeaMonkey1.x</strong>。</p>
+
+<pre class="eval">seamonkey -resetPref browser.startup.homepage
+</pre>
+
+<h4 id="-override_.2Fpath.2Fto.2Foverride.ini" name="-override_.2Fpath.2Fto.2Foverride.ini"><code>-override <em>/path/to/</em>override.ini</code></h4>
+
+<p>加载指定的 <code>override.ini</code> 文件以覆盖 <code>application.ini</code> ({{ Source("browser/app/application.ini") }})中的配置。通过加载下列 <code>override.ini</code> 可以抑制在启动时的迁移向导。仅用于 <strong>Firefox</strong>。</p>
+
+<pre class="eval">[XRE]
+EnableProfileMigrator=0
+</pre>
+
+<h3 id="Browser" name="Browser">浏览器</h3>
+
+<h4 id="-browser" name="-browser"><code>-browser</code></h4>
+
+<p>使用 browser(浏览器)组件启动。仅用于 <strong>Firefox</strong> 和 <strong>SeaMonkey</strong>。</p>
+
+<h4 id="-url_URL" name="-url_URL"><code>-url <var>URL</var></code></h4>
+
+<p>根据浏览器选项,在新标签页或窗口中打开 <var>URL</var>。<code>-url</code> 可以省略。仅用于 <strong>Firefox</strong> 和 <strong>SeaMonkey</strong>。注: 当打开多个 URLs 时,Firefox 总是把它们打开为一个新窗口中的选项页。</p>
+
+<pre class="eval">firefox www.mozilla.com
+</pre>
+
+<h4 id="-private" name="-private"><code>-private</code></h4>
+
+<p>以私密浏览模式打开 Firefox,而不考虑当前的用户首选项。仅用于 <strong>Firefox 3.6</strong> 和以后版本。</p>
+
+<h4 id="-new-tab_URL" name="-new-tab_URL"><code>-new-tab <var>URL</var></code></h4>
+
+<p>在新标签页中打开 <var>URL</var>。仅用于 <strong>Firefox</strong> 和 <strong>SeaMonkey2.x</strong>。</p>
+
+<h4 id="-new-window_URL" name="-new-window_URL"><code>-new-window <var>URL</var></code></h4>
+
+<p>在新窗口中打开 <var>URL</var>。仅用于 <strong>Firefox</strong> 和 <strong>SeaMonkey2.x</strong>。</p>
+
+<h4 id="-search_term" name="-search_term"><code>-search <var>term</var></code></h4>
+
+<p>使用您的默认搜索引擎搜索 <var>term</var>。仅用于 <strong>Firefox</strong> 和 <strong>SeaMonkey2.x</strong> 及以后的版本。</p>
+
+<h4 id="-preferences" name="-preferences"><code>-preferences</code></h4>
+
+<p>打开选项/首选项窗口。仅用于 <strong>Firefox</strong> 和 <strong>SeaMonkey2.x</strong>。</p>
+
+<h4 id="-setDefaultBrowser" name="-setDefaultBrowser"><code>-setDefaultBrowser</code></h4>
+
+<p>设置应用程序为默认的浏览器。仅用于 <strong>Firefox</strong>。</p>
+
+<h3 id="Mail.2FNews" name="Mail.2FNews">邮件/新闻</h3>
+
+<h4 id="-mail" name="-mail"><code>-mail</code></h4>
+
+<p>使用邮件客户端启动。仅用于 <strong>Thunderbird</strong> 和 <strong>SeaMonkey</strong>。</p>
+
+<h4 id="-mail_mailto_URL" name="-mail_mailto_URL"><code>-mail <var>mailto_URL</var></code></h4>
+
+<p>为给出的 <var>mailto_URL </var>启动撰写消息的窗口。仅用于 <strong>Thunderbird</strong>。</p>
+
+<pre class="eval">thunderbird -mail <span class="nowiki">mailto:me@isp.net?subject=hi</span>
+</pre>
+
+<h4 id="-news_news_URL" name="-news_news_URL"><code>-news</code> <var>news_URL</var></h4>
+
+<p>使用新客户端启动。如果给出了 <var>news_URL</var> (可选),则打开指定的新闻组。仅用于 <strong>Thunderbird</strong> 和 <strong>SeaMonkey</strong>。</p>
+
+<pre class="eval">thunderbird -news <span class="nowiki">news://server/group</span>
+</pre>
+
+<h4 id="-compose_message_options" name="-compose_message_options"><code>-compose <var>message_options</var></code></h4>
+
+<p>使用邮件撰写器启动。查看<a href="#Syntax_Rules">语法规则</a>。仅用于 <strong>Thunderbird</strong> 和 <strong>SeaMonkey</strong>。</p>
+
+<pre class="eval">thunderbird -compose "<span class="nowiki">to=foo@nowhere.net</span>"
+</pre>
+
+<h4 id="-addressbook" name="-addressbook"><code>-addressbook</code></h4>
+
+<p>使用地址簿启动。仅用于 <strong>Thunderbird</strong> 和 <strong>SeaMonkey</strong>。</p>
+
+<h4 id="-options" name="-options"><code>-options</code></h4>
+
+<p>打开选项/首选项窗口。仅用于 <strong>Thunderbird</strong>。</p>
+
+<h4 id="-offline" name="-offline"><code>-offline</code></h4>
+
+<p>以离线模式启动。仅用于 <strong>Thunderbird</strong> 和 <strong>SeaMonkey</strong>。</p>
+
+<h4 id="-setDefaultMail" name="-setDefaultMail"><code>-setDefaultMail</code></h4>
+
+<p>设置应用程序为默认的邮件客户端。仅用于 <strong>Thunderbird</strong>。</p>
+
+<h3 id="Calendar" name="Calendar">日历</h3>
+
+<h4 id="-calendar" name="-calendar"><code>-calendar</code></h4>
+
+<p>使用日历客户端启动。仅用于 <strong>Sunbird</strong>。</p>
+
+<h4 id="-subscribe_URL_or_-url_URL" name="-subscribe_URL_or_-url_URL"><code>-subscribe <var>URL</var></code> 或 <code>-url <var>URL</var></code></h4>
+
+<p>订阅到给出的 <var>URL</var>。仅用于 <strong>Sunbird</strong>。</p>
+
+<h4 id="-showdate_date" name="-showdate_date"><code>-showdate <var>日期</var></code></h4>
+
+<p>显示给出的<var>日期</var>的您的计划安排。仅用于 <strong>Sunbird</strong>。</p>
+
+<pre class="eval">sunbird -showdate 08/04/2008
+</pre>
+
+<h3 id="Other_Components" name="Other_Components">其它组件</h3>
+
+<h4 id="-editor_URL_or_-edit_URL" name="-editor_URL_or_-edit_URL"><code>-editor <var>URL</var></code> 或 <code>-edit <var>URL</var></code></h4>
+
+<p>为给出的 <em>URL</em> 使用编辑器(撰写器)启动(<em>其中 </em><var>URL</var> 是可选的)。仅用于 <strong>SeaMonkey</strong>。</p>
+
+<pre class="eval">seamonkey -edit www.mozilla.org
+</pre>
+
+<h4 id="-jsconsole" name="-jsconsole"><code>-jsconsole</code></h4>
+
+<p>使用<a href="/en/Error_Console" title="en/Error_Console">错误控制台</a>启动应用程序.</p>
+
+<h4 id="-inspector_URL" name="-inspector_URL"><code>-inspector <var>URL</var></code></h4>
+
+<p>使用 <a href="/en/DOM_Inspector" title="en/DOM_Inspector">DOM Inspector</a> 启动(如果已安装的话),并观察给出的 <var>URL</var> (其中 <var>URL</var> 是可选的)。</p>
+
+<h4 id="-venkman" name="-venkman"><code>-venkman</code></h4>
+
+<p>使用 JavaScript 调试器 <a href="/en/Venkman" title="en/Venkman">Venkman</a> 启动(如果已安装的话)。</p>
+
+<h4 id="-chat" name="-chat"><code>-chat</code></h4>
+
+<p>使用 IRC 客户端 <a class="link-https" href="https://addons.mozilla.org/en-US/firefox/addon/16">ChatZilla</a> 启动(如果已安装的话)。</p>
+
+<h3 id="XULRunner" name="XULRunner">XULRunner</h3>
+
+<h4 id="-app_.2Fpath.2Fto.2Fapplication.ini" name="-app_.2Fpath.2Fto.2Fapplication.ini"><code>-app <em>/path/to/</em>application.ini</code></h4>
+
+<p>启动一个新进程运行在指定路径 <em>path/to </em>处的 <a href="/en/XULRunner" title="en/XULRunner">XULRunner</a> 应用程序。仅用于 <strong>Firefox</strong> 版本 3 和以上。</p>
+
+<h3 id="Chrome" name="Chrome">Chrome</h3>
+
+<h4 id="-chrome_chrome_URL" name="-chrome_chrome_URL"><code>-chrome <var>chrome_URL</var></code></h4>
+
+<p>加载指定的 chrome。</p>
+
+<pre class="eval">firefox -chrome <a class="external" rel="freelink">chrome://inspector/content</a>
+</pre>
+
+<h4 id="-register_chrome_URL" name="-register_chrome_URL"><code>-register <var>chrome_URL</var></code></h4>
+
+<p>注册指定的 chrome,而不启动应用程序。</p>
+
+<h3 id="Add-ons" name="Add-ons">扩展附件</h3>
+
+<p>{{ gecko_minversion_note("1.9.2", "-install-global-extension 和 -install-global-theme 已经从 Gecko 1.9.2 和以上的版本移除。") }}</p>
+
+<h4 id="-install-global-extension_.2Fpath.2Fto.2Fextension" name="-install-global-extension_.2Fpath.2Fto.2Fextension"><code>-install-global-extension <var>/path/to/extension</var></code></h4>
+
+<p>安装扩展到应用程序目录。参数是扩展的路径。您必须有管理权限。(在 <strong>SeaMonkey1.x</strong> 中无效,但是某些扩展已经把这个作为一个安装时的选项)。</p>
+
+<h4 id="-install-global-theme_.2Fpath.2Fto.2Ftheme" name="-install-global-theme_.2Fpath.2Fto.2Ftheme"><code>-install-global-theme <var>/path/to/theme</var></code></h4>
+
+<p>和上面类似,但是只用于主题。您必须有管理权限。(在 <strong>SeaMonkey1.x</strong> 中无效,但是某些扩展已经把这个作为一个安装时的选项)。</p>
+
+<div class="note">
+<p>从 Firefox 2.0.0.7 开始,<code>-install-global-extension</code> 和 <code>-install-global-theme</code> 命令行参数选项的使用被限制为只允许安装在本地磁盘或映射的驱动器上的附加组件。从网络共享直接安装将不再成功。</p>
+</div>
+
+<h4 id="-safe-mode" name="-safe-mode"><code>-safe-mode</code></h4>
+
+<p>禁用所有的扩展启动应用程序,仅用于启动。(扩展不会加载,但是不会在扩展管理器数据源中永久禁用)。(在 <strong>SeaMonkey1.x</strong> 中无效)</p>
+
+<h3 id="Locale" name="Locale">语种</h3>
+
+<h4 id="-UILocale_locale" name="-UILocale_locale"><code>-UILocale <var>locale</var></code></h4>
+
+<p>以 <var>locale</var> 资源作为用户界面的语种。</p>
+
+<pre class="eval">firefox -UILocale en-US
+</pre>
+
+<h3 id="Startup" name="Startup">启动</h3>
+
+<h4 id="-turbo" name="-turbo"><code>-turbo</code></h4>
+
+<p>Launch application in Quick Launch mode. <strong>SeaMonkey1.x</strong> only.</p>
+
+<h4 id="-nosplash_or_-quiet" name="-nosplash_or_-quiet"><code>-nosplash</code> or <code>-quiet</code></h4>
+
+<p>Suppresses display of the splash screen. To show splash screen, use the <code>-splash</code> command. Note the splash screen is disabled by default on some systems. <strong>SeaMonkey1.x</strong> only.</p>
+
+<h3 id="Remote_Control" name="Remote_Control">远程控制</h3>
+
+<h4 id="-remote_remote_command" name="-remote_remote_command"><code>-remote <var>远程命令</var></code></h4>
+
+<p>在一个已经运行的应用程序进程中执行<var>远程命令</var>(查看<a class="external" href="http://www.mozilla.org/unix/remote.html">远程控制</a>)。注: Unix/Linux 仅适用于 <strong>SeaMonkey1.x</strong></p>
+
+<pre class="eval">firefox -remote "openURL(www.mozilla.org, new-tab)"
+</pre>
+
+<h3 id="Miscellaneous" name="Miscellaneous">其它</h3>
+
+<h4 id="-console" name="-console"><code>-silent</code></h4>
+
+<p>不打开默认窗口。对于那些打开它们自己窗口但是未防止默认窗口打开的那些命令行参数很有用。仅适用于 <strong>Firefox</strong>、<strong>Thunderbird3.x</strong> 和 <strong>SeaMonkey2.x</strong>。</p>
+
+<h4 id="-console" name="-console"><code>-console</code></h4>
+
+<p>使用一个调试控制台启动应用程序。注:仅适用于 Windows。</p>
+
+<h4 id="-h_or_-help_or_-.3F" name="-h_or_-help_or_-.3F"><code>-h</code> 或 <code>-help</code> 或 <code>-?</code></h4>
+
+<p>显示所有可用的命令行参数的列表。注意,在 Windows 上仅对调试构建版本({{ Bug(355889) }})有效。这个选项仅在命令行控制台中可用。</p>
+
+<h4 id="-v_or_-version" name="-v_or_-version"><code>-v</code> 或 <code>-version</code></h4>
+
+<p>打印应用程序版本。注意,在 Windows 上仅对调试构建版本({{ Bug(355889) }})有效。</p>
+
+<h4 id="-osint" name="-osint"><code>-osint</code></h4>
+
+<p>告诉应用程序它是被 OS SHell 启动的。这个不应该指定,除非调用者在启动应用程序时,提供了 OS  Shell 的所有功能。({{ Bug(384384) }}).</p>
+
+<h4 id="-requestPending" name="-requestPending"><code>-requestPending</code></h4>
+
+<p>Tells the application that there will be a Windows DDE request to open the same url specified on the command line. This should not be specified unless the caller provides all of the functionality provided by the OS shell when launching the application ({{ Bug(354005) }}).</p>
+
+<h4 id="X11_options">X11 options</h4>
+
+<p>These options are only available for an application build for and running atop the X11/X.org display and window system to be found on Linux and other Unices.</p>
+
+<h5 id="--displayDISPLAY">--display=DISPLAY</h5>
+
+<p>设置要使用的 X display</p>
+
+<h5 id="--sync">--sync</h5>
+
+<p>使 X 调用同步</p>
+
+<h5 id="--g-fatal-warnings">--g-fatal-warnings</h5>
+
+<p>使所有警告视为严重</p>
+
+<h3 id="Other_options_need_to_be_documented" name="Other_options_need_to_be_documented">其它需要编写文档的选项</h3>
+
+<ul>
+ <li><code>-print-xpcom-dir</code></li>
+ <li><code>-print-xpcom-dirlist</code></li>
+ <li><code>-kill</code></li>
+ <li><code>-killAll</code></li>
+ <li><code>-f</code></li>
+ <li><code>-ftimeout</code></li>
+ <li><code>-fwait</code></li>
+ <li><code>-unsetDefaultMail</code></li>
+ <li><code>-foreground</code></li>
+ <li>GTK options</li>
+</ul>
+
+<h3 id="References" name="References">参考</h3>
+
+<ul>
+ <li><a href="/en/Chrome/Command_Line" title="en/Chrome/Command_Line">Chrome: Command Line</a></li>
+ <li><a class="external" href="http://www-archive.mozilla.org/quality/browser/front-end/testcases/cmd-line/">Test Documentation for Command-line Features</a> (mozilla.org)</li>
+ <li>{{ Source("toolkit/xre/nsAppRunner.cpp") }}</li>
+ <li>{{ Source("browser/components/nsBrowserContentHandler.js") }}</li>
+ <li>{{ Source("suite/browser/nsBrowserContentHandler.js") }}</li>
+ <li>{{ Source("mail/components/nsMailDefaultHandler.js") }}</li>
+ <li><a class="link-https" href="https://wiki.mozilla.org/Installer:Command_Line_Arguments">Installer command line options</a></li>
+</ul>
+
+<div class="originaldocinfo">
+<h2 id="Original_Document_Information" name="Original_Document_Information">原始文档信息</h2>
+
+<ul>
+ <li>Author(s): Ben Goodger, Steffen Wilberg, Seth Spitzer, Daniel Wang</li>
+ <li>Copyright Information: Portions of this content are © 1998–2007 by individual mozilla.org contributors; content available under a Creative Commons license | <a class="external" href="http://www.mozilla.org/foundation/licensing/website-content.html">Details</a>.</li>
+</ul>
+</div>
+
+<p>{{ languages( { "ja": "ja/Command_Line_Options" } ) }}</p>
diff --git a/files/zh-cn/mozilla/connect/index.html b/files/zh-cn/mozilla/connect/index.html
new file mode 100644
index 0000000000..7e75bb5c62
--- /dev/null
+++ b/files/zh-cn/mozilla/connect/index.html
@@ -0,0 +1,122 @@
+---
+title: Mozilla 开发者计划
+slug: Mozilla/Connect
+translation_of: Mozilla/Connect
+---
+<div class="summary">
+<p>采取行动、互相激励并共同协作,使网络成为创建跨联网设备体验的主要平台。</p>
+</div>
+
+<div>
+<div class="column-container dev-program-callouts dev-program-block dev-program-first dev-program-column-wrapper">
+<div class="dev-program-callout">
+<div class="callout-link-container">
+<h2 id="Hacks_blog">Hacks blog</h2>
+
+<p align="left"> 作为网页开发的关键资源,Mozilla Hacks Blog 提供了最新的网络开发技术和浏览器属性,并欢迎大家在此。</p>
+
+<div class="callout-link-wrapper"><a class="callout-link ignore-external" href="https://hacks.mozilla.org/" style="white-space: normal;">马上看看 </a></div>
+</div>
+</div>
+
+<div class="dev-program-callout">
+<div class="callout-link-container">
+<h2 id="反馈渠道">反馈渠道</h2>
+
+<p>你有 <a href="http://mzl.la/devtools">关于开发者工具的好点子</a>? 告诉我们,帮助塑造未来特征!</p>
+
+<p>正在努力,需要帮助?问问Stack Overflow!<br>
+ <span class="smaller"><strong>{{anch("Developer discussions", "Search the Q&amp;A below")}}</strong></span></p>
+
+<div class="callout-link-wrapper"><a class="callout-link ignore-external" href="http://stackoverflow.com/r/mozilla" style="white-space: normal;">Mozilla Q&amp;A on Stack Overflow </a></div>
+</div>
+</div>
+
+<div class="dev-program-callout">
+<div class="callout-link-container">
+<h2 id="MDN上的Hack">MDN上的Hack</h2>
+
+<p>Whether you hack code or text, we have <a href="https://developer.mozilla.org/en-US/docs/MDN/Getting_Started">让你帮助MDN变得更好的办法you can help make MDN better</a>. When you create an MDN profile, you can show off your work here, and get early access to MDN features over time as we roll them out.</p>
+
+<div class="callout-link-wrapper"><a class="callout-link" href="https://developer.mozilla.org/profile/edit" style="white-space: normal;">加入和登录</a></div>
+</div>
+</div>
+</div>
+
+<div class="dev-program-explanation dev-program-block">
+<h2 id="联系Mozilla">联系Mozilla</h2>
+
+<p>开发商为全世界的人们创造未来的建筑服务和应用程序。Mozilla开发者关系的目标是帮助开发人员使用开放标准的Web技术,成功实现自己的目标。除了文件在MDN,我们提供的帮助和其他资源来实现这一目标,通过各种渠道。我们邀请您来连接、学习和分享自己的知识。</p>
+
+<p>我们提供的帮助下通过<a href="http://stackoverflow.com/r/mozilla">Stack Overflow的Q&amp;A</a>解决你可能有的特定技术问题和挑战。我们也有一个简讯让您了解在Web场景周围的Web应用程序的最新动态和更多资讯。<a href="https://marketplace.firefox.com/developers/#newsletter-signup">订阅 Apps &amp; Hacks newsletter</a>。</p>
+
+<p>If you share Mozilla's <a href="https://www.mozilla.org/en-US/mission/">mission</a> and <a href="https://www.mozilla.org/en-US/about/manifesto/">principles</a> and want to help spread them to more developers, check out the ways you can <a href="https://wiki.mozilla.org/Engagement/Developer_Engagement/Technical_Evangelism/Get_Involved">get involved with technical evangelism</a>, and join our <a href="https://lists.mozilla.org/listinfo/evangelism">evangelism discussion group</a>.</p>
+
+<p>我们有很多计划和点子去反复扩展我们的开发者关系,我们希望你也参与我们!因此,<a class="external external-icon" href="http://stackoverflow.com/r/mozilla">在Stack Overflow上关注这个标签</a>,<a class="external external-icon" href="https://hacks.mozilla.org/">订阅这个Hacks博客</a>,和<a href="https://marketplace.firefox.com/developers/#newsletter-signup">订阅邮件</a>!</p>
+
+<h2 id="Join_Mozilla" style="line-height: 30px;"><strong>Join Mozilla</strong></h2>
+
+<p>If you want to go beyond <em>connecting</em> with Mozilla, you can <em>join</em> Mozilla and help realize <a href="https://www.mozilla.org/mission/">Mozilla's mission of building a better Internet</a>. As a developer, you have skills to contribute in many areas, as well as the opportunity to enhance your skills. Mozilla is an open source project, so we "default to open." You can "view source" and contribute to our software development projects, like the Firefox browser for desktop and Android, Firefox OS, and Mozilla's websites. You can become part of an international community and get recognition for your efforts. Here are some of the advantages of contributing to the Mozilla project.</p>
+
+<h3 id="Opportunity_to_learn_something_new"><strong>Opportunity to learn something new </strong></h3>
+
+<div>
+<p>In writing code for an open source project, you may face problems you have not encountered before, which present learning opportunities for you. You can try out new tools and techniques in an open source project. If for example, if you have never done unit testing, and cannot get permission to do so at work then coding for an open source project would be an excellent place to learn more about it. Contributing to open source gives you the opportunity to collaborate with and get to know many people around the world who have similar interests. Moreover, an open source organization like Mozilla has many contributors who can help you in solving problems you encounter. If you're just getting started contributing, you can look for "mentored" bugs, where an experienced contributor has offered to help a newcomer fix them.</p>
+
+<h3 id="What_can_I_get_by_contributing"><strong>What can I get by contributing? </strong></h3>
+
+<p>Exploring many things and gaining recognition in the community -- these are the intangible benefits of contributing to Mozilla. While we can't guarantee specific tangible benefits, many valued contributors receive free Mozilla gear and invitations to Mozilla-related events, and are first in line to be considered for internships. Moreover, your experience in contributing to an open source project might help you find a job. More and more employers of developers are looking at open source contributions. They like to see that you're blogging and contributing to mailing lists, and they like to see you listed as a contributor to an open source project. It may also help with the work experience section of your CV/resumé.</p>
+
+<h3 id="How_you_can_contribute_to_Mozilla"><strong>How you can contribute to Mozilla</strong></h3>
+
+<p>There are many project area for which you can contribute to Mozilla. You can find a current, complete list on the main Mozilla <a href="https://www.mozilla.org/contribute">Get Involved</a> page. Some areas that may interest you as a developer include:</p>
+
+<ul>
+ <li><a href="http://www.whatcanidoformozilla.org/">Coding</a></li>
+ <li><a href="http://www.whatcanidoformozilla.org/">Web development</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/Firefox_OS/Developing_Gaia">Firefox OS</a></li>
+ <li><a href="https://quality.mozilla.org/teams/">QA</a></li>
+ <li><a href="https://wiki.mozilla.org/Marketplace/Contributing/Addons">Add-ons</a></li>
+ <li><a href="https://wiki.mozilla.org/Marketplace/Contributing/Apps">Apps</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/MDN/Getting_started">Developer documentation (here on MDN)</a></li>
+</ul>
+</div>
+</div>
+</div>
+
+<div class="column-container dev-program-block">
+<div class="column-half" id="Developer_discussions">
+<h2 id="Stack_Overflow_上的常见问题解答_查看所有问与答...">Stack Overflow 上的常见问题解答 <a class="heading-link" href="http://stackoverflow.com/r/mozilla">查看所有问与答...</a></h2>
+
+<p>在开发时我们有问与答去讨论挑战和问题,特别是Firefox OS和移动开放的互联网。在堆栈溢出上可用的简单URL <a href="http://stackoverflow.com/r/mozilla">http://stackoverflow.com/r/mozilla</a>.</p>
+
+<div class="stack-form"><label>Search Stack Overflow</label><input></div>
+
+<h3 id="最新常见问题解答主题">最新常见问题解答主题</h3>
+</div>
+
+<div class="column-half dev-program-hacks dev-program-block"> </div>
+</div>
+
+<p class="dev-program-block"><img alt="Developers at a Firefox OS workshop in Madrid." src="https://mdn.mozillademos.org/files/7479/PhonesUp.jpg" style="display: block; height: 359px; margin: 0px auto; max-width: 100%; width: 720px;"></p>
+
+<div class="column-container dev-program-block">
+<div class="column-7 dev-program-events">
+<h2 id="Mozilla_在哪?_在我们的活动页面上查看参加者和详情...">Mozilla 在哪? <a class="heading-link" href="https://developer.mozilla.org/en/events">在我们的活动页面上查看参加者和详情...</a></h2>
+</div>
+
+<div class="column-5">
+<h2 id="其他资源">其他资源</h2>
+
+<ul class="no-bullets">
+ <li><a href="http://www.youtube.com/user/mozhacks">Mozilla Hacks on YouTube</a>
+
+ <ul>
+ <li><a href="http://www.youtube.com/playlist?list=PLo3w8EB99pqIHIUUv08hBCHq1OgPKhdo0">Firefox OS 视频</a></li>
+ <li><a href="http://www.youtube.com/playlist?list=PLo3w8EB99pqLZNY22xKbTEzMfYo9PXAlm">Firefox 开发者工具视频</a></li>
+ </ul>
+ </li>
+ <li><a href="https://twitter.com/mozhacks">@mozhacks on Twitter</a></li>
+</ul>
+</div>
+</div>
diff --git a/files/zh-cn/mozilla/debugging/existing_tools/index.html b/files/zh-cn/mozilla/debugging/existing_tools/index.html
new file mode 100644
index 0000000000..055f003c2b
--- /dev/null
+++ b/files/zh-cn/mozilla/debugging/existing_tools/index.html
@@ -0,0 +1,36 @@
+---
+title: Existing Tools
+slug: Mozilla/Debugging/Existing_Tools
+translation_of: Mozilla/Debugging/Existing_Tools
+---
+<p>下面列出的工具可以帮助你<span class="long_text short_text" id="result_box" lang="zh-CN"><span>调试Firefox中因</span><span>性能和内存引发的</span><span>问题</span></span></p>
+<h2 id="SPS_-_Built-in_profiler">SPS - Built-in profiler</h2>
+<p><a href="/@api/deki/files/6129/=profiler.png" title="profiler.png"><img align="left" alt="profiler.png" class="internal lwrap" src="/@api/deki/files/6129/=profiler.png?size=thumb" style="width: 160px; height: 91px;"></a><strong>描述:</strong> Add-on that runs the built-in profiler, retrieves the data and parses it on a web service, displaying a call tree and a timeline with responsiveness measurements.<br> <strong>用处:</strong> Figuring out where time is being spent in the code / what is hanging Firefox<br> <strong> URL:</strong> <a class="link-https" href="https://github.com/bgirard/Gecko-Profiler-Addon/raw/master/geckoprofiler.xpi" title="https://github.com/bgirard/Gecko-Profiler-Addon/raw/master/geckoprofiler.xpi">geckoprofiler.xpi on GitHub</a><br> <strong> 用法:</strong> After installing the add-on, click on the icon in the Add-ons bar (status bar) to open an widget with Start/Stop and Analyze buttons. More details at <a href="/en/Performance/Profiling_with_the_Built-in_Profiler" title="En/Performance/Profiling_with_the_Built-in_Profiler">Profiling with the built-in profiler</a>. The <a class="external" href="http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-profiling/" title="http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-profiling/">profiling build</a> can be used to get accurate call stacks (currently Mac only).</p>
+<p> </p>
+<h2 id="aboutjank">about:jank</h2>
+<p><a href="/@api/deki/files/6128/=aboutjank.PNG" title="aboutjank.PNG"><img align="left" alt="aboutjank.PNG" class="internal lwrap" src="/@api/deki/files/6128/=aboutjank.PNG?size=webview" style="width: 148px; height: 159px;"></a><strong>描述:</strong> <span class="long_text short_text" id="result_box" lang="zh-CN"><span>运行</span><span>内置的</span><span>分析器</span><span>并将</span><span>检索到的数据显示在</span></span>about:jank页面.<br> <strong>用处:</strong> 找出哪些代码在消耗时间,哪些代码让Firefox运行受阻.<br> <strong> URL:</strong> <a class="link-https" href="https://addons.mozilla.org/en-US/firefox/addon/aboutjank/" title="https://addons.mozilla.org/en-US/firefox/addon/aboutjank/">about:jank AMO下载</a><br> <strong> 用法:</strong> 首次打开about:jank页面激活分析器,然后刷新页面查看分析的数据.</p>
+<p> </p>
+<p> </p>
+<p> </p>
+<h2 id="abouttelemetry">about:telemetry</h2>
+<p><strong><a href="/@api/deki/files/6127/=aboutelemetry.png" title="aboutelemetry.png"><img align="left" alt="aboutelemetry.png" class="internal lwrap" src="/@api/deki/files/6127/=aboutelemetry.png?size=webview" style="width: 160px; height: 124px;"></a></strong><strong>描述:</strong> <span class="long_text short_text" id="result_box" lang="zh-CN"><span>显示</span><span>当前配置文件</span><span>的</span><span>性能数据</span></span>:<span class="long_text short_text" id="result_box" lang="zh-CN"><span>直方图,</span></span>缓慢的SQL语句和启动时间线.<br> <strong>用处:</strong> <span class="long_text short_text" id="result_box" lang="zh-CN"><span>获取</span><span>当前配置文件</span><span>的</span><span>性能数据.</span></span><br> <strong>URL:</strong> <a class="link-https" href="https://addons.mozilla.org/en-US/firefox/addon/abouttelemetry/" title="https://addons.mozilla.org/en-US/firefox/addon/abouttelemetry/">about:telemetry  AMO下载</a><br> <strong>用法:</strong> 确保选项"提交性能数据"已经开启 (选项 -&gt; 高级 -&gt;提交性能数据)然后打开about:telemetry.</p>
+<p> </p>
+<p> </p>
+<h2 id="aboutstartup">about:startup</h2>
+<p><strong><a href="/@api/deki/files/6130/=aboutstartup.PNG" title="aboutstartup.PNG"><img align="left" alt="aboutstartup.PNG" class="internal lwrap" src="/@api/deki/files/6130/=aboutstartup.PNG?size=thumb" style="width: 160px; height: 90px;"></a>描述:</strong> 在about:startup页面显示Firefox的<span class="long_text short_text" id="result_box" lang="zh-CN"><span>启动</span><span>计时</span></span>.<br> <strong>用处:</strong> <span class="long_text short_text" id="result_box" lang="zh-CN"><span>获取</span><span>当前配置文件的</span><span>启动性能</span><span>信息.</span></span><br> <strong> URL:</strong> <a class="link-https" href="https://addons.mozilla.org/en-US/firefox/addon/about-startup/" title="https://addons.mozilla.org/en-US/firefox/addon/about-startup/">about:startup AMO下载</a><br> <strong> 用法:</strong> 安装扩展后打开about:startup.</p>
+<p> </p>
+<p> </p>
+<h2 id="aboutcc">about:cc</h2>
+<p><strong><a href="/@api/deki/files/6126/=aboutcc.PNG" title="aboutcc.PNG"><img align="left" alt="aboutcc.PNG" class="internal lwrap" src="/@api/deki/files/6126/=aboutcc.PNG?size=webview" style="width: 159px; height: 96px;"></a>描述:</strong> Analyzes the cycle collection graphs and helps find leaks (specially documents) and missing CC optimizations.<br> <strong>用处:</strong> 找出内存泄漏的页面.<br> <strong> URL:</strong> <a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=726346" title="https://bugzilla.mozilla.org/show_bug.cgi?id=726346">about:cc bugzilla下载</a><br> <strong> 用法:</strong> 安装该扩展,重启, 打开about:cc.首先点击Run Cycle Collector,然后点击 Find Documents.</p><h2 id="aboutccdump">about:ccdump</h2>
+<p><strong><a href="/@api/deki/files/6125/=aboutccdump.png" title="aboutccdump.png"><img align="left" alt="aboutccdump.png" class="internal lwrap" src="/@api/deki/files/6125/=aboutccdump.png?size=thumb" style="width: 160px; height: 70px;"></a>描述:</strong> More graphical interface to about:cc. Helps analyze cycle collection graphs and finding leaks<br> <strong>用处:</strong> 找出引起内存泄漏的死循环.<br> <strong> URL:</strong> <a href="/en/Submitting_an_add-on_to_AMO" title="Submitting an add-on to AMO">about:ccdump  AMO下载</a><br> <strong> 用法:</strong> 查看 <a class="external" href="http://www.softwareishard.com/blog/planet-mozilla/hunting-zombie-memory-leaks-in-firefox/" title="http://www.softwareishard.com/blog/planet-mozilla/hunting-zombie-memory-leaks-in-firefox/">Jan Odvarko's post</a> 了解更多信息.</p>
+<p> </p>
+<h2 id="aboutnosy">about:nosy</h2>
+<p><strong><a class="external" href="http://www.visophyte.org/blog/wp-content/uploads/2012/02/about-nosy-overview-scaled.png" title="about-nosy-overview-scaled.png"><img align="left" alt="about-nosy-overview-scaled.png" class="lwrap" src="http://www.visophyte.org/blog/wp-content/uploads/2012/02/about-nosy-overview-scaled.png" style="width: 160px; height: 70px;"></a>描述:</strong> <span class="long_text short_text" id="result_box" lang="zh-CN"><span>图形界面的</span><span>jsprobes</span><span>,</span><span>帮助</span><span>分析</span><span>哪个标签</span><span>最消耗资源</span></span>.<br> <strong>用处:</strong> 查看各标签和扩展的内存以及cpu使用情况.<br> <strong> URL:</strong> <a class="link-https" href="https://github.com/asutherland/about-nosy/" title="about:nosy on Github">about:nosy Github下载</a><br> <strong> 用法:</strong> 查看 <a class="external" href="http://www.visophyte.org/blog/2012/02/11/aboutnosy-can-now-show-cpu-usage-using-jsprobes/" title="http://www.visophyte.org/blog/2012/02/11/aboutnosy-can-now-show-cpu-usage-using-jsprobes/">Andrew Sutherland's post</a>获得更多详情. 注意: <a class=" link-https" href="https://clicky.visophyte.org/files/labs/about-nosy/" rel="freelink">https://clicky.visophyte.org/files/labs/about-nosy/</a> 上已有的版本只适合Firefox "Aurora" 12的早期版本使用.</p><h2 id="MemChaser">MemChaser</h2>
+<p><strong><a href="/@api/deki/files/6131/=memchaser.png" title="memchaser.png"><img align="left" alt="memchaser.png" class="internal lwrap" src="/@api/deki/files/6131/=memchaser.png?size=thumb" style="width: 160px; height: 44px;"></a>描述:</strong> 在附加组件栏(状态栏)显示GC/CC和内存使用等信息. 还可以切换内存报告记录.<br> <strong>用处:</strong> 在一个标准的浏览会话里跟踪记录垃圾回收和内存占用等信息<br> <strong> URL:</strong> <a href="/en/Submitting_an_add-on_to_AMO" title="Submitting an add-on to AMO">MemChaser AMO下载</a><br> <strong> 用法:</strong> 安装扩展并打开附加组建栏</p>
+<h2 id="MozRegression">MozRegression</h2>
+<p><strong>描述:</strong> Python script that greatly helps you binary-search a regression bug through the nightly builds by automatically downloading and running each build with a fresh profile.<br> <strong>用处:</strong> Finding the nightly regression range for a bug that you're not sure when was introduced.<br> <strong>URL:</strong> <a class="link-https" href="https://github.com/mozilla/mozregression/" title="https://github.com/mozilla/mozregression/">MozRegression on GitHub</a><br> <strong>用法:</strong> First find a nightly build date that you're sure the problem exists, and one where you're sure it doesn't. Then run <code>mozregression --good=yyyy-mm-dd --bad=yyyy-mm-dd</code> and the script will guide you on finding the regression.</p>
+<p> </p>
+<h2 id="Layout_painting_flash">Layout painting flash</h2>
+<p><strong>描述:</strong> 打开该选项后, Firefox中每次被重绘的元素都会以随机的背景颜色显示出来.<br> <strong>用处:</strong> <span class="long_text short_text" id="result_box" lang="zh-CN"><span>查找</span><span>不必要的</span></span>页面重绘<span class="long_text short_text" id="result_box" lang="zh-CN"><span>或</span><span>失效</span><span>问题</span></span><br> <strong>URL:</strong> 在about:config中将<em>nglayout.debug.paint_flashing</em> 设置为true<br> <strong>用法:</strong> 在about:config页面中配置, 更多信息请参考 <a class="external" href="http://msujaws.wordpress.com/2012/02/01/layout-paint-flashing-in-firefox/" title="http://msujaws.wordpress.com/2012/02/01/layout-paint-flashing-in-firefox/">这篇文章</a>.</p><h2 id="Logging_GCCC_times">Logging GC/CC times</h2>
+<p><strong>描述:</strong> 在错误控制台上显示GC/CC运行的时间.<br> <strong>用处:</strong> 查看垃圾回收/循环回收是否运行太长时间.<br> <strong>URL:</strong> 在about:config中将<em><span class="message">javascript.options.mem.log</span></em> 设置为true<br> <strong>用法:</strong> 在about:config页面中配置, 打开错误控制台查看记录的信息.</p>
+<p>{{ languages( { "en": "en/Debugging/Existing_Tools"} ) }}</p>
diff --git a/files/zh-cn/mozilla/debugging/index.html b/files/zh-cn/mozilla/debugging/index.html
new file mode 100644
index 0000000000..d3c90b5685
--- /dev/null
+++ b/files/zh-cn/mozilla/debugging/index.html
@@ -0,0 +1,139 @@
+---
+title: 调试
+slug: Mozilla/Debugging
+translation_of: Mozilla/Debugging
+---
+<p>Debugging a project as large as Mozilla can be a daunting task. Fortunately, over the years, Mozilla developers have come up with not just technologies and features to help you debug code, but have devised tips and techniques that can help too. Also available are assorted tools that you can use when debugging.</p>
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td colspan="2">
+ <h2 class="Documentation" id="Documentation_topics">Documentation topics</h2>
+ <h2 id="Debugging_on_top_of_the_Mozilla_platform">Debugging on top of the Mozilla platform</h2>
+ <dl>
+ <dt>
+ <a href="/en-US/docs/Debugging_JavaScript" title="Debugging JavaScript">Debugging JavaScript code</a></dt>
+ <dd>
+ How to debug JavaScript code, with a focus on debugging code in the Mozilla project itself.</dd>
+ <dt>
+ <a href="/en-US/docs/Debugging_a_XULRunner_Application" title="Debugging a XULRunner Application">Debugging a XULRunner application</a></dt>
+ <dd>
+ Tips and suggestions that will help you debug your <a href="/en-US/docs/XULRunner" title="XULRunner">XULRunner</a> based application.</dd>
+ <dt>
+ <a href="/en-US/docs/Mozilla/Boot_to_Gecko/Debugging_on_Boot_to_Gecko" title="">Debugging on Boot to Gecko</a></dt>
+ <dd>
+ Debugging Firefox OS (apps and the platform itself)</dd>
+ <dt>
+ <a href="/en-US/docs/Debugging_Update_Problems" title="Debugging Update Problems">Debugging update problems</a></dt>
+ <dd>
+ Learn how to debug update problems in Mozilla-based applications.</dd>
+ </dl>
+ <h2 id="Debugging_the_Mozilla_platform">Debugging the Mozilla platform</h2>
+ <h3 id="Using_debuggers_with_Mozilla">Using debuggers with Mozilla</h3>
+ <dl>
+ <dt>
+ <a href="/en-US/docs/Debugging_Mozilla_on_Windows_FAQ" title="Debugging Mozilla on Windows FAQ">Debugging Mozilla on Windows FAQ</a></dt>
+ <dd>
+ Questions (and answers) about debugging Mozilla on Windows.</dd>
+ <dt>
+ <a href="/en-US/docs/Debugging_on_Mac_OS_X" title="Debugging on Mac OS X">Debugging Mozilla on Mac OS X</a></dt>
+ <dd>
+ Questions (and answers) about debugging Mozilla on Mac OS X.</dd>
+ <dt>
+ <a href="/en-US/docs/Debugging_Mozilla_with_gdb" title="Debugging Mozilla on Linux FAQ">Debugging Mozilla with gdb</a></dt>
+ <dd>
+ gdb is our primary debugger on Mac and Linux.</dd>
+ <dt>
+ <a href="/en-US/docs/Debugging_Mozilla_with_lldb" title="Debugging Mozilla with lldb">Debugging Mozilla with lldb</a></dt>
+ <dd>
+ lldb is the new debugger on Mac.</dd>
+ </dl>
+ <h3 id="Advanced_debugging_techniques">Advanced debugging techniques</h3>
+ <dl>
+ <dt>
+ <a href="/en-US/docs/Debugging_Mozilla_with_Valgrind" title="Debugging Mozilla with valgrind">Debugging Mozilla with valgrind</a></dt>
+ <dd>
+ valgrind is a memory debugger for Mac and Linux. It is slow, but good for tracking down difficult memory safety bugs.</dd>
+ <dt>
+ <a href="/en-US/docs/Debugging/Record_and_Replay_Debugging_Firefox" title="Debugging/Record and Replay Debugging Firefox">Replay debugging Firefox with VMWare Workstation</a></dt>
+ <dd>
+ How to setup record and replay debugging on Firefox, to help debug intermittent mochitest failures.</dd>
+ </dl>
+ <h3 id="Debugging_specific_parts_of_the_Mozilla_codebase">Debugging specific parts of the Mozilla codebase</h3>
+ <dl>
+ <dt>
+ <a href="/en-US/docs/Debugging/Debugging_OpenGL" title="Debugging/Debugging OpenGL">Debugging OpenGL</a> {{gecko_minversion_inline("2.0")}}</dt>
+ <dd>
+ If you're working on code that involves OpenGL calls, and need to debug it, you can turn on a special OpenGL debugging mode.</dd>
+ <dt>
+ <a href="/en-US/docs/Debugging_Frame_Reflow" title="Debugging_Frame_Reflow">Debugging frame reflow</a> and <a href="/en-US/docs/Debugging_Table_Reflow" title="Debugging_Table_Reflow">Debugging table reflow</a></dt>
+ <dd>
+ Notes on debugging issues in Gecko's layout engine.</dd>
+ </dl>
+ <h2 id="Miscellaneous">Miscellaneous</h2>
+ <dl>
+ <dt>
+ <a href="/en-US/docs/Debugging_Safari" title="Debugging Safari">Debugging Safari</a></dt>
+ <dd>
+ Some tips for debugging Safari</dd>
+ <dt>
+ <a href="/en-US/docs/Debugging_Chrome" title="Debugging Chrome">Debugging Chrome</a></dt>
+ <dd>
+ Some tips for debugging Chrome</dd>
+ <dt>
+ <a href="/en-US/docs/Debugging_Internet_Explorer" title="Debugging Internet Explorer">Debugging Internet Explorer</a></dt>
+ <dd>
+ Some tips for debugging Internet Explorer</dd>
+ </dl>
+ </td>
+ <td>
+ <h3 id="Providing_useful_information_to_the_Mozilla_developers">Providing useful information to the Mozilla developers</h3>
+ <dl>
+ <dt>
+ <a href="/en-US/docs/How_to_get_a_stacktrace_for_a_bug_report" title="How_to_get_a_stacktrace_for_a_bug_report">How to get a stacktrace for a bug report</a></dt>
+ <dd>
+ Useful information you can provide about a crash.</dd>
+ <dt>
+ <a href="/en-US/docs/Performance/Reporting_a_Performance_Problem" title="Performance/Reporting_a_Performance_Problem">Reporting a Performance Problem</a></dt>
+ <dd>
+ ...using the Gecko Profiler extension.</dd>
+ <dt>
+ <a href="/en-US/docs/Debugging_a_hang_on_OS_X" title="Debugging a hang on OS X">Debugging a hang on Mac OS X</a></dt>
+ <dd>
+ Collecting "samples" to attach to a bug.</dd>
+ <dt>
+ <a href="/en-US/docs/Remote_debugging" title="Remote_debugging">Remote debugging</a></dt>
+ <dd>
+ Core dumps and examples of remote debugging. Useful if a developer can't reproduce your crash.</dd>
+ <dt>
+ <a href="/en-US/docs/Mozilla/Debugging/HTTP_logging" title="/en-US/docs/Mozilla/Debugging/HTTP_logging">HTTP logging</a></dt>
+ <dd>
+ How to log HTTP network traffic for debugging purposes.</dd>
+ </dl>
+ <h2 class="Tools" id="Debugging_tools">Debugging tools</h2>
+ <dl>
+ <dt>
+ <a href="/en-US/docs/Tools" title="Tools">Tools</a></dt>
+ <dd>
+ Assorted tools that will help you debug your code or web site.</dd>
+ <dt>
+ <a href="http://ftp.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/" title="http://ftp.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/">Download a debug build</a></dt>
+ <dd>
+ Recent automatically compiled debug builds are available. Note that these are replaced frequently by our tinderboxes. The debug builds have "-debug" at the end of their file names.</dd>
+ </dl>
+ <h2 id="Related_topics">Related topics</h2>
+ <dl>
+ <dt>
+ <a href="/en-US/docs/Performance" title="Storage/Performance">Performance and profiling</a></dt>
+ <dd>
+ Troubleshooting performance problems.</dd>
+ <dt>
+ <a href="/en-US/docs/Debugging/Debugging_memory_leaks" title="Debugging memory leaks">Debugging memory leaks</a></dt>
+ <dd>
+ Learn about tools and techniques that will help you debug memory leaks.</dd>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
diff --git a/files/zh-cn/mozilla/developer_guide/adding_apis_to_the_navigator_object/index.html b/files/zh-cn/mozilla/developer_guide/adding_apis_to_the_navigator_object/index.html
new file mode 100644
index 0000000000..8be46c6439
--- /dev/null
+++ b/files/zh-cn/mozilla/developer_guide/adding_apis_to_the_navigator_object/index.html
@@ -0,0 +1,34 @@
+---
+title: Adding APIs to the navigator object
+slug: Mozilla/Developer_guide/Adding_APIs_to_the_navigator_object
+tags:
+ - chenxk@xi'an
+translation_of: Mozilla/Developer_guide/Adding_APIs_to_the_navigator_object
+---
+<p>{{ gecko_minversion_header("9.0") }}</p>
+<p>Gecko 9.0之后 {{ geckoRelease("9.0") }}, 我们可以很容易的利用Category Manager添加新的APIs 到 {{ domxref("window.navigator") }} 对象。简单地添加一个到 "JavaScript-navigator-property" category 的入口。</p>
+<h2 id="在程序中添加对象到navigator">在程序中添加对象到navigator</h2>
+<pre>var categoryManager = Components.classes["@mozilla.org/categorymanager;1"]
+                      .getService(nsICategoryManager);
+
+categoryManager.addCategoryEntry("JavaScript-navigator-property", "myApi",
+                      MY_CONTRACT_ID, false, true);
+</pre>
+<p>这两句添加了一个新的对象, <code>myApi</code>, 到 {{ domxref("window.navigator") }} 对象; 这个新添加的对象是基于由contract ID <span style="font-family: monospace; line-height: 21px;">MY_CONTRACT_ID </span>所制定的组件的。</p>
+<h2 id="使用_manifest_文件添加对象到_navigator">使用 manifest 文件添加对象到 navigator</h2>
+<p>我们也可以使用chrome manifest 文件添加对象到{{ domxref("window.navigator") }} :</p>
+<pre>component {ffffffff-ffff-ffff-ffff-ffffffffffff} MyComponent.js
+contract @mozilla.org/mycomponent;1 {ffffffff-ffff-ffff-ffff-ffffffffffff}
+category JavaScript-navigator-property myComponent @mozilla.org/mycomponent;1
+</pre>
+<p>这样就添加了一个新的 API, <code>myComponent</code>, 到navigator 对象, 然后就可以通过 <code>navigator.myComponent</code>访问到。</p>
+<h2 id="实例">实例</h2>
+<p>通过下面两个文件你可以明白接口 <code>mozApps</code> 的实现:</p>
+<ul>
+ <li>{{ source("dom/base/Webapps.manifest") }}</li>
+ <li>{{ source("dom/base/Webapps.js") }}</li>
+</ul>
+<h2 id="See_also">See also</h2>
+<ul>
+ <li>{{ interface("nsICategoryManager") }}</li>
+</ul>
diff --git a/files/zh-cn/mozilla/developer_guide/customizing_firefox/index.html b/files/zh-cn/mozilla/developer_guide/customizing_firefox/index.html
new file mode 100644
index 0000000000..b19c860926
--- /dev/null
+++ b/files/zh-cn/mozilla/developer_guide/customizing_firefox/index.html
@@ -0,0 +1,9 @@
+---
+title: 自定义 Firefox
+slug: Mozilla/Developer_guide/Customizing_Firefox
+tags:
+ - Firefox
+ - Mozilla
+translation_of: Mozilla/Developer_guide/Customizing_Firefox
+---
+<p><a href="https://support.mozilla.org/zh-CN/products/firefox-enterprise">Firefox 企业版文档 | Firefox 帮助</a></p>
diff --git a/files/zh-cn/mozilla/developer_guide/index.html b/files/zh-cn/mozilla/developer_guide/index.html
new file mode 100644
index 0000000000..4a4f0edd52
--- /dev/null
+++ b/files/zh-cn/mozilla/developer_guide/index.html
@@ -0,0 +1,106 @@
+---
+title: 开发者手册
+slug: Mozilla/Developer_guide
+translation_of: Mozilla/Developer_guide
+---
+<p><span class="seoSummary">有许多方法可以为 Mozilla 项目做出贡献:编码,测试,改进构建过程和工具或为文档做出贡献。 本指南提供的信息不仅可以帮助您以 Mozilla 贡献者的身份入门,而即使您已经是经验丰富的贡献者,本指南也会对您有所帮助。</span></p>
+
+<div class="row topicpage-table">
+<div class="section">
+<h2 class="Documentation" id="文档主题">文档主题</h2>
+
+<dl>
+ <dt><a href="/zh-CN/docs/Introduction" title="Introduction">入门</a></dt>
+ <dd>一步一步引领初学者参与为Mozilla贡献的入门指南。</dd>
+ <dt><a href="/zh-CN/docs/Mozilla/Developer_guide/Articles_for_new_developers">对于新的 Mozilla 开发人员</a></dt>
+ <dd>一个对Mozilla新的开发人员的特别有用的文章目录。</dd>
+</dl>
+
+<dl>
+ <dt><a href="/zh-CN/Developer_Guide/Source_Code" title="zh-CN/Developer_Guide/Source_Code">与 Mozilla 源代码一起工作</a></dt>
+ <dd>一个代码概况、如何获取代码和编码风格的指南。</dd>
+ <dt><a class="internal" href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Developer_guide/Build_Instructions" title="zh-CN/Developer_Guide/Build_Instructions">编译指南</a></dt>
+ <dd>如何编译Firefox、Thunderbird、SeaMonkey或者其他 Mozilla 应用。</dd>
+ <dt><a class="internal" href="/zh-CN/docs/Developer_Guide/Editor_Configuration" title="zh-CN/docs/Developer_Guide/Editor_Configuration">编辑器配置</a></dt>
+ <dd>设置您喜欢的IDE或文本编辑器以此来与Mozilla项目一起工作的提示。</dd>
+ <dt><a href="/zh-CN/docs/Developer_Guide/Development_process_overview" title="zh-CN/docs/Developer Guide/Development process overview">开发过程概要</a></dt>
+ <dd>Mozilla开发过程的概要。</dd>
+ <dt><a href="/zh-CN/docs/Mozilla/Multiple_Firefox_Profiles" title="zh-CN/docs/Mozilla/Multiple_Firefox_Profiles">管理多个配置文件</a></dt>
+ <dd>作业于 Firefox 先行释出的版本时,通常有数个Firefox文件是有帮助的,例如每个通道配置一个文件,或者针对不同的测试有不同的文件。</dd>
+ <dt><a class="internal" href="/zh-CN/Mozilla_automated_testing" title="/Mozilla automated testing">自动测试</a></dt>
+ <dd>如何运行Mozilla的自动测试及如何写新的测试。</dd>
+ <dt><a class="internal" href="/zh-CN/Developer_Guide/How_to_Submit_a_Patch" title="zh-CN/Developer Guide/How to Submit a Patch">添加你的patch到树中</a></dt>
+ <dd>当你的patch完成后,你需要把它添加到树中。这篇文章解释了review过程和如何使你的patch得到支持。</dd>
+ <dt><a class="internal" href="/zh-CN/Mozilla_Modules_and_Module_Ownership" title="zh-CN/Mozilla Modules and Module Ownership">Mozilla模块及模块所有权</a></dt>
+ <dd>这篇文章提供关于Mozilla的模块、模块所有者的角色是什么及模块所有者是怎么选择的。</dd>
+ <dt><a class="internal" href="/zh-CN/Hacking_Firefox" title="zh-CN/Hacking_Firefox">探秘Firefox用户接口</a></dt>
+ <dd>如何加入到Firefox用户接口及前端软件的开发。</dd>
+ <dt><a class="internal" href="/zh-CN/Code_snippets" title="zh-CN/Code snippets">代码片段</a></dt>
+ <dd>与你需要理解如何工作的许多事物相关的有用的代码示例。</dd>
+ <dt><a class="internal" href="/zh-CN/Mozilla_Development_Strategies" title="zh-CN/Mozilla Development Strategies">Mozilla开发策略</a></dt>
+ <dd>关于如何充分利用你的时间参与到Mozilla项目中的提示。</dd>
+ <dt><a class="internal" href="/zh-CN/Debugging" title="zh-CN/Debugging">调试</a></dt>
+ <dd>寻找关于调试Mozilla代码的有帮助的提示和指南。</dd>
+ <dt><a href="/zh-CN/docs/Performance" title="zh-CN/docs/Performance">性能</a></dt>
+ <dd>性能指南和实用程序可帮助您使代码性能良好(并与他人很好地交流)。</dd>
+ <dt><a class="internal" href="/zh-CN/Mozilla_Development_Strategies" title="zh-CN/Mozilla_Development_Strategies">Mozilla平台</a></dt>
+ <dd>关于 Mozilla 平台成果的信息。</dd>
+ <dt><a class="internal" href="https://developer.mozilla.org/zh-CN/docs/Mozilla">Mozilla</a></dt>
+ <dd>有关Mozilla编码实践的更多其他信息。</dd>
+ <dt><a href="/zh-CN/docs/Developer_Guide/Adding_APIs_to_the_navigator_object" title="zh-CN/docs/Developer_Guide/Adding_APIs_to_the_navigator_object">将API添加到navigator对象</a> {{ gecko_minversion_inline("9.0") }}</dt>
+ <dd>如何和扩展API扩大{{ domxref("window.navigator") }}对象。</dd>
+ <dt><a class="internal" href="/zh-CN/Developer_Guide/Interface_Compatibility" title="zh-CN/Developer Guide/Interface Compatibility">接口兼容性 </a></dt>
+ <dd>关于修改Mozilla中脚本的和二进制的应用程序接口的准则。</dd>
+</dl>
+
+<dl>
+ <dt><a href="/zh-CN/docs/Developer_Guide/Customizing_Firefox" title="zh-CN/docs/Developer Guide/Customizing Firefox">自定义Firefox</a></dt>
+ <dd>有关创建Firefox的自定义版本的信息。</dd>
+ <dt><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Task_graph" title="zh-CN/docs/Developer Guide/Customizing Firefox">Task-Graph生成</a></dt>
+ <dd>是什么控制在推送到版本控制上运行的工作?你能怎么改变呢?</dd>
+ <dt><a href="/zh-CN/docs/Developer_Guide/Virtual_ARM_Linux_environment" title="Virtual ARM Linux environment">虚拟ARM Linux环境</a></dt>
+ <dd>如何设置运行Linux的ARM仿真器以测试特定于ARM的(但不一定特定于平台的)代码。对移动开发人员特别有用</dd>
+ <dt><a href="/zh-CN/docs/Introduction/Obsolete_Build_Caveats_and_Tips" title="Obsolete Build Caveats and Tips">过时的构建警告和技巧</a></dt>
+ <dd>一个放置构建提示的地方,该构建提示不再与从main构建最新版本的代码相关,而在构建旧代码库时相关。</dd>
+ <dt><a href="https://firefox-source-docs.mozilla.org/">Firefox源文档</a></dt>
+ <dd>由mozilla-central源代码构建的Web托管文档。</dd>
+</dl>
+</div>
+
+<div class="section">
+<h2 id="工具">工具</h2>
+
+<dl>
+ <dt><a class="link-https" href="https://bugzilla.mozilla.org/" title="https://bugzilla.mozilla.org/">Bugzilla</a></dt>
+ <dd><a class="internal" href="/zh-CN/docs/Bugzilla">Bugzilla</a>数据库用来跟踪Mozilla项目的相关事件。</dd>
+ <dt><a href="https://dxr.mozilla.org/">DXR</a></dt>
+ <dd>下一代搜索Mozilla的源代码。在积极开发中。</dd>
+ <dt><a href="https://searchfox.org/">SearchFox</a></dt>
+ <dd>Mozilla代码搜索的另一种选择。索引JS以及C ++都包含blame功能。在积极开发中。</dd>
+ <dt><a class="internal" href="/zh-CN/docs/Mercurial" title="zh-CN/docs/Mercurial">Mercurial</a></dt>
+ <dd>用于管理Mozilla的源代码的分布式版本控制系统。</dd>
+ <dt><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Developer_guide/Using_the_VM">Mozilla构建VM</a></dt>
+ <dd>与VirtualBox兼容的虚拟机,配置了在Firefox上构建和工作所需的所有软件。</dd>
+ <dt><a class="external" href="http://bonsai.mozilla.org/cvsqueryform.cgi" rel="external nofollow" title="http://bonsai.mozilla.org/cvsqueryform.cgi"><font color="#0479a7">Bonsai</font></a></dt>
+ <dd><a class="internal" href="/en/Bonsai" rel="internal">Bonsai</a>工具帮助你找到谁在何时对代码库进行了什么修改。</dd>
+ <dt><a class="external" href="https://docs.taskcluster.net">TaskCluster</a></dt>
+ <dd>TaskCluster是支持Mozilla持续集成和发布过程的任务执行框架。</dd>
+ <dt><a class="external" href="https://treeherder.mozilla.org/">Treeherder</a></dt>
+ <dd>Treeherder显示树的状态(无论当前是否成功构建)。在签入和签出之前检查此项,以确保您使用的是工作树。</dd>
+ <dt><a href="https://treeherder.mozilla.org/perf.html">Perfherder</a></dt>
+ <dd>Perfherder用于汇总针对树的自动性能测试的结果。</dd>
+ <dt><a class="internal" href="/zh-CN/docs/Crash_reporting" title="zh-CN/docs/Crash reporting">崩溃跟踪</a></dt>
+ <dd>Information about the <a class="link-https" href="https://crash-reports.mozilla.com/reports">Socorro</a> 崩溃报告系统。</dd>
+ <dt><a href="/zh-CN/docs/Developer_Guide/Callgraph" title="zh-CN/docs/Developing Mozilla/Callgraph">Callgraph</a></dt>
+ <dd>通过自动生成调用图来帮助执行Mozilla代码的静态分析的工具。</dd>
+ <dt><a class="external" href="http://www.mozilla.org/community/developer-forums.html" rel="external nofollow" title="http://www.mozilla.org/community/developer-forums.html">开发者论坛</a></dt>
+ <dd>一个有针对性主题的论坛。在这里你可以讨论开发的各种事件。</dd>
+ <dt><a class="external" href="https://web.archive.org/web/20160813112326/http://www.codefirefox.com:80/cheatsheet">Mozilla平台开发备忘单</a> (archive.org)</dt>
+ <dd>Brian Bondy的平台开发人员常用信息列表。 Brian Bondy <a href="https://brianbondy.com/blog/173/shutting-down-code-firefox">记下了</a> codefirefox.com,但存档的备忘单可能仍然有用。</dd>
+ <dt><a class="external" href="http://www.codefirefox.com/videos/">Firefox开发视频教程</a></dt>
+ <dd>Brian Bondy的有关Firefox开发的视频教程。</dd>
+</dl>
+</div>
+</div>
+
+<p>{{ languages( { "en": "En/Developer_Guide", "ja": "ja/Developer_Guide" } ) }}</p>
diff --git a/files/zh-cn/mozilla/developer_guide/source_code/cvs/index.html b/files/zh-cn/mozilla/developer_guide/source_code/cvs/index.html
new file mode 100644
index 0000000000..30cd759598
--- /dev/null
+++ b/files/zh-cn/mozilla/developer_guide/source_code/cvs/index.html
@@ -0,0 +1,192 @@
+---
+title: 通过CVS获取源码
+slug: Mozilla/Developer_guide/Source_Code/CVS
+tags:
+ - Build documentation
+ - 所有分类
+translation_of: Mozilla/Developer_guide/Source_Code/CVS
+---
+<div class="breadcrumbs"><a href="/cn" title="cn">首页</a>&gt; <a href="/cn/%E7%BC%96%E8%AF%91%E6%89%8B%E5%86%8C" title="cn/编译手册">编译手册</a>&gt; 通过CVS获取源码</div>
+
+<div class="breadcrumbs"> </div>
+
+<div class="breadcrumbs">注:本文档,描述如何获得源代码早起版本的代码,Gecko 1.9.0,Firefox 3或更早,和早起版本的NSS NSPR。<br>
+开发者版本1.9.1/Firefox 3.5,使用 <a class="internal" href="/cn/通过Mercurial获取源码" title="En/Developer Guide/Source Code/Mercurial">Mercurial</a> source 代码控制系统的NSS NSPR最新版本。</div>
+
+<p> </p>
+
+<p>那些活跃的开发者可以使用CVS来查看最新的源代码。如果你计划提供补丁和修复bug这是你的首选,因为它可以让你得到最新的更新并且作为你自己的。</p>
+
+<p>如果你想编译发布一款产品,一般最好<a href="/cn/Download_Mozilla_Source_Code" title="源代码">下载Mozilla源代码</a>。</p>
+
+<h3 id="Getting_Started" name="Getting_Started">开始</h3>
+
+<div><span id="ouHighlight__0_2TO0_2">CVS</span><span id="noHighlight_0.006101604173799902"> 是</span><span id="ouHighlight__4_8TO5_5">指</span><span id="ouHighlight__10_20TO6_8">"并发</span><span id="ouHighlight__22_31TO9_12">版本控制</span><span id="ouHighlight__33_39TO13_14">系统</span><span id="ouHighlight__40_40TO15_16">"。</span><span id="ouHighlight__42_49TO17_18">要想了解</span><span class="highlight" id="ouHighlight__51_54TO19_20">更多</span><span id="ouHighlight__56_60TO21_22">关于</span><span id="noHighlight_0.3904859264576983"> </span><span id="ouHighlight__62_64TO24_26">CVS</span><span id="noHighlight_0.02617727506384604">  </span><span id="ouHighlight__66_67TO28_28">的</span><span id="ouHighlight__69_75TO29_30">通用性</span><span id="ouHighlight__76_76TO34_34">,</span><span id="ouHighlight__78_82TO35_36">欢迎访问</span><span id="noHighlight_0.7504795543601643"> </span><a class="external" href="http://ximbiot.com/cvs/manual/">ximbiot.com</a><span id="ouHighlight__95_95TO49_49">,</span><span id="ouHighlight__97_98TO50_50">或</span><span id="ouHighlight__100_103TO51_52">阅读</span><a class="external" href="/zh-CN/docs/Web/Tutorials">教程</a><span id="noHighlight_0.44247972506917965">。</span></div>
+
+<p> </p>
+
+<p>任何人都可以通过 CVS的源代码来Check out (也被称为"拉取"或"下载") ,但只有某些人可信任的人能Check in (进行更改,也被称为"提交")。这些人是<a href="http://www.mozilla.org/owners.html">模块所有者</a>和他们的代表。阅读我们 <a class="external" href="http://www.mozilla.org/hacking/">hacking mozilla</a>  的文档了解如何获得录入信任。同时你也不妨阅读有关<a class="external" href="http://www.mozilla.org/cvs-ssh-faq.html">使用 SSH 连接到 CVS</a>。</p>
+
+<div class="InnerControlsContainer" id="OutputControlsInnerContainer">
+<div class="zh-CHS" id="OutputArea" style="direction: ltr; text-align: left;">
+<div class="Wrap" id="OutputText" style="direction: ltr; text-align: left;">
+<div><span id="ouHighlight__0_4TO0_1">尽管</span><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Developer_guide/Source_Code/CVS#Full_CVS_Checkout">完整的 CVS Checkout</a><span id="ouHighlight__29_32TO12_12">也</span><span id="ouHighlight__26_27TO13_13">是</span>可行<span id="noHighlight_0.23447154538345538">的</span><span id="ouHighlight__44_45TO17_17">但并</span><span id="ouHighlight__50_52TO18_18">不推荐</span><span id="ouHighlight__65_65TO21_21">;</span><span id="noHighlight_0.898978494462116"> </span><span id="ouHighlight__95_101TO25_31">mozilla</span><span id="noHighlight_0.004147883966893695"> </span><span id="ouHighlight__103_105TO33_35">cvs</span><span id="noHighlight_0.5887991782855997"> </span><span id="ouHighlight__107_112TO37_39">服务器</span><span id="noHighlight_0.3493855925398275">上</span><span id="ouHighlight__75_79TO42_44">不应有</span><span id="ouHighlight__81_86TO46_47">压力</span><span id="ouHighlight__115_117TO48_48">,</span><span id="ouHighlight__119_124TO51_52">应完全</span><span id="ouHighlight__136_142TO53_54">避免</span><span id="noHighlight_0.49436219439103335">,</span><span id="ouHighlight__144_149TO56_57">除非</span><span id="ouHighlight__151_153TO58_58">你</span><span id="ouHighlight__155_158TO59_60">知道</span><span id="ouHighlight__165_167TO61_61">你</span><span id="ouHighlight__169_171TO62_63">正在</span><span id="ouHighlight__173_177TO64_64">做什么</span><span id="noHighlight_0.9103636369103666">的</span><span id="ouHighlight__180_182TO66_66">和你真正</span><span id="ouHighlight__184_187TO67_68">需要</span><span id="ouHighlight__189_191TO69_69">它</span><span id="noHighlight_0.9572012512895453">。</span></div>
+</div>
+</div>
+</div>
+
+<h4 id="Requirements" name="Requirements"> </h4>
+
+<h4 id="Requirements" name="Requirements"><span class="highlight" id="ouHighlight__0_11TO0_1">要求</span></h4>
+
+<p>要Check out源代码,您需要运行 <a class="external" href="http://www.nongnu.org/cvs/">CVS</a> 1.11 或更高版本。1.12.13版本无法和CVS 服务器一起使用,反而导致挂起,虽然 1.12.9 已知工作正常。此外,您必须使用 <a class="external" href="http://www.gnu.org/software/make/">GNU make</a> 来Check out和建立 Mozilla。没有其他"make"是程序可以接受的。在 windows、 mac 和周期性的 GNU 系统 (如 GNU/Linux),使用"make"来运行 GNU make;对大多数非 GNU unix (像例如 Solaris, etc.),使用"gmake"。</p>
+
+<h3 id="CVS_Client_Settings" name="CVS_Client_Settings">CVS <span id="ouHighlight__4_9TO4_6">客户端</span><span id="ouHighlight__11_18TO7_8">设置</span></h3>
+
+<p><span id="ouHighlight__4_12TO0_8">"Cvsroot"</span><span id="ouHighlight__14_24TO9_9">(存储库</span><span id="ouHighlight__26_39TO13_14">标识</span><span id="ouHighlight__41_47TO15_18">字符串)</span><span id="noHighlight_0.42411573837951677"> </span><span id="ouHighlight__49_56TO20_21">用于</span><span id="ouHighlight__58_66TO22_23">匿名</span><span id="ouHighlight__68_73TO24_25">访问</span><span id="noHighlight_0.08293482149776588"> </span><span id="ouHighlight__78_84TO27_33">Mozilla</span><span id="noHighlight_0.5289142812629902"> </span><span class="highlight" id="ouHighlight__86_88TO35_37">CVS</span></p>
+
+<pre class="eval">:pserver:<a class="link-mailto" href="mailto:anonymous@cvs-mirror.mozilla.org" rel="freelink">anonymous@cvs-mirror.mozilla.org</a>:/cvsroot
+</pre>
+
+<div class="zh-CHS" id="OutputArea" style="direction: ltr; text-align: left;">
+<div class="Wrap" id="OutputText" style="direction: ltr; text-align: left;">
+<div><span id="ouHighlight__3_7TO1_2">开始</span><span id="ouHighlight__9_13TO3_4">使用</span><span id="noHighlight_0.4494873625160599"> </span><span id="ouHighlight__15_17TO7_9">CVS</span><span id="noHighlight_0.8497840591303994"> 前</span><span id="ouHighlight__19_21TO11_11">你</span><span id="ouHighlight__28_32TO14_15">首先要</span><span id="ouHighlight__34_36TO16_17">登录</span><span id="noHighlight_0.6510822178000212">。</span><span id="ouHighlight__42_44TO19_20">运行</span><span id="ouHighlight__50_58TO21_22">以下</span><span id="ouHighlight__60_66TO23_24">命令</span><span id="noHighlight_0.07365615678397897">:</span></div>
+</div>
+</div>
+
+<pre class="eval">$ cvs -d :pserver:<a class="link-mailto" href="mailto:anonymous@cvs-mirror.mozilla.org" rel="freelink">anonymous@cvs-mirror.mozilla.org</a>:/cvsroot login
+# type the password <em>anonymous</em>
+</pre>
+
+<p><span id="ouHighlight__0_1TO0_1">如果</span><span id="ouHighlight__3_5TO2_2">您</span><span id="ouHighlight__11_15TO3_4">使用</span><span id="noHighlight_0.44859764876350694">的</span><span id="ouHighlight__17_18TO6_6">是</span><span id="noHighlight_0.10028503295802516"> </span><span id="ouHighlight__20_22TO8_10">IDE</span><span id="ouHighlight__23_23TO11_11">,</span><span id="ouHighlight__25_27TO12_13">使用</span><span class="highlight" id="ouHighlight__33_41TO14_15">以下</span><span id="ouHighlight__43_48TO16_18">服务器</span><span id="ouHighlight__50_53TO19_20">数据</span><span id="noHighlight_0.23928851291086273">:</span></p>
+
+<ul>
+ <li><strong>host</strong>: "cvs-mirror.mozilla.org"</li>
+ <li><strong>repository path</strong>: "/cvsroot"</li>
+ <li><strong>user</strong>: "anonymous"</li>
+ <li><strong>password</strong>: "anonymous"</li>
+ <li><strong>connection type</strong>: pserver</li>
+ <li><strong>port</strong>: default (2401)</li>
+</ul>
+
+<h3 id="Selecting_a_Project_to_Pull" name="Selecting_a_Project_to_Pull">选择一个项目进行拉取</h3>
+
+<p>由于多种不同的应用都基于相同的源代码,您必须通过 <code>MOZ_CO_PROJECT 变量</code>选择对何种应用进行 checkout。当 checkout 真正的源代码时,这一信息(<code>MOZ_CO_PROJECT</code>)是必需的(详见下面对应于您想要checkout的分支的 <a href="#Checkout">checkout</a> 部分)。允许的(<code>MOZ_CO_PROJECT</code>)选项有:</p>
+
+<dl>
+ <dt>browser </dt>
+ <dd>独立的 "Firefox" 浏览器。</dd>
+ <dt>mail </dt>
+ <dd>独立的 "Thunderbird" 邮件/新闻客户端。</dd>
+ <dt>suite </dt>
+ <dd>传统的 "Mozilla" SeaMonkey 套件,包括 browser, mail/news, composer 和其他应用。</dd>
+ <dt>minimo </dt>
+ <dd>独立的针对小型设备的浏览器。</dd>
+ <dt>composer </dt>
+ <dd>独立的 HTML 编辑器。</dd>
+ <dt>calendar </dt>
+ <dd>独立的 "Sunbird" 日历应用。</dd>
+ <dt>xulrunner </dt>
+ <dd>下一代的XUL应用启动器。</dd>
+ <dt>macbrowser </dt>
+ <dd>针对 Macintosh 的 "Camino" 本地浏览器。</dd>
+ <dt>all </dt>
+ <dd>Check out 以上所有的项目,以及一些附加组件的代码。</dd>
+</dl>
+
+<p>选择多项项目可以用逗号分隔:<code>MOZ_CO_PROJECT=suite,browser,xulrunner</code>.</p>
+
+<p><strong>注意</strong>如果您正在使用一个用户自定义的 <code><a href="/cn/%E9%85%8D%E7%BD%AE%E7%BC%96%E8%AF%91%E9%80%89%E9%A1%B9#Using_a_.mozconfig_Configuration_File" title="cn/配置编译选项#Using_a_.mozconfig_Configuration_File">.mozconfig</a> </code>文件,您也可以在这一文件中注明 <code>MOZ_CO_PROJECT 设置,而无需在命令行中添加 MOZ_CO_PROJECT。</code></p>
+
+<h3 id="Checking_Out_a_New_Source_Tree" name="Checking_Out_a_New_Source_Tree">Checking Out 一个新的源代码树</h3>
+
+<h4 id="Check_Tinderbox" name="Check_Tinderbox">检查 Tinderbox</h4>
+
+<p>在拉取一个代码树之前,您应该检查相应的Tinderbox来确保代码库的完整性。如果存在红色的tinderboxes,我们总是建议您在等到它们变为绿色后,再进行拉取。</p>
+
+<h4 id="Branch_HEAD" name="Branch_HEAD">HEAD 分支</h4>
+
+<p>为了从头开始 check out 一个新的源代码树,需要首先拿到 <code>client.mk 文件。这个文件含有</code>使用 makefile 对剩余的源代码树进行拉取的说明<font face="Consolas, Liberation Mono, Courier, monospace">:</font></p>
+
+<pre><code>$ cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/client.mk</code></pre>
+
+<p>注意:如果您已经设置了一个 <code><a href="https://developer.mozilla.org/cn/%E9%85%8D%E7%BD%AE%E7%BC%96%E8%AF%91%E9%80%89%E9%A1%B9#Using_a_.mozconfig_Configuration_File" title="cn/配置编译选项#Using_a_.mozconfig_Configuration_File">.mozconfig</a></code> 文件,您仍将需要 check out 以下文件:</p>
+
+<dl>
+ <dt>Firefox </dt>
+ <dd>
+ <pre><code>cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/browser/config/mozconfig</code></pre>
+ </dd>
+ <dt>Thunderbird </dt>
+ <dd>
+ <pre><code>cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/mail/config/mozconfig</code></pre>
+ </dd>
+</dl>
+
+<h4 id="Specific_Branch" name="Specific_Branch">特定分支</h4>
+
+<p>如果您想要 check out 一个特定 <a href="http://ximbiot.com/cvs/wiki/index.php?title=CVS--Concurrent_Versions_System_v1.12.12.1:_Branching_and_merging">CVS </a>分支的源代码,使用</p>
+
+<pre><code>$ cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co -r BRANCH mozilla/client.mk</code></pre>
+
+<p>例如,在拉取 Firefox 1.5 development 分支时,需要用 MOZILLA_1_8_BRANCH 替换上面的 BRANCH。在 <a href="https://developer.mozilla.org/cn/CVS_Tags" title="cn/CVS_Tags">CVS Tags</a> 中可以查看 Mozilla 中可用的分支标签。</p>
+
+<p>当然前面提供的拉取特定项目的 <code>.mozconfig</code> 文件的方法对除 HEAD 外的分支同样适用。</p>
+
+<h4 id="Checkout" name="Checkout">Checkout</h4>
+
+<p>在选定正确的分支后,运行:</p>
+
+<pre><code>$ cd mozilla
+$ make -f client.mk checkout MOZ_CO_PROJECT=option,option</code></pre>
+
+<p>上面已经提到,如果您正在适用已经注明了 <code>MOZ_CO_PROJECT</code> 变量的 <code>.mozconfig 文件,无需在命令行中重复注明。</code></p>
+
+<h4 id="Specific_Time" name="Specific_Time">特定时刻</h4>
+
+<p>如果您想要 check out 源代码在某一特定时刻的状态,您可以使用 MOZ_CO_DATE 变量。例如 <code>MOZ_CO_DATE="20 Oct 2006 17:00 PDT"。</code></p>
+
+<p>这一说明可以加入 <code><a href="https://developer.mozilla.org/en/Configuring_Build_Options#Using_a_.mozconfig_Configuration_File" title="en/Configuring_Build_Options#Using_a_.mozconfig_Configuration_File">.mozconfig</a></code> 文件中,或者可以在命令行注明,例如</p>
+
+<pre><code>$ cd mozilla
+$ make -f client.mk checkout MOZ_CO_DATE="20 Oct 2006 17:00 PDT" MOZ_CO_PROJECT=option,option</code></pre>
+
+<h3 id="Updating_a_Source_Tree" name="Updating_a_Source_Tree">将源代码树变更至另一个分支</h3>
+
+<h4 id="Branch_HEAD_2" name="Branch_HEAD_2">HEAD 分支</h4>
+
+<p>更新一个源代码树(无论是 HEAD 分支还是一个特定的分支)至最新的 HEAD 分支,运行:</p>
+
+<pre><code>$ cd mozilla
+$ cvs up -A client.mk</code></pre>
+
+<p>-A 选择项会删除任何“黏性分支” ("sticky branch")信息,从而达到更新至 HEAD 分支的效果。</p>
+
+<h4 id="Specific_Branch_2" name="Specific_Branch_2">特定分支</h4>
+
+<p>更新一个从某一特定分支拉取来的源代码树,首先使用</p>
+
+<pre><code>$ cd mozilla
+$ cvs up -r BRANCH client.mk</code></pre>
+
+<p>将 BRANCH 替换为您想要更新的分支的标签。</p>
+
+<h3 id="Updating_a_Source_Tree" name="Updating_a_Source_Tree">更新一个源代码树</h3>
+
+<p>只需使用以下方法即可更新您的代码树:</p>
+
+<pre><code>$ make -f client.mk checkout MOZ_CO_PROJECT=option,option</code></pre>
+
+<p>同样地,如果您使用了 <code>MOZ_CO_PROJECT</code> 已被定义的用户自定义 <code>.mozconfig</code> 文件,无需在命令行中重复注明。</p>
+
+<h3 id="Creating_a_Diff_File" name="Creating_a_Diff_File">创建一个 Diff 文件</h3>
+
+<p>为一个与当前知识库(repository)中相应文件不同的单一本地文件创建 diff,使用:</p>
+
+<pre><code>$ cvs diff -u8p FILENAME</code></pre>
+
+<p>更多信息可以查看 <a href="https://developer.mozilla.org/cn/Creating_a_patch" title="cn/Creating_a_patch">Creating a patch</a>。</p>
+
+<h3 id="Converting_a_Downloaded_Source_Tree" name="Converting_a_Downloaded_Source_Tree">转换一个已下载的源代码树</h3>
+
+<p>与普通的 checkout 相同,从 mozilla.org (<a href="https://developer.mozilla.org/cn/Download_Mozilla_Source_Code" title="cn/Download_Mozilla_Source_Code">source tarballs</a>) 下载的源代码树已经被设置了 CVS 信息。您可以像普通的源代码树一样更新这些树至最新代码,无需多余操作。有关如何更新源代码树的内容请查看前述章节。</p>
diff --git a/files/zh-cn/mozilla/developer_guide/source_code/index.html b/files/zh-cn/mozilla/developer_guide/source_code/index.html
new file mode 100644
index 0000000000..7e23f93adf
--- /dev/null
+++ b/files/zh-cn/mozilla/developer_guide/source_code/index.html
@@ -0,0 +1,48 @@
+---
+title: 与Mozilla源代码一起工作
+slug: Mozilla/Developer_guide/Source_Code
+translation_of: Mozilla/Developer_guide/Source_Code
+---
+<p>本文将会帮助你找到Mozilla源代码、学会浏览代码及如何把你建议的改变放到代码树中。</p>
+
+<p> </p>
+
+<table class="mainpage-table">
+ <tbody>
+ <tr>
+ <td colspan="2">
+ <h2 id="文档话题">文档话题</h2>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <dl>
+ <dt><a class="internal" href="/En/Developer_Guide/Source_Code/Mercurial" title="En/Mozilla Source Code (Mercurial)">从Mercurial存储库获取代码</a></dt>
+ <dd>如果您打算为Mozilla项目做出贡献,获取代码的最佳方式是从版本控制存储库中检查出来。 在这里学习如何做到这一点。</dd>
+ <dt><a class="internal" href="/En/Developer_Guide/Source_Code/Downloading_Source_Archives" title="En/Mozilla Source Code (HTTP//FTP)">使用HTTP或FTP下载代码</a></dt>
+ <dd>如果您想获取特定Mozilla产品特定版本的代码,您可能更愿意下载源代码档案。</dd>
+ <dt><a class="internal" href="/en/Viewing_and_searching_Mozilla_source_code_online" title="En/Viewing and searching Mozilla source code online">在线查看和搜索Mozilla源代码</a></dt>
+ <dd>了解如何使用MXR,Mozilla的在线搜索和浏览工具来访问源代码。 这不是下载代码的好方法,但它是搜索它的好方法。</dd>
+ <dt><a class="internal" href="/en/Mozilla_Source_Code_Directory_Structure" title="en/Mozilla Source Code Directory Structure">浏览Mozilla源代码</a></dt>
+ <dd>了解Mozilla源代码树中的各种文件夹,以及如何找到您要找的内容。</dd>
+ <dt><a class="external" href="http://www.mozilla.org/contribute/hacking/first-bugs/" title="http://www.mozilla.org/contribute/hacking/first-bugs/">Good First Bugs</a></dt>
+ <dd>如果你对这个项目不熟悉,并且想要一些工作,请看这里。</dd>
+ </dl>
+ </td>
+ <td>
+ <dl>
+ <dt><a class="internal" href="/En/Developer_Guide/Coding_Style" title="En/Mozilla Coding Style Guide">Mozilla编码风格指南</a></dt>
+ <dd>代码风格指南提供了有关如何格式化源代码的信息,以确保您不会被审阅者嘲笑。</dd>
+ <dt><a class="link-https" href="https://wiki.mozilla.org/Build:TryServer" title="https://wiki.mozilla.org/Build:TryServer">Try Servers</a></dt>
+ <dd>Mozilla产品至少建立在三个平台上。 如果您没有全部访问权限,则可以使用服务器来测试您的修补程序并确保测试通过。</dd>
+ <dt><a class="internal" href="/en/Creating_a_patch" title="En/Creating a patch">创建一个补丁</a></dt>
+ <dd>一旦你修改了Mozilla代码,下一步(在确定它能运行之后)就创建一个补丁并提交它进行审查。 这篇文章需要完全更新为Mercurial。</dd>
+ <dt><a class="external" href="http://www.mozilla.org/hacking/committer/" title="http://www.mozilla.org/hacking/committer/">获取对源代码的提交访问权限</a></dt>
+ <dd>感觉准备加入少数,骄傲的提议者? 了解如何获取Mozilla代码的签入访问权限。</dd>
+ <dt><a class="internal" href="/En/Developer_Guide/Source_Code/CVS" title="En/Mozilla Source Code (CVS)">从CVS获取较旧的Mozilla代码</a></dt>
+ <dd>较旧版本的Mozilla源代码以及当前版本的NSS和NSPR都保存在CVS存储库中。 在本文中了解这一点。</dd>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
diff --git a/files/zh-cn/mozilla/developer_guide/source_code/latestpassingsource/index.html b/files/zh-cn/mozilla/developer_guide/source_code/latestpassingsource/index.html
new file mode 100644
index 0000000000..a425401edd
--- /dev/null
+++ b/files/zh-cn/mozilla/developer_guide/source_code/latestpassingsource/index.html
@@ -0,0 +1,22 @@
+---
+title: Latest Source Passing Tests
+slug: Mozilla/Developer_guide/Source_Code/LatestPassingSource
+translation_of: Mozilla/Developer_guide/Source_Code/LatestPassingSource
+---
+<p>This is a supplement to <a class="internal" href="/En/Developer_Guide/Source_Code/Mercurial" title="En/Developer Guide/Source Code/Mercurial">the  general instructions for obtaining Mozilla source code</a>.</p>
+<p>You can look at <a class="external" href="http://tbpl.mozilla.org/" title="http://tbpl.mozilla.org/">tinderboxpushlog</a> to see how green the tree is, though often there are known random failures in play so it can be tricky to identify exactly how good the build is. But in general if it isn't burning it should be mostly usable.</p>
+<p>On the left hand, you see pushlogs, which means one or more changeset(s) pushed at once.  On the right, you see the results of the tinderbox machines associated with that pushlog.  Each letter shows a machine status type.  Here's a short glossary (tooltips available on hovering the letters):<br>
+ <br>
+ B - Build<br>
+ M - Mochitest<br>
+ R - Reftest<br>
+ J - JSReftest<br>
+ T - Talos (performance tests)<br>
+ S - Static analysis tests<br>
+ <br>
+ For each pushlog, you can check whether all of the letters associated with it on all platforms are green or not.  Having them all green is a sign of a healthy changeset to pull.  Some failures might be intermittent (or due to machine issues, etc), which are (hopefully) starred.</p>
+<p>You should note that once you find a healthy pushlog changeset ID, you need to pull its topmost changeset.</p>
+<p>In case you only care about one platform: "WINNT 5.1" means Windows XP, "WINNT 5.2" means Windows Server 2003, and "WINNT 6.1" means Windows 7. The Mac OS X 10.5 machines test 32-bit; the 10.6 machines test 64-bit.</p>
+<p>If for example you see that revision 531f60d6cf88 is good enough, you should do the following locally and start a build:</p>
+<pre>hg pull
+hg up 531f60d6cf88</pre>
diff --git a/files/zh-cn/mozilla/firefox/australis_add-on_compat/index.html b/files/zh-cn/mozilla/firefox/australis_add-on_compat/index.html
new file mode 100644
index 0000000000..0f0031c0f1
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/australis_add-on_compat/index.html
@@ -0,0 +1,130 @@
+---
+title: Australis and add-on compatibility
+slug: Mozilla/Firefox/Australis_add-on_compat
+tags:
+ - 扩展
+translation_of: Mozilla/Firefox/Australis_add-on_compat
+---
+<div>{{FirefoxSidebar}}</div>
+
+<h2 id="扩展程序的改变">扩展程序的改变</h2>
+
+<p><strong>我们已经移除了扩展程序的工具栏(包括状态栏)。</strong>您不应再依赖它的存在。已有一个填隙片会尝试迁移您的图标,但它可能不起作用或只能部分起作用。 最好的解决方案是更改按钮的位置。 这也许是一个很好的时机去考虑您的扩展程序是否真的需要在默认情况下对所有用户可见的工具栏按钮。<strong>使用扩展程序SDK开发的扩展程序不需要注意这次改变。</strong></p>
+
+<p><strong>我们已经移除了应用(Firefox)菜单。</strong> 取而代之的是一个<strong>新的基于面板的菜单</strong>,可以用导航栏远端的一个按钮打开它。可以将工具栏项目拖进/拖出这个面板。</p>
+
+<p>一些默认的工具栏按钮ID已更改,我们添加了一些新的ID,并且后退/前进按钮,URL栏,停止/重新加载按钮的顺序将不再可自定义。这也意味着用户不能用常规的自定义流程在这些按钮中添加新的(扩展程序提供的)按钮。</p>
+
+<p>独立的暂停刷新按钮已被移除</p>
+
+<p>我们正在更改工具栏按钮的添加方式。 虽然我们尝试保持某种向后兼容性,但是以下的 the following are deprecated and will be removed in the near future: the <code style="">toolbar.insertItem</code> 方法, <code style="">toolbar.currentSet</code> 属性, and the <code style="">currentset</code> 属性 on toolbars. If possible, please stop relying on them. Instead, you should use the <a href="http://mxr.mozilla.org/projects-central/source/ux/browser/components/customizableui/src/CustomizableUI.jsm">CustomizableUI</a> module.</p>
+
+<p>CustomizableUI introduces a new API to insert, move and remove toolbar buttons and other toolbar items, as well as creating panels that are anchored to these toolbarbuttons. We believe this will be simpler and more powerful than the previous mix of APIs.</p>
+
+<p>Because of the new customization APIs, your toolbar buttons may not be direct children of a XUL <code style="">&lt;toolbar&gt;</code>; they might still be in a toolbar, or they might be in the "customization target" of a toolbar (a descendant node in a toolbar), or they might be in the new menu panel. The customization target of any toolbar (whether the target is a child node, or the toolbar itself) via <code style="">toolbar.customizationTarget.</code></p>
+
+<p><strong>Icon sizes in toolbars have changed</strong>, and you should ideally provide a larger icon for your add-on's buttons, should they exist, for use in the menu panel and customization area (palette). The new icon sizes are the same on all platforms and are:</p>
+
+<ul>
+ <li>Toolbars:<br>
+ <strong>16px</strong> (32px @2dppx) without padding.<br>
+ Internal icons on the navbar use 18px. For add-ons, by default the padding is set up so it should work well if add-ons specify an icon of size 16px.</li>
+ <li>Menu panel/Customization area (palette):<br>
+ <strong>32px</strong> (64px @2dppx)<br>
+ Please note that smaller icons will be <em>upscaled</em>.</li>
+</ul>
+
+<p>When in the customization area (palette), the button will be wrapped in a toolbarpaletteitem with a <code style="">place</code> attribute set to <code style="">palette</code>. Putting it all together, your updated CSS might look like this:</p>
+
+<pre class="brush: css notranslate" style="">#my-addon-button {
+    list-style-image: url(icon16.png);
+}
+#my-addon-button[cui-areatype="menu-panel"],
+toolbarpaletteitem[place="palette"] &gt; #my-addon-button {
+    list-style-image: url(icon32.png);
+}
+
+/* High-resolution displays */
+@media (min-resolution: 2dppx) {
+ #my-addon-button {
+     list-style-image: url(icon32.png);
+ }
+ #my-addon-button[cui-areatype="menu-panel"],
+ toolbarpaletteitem[place="palette"] &gt; #my-addon-button {
+     list-style-image: url(icon64.png);
+ }
+}
+</pre>
+
+<p>Tab markup and styling have changed. If your add-on affects the tabstrip or provides alternative visualizations of the tabstrip, changes tab colors, or anything else related to the tabstrip, you may want to verify that it still works.</p>
+
+<p>The navigation toolbar is always visible (except in popup windows where a reduced navigation toolbar with the urlbar is visible) and can no longer be hidden e.g. for update pages or in-content UI. The related Add-on SDK module <a href="/en-US/Add-ons/SDK/High-Level_APIs/addon-page">addon-page</a> has been removed as it no longer has any effect.</p>
+
+<p>Items in the navigation toolbar can be overflowed if the browser window is made too small. Items in the toolbar will be moved into the new "overflow panel" when this occurs. The overflow panel is anchored to a button that appears in the navigation toolbar when one or more items are overflowed. If your item should never be overflowed, set an <code style="">overflows</code> attribute to <code style="">false</code> on the item. The <code style="">urlbar-container</code> is not overflowable by default, for example. Items that are overflowed have the <code style="">overflowedItem</code> attribute set to <code style="">true</code>.</p>
+
+<p>The menu panel uses a 3-column grid layout. Items should either fit in a single grid column (<code style="">toolbarbutton</code>s will be styled to do so automatically) or span the entire width of the panel if they wouldn't fit in a single grid column, e.g. for wide <code style="">toolbaritem</code>s. In order to have the latter work correctly, you should use the <code style="">panel-wide-item</code> class on your <code style="">toolbaritem</code>.</p>
+
+<p>If your add-on provides a <code style="">&lt;toolbarbutton type="menu"/&gt;</code> or <code style="">&lt;toolbarbutton type="menu-button"/&gt;</code>, consider moving to a subview-based design, which will work much better in the menu panel. There's some <a href="/en-US/docs/Mozilla/JavaScript_code_modules/CustomizableUI.jsm">documentation</a> you can look at, as well as <a href="http://hg.mozilla.org/projects/ux/annotate/8b514254b168/browser/components/customizableui/src/CustomizableWidgets.jsm#l56">the implementation of the history widget</a>.</p>
+
+<p>If your add-on provides a simple <code style="">toolbarbutton</code> then it should automatically be styled correctly in the menu panel, overflow panel and palette. If it provides a <code style="">toolbaritem</code> it is likely you will need to do additional work to make it look nice in places other than a toolbar.</p>
+
+<p>All items will have context menus allowing users to move the items between the palette, panel and the navigation toolbar. If your add-on uses the contextmenu itself, we will not override or change it (see <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=892463">this bug</a> for a lengthy discussion as to why). You are requested, however, to update your menus yourself so that users do have the possibility of using these options even for your add-on's button.</p>
+
+<p>The <code style="">class</code> attribute on tab close buttons has been changed. Extensions shouldn't be relying on the class attribute value since it is a list of tokens and should instead look for the <code style="">anonid </code>attribute with value "<code style="">close-button</code>".</p>
+
+<p>The <code style="">close-icon</code> class now works cross-platform to provide a close icon with a default, hover, and active state. Previously, this wasn't available on Linux and the GTK close icon (gtk-close) was used instead.</p>
+
+<p>The BrowserToolboxCustomizeDone, BrowserToolboxCustomizeChange, and BrowserCustomizeToolbar global window functions have been removed. <a href="/en-US/docs/XUL/Toolbars/Toolbar_customization_events">The customize events fired from the toolbox</a> are now the preferred mechanism for hooking new logic into the customization feature.</p>
+
+<h3 id="Add-on_SDK_Australis_APIs" style="">Add-on SDK Australis APIs</h3>
+
+<p>If you're using the Add-on SDK, there are several new APIs for building your add-on's user interface in Australis. See the <a href="/en-US/Add-ons/SDK/High-Level_APIs/ui">reference documentation</a>. Also note that the <code style=""><a href="/en-US/Add-ons/SDK/High-Level_APIs/widget">widget</a></code> module has been deprecated in favor of the new APIs.</p>
+
+<h2 id="Changes_for_themes">Changes for themes</h2>
+
+<p>We've changed the tab markup. If you style these differently, you'll need to check whether it still works.</p>
+
+<p>We'll be drawing tabs in the titlebar and on top, on all platforms (currently implemented on Windows and OS X), except when not showing tabs at all (in popup windows).</p>
+
+<p>Support for small icons mode as well as text and icons mode have been removed.</p>
+
+<p>We've changed the default iconsets, and there are new icon sizes for the menupanel. If you're building on the default theme with new icons, you'll need to rearrange your icons in your Toolbar icon files. In both this case and if you supply a complete theme, you will also need to provide icons for the menu panel. The new icon sizes are the same on all platforms and are:</p>
+
+<ul>
+ <li>Toolbars:<br>
+ <strong>16px</strong> (32px @2dppx) without padding.<br>
+ Internal icons on the navbar use 18px. For add-ons, by default the padding is set up so it should work well if add-ons specify an icon of size 16px.</li>
+ <li>Menu panel/Customization area (palette):<br>
+ <strong>32px</strong> (64px @2dppx)<br>
+ Please note that smaller icons will be <em>upscaled</em>.</li>
+</ul>
+
+<p>We've removed the add-on bar, but have a shim in place to migrate icons to other places. Any styles pertaining to should be removed so as not to disturb the migration work.</p>
+
+<p>We've changed a few toolbarbutton IDs, such as those for the bookmark and history buttons. We also added new ones.</p>
+
+<p>The application (Firefox) menu has been removed.</p>
+
+<p>The back, forward, stop and refresh buttons will no longer be movable. They will always remain in their current position next to the urlbar. Your CSS rules can probably be simplified now that this is the case.</p>
+
+<p>The navigation toolbar can no longer be hidden e.g. for update pages or in-content UI.<br>
+  </p>
+
+<h2 id="Known_issues_related_to_add-ons">Known issues related to add-ons</h2>
+
+<ul>
+ <li>Add-ons that have copied their toolbarbutton-insertion code from Adblock Plus hide their toolbarbutton icon. They keep track of their insertion point by themselves. Even though our compatibility shims correctly insert these button initially, their detection code decides it is not in a toolbar (it is in fact in a customization target inside a toolbar, see above) and removes the icon on restart. This has been fixed in Adblock Plus but add-ons using similar code patterns might still be affected.</li>
+ <li>Many add-ons check whether their button is in the toolbox (rather than in a toolbar or some other visible place) by checking the result of <code style="">document.getElementById()</code>. This is <strong>no longer enough</strong>. If your button is in the menu panel, it will not be moved there until the menu panel is first shown. Instead, use:<a href="/en-US/docs/Mozilla/JavaScript_code_modules/CustomizableUI.jsm"><code style=""> CustomizableUI.getPlacementOfWidget("mytoolbarbuttonId")</code></a>. This will return <code style="">null</code> if and only if the widget is in the palette.</li>
+ <li>If a <code style="">&lt;menulist&gt;</code> element is wrapped inside a toolbaritem, popping up the <code style="">&lt;menulist&gt;</code> closes the new menu panel. This issue is being tracked <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=964944">here</a>.</li>
+ <li>Add-ons that automatically re-add their icons to the add-on bar when removed will need to fix their own insertion code to not do that.</li>
+ <li>Elements inserted in the statusbar element or the add-on bar itself will not be shown. This can only be fixed by the add-on authors, who need to update their add-on to use toolbaritems instead of statuspanels, and insert into a normal toolbar.</li>
+ <li>For toolbaritems and toolbarbuttons inserted into the add-on bar, we will attempt to migrate them to a visible toolbar automatically <strong>if</strong> the add-on bar was visible in the user's profile before migrating to Australis. However, depending on your add-on's code this may or may not work correctly without further code changes on your part.</li>
+ <li>Toolbar buttons of type <code style="">menu </code>with a <code style="">orient="horizontal"</code> attribute will not display properly in the menu panel. This attribute should probably be avoided altogether.</li>
+</ul>
+
+<h2 id="See_Also">See Also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/JavaScript_code_modules/CustomizableUI.jsm">CustomizableUI.jsm</a></li>
+ <li><a href="/en-US/Firefox/Releases/29">Firefox 29 for developers</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/firefox/developer_edition/index.html b/files/zh-cn/mozilla/firefox/developer_edition/index.html
new file mode 100644
index 0000000000..8764178a14
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/developer_edition/index.html
@@ -0,0 +1,57 @@
+---
+title: 开发者版本
+slug: Mozilla/Firefox/Developer_Edition
+translation_of: Mozilla/Firefox/Developer_Edition
+---
+<div>{{FirefoxSidebar}}</div><p><img alt="" src="https://mdn.mozillademos.org/files/9069/firefox-dev-ed_logo-only_1024.png" style="display: block; height: 256px; margin-left: auto; margin-right: auto; width: 256px;"></p>
+
+<p style="text-align: center;">一个为网页开发者量身定制的 Firefox。</p>
+
+<p><a href=" https://www.mozilla.org/en-US/firefox/developer/" style="width: 250px; display: block; margin-left: auto; margin-right: auto; padding: 10px; text-align: center; border-radius: 4px; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;">下载 Firefox 开发者版本</a></p>
+
+<hr>
+<div class="column-container">
+<div class="column-half">
+<h3 id="最新的_Firefox_特性"><strong>最新的 Firefox 特性</strong></h3>
+
+<p>Firefox 开发者版本会在 <a href="https://wiki.mozilla.org/Release_Management/Release_Process">Firefox 发布流程</a>中取代 Aurora 通道。像 Aurora 通道一样, 每 6 周新特性当它们在 Nightly 版本中稳定后,会登录到开发者版本中。</p>
+
+<p>通过使用开发者版本,你将会比常规发布的 Firefox 提前至少 12 周体验到新的工具以及平台特性。</p>
+
+<p><a href="/en-US/Firefox/Releases/35">来看看开发者版本中有什么新的内容</a>。</p>
+</div>
+
+<div class="column-half">
+<h3 id="实验性开发工具"><strong>实验性开发工具</strong></h3>
+
+<p>我们还包含了一系列没有足够测试的实验性工具。</p>
+
+<p>例如,开发者版本包含了 <a href="/en-US/docs/Tools/Firefox_Tools_Adapter">Firefox Tools Adapter</a>,它可以帮你将 <a href="/en-US/docs/Tools">Firefox 开发工具</a> 连接到其他平台的浏览器上,像 Android 上的 Chrome 以及 iOS 上的 Safari。</p>
+</div>
+</div>
+
+<div class="column-container">
+<div class="column-half">
+<h3 id="单独的配置文件"><strong>单独的配置文件</strong></h3>
+
+<p>Firefox 开发版有自己一套单独的配置文件,这就意味着它不会影响你电脑里已经安装了的稳定版或者 Beta 版的 Firefox。</p>
+</div>
+
+<div class="column-half">
+<h3 id="专为网页开发者而设"><strong>专为网页开发者而设</strong></h3>
+
+<p>我们为网页开发者提供了量身的默认设置。例如,默认开启了 Chrome 以及远程调试功能。</p>
+</div>
+</div>
+
+<div class="column-container">
+<div class="column-half">
+<h3 id="一个独特的主题"><strong>一个独特的主题</strong></h3>
+
+<p>这将让你更迅速地进入开发工具中。</p>
+</div>
+
+<div class="column-half"> </div>
+</div>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/firefox/enterprise_deployment/index.html b/files/zh-cn/mozilla/firefox/enterprise_deployment/index.html
new file mode 100644
index 0000000000..13d68ed3ce
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/enterprise_deployment/index.html
@@ -0,0 +1,138 @@
+---
+title: 将火狐部署到企业环境下
+slug: Mozilla/Firefox/Enterprise_deployment
+tags:
+ - 发布 企业环境 火狐 管理员手册
+translation_of: Mozilla/Firefox/Enterprise_deployment_before_60
+---
+<div>{{FirefoxSidebar}}</div><p>本页将为您介绍在企业配置环境下针对Mac OS X、Windows系统中火狐管理的整个流程。如您遇有不清楚的地方,请发送邮件至<a href="mailto:enterprise@mozilla.org?subject=Question%3A">enterprise@mozilla.org</a>。</p>
+
+<h2 id="选择一个火狐的版本">选择一个火狐的版本</h2>
+
+<p> </p>
+
+<h3 id="快速发布版(RR)">快速发布版(RR)</h3>
+
+<p>火狐发布的每一个更新都会将主版本号增加,每6周便会发布新功能、Bug修复信息,如有必要,更新中也会加入额外的安全更新信息。当主版本更新后,Mozilla将不再提供上一版本的Bug修复。</p>
+
+<p>具体更新发布计划请关注Mozilla wiki的<a href="https://wiki.mozilla.org/RapidRelease/Calendar#Future_branch_dates">版本更新日程表</a>中的”发布日程”。</p>
+
+<h3 id="稳定版_(ESR)">稳定版 (ESR)</h3>
+
+<p>火狐每隔7个主版本都会释出一个稳定版的发布内容。这些稳定发布的版本会将54周(9个“六周”一次的更新周期)以来一系列的bug进行修复。这两个版本中都会共同包含第12周(两个发布版本周期)的ESR更新内容。</p>
+
+<p>到目前为止,扩展支持发布版本的版本号有10、17、24和31。</p>
+
+<p>绝大多数企业以及组织机构更倾向与选择ESR版本,主要是因为稳定版发布间隔较长,以让各企业用户有充裕的时间对兼容性进行考核(ESR为42周,而RR则仅为6周),一旦在测试期间发现问题,用户也将拥有12周时间建立解决方案(每12周ESR版本会有重复发布)。</p>
+
+<p>需要注意的是,如果您先使用RR后转为ESR较旧的版本时,将可能受到一些不利因素的影响。即便假设您此前使用的26RR版本火狐,和现改用24.2ESR版本发布于统一天,不同版本差异也会产生不利的因素。这是因为新功能仅会在RR版本发布前加入快速发布版进行评测,但由于一些原因Mozilla决定待功能到某一特定版本后才触发使用,在这之前都会在用户配置文件重将对应功能关闭。一旦您选择了旧版本火狐,用户文档保存的将是最后一次保存的文件,其中即可能设定新功能为启用的状态,进而导致在ESR版中功能失效。如果您执意要从RR过度到ESR版本,您需要等到最新的ESR发布版本释出后再这样做。</p>
+
+<h2 id="安装">安装</h2>
+
+<ol>
+ <li>从<a href="http://www.mozilla.org/firefox/all/">http://www.mozilla.org/firefox/all/</a> (RR)或 <a href="https://www.mozilla.org/firefox/organizations/all.html">https://www.mozilla.org/firefox/organizations/all.html</a> (ESR)处获取发布版本安装包,单击“下载”按钮获取软件包或下载器;</li>
+ <li>根据您选择的安装模式进行安装,命令行下静默安装的参数为 -ms;</li>
+ <li>您也可以额外指定一个INI文件用以指定建立快捷方式等维护服务;具体请参照<a href="https://wiki.mozilla.org/Installer:Command_Line_Arguments">命令行安装参数</a>章节中的相关内容.</li>
+</ol>
+
+<h2 id="设置">设置</h2>
+
+<ol>
+ <li>找到火狐的<strong>程序主文件夹,</strong>(Win7 64位操作系统默认安装位置是 <code>C:\Program Files (x86)\Mozilla Firefox</code>; OSX 10.8 则是默认安装在 <code>/Applications/Firefox.app/Contents/MacOS</code>。下文提到的这些子文件夹都在此程序主文件夹下;</li>
+ <li>在defaults/pref子文件夹中新建一个Javascript文件 <code>autoconfig.js</code> 或者别的名字,但是建议您还是选用英文字母组合命名文件。该文件将告诉火狐查询对应的配置信息(具体请参考 <a href="http://mike.kaply.com/2012/03/15/customizing-firefox-default-preference-files/">自定义火狐的默认选项文件</a>章节重的相关内容),您需要至少写入以下两行:</li>
+ <li>
+ <pre class="brush: js">pref("general.config.filename", "mozilla.cfg");
+pref("general.config.obscure_value", 0);</pre>
+ </li>
+ <li>新建.cfg文件,一般命名为<code>mozilla.cfg</code>,同样的它的文件名也可以用其它名字。它用于匹配识别general.config.filename的内容。将第一个语句跳过或注释掉后便可设置您的选项。具体都有哪些选项,您可参考about:config中的内容写入、或者您也可以参考后面的示例配置选项内容。任何about:config选项都可以通过以下函数之一进行设置:
+ <dl>
+ <dt> </dt>
+ <dt><strong>pref </strong></dt>
+ <dd>此选项可设置每次打开浏览器都按照此配置内容指定用户使用习惯。因此,即便用户在使用过程中可以随意更改偏好,但每次重新启动浏览器,用户之前的配置都将被抹消。如果您需要此方面的相关设置,请在about:config中查找“user set”。</dd>
+ <dt><strong>defaultPref</strong></dt>
+ <dd>此选项可用于修改默认值,但用户通常可以将其更改并将修改内容保存到用户会话中。如果用户偏好被重置,重置的内容将变为此设定值。此项目在about:config的“default”中。</dd>
+ <dt><strong>lockPref</strong></dt>
+ <dd>此选项可用于锁定指定项目,以防止用户在使用过程中通过界面或about:config对指定的配置选项进行修改。 通常锁定项的表现方式是变灰或移除选项内容。在about:config中则显示为“locked”。有一些选项必须通过<span class="author-g-fer323ku83ypu55t"><strong>lockPref</strong>设置比如<strong>app.update.enabled</strong>。如果只用pref设置该内容,该设置无效。</span></dd>
+ <dt><span class="author-g-fer323ku83ypu55t">clearPref</span></dt>
+ <dd><span class="author-g-fer323ku83ypu55t">此选项可以将某些指定的内容“放空”。此选项可以便于跳过某些网站的浏览器版本号检查功能。</span></dd>
+ </dl>
+ </li>
+</ol>
+
+<p>相关内容请您参考<a href="http://mike.kaply.com/2012/03/16/customizing-firefox-autoconfig-files/">自定义火狐的自动配置文件</a>以及<a href="http://mike.kaply.com/2012/03/20/customizing-firefox-autoconfig-files-continued/">继续自定义火狐的自动配置文件</a>中的内容。如果您是倾向于零UI操作的狂热者,您可能需要用到<a href="http://mike.kaply.com/cck2/">CCK2</a>这个扩展。</p>
+
+<h3 id="配置文件示例">配置文件示例</h3>
+
+<p>如果您倾向于配置“极为复杂的用户偏好”,就请跳过这里。自火狐31版发布起,以下示例为您展示了常用的设置选项示例。如果您有某些指定的配置需求,请自行查询<a href="http://kb.mozillazine.org/Knowledge_Base">知识库中</a>的信息。</p>
+
+<pre class="brush: js"><span class="brush: js">//关闭更新器
+lockPref("app.update.enabled", false);
+//确认更新起已经绝对关闭
+lockPref("app.update.auto", false);
+lockPref("app.update.mode", 0);
+lockPref("app.update.service.enabled", false);
+
+//取消插件兼容性检查
+clearPref("extensions.lastAppVersion");
+
+//第一次运行火狐时不再提示“了解您的权益”
+pref("browser.rights.3.shown", true);
+
+//每次更新后不再显示更新发布注记
+pref("browser.startup.homepage_override.mstone","ignore");
+
+//修改主页地址(用户可改)
+defaultPref("browser.startup.homepage", "http://home.example.com");
+
+//关闭浏览器内默认的PDF阅读器
+pref("pdfjs.disabled", true);
+
+//关闭flash、js转换
+pref("shumway.disabled", true);
+
+//不再提示安装flash插件
+pref("plugins.notifyMissingFlash", false);
+
+//关闭插件提示
+lockPref("plugins.hide_infobar_for_outdated_plugin", true);
+clearPref("plugins.update.url");
+
+//关闭健康诊断报告
+lockPref("datareporting.healthreport.service.enabled", false);
+
+</span>// Disable all data upload (Telemetry and FHR)
+lockPref("datareporting.policy.dataSubmissionEnabled", false);
+<span class="brush: js">
+//关闭崩溃报告
+lockPref("toolkit.crashreporter.enabled", false);
+Components.classes["@mozilla.org/toolkit/crash-reporter;1"].getService(Components.interfaces.nsICrashReporter).submitReports = false;</span><em> </em>
+</pre>
+
+<h2 id="扩展包">扩展包</h2>
+
+<ol>
+ <li>安装扩展,通过about:support找到该拓展对应的GUID;</li>
+ <li>找到<a href="https://support.mozilla.org/en-US/kb/profiles-where-firefox-stores-user-data">用户配置文件目录</a> (如win7的是:<code>%APPDATA%\Mozilla\Firefox\Profiles</code> , 在about:support中单击<strong>显示文件夹</strong>,然后在“扩展”下找到你需要的插件。插件文件可能是单独的xpi文件,或者是一个包含多个文件的目录。</li>
+ <li>确定如何发布此扩展。最简单的方式是将xpi直接拽到<strong>程序主文件夹<code>/</code></strong><code>distribution/extensions目录下,但是这仅限于用户配置文件已记录该插件的安装情况。您另外还可以手动打开火狐重新安装。具体请参考</code><a href="http://mike.kaply.com/2012/02/09/integrating-add-ons-into-firefox/">让插件与火狐合二为一</a>的相关章节。</li>
+</ol>
+
+<p>Also keep in mind: <a href="http://mike.kaply.com/2013/05/03/add-on-scopes-redux/">Add-on scopes redux/</a></p>
+
+<h2 id="随时变化">随时变化</h2>
+
+<h3 id="目录结构的变化">目录结构的变化</h3>
+
+<p>到目前为止,火狐的目录结构已经变更过两次。如果您需要使用21版本以前的火狐,请注意以下的变化:</p>
+
+<ul>
+ <li>在14版中,当所有pref设置都写在一个/defaults/pref中的某文件时,设置将可能失效。解决办法是新建文件夹<code>defaults/preferences</code>并将配置文件放在这里;</li>
+ <li>在21版中新加入了browser文件夹。该文件夹将替换之前的.ini文件,<code>defaults/preferences</code>、<code>defaults/profile、</code><code>extensions</code>、<code>plugins以及searchplugins都将放在这里。plugins下的</code>Plug-ins可以通过修改.plugins.load_appdir_plugins 为 <strong>true</strong> 来重新激活。</li>
+</ul>
+
+<p>自动配置<code>general.config.filename</code>和<code>general.config.obscure_value可以在defaults/pref</code>中完成,但文件名应该以英文字母‘a’开头,比如“autoconfig.js”</p>
+
+<p>如果您的版本defaults/pref与插件设置相悖,您可以尝试将目录结构改为和新版一样。</p>
+
+<h3 id="ESR_24.x的变化(有Adobe_PDF支持)">ESR 24.x的变化(有Adobe PDF支持)</h3>
+
+<p>火狐RR19.x起将PDF查看器嵌入到自己内部来, 即便您已经将火狐配置了其它PDF视图软件,但嵌入支持直到24.x版本以后才开始启用。而内容类型描述也与Adobe文档的PDF文件不同,若要取消此功能,请您将前面示例中的pdfjs.disabled改为true即可。</p>
diff --git a/files/zh-cn/mozilla/firefox/experimental_features/index.html b/files/zh-cn/mozilla/firefox/experimental_features/index.html
new file mode 100644
index 0000000000..390a652feb
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/experimental_features/index.html
@@ -0,0 +1,623 @@
+---
+title: Experimental features in Firefox
+slug: Mozilla/Firefox/Experimental_features
+tags:
+ - 实验的
+ - 火狐
+ - 特性
+ - 设置
+translation_of: Mozilla/Firefox/Experimental_features
+---
+<div>{{FirefoxSidebar}}</div><p class="summary">Mozilla发布了测试的nightly版本,用于测试新的浏览器特性。 实验性特性,例如所提议的可用的Web平台标准的实现。这个页面列出了Firefox Nightly中的一些新特性和启用方法等信息。在发布这些功能之前,你可以测试Web站点和应用程序,并确保一切都能与最新的Web技术功能协同工作。</p>
+
+<p>你需要下载隔夜版或是开发者版,来测试下面这些实验性特性。</p>
+
+<h2 id="HTML">HTML</h2>
+
+<table style="height: 359px; width: 823px;" class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">功能</th>
+ <th scope="col">Firefox Nightly</th>
+ <th scope="col">Firefox 开发者版</th>
+ <th scope="col">Firefox 测试版</th>
+ <th scope="col">Firefox 发行版</th>
+ <th scope="col">Preference</th>
+ </tr>
+ <tr>
+ <td><strong>日期和时间输入</strong>{{HTMLElement("input")}}为 <a href="/en-US/docs/Web/HTML/Element/input/date">日期</a> 和 <a href="/en-US/docs/Web/HTML/Element/input/time">时间</a> 相关的输入类型提供的新用户界面</td>
+ <td>开启<br>
+ <sub>(从51开始支持, 从55开始默认开启)</sub></td>
+ <td>开启<br>
+ <sub>(从51开始支持)</sub></td>
+ <td>关闭<br>
+ <sub>(从51开始支持)</sub></td>
+ <td>---</td>
+ <td><code>dom.forms.datetime</code></td>
+ </tr>
+ <tr>
+ <td><strong>{{HTMLElement("dialog")}}</strong><br>
+ 包含与之交互的DOM元素的对话框元素。Implementation of modal dialogs and accessibility still missing.</td>
+ <td>关闭<br>
+ <sub>(从53开始支持)</sub></td>
+ <td>关闭<br>
+ <sub>(从53开始支持)</sub></td>
+ <td>---</td>
+ <td>---</td>
+ <td><code>dom.dialog_element.enabled</code></td>
+ </tr>
+ </thead>
+</table>
+
+<h2 id="CSS">CSS</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">功能</th>
+ <th scope="col">Firefox Nightly</th>
+ <th scope="col">Firefox Developer Edition</th>
+ <th scope="col">Firefox Beta</th>
+ <th scope="col">Firefox Release</th>
+ <th scope="col">Preference</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><strong>Subgrids</strong></td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td><code>layout.css.grid-template-subgrid-value.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong>Display stray control characters in CSS as hex boxes</strong><br>
+ This feature renders control characters (Unicode category Cc) other than <em>tab</em> (<code>U+0009</code>), <em>line feed</em> (<code>U+000A</code>), <em>form feed</em> (<code>U+000C</code>), and <em>carriage return</em> (<code>U+000D</code>) as a hexbox when they are not expected.</td>
+ <td>43</td>
+ <td>43</td>
+ <td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1329613">Disabled</a></td>
+ <td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1329613">Disabled</a></td>
+ <td><code>layout.css.control-characters.enabled</code> or <code>layout.css.control-characters.visible</code></td>
+ </tr>
+ <tr>
+ <td><strong>Positioned CSS Masks</strong><br>
+ A subset of CSS Masks that includes <a href="/en-US/docs/Web/CSS/CSS_Masks">longhand properties of CSS Masks</a>, as well as a change in the shorthand property</td>
+ <td>51</td>
+ <td>51</td>
+ <td>53</td>
+ <td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1251161">Disabled</a></td>
+ <td>Controlled by a compile flag (MOZ_ENABLE_MASK_AS_SHORTHAND).</td>
+ </tr>
+ <tr>
+ <td><strong>The <code>font-display</code> descriptor for <code>@font-face</code></strong><br>
+ To improve Web fonts performance, {{cssxref("@font-face")}} has an experimental {{cssxref("@font-face/font-display", "font-display")}} descriptor.</td>
+ <td>关闭<br>
+ <sub>(available since 46)</sub></td>
+ <td>关闭<br>
+ <sub>(available since 46)</sub></td>
+ <td>关闭<br>
+ <sub>(available since 46)</sub></td>
+ <td>关闭<br>
+ <sub>(available since 46)</sub></td>
+ <td><code>layout.css.font-display.enabled</code></td>
+ </tr>
+ <tr>
+ <td>
+ <p><strong><code>font-variation-settings</code> 属性</strong><br>
+ {{cssxref("font-variation-settings")}} 提供了OpenType或TrueType字体印刷特点的低级别的控制, by specifying the four letter axis names of the features you want to vary, along with their variation values.</p>
+ </td>
+ <td>关闭<br>
+ <sub>(available since 53)</sub></td>
+ <td>关闭<br>
+ <sub>(available since 53)</sub></td>
+ <td>关闭<br>
+ <sub>(available since 53)</sub></td>
+ <td>关闭<br>
+ <sub>(available since 53)</sub></td>
+ <td>
+ <p><code>layout.css.font-variations.enabled</code><br>
+ Functions only in Mac OS Sierra (and later).<br>
+ <br>
+ For the downloadable fonts on axis-praxis, you also need <code>gfx.downloadable_fonts.keep_variation_tables</code> (in Firefox 54 and later)</p>
+ </td>
+ </tr>
+ <tr>
+ <td><strong><code>touch-action</code> CSS 属性</strong><br>
+ The {{cssxref("touch-action")}} CSS property is part of the {{SpecName("Pointer Events")}} specification and allows you to specify how and in what way the user is able to manipulate an object by touch.</td>
+ <td>50</td>
+ <td>—</td>
+ <td>—</td>
+ <td>—</td>
+ <td><code>layout.css.touch_action.enabled</code></td>
+ </tr>
+ <tr id="shape-outside">
+ <td>
+ <p><strong>The <code>shape-outside</code> CSS property</strong><br>
+ The {{cssxref("shape-outside")}} CSS property is part of the {{SpecName("CSS Shapes")}} specification and allows you to specify a float area causing inline contents to wrap around a shape.</p>
+
+ <p>Firefox currently implements the <code>&lt;shape-box&gt;</code> values ({{bug(1309467)}}) as well as the <code>circle()</code> ({{bug(1311244)}}), <code>ellipse()</code> ({{bug(1326406)}}), and <code>polygon()</code> ({{bug(1326409)}}) functions.</p>
+ </td>
+ <td>关闭<br>
+ <sub>(available since 53)</sub></td>
+ <td>—</td>
+ <td>—</td>
+ <td>—</td>
+ <td><code>layout.css.shape-outside.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong>The <code>contain</code> CSS property</strong><br>
+ The {{cssxref("contain")}} CSS property is part of the {{SpecName("CSS Containment")}} specification and allows you to indicate that an element and its contents are independent of the rest of the document tree, allowing {{Glossary("User agent", "user agents")}} to optimize the rendering of a page.</td>
+ <td>关闭<br>
+ <sub>(available since 45)</sub></td>
+ <td>关闭<br>
+ <sub>(available since 45)</sub></td>
+ <td>关闭<br>
+ <sub>(available since 45)</sub></td>
+ <td>关闭<br>
+ <sub>(available since 45)</sub></td>
+ <td><code>layout.css.contain.enabled</code></td>
+ </tr>
+ <tr id="column-span">
+ <td>
+ <p><strong>The <code>column-span</code> CSS property</strong><br>
+ The {{cssxref("column-span")}} CSS property is part of the {{SpecName("CSS3 Multicol")}} specification and allows you to specify how many columns an element spans across.</p>
+
+ <p>Firefox currently only parses the property ({{bug(1339298)}}), it's not actually implemented yet ({{bug(616436)}}).</p>
+ </td>
+ <td>关闭<br>
+ <sub>(recognized since 55, but not implemented yet)</sub></td>
+ <td>—</td>
+ <td>—</td>
+ <td>—</td>
+ <td><code>layout.css.column-span.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong>The <code>frames()</code> timing function</strong><br>
+ See <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/single-transition-timing-function#The_frames()_class_of_timing-functions">The frames() class of timing-functions</a> for more details.</td>
+ <td>开启</td>
+ <td><sub>N/A</sub></td>
+ <td>关闭<br>
+ <sub>(available since 55)</sub></td>
+ <td>关闭<br>
+ <sub>(available since 55)</sub></td>
+ <td>None</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="JavaScript">JavaScript</h2>
+
+<p id="ECMAScript_2016">See also <a href="/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_Next_support_in_Mozilla">ECMAScript Next support</a> for implemented features of ECMAScript 2016 and later, that are not experimental and thus available without preferences in Firefox Release.</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Feature</th>
+ <th scope="col">Firefox Nightly</th>
+ <th scope="col">Firefox Developer Edition</th>
+ <th scope="col">Firefox Beta</th>
+ <th scope="col">Firefox Release</th>
+ <th scope="col">Preference</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><strong>Additions to the <code>ArrayBuffer</code> object</strong><br>
+ Adds the {{jsxref("ArrayBuffer.transfer()")}} that returns a new <code>ArrayBuffer</code> whose contents have been taken from the <code>oldBuffer</code>'s data (<a href="https://gist.github.com/lukewagner/2735af7eea411e18cf20">spec</a>).</td>
+ <td>36</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>None</td>
+ </tr>
+ <tr>
+ <td><strong>TypedObject objects</strong> (<a href="https://github.com/dslomov-chromium/typed-objects-es7">spec</a>)</td>
+ <td>Enabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>None</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/SIMD">SIMD</a> (<a href="https://github.com/johnmccutchan/ecmascript_simd">specification and polyfill</a>)</td>
+ <td>Enabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>None</td>
+ </tr>
+ <tr>
+ <td><strong>ECMAScript modules</strong><br>
+ Allows you to use native ECMAScript modules, for example defining modules with <code>&lt;script type="module"&gt;</code>, defining fallback scripts with <code>&lt;script nomodule&gt;</code>, and <a href="/en-US/docs/Web/JavaScript/Reference/Statements/import">importing</a> code features that have been <a href="/en-US/docs/Web/JavaScript/Reference/Statements/export">exported</a> from modules.</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td><code>dom.moduleScripts.enabled</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="APIs">APIs</h2>
+
+<h3 id="Canvas_WebGL">Canvas &amp; WebGL</h3>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Feature</th>
+ <th scope="col">Firefox Nightly</th>
+ <th scope="col">Firefox Developer Edition</th>
+ <th scope="col">Firefox Beta</th>
+ <th scope="col">Firefox Release</th>
+ <th scope="col">Preference</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><strong><code>WEBGL_debug_renderer_info</code> extension</strong><br>
+ The {{domxref("WEBGL_debug_renderer_info")}} extension allows you to transmit information useful to help debugging problems to the server.</td>
+ <td>42</td>
+ <td>42</td>
+ <td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=742798">Disabled</a></td>
+ <td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=742798">Disabled</a></td>
+ <td><code>webgl.enable-debug-renderer-info</code></td>
+ </tr>
+ <tr>
+ <td><strong>OffscreenCanvas</strong><br>
+ The {{domxref("OffscreenCanvas")}} interface provides a canvas that can be rendered off screen. It is available in both the window and <a href="/en-US/docs/Web/API/Web_Workers_API">worker</a> contexts.</td>
+ <td>Disabled<br>
+ <sub>(available since 44)</sub></td>
+ <td>Disabled<br>
+ <sub>(available since 44)</sub></td>
+ <td>Disabled<br>
+ <sub>(available since 44)</sub></td>
+ <td>Disabled<br>
+ <sub>(available since 44)</sub></td>
+ <td><code>gfx.offscreencanvas.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong><a href="/en-US/docs/Web/API/Canvas_API/Tutorial/Hit_regions_and_accessibility">Hit regions</a></strong><br>
+ Whether the mouse coordinates are within a particular area on the canvas is a common problem to solve. The hit region API allows you define an area of your canvas and provides another possibility to expose interactive content on a canvas to accessibility tools.</td>
+ <td>Disabled<br>
+ <sub>(available since 30)</sub></td>
+ <td>Disabled<br>
+ <sub>(available since 30)</sub></td>
+ <td>Disabled<br>
+ <sub>(available since 30)</sub></td>
+ <td>Disabled<br>
+ <sub>(available since 30)</sub></td>
+ <td><code>canvas.hitregions.enabled</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="DOM">DOM</h3>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Feature</th>
+ <th scope="col">Firefox Nightly</th>
+ <th scope="col">Firefox Developer Edition</th>
+ <th scope="col">Firefox Beta</th>
+ <th scope="col">Firefox Release</th>
+ <th scope="col">Preference</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><strong>Mac上的WebVR API 1.1</strong><br>
+ <a href="/en-US/docs/Web/API/WebVR_API">WebVR API</a> 允许你控制并和使用虚拟现实设备。</td>
+ <td>Enabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td><code>dom.vr.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong>游戏手柄扩展</strong><br>
+ <a href="/en-US/docs/Web/API/Gamepad_API#Experimental_Gamepad_extensions">The Gamepad Extensions</a> provide access to additional functionality such as pose information in the case of WebVR controllers, and haptic actuator control (e.g. controller vibration hardware).</td>
+ <td>Enabled</td>
+ <td>Enabled</td>
+ <td>Enabled</td>
+ <td>Disabled</td>
+ <td><code>dom.gamepad-extensions.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong>Experimental fetch controller/signal/observer interfaces</strong><br>
+ Also known as "cancellable fetch", <a href="/en-US/docs/Web/API/Fetch_API#Experimental_fetch_controllersignalobserver_interfaces">these interfaces</a> contain functionality to allow fetch request operations to be observed and controlled during their lifetimes.</td>
+ <td>Disabled<br>
+ <sub>(Available since 55)</sub></td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td><code>dom.fetchObserver.enabled</code> and <code>dom.fetchController.enabled</code> (not in <code>about:config</code> by default; you must set them yourself).</td>
+ </tr>
+ <tr>
+ <td><strong>FlyWeb</strong><br>
+ <a href="https://flyweb.github.io/">FlyWeb</a> is a project at Mozilla focused on bringing a new set of APIs to the browser for advertising and discovering local-area web servers.</td>
+ <td>51</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td><code>dom.flyweb.enabled</code></td>
+ </tr>
+ <tr>
+ <td><code><strong>HTMLMediaElement.seekToNextFrame()</strong></code><br>
+ Part of an experimentation process around support non-real-time access to media for tasks including filtering, editing, and so forth, the {{domxref("HTMLMediaElement.seekToNextFrame()")}} advances the the current play position to the next frame in the media.</td>
+ <td>49<br>
+ <sub>(Fundamental update in version 50)</sub></td>
+ <td>49<br>
+ <sub>(Fundamental update in version 50)</sub></td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td><code>media.seekToNextFrame.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong><code>GeometryUtils.getBoxQuads()</code></strong> ({{bug(917755)}})</td>
+ <td>31</td>
+ <td>31</td>
+ <td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1107559">Disabled</a></td>
+ <td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1107559">Disabled</a></td>
+ <td><code>layout.css.getBoxQuads.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong><code>GeometryUtils.convertPointFromNode()</code></strong>,<br>
+ <strong><code>GeometryUtils.RectFromNode()</code></strong>, and<br>
+ <code><strong>GeometryUtils.convertQuadFromNode()</strong></code><br>
+ ({{bug(918189)}})</td>
+ <td>31</td>
+ <td>31</td>
+ <td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1107559">Disabled</a></td>
+ <td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1107559">Disabled</a></td>
+ <td><code>layout.css.convertFromNode.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong><code>Node.rootNode</code></strong><br>
+ The {{domxref("Node.rootNode")}} property returns a {{domxref("Node")}} object representing the topmost node in the tree, or the current node if it's the topmost node in the tree.<br>
+ <em>This feature is kept experimental as its naming poses Web compatibility problems. It will be renamed in the future.</em></td>
+ <td>48</td>
+ <td>48</td>
+ <td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1269155">Disabled</a></td>
+ <td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1269155">Disabled</a></td>
+ <td><code>dom.node.rootNode.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong>Performance Observer API</strong><br>
+ The {{domxref("PerformanceObserver")}} interface is used to <em>observe</em> performance measurement events and be notified of new <a href="/en-US/docs/Web/API/PerformanceEntry" title="The PerformanceEntry object encapsulates a single performance metric that is part of the performance timeline. A performance entry can be directly created by making a performance mark or measure (for example by calling the mark() method) at an explicit point in an application. Performance entries are also created in indirect ways such as loading a resource (such as an image).">performance entries</a> as they are recorded in the browser's <em>performance timeline</em>.</td>
+ <td>49</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td><code>dom.enable_performance_observer</code></td>
+ </tr>
+ <tr>
+ <td><strong>WebVTT Regions API</strong><br>
+ <a href="/en-US/docs/Web/API/Web_Video_Text_Tracks_Format">WebVTT</a> regions are parts of the video viewport that provide a rendering area for WebVTT cues. The {{domxref("VTTRegion")}} is the interface exposing the WebVTT cues.<br>
+ <em>This interface is considered to be in flux and isn't therefore activated in any version by default.</em></td>
+ <td>Disabled<br>
+ <sub>(Experimental implementation since version 30)</sub></td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td><code>media.webvtt.regions.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong>音频和视频轨道支持</strong><br>
+ Implements {{domxref("HTMLMediaElement.audioTracks")}} and {{domxref("HTMLMediaElement.videoTracks")}}.<br>
+ <em>Firefox doesn't support multiple audio or video tracks, preventing the most common use cases for these properties to work properly. That's why these properties are not activated by default in any version.</em></td>
+ <td>Disabled<br>
+ <sub>(Experimental implementation since version 33)</sub></td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td><code>media.track.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong>Better value for <code>Event.timestamp</code></strong><br>
+ The property {{domxref("Event.timestamp")}} is returning a {{domxref("DOMHighResTimeStamp")}}, which is now relative to the Unix epoch.</td>
+ <td>32 (Windows)<br>
+ 43 (Linux)</td>
+ <td>32 (Windows)<br>
+ 43 (Linux)</td>
+ <td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1026804">Disabled</a></td>
+ <td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1026804">Disabled</a></td>
+ <td><code>media.track.enabled</code></td>
+ </tr>
+ <tr id="pointer-events">
+ <td><strong>指针事件</strong></td>
+ <td>50</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td><code>dom.w3c_pointer_events.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong>Pointer Events {{domxref("PointerEvent.tangentialPressure")}} and {{domxref("PointerEvent.twist")}}</strong></td>
+ <td>54</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td><code>dom.w3c_pointer_events.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong>Intersection Observer API</strong><br>
+ The {{domxref("Intersection Observer API")}} allows you to configure a callback that is called whenever one item, called a target, intersects either the device viewport or a specified element called.</td>
+ <td>Disabled<br>
+ <sub>(available since 53)</sub></td>
+ <td>—</td>
+ <td>—</td>
+ <td>—</td>
+ <td><code>dom.IntersectionObserver.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong><a href="/en-US/docs/Web/API/Web_Animations_API">Web Animations API: KeyframeEffect and KeyframeEffectReadOnly</a></strong><br>
+ The {{domxref("KeyframEffectReadOnly()", "KeyframeEffectReadOnly.KeyframeEffectReadOnly()")}} and {{domxref("KeyframeEffect()", "KeyframeEffect.KeyframeEffect()")}} constructors can be used to clone existing {{domxref("KeyframeEffectReadOnly")}} object instances by being given the object to clone as their only parameter (see {{bug(1273784)}}.)</td>
+ <td>52</td>
+ <td>52</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>None</td>
+ </tr>
+ <tr>
+ <td><strong>{{domxref("PromiseRejectionEvent")}} and related features</strong><br>
+ Providing a way to monitor and more finely control the rejection of Promises.<br>
+  </td>
+ <td>Disabled<br>
+ <sub>(available since 55)</sub></td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td><code>dom.promise_rejection_events.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong><a href="/en-US/docs/Web/API/Payment_Request_API">Payment Request API</a></strong><br>
+ 为网络支付提供的一个API。</td>
+ <td>Disabled<br>
+ <sub>(available since 55)</sub></td>
+ <td>Disabled<br>
+ <sub>(available since 55)</sub></td>
+ <td>Disabled<br>
+ <sub>(available since 55)</sub></td>
+ <td>Disabled<br>
+ <sub>(available since 55)</sub></td>
+ <td><code>dom.payments.request.enabled</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="WebRTC">WebRTC</h3>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Feature</th>
+ <th scope="col">Firefox Nightly</th>
+ <th scope="col">Firefox Developer Edition</th>
+ <th scope="col">Firefox Beta</th>
+ <th scope="col">Firefox Release</th>
+ <th scope="col">Preference</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><strong>TCP ICE candidates</strong><br>
+ ICE candidates that use TCP rather than UDP are considered during ICE negotiation.</td>
+ <td>
+ <p>Disabled<br>
+ 41</p>
+
+ <p>Enabled<br>
+ 54</p>
+ </td>
+ <td>Disabled<br>
+ 41</td>
+ <td>Disabled<br>
+ 41</td>
+ <td>Disabled<br>
+ 41</td>
+ <td><code>media.peerconnection.ice.tcp</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="开发者工具">开发者工具</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Feature</th>
+ <th scope="col">Firefox Nightly</th>
+ <th scope="col">Firefox Developer Edition</th>
+ <th scope="col">Firefox Beta</th>
+ <th scope="col">Firefox Release</th>
+ <th scope="col">Preference</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr id="new-debugger-frontend">
+ <td><strong>Debugger rewrite in HTML</strong></td>
+ <td>52</td>
+ <td>52</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td><code>devtools.debugger.new-debugger-frontend</code></td>
+ </tr>
+ <tr id="new-console-frontend">
+ <td><strong>Console rewrite in HTML</strong></td>
+ <td>52</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td><code>devtools.webconsole.new-frontend-enabled</code></td>
+ </tr>
+ <tr id="performance-tool-options">
+ <td><strong>Experimental Performance tool options</strong><br>
+ Enables options in the UI for JIT optimizations, memory, etc.</td>
+ <td>41</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td>Disabled</td>
+ <td><code>devtools.performance.ui.experimental</code></td>
+ </tr>
+ <tr id="layout-side-panel">
+ <td><strong>Layout side panel</strong><br>
+ The Layout side panel allows to inspect and manage different CSS layout types like <a href="/en-US/docs/Web/CSS/CSS_Grid_Layout">CSS Grid Layout</a>.</td>
+ <td>Disabled<br>
+ <sub>(available since 52)</sub></td>
+ <td>Disabled<br>
+ <sub>(available since 52)</sub></td>
+ <td>Disabled<br>
+ <sub>(available since 52)</sub></td>
+ <td>Disabled<br>
+ <sub>(available since 52)</sub></td>
+ <td><code>devtools.layoutview.enabled</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="其他">其他</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Feature</th>
+ <th scope="col">Firefox Nightly</th>
+ <th scope="col">Firefox Developer Edition</th>
+ <th scope="col">Firefox Beta</th>
+ <th scope="col">Firefox Release</th>
+ <th scope="col">Preference</th>
+ </tr>
+ <tr>
+ <td><a href="https://support.mozilla.org/t5/Other/How-to-add-a-shortcut-to-a-website-on-Android/ta-p/21992"><strong>添加到主屏幕</strong></a><br>
+ The <code>icons</code>, <code>name</code>, <code>short_name</code>, and <code>theme_color</code> fields of the <a href="/en-US/docs/Web/Manifest">Web App Manifest</a> (if present) can now be as the source of the homescreen/apps window icons, apps window title, homescreen icon title, and apps window color (respectively) for "Add to home screen" (Firefox Mobile only).</td>
+ <td>关闭<br>
+ <sub>(available since 53)</sub></td>
+ <td>关闭<br>
+ <sub>(available since 53)</sub></td>
+ <td>关闭<br>
+ <sub>(available since 53)</sub></td>
+ <td>关闭<br>
+ <sub>(available since 52)</sub></td>
+ <td><code>manifest.install.enabled</code></td>
+ </tr>
+ <tr>
+ <td><strong>TLS 1.3</strong></td>
+ <td>开启</td>
+ <td>开启</td>
+ <td>关闭</td>
+ <td>关闭</td>
+ <td><code>security.tls.version.max</code> to <code>4</code></td>
+ </tr>
+ </thead>
+</table>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/Firefox/Releases">Firefox 开发者发行日志</a></li>
+ <li><a href="https://nightly.mozilla.org/">Firefox Nightly</a></li>
+ <li><a href="https://www.mozilla.org/en-US/firefox/developer/">Firefox 开发者版本</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/firefox/headless_mode/index.html b/files/zh-cn/mozilla/firefox/headless_mode/index.html
new file mode 100644
index 0000000000..855339e6d1
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/headless_mode/index.html
@@ -0,0 +1,270 @@
+---
+title: Headless mode
+slug: Mozilla/Firefox/Headless_mode
+translation_of: Mozilla/Firefox/Headless_mode
+---
+<div>{{FirefoxSidebar}}</div>
+
+<p class="summary">Headless模式是运行Firefox的一种非常有用的方式。就像听起来一样,Firefox正常运行,但没有任何可见UI组件。虽然不太适合浏览网页,但它对自动化测试非常有用。本文提供了有关运行 headless Firefox 的所有知识。</p>
+
+<h2 id="Using_headless_mode">Using headless mode</h2>
+
+<p>This section provide usage instructions for headless mode.</p>
+
+<h3 id="Basic_usage">Basic usage</h3>
+
+<p>You can run Firefox in headless mode from the command line, by including the <code>-headless</code> flag. For example:</p>
+
+<pre class="brush: bash">/path/to/firefox -headless</pre>
+
+<h3 id="Taking_screenshots">Taking screenshots</h3>
+
+<p>Since Firefox 57, the <code>-screenshot</code> flag allows you to take screenshots of websites. The basic usage:</p>
+
+<pre class="brush: bash">/path/to/firefox -headless -screenshot https://developer.mozilla.com</pre>
+
+<p>This creates a full-height screenshot of <code>https://developer.mozilla.com,</code> in the active directory called <code>screenshot.png</code>, with a viewport width of 800px.</p>
+
+<p>You can omit <code>-headless</code> when using <code>-screenshot, </code>as it is implied:</p>
+
+<pre class="brush: bash">/path/to/firefox -screenshot https://developer.mozilla.com</pre>
+
+<p>To override the default values, mentioned above, you can use the following flags/features:</p>
+
+<ul>
+ <li><code>-screenshot name url</code> — Set a custom name for the screenshot by including it between the <code>-screenshot</code> flag and the URL you want to capture. You can specify other web-compatible image formats such as <code>.jpg</code>, <code>.bmp</code>, etc.</li>
+ <li><code>--window-size=x</code> — Set a custom viewport width when taking the screenshot (full height is maintained). Note that the single argument version of this doesn't work.</li>
+ <li><code>--window-size=x,y</code> — Set a custom viewport width and height to capture.</li>
+</ul>
+
+<p>For example, the following command creates a screenshot of <code>https://developer.mozilla.com</code>, in the active directory called <code>test.jpg</code>, with a viewport width of 800px, and a height of 1000px:</p>
+
+<pre class="brush: bash">/path/to/firefox -screenshot test.jpg https://developer.mozilla.com --window-size=800,1000</pre>
+
+<h3 id="Browser_support">Browser support</h3>
+
+<p>Headless Firefox works on Fx55+ on Linux, and 56+ on Windows/Mac.</p>
+
+<h2 id="Automated_testing_with_headless_mode">Automated testing with headless mode</h2>
+
+<p>The most useful way to use headless Firefox, is to run automated tests. You can make your testing process much more efficient.</p>
+
+<h3 id="Selenium_in_Node.js">Selenium in Node.js</h3>
+
+<p>Here we'll create a <a href="http://www.seleniumhq.org/">Selenium</a> test, using <a href="https://nodejs.org/">Node.js</a> and the <code><a href="https://www.npmjs.com/package/selenium-webdriver">selenium-webdriver</a></code> package. For this guide, we'll assume that you already have basic familiarity with Selenium, Webdriver, and Node, and you already have a testing environment created. If now, work through our <a href="https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Your_own_automation_environment#Setting_up_Selenium_in_Node">Setting up Selenium in Node</a> guide, and return when you have.</p>
+
+<p>First, confirm you've installed Node and the <code>selenium-webdriver</code> on your system. Then create a new file, called <code>selenium-test.js,</code> and follow the steps below to populate it with test code.</p>
+
+<div class="note">
+<p><strong>Note</strong>: Alternatively, you could clone our <a href="https://github.com/mdn/headless-examples">headless-examples repo</a>. This also includes a package file, so you can just use <code>npm install</code> to install necessary dependencies.</p>
+</div>
+
+<ol>
+ <li>
+ <p>Let's add some code. Inside this file, start by importing the main <code>selenium-webdriver</code> module, and the <code>firefox</code> submodule:</p>
+
+ <pre class="brush: js">var webdriver = require('selenium-webdriver'),
+ By = webdriver.By,
+ until = webdriver.until;
+
+var firefox = require('selenium-webdriver/firefox');</pre>
+ </li>
+ <li>
+ <p>Next, we create a new <code>binary</code> object representing Firefox Nightly, and add the <code>-headless</code> argument, so it will run in headless mode:</p>
+
+ <pre class="brush: js">var binary = new firefox.Binary(firefox.Channel.NIGHTLY);
+binary.addArguments("-headless");</pre>
+ </li>
+ <li>
+ <p>Now let's create a new driver instance for Firefox, using <code>setFirefoxOptions()</code> to include an options object, which specifies that we want to run the test using the above binary. This step will be unnecessary on Linux, and after headless mode lands in the release channel on Windows/Mac, but it is still useful if you want to test Nightly-specific features:</p>
+
+ <pre class="brush: js">var driver = new webdriver.Builder()
+    .forBrowser('firefox')
+    .setFirefoxOptions(new firefox.Options().setBinary(binary))
+    .build();</pre>
+
+ <p>Alternatively, you can use options to set the binary and the headless arguments:</p>
+
+ <pre class="brush: js">var firefoxOptions = new firefox.Options();
+firefoxOptions.setBinary('/path/to/binary');
+firefoxOptions.headless();
+
+const driver = new webdriver.Builder()
+ .forBrowser('firefox')
+ .setFirefoxOptions(firefoxOptions)
+ .build();
+</pre>
+ </li>
+ <li>
+ <p>Finally, add the following code, which performs a simple test on the Google search homepage:</p>
+
+ <pre class="brush: js">driver.get('https://www.google.com');
+driver.findElement(By.name('q')).sendKeys('webdriver');
+
+driver.sleep(1000).then(function() {
+ driver.findElement(By.name('q')).sendKeys(webdriver.Key.TAB);
+});
+
+driver.findElement(By.name('btnK')).click();
+
+driver.sleep(2000).then(function() {
+ driver.getTitle().then(function(title) {
+ if(title === 'webdriver - Google Search') {
+ console.log('Test passed');
+ } else {
+ console.log('Test failed');
+ }
+ });
+});
+
+driver.quit();</pre>
+ </li>
+ <li>
+ <p>Finally, run your test with following command:</p>
+
+ <pre class="brush: bash">node selenium-test</pre>
+ </li>
+</ol>
+
+<p>That's it! After a few seconds, you should see the message "Test passed" returned in the console.</p>
+
+<p><a href="https://mykzilla.org/2017/08/30/headless-firefox-in-node-js-with-selenium-webdriver/">Headless Firefox in Node.js with selenium-webdriver</a>, by Myk Melez, contains additional useful tips and tricks for running Node.js Selenium tests with headless mode.</p>
+
+<h3 id="Selenium_in_Java">Selenium in Java</h3>
+
+<div class="note">
+<p><strong>Note</strong>: Thanks a lot to nicholasdipiazza for writing these instructions!</p>
+</div>
+
+<p>This guide assumes you already have Geckodriver on your machine, as explained in  <a href="https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Your_own_automation_environment#Setting_up_Selenium_in_Node">Setting up Selenium in Node</a>, and an IDE set up which supports Gradle projects.</p>
+
+<ol>
+ <li>
+ <p>Download our <a href="https://github.com/mdn/headless-examples/blob/master/headlessfirefox-gradle.zip">headlessfirefox-gradle.zip</a> archive (<a href="https://github.com/mdn/headless-examples/tree/master/headlessfirefox-gradle">see the source here</a>). Extract it, and import the headlessfirefox folder into your IDE, as a gradle project.</p>
+ </li>
+ <li>
+ <p>Edit the <code>build.gradle</code> file, to set selenium to a later version, if needed. At the time of writing, we used 3.5.3.</p>
+
+ <pre class="brush: java">group 'com.mozilla'
+version '1.0'
+
+apply plugin: 'java'
+
+sourceCompatibility = 1.8
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ compile('org.seleniumhq.selenium:selenium-api:3.5.3')
+ compile('org.seleniumhq.selenium:selenium-remote-driver:3.5.3')
+ compile('org.seleniumhq.selenium:selenium-server:3.5.3')
+
+ testCompile group: 'junit', name: 'junit', version: '4.12'
+}</pre>
+ </li>
+ <li>
+ <p>Edit the <code>webdriver.gecko.driver</code> property, in the HeadlessFirefoxSeleniumExample.java file, to equal the path where you installed geckodriver (see line 15 below).</p>
+
+ <pre class="brush: java">package com.mozilla.example;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.firefox.FirefoxBinary;
+import org.openqa.selenium.firefox.FirefoxDriver;
+import org.openqa.selenium.firefox.FirefoxOptions;
+
+import java.util.concurrent.TimeUnit;
+
+public class HeadlessFirefoxSeleniumExample {
+ public static void main(String [] args) {
+ FirefoxBinary firefoxBinary = new FirefoxBinary();
+ firefoxBinary.addCommandLineOptions("--headless");
+ System.setProperty("webdriver.gecko.driver", "/opt/geckodriver");
+ FirefoxOptions firefoxOptions = new FirefoxOptions();
+ firefoxOptions.setBinary(firefoxBinary);
+ FirefoxDriver driver = new FirefoxDriver(firefoxOptions);
+ try {
+ driver.get("http://www.google.com");
+ driver.manage().timeouts().implicitlyWait(4,
+ TimeUnit.SECONDS);
+ WebElement queryBox = driver.findElement(By.name("q"));
+ queryBox.sendKeys("headless firefox");
+ WebElement searchBtn = driver.findElement(By.name("btnK"));
+ searchBtn.click();
+ WebElement iresDiv = driver.findElement(By.id("ires"));
+ iresDiv.findElements(By.tagName("a")).get(0).click();
+ System.out.println(driver.getPageSource());
+ } finally {
+ driver.quit();
+ }
+ }
+}</pre>
+ </li>
+ <li>
+ <p>Run the java class, and you should see the HTML content of this page printed in your console/terminal.</p>
+ </li>
+</ol>
+
+<h3 id="Selenium_in_Python">Selenium in Python</h3>
+
+<p>This guide assumes you already have geckodriver on your machine, as explained in <a href="https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Your_own_automation_environment#Setting_up_Selenium_in_Node">Setting up Selenium in Node</a>.</p>
+
+<ol>
+ <li>
+ <p>Install the latest version of the <a href="https://pypi.python.org/pypi/selenium">Python client for Selenium</a>.</p>
+ </li>
+ <li>
+ <p>Edit the following, to set the <code>executable_path</code> on line 11, to the path where you installed geckodriver:</p>
+
+ <pre class="brush: python">from selenium.webdriver import Firefox
+from selenium.webdriver.common.by import By
+from selenium.webdriver.common.keys import Keys
+from selenium.webdriver.firefox.options import Options
+from selenium.webdriver.support import expected_conditions as expected
+from selenium.webdriver.support.wait import WebDriverWait
+
+if __name__ == "__main__":
+ options = Options()
+ options.add_argument('-headless')
+ driver = Firefox(executable_path='geckodriver', firefox_options=options)
+ wait = WebDriverWait(driver, timeout=10)
+ driver.get('http://www.google.com')
+ wait.until(expected.visibility_of_element_located((By.NAME, 'q'))).send_keys('headless firefox' + Keys.ENTER)
+ wait.until(expected.visibility_of_element_located((By.CSS_SELECTOR, '#ires a'))).click()
+ print(driver.page_source)
+ driver.quit()</pre>
+ </li>
+ <li>
+ <p>Run the Python script, and you should see the HTML content of this page printed in your console/terminal.</p>
+ </li>
+</ol>
+
+<h3 id="Other_testing_solutions">Other testing solutions</h3>
+
+<ul>
+ <li>Slimerjs has Firefox support built in on Linux, with Mac and Windows support, coming soon. See <a href="https://adriftwith.me/coding/2017/04/21/headless-slimerjs-with-firefox/">Headless SlimerJS with Firefox</a> by Brendan Dahl for more details.</li>
+ <li><a href="https://github.com/DevExpress/testcafe">TestCafe</a> (v.0.18.0 and higher) also supports testing in headless Firefox, by default. See <a href="https://devexpress.github.io/testcafe/blog/testcafe-v0-18-0-released.html#testing-in-headless-firefox">the documentation</a> for the details.</li>
+</ul>
+
+<p>In addition, you can use headless Firefox to run automated tests written in most other popular testing apps, as long as you are able to set environment variables.</p>
+
+<h2 id="Troubleshooting_and_further_help">Troubleshooting and further help</h2>
+
+<p>If you are having trouble getting headless mode to work, then do not worry — we are here to help. This section is designed to be added to as more questions arise, and answers are found.</p>
+
+<ul>
+ <li>On Linux, certain libraries are currently required on your system, even though headless mode doesn't use them, as Firefox links against them. See {{bug(1372998)}}, for more details and progress towards a fix.</li>
+</ul>
+
+<p>If you want to ask the engineers a question, the best place to go is the <code>#headless</code> channel on <a href="https://wiki.mozilla.org/IRC">Mozilla IRC</a>. If you are pretty sure you've found a bug, file it on <a href="https://bugzilla.mozilla.org/">Mozilla Bugzilla</a>.</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="https://intoli.com/blog/running-selenium-with-headless-firefox/">Using Selenium with Headless Firefox (on Windows)</a> by Andre Perunicic (uses Python)</li>
+ <li><a href="https://mykzilla.org/2017/08/30/headless-firefox-in-node-js-with-selenium-webdriver/">Headless Firefox in Node.js with selenium-webdriver</a> by Myk Melez</li>
+ <li><a href="https://adriftwith.me/coding/2017/04/21/headless-slimerjs-with-firefox/">Headless SlimerJS with Firefox</a> by Brendan Dahl</li>
+ <li><a href="http://blog.rousek.name/2017/09/08/going-headless-with-firefox-since-55/">Using Selenium with Headless Firefox on Travis-CI</a> by Josef Rousek</li>
+</ul>
diff --git a/files/zh-cn/mozilla/firefox/index.html b/files/zh-cn/mozilla/firefox/index.html
new file mode 100644
index 0000000000..b0bc71f5b5
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/index.html
@@ -0,0 +1,74 @@
+---
+title: Firefox
+slug: Mozilla/Firefox
+tags:
+ - Firefox
+ - Mozilla
+ - NeedsTranslation
+ - TopicStub
+translation_of: Mozilla/Firefox
+---
+<div>{{FirefoxSidebar}}</div>
+
+<p><a class="external external-icon" href="https://www.mozilla.org/firefox/all/">Firefox(非正式中文名称“火狐”)</a>是Mozilla出品的网页浏览器,可用于Windows、Mac OS X、Linux等桌面操作系统,也可以用于Android等移动操作系统。得益于对最新的网络标准的广泛兼容和强有力的<a href="/zh-CN/docs/Tools">开发工具</a>,Firefox对最终用户和开发者而言都是优秀的浏览器。</p>
+
+<p>Firefox是一个开源项目,许多代码都是由志愿者社群提供的。在此你将了解如何为Firefox项目做贡献,你也可以找到关于制作附加组件、使用Firefox开发者工具等内容。</p>
+
+<div class="summary">
+<p>了解如何为 <a class="external external-icon" href="https://www.mozilla.org/firefox/">Firefox</a>添加附加组件,如何开发和构建Firefox自身,以及了解Firefox以及其他组件内部如何运作。</p>
+</div>
+
+<ul class="card-grid">
+ <li><span>面向开发者的发布说明</span>
+
+ <p><a href="/zh-CN/docs/Firefox/Releases">面向开发者的发布说明</a>;了解每一个Firefox新版本为网站开发者与拓展开发者带来的新功能.</p>
+ </li>
+ <li><span>项目文档</span>
+ <p>获取关于 <a href="/zh-CN/docs/Mozilla"> Firefox 的内部机制 </a> 和它的构建系统的详细信息,从而在代码中找到方向。</p>
+ </li>
+ <li><span>开发者指南</span>
+ <p>我们的 <a href="/zh-CN/docs/Developer_Guide">开发者指南</a> 提供了关于获取与编译Firefox源代码、在代码中找到方向、以及对项目作出贡献的详细说明。</p>
+ </li>
+</ul>
+
+<h2 id="Firefox_发布频道">Firefox 发布频道</h2>
+
+<p>Firefox 通过 5 个 <strong>发布频道</strong> 进行发布。</p>
+
+<h3 id="Firefox_Nightly">Firefox Nightly</h3>
+
+<p>每天晚上,我们都使用 <a href="/zh-CN/docs/mozilla-central">mozilla-central</a> 代码库中的最新代码构建的版本。这些版本适用于开发者或想要尝试最新的、处于活跃开发中的特性的使用者。</p>
+
+<p><a class="external external-icon" href="https://nightly.mozilla.org/" style="width: 250px; display: block; margin-left: auto; margin-right: auto; padding: 10px; text-align: center; border-radius: 4px; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;">下载 Firefox Nightly</a></p>
+
+<h3 id="Firefox_Developer_Edition">Firefox Developer Edition</h3>
+
+<p>这是一个为开发者量身定制的版本。每隔六周,我们便选择Firefox Nightly 频道中足够稳定的特性创建一个新版本的Firefox Developer Edition。同时我们还仅仅在该发布频道中为开发者添加一些特有的特性。</p>
+
+<p><a href="/zh-CN/docs/Firefox/Developer_Edition">了解关于Firefox Developer Edition的更多信息</a>。</p>
+
+<p><a class="external external-icon" href="https://www.mozilla.org/firefox/developer/" style="width: 250px; display: block; margin-left: auto; margin-right: auto; padding: 10px; text-align: center; border-radius: 4px; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;">下载 Firefox Developer Edition</a></p>
+
+<h3 id="Firefox_Beta">Firefox Beta</h3>
+
+<p>在Firefox Developer Edition停留六周之后,我们将选择足够稳定的特性构建一个新版本的 Firefox Beta 。Firefox Beta 版本适用于热衷于测试将在下一个Firefox 版本中推出的新特性的用户。</p>
+
+<p><a class="external external-icon" href="https://www.mozilla.org/firefox/channel/#beta" style="width: 250px; display: block; margin-left: auto; margin-right: auto; padding: 10px; text-align: center; border-radius: 4px; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;">下载 Firefox Beta</a></p>
+
+<h3 id="Firefox">Firefox</h3>
+
+<p>当在Beta频道中稳定六周之后,我们便发布新版本Firefox,将新特性推送至数亿用户。</p>
+
+<p><a class="external external-icon" href="https://www.mozilla.org/firefox/channel/#firefox" style="width: 250px; display: block; margin-left: auto; margin-right: auto; padding: 10px; text-align: center; border-radius: 4px; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;">下载 Firefox</a></p>
+
+<h3 id="Firefox_延长支持版_ESR">Firefox 延长支持版 (ESR)</h3>
+
+<p>Firefox ESR 是在较长周期提供支持的桌面版本Firefox,适用于学校、大学、商业机构等组织以及需要延长支持用以进行大规模部署的用户。</p>
+
+<p><a href="/zh-CN/docs/Firefox/Firefox_ESR">了解关于 Firefox 延长支持版的更多信息</a>。</p>
+
+<p><a class="external external-icon" href="https://www.mozilla.org/firefox/organizations/all/" style="width: 250px; display: block; margin-left: auto; margin-right: auto; padding: 10px; text-align: center; border-radius: 4px; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;">下载 Firefox ESR</a></p>
+
+<h2 id="Firefox_配置">Firefox 配置</h2>
+
+<p>如果你在日常中使用多个Firefox发行频道,或者多个不同的配置选项,你应该阅读了解如何通过Firefox的配置管理器与其他管理工具实现<a href="/zh-CN/docs/Mozilla/Firefox/Multiple_profiles">使用多个Firefox配置</a>。</p>
diff --git a/files/zh-cn/mozilla/firefox/multiprocess_firefox/cross_process_object_wrappers/index.html b/files/zh-cn/mozilla/firefox/multiprocess_firefox/cross_process_object_wrappers/index.html
new file mode 100644
index 0000000000..38fde2acbf
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/multiprocess_firefox/cross_process_object_wrappers/index.html
@@ -0,0 +1,114 @@
+---
+title: 跨进程对象包装器
+slug: Mozilla/Firefox/Multiprocess_Firefox/Cross_Process_Object_Wrappers
+translation_of: Mozilla/Firefox/Multiprocess_Firefox/Cross_Process_Object_Wrappers
+---
+<div>{{FirefoxSidebar}}</div><div class="summary">
+<p>本文档介绍了 Cross Process Object Wrappers (CPOWs),这使 chrome 代码能够同步访问多进程 Firefox 中的内容。</p>
+</div>
+
+<p>在多进程 Firefox 中,chrome 代码运行在与 Web 内容不同的另一个进程中。因此 chrome 代码不能直接与 Web 内容交互;相反,它必须考虑将与 Web 内容交互的脚本放在单独的脚本中,这被称为框架脚本(frame scripts),也称帧脚本。</p>
+
+<p>Chrome 代码可以使用消息管理器加载框架脚本到内容进程,然后可以使用消息传递 API 与它们通信。有关于此的更多信息,详见 <a href="/en-US/docs/The_message_manager">消息管理器</a> 的使用文档。</p>
+
+<p>Chrome 到内容的通信必须是异步的。这是因为 chrome 进程运行着 Firefox UI,因此如果被内容进程所影响,缓慢的内容进程可能致使 Firefox 对用户无响应。<br>
+ <br>
+ 将同步代码转换成异步可能是困难并且耗时的。作为一个迁移的辅助,消息框架使框架脚本变成了内容对象,通过一个被称为 Cross Process Object Wrapper(简称 CPOW)的包装器,使其在 chrome 中可用。但是,尽管 CPOWs 很方便,它们存在<a href="/en-US/docs/Cross_Process_Object_Wrappers#Limitations_of_CPOWs">严重的局限性并且可能导致响应性问题</a>,因此只应在必要时使用,并仅作为迁移的辅助。</p>
+
+<h2 id="从框架脚本传递_CPOWs">从框架脚本传递 CPOWs</h2>
+
+<p>框架脚本可以发送消息到 chrome,使用两个全局函数之一:<a href="/en-US/docs/The_message_manager#Content_to_chrome"><code>sendAsyncMessage()</code> 或者 <code>sendSyncMessage()</code></a>。这些函数的第三个可选参数是被包装的属性对象。举例来说,框架脚本在用户点击它时发送一个 DOM 节点到 chrome,并将 <code>clicked</code> 属性作为第三个参数:</p>
+
+<pre class="brush: js">// frame script
+addEventListener("click", function (event) {
+ sendAsyncMessage("my-e10s-extension-message", {}, { clicked : event.target });
+}, false);</pre>
+
+<p>在 chrome 脚本中,DOM 节点现在是通过 Cross Process Object Wrapper 访问,作为该消息的 <code>objects</code>  属性的个属性。chrome 脚本可以获得和设置包装的对象属性,以及调用它的函数:</p>
+
+<pre class="brush: js">// chrome script
+windowMM.addMessageListener("my-e10s-extension-message", handleMessage);
+
+function handleMessage(message) {
+ let wrapper = message.objects.clicked;
+ console.log(wrapper.innerHTML);
+ wrapper.innerHTML = "&lt;h2&gt;已被 chrome 修改!&lt;/h2&gt;"
+ wrapper.setAttribute("align", "center");
+}</pre>
+
+<h2 id="自动生成的_CPOWs">自动生成的 CPOWs</h2>
+
+<p>没有自我声明多进程兼容的附加组件会加载一些<a href="/en-US/Firefox/Multiprocess_Firefox/Limitations_of_chrome_scripts#Compatibility_shims">兼容性垫片</a>。其中一个垫片提供了以下行为:每当 chrome 代码尝试直接访问内容(例如通过 <a href="/en/docs/Working_with_windows_in_chrome_code#The_content_shortcut"><code>window.content</code></a> 或者 <a href="/en-US/docs/Mozilla/Tech/XUL/browser#p-contentDocument"><code>browser.contentDocument</code></a>),提供一个包装了内容的 CPOW。这意味着下面这样的例子在多进程 Firefox 中也能正常工作。</p>
+
+<pre class="brush: js">gBrowser.selectedBrowser.contentDocument.body.innerHTML = "被 chrome 代码替换";</pre>
+
+<p>但仍然要记住,这是通过 CPOW 访问,并不是直接访问内容。</p>
+
+<h2 id="双向_CPOWs">双向 CPOWs</h2>
+
+<p>一个常见的模式是 chrome 代码访问内容对象并添加事件监听器到那里。为了解决这个问题,CPOWs 是双向的。这意味着如果内容传递了一个 CPOW 到 chrome 进程,chrome 进程可以同步传递对象(如事件监听器函数)到 CPOW 中定义的函数。</p>
+
+<p>这意味着你可以写这样的代码:</p>
+
+<pre class="brush: js">// frame script
+
+/*
+在 mouseover,发送 button 到 chrome 脚本,以一个CPOW形式。
+*/
+
+var button = content.document.getElementById("click-me");
+
+button.addEventListener("mouseover", function (event) {
+ sendAsyncMessage("my-addon-message", {}, { element : event.target });
+}, false);</pre>
+
+<pre class="brush: js">// chrome script
+
+/*
+载入框架脚本,然后监听消息。
+在我们得到消息时,提取 CPOW 并添加一个函数作为监听器到按钮的 "click" 事件。
+*/
+
+ browserMM.loadFrameScript("chrome://my-addon/content/frame-script.js", false);
+ browserMM.addMessageListener("my-addon-message", function(message) {
+ let wrapper = message.objects.element;
+ wrapper.addEventListener("click", function() {
+ console.log("被点击了");
+ });
+ });
+</pre>
+
+<h2 id="映射内容文档到_XUL_浏览器">映射内容文档到 XUL 浏览器</h2>
+
+<p>一个常见的模式是获取 XUL <a href="/en-US/docs/XUL/browser"><code>&lt;browser&gt;</code></a>,它对应一个内容文档。要做到这点, <code>gBrowser.getBrowserForDocument</code>  <code>和 gBrowser.getBrowserForContentWindow</code> 分别可以传递一个内容文档和内容窗口的 CPOW,并且返回这些文档 / 窗口所属的 XUL  <code>&lt;browser&gt;。</code>如果没有找到这样的浏览器,两者都是返回 null。</p>
+
+<h2 id="CPOWs_的限制">CPOWs 的限制</h2>
+
+<p>尽管 CPOWs 可以方便的使用,但它有几个主要的局限性,在下面列出。</p>
+
+<h3 id="CPOWs_与平台_API">CPOWs 与平台 API</h3>
+
+<p>你不能传递 CPOWs 到预期会收到 DOM 对象的平台 API。举例来说,你不能传递一个 CPOW  <code>到 </code><a href="http://dxr.mozilla.org/mozilla-central/source/dom/interfaces/base/nsIFocusManager.idl"><code>nsIFocusManager.setFocus()</code></a>。</p>
+
+<h3 id="Chrome_响应性">Chrome 响应性</h3>
+
+<p>在 chrome 这边缺少同步 API 是有意的:因为 chrome 进程运行着 Firefox UI,任何响应性问题都将影响整个浏览器。在制成 chrome 进程与内容进程的过程中,CPOWs 打破了这个原则,并且致使内容进程可能使整个浏览器陷入无响应状态。</p>
+
+<h3 id="性能">性能</h3>
+
+<p>尽管包装器看起来像是一个完全在 chrome 脚本范围下管控的对象,但它实际上只是一个到内容进程中一个对象的引用。在你访问一个包装器的属性时,它发送一个同步消息到内容进程及返回结果。这意味着它比使用一个对象慢很多倍。</p>
+
+<h3 id="消息顺序">消息顺序</h3>
+
+<p>CPOWs 可能违反你做出的有关消息排序的假设。考虑以下代码:</p>
+
+<pre class="brush: js">mm.addMessageListener("GotLoadEvent", function (msg) {
+ mm.sendAsyncMessage("ChangeDocumentURI", {newURI: "hello.com"});
+ let uri = msg.objects.document.documentURI;
+ dump("收到加载事件: " + uri + "\n");
+});
+</pre>
+
+<p>这发送了一个消息,要求框架脚本更改当前文档的 URI,然后通过一个 CPOW 访问当前的文档 URI。你可能预期 <code>uri</code> 的值得到设置的 "hello.com"。但这不一定:为了避免死锁,CPOW 消息可以绕过正常的消息并且被优先处理。对 documentURI 属性的请求有可能在 "ChangeDocumentURI" 的消息之前被处理,并因而 <code>uri</code> 持有它在更改之前的值。<br>
+ <br>
+ 出于这个原因,最好不要混用 CPOWs 和正常的消息管理器消息。还有一个坏主意是将 CPOWs 用于任何安全相关,因为你可能获得不一致的结果,与使用消息管理器的相关代码。</p>
diff --git a/files/zh-cn/mozilla/firefox/multiprocess_firefox/debugging_frame_scripts/index.html b/files/zh-cn/mozilla/firefox/multiprocess_firefox/debugging_frame_scripts/index.html
new file mode 100644
index 0000000000..57c1b3412a
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/multiprocess_firefox/debugging_frame_scripts/index.html
@@ -0,0 +1,53 @@
+---
+title: 调试框架脚本
+slug: Mozilla/Firefox/Multiprocess_Firefox/Debugging_frame_scripts
+translation_of: Mozilla/Firefox/Multiprocess_Firefox/Debugging_frame_scripts
+---
+<div>{{FirefoxSidebar}}</div><div class="geckoVersionNote">
+<p>浏览器内容工具箱仅在 Firefox Nightly 中可用,并且仅在多进程模式下可用。</p>
+</div>
+
+<p>你可以使用浏览器内容工具箱来调试框架脚本。浏览器内容工具箱是一个单独的窗口,它包括一些共享的 <a href="/en-US/docs/Tools">Firefox 开发者工具</a>,具体来说:<a href="/en-US/docs/Web/API/Console">控制台</a>,<a href="/en-US/docs/Tools/Debugger">JavaScript 调试器</a>,以及<a href="/en-US/docs/Tools/Scratchpad">代码草稿纸</a> —— 但它们着重于浏览器的内容进程。这意味着你可以调试你的附加组件中的框架脚本。</p>
+
+<h2 id="打开浏览器内容工具箱">打开浏览器内容工具箱</h2>
+
+<p>{{EmbedYouTube("Cg6X_zIu7Xk")}}</p>
+
+<p>要打开浏览器内容工具箱,你需要:</p>
+
+<ul>
+ <li>正在运行 Firefox Nightly</li>
+ <li>多进程 Firefox 已启用:打开“选项”页面,选择"启用 E10S (多进程)“,然后重新启动。在你运行多进程 Firefox 时,一个虚拟指示符会出现,远程选项卡的标题会有下划线。</li>
+ <li>在 Firefox 开发者工具的设置中启用 <a href="/en-US/docs/Tools/Tools_Toolbox#Settings">"chrome 和附加组件调试" 和 "远程调试"</a>。</li>
+</ul>
+
+<p>你应该已经在 Firefox 菜单中 ”Web 开发者“的子菜单中看到”浏览器内容工具箱“(或者工具菜单,如果你显示了菜单栏,或者在 OS X)。它会打开一个单独的窗口:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/9761/browser-content-toolbox.png" style="display: block; height: 854px; margin-left: auto; margin-right: auto; width: 723px;">If you've used the <a href="/en-US/docs/Tools/Tools_Toolbox">Firefox Developer Tools</a> before, this should look pretty familiar.</p>
+
+<p>Along the top is a row of tabs that you can use to switch the active tool. Currently we only support the <a href="/en-US/docs/Web/API/Console">Console</a>, the <a href="/en-US/docs/Tools/Debugger">Debugger</a>, and <a href="/en-US/docs/Tools/Scratchpad">Scratchpad</a> in the Browser Content Toolbox. At the right of this row are three buttons that activate the <a href="/en-US/docs/Tools/Web_Console#The_split_console">split console</a>, open settings, and close the toolbox.</p>
+
+<p>The rest of the toolbox is taken up with the tool you've currently selected.</p>
+
+<h2 id="使用">使用</h2>
+
+<p>{{EmbedYouTube("XF0ULNnNOxg")}}</p>
+
+<h3 id="调试器">调试器</h3>
+
+<p>The Debugger lists all the scripts that are loaded into the content process. You'll find your frame scripts listed under the chrome:// URL you registered for them:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/9771/browser-content-toolbox-listing.png" style="display: block; margin-left: auto; margin-right: auto; width: 723px;">You can set breakpoints, of course, and do all the other <a href="/en-US/docs/Tools/Debugger">things supported by the debugger</a>.</p>
+
+<h3 id="控制台">控制台</h3>
+
+<p>The Console logs output from your frame scripts. If you want to use it to evaluate JavaScript in your frame script's scope, there's a trick you need to know:</p>
+
+<ul>
+ <li>在你的框架脚本中设置一个断点。</li>
+ <li>When you hit the breakpoint, switch to the Console, or activate the <a href="/en-US/docs/Tools/Web_Console#The_split_console">split console</a> by pressing "Escape".</li>
+</ul>
+
+<p>Now the console's scope is your frame script's scope, and you can interact directly with it:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/9769/browser-content-toolbox-debugging.png" style="display: block; margin-left: auto; margin-right: auto; width: 839px;"></p>
diff --git a/files/zh-cn/mozilla/firefox/multiprocess_firefox/faq/index.html b/files/zh-cn/mozilla/firefox/multiprocess_firefox/faq/index.html
new file mode 100644
index 0000000000..3299dd0856
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/multiprocess_firefox/faq/index.html
@@ -0,0 +1,18 @@
+---
+title: FAQ
+slug: Mozilla/Firefox/Multiprocess_Firefox/FAQ
+translation_of: Mozilla/Firefox/Multiprocess_Firefox/FAQ
+---
+<div>{{FirefoxSidebar}}</div><h2 id="使命">使命</h2>
+
+<p> </p>
+
+<h2 id="历史">历史</h2>
+
+<p> </p>
+
+<h2 id="方式">方式</h2>
+
+<p> </p>
+
+<h2 id="影响">影响</h2>
diff --git a/files/zh-cn/mozilla/firefox/multiprocess_firefox/index.html b/files/zh-cn/mozilla/firefox/multiprocess_firefox/index.html
new file mode 100644
index 0000000000..2936128948
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/multiprocess_firefox/index.html
@@ -0,0 +1,78 @@
+---
+title: 多进程 Firefox
+slug: Mozilla/Firefox/Multiprocess_Firefox
+tags:
+ - NeedsTranslation
+ - TopicStub
+translation_of: Mozilla/Firefox/Multiprocess_Firefox
+---
+<div>{{FirefoxSidebar}}</div><p>在目前版本的桌面版 Firefox 中,整个浏览器运行在单个操作系统进程中。尤其是 JavaScript 在同一进程中运行着用户界面(UI,也称 "chrome 代码"),它还搭载着所有网页(也称“内容”,即“标签页”)。<br>
+ <br>
+ 未来版本的 Firefox 将在单独的进程中运行浏览器界面,与网页内容的进程分离。这种架构的第一次迭代是所有浏览器标签页在同一个进程中运行,浏览器界面运行在另一个进程中。在未来的迭代中,我们期望有一个以上的内容进程。提供多进程 Firefox 的项目名为 Electrolysis,有时被简称为 e10s。</p>
+
+<p>普通的网页不会受到多进程 Firefox 的影响。Firefox 本身和 Firefox 附加组件的开发者将受到影响,如果他们的代码依赖于能直接访问 Web 内容。</p>
+
+<p>不同于此前的直接访问内容,chrome JavaScript 将使用<a href="/Firefox/Multiprocess_Firefox/Message_manager">消息管理器</a>来访问内容。为了帮助缓解过渡期,我们实现了<a href="/Firefox/Multiprocess_Firefox/Cross_Process_Object_Wrappers">跨进程对象包装器(CPOW)</a>和一些<a href="/Firefox/Multiprocess_Firefox/Limitations_of_chrome_scripts#Compatibility_shims">面向附加组件开发者的兼容性垫片</a>。如果你是一名附加组件开发者并且想知道自己是否受到影响,参见<a href="/Mozilla/Add-ons/Working_with_multiprocess_Firefox">多进程 Firefox 工作指南</a>。</p>
+
+<p>多进程 Firefox 目前在 <a class="external external-icon" href="https://www.mozilla.org/firefox/developer/">开发者版本</a> 默认启用。</p>
+
+<hr>
+<div class="column-container">
+<div class="column-half">
+<dl>
+ <dt><a href="/Firefox/Multiprocess_Firefox/Technical_overview">技术概述</a></dt>
+ <dd>高等层面看待多进程 Firefox 如何被实现。</dd>
+ <dt><a href="/Firefox/Multiprocess_Firefox/Glossary">术语表</a></dt>
+ <dd>多进程 Firefox 领域相关的术语参考。</dd>
+ <dt><a href="/Firefox/Multiprocess_Firefox/Message_Manager">消息管理器</a></dt>
+ <dd>完整的指南,在 chrome 与内容之间通信的对象。</dd>
+ <dt><a href="/en-US/Add-ons/SDK/Guides/Multiprocess_Firefox_and_the_SDK">基于 SDK 的附加组件</a></dt>
+ <dd>如何迁移使用 Add-on SDK 开发的附加组件。</dd>
+ <dt><a href="/Firefox/Multiprocess_Firefox/Which_URIs_load_where">各类 URI 在哪里加载</a></dt>
+ <dd>各类 URI 的快速指南:chrome:, about:, file:, resource: - 在哪个进程被加载。</dd>
+</dl>
+</div>
+
+<div class="column-half">
+<dl>
+ <dt><a href="/Firefox/Multiprocess_Firefox/Motivation">动机</a></dt>
+ <dd>为什么我们要实现多进程的 Firefox:性能、安全和稳定性。</dd>
+ <dt><a href="/Mozilla/Add-ons/Working_with_multiprocess_Firefox">附加组件迁移指南</a></dt>
+ <dd>如果你是一名附加组件开发者,看看你的影响,以及如何更新你的代码。</dd>
+ <dt><a href="/Firefox/Multiprocess_Firefox/Cross_Process_Object_Wrappers">跨进程对象包装器(CPOW)</a></dt>
+ <dd>Cross Process Object Wrappers 是一个迁移辅助,使 chrome 代码能够访问内容。</dd>
+ <dt><a href="/Firefox/Multiprocess_Firefox/Debugging_frame_scripts">调试内容进程</a></dt>
+ <dd>如何调试运行在内容进程中的代码,包括框架和进程脚本。</dd>
+ <dt><a href="/docs/Mozilla/Firefox/Multiprocess_Firefox/Tab_selection_in_multiprocess_Firefox">多进程 Firefox 中的标签选择</a></dt>
+ <dd>多进程 Firefox 中如何切换标签页。</dd>
+</dl>
+</div>
+</div>
+
+<hr>
+<div class="column-container">
+<div class="column-half">
+<dl>
+ <dt><a href="/Firefox/Multiprocess_Firefox/Limitations_of_chrome_scripts">chrome 脚本的限制</a></dt>
+ <dd>哪些 chrome 代码的做法将不再有效,以及如何解决。</dd>
+</dl>
+</div>
+
+<div class="column-half">
+<dl>
+ <dt><a href="/Firefox/Multiprocess_Firefox/Limitations_of_frame_scripts">框架脚本的限制</a></dt>
+ <dd>哪些框架脚本的做法将不再有效,以及如何代替。</dd>
+</dl>
+</div>
+</div>
+
+<hr>
+<h2 id="联系我们">联系我们</h2>
+
+<p>有关此项目的更多信息、参与或提问。</p>
+
+<ul>
+ <li><strong>Electrolysis 项目页面</strong>: <a href="https://wiki.mozilla.org/Electrolysis">https://wiki.mozilla.org/Electrolysis</a></li>
+ <li><strong>IRC</strong>: #e10s on <a href="https://wiki.mozilla.org/IRC">irc.mozilla.org</a></li>
+ <li><strong>邮件列表</strong>: <a href="https://groups.google.com/forum/#!forum/mozilla.dev.tech.electrolysis">dev.tech.electrolysis</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/firefox/multiprocess_firefox/limitations_of_chrome_scripts/index.html b/files/zh-cn/mozilla/firefox/multiprocess_firefox/limitations_of_chrome_scripts/index.html
new file mode 100644
index 0000000000..130ce276e3
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/multiprocess_firefox/limitations_of_chrome_scripts/index.html
@@ -0,0 +1,197 @@
+---
+title: chrome 脚本的限制
+slug: Mozilla/Firefox/Multiprocess_Firefox/Limitations_of_chrome_scripts
+translation_of: Mozilla/Firefox/Multiprocess_Firefox/Limitations_of_chrome_scripts
+---
+<div>{{FirefoxSidebar}}</div><p>This page describes patterns that used to work in the chrome process that will no longer work in multiprocess Firefox. These are the sorts of things that will break an old add-on in multiprocess Firefox. The fix is generally some variant of "do that in a frame script loaded into the content process".</p>
+
+<p>This is one of a pair of articles: the other one lists <a href="/en-US/Firefox/Multiprocess_Firefox/Limitations_of_frame_scripts">limitations of frame scripts</a>.</p>
+
+<h2 id="兼容性垫片">兼容性垫片</h2>
+
+<p>For many of the patterns described here we've implemented compatibility shims so the patterns still work. For example: whenever extensions try to access web content from the chrome process, the browser will return a <a href="https://developer.mozilla.org/en-US/docs/Cross_Process_Object_Wrappers">Cross Process Object Wrapper</a> that gives the chrome code synchronous access to the content.</p>
+
+<p>You'll get the shims for your add-on by default, unless you set the <a href="/en-US/Add-ons/Install_Manifests#multiprocessCompatible"><code>multiprocessCompatible</code> flag in your add-on's install manifest</a>.</p>
+
+<p>However, these shims are not a substitute for migrating extensions:</p>
+
+<ul>
+ <li>they are only a temporary measure, and will be removed eventually</li>
+ <li>they can have a bad effect on responsiveness</li>
+ <li>there are likely to be edge cases in which they don't work properly</li>
+</ul>
+
+<p>For each pattern we've noted:</p>
+
+<ul>
+ <li>whether a shim exists and what kind of behavior it provides</li>
+ <li>how to update your add-on so you don't need the shim</li>
+</ul>
+
+<h2 id="gBrowser.contentWindow_window.content...">gBrowser.contentWindow, window.content...</h2>
+
+<h3 id="如果没有垫片">如果没有垫片</h3>
+
+<p>所有在 chrome 进程中的 API 提供的直接访问内容对象将不再工作。例如:</p>
+
+<pre class="brush: js">// chrome code
+
+gBrowser.contentWindow; // null
+
+gBrowser.contentDocument; // null
+
+gBrowser.selectedBrowser.contentWindow; // null
+
+window.content; // null
+
+content; // null
+</pre>
+
+<p>特别说明,docshells 存在于内容进程,因此它们也无法访问:</p>
+
+<pre>gBrowser.docShell; // null
+
+gBrowser.selectedBrowser.docShell; // null</pre>
+
+<h3 id="如果有垫片">如果有垫片</h3>
+
+<p>在这些情况下,垫片为你通过一个 <a href="/en-US/Firefox/Multiprocess_Firefox/Cross_Process_Object_Wrappers">CPOW</a> 提供内容对象。</p>
+
+<p>In some situations, the content process may not be initialized when an add-on asks for access to its content. In this case, the shim will return a JavaScript object that looks somewhat like a window or a document for about:blank. However, this "dummy" object is completely static and only exposes a few of the normal properties that windows and documents have. For this reason, add-ons that try to access content objects in fresh &lt;browser&gt; elements may run into trouble.</p>
+
+<p>To make the shim unnecessary: factor the code that needs to access content into a separate script, load that script into the content process as a frame script, and communicate between the chrome script and the frame script using the message-passing APIs. See the article on <a href="/en-US/Firefox/Multiprocess_Firefox/The_message_manager">using the message manager</a>.</p>
+
+<h2 id="CPOW_的限制">CPOW 的限制</h2>
+
+<p><a href="/en-US/Firefox/Multiprocess_Firefox/Cross_Process_Object_Wrappers">跨进程对象包装器</a> (CPOWs) 是一个迁移辅助,给 chrome 代码带来同步访问内容对象的能力。但是,在使用它时也有各种<a href="/en-US/Firefox/Multiprocess_Firefox/Cross_Process_Object_Wrappers#Limitations_of_CPOWs">限制</a>。</p>
+
+<h2 id="nsIContentPolicy">nsIContentPolicy</h2>
+
+<h3 id="如果没有垫片_2">如果没有垫片</h3>
+
+<p>在多进程的 Firefox 上,你无法在 chrome  进程中使用 <a href="http://dxr.mozilla.org/mozilla-central/source/dom/base/nsIContentPolicy.idl"><code>nsIContentPolicy</code></a>,因为它需要接触网络内容。</p>
+
+<h3 id="如果有垫片_2">如果有垫片</h3>
+
+<p>The shim enables you to add content policies in the chrome process. It transparently registers an <code>nsIContentPolicy</code> in the content process, whose <code>shouldLoad</code> just forwards to the chrome process. The content to check is forwarded as a <a href="/en-US/Firefox/Multiprocess_Firefox/Cross_Process_Object_Wrappers">CPOW</a>. The chrome process then checks the content against the policy supplied by the add-on, and forwards the response back to the child to be enforced.</p>
+
+<p>为了使垫片不再必要,在内容进程中定义和注册 <code>nsIContentPolicy</code>。如果你需要确保该政策只注册一次,使用一个 <a href="/en-US/docs/User:wbamberg/Multiprocess_Firefox-2/Message_manager/Process_scripts">process 脚本</a> 来注册该政策。</p>
+
+<h2 id="nsIWebProgressListener">nsIWebProgressListener</h2>
+
+<p>这个 API 在 chrome 进程中工作。有一个垫片让你可以访问传递到 <code>onStateChange</code> 的<code> </code><a href="http://dxr.mozilla.org/mozilla-central/source/uriloader/base/nsIWebProgress.idl"><code>nsIWebProgress</code></a>  对象的 <code>DOMWindow</code> 属性。但是,该 <code>DOMWindow</code> 是异步传递,因此在 chrome 进程收到时,DOM 可能已经改变了(例如,因为代码运行的内容进程已经修改它,或者我们已经导航到另一个页面)。</p>
+
+<p>还要注意,不同于其他垫片,这个垫片始终有效。</p>
+
+<p>我们正在努力修复此问题,见 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1118880">bug 1118880</a>。</p>
+
+<p>另外,你可以在内容进程中使用 <code>nsIWebProgressListener</code>。</p>
+
+<h2 id="chrome_进程中的_Observers">chrome 进程中的 Observers</h2>
+
+<p>根据不同的主题,你需要在 chrome 进程或者一个框架脚本中注册 observers。</p>
+
+<p>对于大多数主题,你需要在 chrome 进程中注册 observers。</p>
+
+<p>但是,你必须在一个框架脚本中监听 <a href="/en/docs/Observer_Notifications#Documents"><code>content-document-global-created</code> and <code>document-element-inserted</code></a>。这些主题的 <a href="http://dxr.mozilla.org/mozilla-central/source/xpcom/ds/nsIObserver.idl">Observers</a> 获取内容对象并作为 <code>aSubject</code> 参数到 <code>observe()</code>,因此通知不会发送到 chrome 进程。</p>
+
+<p>有一个垫片会将两个主题转发到 chrome 进程,将 <a href="/en-US/Firefox/Multiprocess_Firefox/Cross_Process_Object_Wrappers">CPOWs</a> 发送为 <code>aSubject</code> 参数。</p>
+
+<h3 id="HTTP_请求">HTTP 请求</h3>
+
+<p>你不能观测(observe)内容进程中的 <a href="https://developer.mozilla.org/en/docs/Observer_Notifications#HTTP_requests">HTTP 请求</a>。如果这样做,你将得到一个错误。<br>
+ <br>
+ 如果你在 chrome 进程中这样做,它一般会工作。observer 通知的主题将是一个 <code><a href="http://dxr.mozilla.org/mozilla-central/source/netwerk/protocol/http/nsIHttpChannel.idl">nsIHttpChannel</a></code>,正如你所期望的。</p>
+
+<p>A common pattern here is to use the <code>notificationCallbacks</code> property of the <code>nsIHttpChannel</code> to get the DOM window that initiated the load, like this:</p>
+
+<pre class="brush: js">observe: function (subject, topic, data) {
+ if (topic == "http-on-modify-request") {
+ var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
+ var domWindow = httpChannel.notificationCallbacks.getInterface(Ci.nsIDOMWindow);
+ }
+}</pre>
+
+<p>或者这样:</p>
+
+<pre class="brush: js">observe: function (subject, topic, data) {
+ if (topic == "http-on-modify-request") {
+ var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
+ var domWindow = httpChannel.notificationCallbacks.getInterface(Ci.nsILoadContext).associatedWindow;
+ }
+}</pre>
+
+<p>In multiprocess Firefox these patterns will no longer work: the <code>getInterface</code> call will fail.</p>
+
+<p>In multiprocess Firefox, <code>notificationCallbacks</code> is a special object that tries to emulate the single-process <code>notificationsCallbacks</code> object as best it can. It will return a dummy <code>nsILoadContext</code> when asked, but any attempt to get a window out of it will fail.<br>
+ <br>
+ There is an outstanding bug (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1108827">bug 1108827</a>) to implement a shim here that will make <code>notificationCallbacks</code> a <a href="/en-US/Firefox/Multiprocess_Firefox/Cross_Process_Object_Wrappers">CPOW</a> for the objects in the content process.</p>
+
+<p>The correct way to access the DOM window is through a message manager. In an HTTP observer, you can get the browser message manager for the window using code like this:</p>
+
+<pre class="brush: js">observe: function (subject, topic, data) {
+ if (topic == "http-on-modify-request") {
+ var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
+ var loadContext = httpChannel.notificationCallbacks.getInterface(Ci.nsILoadContext);
+ // topFrameElement is the &lt;browser&gt; element
+ var topFrameElement = loadContext.topFrameElement;
+ var browserMM = topFrameElement.messageManager;
+ console.log("browserMM: " + browserMM);
+ }
+}</pre>
+
+<p>However, before Firefox 38, this technique will not work if multiprocess Firefox is disabled: specifically, <code>topFrameElement</code> will be null. This means that if you need to write code that works before Firefox 38 and on both multiprocess and non-multiprocess variants, you need to implement both paths:</p>
+
+<ul>
+ <li>test whether <code>topFrameElement</code> is null</li>
+ <li>if it is, you're running in single-process Firefox, and should use the old way</li>
+ <li>if it isn't, you're running in multiprocess Firefox and should use the new way</li>
+</ul>
+
+<p>From Firefox 38 onwards, the topFrameElement approach always works.</p>
+
+<h2 id="DOM_事件">DOM 事件</h2>
+
+<h3 id="如果没有垫片_3">如果没有垫片</h3>
+
+<p>In multiprocess Firefox, if you want to register an event listener on some content DOM node, that needs to happen in the content process.</p>
+
+<p>It used to be that if you registered a listener on the <a href="/en-US/docs/XUL/browser">XUL <code>&lt;browser&gt;</code></a>  or <a href="/en-US/docs/XUL/tab"><code>&lt;tab&gt;</code></a> element that hosted some DOM content, then events in the content would bubble up to the XUL and you could handle them there. This no longer happens in multiprocess Firefox.</p>
+
+<h3 id="如果有垫片_3">如果有垫片</h3>
+
+<p>The shim intercepts chrome process code that adds listeners to XUL elements and sets up listeners in the content process, relaying the result back to the chrome process. The <a href="/en-US/docs/Web/API/Event"><code>Event</code></a> object itself is relayed to the chrome process as a <a href="/en-US/Firefox/Multiprocess_Firefox/Cross_Process_Object_Wrappers">CPOW</a>.</p>
+
+<p>To make the shim unnecessary: register event listeners on the global object inside a <a href="/en-US/Firefox/Multiprocess_Firefox/The_message_manager">frame script</a>. For example:</p>
+
+<pre class="brush: js">addEventListener("load", handler, true) // for example</pre>
+
+<div>如果你需要在这时联系 chrome 进程,发送一个消息。</div>
+
+<div> </div>
+
+<h2 id="沙盒">沙盒</h2>
+
+<div>You can create sandboxes in the chrome or the content process. Sandboxes are often used as a safe way to manipulate web content, and if that's your goal, create the sandbox in the content process.</div>
+
+<div> </div>
+
+<div>There is a shim for sandboxes: if you make a sandbox in the chrome process and give it content principals (by passing a CPOW as the first argument to <a href="/en-US/docs/Components.utils.Sandbox">Components.utils.Sandbox</a>) then we'll actually make it in the content process.</div>
+
+<div> </div>
+
+<div>
+<h2 id="nsIAboutModule">nsIAboutModule</h2>
+
+<p>By default, custom about: pages registered using nsIAboutModule are loaded in the chrome process. This means that you can't access their content from the content process (via XHR, for example).</p>
+
+<p>你可以在你注册 about: URI 的代码中改变这个默认值。见 <a href="/en-US/Firefox/Multiprocess_Firefox/about:_and_chrome:_URIs">about: 和 chrome: URI</a>。</p>
+</div>
+
+<h2 id="JavaScript_代码模块_(JSM)">JavaScript 代码模块 (JSM)</h2>
+
+<div>在单进程的 Firefox 中,你可以使用 <a href="/en-US/docs/Mozilla/JavaScript_code_modules">JavaScript 代码模块 (JSM)</a> 来维持全局状态。在多进程的 Firefox 中,一个加载到某个进程的 JSM 不与加载到另一个进程的同样 JSM 共享状态:因此你不能使用一个 JSM 在 chrome 和内容进程之间共享状态。</div>
+
+<div> </div>
+
+<div>If an add-on wants to use a JSM to share state in this way, it's best to load the JSM in the chrome process, and have frame scripts store and access the JSM's state by sending messages to the chrome process using the message manager.</div>
diff --git a/files/zh-cn/mozilla/firefox/multiprocess_firefox/limitations_of_frame_scripts/index.html b/files/zh-cn/mozilla/firefox/multiprocess_firefox/limitations_of_frame_scripts/index.html
new file mode 100644
index 0000000000..d942067bd3
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/multiprocess_firefox/limitations_of_frame_scripts/index.html
@@ -0,0 +1,101 @@
+---
+title: 框架脚本的限制
+slug: Mozilla/Firefox/Multiprocess_Firefox/Limitations_of_frame_scripts
+translation_of: Mozilla/Firefox/Multiprocess_Firefox/Limitations_of_frame_scripts
+---
+<div>{{FirefoxSidebar}}</div><p>框架脚本使用<a href="/en-US/docs/Security_check_basics#Principals">系统特权</a>运行,并且能够访问<a href="/en-US/docs/Components_object"> Components</a> 对象,使它们能够使用 <a href="/en-US/docs/Mozilla/Tech/XPCOM">XPCOM</a> 对象和 <a href="/en-US/docs/Mozilla/JavaScript_code_modules">JSM</a>。许多特权的 API 在内容进程中仍然工作。数据结构的处理仍将工作。XHR 和 Workers 仍将工作。但是,某些 API 在 chrome 进程中工作,但在框架脚本中将不工作。本文列出最重要的那些 API。</p>
+
+<p>这是一对文章之一,另一篇是:<a href="/en-US/Firefox/Multiprocess_Firefox/Limitations_of_chrome_scripts">chrome 脚本的限制</a>。</p>
+
+<h2 id="文件_IO">文件 I/O</h2>
+
+<p>你不应该从内容脚本写入或者读取磁盘,特别是配置文件目录。即使这是可能的,你也不应该这样做,应该预期它可能在任何时间停止工作。文件 I/O 应该全部放在 chrome 进程完成。例如:</p>
+
+<ul>
+ <li><a href="http://dxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsIFileStreams.idl"><code>nsIFileInputStream</code></a></li>
+ <li><a href="http://dxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsIFileStreams.idl"><code>nsIFileOutputStream</code></a></li>
+ <li><a href="/en-US/docs/Extensions/Using_the_DOM_File_API_in_chrome_code">Constructing a <code>File</code> from a string or <code>nsIFile</code></a> (但 <code>File</code> 对象可以通过消息管理器发送)</li>
+ <li><code><a href="/en-US/docs/Web/API/HTMLInputElement/mozSetFileNameArray">HTMLInputElement.mozSetFileNameArray</a></code> (替代: <code>mozSetFileArray</code>)</li>
+</ul>
+
+<h2 id="XUL_和浏览器界面">XUL 和浏览器界面</h2>
+
+<p>任何试图接触界面或者与 XUL 相关的东西都很可能在内容进程中不工作。例如:</p>
+
+<ul>
+ <li><code><a href="http://dxr.mozilla.org/mozilla-central/source/embedding/components/windowwatcher/nsIPromptService.idl">nsIPromptService</a></code></li>
+ <li><a href="http://dxr.mozilla.org/mozilla-central/source/widget/nsIFilePicker.idl"><code>nsIFilePicker</code></a></li>
+ <li><code>nsIXUL*</code></li>
+ <li>&lt;更多例子待补充&gt;</li>
+</ul>
+
+<h2 id="Services">Services</h2>
+
+<p>某些服务不能在框架脚本中工作。</p>
+
+<ul>
+ <li>Services.search</li>
+ <li>Services.downloads</li>
+</ul>
+
+<h2 id="Chrome_窗口">Chrome 窗口</h2>
+
+<p>任何需要使用 chrome 窗口的东西都不能在内容进程中工作。例如:</p>
+
+<ul>
+ <li><a href="http://dxr.mozilla.org/mozilla-central/source/mobile/android/components/SessionStore.idl"><code>nsISessionStore</code></a></li>
+ <li><a href="http://dxr.mozilla.org/mozilla-central/source/xpfe/appshell/nsIWindowMediator.idl"><code>nsIWindowMediator</code></a></li>
+ <li>&lt;更多例子待补充&gt;</li>
+</ul>
+
+<h2 id="Places_API">Places API</h2>
+
+<p><a href="/en-US/docs/Mozilla/Tech/Places">Places API</a> 不能在框架脚本中使用。例如:</p>
+
+<ul>
+ <li><a href="http://dxr.mozilla.org/mozilla-central/source/toolkit/components/places/nsINavHistoryService.idl"><code>nsINavHistoryService</code></a></li>
+ <li><a href="http://dxr.mozilla.org/mozilla-central/source/toolkit/components/places/nsINavBookmarksService.idl"><code>nsINavBookmarksService</code></a></li>
+</ul>
+
+<h2 id="内容进程中的_Observers">内容进程中的 Observers</h2>
+
+<p>As noted in <a href="https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Limitations_of_chrome_scripts#Observers_in_the_chrome_process">Observers in the chrome process</a>, most <a href="http://dxr.mozilla.org/mozilla-central/source/xpcom/ds/nsIObserver.idl">observers</a> should be registered in the chrome process and will not work in the content process. The exceptions are:</p>
+
+<ul>
+ <li><code><a href="https://developer.mozilla.org/en-US/docs/Observer_Notifications#Documents">content-document-global-created</a></code></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Observer_Notifications#Documents"><code>document-element-inserted</code></a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Observer_Notifications#Windows"><code>outer-window-destroyed</code></a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Observer_Notifications#Windows"><code>inner-window-destroyed</code></a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Observer_Notifications#Windows"><code>dom-window-destroyed</code></a></li>
+</ul>
+
+<p>这些必须在内容进程中注册。</p>
+
+<h2 id="内容窗口到_chrome_窗口的_QI">内容窗口到 chrome 窗口的 QI</h2>
+
+<div>There's a particular pattern often used to get from a content window to the associated chrome window. It looks something like this:</div>
+
+<div> </div>
+
+<pre class="brush: js">window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsIDocShellTreeItem)
+ .rootTreeItem
+ .QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindow);</pre>
+
+<div>This will no longer work. In the content process the root tree item is an <a href="http://dxr.mozilla.org/mozilla-central/source/dom/interfaces/base/nsITabChild.idl"><code>nsITabChild</code></a>, that cannot be converted to an <code>nsIDOMWindow</code>, so the second <code>getInterface</code> call here will fail.</div>
+
+<div> </div>
+
+<p>If you want a chrome window: send a message from the content process using the <a href="/en-US/Firefox/Multiprocess_Firefox/The_message_manager">message manager</a>. The <a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListener#receiveMessage()"><code>target</code></a> property of the object passed into the message handler in the chrome process is the XUL <a href="/en-US/docs/XUL/browser"><code>&lt;browser&gt;</code></a> receiving the message, and you can get the chrome window from that (Note: I'm not really sure how...).</p>
+
+<h2 id="nsIAboutModule">nsIAboutModule</h2>
+
+<p>默认情况下,使用 <a href="http://dxr.mozilla.org/mozilla-central/source/netwerk/protocol/about/nsIAboutModule.idl"><code>nsIAboutModule</code></a>  注册的自定义的 <code>about:</code> 页面在 chrome 进程中加载。这意味着你不能从内容进程访问它们的内容(比如通过 XHR)。</p>
+
+<p>你可以在注册 about: URI 的代码中更改这个默认值。见 <a href="/en-US/Firefox/Multiprocess_Firefox/about:_and_chrome:_URIs">about: 和 chrome: URI</a>。</p>
+
+<h2 id="JavaScript_代码模块_(JSM)">JavaScript 代码模块 (JSM)</h2>
+
+<div>在多进程的 Firefox 中,一个加载到内容进程的 JSM 不予加载到 chrome 进程的同一个 JSM 共享任何状态。参考 <a href="/en-US/Firefox/Multiprocess_Firefox/Limitations_of_chrome_scripts#JavaScript_code_modules_%28JSMs%29">chrome 脚本的限制</a> 页面中的内容。</div>
diff --git a/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/communicating_with_frame_scripts/index.html b/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/communicating_with_frame_scripts/index.html
new file mode 100644
index 0000000000..9c8abfa1c9
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/communicating_with_frame_scripts/index.html
@@ -0,0 +1,205 @@
+---
+title: 与框架脚本通信
+slug: >-
+ Mozilla/Firefox/Multiprocess_Firefox/Message_Manager/Communicating_with_frame_scripts
+translation_of: >-
+ Mozilla/Firefox/Multiprocess_Firefox/Message_Manager/Communicating_with_frame_scripts
+---
+<div>{{FirefoxSidebar}}</div><p>Chrome 的代码与框架脚本的往来通信采用消息 API,它可以包含可 JSON 序列化的对象作为参数。</p>
+
+<p>这个 API 大多是对称的,但有一个主要的例外:框架脚本可以发送同步或者异步消息到 chrome,但 chrome 只能发送异步消息到内容。这是一种有意的设计,是为了防止内容不响应而导致的 chrome 失去响应。<br>
+ <br>
+ 在绝对必要时,框架脚本可以通过被称为 <a href="/en-US/docs/Cross_Process_Object_Wrappers">跨进程对象包装器</a>(也称 CPOWs)的东西到达 chrome,并且 chrome 可以使用这些包装器来获得到内容对象的同步访问。</p>
+
+<h2 id="内容到_chrome">内容到 chrome</h2>
+
+<p>框架脚本可以选择发送同步消息或者异步消息到 chrome 代码。</p>
+
+<h3 id="异步消息">异步消息</h3>
+
+<p>要发送异步消息,内容脚本应使用 <code>sendAsyncMessage()</code> 函数:</p>
+
+<pre class="brush: js">// frame script
+sendAsyncMessage("my-addon@me.org:my-e10s-extension-message");</pre>
+
+<p><code>sendAsyncMessage()</code> takes one mandatory parameter, which is the name of the message. All messages share the same namespace, so to avoid conflicts with other code, you'll need to ensure that the names you use are unique. If you're using the message manager in an add-on, a good way to do that is to prefix messages with your add-on's ID.</p>
+
+<p>After the name, you can pass detailed data as a string or a JSON-serializable object, and after that you can pass any objects it wants to pass to content as <a href="/en-US/docs/Cross_Process_Object_Wrappers">CPOWs</a>.</p>
+
+<p>The example below sends a message named "my-e10s-extension-message", with a <code>data</code> payload containing <code>details</code> and <code>tag</code> properties, and exposes the <code>event.target</code> object as a CPOW:</p>
+
+<pre class="brush: js">// frame script
+addEventListener("click", function (event) {
+ sendAsyncMessage("my-addon@me.org:my-e10s-extension-message", {
+ details : "they clicked",
+ tag : event.target.tagName
+ },
+ {
+ target : event.target
+ });
+}, false);</pre>
+
+<p>要接收来自内容的消息,一个 chrome 脚本需要使用消息管理器的 <code>addMessageListener()</code> API 添加消息监听器:<br>
+ <br>
+ 传递给监听器的消息是一个对象,包含下列属性:</p>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <td><code>name</code></td>
+ <td>字符串,包含消息的名称。</td>
+ </tr>
+ <tr>
+ <td><code>sync</code></td>
+ <td>布尔值,表示消息是否为同步发送,或者是异步发送。</td>
+ </tr>
+ <tr>
+ <td><code>data</code></td>
+ <td>JSON 对象,作为传递给 <code>sendAsyncMessage()</code> 的第二个参数。</td>
+ </tr>
+ <tr>
+ <td><code>target</code></td>
+ <td>这是 XUL 的 <code>&lt;browser&gt;</code> 元素,来自消息发送的位置。</td>
+ </tr>
+ <tr>
+ <td><code>objects</code></td>
+ <td>An object whose properties are any CPOWs exposed by the sender as the third argument to <code>sendAsyncMessage()</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<p>在下面的例子中,监听器只是记录所有的消息细节;</p>
+
+<pre class="brush: js">// chrome script
+messageManager.addMessageListener("my-addon@me.org:my-e10s-extension-message", listener);
+
+function listener(message) {
+ console.log(message.name);
+ console.log(message.sync);
+ console.log(message.data);
+ console.log(message.target);
+ console.log(message.objects);
+}
+</pre>
+
+<p>So combining this message listener with the message above will give console output somewhat like this, when the user clicks a <code>&lt;div&gt;</code>:</p>
+
+<pre>"my-addon@me.org:my-e10s-extension-message"
+false
+Object { details: "they clicked", tag: "div" }
+&lt;xul:browser anonid="initialBrowser" ... &gt;
+{ target: &lt;div#searchContainer&gt; }
+</pre>
+
+<p>If your code requires access to a <code>window</code> (for example to run <code>window.openDialog</code>), and your message listener is run from somewhere without access to a <code>window</code> (e.g. an XPCOM component), you can access the window of the <code>browser</code> that sent the message with <code>message.target.ownerDocument.defaultView</code>.</p>
+
+<h3 id="同步消息">同步消息</h3>
+
+<p>要发送一个同步消息,框架脚本应使用全局的 <code>sendSyncMessage()</code>  函数:</p>
+
+<pre class="brush: js">// frame script
+sendSyncMessage("my-addon@me.org:my-e10s-extension-message");</pre>
+
+<p>在一个 chrome 脚本收到一个同步消息时,它应该从它的消息监听器返回一个值:</p>
+
+<pre class="brush: js">// chrome script
+messageManager.addMessageListener("my-addon@me.org:my-e10s-extension-message", listener);
+
+function listener(message) {
+ return "value from chrome";
+}</pre>
+
+<p>This value is then presented to the frame script in the return value of <code>sendSyncMessage()</code>. Because a single message can be received by more than one listener, the return value of <code>sendSyncMessage()</code> is an array of all the values returned from every listener, even if it only contains a single value:</p>
+
+<pre class="brush: js">// frame script
+addEventListener("click", function (event) {
+ var results = sendSyncMessage("my-addon@me.org:my-e10s-extension-message", {
+ details : "they clicked",
+ tag : event.target.tagName
+ });
+ content.console.log(results[0]); // "value from chrome"
+}, false);</pre>
+
+<p>Like arguments, return values from <code>sendSyncMessage()</code> must be JSON-serializable, so chrome can't return functions.</p>
+
+<h3 id="removeMessageListener()">removeMessageListener()</h3>
+
+<p>要停止监听来自内容的消息,使用消息管理器的 <code>removeMessageListener()</code> 方法:</p>
+
+<pre class="brush: js">// chrome script
+messageManager.removeMessageListener("my-addon@me.org:my-e10s-extension-message", listener);</pre>
+
+<h2 id="Chrome_到内容">Chrome 到内容</h2>
+
+<p>要从 chrome 发送一个消息到内容,你需要知道你正在使用什么类型的消息管理器。如果它是一个浏览器消息管理器,你可以使用消息管理器的 <code>sendAsyncMessage</code>  方法:</p>
+
+<pre class="brush: js">// chrome script
+browser.messageManager.sendAsyncMessage("my-addon@me.org:message-from-chrome");</pre>
+
+<p>如果你有一个窗口或者全局消息管理器,你需要使用 <code>broadcastAsyncMessage</code> 方法:</p>
+
+<pre>// chrome script
+window.messageManager.broadcastAsyncMessage("my-addon@me.org:message-from-chrome");</pre>
+
+<p>These methods takes one mandatory parameter, which is the message name. All messages share the same namespace, so to avoid conflicts with other code, you'll need to ensure that the names you use are unique. If you're using the message manager in an add-on, a good way to do that is to prefix messages with your add-on's ID.</p>
+
+<p>在消息名称后,你可以将详细的数据传递为一个字符串或者一个可 JSON 序列化的对象:</p>
+
+<pre class="brush: js">// chrome script
+messageManager.sendAsyncMessage("my-addon@me.org:message-from-chrome", {
+ details : "some more details"
+});</pre>
+
+<p>To receive a message from chrome, a frame script uses the global <code>addMessageListener()</code> function. This takes two parameters: the name of the message and a listener function. The listener will be passed a <code>message</code> object whose <code>data</code> property is the message payload:</p>
+
+<pre class="brush: js">// frame script
+function handleMessageFromChrome(message) {
+ var payload = message.data.details; // "some more details"
+}
+
+addMessageListener("my-addon@me.org:message-from-chrome", handleMessageFromChrome);</pre>
+
+<h3 id="message-manager-disconnect">message-manager-disconnect</h3>
+
+<p>If you're using a <a href="https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/The_message_manager">message manager</a> to communicate with a script that may be running in a different process, you can listen for the <a href="/en-US/docs/Observer_Notifications#Message_manager">message-manager-disconnect </a>observer notification to know when the message manager has disconnected from the other end of the conversation, so you can stop sending it messages or expecting to receive messages.</p>
+
+<p>For example, suppose we load a script into the current <code>&lt;browser&gt;</code> on some event, and keep the browser message manager in an array, so we can send it messages:</p>
+
+<pre class="brush: js">var messageManagers = [];
+
+...
+
+// on some event
+var browserMM = gBrowser.selectedBrowser.messageManager;
+browserMM.loadFrameScript("chrome://my-addon@me.org/content/frame-script.js", false);
+messageManagers.push(browserMM);
+console.log(messageManagers.length);</pre>
+
+<p>We can listen for <code>message-manager-disconnect</code> to update the array when the message managers disconnect (for example because the user closed the tab):</p>
+
+<pre class="brush: js">function myObserver() {
+}
+
+myObserver.prototype = {
+ observe: function(subject, topic, data) {
+ var index = messageManagers.indexOf(subject);
+ if (index != -1) {
+ console.log("one of our message managers disconnected");
+ mms.splice(index, 1);
+ }
+ },
+ register: function() {
+ var observerService = Cc["@mozilla.org/observer-service;1"]
+ .getService(Ci.nsIObserverService);
+ observerService.addObserver(this, "message-manager-disconnect", false);
+ console.log("listening");
+ },
+ unregister: function() {
+ var observerService = Cc["@mozilla.org/observer-service;1"]
+ .getService(Ci.nsIObserverService);
+ observerService.removeObserver(this, "message-manager-disconnect");
+ }
+}
+
+var observer = new myObserver();
+observer.register();</pre>
diff --git a/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/frame_script_environment/index.html b/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/frame_script_environment/index.html
new file mode 100644
index 0000000000..8d5e9d287b
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/frame_script_environment/index.html
@@ -0,0 +1,104 @@
+---
+title: 框架脚本环境
+slug: Mozilla/Firefox/Multiprocess_Firefox/Message_Manager/Frame_script_environment
+translation_of: Mozilla/Firefox/Multiprocess_Firefox/Message_Manager/Frame_script_environment
+---
+<div>{{FirefoxSidebar}}</div><p>框架脚本的全局是 <a href="http://dxr.mozilla.org/mozilla-central/source/dom/base/nsIMessageManager.idl#345">ContentFrameMessageManager</a>,提供下列环境:</p>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <td><code>content</code></td>
+ <td>The DOM window of the content loaded in the browser. may be <code>null</code> (see below)</td>
+ </tr>
+ <tr>
+ <td><code>docShell</code></td>
+ <td>The <a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDocShell"><code>nsIDocShell</code></a> associated with the browser.</td>
+ </tr>
+ <tr>
+ <td><code>addEventListener()</code></td>
+ <td>Listen to events from content.</td>
+ </tr>
+ <tr>
+ <td><code>removeEventListener()</code></td>
+ <td>Stop listening to events from content.</td>
+ </tr>
+ <tr>
+ <td><code>addMessageListener()</code></td>
+ <td>Listen to messages from chrome.</td>
+ </tr>
+ <tr>
+ <td><code>removeMessageListener()</code></td>
+ <td>Stop listening to messages from chrome.</td>
+ </tr>
+ <tr>
+ <td><code>sendAsyncMessage()</code></td>
+ <td>Send an asynchronous message to chrome.</td>
+ </tr>
+ <tr>
+ <td><code>sendSyncMessage()</code></td>
+ <td>Send a synchronous message to chrome.</td>
+ </tr>
+ <tr>
+ <td><code>dump()</code></td>
+ <td>Print a message to the console.</td>
+ </tr>
+ <tr>
+ <td><code>atob()</code></td>
+ <td>Base64 decode.</td>
+ </tr>
+ <tr>
+ <td><code>btoa()</code></td>
+ <td>Base64 encode.</td>
+ </tr>
+ <tr>
+ <td><code>Components</code></td>
+ <td>The usual <a href="/en-US/docs/Components_object"><code>Components</code> object</a>.</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>特别注意,框架脚本使用<code> content </code>访问 DOM 窗口,而不是 <code>window</code>:</p>
+
+<pre class="brush: js">// frame script
+var links = content.document.getElementsByTagName("a");</pre>
+
+<p>All the frame scripts running in a tab share this global. However, any top-level variables defined by a script are not stored on the global: instead, top-level variables are stored in a special per-script object that delegates to the per-tab global. This means you don't have to worry about global variables you define conflicting with global variables defined by another frame script. You can still access the global directly via <code>this</code>.</p>
+
+<p>框架脚本使用系统主体运行。如果你想使用其他主题,可以使用 <a href="/en-US/docs/Components.utils.Sandbox"><code>Sandbox</code></a>。</p>
+
+<p>Frame scripts run with <a href="https://developer.mozilla.org/en-US/docs/Security_check_basics#Principals">system privileges</a> and have access to the <a href="https://developer.mozilla.org/en-US/docs/Components_object">Components</a> object, enabling them to use <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM">XPCOM</a> objects and <a href="https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules">JSMs</a>. However, some APIs  that work in the chrome process will not work in a frame script. See <a href="/en-US/Firefox/Multiprocess_Firefox/Limitations_of_frame_scripts">Limitations of frame scripts</a> for more details.</p>
+
+<h2 id="事件">事件</h2>
+
+<p>Besides the regular DOM events being captured/bubbling up from content the current <code>content</code> object the following additional events get fired in a frame script environment:</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><a href="/en-US/docs/Web/Reference/Events/unload">unload</a></td>
+ <td>
+ <dl>
+ <dt style="float: left; text-align: right; width: 120px;">Bubbles</dt>
+ <dd style="margin: 0 0 0 120px;">No</dd>
+ </dl>
+
+ <p>Fires when the frame script environment is shut down, i.e. when a tab gets closed.</p>
+
+ <p>If you use a capturing event listener on the <code>ContentFrameMessageManager</code>, you should verify that its <code>event.target</code> is set to the <code>ContentFrameMessageManager</code> global object in order to avoid handling <code>unload</code> events from content.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/Events/DOMWindowCreated">DOMWindowCreated</a></td>
+ <td>
+ <p>Fires when a new <code>content</code> object is created.<br>
+ <br>
+ This can be used if a framescript needs to interact with individual DOM windows instead of simply listening for events bubbling up from content.<br>
+ Another use is to interact with the content very early in the page load process, long before <a href="/en-US/docs/Web/Events/DOMContentLoaded">DOMContentLoaded</a> event is fired.<br>
+  </p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/frame_script_loading_and_lifetime/index.html b/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/frame_script_loading_and_lifetime/index.html
new file mode 100644
index 0000000000..ee53fe52e2
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/frame_script_loading_and_lifetime/index.html
@@ -0,0 +1,124 @@
+---
+title: 框架脚本的加载与寿命
+slug: >-
+ Mozilla/Firefox/Multiprocess_Firefox/Message_Manager/Frame_script_loading_and_lifetime
+translation_of: >-
+ Mozilla/Firefox/Multiprocess_Firefox/Message_Manager/Frame_script_loading_and_lifetime
+---
+<div>{{FirefoxSidebar}}</div><h2 id="加载框架脚本">加载框架脚本</h2>
+
+<p>要加载一个框架脚本,使用 <code>loadFrameScript()</code> 函数。</p>
+
+<p>这行代码加载一个框架脚本到当前选中的标签页。该框架脚本只是将 "foo" 写入到命令行:</p>
+
+<pre class="brush: js">// chrome script
+var mm = gBrowser.selectedBrowser.messageManager;
+mm.loadFrameScript('data:,dump("foo\\n")', true);</pre>
+
+<p><code>loadFrameScript()</code> 有两个强制性参数:</p>
+
+<ul>
+ <li>一个 URL 指向要加载的框架脚本。</li>
+ <li>一个布尔变量,<code>allowDelayedLoad</code></li>
+</ul>
+
+<p>Note that if the message manager is a <a href="/en-US/Firefox/Multiprocess_Firefox/Message_Manager/Message_manager_overview#Global_frame_message_manager">global frame message manager</a> or a <a href="/en-US/Firefox/Multiprocess_Firefox/Message_Manager/Message_manager_overview#Window_message_manager">window message manager</a> then <code>loadFrameScript() </code>may load the script multiple times, once into each applicable frame.</p>
+
+<h3 id="chrome_URL">chrome: URL</h3>
+
+<p>扩展开发者通常会使用 <code>chrome://</code> URL 来指向一个框架脚本。</p>
+
+<p>要定义 <code>chrome://</code> URL 的映射和将一个框架脚本打包到扩展中,使用 "chrome.manifest" 文件来 <a href="/en/docs/Chrome_Registration">注册一个chrome URL</a>:</p>
+
+<pre class="brush: js">// chrome.manifest
+content my-e10s-extension content.js</pre>
+
+<pre class="brush: js">// chrome script
+mm.loadFrameScript("chrome://my-e10s-extension/content/content.js", true);</pre>
+
+<h3 id="allowDelayedLoad">allowDelayedLoad</h3>
+
+<p>如果消息管理器是一个 <a href="/en-US/Firefox/Multiprocess_Firefox/Message_Manager/Message_manager_overview#Global_frame_message_manager">全局框架消息管理器</a> 或者一个 <a href="/en-US/Firefox/Multiprocess_Firefox/Message_Manager/Message_manager_overview#Window_message_manager">窗口消息管理器</a>,那么:</p>
+
+<ul>
+ <li>
+ <p>如果 <code>allowDelayedLoad</code> 为 <code>true</code>,在 <code>loadFrameScript()</code> 调用后,框架脚本将加载到任何新的已打开的标签页。例如:</p>
+
+ <pre class="brush: js">var mm = window.messageManager;
+mm.loadFrameScript("chrome://my-e10s-extension/content/frame-script.js", true);</pre>
+
+ <p>这段脚本将加载到此窗口中目前已打开的所有标签页,以及未来进入的新打开的标签页。</p>
+ </li>
+ <li>如果 <code>allowDelayedLoad</code>  为 <code>false</code>,那么脚本只会在执行调用时已打开的标签页中加载。</li>
+</ul>
+
+<p>如果消息管理器是一个 <a href="/en-US/Firefox/Multiprocess_Firefox/Message_Manager/Message_manager_overview#Browser_message_manager">浏览器消息管理器</a>,你应该始终在这里传递 <code>true</code>。因为一个浏览器消息管理器永远只对应一个浏览器标签页,它的 <code>loadFrameScript()</code> 函数只加载框架脚本到一个标签页。因此传递 <code>allowDelayedLoad</code> 仅仅是一个方法来确保脚本被正确加载,在你的标签页在执行后还没有准备好时。</p>
+
+<p>如果你使用 <code>allowDelayedLoad</code>,你可以使用 <code>removeDelayedFrameScript</code> 取消它:</p>
+
+<pre class="brush: js">var mm = window.messageManager;
+<code>mm.removeDelayedFrameScript</code>("chrome://my-e10s-extension/content/frame-script.js");</pre>
+
+<p>这意味着我们将停止加载脚本到新的标签页。请注意,此函数不会移除已经加载的任何脚本。</p>
+
+<h2 id="框架脚本的寿命">框架脚本的寿命</h2>
+
+<p>框架脚本将在 <code>loadFrameScript()</code> 被调用后尽快加载。如果你设置了 <code>allowDelayedLoad</code>,脚本将加载到一个新的标签页,一旦其已被创建。</p>
+
+<p>框架脚本与浏览器的标签页相关联,而不是与页面。因此一旦你加载它们,它们就会持续存在,直至标签页被关闭,因此即便你重新加载或者文档重新导航也不会丢失。</p>
+
+<p>如果你想一个框架脚本在每次新文档被加载后执行操作,你需要监听一个适当的 DOM 事件,通常是 <code><a href="/en-US/docs/Web/Events/DOMWindowCreated">DOMWindowCreated</a></code>, <code><a href="/en-US/docs/Web/Events/DOMContentLoaded">DOMContentLoaded</a></code>,  或者 <code><a href="/en-US/docs/Web/Events/load">load</a></code>。</p>
+
+<h2 id="卸载框架脚本">卸载框架脚本</h2>
+
+<p>框架脚本会在托管它们的标签页被关闭时自动卸载。目前还没有办法在已加载它们的标签页之中卸载它们,除了关闭标签页。</p>
+
+<p>若要监听你的框架脚本被卸载的事件(例如由于标签页被关闭),你必须将 <code>addMessageListener</code> 的第三个参数设置为 true,例如下面的 <code>bootstrap.js</code> 的代码:</p>
+
+<pre class="brush: js">Services.mm.addMessageListener(
+    'my-addon-id',
+    {
+        receiveMessage: function() {
+            console.log('incoming message from frame script:', aMsg.data);
+        }
+    },
+    true // must set this argument to true, otherwise sending message from framescript will not work during and after the unload event on the ContentMessageManager triggers
+);</pre>
+
+<p>and then in your frame script listen for the unload event of the message manager (which is the global this), and then send a message. If you did not set third argument to true in <code>bootstrap.js</code> on <code>Services.mm.addMessageListener</code>, then this send message during and after unload event, will do nothing.</p>
+
+<pre class="brush: js">var gContentFrameMessageManager = this;
+
+addEventListener('unload', function(aEvent) {
+ if (aEvent.target == gContentFrameMessageManager) {
+ sendAsyncMessage('my-addon-id', 'framescript-died'); // if you did not set third argument of `Services.mm.addMessageListener` to `true`, then this will fail to send a message
+ }
+}, false);</pre>
+
+<h3 id="有关卸载升级操作时的卸载">有关卸载/升级操作时的卸载</h3>
+
+<p>在你的附加组件被卸载或禁用时,你应该:</p>
+
+<ul>
+ <li>如果使用了 <code>allowDelayedLoad</code>,调用 <code>removeDelayedFrameScript</code> 取消它,确保框架脚本不会加载到任何新的标签页。</li>
+ <li>禁用已加载的任何框架脚本。没有任何机制来卸载已加载的框架脚本,因此你需要发送一个消息到你的框架脚本来告诉它们禁用自己(例如撤销所有已取得的更改,以及移除事件监听器)。</li>
+</ul>
+
+<div class="note">
+<div class="warning">
+<p>There is a bug in non-e10s where this oder is not true. In e10s framescripts work fine on updating. For non-e10s waiting for <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1202125">Bug 1202125 - framescripts are not backwards loaded in message order in non-e10s</a>.</p>
+</div>
+
+<p>Note: you might think that there is a race condition here due to the asynchronous nature of the message passing:</p>
+
+<ul>
+ <li>your add-on is disabled for an upgrade</li>
+ <li>your add-on broadcasts "disable" to your frame scripts</li>
+ <li>your add-on is upgraded, and the new code loads new frame scripts</li>
+ <li>the new frame scripts receive the "disable" message, and stop working</li>
+</ul>
+
+<p>In fact, the message manager guarantees that <code>loadFrameScript</code> and <code>broadcastAsyncMessage</code> are guaranteed to affect frame scripts in the order that they are called, so in this case "disable" will be received and consumed before the new frame scripts are loaded.</p>
+</div>
+
+<p>At the moment frame scripts are cached until the browser restarts: this problem is tracked as <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1051238">bug 1051238</a>. This is especially a problem for <a href="/en-US/Add-ons/Bootstrapped_extensions">restartless add-ons</a>, because when a new version of the add-on is installed, the old frame scripts will not be unloaded. The workaround here is to randomize the frame script's URL, for example by appending <code>"?" + Math.random()</code> to it.</p>
diff --git a/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/index.html b/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/index.html
new file mode 100644
index 0000000000..be6ba855c9
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/index.html
@@ -0,0 +1,68 @@
+---
+title: 消息管理器
+slug: Mozilla/Firefox/Multiprocess_Firefox/Message_Manager
+translation_of: Mozilla/Firefox/Multiprocess_Firefox/Message_Manager
+---
+<div>{{FirefoxSidebar}}</div><p>消息管理器为 chrome 特权的 JavaScript 代码提供了跨进程边界的通信方式。它非常有用,可以允许 chrome 代码(包括浏览器自身的代码和外部代码)访问在单独的进程中运行的网页内容。</p>
+
+<p>这些指南介绍了如何在多进程 Firefox 中使用消息管理器。</p>
+
+<p>请注意,多进程 Firefox 的环境并非是必须的:这里描述的一切对单进程 Firefox 也同样有效,所以相同的代码在两个环境下都可以正常工作。</p>
+
+<hr>
+<h2 id="指南">指南</h2>
+
+<div class="column-container">
+<div class="column-half">
+<dl>
+ <dt><a href="/Firefox/Multiprocess_Firefox/Message_Manager/Message_manager_overview">消息管理器概述</a></dt>
+ <dd> </dd>
+ <dt><a href="/Firefox/Multiprocess_Firefox/Message_Manager/Frame_script_loading_and_lifetime">框架脚本的加载与寿命</a></dt>
+ <dd> </dd>
+ <dt><a href="/Firefox/Multiprocess_Firefox/Message_Manager/Communicating_with_frame_scripts">与框架脚本通信</a></dt>
+ <dd> </dd>
+ <dt><a href="/Firefox/Multiprocess_Firefox/Message_Manager/Performance">性能的最佳实践</a></dt>
+ <dd> </dd>
+</dl>
+</div>
+
+<div class="column-half">
+<dl>
+ <dt><a href="/Firefox/Multiprocess_Firefox/Message_Manager/Frame_script_environment">框架脚本环境</a></dt>
+ <dd> </dd>
+ <dt><a href="/Firefox/Multiprocess_Firefox/Message_Manager/_Limitations_of_frame_scripts">框架脚本的限制</a></dt>
+ <dd> </dd>
+ <dt><a href="/Firefox/Multiprocess_Firefox/Message_Manager/Process_scripts">进程脚本</a></dt>
+ <dd> </dd>
+</dl>
+</div>
+</div>
+
+<hr>
+<h2 id="API_参考资料">API 参考资料</h2>
+
+<div class="column-container">
+<div class="column-half">
+<dl>
+ <dt><a href="/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFrameScriptLoader">nsIFrameScriptLoader</a></dt>
+ <dd> </dd>
+ <dt><a href="/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager">nsIMessageListenerManager</a></dt>
+ <dd> </dd>
+ <dt><a href="/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageBroadcaster">nsIMessageBroadcaster</a></dt>
+ <dd> </dd>
+ <dt><a href="/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageSender">nsIMessageSender</a></dt>
+ <dd> </dd>
+</dl>
+</div>
+
+<div class="column-half">
+<dl>
+ <dt><a href="/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISyncMessageSender">nsISyncMessageSender</a></dt>
+ <dd> </dd>
+ <dt><a href="/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentFrameMessageManager">nsIContentFrameMessageManager</a></dt>
+ <dd> </dd>
+ <dt><a href="/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIProcessScriptLoader">nsIProcessScriptLoader</a></dt>
+ <dd> </dd>
+</dl>
+</div>
+</div>
diff --git a/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/message_manager_overview/index.html b/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/message_manager_overview/index.html
new file mode 100644
index 0000000000..fb85fa5e79
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/message_manager_overview/index.html
@@ -0,0 +1,442 @@
+---
+title: 消息管理器概述
+slug: Mozilla/Firefox/Multiprocess_Firefox/Message_Manager/Message_manager_overview
+translation_of: Mozilla/Firefox/Multiprocess_Firefox/Message_Manager/Message_manager_overview
+---
+<div class="summary">
+<p>在多进程 Firefox 中有两个进程:</p>
+
+<ul>
+ <li>chrome 进程,也称父进程,运行着浏览器 UI 界面 (chrome) 的代码和扩展安装的代码。</li>
+ <li>内容进程,也称子进程,运行着所有网页内容。在未来的 Firefox 版本中,不同的标签页可能运行在不同的进程中,但截至目前,所有内容标签页共享使用同一个内容进程。</li>
+</ul>
+
+<p>消息管理器的设计目的是使运行在一个进程中的 chrome 特权的 JavaScript 代码能够与不同进程中的 chrome 特权的 JavaScript 代码通信。</p>
+
+<p>本文介绍了几种类型的消息管理器,如何访问它们,以及在一个较高层面你可以使用什么。</p>
+</div>
+
+<p>在顶层,有两种不同类型的消息管理器:</p>
+
+<ul>
+ <li><em>框架消息管理器</em>:这些使 chrome 进程的代码能够加载脚本到内容进程中的浏览器框架(基本上,就是指一个浏览器标签页)。这些脚本被称为框架脚本,顾名思义,它们限定在特定的浏览器框架中。如果 chrome 代码想要在内容进程中运行可以方便访问网页内容的代码,通常就是使用消息管理器的时候了。</li>
+ <li><em>进程消息管理器</em>:这些对应着进程边界,使运行在父 (chrome) 进程中的代码能够与子 (内容) 进程中的代码通信。从 Firefox 38 起,这也使运行在父进程中的代码能够加载进程脚本到子进程。这些类似框架脚本,除了它们是全局访问子进程。进程脚本最有用的时候是进程想要只在内容进程中运行某些代码,来访问某些全局服务:例如,注册一个 <a href="/en/docs/Observer_Notifications">observer </a>或者一个 <a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentPolicy">内容策略</a>。</li>
+</ul>
+
+<h2 id="框架消息管理器">框架消息管理器</h2>
+
+<p>在多进程 Firefox 中,当 chrome 代码需要与网页内容交互时,它需要:</p>
+
+<ul>
+ <li>将需要直接访问内容的脚本代码放到一个单独的脚本,它被称为“框架脚本”。</li>
+ <li>使用框架消息管理器来加载这些框架脚本到内容进程</li>
+ <li>使用框架消息管理器 API 来与框架脚本通信</li>
+</ul>
+
+<div class="note">
+<p>Some older articles on multiprocess Firefox and the message manager might refer to "content scripts" instead of "frame scripts", but this usage is deprecated because the Add-on SDK uses "content script" to refer to a <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Guides/Content_Scripts">similar but different kind of script</a>.</p>
+</div>
+
+<p>因此从根本上,框架消息管理器使 chrome 代码能够:</p>
+
+<ul>
+ <li>加载一个脚本到一个内容进程中的框架(基本上,就是指一个浏览器标签页)。这些脚本被称为“框架脚本”。</li>
+ <li>使用消息传递 API 与框架脚本通信</li>
+</ul>
+
+<p>有多种类型的框架消息管理器,如图所示:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/10795/frame-message-managers.png" style="display: block; height: 596px; margin-left: auto; margin-right: auto; width: 737px;"></p>
+
+<p>This diagram shows the setup when there are 2 browser windows open, one with 2 tabs open and one with 1 tab open.</p>
+
+<h3 id="Chrome_进程">Chrome 进程</h3>
+
+<p>In the chrome process, there's a hierarchy of frame message managers: the global frame message manager, window message managers, and browser message managers.</p>
+
+<h4 id="全局框架消息管理器">全局框架消息管理器</h4>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <td style="width: 20%;">Description</td>
+ <td>
+ <p>There's a single <em>global frame message manager</em> in the chrome process.</p>
+
+ <p>This operates on all frames, in all content tabs. If you load a frame script using the global frame message manager, the script gets loaded separately into every open tab: three times, in the diagram above. Similarly, if you send a message using the global frame message manager, it's received by all content tabs, and is then delivered to any frame scripts that are listening for it.</p>
+
+ <p>Its most important functions and attributes are:</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageBroadcaster#childCount">childCount</a></code> : contains the number of children (typically, browser windows)</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageBroadcaster#getChildAt()">getChildAt()</a></code> : get the child at the given index</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFrameScriptLoader#loadFrameScript()">loadFrameScript()</a></code> : load a frame script into every tab in the browser</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageBroadcaster#broadcastAsyncMessage()">broadcastAsyncMessage()</a></code> : send a message to frame scripts</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager#addMessageListener()">addMessageListener()</a></code> : start listening to a specific message from all frame scripts</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager#removeMessageListener()">removeMessageListener()</a></code> : stop listening to a specific message</p>
+ </td>
+ </tr>
+ <tr>
+ <td>Interfaces</td>
+ <td>
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFrameScriptLoader" title="">nsIFrameScriptLoader</a></code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager" title="">nsIMessageListenerManager</a></code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageBroadcaster" title="">nsIMessageBroadcaster</a></code></p>
+ </td>
+ </tr>
+ <tr>
+ <td>How to access</td>
+ <td>
+ <p>Access it using <code><a href="/en-US/docs/Components.classes">Components.classes</a></code>:</p>
+
+ <pre class="brush: js language-js">
+// chrome script
+let globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
+ .getService(Ci.nsIMessageListenerManager);</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h4 id="窗口消息管理器">窗口消息管理器</h4>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <td style="width: 20%;">Description</td>
+ <td>
+ <p>There's a <em>window message manager</em> for every browser window: two, in the diagram above.</p>
+
+ <p>It operates on all content tabs in a given window. If you load a frame script using the window message manager it gets loaded separately into each tab open in that particular window. If you send a message using the window message manager, it gets sent to all content tabs in that window.</p>
+
+ <p>Its most important functions and attributes are:</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageBroadcaster#childCount">childCount</a></code> : contains the number of children (typically, browser tabs)</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageBroadcaster#getChildAt()">getChildAt()</a></code> : get the child at the given index</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFrameScriptLoader#loadFrameScript()">loadFrameScript()</a></code> : load a frame script into every tab in this window</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageBroadcaster#broadcastAsyncMessage()">broadcastAsyncMessage()</a></code> : send a message to all frame scripts in this window</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager#addMessageListener()">addMessageListener()</a></code> : start listening to a specific message from frame scripts</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager#removeMessageListener()">removeMessageListener()</a></code> : stop listening to a specific message</p>
+ </td>
+ </tr>
+ <tr>
+ <td>Interfaces</td>
+ <td>
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFrameScriptLoader" title="">nsIFrameScriptLoader</a></code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager" title="">nsIMessageListenerManager</a></code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageBroadcaster" title="">nsIMessageBroadcaster</a></code></p>
+ </td>
+ </tr>
+ <tr>
+ <td>How to access</td>
+ <td>
+ <p>You can access it as a property of the browser window:</p>
+
+ <pre class="brush: js">
+// chrome script
+let windowMM = window.messageManager;</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h4 id="浏览器消息管理器">浏览器消息管理器</h4>
+
+<div class="note">
+<p>Note that in this context, "browser" refers to the <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/browser">XUL &lt;browser&gt; object</a>, which is a frame that hosts a single Web document. It does not refer to the more general sense of a Web browser.</p>
+</div>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <td style="width: 20%;">Description</td>
+ <td>
+ <p>Finally, there's a <em>browser message manager</em> for every open content tab: three, in the diagram above.</p>
+
+ <p>This corresponds one-to-one with a content tab. Scripts you load using a browser message manager are loaded only into that content tab, and messages you send are delivered only to that content tab.</p>
+
+ <p>You can mix and match: so for example, you could load a script into every tab using the global message manager, but then send a message to the script instance loaded into a specific tab by using the browser message manager.</p>
+
+ <p>Its most important functions are:</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFrameScriptLoader#loadFrameScript()">loadFrameScript()</a></code> : load a frame script into this browser frame (tab)</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageSender#sendAsyncMessage()">sendAsyncMessage()</a></code> : send a message to all frame scripts in this browser frame</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager#addMessageListener()">addMessageListener()</a></code> : start listening to a specific message from frame scripts</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager#removeMessageListener()">removeMessageListener()</a></code> : stop listening to a specific message</p>
+ </td>
+ </tr>
+ <tr>
+ <td>Interfaces</td>
+ <td>
+ <p><code>nsIProcessChecker</code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFrameScriptLoader">nsIFrameScriptLoader</a></code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager">nsIMessageListenerManager</a></code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageSender">nsIMessageSender</a></code></p>
+ </td>
+ </tr>
+ <tr>
+ <td>How to access</td>
+ <td>
+ <p>The browser message manager can be accessed as a property of the XUL <code>&lt;browser&gt;</code> element:</p>
+
+ <pre class="brush: js">
+// chrome script
+let browserMM = gBrowser.selectedBrowser.messageManager;</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="内容进程">内容进程</h3>
+
+<h4 id="内容框架消息管理器">内容框架消息管理器</h4>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <td style="width: 20%;">Description</td>
+ <td>
+ <p>There's a <em>content frame message manager</em> for every open tab. It's the content-side end of frame message manager conversations.</p>
+
+ <p>Frame scripts are loaded into the content frame message manager scope, and messages from chrome message managers end up here.</p>
+
+ <p>The content frame message manager provides the <a href="/en-US/Firefox/Multiprocess_Firefox/Frame_script_environment">global object for frame scripts</a> (but note that there is trickery to ensure that top-level variables defined by frame scripts are not shared).</p>
+
+ <p>Frame scripts can use this object to send messages to the chrome process, and to receive messages from the chrome process.</p>
+
+ <p>Its most important attributes and functions are:</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentFrameMessageManager#content">content</a></code> : access the DOM window hosted by the tab</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentFrameMessageManager#docShell">docShell</a></code> : access the top-level docshell</p>
+
+ <p><code><a href="/en-US/docs/Components_object">Components</a></code> : access privileged objects and APIs</p>
+
+ <p><code><a href="/en-US/docs/Web/API/EventTarget/addEventListener">addEventListener()</a></code> : listen to DOM events</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager#addMessageListener()">addMessageListener()</a></code> : receive messages from the chrome process</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageSender#sendAsyncMessage()">sendAsyncMessage()</a></code> : send asynchronous messages to the chrome process</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISyncMessageSender#sendSyncMessage()">sendSyncMessage()</a></code> : send synchronous messages to the chrome process</p>
+ </td>
+ </tr>
+ <tr>
+ <td>Interfaces</td>
+ <td>
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIDOMEventTarget">nsIDOMEventTarget</a></code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager">nsIMessageListenerManager</a></code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageSender">nsIMessageSender</a></code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISyncMessageSender">nsISyncMessageSender</a></code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentFrameMessageManager">nsIContentFrameMessageManager</a></code></p>
+ </td>
+ </tr>
+ <tr>
+ <td>How to access</td>
+ <td>The content frame message manager is the global object in frame scripts.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="进程消息管理器">进程消息管理器</h2>
+
+<p>Process message managers correspond to process boundaries, and enable code running in different processes to communicate. Multiprocess Firefox has the concept of:</p>
+
+<ul>
+ <li>a "parent process"</li>
+ <li>"child processes" which are processes spawned by the parent process.</li>
+</ul>
+
+<p>For practical purposes, in multiprocess Firefox the parent process is the chrome process, and child processes are content processes. </p>
+
+<p>In each child process, there's a single <em>child process message manager</em> (CPMM). There's also an additional <em>child-in-process message manager</em> (CIPMM) in the parent process.</p>
+
+<p>For each child process message manager, there's a <em>parent process message manager</em> (PPMM) in the parent process.</p>
+
+<p>There's also a single <em>global parent process message manager</em> (GPPMM) in the parent process, that provides access to all the parent process message managers. The diagram below shows the setup that would result from having two child processes:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/10799/process-message-managers.png" style="display: block; height: 477px; margin-left: auto; margin-right: auto; width: 477px;"></p>
+
+<p>With the GPPMM, you can broadcast messages to the CIPMM and all CPMMs. With a PPMM, you can send a message to its corresponding CPMM. With a CPMM, you can send messages to the parent process: these messages are received first by the corresponding PPMM, then by the GPPMM.</p>
+
+<p>From Firefox 38 onwards, you can also use a parent process message manager to load a script into a child process. This is the recommended way to load a script that executes just once per child process, which is something you might want to do if you are interacting with some global service (for example, adding listeners to observer notifications or registering a content policy).</p>
+
+<h3 id="父消息管理器">父消息管理器</h3>
+
+<h4 id="全局父进程消息管理器">全局父进程消息管理器</h4>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <td style="width: 20%;">Description</td>
+ <td>
+ <p>The global parent process message manager (GPPMM) is global to the parent process.</p>
+
+ <ul>
+ <li>Messages sent using the GPPMM get sent to all CPMMs in all child processes.</li>
+ <li>Process scripts loaded using the GPPMM get loaded in all child processes.</li>
+ </ul>
+
+ <p>Its most important functions and attributes are:</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageBroadcaster#childCount">childCount</a></code> : contains the number of children (child processes, plus the in-content child)</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageBroadcaster#getChildAt()">getChildAt()</a></code> : get the child at the given index</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIProcessScriptLoader#loadProcessScript()">loadProcessScript()</a></code> : load a process script into every content process</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageBroadcaster#broadcastAsyncMessage()">broadcastAsyncMessage()</a></code> : send a message to all process scripts</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager#addMessageListener()">addMessageListener()</a></code> : start listening to a specific message from process scripts</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager#removeMessageListener()">removeMessageListener()</a></code> : stop listening to a specific message</p>
+ </td>
+ </tr>
+ <tr>
+ <td>Interfaces</td>
+ <td>
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIProcessScriptLoader">nsIProcessScriptLoader</a></code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager" title="">nsIMessageListenerManager</a></code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageBroadcaster" title="">nsIMessageBroadcaster</a></code></p>
+ </td>
+ </tr>
+ <tr>
+ <td>How to access</td>
+ <td>
+ <p>You can access the GPPMM with code like this:</p>
+
+ <pre class="brush: js">
+// parent process
+let ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
+ .getService(Ci.nsIMessageBroadcaster);</pre>
+
+ <p>You can also access it as the <code>ppmm</code> property of <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Services.jsm">Services.jsm</a>, if you are in the parent process.</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h4 id="父进程消息管理器">父进程消息管理器</h4>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <td style="width: 20%;">Description</td>
+ <td>
+ <p>There's one parent process message manager (PPMM) in the parent process for every child process, and its API is oriented to that one child process.</p>
+
+ <ul>
+ <li>Messages sent using the PPMM are received only by the corresponding CPMM</li>
+ <li>Scripts loaded using the PPMM are loaded only into the corresponding child process.</li>
+ </ul>
+
+ <p>Its most important functions are:</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIProcessScriptLoader#loadProcessScript()">loadProcessScript()</a></code> : load a process script into the content process</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageBroadcaster#broadcastAsyncMessage()">broadcastAsyncMessage()</a></code> : send a message to process scripts</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager#addMessageListener()">addMessageListener()</a></code> : start listening to a specific message from process scripts</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager#removeMessageListener()">removeMessageListener()</a></code> : stop listening to a specific message</p>
+ </td>
+ </tr>
+ <tr>
+ <td>Interfaces</td>
+ <td>
+ <p><code>nsIProcessChecker</code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIProcessScriptLoader">nsIProcessScriptLoader</a></code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager">nsIMessageListenerManager</a></code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageSender">nsIMessageSender</a></code></p>
+ </td>
+ </tr>
+ <tr>
+ <td>How to access</td>
+ <td>
+ <p>You can access a PPMM using the <code>getChildAt()</code> function in the GPPMM:</p>
+
+ <pre class="brush: js">
+// parent process
+let ppmm = Services.ppmm.getChildAt(1);</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="子进程">子进程</h3>
+
+<h4 id="子进程消息管理器">子进程消息管理器</h4>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <td style="width: 20%;">Description</td>
+ <td>
+ <p>There's one child process message manager (CPMM) in each child process. Messages sent using the CPMM are sent to the corresponding PPMM and are also relayed to the GPPMM.</p>
+
+ <p>Its most important attributes and functions are:</p>
+
+ <p><code><a href="/en-US/docs/Components_object">Components</a></code> : access privileged objects and APIs</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager#addMessageListener()">addMessageListener()</a></code> : receive messages from the parent process</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageSender#sendAsyncMessage()">sendAsyncMessage()</a></code> : send asynchronous messages to the parent process</p>
+
+ <p><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISyncMessageSender#sendSyncMessage()">sendSyncMessage()</a></code> : send synchronous messages to the parent process</p>
+ </td>
+ </tr>
+ <tr>
+ <td>Interfaces</td>
+ <td>
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager">nsIMessageListenerManager</a></code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageSender">nsIMessageSender</a></code></p>
+
+ <p><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISyncMessageSender">nsISyncMessageSender</a></code></p>
+
+ <p><code>nsIContentProcessMessageManager</code></p>
+ </td>
+ </tr>
+ <tr>
+ <td>How to access</td>
+ <td>
+ <p>Code running in a child process can access the CPMM with code like this:</p>
+
+ <pre class="brush: js">
+// child process script
+let cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
+ .getService(Ci.nsISyncMessageSender);</pre>
+
+ <p>You can also access it as the <code>cpmm</code> property of <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Services.jsm">Services.jsm</a>, if you are in the child process.</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
diff --git a/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/performance/index.html b/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/performance/index.html
new file mode 100644
index 0000000000..3bcb04d88e
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/multiprocess_firefox/message_manager/performance/index.html
@@ -0,0 +1,292 @@
+---
+title: 性能
+slug: Mozilla/Firefox/Multiprocess_Firefox/Message_Manager/Performance
+translation_of: Mozilla/Firefox/Multiprocess_Firefox/Message_Manager/Performance
+---
+<div>{{FirefoxSidebar}}</div><p>着重讲几点框架脚本/消息管理器的使用方式和替代方法,以避免相关的性能缺陷。</p>
+
+<p>要牢记几点:</p>
+
+<ul>
+ <li>附加组件启动时注册的脚本将在会话恢复时被执行。较长的执行时间会使浏览器启动后的响应速度缓慢。</li>
+ <li>框架脚本还可以在未恢复的标签页上被执行。所有开销不止发生在已激活的标签页,而是取决于会话中的标签页总数。</li>
+</ul>
+
+<div class="note">
+<p>下面的例子为了简洁,省略了一些样板代码</p>
+
+<p>“更好”的例子还省略了一些最佳实践。只是为了演示如何解决各子主题中描述的问题。</p>
+</div>
+
+<h2 id="性能的最佳实践">性能的最佳实践</h2>
+
+<h3 id="每个进程中声明无状态函数">每个进程中声明无状态函数</h3>
+
+<p>不良:</p>
+
+<pre class="brush: js">// addon.js
+<code>Services.mm.loadFrameScript</code>("framescript.js", true)
+</pre>
+
+<pre class="brush: js">// framescript.js
+
+const precomputedConstants = // ...
+
+function helper(window, action) {
+ // ... do some work on the window
+}
+
+function doSomething(message) {
+ result = helper(content, message.data)
+ sendAsyncMessage("my-addon:response-from-child", {something: result})
+}
+
+addMessageListener("my-addon:request-from-parent", doSomething)
+</pre>
+
+<p> </p>
+
+<p>Why is this bad? Because declared functions are also objects. And since frame scripts get evaluated for each tab this means new function objects get instantiated, new constants get computed, block scopes must be set up etc.</p>
+
+<p>While it may seem fairly innocencous in this toy example, real scripts often have a lot more functions and initialize some fairly heavyweight objects.</p>
+
+<p>更好:</p>
+
+<p><em>addon.js 如上</em></p>
+
+<pre class="brush: js">// framescript.js
+Components.utils.import("resource://my-addon/processModule.jsm", {}).addFrame(this)
+</pre>
+
+<pre class="brush: js">// processModule.jsm
+
+const EXPORTED_SYMBOLS = ['addFrame'];
+
+const precomputedConstants = // ...
+
+function helper(window, action) {
+ // ... do some work on the window
+}
+
+function doSomething(message) {
+ frameGlobal = message.target
+ result = helper(frameGlobal.content, message.data)
+ frameGlobal.sendAsyncMessage("my-addon:response-from-child", {something: result})
+}
+
+function addFrame(frameGlobal) {
+ frameGlobal.addMessageListener("my-addon:request-from-parent", doSomething)
+}
+</pre>
+
+<p><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Using">Javascript modules</a> are per-process singletons and thus all their objects are only initialized once, which makes them suitable for stateless callbacks.<br>
+ <br>
+ But care must be taken to not leak references to the frame script global when it is passed into a JSM. Alternatively the frame's <a href="/en-US/Firefox/Multiprocess_Firefox/Message_Manager/Frame_script_environment">unload event</a> or <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap">weak maps</a> can be used to ensure that frames can be cleaned up when their respective tab is closed.</p>
+
+<h3 id="每个进程中存放重量级的状态"><a name="per-process-state">每个进程中存放重量级的状态</a></h3>
+
+<p>不良:</p>
+
+<pre class="brush: js">// addon.js
+var main = new MyAddonService();
+
+main.onChange(stateChange);
+
+function stateChange() {
+ Services.mm.<code>broadcastAsyncMessage("my-addon:update-configuration", {newConfig: </code>main<code>.serialize()})</code>
+}
+</pre>
+
+<pre class="brush: js">// framescript.js
+var mainCopy;
+
+function onUpdate(message) {
+ mainCopy = MyAddonService.deserialize(message.data.newConfig);
+}
+
+addMessageListener("my-addon:update-configuration", onUpdate)
+
+
+// mainCopy used by other functions
+</pre>
+
+<p>The main issue here is that a separate object is kept for each tab. Not only does that increase memory footprint but the deserialization also has to be executed seperately for each tab, thus requiring more CPU time.</p>
+
+<p>不良:</p>
+
+<pre class="brush: js">// addon.js
+var main = new MyAddonService();
+
+main.onChange(stateChange);
+
+function stateChange() {
+ Services.ppmm.<code>broadcastAsyncMessage("my-addon:update-configuration", {newConfig: </code>main<code>.serialize()})</code>
+}</pre>
+
+<pre class="brush: js">// processModule.jsm
+const EXPORTED_SYMBOLS = ['getMainCopy'];
+
+var mainCopy;
+
+Services.cpmm.addMessageListener(<code>"my-addon:update-configuration"</code>, function(message) {
+ mainCopy = message.data.newConfig;
+})
+
+funtion getMainCopy() {
+ return mainCopy;
+}
+
+</pre>
+
+<pre class="brush: js">// framescript.js
+Components.utils.import("resource://my-addon/processModule.jsm")
+
+// getMainCopy() used by other functions
+</pre>
+
+<p> </p>
+
+<h3 id="不要在框架脚本中注册观察者(及其他到全局服务的回调)">不要在框架脚本中注册观察者(及其他到全局服务的回调)</h3>
+
+<p>不良:</p>
+
+<pre class="brush: js">//framescript.js
+Services.obs.addObserver("document-element-inserted", {
+ observe: function(doc, topic, data) {
+ if(doc.ownerGlobal.top != content)
+ return; // bail out if this is for another tab
+ decorateDocument(doc);
+ }
+})</pre>
+
+<p>Observer notifications get fired for events that happen <em>anywhere</em> in the browser, they are not scoped to the current tab. If each framescript registers a seperate listener then the observed action will trigger the callbacks in all tabs.</p>
+
+<p>Additionally the example above does not clean unregister itself, thus leaking objects each time a tab is closed. Frame message manager  message and event listeners are limited in their lifetime to that of the frame itself, this does not apply  to observer registrations.</p>
+
+<p>更好:</p>
+
+<p><span style="display: none;"> </span><span style="display: none;"> </span><span style="display: none;"> </span><span style="display: none;"> </span> </p>
+
+<dl>
+ <dt>content-document-global-created 通知</dt>
+ <dd>可以用 <a href="/en-US/Firefox/Multiprocess_Firefox/Message_Manager/Frame_script_environment">DOMWindowCreated</a> 事件取代</dd>
+ <dt>其他观察者和服务</dt>
+ <dd>应该在 <a href="/en-US/docs/Mozilla/Firefox/Multiprocess_Firefox/Message_Manager/Process_scripts">进程脚本</a> 中注册,或者用 JSM 代替</dd>
+</dl>
+
+<p> </p>
+
+<h3 id="根据需要加载框架脚本">根据需要加载框架脚本</h3>
+
+<p>不良:</p>
+
+<pre class="brush: js">// addon.js
+<code>Services.mm.loadFrameScript</code>("framescript.js", /*delayed:*/ true)
+
+// stuff communicating with the framescript
+</pre>
+
+<pre class="brush: js">// framescript.js
+function onlyOnceInABlueMoon() {
+ // we only need this during a total solar eclipse while goat blood rains from the sky
+ sendAsyncMessage('my-addon:paragraph-count', {num: content.document.querySelectorAll('p').length})
+}
+addMessageListener("my-addon:request-from-parent", onlyOnceInABlueMoon)
+</pre>
+
+<p>更好:</p>
+
+<pre class="brush: js">// addon.js
+function onToolbarButton(event) {
+ let tabMM = gBrowser.mCurrentBrowser.frameLoader.messageManager;
+ let button = event.target;
+ let callback = (message) =&gt; {
+ tabMM.removeMessageListener("my-addon:paragraph-count", callback)
+ decorateButton(button, message.data.num)
+ }
+ tabMM.addMessageListener("my-addon:paragraph-count", callback);
+ tabMM.loadFrameScript("data:,sendAsyncMessage('my-addon:paragraph-count', {num: content.document.querySelectorAll('p').length})", false)
+}
+
+function decorateButton(button, count) {
+ // do stuff with result
+}
+</pre>
+
+<p>This executes the script only when it is needed and only in one tab and allows it to be garbage-collected immediately after execution.  As long as it the action does not happen frequently the memory and startup savings should outstrip the added cost of script evaluation.</p>
+
+<p>Delaying the script registration <a href="/en-US/docs/Observer_Notifications#Application_startup">until the session is restored</a> my provide some middle ground for some addons. It does not provide the same memory footprint reductions but it improves application startup.</p>
+
+<p> </p>
+
+<h3 id="向下推进信息,避免到父进程的调用">向下推进信息,避免到父进程的调用</h3>
+
+<p>不良:</p>
+
+<pre>// processscript.js
+
+function ContentPolicy() {
+ // ...
+}
+
+Object.assign(ContentyPolicy.prototype, {
+ classDescription: ..., classID: ..., contractID: ...,
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPolicy]),
+
+ shouldLoad: function(type, location, origin, context) {
+
+ let resultList = Services.cpmm.sendSyncMessage("my-addon:check-load", {destination: location, source: origin}) // &lt;=== SYNC MESSAGE!
+
+ if(resultList.every((r) =&gt; r == true))
+ return Ci.nsIContentPolicy.<code>ACCEPT;
+
+ return Ci.nsIContentPolicy.REJECT_REQUEST;</code>
+ }
+});
+
+// more boilerplate code here
+</pre>
+
+<p>This example is a (somewhat condensed) <a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentPolicy">content policy</a> which gets triggered for every network request in a child process to either allow or deny the request. Since the code calls to the parent process to check whether a specific request can be allowed it would slow down all page loads, as web pages generally issue dozens of requests.</p>
+
+<p>更好:</p>
+
+<p>Instead of only keeping the state in the parent an addon can employ a master-slave architecture where the parent has the authoritative state and replicates it to the child processes in advance so they can act based on their local copy.</p>
+
+<p>See the <a href="#per-process-state">previous chapter</a> on how to efficiently replicate addon state to each process.</p>
+
+<p> </p>
+
+<p> </p>
+
+<h3 id="附加组件卸载时的清理">附加组件卸载时的清理</h3>
+
+<p> </p>
+
+<p>不良:</p>
+
+<p>包括上述所有例子,*包括上述的“更好”*</p>
+
+<p>If your addon is restartless or uses the SDK then updates or the user turning it off and on will load to unload/reload events. Not handling those properly can lead to duplicate or conflicting code execution, especially when messages are sent. It can also lead to conflicts between the old and new code. Under some circumstances it may even cause exceptions when attempting to register something twice under the same ID.</p>
+
+<p>更好:</p>
+
+<pre class="brush: js">// addon.js
+function onUnload() {
+ Services.mm.removeDelayedFrameScript("resources://my-addon/framescript.js");
+ Services.ppmm.removeDelayedProcessScript("resources://my-addon/processcript.js");
+ Services.mm.broadcastAsyncMessage("my-addon:unload");
+ Services.ppmm.broadcastAsyncMessage("my-addon:unload");
+}
+</pre>
+
+<p>在框架/进程脚本中:</p>
+
+<ul>
+ <li>移除各种监听器</li>
+ <li>移除观察者通知</li>
+ <li>移除自定义的类和服务</li>
+ <li><a href="/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.Sandbox#Freeing_the_sandbox">nuke 沙盒</a></li>
+ <li><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Using#Unloading_code_modules">卸载 JSM</a></li>
+ <li>必要时还原内容 DOM 的状态,例如移除附加组件加入的不再需要的互动 UI 元素</li>
+</ul>
diff --git a/files/zh-cn/mozilla/firefox/multiprocess_firefox/motivation/index.html b/files/zh-cn/mozilla/firefox/multiprocess_firefox/motivation/index.html
new file mode 100644
index 0000000000..7ae3c2aaef
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/multiprocess_firefox/motivation/index.html
@@ -0,0 +1,44 @@
+---
+title: 动机
+slug: Mozilla/Firefox/Multiprocess_Firefox/Motivation
+translation_of: Mozilla/Firefox/Multiprocess_Firefox/Motivation
+---
+<div>{{FirefoxSidebar}}</div><p>使 Firefox 在单独的进程中运行内容的主要原因:性能、安全和稳定性。</p>
+
+<h2 id="性能">性能</h2>
+
+<p>Mozilla 在过去两年对性能的工作重点是浏览器的响应速度。目标是减少 “<a href="/en-US/docs/Glossary/Jank">jank</a>”—在加载大的页面时、表单中输入、或者滚动时,浏览器暂时性失去响应。响应问题在当今较高吞吐量的网络上日益显著。这些工作大部分已被 <a href="https://wiki.mozilla.org/Performance/Snappy">Snappy 项目</a>完成。主要的重点在:</p>
+
+<ul>
+ <li>将运行时间长的操作移入单独的线程,使主线程可以继续向用户做出响应。</li>
+ <li>异步或者在其他线程进行 I/O,使主线程不必等待磁盘。</li>
+ <li>将运行时间长的代码拆分成较短片段,并且在事件循环之间运行。增量式垃圾收集就是一个例子。</li>
+</ul>
+
+<p>大部分能轻易做到的事情在这些领域已经完成。剩下的问题比较难以解决。举例来说,JavaScript 执行和布局都发生在主线程,并且阻挡着事件循环。在单独的线程中运行这些组件是困难的,因为它们访问数据,像是 DOM,它们不是线程安全的。作为替代方案,我们已经考虑让事件循环运行在 JavaScript 执行的中间,但这样做会毁掉大量 Firefox 其他地方做出的假设(更不用提附加组件)。</p>
+
+<p>在一个单独的进程中运行网络内容,是这些方法的一个不错的替代品。类似线程的方式,Firefox 可以在 JavaScript 和布局在内容进程中运行时运行事件循环。但是不同于线程,用户界面(UI)的代码不能访问内容 DOM 或者其他内容的数据结构,因此没有必要进行锁定或者线程安全。而不足之处是,理所当然的,任何在 Firefox UI 进程中运行的需要访问内容数据的代码,都必须明确的通过消息传递的方式来访问内容数据。</p>
+
+<p>我们觉得这种权衡有道理,有几个原因:</p>
+
+<ul>
+ <li>Firefox 代码访问内容 DOM 并不是很常见。</li>
+ <li>与 Firefox OS 共享的代码已经使用消息传递。</li>
+ <li>在多进程模型中,使用消息传递访问内容失败的 Firefox 代码将明显的失败,一致的方式。在线程模型中,没有适当锁定的访问内容的代码将以微妙的方式失败,很难调试。</li>
+</ul>
+
+<h2 id="安全">安全</h2>
+
+<p>目前来说,如果某人发现了一个 Firefox 中的可利用漏洞,他们能够接管用户的计算机。有很多种技术来缓解这种问题,但其中最强大的是<a href="http://en.wikipedia.org/wiki/Sandbox_%28computer_security%29">沙盒</a>。从技术上讲,沙盒不需要多个进程。但是,涵盖沙盒的单进程 Firefox 并不会很有用。沙盒能阻止进程执行,一个乖巧进程绝不会做的操作。遗憾的是,乖巧的 Firefox 进程(尤其是已安装附加组件的 Firefox)会访问很多网络和文件系统。因此,对单进程的 Firefox 沙盒不能限制太多。</p>
+
+<p>在多进程 Firefox 中,内容进程将被沙盒化。一个乖巧的内容进程不会直接访问文件系统;它必须询问主线程来执行请求。在那时,主进程可以验证请求是否安全和合理。因此,对内容进程的沙盒化可以是相当严格的。我们希望这样的布局可以使 Firefox 更难被安全漏洞所利用。</p>
+
+<h2 id="稳定性">稳定性</h2>
+
+<p>目前来说,在网页中运行的代码出现崩溃将导致整个浏览器崩溃。而多进程 Firefox 中,只有崩溃的内容进程会被终止。</p>
+
+<div class="note">
+<p>此页面整合了很多 Bill McCloskey 的有关多进程 Firefox 的文章: <a href="http://billmccloskey.wordpress.com/2013/12/05/multiprocess-firefox/">http://billmccloskey.wordpress.com/2013/12/05/multiprocess-firefox/</a></p>
+</div>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/firefox/multiprocess_firefox/tab_selection_in_multiprocess_firefox/index.html b/files/zh-cn/mozilla/firefox/multiprocess_firefox/tab_selection_in_multiprocess_firefox/index.html
new file mode 100644
index 0000000000..f396b7dcb5
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/multiprocess_firefox/tab_selection_in_multiprocess_firefox/index.html
@@ -0,0 +1,21 @@
+---
+title: 多进程 Firefox 中的标签选择
+slug: Mozilla/Firefox/Multiprocess_Firefox/Tab_selection_in_multiprocess_Firefox
+translation_of: Mozilla/Firefox/Multiprocess_Firefox/Tab_selection_in_multiprocess_Firefox
+---
+<div>{{FirefoxSidebar}}</div><p>在单进程的 Firefox 中,当用户切换标签页时,这是同步操作。当浏览器加载新选择的标签页时,浏览器会阻塞,然后切换到该标签页。这表示标签页选定是通过设置 XUL 的 tab 对象的 <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/selected">selected</a></code> 属性。代码(包括浏览器代码、扩展或主题)想要更改选定标签页的外观时,可以使用 <code>selected</code>  属性来应用 CSS 到该标签页。</p>
+
+<p>在多进程的 Firefox 中,标签页切换是异步的。在用户切换标签页时,chrome 进程发送一个请求到内容进程来加载该页面到新选择的标签页。chrome 进程中的函数会立即返回,以便其他代码可以运行。一旦内容进程准备就绪,它发回一个消息到 chrome 进程,然后在用户界面中切换标签页。</p>
+
+<p>还有 chrome 进程中的计时器:如果内容进程在计时器到期前没有响应,那么浏览器虽然继续切换标签页,但也显示一个包含标识的空标签页,直到目前的内容进程完成页面的加载。目前的计时器被设定为300毫秒。</p>
+
+<p>还有,相应的,两个属性用于指示标签页选择:</p>
+
+<ul>
+ <li>旧的 <code><a href="/en-US/docs/XUL/Attribute/selected">selected</a></code> 属性是同步设置,在进程的开始。它表示标签页选择已经开始,但在用户界面还没有被更新。</li>
+ <li>新的属性 <code><a href="/en-US/docs/Mozilla/Tech/XUL/Attribute/visuallyselected">visuallyselected</a></code> 现在表示浏览器在用户界面已实际更新(显示)的标签页,包括内容进程已就绪或者计时器已过期这两种情况。</li>
+</ul>
+
+<p>这意味着想要对当前选中标签页应用的样式需要使用 <code>visuallyselected</code> 属性。如果使用 <code>selected</code> 属性,那么在新选择的标签页的样式被更新时会有一个短暂的断层,浏览器仍然在显示旧的标签页的内容。</p>
+
+<footer class="entry-meta"> </footer>
diff --git a/files/zh-cn/mozilla/firefox/multiprocess_firefox/technical_overview/index.html b/files/zh-cn/mozilla/firefox/multiprocess_firefox/technical_overview/index.html
new file mode 100644
index 0000000000..18917fabc4
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/multiprocess_firefox/technical_overview/index.html
@@ -0,0 +1,164 @@
+---
+title: 技术概述
+slug: Mozilla/Firefox/Multiprocess_Firefox/Technical_overview
+translation_of: Mozilla/Firefox/Multiprocess_Firefox/Technical_overview
+---
+<div>{{FirefoxSidebar}}</div><div class="note">
+<p>这个页面主要是 Bill McCloskey 的关于多进程 Firefox 的摘要: <a class="external external-icon" href="http://billmccloskey.wordpress.com/2013/12/05/multiprocess-firefox/">http://billmccloskey.wordpress.com/2013/12/05/multiprocess-firefox/</a></p>
+</div>
+
+<p>从总体上来看,多进程 Firefox 的运行方式如下。当 Firefox 启动时的进程被称为父进程。起初和单程 Firefox 一样:打开一个窗口用于显示<code><a href="http://mxr.mozilla.org/mozilla-central/source/browser/base/content/browser.xul">browser.xul</a>,它</code>包含主要的 UI 元素。XUL是Firefox的GUI工具箱, 由它提供了类似Web HTML的方式来声明定义UI元素。Firefox 的 UI也有一个<code>window</code> 对象。它有一个<code>document</code> 属性,并含了在 <code>browser.xul</code> 中所有的XML元素。所有的菜单,工具栏,侧边栏和标签页都是 <code>document</code> 下的 XML 元素。每一个标签页(tab)都包含一个 <code>&lt;browser&gt;</code> 元素用来显示网页内容.</p>
+
+<p>多进程与单进程的最主要区别是每个 <code>&lt;browser&gt;</code> 都有一个<code>remote="true"</code> 的属性。当这个 browser 元素被添加到 document 时,将会启动一个新的内容进程,也称为子进程。同时创建一个跨进程通信的IPC通道。开始时子进程显示<code> about:blank</code>,父进程通过给子进程发送命令来导航显示的内容。</p>
+
+<h2 id="绘制"><strong id="drawing">绘制</strong></h2>
+
+<p>有时,显示的网页内容需要从子进程传递到父进程然后再显示到屏幕。多进程模式依赖于一个新的特性(<a href="http://benoitgirard.wordpress.com/2012/05/15/off-main-thread-compositing-omtc-and-why-it-matters/"><em>off main thread compositing</em></a> ,OMTC)。简单来说,每个窗口被分成若干层,概念上类似于photoshop中的层。每一次Firefox进行渲染时,这些层被提交到合成线程来构建为一个图片。</p>
+
+<p>层是树状结构。树的根节点对应一个Firefox窗口。根节点层包其他子层,如绘制菜单和标签页。一个子树对应所有网页内容。网页内容可被分成更多的层,这些层都以同一个内容层为根节点。</p>
+
+<p>在多进程Firefox中,内容层的子树是一个垫片(shim)。在大多数时间,它包含一个能够简单地保持到子进程的通信链接的引用的占位符节点。内容进程包括网页内容的层树。它构建并且描绘这个层树。当描绘完成时,它通过IPC将层数的结构发送给父进程。当父进程受到这个层树时,它删除这个占位符内容节点并且将其替换为源于内容的实际树。然后它正常地合成并且绘制。当它完成后,它将占位符放回。</p>
+
+<p>因为Firefox OS的需要,OMTC怎样于多进程一起工作的基本构架已经存在了一段时间。然而,Matt Woodrow和 David Anderson已经完成了大量工作来使得其在Windows,Mac和Linux正常工作。一个巨大的挑战是使多进程Firefox能够在所有平台下都能使OMTC启动。现在,只有Macs默认使用OMTC。</p>
+
+<h2 id="用户输入"><strong id="input">用户输入</strong></h2>
+
+<p>Events in Firefox work the same way as they do on the web. Namely, there is a DOM tree for the entire window, and events are threaded through this tree in capture and bubbling phases. Imagine that the user clicks on a button on a web page. In single-process Firefox, the root DOM node of the Firefox window gets the first chance to process the event. Then, nodes lower down in the DOM tree get a chance. The event handling proceeds down through to the XUL <code>&lt;browser&gt;</code> element. At this point, nodes in the web page’s DOM tree are given a chance to handle the event, all the way down to the button. The bubble phase follows, running in the opposite order, all the way back up to the root node of the Firefox window.</p>
+
+<p>With multiple processes, event handling works the same way until the <code>&lt;browser&gt;</code> element is hit. At that point, if the event hasn’t been handled yet, it gets sent to the child process by IPC, where handling starts at the root of the content DOM tree. The parent process then waits to run its bubbling phase until the content process has finished handling the event.</p>
+
+<h2 id="进程间通信"><strong id="ipc">进程间通信</strong></h2>
+
+<p>所有 IPC 使用 Chromium IPC 程序库。每个子进程都有单独的与父进程的 IPC 链接。子进程之间不能直接通信。为了避免死锁和确保响应能力,父进程不允许坐等子进程的消息。但是,子进程可以阻塞等待父进程的消息。</p>
+
+<p>相比于人们预期的直接通过 IPC 发送数据包,我们使用代码生成使这个过程更漂亮。IPC 协议在 <a href="https://wiki.mozilla.org/IPDL">IPDL</a> 中定义, which sort of stands for “inter-* protocol definition language”. A typical IPDL file is <code><a href="http://mxr.mozilla.org/mozilla-central/source/netwerk/ipc/PNecko.ipdl">PNecko.ipdl</a></code>. It defines a set messages and their parameters. Parameters are serialized and included in the message. To send a message <code>M</code>, C++ code just needs to call the method <code>SendM</code>. To receive the message, it implements the method <code>RecvM</code>.</p>
+
+<p>IPDL is used in all the low-level C++ parts of Gecko where IPC is required. In many cases, IPC is just used to forward actions from the child to the parent. This is a common pattern in Gecko:</p>
+
+<pre class="brush: cpp">void AddHistoryEntry(param) {
+ if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ // If we're in the child, ask the parent to do this for us.
+ SendAddHistoryEntry(param);
+ return;
+ }
+
+ // Actually add the history entry...
+}
+
+bool RecvAddHistoryEntry(param) {
+ // Got a message from the child. Do the work for it.
+ AddHistoryEntry(param);
+ return true;
+}
+</pre>
+
+<p>When <code>AddHistoryEntry</code> is called in the child, we detect that we’re inside the child process and send an IPC message to the parent. When the parent receives that message, it calls <code>AddHistoryEntry</code> on its side.</p>
+
+<p>For a more realistic illustration, consider the Places database, which stores visited URLs for populating the awesome bar. Whenever the user visits a URL in the content process, we call <a href="http://mxr.mozilla.org/mozilla-central/source/toolkit/components/places/History.cpp?rev=8b9687f6c602#2326">this code</a>. Notice the content process check followed by the <code>SendVisitURI</code> call and an immediate return. The message is received <a href="http://mxr.mozilla.org/mozilla-central/source/dom/ipc/ContentParent.cpp?rev=fecda5f4a0df#2666">here</a>; this code just calls <code>VisitURI</code> in the parent.</p>
+
+<p>The code for IndexedDB, the places database, and HTTP connections all runs in the parent process, and they all use roughly the same proxying mechanism in the child.</p>
+
+<h2 id="框架脚本"><strong id="contentscripts">框架脚本</strong></h2>
+
+<p>IPDL takes care of passing messages in C++, but much of Firefox is actually written in JavaScript. Instead of using IPDL directly, JavaScript code relies on <a href="/en-US/Firefox/Multiprocess_Firefox/The_message_manager">the message manager</a> to communicate between processes. To use the message manager in JS, you need to get hold of a message manager object. There is a global message manager, message managers for each Firefox window, and message managers for each <code>&lt;browser&gt;</code> element. A message manager can be used to load JS code into the child process and to exchange messages with it.</p>
+
+<p>As a simple example, imagine that we want to be informed every time a <code>load</code> event triggers in web content. We’re not interested in any particular browser or window, so we use the global message manager. The basic process is as follows:</p>
+
+<pre class="brush: js">// Get the global message manager.
+let mm = Cc["@<span class="skimlinks-unlinked">mozilla.org/globalmessagemanager;1</span>"].
+ getService(Ci.nsIMessageListenerManager);
+
+// Wait for load event.
+mm.addMessageListener("GotLoadEvent", function (msg) {
+ dump("Received load event: " + <span class="skimlinks-unlinked">msg.data.url</span> + "\n");
+});
+
+// Load code into the child process to listen for the event.
+mm.loadFrameScript("chrome://content/<span class="skimlinks-unlinked">content-script.js</span>", true);
+</pre>
+
+<p>For this to work, we also need to have a file <code>content-script.js</code>:</p>
+
+<pre class="brush: js">// Listen for the load event.
+addEventListener("load", function (e) {
+ // Inform the parent process.
+ let docURL = content.document.documentURI;
+ sendAsyncMessage("GotLoadEvent", {url: docURL});
+}, false);
+</pre>
+
+<p>This file is called a <em>frame script</em>. When the <code>loadFrameScript</code> function call runs, the code for the script is run once for each <code>&lt;browser&gt;</code> element. This includes both remote browsers and regular ones. If we had used a per-window message manager, the code would only be run for the browser elements in that window. Any time a new browser element is added, the script is run automatically (this is the purpose of the <code>true</code> parameter to <code>loadFrameScript</code>). Since the script is run once per browser, it can access the browser’s window object and docshell via the <code>content</code> and <code>docShell</code> globals.</p>
+
+<p>The great thing about frame scripts is that they work in both single-process and multiprocess Firefox. To learn more about the message manager, see the <a href="/en-US/Firefox/Multiprocess_Firefox/The_message_manager">message manager guide</a>.</p>
+
+<h2 id="跨进程_API"><strong id="shims">跨进程 API</strong></h2>
+
+<p>There are a lot of APIs in Firefox that cross between the parent and child processes. An example is the <code>webNavigation</code> property of XUL <code>&lt;browser&gt;</code> elements. The <code>webNavigation</code> property is an object that provides methods like <code>loadURI</code>, <code>goBack</code>, and <code>goForward</code>. These methods are called in the parent process, but the actions need to happen in the child. First I’ll cover how these methods work in single-process Firefox, and then I’ll describe how we adapted them for multiple processes.</p>
+
+<p>The <code>webNavigation</code> property is defined using the XML Binding Language (XBL). XBL is a declarative language for customizing how XML elements work. Its syntax is a combination of XML and JavaScript. Firefox uses XBL extensively to customize XUL elements like <code>&lt;browser&gt;</code> and <code>&lt;tabbrowser&gt;</code>. The <code>&lt;browser&gt;</code> customizations reside in <code><a href="http://mxr.mozilla.org/mozilla-central/source/toolkit/content/widgets/browser.xml?rev=754cf7fc84cd">browser.xml</a></code>. <a href="http://mxr.mozilla.org/mozilla-central/source/toolkit/content/widgets/browser.xml?rev=754cf7fc84cd#262">Here</a> is how <code>browser.webNavigation</code> is defined:</p>
+
+<pre class="brush: xml">&lt;field name="_webNavigation"&gt;null&lt;/field&gt;
+
+&lt;property name="webNavigation" readonly="true"&gt;
+ &lt;getter&gt;
+ &lt;![CDATA[
+ if (!this._webNavigation)
+ this._webNavigation = this.docShell.QueryInterface(Components.interfaces.nsIWebNavigation);
+ return this._webNavigation;
+ ]]&gt;
+ &lt;/getter&gt;
+&lt;/property&gt;
+</pre>
+
+<p>This code is invoked whenever JavaScript code in Firefox accesses <code>browser.webNavigation</code>, where <code>browser</code> is some <code>&lt;browser&gt;</code> element. It checks if the result has already been cached in the <code>browser._webNavigation</code> field. If it hasn’t been cached, then it fetches the navigation object based off the browser’s <em>docshell</em>. The docshell is a Firefox-specific object that encapsulates a lot of functionality for loading new pages, navigating back and forth, and saving page history. In multiprocess Firefox, the docshell lives in the child process. Since the <code>webNavigation</code> accessor runs in the parent process, <code>this.docShell</code> above will just return null. As a consequence, this code will fail completely.</p>
+
+<p>One way to fix this problem would be to create a fake docshell in C++ that could be returned. It would operate by sending IPDL messages to the real docshell in the child to get work done. We may eventually take this route in the future. We decided to do the message passing in JavaScript instead, since it’s easier and faster to prototype things there. Rather than change every docshell-using accessor to test if we’re using multiprocess browsing, we decided to create a new XBL binding that applies only to remote <code>&lt;browser&gt;</code> elements. It is called <a href="http://mxr.mozilla.org/mozilla-central/source/toolkit/content/widgets/remote-browser.xml?rev=9583bd3099ae"><code>remote-browser.xml</code></a>, and it extends the existing <code>browser.xml</code> binding.</p>
+
+<p>The <code>remote-browser.xml</code> binding returns a JavaScript <em>shim object</em> whenever anyone uses <code>browser.webNavigation</code> or other similar objects. The shim object is implemented <a href="http://mxr.mozilla.org/mozilla-central/source/toolkit/modules/RemoteWebNavigation.jsm">in its own JavaScript module</a>. It uses the message manager to send messages like <code>"WebNavigation:LoadURI"</code> to <a href="http://mxr.mozilla.org/mozilla-central/source/toolkit/content/browser-child.js?rev=9583bd3099ae#107">a content script loaded by <code>remote-browser.xml</code></a>. The content script performs the actual action.</p>
+
+<p>The shims we provide emulate their real counterparts imperfectly. They offer enough functionality to make Firefox work, but add-ons that use them may find them insufficient. I’ll discuss strategies for making add-ons work in more detail later.</p>
+
+<h2 id="跨进程对象包装器"><strong id="cpows">跨进程对象包装器</strong></h2>
+
+<p>The message manager API does not allow the parent process to call <code>sendSyncMessage</code>; that is, the parent is not allowed to wait for a response from the child. It’s detrimental for the parent to wait on the child, since we don’t want the browser UI to be unresponsive because of slow content. However, converting Firefox code to be asynchronous (i.e., to use <code>sendAsyncMessage</code> instead) can sometimes be onerous. As an expedient, we’ve introduced a new primitive that allows code in the parent process to access objects in the child process synchronously.</p>
+
+<p>These objects are called cross-process object wrappers, frequently abbreviated to CPOWs. They’re created using the message manager. Consider this example content script:</p>
+
+<pre class="brush: js">addEventListener("load", function (e) {
+ let doc = content.document;
+ sendAsyncMessage("GotLoadEvent", <strong>{}, {document: doc}</strong>);
+}, false);
+</pre>
+
+<p>In this code, we want to be able to send a reference to the document to the parent process. We can’t use the second parameter to <code>sendAsyncMessage</code> to do this: that argument is converted to JSON before it is sent up. The optional third parameter allows us to send object references. Each property of this argument becomes accessible in the parent process as a CPOW. Here’s what the parent code might look like:</p>
+
+<pre class="brush: js">let mm = Cc["@<span class="skimlinks-unlinked">mozilla.org/globalmessagemanager;1</span>"].
+ getService(Ci.nsIMessageListenerManager);
+
+mm.addMessageListener("GotLoadEvent", function (msg) {
+ let uri = <strong>msg.objects.document.documentURI</strong>;
+ dump("Received load event: " + uri + "\n");
+});
+mm.loadFrameScript("chrome://content/<span class="skimlinks-unlinked">content-script.js</span>", true);
+</pre>
+
+<p>It’s important to realize that we’re send object <em>references</em>. The <code>msg.objects.document</code> object is only a wrapper. The access to its <code>documentURI</code> property sends a synchronous message down to the child asking for the value. The dump statement only happens after a reply has come back from the child.</p>
+
+<p>Because every property access sends a message, CPOWs can be slow to use. There is no caching, so 1,000 accesses to the same property will send 1,000 messages.</p>
+
+<p>Another problem with CPOWs is that they violate some assumptions people might have about message ordering. Consider this code:</p>
+
+<pre class="brush: js">mm.addMessageListener("GotLoadEvent", function (msg) {
+ mm.sendAsyncMessage("ChangeDocumentURI", {newURI: "<span class="skimlinks-unlinked">hello.com</span>"});
+ let uri = <strong>msg.objects.document.documentURI</strong>;
+ dump("Received load event: " + uri + "\n");
+});
+</pre>
+
+<p>This code sends a message asking the child to change the current document URI. Then it accesses the current document URI via a CPOW. You might expect the value of <code>uri</code> to come back as <code>"hello.com"</code>. But it might not. In order to avoid deadlocks, CPOW messages can bypass normal messages and be processed first. It’s possible that the request for the <code>documentURI</code> property will be processed before the <code>"ChangeDocumentURI"</code> message, in which case <code>uri</code> will have some other value.</p>
+
+<p>For this reason, it’s best not to mix CPOWs with normal message manager messages. It’s also a bad idea to use CPOWs for anything security-related, since you may not get results that are consistent with surrounding code that might use the message manager.</p>
+
+<p>Despite these problems, we’ve found CPOWs to be useful for converting certain parts of Firefox to be multiprocess-compatible. It’s best to use them in cases where users are less likely to notice poor responsiveness. As an example, we use CPOWs to implement the context menu that pops up when users right-click on content elements. Whether this code is asynchronous or synchronous, the menu cannot be displayed until content has responded with data about the element that has been clicked. The user is unlikely to notice if, for example, tab animations don’t run while waiting for the menu to pop up. Their only concern is for the menu to come up as quickly as possible, which is entirely gated on the response time of the content process. For this reason, we chose to use CPOWs, since they’re easier than converting the code to be asynchronous.</p>
+
+<p>It’s possible that CPOWs will be phased out in the future. Asynchronous messaging using the message manager gives a user experience that is at least as good as, and often strictly better than, CPOWs. We strongly recommend that people use the message manager over CPOWs when possible. Nevertheless, CPOWs are sometimes useful.</p>
diff --git a/files/zh-cn/mozilla/firefox/multiprocess_firefox/which_uris_load_where/index.html b/files/zh-cn/mozilla/firefox/multiprocess_firefox/which_uris_load_where/index.html
new file mode 100644
index 0000000000..df24c59988
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/multiprocess_firefox/which_uris_load_where/index.html
@@ -0,0 +1,53 @@
+---
+title: 各类 URI 在哪里加载
+slug: Mozilla/Firefox/Multiprocess_Firefox/Which_URIs_load_where
+translation_of: Mozilla/Firefox/Multiprocess_Firefox/Which_URIs_load_where
+---
+<div>{{FirefoxSidebar}}</div><p>浏览器加载一个页面到 chrome 或者内容进程,基于它的 URI 方案(URI scheme)。对于某些方案,你可以改变默认行为。</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Scheme</th>
+ <th scope="col">Behavior</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>about:</code></td>
+ <td>
+ <p>默认情况下,<code>about:</code> 页面始终在 chrome 进程加载。但是,在你注册新的 <code>about:</code> 页面时,你可以改变此默认值。</p>
+
+ <p>两个新标志定义在 <code><a href="https://dxr.mozilla.org/mozilla-central/source/netwerk/protocol/about/nsIAboutModule.idl">nsIAboutModule</a></code>:</p>
+
+ <ul>
+ <li><code>URI_CAN_LOAD_IN_CHILD</code>: 页面将加载在加载它的 <code><a href="/en-US/docs/XUL/browser">browser</a></code> 所在的进程。</li>
+ <li><code>URI_MUST_LOAD_IN_CHILD</code>: 页面将始终加载在一个子进程</li>
+ </ul>
+
+ <p>要使用上述任一标志,在你的 <a href="/en-US/docs/Custom_about:_URLs">注册 <code>about:</code> URI 的代码</a> 的 <code>getURIFlags</code> 实现中返回它。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>chrome:</code></td>
+ <td>
+ <p><code>默认情况下,chrome:</code> 页面始终加载在 chrome 进程。但是,在你注册新的 <code>chrome:</code> 页面时,你可以改变此默认值。</p>
+
+ <p>两个新标志定义在 <a href="/en-US/docs/Chrome_Registration">chrome.manifest 文件</a>:</p>
+
+ <ul>
+ <li>remoteenabled: 页面将加载在加载它的 <code><a href="/en-US/docs/XUL/browser">browser</a></code> 所在的进程。</li>
+ <li>remoterequired: 页面将始终加载在一个子进程</li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td><code>file:</code></td>
+ <td>始终在内容进程中加载。</td>
+ </tr>
+ <tr>
+ <td><code>resource:</code></td>
+ <td>始终在内容进程中加载。</td>
+ </tr>
+ </tbody>
+</table>
diff --git a/files/zh-cn/mozilla/firefox/privacy/index.html b/files/zh-cn/mozilla/firefox/privacy/index.html
new file mode 100644
index 0000000000..e9a4126aa6
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/privacy/index.html
@@ -0,0 +1,22 @@
+---
+title: 隐私
+slug: Mozilla/Firefox/Privacy
+tags:
+ - 安全
+ - 隐私
+translation_of: Mozilla/Firefox/Privacy
+---
+<div>{{FirefoxSidebar}}</div>
+
+<p class="summary">本文档是所有隐私相关的文档的列表。</p>
+
+<p>{{ ListSubpages () }}</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li><a href="https://support.mozilla.org/zh-CN/products/firefox/privacy-and-security">隐私与安全设置 | Firefox 帮助</a></li>
+ <li><a href="/zh-CN/docs/Web/Security">
+Web 安全
+</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/firefox/privacy/storage_access_policy/errors/index.html b/files/zh-cn/mozilla/firefox/privacy/storage_access_policy/errors/index.html
new file mode 100644
index 0000000000..a1e1f54a75
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/privacy/storage_access_policy/errors/index.html
@@ -0,0 +1,24 @@
+---
+title: Errors
+slug: Mozilla/Firefox/Privacy/Storage_access_policy/Errors
+tags:
+ - Cookies
+ - Errors
+ - NeedsTranslation
+ - Storage
+ - TopicStub
+ - storage access policy
+translation_of: Mozilla/Firefox/Privacy/Storage_access_policy/Errors
+---
+<div>{{FirefoxSidebar}}</div>
+
+<p>This page lists the errors that can be raised due to Firefox's anti-tracking functionality, governed by the <a href="/en-US/docs/Mozilla/Firefox/Privacy/Storage_access_policy">Storage access policy</a>. You can find further information about them by clicking on the links below:</p>
+
+<p>A request to access cookies or storage was blocked because</p>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/Firefox/Privacy/Storage_access_policy/Errors/CookieBlockedByPermission">of custom cookie permission</a></li>
+ <li><a href="/en-US/docs/Mozilla/Firefox/Privacy/Storage_access_policy/Errors/CookieBlockedTracker">it came from a tracker and content blocking is enabled</a></li>
+ <li><a href="/en-US/docs/Mozilla/Firefox/Privacy/Storage_access_policy/Errors/CookieBlockedAll">we are blocking all storage access requests</a></li>
+ <li><a href="/en-US/docs/Mozilla/Firefox/Privacy/Storage_access_policy/Errors/CookieBlockedForeign">we are blocking all third-party storage access requests and content blocking is enabled</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/firefox/privacy/storage_access_policy/errors/禁用外部cookie/index.html b/files/zh-cn/mozilla/firefox/privacy/storage_access_policy/errors/禁用外部cookie/index.html
new file mode 100644
index 0000000000..d2c05cd375
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/privacy/storage_access_policy/errors/禁用外部cookie/index.html
@@ -0,0 +1,39 @@
+---
+title: 禁用:所有第三方存储访问请求
+slug: Mozilla/Firefox/Privacy/Storage_access_policy/Errors/禁用外部Cookie
+tags:
+ - cookie
+ - 存储
+ - 存储访问策略
+ - 跟踪
+ - 错误
+translation_of: Mozilla/Firefox/Privacy/Storage_access_policy/Errors/CookieBlockedForeign
+---
+<div>{{FirefoxSidebar}}</div>
+
+<h2 id="消息">消息</h2>
+
+<p>Firefox:</p>
+
+<pre class="syntaxbox">禁用外部Cookie:由于浏览器禁用第三方内容展示及存储访问请求,Cookie和存储访问被拦截无法使用。</pre>
+
+<h2 id="出现此类情形的原因?">出现此类情形的原因?</h2>
+
+<p>由于浏览器禁用第三方内容的选项被开启,因此第三方Cookie使用请求和存储请求被拦截了。</p>
+
+<p>通过以下操作可以修改权限或移除站点:</p>
+
+<ul>
+ <li>跳转到 <em>首选项 &gt; 隐私与安全 &gt; 内容拦截</em></li>
+ <li>点击 <em>管理例外</em> 按钮添加例外</li>
+ <li>选中 <em>自定义</em> 内容拦截并取消 <em>Cookie</em> 前面的勾</li>
+</ul>
+
+<p>如果被拦截的资源不需要进行身份验证,你也可以给相关元素添加 <code>crossorigin="anonymous"</code> 属性来达到消除警告的目的。</p>
+
+<h2 id="相关资料">相关资料</h2>
+
+<ul>
+ <li><a href="https://support.mozilla.org/zh-CN/kb/%E5%86%85%E5%AE%B9%E6%8B%A6%E6%88%AA">内容拦截</a> on <a href="https://support.mozilla.org">support.mozilla.org</a></li>
+ <li><a href="https://developer.mozilla.org/zh-CN/docs/Web/HTML/CORS_settings_attributes"><code>crossorigin</code> 属性</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/firefox/privacy/storage_access_policy/index.html b/files/zh-cn/mozilla/firefox/privacy/storage_access_policy/index.html
new file mode 100644
index 0000000000..801d5bfad1
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/privacy/storage_access_policy/index.html
@@ -0,0 +1,261 @@
+---
+title: 'Storage access policy: Block cookies from trackers'
+slug: Mozilla/Firefox/Privacy/Storage_access_policy
+tags:
+ - NeedsTranslation
+ - Privacy
+ - TopicStub
+ - storage access policy
+ - tracking protection
+translation_of: Mozilla/Firefox/Privacy/Storage_access_policy
+---
+<div>{{FirefoxSidebar}}</div>
+
+<p class="summary">Firefox includes a new storage access policy that blocks cookies and other site data from third-party tracking resources. This policy is designed as an alternative to the <a href="/en-US/docs/Mozilla/Cookies_Preferences">older cookie policies</a>, which have been available in Firefox for many years. This policy protects against cross-site tracking while minimizing the site breakage associated with traditional cookie blocking. This article explains how the policy works and how you can test it.</p>
+
+<h2 id="Testing_in_Firefox">Testing in Firefox</h2>
+
+<p>This cookie policy has been available in Firefox since version 63. This documentation describes the policy that we intend to ship to Firefox Release users, but may not match what is implemented in the current Release version of Firefox. That's because we document new aspects of the policy as soon as they land in <a href="https://www.mozilla.org/en-US/firefox/channel/desktop/#nightly">Firefox Nightly</a>, our pre-release channel. Firefox Nightly may also contain experimental features that we don't yet plan to ship to Release users; experimental features will not be included in this documentation, but may nevertheless impact the functionality of domains classified as trackers.</p>
+
+<p>We recommend sites test with <a href="https://www.mozilla.org/en-US/firefox/channel/desktop/#nightly">Firefox Nightly</a>, as this includes the newest version of our protections. As described above, note that Nightly may include additional protections that end up getting removed or changed before they reach our Release users. We’ll keep this page updated with the newest information as we strengthen our protections.</p>
+
+<p>These protections are on by default in Nightly. The cookie policy can be enabled in other versions of Firefox through the <a href="https://support.mozilla.org/en-US/kb/content-blocking">Content Blocking settings</a> (these steps will vary by version; the linked documentation includes a dropdown to select the appropriate Firefox version).</p>
+
+<h3 id="Report_Broken_Sites">Report Broken Sites</h3>
+
+<p>If you find a website broken as a result of this change, file a bug under the Tracking Protection component within the Firefox product on <a href="https://bugzilla.mozilla.org/enter_bug.cgi?assigned_to=nobody%40mozilla.org&amp;blocked=1480137&amp;bug_file_loc=http%3A%2F%2F&amp;bug_ignored=0&amp;bug_severity=normal&amp;bug_status=NEW&amp;cf_fx_iteration=---&amp;cf_fx_points=---&amp;cf_platform_rel=---&amp;cf_status_firefox62=---&amp;cf_status_firefox63=---&amp;cf_status_firefox64=---&amp;cf_status_firefox_esr60=---&amp;cf_status_geckoview62=---&amp;cf_tracking_firefox62=---&amp;cf_tracking_firefox63=---&amp;cf_tracking_firefox64=---&amp;cf_tracking_firefox_esr60=---&amp;cf_tracking_firefox_relnote=---&amp;cf_tracking_geckoview62=---&amp;component=Tracking%20Protection&amp;contenttypemethod=list&amp;contenttypeselection=text%2Fplain&amp;defined_groups=1&amp;flag_type-203=X&amp;flag_type-37=X&amp;flag_type-41=X&amp;flag_type-5=X&amp;flag_type-607=X&amp;flag_type-721=X&amp;flag_type-737=X&amp;flag_type-748=X&amp;flag_type-787=X&amp;flag_type-799=X&amp;flag_type-800=X&amp;flag_type-803=X&amp;flag_type-835=X&amp;flag_type-846=X&amp;flag_type-855=X&amp;flag_type-864=X&amp;flag_type-914=X&amp;flag_type-916=X&amp;flag_type-929=X&amp;flag_type-930=X&amp;flag_type-933=X&amp;form_name=enter_bug&amp;maketemplate=Remember%20values%20as%20bookmarkable%20template&amp;op_sys=Unspecified&amp;priority=--&amp;product=Firefox&amp;rep_platform=Unspecified&amp;target_milestone=---&amp;version=unspecified">Bugzilla</a>. Alternatively you can report broken sites directly in Firefox by clicking "Report a Problem" in the Content Blocking section of the <a href="https://support.mozilla.org/en-US/kb/control-center-site-privacy-and-security-firefox">Control Center</a> (this shortcut may not be available in all versions of Firefox).</p>
+
+<h2 id="Tracking_protection_explained">Tracking protection explained</h2>
+
+<p>How does Firefox determine which resources are tracking resources?</p>
+
+<p>Firefox uses the Tracking Protection list to determine which resources are tracking resources. The Tracking Protection list is <a href="https://github.com/disconnectme/disconnect-tracking-protection/issues">maintained by Disconnect</a>. When the list is applied in Firefox, we make two important changes:</p>
+
+<ul>
+ <li>First, we only use the "Basic Protection" version of the list, which <a href="https://github.com/mozilla-services/shavar-prod-lists#blacklist">excludes some categories of trackers</a>. In the future, we may expand our protections to use the "Strict Protection" version of the list.</li>
+ <li>Second, Firefox uses an additional "<a href="https://github.com/mozilla-services/shavar-prod-lists/blob/master/disconnect-entitylist.json">entity list</a>", which prevents <a href="https://github.com/mozilla-services/shavar-prod-lists#entity-list">domains from being classified as trackers when they are loaded on a top-level site owned by the same organization</a>.</li>
+</ul>
+
+<p>Firefox uses the built-in <a href="https://support.mozilla.org/en-US/kb/tracking-protection">Tracking Protection</a> URL classifier to determine which resources match the tracking protection list. Domains are matched against the list in accordance with the <a href="https://developers.google.com/safe-browsing/v4/urls-hashing#suffixprefix-expressions">SafeBrowsing v4 specification</a>. Specifically, we check the exact hostname of the resource against the list, as well as the last four hostnames formed by starting with the last five components and successively removing the leading component. Consider the following examples:</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Hostname on the list</th>
+ <th scope="col">Hostname of resource</th>
+ <th scope="col">Matched</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>example.com</code></td>
+ <td><code>example.com</code></td>
+ <td>Yes</td>
+ </tr>
+ <tr>
+ <td><code>example.com</code></td>
+ <td><code>a.b.example.com</code></td>
+ <td>Yes</td>
+ </tr>
+ <tr>
+ <td><code>blah.example.com</code></td>
+ <td><code>example.com</code></td>
+ <td>No</td>
+ </tr>
+ <tr>
+ <td><code>a.b.example.com</code></td>
+ <td><code>c.d.example.com</code></td>
+ <td>No</td>
+ </tr>
+ <tr>
+ <td><code>blah.example.com</code></td>
+ <td><code>foo.blah.example.com</code></td>
+ <td>Yes</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="What_does_the_storage_access_policy_block">What does the storage access policy block?</h2>
+
+<p>The storage access policy blocks resources identified as trackers from accessing their cookies and other site storage when they are loaded in a third-party context. This prevents those resources from retrieving tracking identifiers stored in cookies or site storage and using them to identify users across visits to multiple first parties. Specifically, Firefox does this by imposing the following restrictions:</p>
+
+<p>Cookies:</p>
+
+<ul>
+ <li>Block {{httpheader("Cookie")}} request headers and ignore {{httpheader("Set-Cookie")}} response headers.</li>
+ <li>Return an empty string for calls to {{domxref("Document.cookie")}} and ignore requests to set cookies via <code>Document.cookie</code>.</li>
+</ul>
+
+<p>DOM Storage:</p>
+
+<ul>
+ <li><a href="/en-US/docs/Web/API/Web_Storage_API">localStorage</a>: <code><a href="/en-US/docs/Web/API/Window/localStorage">Window.localStorage</a></code>: read and write attempts throw a <code>SecurityError</code> exception.  Prior to Firefox 70: <code><a href="/en-US/docs/Web/API/Window/localStorage">Window.localStorage</a></code> is <code>null</code>. Thus, attempts to read and write using this object will throw a <code>TypeError</code> exception.</li>
+ <li><a href="/en-US/docs/Web/API/Web_Storage_API">sessionStorage</a>: read and write attempts are permitted.</li>
+ <li><a href="/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a>: read and write attempts throw a <code>SecurityError</code> exception.</li>
+</ul>
+
+<p>Messaging and Workers:</p>
+
+<ul>
+ <li><a href="/en-US/docs/Web/API/Broadcast_Channel_API">Broadcast Channel</a>: attempts to create a new {{domxref("BroadcastChannel")}} will throw a <code>SecurityError</code> exception.</li>
+ <li><a href="/en-US/docs/Web/API/Web_Workers_API">Shared Worker</a>: attempts to create a new {{domxref("SharedWorker")}} will throw a <code>SecurityError</code> exception.</li>
+ <li><a href="/en-US/docs/Web/API/Service_Worker_API">Service Worker</a>: attempts to create a new {{domxref("ServiceWorker")}} will throw a <code>SecurityError</code> exception.</li>
+</ul>
+
+<p>DOM Cache:</p>
+
+<ul>
+ <li>Calls to {{domxref("CacheStorage")}} will always reject with a <code>SecurityError</code>.</li>
+</ul>
+
+<p>Browser caches:</p>
+
+<ul>
+ <li>The <a href="/en-US/docs/Mozilla/HTTP_cache">HTTP cache</a>, the Image cache, and the <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Alt-Svc">Alternative Services (Alt-Svc) cache</a> are all partitioned for tracking resources, such that each top-level origin will have a separate partition and tracking resources on different top-level origins will be cached separate from each other.</li>
+</ul>
+
+<p>Network connections:</p>
+
+<ul>
+ <li><a href="https://wiki.mozilla.org/Security/Server_Side_TLS#Session_Resumption">TLS sessions</a> will not be resumed using a session ticket when an HTTPS connection is made to an embedded third-party resource that is classified as a tracker.</li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Connection_management_in_HTTP_1.x#Persistent_connections">HTTP connection reuse</a> by domains classified as trackers is limited to requests that occur under the same top-level origin. For example, a request for content from tracker.example on news.example will not reuse an HTTP connection with a request for content from tracker.example on shopping.example or with requests that occur when tracker.example is visited directly (i.e., as a first party).</li>
+</ul>
+
+<h3 id="What_is_not_blocked_by_the_policy">What is not blocked by the policy?</h3>
+
+<ol>
+ <li>This policy does not currently restrict third-party storage access for resources that are not classified as tracking resources. We may choose to apply additional restrictions to third-party storage access in the future.</li>
+ <li>The restrictions applied by the policy will not prevent third-party scripts classified as tracking resources from accessing storage in the main context of the page. These scripts can continue to use storage scoped to the top-level origin.</li>
+ <li>Origins classified as trackers will have access to their own storage when they are loaded in a first-party context.</li>
+ <li>Cross-origin resources loaded from the same eTLD+1 as the top-level context will still have access to their storage.</li>
+ <li>Origins normally classified as trackers will <a href="https://github.com/mozilla-services/shavar-prod-lists#entity-list">not be blocked if the top-level page origin is determined to be from the same organization as them</a>.</li>
+</ol>
+
+<h2 id="Storage_access_grants">Storage access grants</h2>
+
+<p>In order to improve web compatibility and permit third-party integrations that require storage access, Firefox will grant storage access scoped to the first party for a particular third-party origin as described in this section. Currently, Firefox includes some web compatibility heuristics that grant storage access to third-party resources classified as trackers when a user interacts with those third parties. We do this when we expect that not granting access would cause the web page to break. We also support an initial implementation of the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Storage_Access_API">Storage Access API</a>, through which embedded {{htmlelement("iframe")}}s can request storage access by calling {{domxref("Document.requestStorageAccess()")}}. Although both of these approaches provide the same level of storage access, we recommend third parties switch to using the Storage Access API in order to guarantee their access to storage.</p>
+
+<h3 id="Automatic_storage_access_upon_interaction">Automatic storage access upon interaction</h3>
+
+<p>In order to improve web compatibility, Firefox currently includes some heuristics to grant storage access automatically to third parties that receive user interaction. These heuristics are intended to allow some third-party integrations that are common on the web to continue to function. They are intended to be temporary and will be removed in a future version of Firefox. They should not be relied upon for current and future web development.</p>
+
+<p>Third-party storage access may be granted to resources that have been classified as tracking resources when a user gesture triggers a pop-up window that has <a href="/en-US/docs/Web/API/Window/opener">opener access</a> to the originating document. When that occurs, there are two possible ways a third-party origin can be granted access:</p>
+
+<ul>
+ <li>The origin of the resource that is initially loaded in the pop-up window is granted storage access on the opener document if that origin has received user interaction as a first party within the past 30 days.</li>
+ <li>After the initial resource is loaded in the pop-up window, the window may go through a series of redirects to other hosts. If a user interacts with the pop-up window following a redirect, the origin of the content loaded in the pop-up window is given storage access on the opener document.</li>
+</ul>
+
+<h3 id="Scope_of_storage_access">Scope of storage access</h3>
+
+<p>When storage access is granted, it is scoped to the origin of the opener document or subdomains of that origin. Access that is granted on the subdomain of an origin does not extend to the top-level origin. As an example, if a resource from <code>tracker.example</code> is granted storage access on <code>foo.example.com</code>, then <code>tracker.example</code> will be able to access its cookies on <code>bar.foo.example.com</code> but not <code>example.com</code>. Instead, if <code>tracker.example</code> were granted access on <code>example.com</code> it would be able to access its storage on <code>bar.foo.example.com</code>, <code>foo.example.com</code>, and <code>example.com</code>.</p>
+
+<p>When storage access is granted to <code>tracker.example</code> on <code>example.com</code>, all resources loaded from <code>tracker.example</code> on any top-level document loaded from <code>example.com</code> are immediately given storage access. This includes all resources loaded in the main context of the page, embedded <code>&lt;iframe&gt;</code>s, and resources loaded within embedded <code>&lt;iframe&gt;</code>s. Storage access is not extended to other resources loaded on <code>example.com</code> (e.g. <code>other-tracker.example</code>), nor to other first parties on which <code>tracker.example</code> is embedded (e.g. <code>example.org</code>).</p>
+
+<p>Storage access grants extend into the first level of nested contexts, but no further. This means that <code>&lt;iframe&gt;</code>s embedded in the main context of the page and loaded from a domain classified as a tracker will have full access to all storage locations accessible through JavaScript. Similarly, requests for resources loaded in <code>&lt;iframe&gt;</code>s embedded in the main context of the page will have access to HTTP cookies. However, further nested contexts, including but not limited to those from the origin classified as a tracker, will not be granted storage access.</p>
+
+<p>Consider the following embedding scenarios on a top-level page loaded from <code>example.com</code> on which <code>tracker.example</code> has been granted storage access.</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Embedding</th>
+ <th scope="col">tracker.example resource storage access</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>An image is loaded from <code>tracker.example</code> and embedded in the main context of <code>example.com</code>.</td>
+ <td>HTTP: Yes<br>
+ JS: N/A</td>
+ </tr>
+ <tr>
+ <td><code>example.com</code> embeds an <code>&lt;iframe&gt;</code> from <code>example.org</code>. That <code>&lt;iframe&gt;</code> goes on to load an image from <code>tracker.example</code>.</td>
+ <td>HTTP: Yes<br>
+ JS: N/A</td>
+ </tr>
+ <tr>
+ <td><code>example.com</code> embeds an <code>&lt;iframe&gt;</code> from <code>example.org</code>. That <code>&lt;iframe&gt;</code> goes on to embed an <code>&lt;iframe&gt;</code> from <code>tracker.example</code>.</td>
+ <td>HTTP: Yes<br>
+ JS: No</td>
+ </tr>
+ <tr>
+ <td><code>example.com</code> embeds an <code>&lt;iframe&gt;</code> from <code>tracker.example</code>.</td>
+ <td>HTTP: Yes<br>
+ JS: Yes</td>
+ </tr>
+ <tr>
+ <td><code>example.com</code> embeds an <code>&lt;iframe&gt;</code> from <code>example.com</code> (same origin). The nested <code>&lt;iframe&gt;</code> embeds an <code>&lt;iframe&gt;</code> from <code>tracker.example</code>.</td>
+ <td>HTTP: Yes<br>
+ JS: No</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Storage_access_expiration">Storage access expiration</h3>
+
+<p>The storage access grant expires after 30 days. Domains classified as tracking resources may be granted third-party storage access on multiple first parties, and the storage permission for each party expires independently. The above heuristics will also serve to extend the lifetime of a third-party storage permission on origins that have already been granted access.  Each time the heuristic is activated, or a success call to the Storage Access API is made, the pre-existing storage access expiration will be extended by 30 days, counting from the time the previous access was granted.</p>
+
+<p>Please note that in the future we expect to make changes to how long storage access will remain valid for.  As mentioned before, the way to know that you will be able to use storage as a third-party going forward will be using the Storage Access API.</p>
+
+<h2 id="Debugging">Debugging</h2>
+
+<p>We encourage site owners to test their sites, particularly those that rely on third-party content integrations. We’ve added several new features to Firefox to make testing easier.</p>
+
+<h3 id="Developer_Tools_notifications">Developer Tools notifications</h3>
+
+<p>The <a href="/en-US/docs/Tools/Network_Monitor">Network Monitor</a> in Firefox Developer Tools now includes an indicator for all resource requests that have been classified as tracking resources. This indicator is shown as a shield icon in the domain column. In the sample image below, <code>trackertest.org</code> is classified as a tracking resource, while the request to example.com is not.</p>
+
+<p><img alt="network requests in Firefox devtools indicating which ones are tracking resources with a small shield icon" src="https://mdn.mozillademos.org/files/16181/Screen_Shot_2018-09-21_at_10.34.22_AM.png" style="border-style: solid; border-width: 1px; display: block; height: 57px; margin: 0px auto; width: 600px;"></p>
+
+<h3 id="Adding_custom_domains_to_the_Tracking_Protection_list">Adding custom domains to the Tracking Protection list</h3>
+
+<p>Curious how things will work if a third-party domain on your site were classified as a tracker? We’ve added a preference that allows you to add custom domains to the Tracking Protection URL classifier. To do so:</p>
+
+<ol>
+ <li>Type <code>about:config</code> in your address bar. If you are presented with a page that warns you "This may void your warranty!", click "I accept the risk!"</li>
+ <li>Right click on the next page and click "New" &gt; "String".</li>
+ <li>For the preference name enter "urlclassifier.trackingAnnotationTable.testEntries".</li>
+ <li>For the preference value enter comma separated origins that you’d like to have classified as trackers. E.g. "example.net,example.org".</li>
+</ol>
+
+<div class="warning">
+<p><strong>Warning</strong>: Be sure to remove these entries after you have finished testing.</p>
+</div>
+
+<h2 id="FAQ">FAQ</h2>
+
+<p>This cookie policy has the potential to lead to site breakage, but has been designed to allow common third-party integrations to continue to work while preventing cross-site tracking. In this section we describe the functionality you can expect in different integration scenarios.</p>
+
+<h3 id="Will_this_storage_access_policy_block_ads_from_displaying_on_my_website">Will this storage access policy block ads from displaying on my website?</h3>
+
+<p>No — this feature only restricts access to cookies and site data that can be used to track users across websites. Blocking tracking identifiers does not prevent the display of advertisements.</p>
+
+<h3 id="I_use_a_third-party_analytics_service_that_is_classified_as_a_tracker._Will_I_still_receive_analytics_data">I use a third-party analytics service that is classified as a tracker. Will I still receive analytics data?</h3>
+
+<p>This depends on how the third-party analytics service is implemented. Third-party analytics providers will no longer be able to user their third-party storage to collect data. This means that providers using cookies which are scoped to their third-party domain, or local storage and other site data stored under their origin, will no longer have access to those identifiers across other websites.</p>
+
+<p>If these services are embedded into the main context of the page, they can continue to use first-party cookies and site storage to track users across page visits on that specific first-party domain.</p>
+
+<h3 id="I_use_third-party_services_for_social_login_like_and_share_button_integration._Will_my_users_still_be_able_to_make_use_of_these_services">I use third-party services for social login, like, and share button integration. Will my users still be able to make use of these services?</h3>
+
+<p>This depends on how the social integration is implemented. We expect that many of the popular social integrations will continue to function as they do under Firefox’s current cookie policy with some minor differences in the user experience.</p>
+
+<p>A social content provider that is classified as a tracker will not have access to their third-party cookies when the user first visits a new first party. Thus, the user may appear logged out to the service despite being logged in when they visit the provider’s website directly. Depending on the type of integration, the user may have to take some action to interact with the social content provider before the provider is given access to their cookies. For example:</p>
+
+<ul>
+ <li>For social login, the user may have to click a login button on the first party.</li>
+ <li>For social like or share buttons, the user will have to first interact with the button in a logged-out state. Once they do, many social content providers will prompt them to log in.</li>
+</ul>
+
+<p>After these interactions, the provider will receive third-party storage access if they prompt the user in a way that is captured by the storage access activation heuristics described above. These providers should consider switching to explicitly request storage access through the Storage Access API as soon as possible. An <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1469714">initial implementation of this API</a> is currently available in Nightly.</p>
+
+<h3 id="I_use_third-party_pixels_and_other_tools_to_measure_the_effectiveness_of_my_ad_campaigns._Will_I_still_be_able_to_measure_the_conversion_rate_of_my_ads">I use third-party pixels and other tools to measure the effectiveness of my ad campaigns. Will I still be able to measure the conversion rate of my ads?</h3>
+
+<p>This depends on how the third party has implemented the measurement tool, but generally ad conversion measurement will be more difficult. Consider the following examples:</p>
+
+<ol>
+ <li>You run an ad on a social media website that is seen several times by a user, but never clicked. That user later visits your website, which includes a conversion tracking tag from the same social media website. This type of conversion is often referred to as a “view-through conversion.” Since the social media website does not have access to their third-party storage, they will not recognize the user as the same user that saw the advertisements on their website and the conversion will not be tracked. We expect that most view-through conversion tracking techniques will no longer work, including those offered by display networks.</li>
+ <li>You run an ad on a display network or social media website that is clicked by a user. That user lands on your website, which includes a conversion tracking tag from the same website that displayed your ad. This type of conversion is often referred to as a “click-through conversion.” Since the social media site or display network will not have access to their third-party storage, they will not recognize the user as the same user that saw the advertisements on their website and the conversion will not be tracked. We expect that this version of click-through conversion will no longer work.</li>
+ <li>You run an ad that appears on a social media website. A user clicks on your advertisement and is taken to a landing page that contains a conversion tracking tag from the third-party network. On the social media website, the network annotates the advertisement landing page URL with a query parameter that signals that the visit was the result of a click on an advertisement. On your website, the display network’s tag checks the URL query parameters and saves any ad tracking parameters to first-party storage. If a user later completes a conversion event, the network’s tag checks first-party storage to determine which click (or clicks) was responsible for the visit. We expect that click-through conversion implemented in this way will continue to work.</li>
+</ol>
diff --git a/files/zh-cn/mozilla/firefox/privacy/tracking_protection/index.html b/files/zh-cn/mozilla/firefox/privacy/tracking_protection/index.html
new file mode 100644
index 0000000000..66620f47d9
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/privacy/tracking_protection/index.html
@@ -0,0 +1,87 @@
+---
+title: Tracking Protection
+slug: Mozilla/Firefox/Privacy/Tracking_Protection
+tags:
+ - 隐私
+translation_of: Mozilla/Firefox/Privacy/Tracking_Protection
+---
+<div>{{FirefoxSidebar}}</div>
+
+<h2 id="什么是跟踪保护">什么是跟踪保护?</h2>
+
+<p>Firefox 浏览器桌面版和 Android 移动版内置跟踪保护。在隐私窗口或标签页(Android移动版)内,Firefox会阻止跨网站的内容加载。</p>
+
+<p>如果拦截的内容是网页的一部分,用户可能会注意到网页排版出现问题。如果页面上的其它元素把拦截内容的空位给填补上时,用户完全不会注意到 Firefox 浏览器阻止了一些内容加载。</p>
+
+<p>当 Firefox 浏览器拦截到内容时,在控制台会有类似这样一条日志消息:</p>
+
+<pre class="notranslate">位于“http://some/url”的资源<span class="message-body-wrapper"><span class="message-flex-body"><span class="devtools-monospace message-body"><span class="objectBox objectBox-string">已被内容拦截功能拦截。</span></span></span></span></pre>
+
+<p>Firefox 浏览器 Android 移动版需要使用远程调试来看到控制台的输出内容。</p>
+
+<p><img alt="Page information showing possible blocked content." src="https://mdn.mozillademos.org/files/16583/blocked_content.png" style="border-style: solid; border-width: 1px; display: block; height: 384px; margin: 0px auto; width: 416px;"></p>
+
+<p>点下地址栏左侧这个标志ⓘ 可以查看当前页面的信息。按下第一行的按钮可以关闭对当前网站的跟踪保护。</p>
+
+<p>如果存在跟踪Cookie,您可以通过单击上图中的“阻止跟踪Cookie”查看以下弹出窗口来查看列表:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/16584/tracking_cookies.png" style="border-style: solid; border-width: 1px; display: block; height: 384px; margin: 0px auto; width: 416px;"></p>
+
+<p>您可以单击“管理内容阻止”来更改阻止设置:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/16585/content_blocking.png" style="border-style: solid; border-width: 1px; display: block; margin: 0px auto;"></p>
+
+<h2 id="Firefox如何选择要阻止的内容?_基于要从中加载内容的域阻止内容。_Firefox将提供一个站点列表,这些站点已经被确定为参与用户的跨站点跟踪。启用跟踪保护后,Firefox将阻止来自列表中站点的内容。_跟踪用户的网站通常是第三方广告和分析网站。">Firefox如何选择要阻止的内容?<br>
+ 基于要从中加载内容的域阻止内容。<br>
+ Firefox将提供一个站点列表,这些站点已经被确定为参与用户的跨站点跟踪。启用跟踪保护后,Firefox将阻止来自列表中站点的内容。<br>
+ 跟踪用户的网站通常是第三方广告和分析网站。</h2>
+
+<h2 id="这对你的网站意味着什么?_最明显的是,这意味着当启用跟踪保护时:_从第三方跟踪服务的内容将对用户不可见_您的网站将无法使用第三方广告或参与跟踪的分析服务_更微妙的是,如果站点的其他部分依赖于正在加载的跟踪器,那么当启用跟踪保护时,这些部分也将被破坏。例如,如果站点包含在加载跟踪站点的内容时运行的回调,则不会执行该回调。_例如,您不应以以下方式使用Google_Analytics:">这对你的网站意味着什么?<br>
+ 最明显的是,这意味着当启用跟踪保护时:<br>
+ 从第三方跟踪服务的内容将对用户不可见<br>
+ 您的网站将无法使用第三方广告或参与跟踪的分析服务<br>
+ 更微妙的是,如果站点的其他部分依赖于正在加载的跟踪器,那么当启用跟踪保护时,这些部分也将被破坏。例如,如果站点包含在加载跟踪站点的内容时运行的回调,则不会执行该回调。<br>
+ 例如,您不应以以下方式使用Google Analytics:</h2>
+
+<pre class="brush:html example-bad notranslate">&lt;a href="http://www.example.com" onclick="trackLink('http://www.example.com', event);"&gt;
+ Visit example.com
+&lt;/a&gt;
+
+&lt;script&gt;
+function trackLink(url,event) {
+ event.preventDefault();
+ ga('send', 'event', 'outbound', 'click', url, {
+     'transport': 'beacon',
+     'hitCallback': function() {
+ document.location = url;
+ }
+   });
+}
+&lt;/script&gt;</pre>
+
+<p>相反,您应该通过检查ga对象是否已初始化来解释Google Analytics丢失的情况:</p>
+
+<pre class="brush:html example-good notranslate">&lt;a href="http://www.example.com" onclick="trackLink('http://www.example.com', event);"&gt;
+ Visit example.com
+&lt;/a&gt;
+
+&lt;script&gt;
+function trackLink(url,event) {
+ event.preventDefault();
+ if (window.ga &amp;&amp; <span class="pl-smi">ga</span>.loaded) {
+ ga('send', 'event', 'outbound', 'click', url, {
+     'transport': 'beacon',
+      'hitCallback': function() { document.location = url; }
+    });
+ } else {
+ document.location = url;
+ }
+}
+&lt;/script&gt;
+</pre>
+
+<p>关于这项技术的更多信息可以在Google分析、隐私和事件跟踪上找到。</p>
+
+<div class="blockIndicator note">
+<p>注意:以这种方式依赖第三方并不是一个好的做法,因为如果第三方速度慢或不可用,或者跟踪器已被加载项阻止,则站点可能会被破坏。</p>
+</div>
diff --git a/files/zh-cn/mozilla/firefox/releases/1.5/index.html b/files/zh-cn/mozilla/firefox/releases/1.5/index.html
new file mode 100644
index 0000000000..a028828a01
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/1.5/index.html
@@ -0,0 +1,123 @@
+---
+title: Firefox 1.5 for developers
+slug: Mozilla/Firefox/Releases/1.5
+tags:
+ - Add-ons
+ - CSS
+ - DOM
+ - Extensions
+ - HTML
+ - JavaScript
+ - NeedsTranslation
+ - RDF
+ - SVG
+ - TopicStub
+ - Web Development
+ - Web Standards
+ - XML
+ - XML Web Services
+ - XSLT
+ - XUL
+translation_of: Mozilla/Firefox/Releases/1.5
+---
+<div>{{FirefoxSidebar}}</div><p>Based on the <a href="/en-US/docs/Gecko" title="en-US/docs/Gecko">Gecko</a> 1.8 engine, Firefox 1.5 improved its already best in class standards support, and provided new capabilities to enable the next generation of web applications. Firefox 1.5 features improved support for CSS2 and CSS3, APIs for scriptable and programmable 2D graphics through <a href="/en-US/docs/SVG" title="en-US/docs/SVG">SVG</a> 1.1 and <a class="internal" href="/en-US/docs/HTML/Canvas" title="en-US/docs/HTML/Canvas"><code>&lt;canvas&gt;</code></a>, <a href="/en-US/docs/XForms" title="en-US/docs/XForms">XForms</a> and XML events, as well as many DHTML, JavaScript, and DOM enhancements.</p>
+
+<h2 id="Developer_Tools">Developer Tools</h2>
+
+<p>Several tools and browser extensions are available to help developers support Firefox 1.5.</p>
+
+<ul>
+ <li><a href="/en-US/docs/DOM_Inspector" title="en-US/docs/DOM_Inspector">DOM Inspector</a>, a tool that allows developers to inspect and modify documents without having to edit the document directly. DOM Inspector is available as part of the Custom install option in Firefox 1.5 under Developer Tools.</li>
+ <li>JavaScript console, a tool to write and test JavaScript code as well as view JavaScript and CSS errors on a page.</li>
+ <li>View page source, with syntax highlighting and find features.</li>
+ <li><a class="link-https" href="https://addons.mozilla.org/extensions/showlist.php?application=firefox&amp;category=Developer%20Tools">Browser extensions</a> including the <a class="external" href="http://www.joehewitt.com/software/firebug/">FireBug</a>, <a href="/en-US/docs/Web_Developer_Extension_(external)" title="en-US/docs/Web_Developer_Extension_(external)">Web Developer toolbar</a>, <a href="/en-US/docs/Live_HTTP_Headers_(external)" title="en-US/docs/Live_HTTP_Headers_(external)">Live HTTP Headers</a>, <a href="/en-US/docs/HTML_Validator_(external)" title="en-US/docs/HTML_Validator_(external)">HTML Validator</a> and many more.</li>
+</ul>
+
+<p><strong>Note:</strong> Some extensions do not currently support Firefox 1.5, and will be automatically disabled.</p>
+
+<h2 id="Overview">Overview</h2>
+
+<p>Some of the new features in Firefox 1.5:</p>
+
+<h3 id="Web_site_and_application_developers">Web site and application developers</h3>
+
+<dl>
+ <dt><a href="/en-US/docs/SVG_In_HTML_Introduction" title="en-US/docs/SVG_In_HTML_Introduction">SVG In XHTML Introduction</a></dt>
+ <dd>Learn how to use SVG in XHTML pages and how to use JavaScript and CSS to manipulate the picture in the same way you would script regular XHTML. See also <a href="/en-US/docs/SVG_in_Firefox" title="en-US/docs/SVG_in_Firefox">SVG in Firefox</a> to learn about the status and known problems of SVG implementation in Firefox.</dd>
+ <dt><a href="/en-US/docs/HTML/Canvas/Drawing_Graphics_with_Canvas" title="en-US/docs/Drawing_Graphics_with_Canvas">Drawing Graphics with Canvas</a></dt>
+ <dd>Learn about the new <code>&lt;canvas&gt;</code> tag and how to draw graphs and other objects in Firefox.</dd>
+ <dt><a href="/en-US/docs/CSS/Using_CSS_multi-column_layouts" title="en-US/docs/CSS3_Columns">CSS3 Columns</a></dt>
+ <dd>Learn about the new support for automatic multi-column text layout as proposed for <a href="/en-US/docs/CSS/CSS3" title="CSS3">CSS3</a>.</dd>
+ <dt><a href="/en-US/docs/Using_Firefox_1.5_caching" title="en-US/docs/Using_Firefox_1.5_caching">Using Firefox 1.5 caching</a></dt>
+ <dd>Learn about <code>bfcache</code> and how it speeds up back and forward navigation.</dd>
+</dl>
+
+<h3 id="XUL_and_Extension_Developers">XUL and Extension Developers</h3>
+
+<dl>
+ <dt><a href="/en-US/docs/Building_an_Extension" title="en-US/docs/Building_an_Extension">Building an Extension</a></dt>
+ <dd>This tutorial will take you through the steps required to build a very basic extension for Firefox. Also see <a class="external" href="http://kb.mozillazine.org/Getting_started_with_extension_development">another tutorial on MozillaZine knowledge base</a>, which demonstrates the new features of the Extension Manager in 1.5 that make creating a new extension even easier.</dd>
+ <dt><a href="/en-US/docs/XPCNativeWrapper" title="en-US/docs/XPCNativeWrapper">XPCNativeWrapper</a></dt>
+ <dd><code>XPCNativeWrapper</code> is a way to wrap up an object so that it's <a href="/en-US/docs/Safely_accessing_content_DOM_from_chrome" title="en-US/docs/Safely_accessing_content_DOM_from_chrome">safe to access from privileged code</a>. It can be used in all Firefox versions, though the behavior changed somewhat starting with Firefox 1.5 (Gecko 1.8).</dd>
+ <dt><a href="/en-US/docs/Preferences_System" title="en-US/docs/Preferences_System">Preferences System</a></dt>
+ <dd>Learn about the new widgets that allow you to create Options windows easier using less JavaScript code.</dd>
+ <dt><a href="/en-US/docs/International_characters_in_XUL_JavaScript" title="en-US/docs/International_characters_in_XUL_JavaScript">International characters in XUL JavaScript</a></dt>
+ <dd>XUL JavaScript files can now contain non-ASCII characters.</dd>
+ <dt><a href="/en-US/docs/Tree_Widget_Changes" title="en-US/docs/Tree_Widget_Changes">Tree API changes</a></dt>
+ <dd>The interfaces for accessing XUL <code>&lt;tree&gt;</code> elements have changed.</dd>
+ <dt><a href="/en-US/docs/XUL_Changes_for_Firefox_1.5" title="en-US/docs/XUL_Changes_for_Firefox_1.5">XUL Changes for Firefox 1.5</a></dt>
+ <dd>Summary of XUL changes. See also <a href="/en-US/docs/Adapting_XUL_Applications_for_Firefox_1.5" title="en-US/docs/Adapting_XUL_Applications_for_Firefox_1.5">Adapting XUL Applications for Firefox 1.5</a>.</dd>
+</dl>
+
+<h4 id="Networking-related_changes">Networking-related changes</h4>
+
+<ul>
+ <li>Certificate prompts can now be overridden on a per-channel basis. This works by setting an interface requestor as an <a href="/en-US/docs/nsIChannel" title="en-US/docs/nsIChannel">nsIChannel</a>'s notificationCallbacks and giving out an interface for <a href="/en-US/docs/NsIBadCertListener" title="en-US/docs/NsIBadCertListener">nsIBadCertListener</a>.</li>
+ <li>nsIWebBrowserPersist's listeners can now implement <a href="/en-US/docs/XPCOM_Interface_Reference/nsIInterfaceRequestor" title="en-US/docs/nsIInterfaceRequestor">nsIInterfaceRequestor</a>::GetInterface and will get an opportunity to provide all interfaces that channels might ask for, including <a href="/en-US/docs/NsIProgressEventSink" title="en-US/docs/NsIProgressEventSink">nsIProgressEventSink</a> (not too useful, redundant with <a href="/en-US/docs/nsIWebProgressListener" title="en-US/docs/nsIWebProgressListener">nsIWebProgressListener</a>). Useful interfaces here include <a href="/en-US/docs/NsIChannelEventSink" title="en-US/docs/NsIChannelEventSink">nsIChannelEventSink</a> and <a href="/en-US/docs/NsIBadCertListener" title="en-US/docs/NsIBadCertListener">nsIBadCertListener</a>.</li>
+ <li>Extensions or other necko consumers, including XMLHttpRequest, can set a Cookie header explicitly, and necko will not replace it. Stored cookies will be merged with the explicitly set header, in a way that the explicit header will override the stored cookies.</li>
+</ul>
+
+<h2 id="New_End_user_Features">New End user Features</h2>
+
+<h3 id="User_Experience">User Experience</h3>
+
+<ul>
+ <li><strong>Faster browser navigation</strong> with improvements to back and forward button performance.</li>
+ <li><strong>Drag and drop reordering for browser tabs.</strong></li>
+ <li><strong>Answers.com is added to the search engine list</strong> for dictionary lookup.</li>
+ <li><strong>Improvements to product usability</strong> including descriptive error pages, redesigned options menu, RSS discovery, and "Safe Mode" experience.</li>
+ <li><strong>Better accessibility support</strong> including DHTML accessibility.</li>
+ <li><strong>Report a broken Web site wizard</strong> to report Web sites that are not working in Firefox.</li>
+ <li><strong>Better support for Mac OS X</strong> (10.2 and greater) including profile migration from Safari and Mac Internet Explorer.</li>
+</ul>
+
+<h3 id="Security_and_Privacy">Security and Privacy</h3>
+
+<ul>
+ <li><strong>Automated update</strong> to streamline product upgrades. Notification of an update is more prominent, and updates to Firefox may now be half a megabyte or smaller. Updating extensions has also improved.</li>
+ <li><strong>Improvements to popup blocking.</strong></li>
+ <li><strong>Clear Private Data</strong> feature provides an easy way to quickly remove personal data through a menu item or keyboard shortcut.</li>
+</ul>
+
+<h3 id="Support_for_open_Web_standards">Support for open Web standards</h3>
+
+<p>Firefox support for Web standards continues to lead the industry with consistent cross-platform implementations for:</p>
+
+<ul>
+ <li>Hypertext Markup Language (<a href="/en-US/docs/HTML" title="en-US/docs/HTML">HTML</a>) and Extensible Hypertext Markup Language (<a href="/en-US/docs/XHTML" title="en-US/docs/XHTML">XHTML</a>): <a class="external" href="http://www.w3.org/TR/html401/">HTML 4.01</a> and <a class="external" href="http://www.w3.org/TR/xhtml1/">XHTML 1.0/1.1</a></li>
+ <li>Cascading Style Sheets (<a href="/en-US/docs/CSS" title="en-US/docs/CSS">CSS</a>): <a class="external" href="http://www.w3.org/TR/REC-CSS1">CSS Level 1</a>, <a class="external" href="http://www.w3.org/TR/REC-CSS2">CSS Level 2</a> and parts of <a class="external" href="http://www.w3.org/Style/CSS/current-work.html">CSS Level 3</a></li>
+ <li>Document Object Model (<a href="/en-US/docs/DOM" title="en-US/docs/DOM">DOM</a>): <a class="external" href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/">DOM Level 1</a>, <a class="external" href="http://www.w3.org/DOM/DOMTR#dom2">DOM Level 2</a> and parts of <a class="external" href="http://www.w3.org/DOM/DOMTR#dom3">DOM Level 3</a></li>
+ <li>Mathematical Markup Language: <a class="external" href="http://www.w3.org/Math/">MathML Version 2.0</a></li>
+ <li>Extensible Markup Language (<a href="/en-US/docs/XML" title="en-US/docs/XML">XML</a>): <a class="external" href="http://www.w3.org/TR/REC-xml">XML 1.0</a>, <a class="external" href="http://www.w3.org/TR/REC-xml-names/">Namespaces in XML</a>, <a class="external" href="http://www.w3.org/TR/xml-stylesheet/">Associating Style Sheets with XML Documents 1.0</a>, <a class="external" href="http://lists.w3.org/Archives/Public/www-xml-linking-comments/2001AprJun/att-0074/01-NOTE-FIXptr-20010425.htm">Fragment Identifier for XML</a></li>
+ <li>XSL Transformations (<a href="/en-US/docs/XSLT" title="en-US/docs/XSLT">XSLT</a>): <a class="external" href="http://www.w3.org/TR/xslt">XSLT 1.0</a></li>
+ <li>XML Path Language (<a href="/en-US/docs/XPath" title="en-US/docs/XPath">XPath</a>): <a class="external" href="http://www.w3.org/TR/xpath">XPath 1.0</a></li>
+ <li>Resource Description Framework (<a href="/en-US/docs/RDF" title="en-US/docs/RDF">RDF</a>): <a class="external" href="http://www.w3.org/RDF/">RDF</a></li>
+ <li>Simple Object Access Protocol (SOAP): <a class="external" href="http://www.w3.org/TR/SOAP/">SOAP 1.1</a></li>
+ <li><a href="/en-US/docs/JavaScript" title="en-US/docs/JavaScript">JavaScript</a> 1.6, based on <a href="/en-US/docs/ECMAScript" title="en-US/docs/ECMAScript">ECMA-262</a>, revision 3: <a class="external" href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMA-262</a></li>
+</ul>
+
+<p>Firefox 1.5 supports the following data transport protocols (HTTP, FTP, SSL, TLS, and others), multilingual character data (Unicode), graphics (GIF, JPEG, PNG, SVG, and others) and the latest version of the world's most popular scripting language, <a href="/en-US/docs/New_in_JavaScript_1.6" title="en-US/docs/New_in_JavaScript_1.6">JavaScript 1.6</a>.</p>
+
+<h2 id="Changes_since_Firefox_1.0">Changes since Firefox 1.0</h2>
+
+<p>Many changes have been introduced into Firefox since it was first released on November 9, 2004. Firefox has progressed with many new features and bug fixes. A detailed list of changes is available from <a class="external" href="http://www.squarefree.com/burningedge/releases/1.5-comprehensive.html">squarefree.com</a>.</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/1.5/using_firefox_1.5_caching/index.html b/files/zh-cn/mozilla/firefox/releases/1.5/using_firefox_1.5_caching/index.html
new file mode 100644
index 0000000000..b062c43ddd
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/1.5/using_firefox_1.5_caching/index.html
@@ -0,0 +1,184 @@
+---
+title: Using Firefox 1.5 caching
+slug: Mozilla/Firefox/Releases/1.5/Using_Firefox_1.5_caching
+translation_of: Mozilla/Firefox/Releases/1.5/Using_Firefox_1.5_caching
+---
+<div>{{FirefoxSidebar}}</div><h2 id="Introduction" name="Introduction">介绍</h2>
+
+<p><a href="/en-US/docs/Firefox_1.5_for_developers" title="Firefox_1.5_for_developers">Firefox 1.5</a> 对整个web页面的一个浏览器会话进行了内存缓存,包括他们对JavaScript状态。在访问过的页面间后退和前进不需要页面加载同时保存JavaScript状态。这个特性,被称为bfcache(“后退前进缓存”),使得页面导航(切换)非常快。这个状态缓存被保存直到用户关闭浏览器。 </p>
+
+<p>有时候,Firefox不缓存页面。下面是一些页面不被缓存的常见的编程的原因:</p>
+
+<ul>
+ <li>页面使用 <code>unload</code> 或者 <code>beforeunload</code> 处理程序;</li>
+ <li>页面设置 "cache-control: no-store".</li>
+ <li>页面是 HTTPS 同时页面至少有一个以下设置:
+ <ul>
+ <li>"Cache-Control: no-cache"</li>
+ <li>"Pragma: no-cache"</li>
+ <li>使用 "Expires: 0" 或者 "Expires" 设置相对于 “Date” header值的过去日期值(除非指定 "Cache-Control: max-age=");</li>
+ </ul>
+ </li>
+ <li>当用户导航跳离页面时页面还没有完全加载或者因为其他原因有等待(pending)的网络请求 (例如 <code>XMLHttpRequest</code>));</li>
+ <li>页面运行IndexedDB事件;</li>
+ <li>顶级页面包含frames (例如 {{HTMLElement("iframe")}})因为这里列出的任何原因 而没有被缓存;</li>
+ <li>页面是在frame内而且用户在这个框架中加载一个新页面(在这种情况下, 当用户离开这个页面,最后加载入frames的内容会被缓存)。</li>
+</ul>
+
+<p>这个新的缓存特性改变了页面的加载行为,web作者也许希望: </p>
+
+<ul>
+ <li>知晓被导航到的页面(当它从用户缓存中被加载)</li>
+ <li>在用户离开页面时定义页面行为  (同时还支持页面缓存)</li>
+</ul>
+
+<p>两个新的浏览器事件使得用户可以做到这2个要求。</p>
+
+<h2 id="New_browser_events" name="New_browser_events">新的浏览器事件</h2>
+
+<p>如果你使用新的事件,你的页面在其他浏览器依然会正确显示  (我们已经测试了早期版本的Firefox, Internet Explorer, Opera, 和 Safari),而且在 Firefox 1.5加载时将会使用新的缓存功能。</p>
+
+<p>注意: 直至10-2009 开发版本的Safari 添加了这些新的事件的支持 (见 <a class="link-https" href="https://bugs.webkit.org/show_bug.cgi?id=28758" title="https://bugs.webkit.org/show_bug.cgi?id=28758">the webkit bug</a>).</p>
+
+<p>标准的页面行为是:</p>
+
+<ol>
+ <li>用户导航至一个页面</li>
+ <li>当页面加载,行内scripts执行。</li>
+ <li>一旦页面加载完毕, <code>onload</code> 事件执行。</li>
+</ol>
+
+<p>有些页面包含第四步。如果一个页面使用 <code>unload</code> 或者 <code>beforeunload</code> 处理程序,当从页面导航离开时事件被执行。如果提供了一个<code>unload</code> 处理程序,页面将不会被缓存。</p>
+
+<p>当一个用户导航至一个被缓存的页面,行内scripts和<code>onload</code> 处理程序将不会执行 (步骤 2 和 3), 因为在大多数情况下,这些scripts的影响(执行效果)已经被保存。</p>
+
+<p>如果你想在每次用户导航到页面时都执行页面包含的scripts或者其他在页面加载期间执行的行为,或者你想知道什么时候用户导航至一个被缓存的页面,使用新的<code>pageshow</code> 事件.</p>
+
+<p>如果你拥有当用户导航离页面是执行的行为,但是你想利用这个新的缓存功能,因此不想使用unload处理程序,使用新的 <code>pagehide</code> 事件</p>
+
+<h3 id="pageshow_event" name="pageshow_event">pageshow 事件</h3>
+
+<p>这个事件和 <code>load</code> 事件一样的工作(效果), 除了它每次页面加载是都执行 that it fires every time the page is loaded (然而  <code>load</code> 事件在 Firefox 1.5中当页面从缓存中加载时不执行). 页面第一次加载时, <code>pageshow</code> 事件在 <code>load</code> 事件执行后执行。 <code>pageshow</code> 事件使用一个命名为<code>persisted</code> 的boolean属性,在初始加载时默认设置为 <code>false</code>。如果它不是初始加载,被设置为<code>true</code>(换句话说,但页面被缓存时它被设置为true).</p>
+
+<p>在 <code>pageshow</code> 事件执行时,设置每次页面加载时你想要运行的任何的JavaScript。</p>
+
+<p>如果你将JavaScript函数作为pageshow事件的一部分调用,你可以通过调用<code>pageshow</code> 事件作为<code>load</code>事件的一部分确保在不同于Firefox 1.5的浏览器在页面加载时调用这些函数,如在本文后面所示的示例。</p>
+
+<h3 id="pagehide_event" name="pagehide_event">pagehide 事件</h3>
+
+<p>如果你想定义当用户导航离页面时的行为,但是你不想使用 <code>unload</code>  (这将导致页面不被缓存),你可以使用新的  <code>pagehide</code> 事件。像 <code>pageshow</code> , <code>pagehide</code> 事件使用一个命名为<code>persisted</code> 的属性。 这个属性在页面未被浏览器缓存时设置为 <code>false</code>  ,如果页面被浏览器缓存则设置为 <code>true</code> 。如果这个属性被设置为 <code>false</code>, 如果有设置<code>unload</code> 处理程序的话,<code>unload</code> 事件在<code>pagehide</code> 事件执行后马上执行。</p>
+
+<p>当页面初次加载,Firefox 1.5 试图按事件会发生相同的顺序模拟load事件。Frames 被作为顶级文档一样对待。如果页面包含frames, 则当缓存当页面被加载:</p>
+
+<ul>
+ <li>每个frame的<code>pageshow</code> 事件在主文档的 <code>pageshow</code> 事件之前执行。</li>
+ <li>当用户导航离被缓存的页面, 每个frame的<code>pagehide</code> 事件在主文档的 <code>pagehide</code> 事件之前执行。</li>
+ <li>发生在一个 frame 的导航, 只有在受影响的frame触发事件。</li>
+</ul>
+
+<h2 id="示例代码">示例代码</h2>
+
+<p>以下的示例演示了一个页面同时使用 <code>load</code> 和 <code>pageshow</code> 事件。这个示例页面行为如下:</p>
+
+<ul>
+ <li>在除了Firefox 1.5的浏览器,以下在每次页面加载都发生:<code>load</code> 事件触发<code>onLoad</code> 函数,该函数调用 <code>onPageShow</code> 函数 (如同一个附加功能).</li>
+ <li>在Firefox 1.5,页面第一次加载时  <code>load</code> 事件和其他浏览器上运行一样。 除了, <code>pageshow</code> 事件的执行和 <code>persisted</code> 设置为 <code>false</code>,没有额外的行动发生。</li>
+ <li>在 Firefox 1.5, 当页面从缓存中被加载,只有 <code>pageshow</code> 事件执行。随着 <code>persisted</code> 被设置为 <code>true</code>,只有 <code>onPageShow</code> 方法中的JavaScript行为被触发。</li>
+</ul>
+
+<p>在这个例子中:</p>
+
+<ul>
+ <li>每次页面加载,页面计算并显示当前日期和时间。这个计算包括秒和毫秒,所以你可以很容易地测试功能。</li>
+ <li>第一次加载页面,光标放置在表单的Name字段。在 Firefox 1.5, 当用户导航回该页面,光标依然在页面导航离开时的位置。在其他浏览器,光标移回到Name字段。</li>
+</ul>
+
+<pre class="brush:html">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd"&gt;
+&lt;HTML&gt;
+&lt;head&gt;
+&lt;title&gt;Order query Firefox 1.5 Example&lt;/title&gt;
+&lt;style type="text/css"&gt;
+body, p {
+ font-family: Verdana, sans-serif;
+ font-size: 12px;
+ }
+&lt;/style&gt;
+&lt;script type="text/javascript"&gt;
+function onLoad() {
+ loadOnlyFirst();
+ onPageShow();
+}
+
+function onPageShow() {
+//calculate current time
+ var currentTime= new Date();
+ var year=currentTime.getFullYear();
+ var month=currentTime.getMonth()+1;
+ var day=currentTime.getDate();
+ var hour=currentTime.getHours();
+ var min=currentTime.getMinutes();
+ var sec=currentTime.getSeconds();
+ var mil=currentTime.getMilliseconds();
+ var displayTime = (month + "/" + day + "/" + year + " " +
+ hour + ":" + min + ":" + sec + ":" + mil);
+ document.getElementById("timefield").value=displayTime;
+}
+
+function loadOnlyFirst() {
+ document.zipForm.name.focus();
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload="onLoad();" onpageshow="if (event.persisted) onPageShow();"&gt;
+&lt;h2&gt;Order query&lt;/h2&gt;
+
+&lt;form name="zipForm" action="http://www.example.com/formresult.html" method="get"&gt;
+&lt;label for="timefield"&gt;Date and time:&lt;/label&gt;
+&lt;input type="text" id="timefield"&gt;&lt;br&gt;
+&lt;label for="name"&gt;Name:&lt;/label&gt;
+&lt;input type="text" id="name"&gt;&lt;br&gt;
+&lt;label for="address"&gt;Email address:&lt;/label&gt;
+&lt;input type="text" id="address"&gt;&lt;br&gt;
+&lt;label for="order"&gt;Order number:&lt;/label&gt;
+&lt;input type="text" id="order"&gt;&lt;br&gt;
+&lt;input type="submit" name="submit" value="Submit Query"&gt;
+&lt;/form&gt;
+&lt;/body&gt;
+&lt;/html&gt;
+</pre>
+
+<p>与此相反, 如果以上页面不监听 <code>pageshow</code> 事件,所有的计算作为 <code>load</code> 事件的一部分(取而代之的是如下面的示例代码片段所示的编码),Firefox 1.5 中,当用户导航离页面时,光标位置及date/time会被缓存。当用户返回回该页面,缓存的date/time将会显示。</p>
+
+<pre class="brush:html">&lt;script&gt;
+function onLoad() {
+ loadOnlyFirst();
+
+//calculate current time
+ var currentTime= new Date();
+ var year = currentTime.getFullYear();
+ var month = currentTime.getMonth()+1;
+ var day = currentTime.getDate();
+ var hour=currentTime.getHours();
+ var min=currentTime.getMinutes();
+ var sec=currentTime.getSeconds();
+ var mil=currentTime.getMilliseconds();
+ var displayTime = (month + "/" + day + "/" + year + " " +
+ hour + ":" + min + ":" + sec + ":" + mil);
+ document.getElementById("timefield").value=displayTime;
+}
+
+function loadOnlyFirst() {
+ document.zipForm.name.focus();
+}
+&lt;/script&gt;
+&lt;/head&gt;
+
+&lt;body onload="onLoad();"&gt;
+</pre>
+
+<h2 id="Developing_Firefox_extensions" name="Developing_Firefox_extensions">开发Firefox扩展</h2>
+
+<p>Firefox 1.5 <a href="/en-US/docs/Building_an_Extension" title="Building_an_Extension">extensions</a> 需要允许缓存功能。如果你在开发一个兼容1.5 及以前版本的Firefox扩展,确保它监听事件触发 <code>load</code> 可被缓存,监听的 <code>pageshow</code> 事件触发不应该被缓存。</p>
+
+<p>例如,Firefox的Google工具栏为了兼容1.5和更早的版本,应该为autolink监听 <code>load</code> 事件函数,为PageRank监听 <code>pageshow</code> 事件函数。</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/12/index.html b/files/zh-cn/mozilla/firefox/releases/12/index.html
new file mode 100644
index 0000000000..ee154efbfe
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/12/index.html
@@ -0,0 +1,165 @@
+---
+title: Firefox 12 for developers
+slug: Mozilla/Firefox/Releases/12
+tags:
+ - Firefox
+ - Firefox 12
+ - Gecko 12
+ - Web Developement
+translation_of: Mozilla/Firefox/Releases/12
+---
+<div>{{FirefoxSidebar}}</div>
+
+<p>Firefox 12 was shipped on April 24, 2012. This page summarizes the changes in Firefox 12 that affect developers. This article provides information about the new features and key bugs fixed in this release, as well as links to more detailed documentation for both web developers and add-on developers.</p>
+
+<h2 id="Changes_for_Web_developers">Changes for Web developers</h2>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>The <code>title</code> attribute now supports newline characters to allow multi-line tooltips.</li>
+ <li>If JavaScript is disabled, the {{HTMLElement("canvas")}} element was being rendered instead of showing the fallback content as per the <a class="external" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html" title="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html">specification</a>. Now the fallback content is rendered instead.</li>
+ <li>The <code>crossorigin</code> attribute is now supported on {{HTMLElement("video")}}.</li>
+</ul>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>Support for the {{cssxref("text-align-last")}} property has been added (prefixed).</li>
+</ul>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li>Support for <a href="/en-US/docs/JavaScript/Sharp_variables_in_JavaScript" title="Sharp variables in JavaScript">sharp variables</a> (a Netscape non-standard extension) has been dropped.</li>
+ <li>{{jsxref("ArrayBuffer.prototype.slice()")}} has been implemented.</li>
+</ul>
+
+<h3 id="DOM">DOM</h3>
+
+<ul>
+ <li>{{domxref("DOMParser")}} now supports parsing of HTML document fragments.</li>
+ <li>{{domxref("XMLHttpRequest")}} now supports timeouts using the <code>timeout</code> property and "timeout" event, as well as the <code>ontimeout</code> event handler on the {{domxref("XMLHttpRequestEventTarget")}} interface.</li>
+ <li>{{domxref("XMLHttpRequest")}} can now load from <a href="/en-US/docs/data_URIs" title="data URIs"><code>data:</code> URIs</a>.</li>
+ <li>When downloading large amounts of data, {{domxref("XMLHttpRequest")}} progress event handlers are now called periodically with the <code>responseType</code> set to "moz-blob" and the response being a {{domxref("Blob")}} containing all of the data received so far. This lets progress handlers begin processing data without having to wait for it all to arrive.</li>
+ <li>Gecko now supports <a href="/en-US/docs/DOM/Touch_events" title="en-US/docs/DOM/Touch_events">multi-touch</a> (instead of just single touches at a time) on Android.</li>
+ <li>While editing text using an IME, the <code>input</code> event is now sent whenever the contents of the element being edited have been changed; this happens after the <code>compositionupdate</code> event has been sent to indicate that the IME's text has been changed. You can use the <code>input</code> event handler, therefore, to monitor changes to the actual content of the element.</li>
+ <li>{{domxref("DOMError")}} as defined in the DOM 4 specification has been implemented.</li>
+ <li>The {{domxref("Document.createNodeIterator()")}} method has been updated to match the DOM4 specification. This makes the <code>whatToShow</code> and <code>filter</code> parameters optional and removes the non-standard fourth parameter, <code>entityReferenceExpansion</code>.</li>
+ <li>The {{domxref("Blob")}} interface's <code>slice()</code> method was affected by a bug that prevented it from properly accepting <code>start</code> and <code>end</code> values outside the range of a signed 64-bit integer; this has been fixed.</li>
+ <li>The {{domxref("element.getBoundingClientRect()")}} method now considers effect of <a href="/en-US/docs/CSS/Using_CSS_transforms" title="Using CSS transforms">CSS transforms</a> when computing the element's bounding rectangle.</li>
+ <li>The <code>crossOrigin</code> property is now supported by {{domxref("HTMLMediaElement")}}.</li>
+</ul>
+
+<h4 id="New_WebAPIs">New WebAPIs</h4>
+
+<ul>
+ <li>Network Information API: Experimental support for {{domxref("window.navigator.connection")}} has been added (prefixed).</li>
+ <li>WebTelephony API: {{domxref("window.navigator.mozTelephony")}} has been implemented and provides support for dialing, answering, and managing phone calls on a device.</li>
+ <li>WebSMS API: {{domxref("window.navigator.mozSms")}} is now available for mobile devices to send SMS text messages.</li>
+ <li>Screen brightness API: {{domxref("window.screen.mozEnabled")}} and {{domxref("window.screen.mozBrightness")}} have been added to control the device's screen.</li>
+</ul>
+
+<h3 id="SVG">SVG</h3>
+
+<ul>
+ <li>Firefox now implements the {{domxref("SVGTests")}} DOM API, see {{bug("607854")}}</li>
+ <li>The {{domxref("SVGStringList")}} DOM interface support the non-standard <code>length</code> property see {{bug("711958")}}</li>
+</ul>
+
+<h3 id="MathML">MathML</h3>
+
+<ul>
+ <li>To control the directionality of MathML formulas, the <code>dir</code> attribute is now supported on the {{MathMLElement("math")}}, {{MathMLElement("mrow")}}, and {{MathMLElement("mstyle")}} elements as well as on <a href="/Special:Tags?tag=MathML:Token+Elements" title="Special:Tags?tag=MathML:Token+Elements">MathML Token Elements</a>. This is particularly important for some <a class="external" href="http://www.w3.org/TR/arabic-math/" title="http://www.w3.org/TR/arabic-math/">Arabic mathematical notations</a>.</li>
+ <li>The alignment attribute <code>align</code> defined in MathML3 has been implemented for {{MathMLElement("munder")}}, {{MathMLElement("mover")}}, and {{MathMLElement("munderover")}}.</li>
+</ul>
+
+<h3 id="Networking">Networking</h3>
+
+<ul>
+ <li>Previously, Gecko reported the close code <code>CLOSE_NORMAL</code> when a WebSocket channel was closed due to an unexpected error, or if it was closed due to an error condition that the specification doesn't cover. Now <code>CLOSE_GOING_AWAY</code> is reported instead.</li>
+</ul>
+
+<h3 id="Developer_tools">Developer tools</h3>
+
+<ul>
+ <li>The <a href="/en-US/docs/Tools/Web_Console" title="Web Console">Web Console</a> now caches error messages and log entries added using {{domxref("console.log()")}} if the console isn't currently open, and displays them when the console is opened.</li>
+ <li>You can now reset the zoom level, panning, and rotation in the <a href="/en-US/docs/Tools/Page_Inspector/3D_view" title="3D view">3D view</a> by pressing the "r" key.</li>
+ <li>You can now hide nodes in the <a href="/en-US/docs/Tools/Page_Inspector/3D_view" title="3D view">3D view</a> by pressing the "x" key after selecting them.</li>
+ <li>The <a href="/en-US/docs/Tools/Using_the_Source_Editor" title="en-US/docs/Tools/Using_the_Source_Editor">source editor</a> has a several new editing features and keyboard shortcuts; see <a href="/en-US/docs/Tools/Using_the_Source_Editor" title="Using the Source Editor">Using the Source Editor</a> for details</li>
+</ul>
+
+<p>Mozilla has been working on integrating its own Web developer tools that complement the popular <a class="external" href="http://getfirebug.com/" title="Firebug Firefox add-on">Firebug</a> add-on. You can get more information about these tools as well as see a list of resources external to Firefox that will help you with your Web development. The entire list is located at <a href="/en-US/docs/Tools" title="Web Developer Tools">Web developer tools</a>.</p>
+
+<h3 id="Miscellaneous_changes">Miscellaneous changes</h3>
+
+<ul>
+ <li>The GEOSTD8 character set, which was never fully supported, is no longer supported at all.</li>
+</ul>
+
+<h2 id="Changes_for_Mozilla_and_add-on_developers">Changes for Mozilla and add-on developers</h2>
+
+<h3 id="JavaScript_code_modules">JavaScript code modules</h3>
+
+<h4 id="source-editor.jsm">source-editor.jsm</h4>
+
+<ul>
+ <li>The <a href="/en-US/docs/JavaScript_code_modules/source-editor.jsm#resetUndo%28%29" title="en-US/docs/JavaScript_code_modules/source-editor.jsm#resetUndo%28%29"><code>resetUndo()</code></a> method was added; this lets you clear the undo stack.</li>
+ <li>The source editor now offers methods for providing search capability: <a href="/en-US/docs/JavaScript_code_modules/source-editor.jsm#find()" title="en-US/docs/JavaScript_code_modules/source-editor.jsm#find()"><code>find()</code></a>, <a href="/en-US/docs/JavaScript_code_modules/source-editor.jsm#findNext()" title="en-US/docs/JavaScript_code_modules/source-editor.jsm#findNext()"><code>findNext()</code></a>, and <a href="/en-US/docs/JavaScript_code_modules/source-editor.jsm#findPrevious()" title="en-US/docs/JavaScript_code_modules/source-editor.jsm#findPrevious()"><code>findPrevious()</code></a>.</li>
+</ul>
+
+<h3 id="XUL">XUL</h3>
+
+<ul>
+ <li>The definition of the values for the {{XULAttr("chromemargin")}} attribute has changed slightly, to make it easier to make cross-platform XUL code look good on platforms with different default window border widths.</li>
+</ul>
+
+<h3 id="XPCOM">XPCOM</h3>
+
+<ul>
+ <li><a href="/en-US/docs/nsISupports_proxies" title="nsISupports proxies"><code>nsISupports</code> proxies</a> are no longer supported. You should be using runnables instead; see <a href="/en-US/docs/XPCOM/Making_cross-thread_calls_using_runnables" title="en-US/docs/XPCOM/Making cross-thread calls using runnables">Making cross-thread calls using runnables</a>.</li>
+ <li>Firefox 11 changed the behavior of <a href="/en-US/docs/Components.utils.getWeakReference" title="Components.utils.getWeakReference"><code>Components.utils.getWeakReference()</code></a> to throw an exception when the object reference is null; the previous behavior of silently failing has been restored.</li>
+</ul>
+
+<h3 id="XPConnect">XPConnect</h3>
+
+<ul>
+ <li>The <a href="/en-US/docs/PRUint64" title="PRUint64"><code>PRUint64</code></a> data type was incorrectly essentially identical to <a href="/en-US/docs/PRInt64" title="PRInt64"><code>PRint64</code></a> when used with XPConnect. This has been fixed.</li>
+</ul>
+
+<h3 id="Interface_changes">Interface changes</h3>
+
+<ul>
+ <li>The <code>nsIScreen_MOZILLA_2_0_BRANCH</code> interface has been merged into {{interface("nsIScreen")}}. The APIs defined in that interface (for controlling minimum screen brightness) had not previously been documented, but now they are.</li>
+ <li>The {{interface("nsIScriptError2")}} interface has been merged into {{interface("nsIScriptError")}}.</li>
+ <li>{{ifmethod("nsIDownloadManager", "addDownload")}} is now handled asynchronously rather than synchronously.</li>
+ <li>The {{ifmethod("imgIContainerObserver", "frameChanged")}} method now receives as its first parameter an {{interface("imgIRequest")}} object identifying the corresponding request.</li>
+ <li>The {{ifmethod("nsIDOMWindowUtils", "sendTouchEvent")}} method has been added to allow synthesizing touch events.</li>
+ <li>You can now scroll the specified content to the vertical center of the view by specifying <code>SCROLL_CENTER_VERTICALLY</code> as the scroll constant when calling {{ifmethod("nsISelectionController", "scrollSelectionIntoView")}}.</li>
+ <li>The new {{ifattribute("nsIMemoryMultiReporter", "explicitNonHeap")}} attribute has been added; this is a more efficient way to obtain the sum of all of the multi-reporter's measurements that have a path that starts with "explicit" <strong>and</strong> are of the kind <code>KIND_NONHEAP</code>.</li>
+ <li>The {{ifattribute("nsIDOMWindowUtils", "paintingSuppressed")}} attribute has been added; this boolean value indicates whether or not painting is currently suppressed on the window. This is used on mobile to prevent bouncy rendering that occurs when attempts to draw the page begin before enough content is available to do so smoothly.</li>
+ <li>The <code>nsIDocCharset</code> and <code>nsIDocumentCharsetInfo</code> interfaces have been merged into {{interface("nsIDocShell")}}. As part of this work, the old <code>forcedDetector</code> attribute has been removed; it never did anything.</li>
+</ul>
+
+<h3 id="SpiderMonkey">SpiderMonkey</h3>
+
+<ul>
+ <li><code>JSThread</code> has been eliminated.</li>
+ <li><code>JSThreadData</code> has been merged into <code>JSRuntime</code>.</li>
+</ul>
+
+<h3 id="Building">Building</h3>
+
+<ul>
+ <li>When building on Windows, you must have the Windows 7 SDK installed.</li>
+</ul>
+
+<h3 id="Other_changes">Other changes</h3>
+
+<ul>
+ <li>The editor component (known as <a href="/en-US/docs/Midas" title="Midas">Midas</a>) now <a href="/en-US/docs/Using_the_Editor_from_XUL#Editor_event_handling" title="en-US/docs/Using_the_Editor_from_XUL#Editor_event_handling">only accepts events</a> from privileged code.</li>
+</ul>
+
+<h2 id="See_also">See also</h2>
+
+<div>{{Firefox_for_developers('11')}}</div>
diff --git a/files/zh-cn/mozilla/firefox/releases/14/index.html b/files/zh-cn/mozilla/firefox/releases/14/index.html
new file mode 100644
index 0000000000..8ef207f56e
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/14/index.html
@@ -0,0 +1,98 @@
+---
+title: Firefox 14 for developers
+slug: Mozilla/Firefox/Releases/14
+tags:
+ - Firefox
+ - Firefox 14
+ - Gecko
+ - Gecko 14
+translation_of: Mozilla/Firefox/Releases/14
+---
+<div>{{FirefoxSidebar}}</div><p>Firefox 14 shipped on July 17, 2012. This article lists key changes that are useful for not only Web developers to know about, but also Firefox and Gecko developers as well as add-on developers.</p>
+
+<h2 id="Changes_for_Web_developers">Changes for Web developers</h2>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>{{ HTMLElement("progress") }}元素不在错误的归为一个表单元素,因此不再有一个<code>form</code>属性.</li>
+ <li>The default modifier keys for the <code><a href="/zh-cn/HTML/Global_attributes" title="Global attributes">accesskey</a></code> of HTML contents on Mac are changed to Control+Option.  This is the same as WebKit-based browsers on Mac.</li>
+</ul>
+
+<h3 id="DOM">DOM</h3>
+
+<ul>
+ <li><a href="/zh-cn/DOM/DOM_event_reference/input" title="input">input</a> events are fired also on editing host element of <a href="/zh-cn/DOM/element.contentEditable" title="Element.contentEditable">contenteditable</a> editor and root element of <a href="/zh-cn/DOM/document.designMode" title="document.designMode">designMode</a> editor.</li>
+ <li>{{ domxref("DOMException", "DOMException.code") }}已被废弃,根据最新的DOM Level 4 规范.</li>
+ <li>{{ domxref("Range.insertNode()") }} method now works correctly when used on collapsed ranges.</li>
+ <li>The {{ domxref("BlobBuilder", "MozBlobBuilder") }} interface has been deprecated in favor of the constructor on {{ domxref("Blob") }}. If you use <code>MozBlobBuilder</code> you'll see a warning message in the Web Console.</li>
+ <li>The {{domxref("Blob.Blob", "Blob()")}} constructor is now available to workers ({{bug(736686)}}).</li>
+ <li>Support for the <a href="/zh-cn/DOM/DOM_Mutation_Observers" title="zh-cn/DOM/DOM_Mutation_Observers">Mutation Observers</a> has been landed. It is designed as a replacement for the Mutation Events in DOM3, which has a number of issues regarding performance.</li>
+ <li>The {{ domxref("HTMLImageElement") }} interface's <code>x</code> and <code>y</code> properties were removed in Gecko 7.0 {{ geckoRelease("7.0") }} but restored in this release for compatibility reasons.</li>
+ <li>{{ domxref("Document") }}上的方法<code>execCommandShowHelp()</code>和<code>queryCommandText()</code>,没有任何作用,已被删除.</li>
+ <li>The <code>GeoPositionAddress</code> interface, an obsolete part of the <a href="/zh-cn/Using_geolocation" title="zh-cn/Using_geolocation">Geolocation</a> API, has been removed.</li>
+ <li>{{ domxref("Storage", "localStorage/sessionStorage") }} now correctly return <code>undefined</code> instead of <code>null</code> for undeclared keys through property access.</li>
+ <li>The {{domxref("ImageData")}} object has been implemented ({{bug(550309)}}).</li>
+ <li>Attributes and methods related to child nodes on {{domxref("Attr")}} interface where obsoleted ({{bug(737122)}}).</li>
+</ul>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>The {{ cssxref("text-transform") }} and {{ cssxref("font-variant") }} CSS properties have been fixed to correctly handle the <code>i</code> → <code>İ</code> and <code>ı</code> → <code>I</code> <a class="external" href="http://en.wikipedia.org/wiki/Turkic_languages" title="http://en.wikipedia.org/wiki/Turkic_languages">Turkic</a>-specific case pairs.</li>
+ <li>The Dutch IJ digraph is now correctly handled by <code>text-transform: capitalization</code>. Similarly the Greek letter <code>Σ</code>, which has two lowercase forms, <code>σ</code> and <code>ς</code>, is now correctly handled by <code>text-transform: lowercase</code>.</li>
+ <li>Support for the <code>skew()</code> function has been removed from {{cssxref("transform")}} property, as it has been removed from the draft standard.</li>
+ <li>The syntax for {{ cssxref("border-image") }} has been updated to match the latest revision of the specification; it no longer accepts a trailing slash ("/").</li>
+</ul>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<p><em>No change.</em></p>
+
+<h3 id="MathML">MathML</h3>
+
+<ul>
+ <li>The syntax of the <code>statusline</code> action type on {{ MathMLElement("maction") }} elements has been adjusted to follow the MathML specification.</li>
+</ul>
+
+<h3 id="HTTP">HTTP</h3>
+
+<ul>
+ <li>Gecko开始支持新的<a href="/zh-cn/HTTP" title="HTTP">HTTP</a> <a href="/zh-cn/HTTP/HTTP_response_codes#308" title="https://developer.mozilla.org/zh-cn/HTTP/HTTP_response_codes#308"><code>308</code>永久重定向</a> 状态码. 由于Gecko并不区分永久重定向和零食重定向,所以该状态码的表现行为和<a href="/zh-cn/HTTP/HTTP_response_codes#307" title="https://developer.mozilla.org/zh-cn/HTTP/HTTP_response_codes#307"><code>307 临时重定向</code></a>状态码是一样的, 和302以及301状态码的区别是,它们禁止用户代理改变重定之后的HTTP方法(<code>POST还是</code><code>POST</code>, <code>GET</code>还是<code>GET</code>).</li>
+</ul>
+
+<h2 id="Changes_for_Mozilla_and_add-on_developers">Changes for Mozilla and add-on developers</h2>
+
+<h3 id="JavaScript_代码模块">JavaScript 代码模块</h3>
+
+<h4 id="source-editor.jsm">source-editor.jsm</h4>
+
+<ul>
+ <li>Added a keyboard shortcut to toggle commenting for the current selection (Ctrl-/ or Cmd-/ on Mac OS X).</li>
+ <li>Added the Ctrl-[ and Ctrl-] keyboard shortcuts for moving the text input position to the beginning and end of the current block.</li>
+ <li>Added the new <a href="/zh-cn/JavaScript_code_modules/source-editor.jsm#getLineStart%28%29" title="zh-cn/JavaScript_code_modules/source-editor.jsm#getLineStart%28%29"><code>getLineStart()</code></a> and <a href="/zh-cn/JavaScript_code_modules/source-editor.jsm#getLineEnd%28%29" title="zh-cn/JavaScript_code_modules/source-editor.jsm#getLineEnd%28%29"><code>getLineEnd()</code></a> methods.</li>
+</ul>
+
+<h3 id="XUL">XUL</h3>
+
+<ul>
+ <li>在 {{ XULElem("window") }}元素上添加了新的 {{ XULAttr("fullscreenbutton") }}属性; 将该属性设置为<code>true,会在</code>窗口上添加一个进入全屏模式的按钮.</li>
+</ul>
+
+<h3 class="editable" id="接口"><span>接口</span></h3>
+
+<ul>
+ <li>{{ interface("nsILocalFile") }}接口被合并到{{ interface("nsIFile") }}接口中. (<a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=682360" title="https://bugzilla.mozilla.org/show_bug.cgi?id=682360">bug 682360</a>).</li>
+ <li>The methods in {{ interface("nsIPlacesImportExportService") }} for importing bookmarks have all been removed in favor of the <code><a href="/zh-cn/JavaScript_code_modules/BookmarkHTMLUtils.jsm" title="zh-cn/JavaScript_code_modules/BookmarkHTMLUtils.jsm">BookmarkHTMLUtils.jsm</a></code> JavaScript code module.</li>
+ <li>{{ interface("nsIDOMGeoPositionAddress") }} 接口已被移除.</li>
+</ul>
+
+<h3 id="拼写检查">拼写检查</h3>
+
+<ul>
+ <li>Dictionary names are now parsed as full <a class="external" href="http://tools.ietf.org/html/bcp47" title="http://tools.ietf.org/html/bcp47">BCP 47</a> language tags (<a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=730209" title="https://bugzilla.mozilla.org/show_bug.cgi?id=730209">bug 730209</a>, <a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=741842" title="https://bugzilla.mozilla.org/show_bug.cgi?id=741842">bug 741842</a>). Developers are encouraged to not hard-code the name of their language in their dictionary names.</li>
+</ul>
+
+<h2 id="相关链接">相关链接</h2>
+
+<div>{{Firefox_for_developers('13')}}</div>
diff --git a/files/zh-cn/mozilla/firefox/releases/15/index.html b/files/zh-cn/mozilla/firefox/releases/15/index.html
new file mode 100644
index 0000000000..1c941836d7
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/15/index.html
@@ -0,0 +1,122 @@
+---
+title: Firefox 15 for developers
+slug: Mozilla/Firefox/Releases/15
+tags:
+ - Firefox
+ - Firefox 15
+ - Gecko 15
+translation_of: Mozilla/Firefox/Releases/15
+---
+<div>{{FirefoxSidebar}}</div><p>Firefox 15 shipped on August 28, 2012. This article lists key changes that are useful for not only Web developers to know about, but also Firefox and Gecko developers as well as add-on developers.</p>
+
+<h2 id="Changes_for_Web_developers">Changes for Web developers</h2>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>The <code>size</code> attribute of the {{ HTMLElement("font") }} element is now handled according the HTML5 spec. It means that all integer greater than 10 or smaller than -10 are now considered equivalent to 10, respectively -10.</li>
+ <li>Support for <code>font-weight</code> and <code>point-size</code> attributes on the <code>&lt;font&gt;</code> element has been removed; these were non-standard and Gecko was the only engine supporting them.</li>
+ <li>The <a class="external" href="http://www.opus-codec.org/" title="http://www.opus-codec.org/">Opus codec</a> is now supported for audio in Ogg containers for the HTML {{ HTMLElement("audio") }} and {{ HTMLElement("video") }} elements.</li>
+ <li>The {{ HTMLElement("source") }} element now supports the <code>media</code> attribute.</li>
+ <li>The {{ HTMLElement("audio") }} and {{ HTMLElement("video") }} elements now support the played attribute, which provides a {{ domxref("TimeRanges") }} object listing the time ranges of the media that have been played back so far.</li>
+</ul>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>The {{ cssxref("font-feature-settings") }} property has been updated to the latest syntax: <code>font-feature-settings: "lnum" 1;</code></li>
+ <li>The CSS {{ cssxref("text-transform") }} property has been extended to correctly handle Unicode ligature characters (like <code>?</code>).</li>
+ <li>The CSS {{ cssxref("word-break") }} property has been implemented.</li>
+ <li>The {{ cssxref("border-image") }} property has been updated to match the latest Specification and properties have been unprefixed. (<a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=713643">bug 713643</a>)</li>
+ <li>The <code>skew()</code> {{cssxref("transform")}} function dropped in Firefox 14 has been restored due to existing site compatibility. Authors are however, advised to use <code>skewX()</code> and <code>skewY(</code>) functions instead.</li>
+ <li>The value <code>plaintext</code> of CSS {{cssxref("unicode-bidi")}} property now applies to inline elements too. ({{bug("746987")}}).</li>
+</ul>
+
+<h3 id="DOM">DOM</h3>
+
+<ul>
+ <li>The DOM Events Level 3 methods <a href="/zh-cn/DOM/KeyboardEvent#getModifierState%28%29" title="https://developer.mozilla.org/zh-cn/DOM/KeyboardEvent#getModifierState%28%29"><code>KeyboardEvent.getModifierState()</code></a> and <a href="/zh-cn/DOM/MouseEvent#getModifierState%28%29" title="https://developer.mozilla.org/zh-cn/DOM/MouseEvent#getModifierState%28%29"><code>MouseEvent.getModifierState()</code></a>, which let you query the state of modifier keys, like <code>Ctrl</code> or <code>Shift</code>, have been implemented (bugs <a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=630811" title="https://bugzilla.mozilla.org/show_bug.cgi?id=630811">630811</a> and <a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=731878" title="https://bugzilla.mozilla.org/show_bug.cgi?id=731878">731878</a>). But the behavior conforms to the latest D3E draft. So, some modifier key names are different from IE ({{ bug("769190") }}).</li>
+ <li>On mouse events, support for querying the state of the mouse buttons using the <a href="/zh-cn/DOM/MouseEvent" title="zh-cn/DOM/MouseEvent"><code>MouseEvent.buttons</code></a> attribute, has been implemented.</li>
+ <li>On keyboard events, support for querying the key location (standard, left or right of modifier key, in the Numpad) using the <a href="/zh-cn/DOM/KeyboardEvent#Attributes_location" title="https://developer.mozilla.org/zh-cn/DOM/KeyboardEvent#Attributes_location">KeyboardEvent.location</a> attribute, has been implemented ({{ bug("166240") }}).</li>
+ <li>KeyboardEvent.keycode result has been computed from better rules which were almost same on Windows/Linux/Mac. And now they are available on some keyboard layouts which are not ASCII capable layouts on Linux and Mac, such as Arabic, Cyrillic, Thai and so on. See <a href="/zh-cn/DOM/KeyboardEvent#Virtual_key_codes" title="zh-cn/DOM/KeyboardEvent#Virtual_key_codes">the document for virtual key codes</a>.</li>
+ <li>The <a href="/zh-cn/DOM/range.detach" title="https://developer.mozilla.org/zh-cn/DOM/range.detach"><code>range.detach()</code></a> method has been transformed in a no-op and will probably be removed in the future.</li>
+ <li>The method <code>HTMLVideoElement.mozHasAudio()</code> has been implemented. It indicates if there is an audio track associated to a given video element. (<a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=480376" title="https://bugzilla.mozilla.org/show_bug.cgi?id=480376">bug </a><a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=480376" title="https://bugzilla.mozilla.org/show_bug.cgi?id=480376">480376</a>)</li>
+ <li>The <code>Performance</code> API has a new method, <code>now()</code>, supporting high resolution timers of type<code> DOMHighResTimeStamp</code>. (<a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=539095" title="https://bugzilla.mozilla.org/show_bug.cgi?id=539095">bug 539095</a>).</li>
+ <li>The <code>Window.java</code> and <code>Window.packages</code> attributes has been removed. These were never documented, and hopefully you're not using them!</li>
+ <li>The <a href="/zh-cn/API/WebSMS" title="zh-cn/API/WebSMS">WebSMS API</a> has been updated and now supports a <code>read </code>attribute indicating whether an SMS text message is read or unread.</li>
+ <li>The <a class="link-https" href="https://wiki.mozilla.org/WebAPI/FileHandleAPI" title="https://wiki.mozilla.org/WebAPI/FileHandleAPI">FileHandle API</a> has been implemented.</li>
+ <li>The <a href="/zh-cn/DOM/Blob" title="zh-cn/DOM/Blob"><code>Blob</code></a> constructor now takes <code>ArrayBufferView</code> as a member of <code><var>blobParts</var></code> parameter in addition to <code>ArrayBuffer</code>. (<a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=752402">bug 752402</a>)</li>
+ <li>The {{domxref("DeviceLightEvent")}} specified in the <a href="http://www.w3.org/TR/ambient-light/" title="http://www.w3.org/TR/ambient-light/">Ambient Light Events Working Draft</a> has been implemented.</li>
+ <li>The {{domxref("DeviceProximityEvent")}} and {{domxref("UserProximityEvent")}} <a href="http://www.w3.org/TR/proximity/" title="http://www.w3.org/TR/proximity/">Proximity Events</a> have been implemented.</li>
+ <li>The {{domxref("File")}} <code>lastModifiedDate</code> property has been implemented. ({{bug("673586")}})</li>
+</ul>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li>Support for the <a href="/zh-cn/JavaScript_typed_arrays/DataView" title="/zh-cn/JavaScript_typed_arrays/DataView"><code>DataView</code></a> interface from the Typed Arrays specification has been added. This provides low-level access to the data contained in an <a href="/zh-cn/JavaScript_typed_arrays/ArrayBuffer" title="zh-cn/JavaScript_typed_arrays/ArrayBuffer"><code>ArrayBuffer</code></a>.</li>
+ <li>Support for new ECMAScript 2015 built-ins:  <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/isNaN" title="JavaScript/Reference/Global_Objects/isNaN"><code>Number.isNaN()</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toInteger"><code>Number.toInteger()</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger"><code>Number.isInteger()</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite"><code>Number.isFinite()</code></a> has been added. (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=749818" title="https://bugzilla.mozilla.org/show_bug.cgi?id=749818">bug 749818</a>, <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=749818" title="https://bugzilla.mozilla.org/show_bug.cgi?id=761495">bug 761495</a>, <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=749818" title="https://bugzilla.mozilla.org/show_bug.cgi?id=761480">bug 761480</a>).</li>
+ <li>添加了对<code>ES6中的<a href="/zh-CN/docs/Web/JavaScript/Reference/Functions/Default_parameters">默认参数</a></code>的支持. (<a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=757676" title="https://bugzilla.mozilla.org/show_bug.cgi?id=757676">bug 757676</a>)</li>
+ <li>添加了对<code>ES6中的<a href="/zh-CN/docs/Web/JavaScript/Reference/Functions/Rest_parameters">剩余参数</a></code>的支持.(<a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=574132" title="https://bugzilla.mozilla.org/show_bug.cgi?id=574132">bug 574132</a>)</li>
+</ul>
+
+<h3 id="WebGL">WebGL</h3>
+
+<ul>
+ <li>Support for the <a href="/zh-cn/WebGL/Using_Extensions#WEBGL_compressed_texture_s3tc" title="zh-cn/WebGL/Using_Extensions#WEBGL_compressed_texture_s3tc"><code>WEBGL_compressed_texture_s3tc</code></a> extension has been added. Compressed textures reduce the amount of memory needed to store a texture on the GPU, allowing for higher resolution textures or more of the same resolution textures.</li>
+</ul>
+
+<h3 id="MathML">MathML</h3>
+
+<ul>
+ <li>Mathematical operators can now use downloadable fonts specified with {{ cssxref("@font-face") }}. This makes the <a class="link-https" href="https://addons.mozilla.org/en-US/firefox/addon/mathml-fonts/" title="https://addons.mozilla.org/en-US/firefox/addon/mathml-fonts/">MathML-fonts add-on</a> work with stretchy operators too.</li>
+ <li>The <code>selection</code> attribute of the {{ MathMLElement("maction") }} is now only taken into account with the <code>toggle</code> actiontype.</li>
+ <li><a class="external" href="http://www.w3.org/TR/MathML3/chapter3.html#id.3.3.4.2.1" title="http://www.w3.org/TR/MathML3/chapter3.html#id.3.3.4.2.1"><span id="summary_alias_container"><span id="short_desc_nonedit_display">Deprecated namedspace binding</span></span></a> has been removed ({{ bug("673759") }}).</li>
+ <li>Supported syntax for <a href="/zh-cn/MathML/Attributes/Values" title="Values">Length</a> and {{ MathMLElement("mpadded") }} values have been made closer to the one specified in MathML3 spec.</li>
+</ul>
+
+<h3 id="SVG">SVG</h3>
+
+<ul>
+ <li>Added support for the {{SVGElement("view")}} element ({{bug("512525")}}).</li>
+</ul>
+
+<h3 id="Network">Network</h3>
+
+<ul>
+ <li>Support for the SPDY v3 protocol has landed. It is disabled by default and can be enabled by setting the preference <code>network.http.spdy.enabled.v3</code> to true. (<a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=737470">bug 737470</a>)</li>
+</ul>
+
+<h2 id="附加组件开发变更">附加组件开发变更</h2>
+
+<h3 id="接口变更">接口变更</h3>
+
+<dl>
+ <dt>{{ interface("nsIDOMWindowUtils") }}</dt>
+ <dd><code>aModifiers</code> of <code>sendMouseEvent()</code>, <code>sendTouchEvent()</code>, <code>sendMouseEventToWindow()</code>, <code>sendMouseScrollEvent()</code> and <code>sendKeyEvent()</code> supports all modifier keys which are supported by <a href="/zh-cn/DOM/KeyboardEvent#getModifierState%28%29" title="https://developer.mozilla.org/zh-cn/DOM/KeyboardEvent#getModifierState%28%29"><code>KeyboardEvent.getModifierState()</code></a>. Use <code>MODIFIER_*</code> values. And now the 5th parameter of <code>sendKeyEvent()</code> is changed from <code>boolean</code> to <code>unsigned long</code>. For backward compatibility, if caller passes <code>true</code> or <code>false</code> to it, the behavior isn't changed. This change allows callers to specify the key's location.</dd>
+ <dt>{{ interface("nsIBrowserHistory") }}</dt>
+ <dd>The <code>hidePage()</code> method was never implemented, and has been removed entirely in this release. The <code>addPageWithDetails()</code> method has also been removed as part of the ongoing work to make all <a href="/zh-cn/Places" title="zh-cn/Places">Places</a> APIs asynchronous; use {{ ifmethod("mozIAsyncHistory", "updatePlaces") }} instead. Also, the <code>count</code> attribute was removed; it had not returned an actual count in some time (instead, it was simply indicating whether or not any entries existed). You can use {{ ifattribute("nsINavHistoryService", "hasHistoryEntries") }} instead.</dd>
+ <dt>{{interface("inIDOMUtils")}}</dt>
+ <dd>The {{ifmethod("inlDOMUtils", "parseStyleSheet")}} method has been added and allows the (re-)parsing of Cascading Style Sheets.</dd>
+ <dt>{{interface("nsIINIParserWriter")}}</dt>
+ <dd>The {{ifmethod("nsIINIParserWriter", "writeFile")}} method now accepts a <code>flags</code>property. This currently offers only one option: you can now tell it to write the file in UTF-16 format instead of UTF-8, for better compatibility with Windows and certain installers.</dd>
+</dl>
+
+<h4 id="新增接口">新增接口</h4>
+
+<dl>
+ <dt>{{ interface("nsISpeculativeConnect") }}</dt>
+ <dd>Provides a way to hint to the networking layer that you are likely to ask to open a connection to a given URI sometime in the near future. This lets the network layer begin the sometimes high-latency process of opening a new network connection ahead of time.</dd>
+</dl>
+
+<h4 id="移除接口">移除接口</h4>
+
+<p>The following interfaces have been removed.</p>
+
+<ul>
+ <li>{{ interface("nsIGlobalHistory") }}</li>
+</ul>
+
+<h2 id="相关链接">相关链接</h2>
+
+<p>{{Firefox_for_developers('14')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/16/index.html b/files/zh-cn/mozilla/firefox/releases/16/index.html
new file mode 100644
index 0000000000..7d63499c62
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/16/index.html
@@ -0,0 +1,114 @@
+---
+title: Firefox 16 for developers
+slug: Mozilla/Firefox/Releases/16
+tags:
+ - Firefox
+ - Firefox 16
+translation_of: Mozilla/Firefox/Releases/16
+---
+<div>{{FirefoxSidebar}}</div><p>Firefox 16 shipped on October 9, 2012. This article lists key changes that are useful for not only Web developers to know about, but also Firefox and Gecko developers as well as add-on developers.</p>
+
+<h2 id="Web开发">Web开发</h2>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>The {{HTMLElement("meter")}} element is now supported.</li>
+ <li>Support for the HTML Microdata API has been added. (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=591467">bug 591467</a>)</li>
+ <li>{{HTMLElement("canvas")}} now supports the CSS <code>currentColor</code> in all case. ({{bug("629882")}})</li>
+ <li>{{HTMLElement("input")}} now allows filtering based on arbitrary mimetypes in <code>accept</code> ({{bug("565274")}}).</li>
+ <li>Two new attributes, <code>width</code> and <code>height</code> have been added to the {{HTMLElement("input")}} element (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=683855">bug 683855</a>).</li>
+</ul>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>实现了标准的不带前缀的 <a href="/En/CSS/Using_CSS_transforms" title="En/CSS/Using_CSS_transforms">CSS Transforms</a>. (<a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=745523">bug 745523</a>)</li>
+ <li>Support for reverse animation direction (keywords <code>reverse</code> and <code>alternate-reverse</code> on the {{cssxref("animation-direction")}} property) has been added. (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=655920">bug 655920</a>).</li>
+ <li>You can now animate the CSS {{cssxref("height")}} and {{cssxref("width")}} properties.</li>
+ <li>The {{cssxref("animation-duration")}} and {{cssxref("transition-duration")}} CSS properties now reject negative values (and do not handle them as <code>0s</code> anymore) (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=773102" title="https://bugzilla.mozilla.org/show_bug.cgi?id=773102">bug 773102</a>).</li>
+ <li>Support for the standard, unprefixed version of <a href="https://developer.mozilla.org/en-US/docs/CSS/Using_CSS_transforms" title="CSS/Using_CSS_transforms">CSS Transforms</a> has been landed (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=745523">bug 745523</a>). {{cssxref("&lt;length&gt;")}} cannot be used for translation values in <code>matrix()</code> and <code>matrix3d()</code> anymore ({{bug(719054)}}).</li>
+ <li>Support for the standard, unprefixed version of <a href="https://developer.mozilla.org/en-US/docs/CSS/Using_CSS_gradients" title="CSS/Using_CSS_gradients">CSS Gradients</a> has been landed. Note that the syntax has changed significantly since the prefixed version, so you should read up on this (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=752187">bug 752187</a>).</li>
+ <li>The {{cssxref("box-sizing", "-moz-box-sizing")}} implementation has been updated to apply to table cells too (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=338554">bug 338554</a>).</li>
+ <li>Support for the standard, unprefixed version of {{cssxref("calc")}} has been landed (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=771678" title="https://bugzilla.mozilla.org/show_bug.cgi?id=771678">bug 771678</a>).</li>
+ <li>The {{cssxref("&lt;resolution&gt;")}} CSS data type has been extended to support the <code>dppx</code>(<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=741644" title="https://bugzilla.mozilla.org/show_bug.cgi?id=741644">bug 741644</a>).</li>
+ <li>On screen, for <a href="https://developer.mozilla.org/en-US/docs/CSS/Media_queries" title="CSS/Media_queries">media queries</a>, <code>dppx</code>, <code>dpi</code>, and <code>dpcm</code> are now representing values based on CSS pixels and no more with the physical units (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=771390" title="https://bugzilla.mozilla.org/show_bug.cgi?id=771390">bug 771390</a>).</li>
+ <li>Three new pseudo-classes <code>:-moz-meter-optimum</code>, <code>:-moz-meter-sub-optimum</code>, and <code>:-moz-meter-sub-sub-optimum</code> have been added for accessing/styling a {{HTMLElement("meter")}} element in a paraticular state (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=660238" title="https://bugzilla.mozilla.org/show_bug.cgi?id=660238">bug 660238</a>).</li>
+ <li>The {{cssxref("-moz-appearance")}} property gains two new values: <code>meterbar</code> and <code>meterchunk</code>. They represent components inside the {{HTMLElement("meter")}} element (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=659999" title="https://bugzilla.mozilla.org/show_bug.cgi?id=659999">bug 659999</a>).</li>
+ <li>The {{cssxref("min-width")}} and {{cssxref("min-height")}} now supports the <code>auto</code>keyword for flex items (and resolves to <code>0</code> for other items) ({{bug("763689")}}).</li>
+</ul>
+
+<h3 id="APIDOM">API/DOM</h3>
+
+<ul>
+ <li>在{{ domxref("HTMLInputElement") }} 接口上添加了两个新的 <code>width</code> 和 <code>height</code>属性 . (<a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=683855">bug 683855</a>)</li>
+ <li>IndexedDB 属性和方法取消前缀. (<a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=726378">bug 726378</a>)</li>
+ <li>The <a href="https://developer.mozilla.org/en-US/docs/DOM/window.navigator.battery" title="DOM/window.navigator.battery">Battery API</a> is now unprefixed.</li>
+ <li>The Vibration API has been unprefixed.</li>
+ <li>The non-standard <code>Keyboard</code> interface, prefixed as <code>mozKeyboard</code>, now has the <code>Keyboard.setSelectedOption()</code> and <code>Keyboard.setValue()</code> methods, as well as the <code>Keyboard.onfocuschange</code>. <em>This interface, only available for Firefox OS, has been removed in Firefox 31.</em></li>
+ <li>The <a href="https://developer.mozilla.org/en-US/docs/LiveConnect_Reference/java" title="/en-US/docs/LiveConnect_Reference/java"><code>java</code></a> and <a href="https://developer.mozilla.org/en-US/docs/LiveConnect_Reference/Packages" title="/en-US/docs/LiveConnect_Reference/Packages"><code>Packages</code></a> global objects have been removed. See <a href="https://developer.mozilla.org/en-US/docs/LiveConnect" title="/en-US/docs/LiveConnect">LiveConnect</a>.</li>
+ <li>The <code>CSSRule.type</code> associated with {{domxref("CSSNamespaceRule")}} has been updated from <code>UNKNOWN_RULE</code> (<code>0</code>) to <code>NAMESPACE_RULE</code> (<code>10</code>) (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=765590" title="https://bugzilla.mozilla.org/show_bug.cgi?id=765590">bug 765590</a>).</li>
+ <li>WebSMS API: {{domxref("SmsRequest")}} has been superseded by the more general {{domxref("DOMRequest")}}.</li>
+ <li>The non-standard {{domxref("Element.scrollTopMax")}} and {{domxref("Element.scrollLeftMax")}} read-only properties have been added ({{bug(766937)}}).</li>
+ <li>The second parameter of {{domxref("Blob.blob", "Blob()")}}, when set to <code>null</code> or <code>undefined</code>, is now being handled as an empty dictionary ({{bug(7691119)}}).</li>
+</ul>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number" title="JavaScript/Reference/Global_Objects/Number"><code>Number</code></a> objects now offer <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite">isFinite</a>()</code>, <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toInteger">toInteger</a>()</code>, and <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger">isInteger</a>()</code> methods. (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=761480">bug 761480</a>, <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=761495">bug 761495</a>)</li>
+ <li>The Harmony <a href="http://wiki.ecmascript.org/doku.php?id=harmony:spread" title="http://wiki.ecmascript.org/doku.php?id=harmony:spread">spread operator</a> is now supported in <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array" title="JavaScript/Reference/Global_Objects/Array"><code>Array</code></a> initializers (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=574130">bug 574130</a>). Note it is not yet supported in calls (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=762363" title="https://bugzilla.mozilla.org/show_bug.cgi?id=762363">bug 762363</a>).</li>
+ <li>The experimental {{jsxref("TypedArray.prototype.move()")}} method has been added (available in Aurora and Nightly channels only) ({{bug(730873)}}).</li>
+</ul>
+
+<h3 id="WebGL">WebGL</h3>
+
+<p><em>No change</em></p>
+
+<h3 id="SVG">SVG</h3>
+
+<p><em>No change</em></p>
+
+<h3 id="MathML">MathML</h3>
+
+<p> </p>
+
+<ul>
+ <li>The <code>lspace</code> and <code>rspace</code> attributes of {{MathMLElement("mo")}} now correctly default to <code>thickmathspace</code>.</li>
+</ul>
+
+<p> </p>
+
+<h3 id="网络">网络</h3>
+
+<p> </p>
+
+<h3 id="Developer_tools">Developer tools</h3>
+
+<p> </p>
+
+<ul>
+ <li>There's now a handy developer toolbar you can access by going to Tools &gt; Web Developer &gt; Developer Toolbar, or by pressing Ctrl-Shift-V (Cmd-Opt-V on Mac OS X). This toolbar offers a command line interface as well as buttons for quickly accessing useful tools. The graphical command line interface (<a href="https://developer.mozilla.org/en-US/docs/Tools/GCLI" title="Tools/GCLI">GCLI</a>) is easy to expand and additional commands are expected in the future. Type "help" to get a list of supported commands.</li>
+ <li>The Web Console now displays an error count so you can quickly see how much work you have ahead of you.</li>
+ <li>The Scratchpad now offers a list of recently opened files.</li>
+</ul>
+
+<p> </p>
+
+<p> </p>
+
+<h2 id="Changes_for_Open_Web_App_developers">Changes for Open Web App developers</h2>
+
+<ul>
+ <li>Initial <a href="https://developer.mozilla.org/en-US/docs/Apps/Getting_Started">Open Web App support</a> has been implemented in the desktop versions of Firefox (that is, on Windows, Mac OS X, and Linux).</li>
+</ul>
+
+<h2 id="附加组件开发变更">附加组件开发变更</h2>
+
+<h3 id="修改接口">修改接口</h3>
+
+<p>{{interface("nsIPrivateDOMEvent")}} has been merged into {{interface("nsIDOMEvent")}}. ({{bug("761613")}})</p>
+
+<h4 id="新增接口">新增接口</h4>
+
+<h4 id="废弃接口">废弃接口</h4>
diff --git a/files/zh-cn/mozilla/firefox/releases/17/index.html b/files/zh-cn/mozilla/firefox/releases/17/index.html
new file mode 100644
index 0000000000..176604bdc7
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/17/index.html
@@ -0,0 +1,146 @@
+---
+title: Firefox 17 for developers
+slug: Mozilla/Firefox/Releases/17
+tags:
+ - Firefox
+ - Firefox 17
+translation_of: Mozilla/Firefox/Releases/17
+---
+<div>{{FirefoxSidebar}}</div>
+
+<p>Firefox 17 shipped on November 20, 2012. This article lists key changes that are useful for not only web developers, but also Firefox and Gecko developers as well as add-on developers.</p>
+
+<h2 id="WEB开发者需要注意的变化">WEB开发者需要注意的变化</h2>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>支持了{{HTMLElement("iframe")}}元素的{{htmlattrxref("sandbox", "iframe") }} 属性 ({{ bug("341604") }})</li>
+</ul>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>支持了定义在 <a href="http://dev.w3.org/csswg/css3-conditional/" title="http://dev.w3.org/csswg/css3-conditional/">CSS3 Conditional Rules specification</a>中的{{ cssxref("@supports") }} at-rule. (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=649740" title="https://bugzilla.mozilla.org/show_bug.cgi?id=649740">bug 649740</a>)</li>
+ <li>支持了CSS4级选择器中的{{ cssxref(":dir", ":dir()") }}伪类,该伪类允许基于元素的方向性来选择元素. (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=562169" title="https://bugzilla.mozilla.org/show_bug.cgi?id=562169">bug 562169</a>)</li>
+ <li>支持了CSS {{ cssxref("unicode-bidi") }} 属性中新添加的<code>isolate-override</code> 属性值. (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=774335" title="https://bugzilla.mozilla.org/show_bug.cgi?id=774335">bug 774335</a>)</li>
+ <li>我们的带前缀版本的{{ cssxref("box-sizing") }}现在考虑到了{{ cssxref("min-height") }}和{{ cssxref("max-height") }}的影响.马上就要去掉前缀了. ({{bug("308801")}})</li>
+</ul>
+
+<h3 id="DOM">DOM</h3>
+
+<ul>
+ <li>支持了定义在 <a href="http://dev.w3.org/csswg/css3-conditional/" title="http://dev.w3.org/csswg/css3-conditional/">CSS3 Conditional Rules specification</a> 中的{{ domxref("CSSSupportsRule") }} 接口. (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=649740" title="https://bugzilla.mozilla.org/show_bug.cgi?id=649740">bug 649740</a>)</li>
+ <li>支持了 {{ domxref("WheelEvent") }} 对象和 <code>wheel</code>事件 ({{ bug("719320") }}).</li>
+ <li>在linux上又一次支持了DOM Meta 键 ({{bug("751749")}}).</li>
+ <li>On {{domxref("HTMLMediaElement")}}, a new method, <code>mozGetMetadata</code>, that returns a javascript object whose properties represent metadata from the playing media resource as {key: value} pairs ({{bug("763010")}}).</li>
+ <li>Support for {{domxref("Range.intersectsNode")}} has been added again; it has been removed in Gecko 1.9 ({{bug("579638")}}.</li>
+ <li>{{domxref("Range.compareBoundaryPoints()")}} now throws a {{domxref("DOMException")}} with the <code>NOT_SUPPORTED_ERR</code> value when the comparison method is invalid ({{bug("714279")}}) .</li>
+ <li>{{domxref("Event.initEvent()")}} has been adapted to the spec: it doesn't throw anymore if called after the dispatch of the event, it is only a no-op ({{bug(768310)}}).</li>
+ <li>The non-standard {{domxref("XMLHttpRequest", "XMLHttpRequest.onuploadrequest")}} property has been removed ({{bug(761278)}}).</li>
+ <li>The method {{domxref("XMLHttpRequest.getAllResponseHeaders()")}} now separates them with a CRLF (instead of a LF), as requested by the spec ({{bug(730925)}}).</li>
+</ul>
+
+<p> </p>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li>支持了Harmony中<a href="/zh-CN/docs/JavaScript/Reference/Global_Objects/String"><code>String</code></a>对象的<code>startsWith</code>, <code>endsWith</code>, 以及 <code>contains</code> 方法. (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=772733" title="https://bugzilla.mozilla.org/show_bug.cgi?id=772733">bug 772733</a>)</li>
+ <li>The String methods <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/link" title="JavaScript/Reference/Global_Objects/String/link">link</a> and <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/anchor" title="JavaScript/Reference/Global_Objects/String/anchor">anchor</a> now escape the <code>'<strong>"</strong>'</code> (quotation mark) ({{bug("352437")}}).</li>
+ <li>实验性的支持了strawman <a href="../../zh-cn/docs/JavaScript/Reference/Global_Objects/ParallelArray" title="/zh-cn/docs/JavaScript/Reference/Global_Objects/ParallelArray"><code>ParallelArray</code></a>对象. ({{ bug("778559") }})</li>
+ <li>支持了遍历 <code><a href="../../zh-cn/docs/JavaScript/Reference/Global_Objects/Map" title="/zh-cn/docs/JavaScript/Reference/Global_Objects/Map">Map</a></code>/<code><a href="../../zh-cn/docs/JavaScript/Reference/Global_Objects/Set" title="/zh-cn/docs/JavaScript/Reference/Global_Objects/Set">Set</a></code>. ({{ bug("725909") }})</li>
+ <li>在web页面上默认禁用<a href="../../zh-cn/docs/E4X" title="/zh-cn/docs/E4X">E4X</a>({{ bug("778851") }})</li>
+ <li><code>__exposedProps__</code> must now be set for Chrome JavaScript objects exposed to content. Attempts to access Chrome objects from content without <code>__exposedProps__</code> set will fail silently ({{bug("553102")}}).</li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of"><code>for..of</code></a> loops now work in terms of <code>.iterator()</code> and <code>.next()</code> ({{bug(725907)}}).</li>
+</ul>
+
+<h3 id="WebGL">WebGL</h3>
+
+<p> </p>
+
+<ul>
+ <li>The {{domxref("EXT_texture_filter_anisotropic")}} WebGL extension has been unprefixed. Using <code>"MOZ_EXT_texture_filter_anisotropic"</code> will present a warning from now on. The prefixed name is going to be removed in a future release ({{bug(776001)}}).</li>
+</ul>
+
+<p> </p>
+
+<h3 id="SVG">SVG</h3>
+
+<p><em>No change.</em></p>
+
+<h3 id="MathML">MathML</h3>
+
+<p> </p>
+
+<ul>
+ <li>The parsing of the <code>align</code> attribute on {{MathMLElement("mtable")}} elements has been updated to treat optional spaces more correctly.</li>
+</ul>
+
+<p> </p>
+
+<h3 id="XUL">XUL</h3>
+
+<ul>
+ <li>XUL <a href="/zh-CN/docs/XUL/key" title="/zh-CN/docs/XUL/key">key</a> 元素支持了 "os" 修饰符,也就是Win键(Super键或者Hyper键) ({{bug("751749")}}).</li>
+</ul>
+
+<h3 id="网络">网络</h3>
+
+<p> </p>
+
+<ul>
+ <li>Removed the the non-standard feature <code>XMLHttpRequest.onuploadprogress</code> which was deprecaed in Firefox 14.</li>
+</ul>
+
+<p> </p>
+
+<h3 id="开发者工具">开发者工具</h3>
+
+<p> </p>
+
+<ul>
+ <li>Change JSTerm's $ helper function from getElementById to querySelector() ({{bug("751749")}}).</li>
+</ul>
+
+<h3 id="User_Agent">User Agent</h3>
+
+<p>The Gecko part of the user agent string changed. The build date (which hadn't been updated since 2010) was removed, and the Gecko version number was put in its place instead. So <code>Gecko/20100101</code> -&gt; <code>Gecko/17.0</code>. This may affect you if you are doing user agent sniffing.</p>
+
+<h2 id="附加组件和Mozilla开发者需要注意的变化">附加组件和Mozilla开发者需要注意的变化</h2>
+
+<h3 id="接口变化">接口变化</h3>
+
+<dl>
+ <dt>{{ interface("nsIInputStream") }}</dt>
+ <dd><code>available()</code> 方法返回一个64位的长度而不是32位的. ({{bug("215450")}})</dd>
+ <dt>{{ interface("nsIDOMWindowUtils") }}</dt>
+ <dd><code>sendMouseScrollEvent()方法被</code><code>sendWheelEvent()替换</code>. ({{bug("719320")}})</dd>
+ <dt>{{interface("nsIFilePicker")}}</dt>
+ <dd>The <code>open()</code> method, to open the file dialog asynchronously, has been added and the <code>show()</code> method has been deprecated ({{bug("731307")}}).</dd>
+ <dt>{{interface("nsIScriptSecurityManager")}}</dt>
+ <dd>The <code>checkLoadURIStr()</code> and <code>checkLoadURI()</code> methods have been removed ({{bug("327244")}}).</dd>
+ <dt>{{interface("nsIRefreshURI")}}</dt>
+ <dd>The <code>setupRefreshURIFromHeader()</code> method has a added <code>principal</code> parameter ({{bug("327244")}}).</dd>
+</dl>
+
+<h4 id="新增接口">新增接口</h4>
+
+<p><em>None.</em></p>
+
+<h4 id="移除接口">移除接口</h4>
+
+<p><em>None removed.</em></p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="http://www.mozilla.org/en-US/firefox/17.0/releasenotes/">Firefox 17 Release Notes</a></li>
+ <li><a href="https://hacks.mozilla.org/2012/08/aurora-17-is-out/">Aurora 17 it out, bringing better security and support for new standards</a> (Mozilla Hacks)</li>
+ <li><a href="https://www.fxsitecompat.com/en-US/versions/17/">Site Compatibility for Firefox 17</a></li>
+ <li><a href="https://blog.mozilla.org/addons/2012/11/08/compatibility-for-firefox-17/">Add-on Compatibility for Firefox 17</a> (Add-ons Blog)</li>
+</ul>
+
+<h3 id="Older_versions">Older versions</h3>
+
+<p>{{Firefox_for_developers('16')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/18/index.html b/files/zh-cn/mozilla/firefox/releases/18/index.html
new file mode 100644
index 0000000000..9854df7bf7
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/18/index.html
@@ -0,0 +1,82 @@
+---
+title: Firefox 18 for developers
+slug: Mozilla/Firefox/Releases/18
+translation_of: Mozilla/Firefox/Releases/18
+---
+<div>{{FirefoxSidebar}}</div><p>Firefox 18已于2013年1月8日发布.</p>
+<h2 id="WEB开发者需要注意的变化">WEB开发者需要注意的变化</h2>
+<h3 id="HTML">HTML</h3>
+<ul>
+ <li>实现了{{HTMLElement("ol")}}元素上的{{htmlattrxref("reversed","ol")}}属性({{bug("601912")}}).</li>
+ <li>实现了{{HTMLElement("link")}}元素上的{{htmlattrxref("crossorigin","link")}}属性({{bug("786564")}}).</li>
+</ul>
+<h3 id="CSS">CSS</h3>
+<ul>
+ <li>{{cssxref("min-width")}}和{{cssxref("min-height")}}属性使用<code>auto关键字作为初始值</code>(This has an effect only on flex items as it resolves to <code>0</code>, the previous initial value, for other items). ({{bug("763689")}})</li>
+ <li>The cascade has been updated: now author <code>!important</code> rules override <a href="/zh-CN/docs/CSS/Using_CSS_animations" title="/zh-CN/docs/CSS/Using_CSS_animations">CSS animations</a>. ({{bug("783714")}})</li>
+ <li>{{cssxref("background")}}简写属性可以包含CSS3中的{{cssxref("background-size")}}属性了. ({{bug("570326")}})</li>
+ <li>初步实现了Flexbox.默认禁用状态,可以通过设置<code>layout.css.flexbox.enabled</code>选项激活该特性.({{bug('666041')}})</li>
+</ul>
+<h3 id="DOM">DOM</h3>
+<ul>
+ <li><code>实现了navigator.mozPay属性</code>({{bug("767818")}})</li>
+ <li><code>实现了window.devicePixelRatio属性</code>. ({{bug("564815")}})</li>
+ <li>在MacOS上实现了<code>window.navigator.battery属性</code>. ({{bug("696045")}})</li>
+ <li>删除了{{domxref("BlobBuilder", "MozBlobBuilder")}}.开发者们应该使用{{domxref("Blob")}}构造函数来创建<code>Blob对象</code>. ({{bug("744907")}})</li>
+ <li>{{event("visibilitychange")}}事件和<a href="/zh-CN/docs/DOM/Using_the_Page_Visibility_API" title="/zh-CN/docs/DOM/Using_the_Page_Visibility_API">页面可见性API</a>取消前缀{{bug("812086")}}).</li>
+ <li><code>实现了TextDecoder</code>和<code>TextEncoder</code> .({{bug("764234")}})</li>
+ <li><code>HTMLMediaElement</code><code>.src</code>被分成了两个属性:一个是标准的<code>src属性</code>,返回普通的字符串{{domxref("DOMString")}},另一个是带前缀的<code>mozSrcObject</code>属性,返回<a href="/zh-CN/docs/WebRTC/MediaStream_API" title="/zh-CN/docs/WebRTC/MediaStream_API">media streams</a> ({{bug("792665")}}).</li>
+</ul>
+<h3 id="JavaScript">JavaScript</h3>
+<ul>
+ <li>实现了EcmaScript 6中的<a href="/zh-CN/docs/JavaScript/Reference/Global_Objects/Proxy">直接代理</a>({{bug("703537")}}).警告:该实现包含了一些已知的bug,以及未根据最新规范草案实现某些特性.不要在生产环境中使用它.</li>
+ <li>实现了ECMAScript 6中的字符串方法<code>contains()</code>.</li>
+</ul>
+<h3 id="WebGL">WebGL</h3>
+<h3 id="SVG">SVG</h3>
+<h3 id="MathML">MathML</h3>
+<h3 id="XUL">XUL</h3>
+<h3 id="网络">网络</h3>
+<ul>
+ <li>HTTP请求头<code>Accept-Language可以使用两位数字的质量因子</code>("q-values")({{bug("672448")}}).</li>
+ <li>HTTP响应头支持了<a href="/zh-CN/docs/The_X-FRAME-OPTIONS_response_header" title="/zh-CN/docs/The_X-FRAME-OPTIONS_response_header"><code>X-FRAME-OPTIONS</code></a>中的<code>ALLOW-FROM</code>语法({{bug("690168")}}).</li>
+</ul>
+<h3 id="开发者工具">开发者工具</h3>
+<h2 id="附加组件和Mozilla开发者需要注意的变化">附加组件和Mozilla开发者需要注意的变化</h2>
+<h3 id="接口变更">接口变更</h3>
+<dl>
+ <dt>
+ {{ interface("nsIStreamListener") }}</dt>
+ <dd>
+ <code>onDataAvailable()</code>方法的第四个参数(aOffset)类型改为无符号长整型. ({{bug("784912")}})</dd>
+ <dt>
+ {{ interface("nsIUploadChannel") }}</dt>
+ <dd>
+ <code>setUploadStream()支持了超过</code>2GB大小的content-length ({{bug("790617")}})</dd>
+ <dt>
+ {{ interface("nsIEditor") }}</dt>
+ <dd>
+ <code>删除了addEditorObserver()</code>,使用<code>setEditorObserver()</code>来替代, <code>removeEditorObserver()</code>不再需要一个{{ interface("nsIEditorObserver") }}参数({{bug("785091")}})</dd>
+</dl>
+<dl>
+ <dt>
+ {{ interface("nsIHttpProtocolHandler") }}</dt>
+ <dd>
+ <code>http-on-modify-request</code> observers are no longer guaranteed to be called synchronously during<br>
+ <code>nsIChannel.asyncOpen(). </code>For observers that need to be called during <code>asyncOpen</code>(), the new <code>http-on-opening-request</code> observer topic has been added. ({{bug("800799")}})</dd>
+</dl>
+<h4 id="新增接口">新增接口</h4>
+<h4 id="移除接口">移除接口</h4>
+<p>下面的接口已经被移除.</p>
+<ul>
+ <li>{{ interface("nsIEditorObserver") }}</li>
+</ul>
+<h2 id="相关链接">相关链接</h2>
+<ul>
+ <li><a href="http://www.mozilla.org/zh-CN/firefox/18.0/releasenotes/">Firefox 18发行说明</a></li>
+ <li><a href="https://hacks.mozilla.org/2012/10/aurora-18-hidpi-touch-events/">Aurora 18: HiDPI &amp; Touch Events</a> (Mozilla Hacks)</li>
+ <li><a href="/zh-CN/docs/Site_Compatibility_for_Firefox_18">Firefox 18网站兼容性</a></li>
+ <li><a href="https://blog.mozilla.org/addons/2012/12/28/compatibility-for-firefox-18/">Firefox 18附加组件兼容性</a></li>
+</ul>
+<h3 id="更早版本">更早版本</h3>
+<p>{{Firefox_for_developers('17')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/19/index.html b/files/zh-cn/mozilla/firefox/releases/19/index.html
new file mode 100644
index 0000000000..670c6f9f18
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/19/index.html
@@ -0,0 +1,76 @@
+---
+title: Firefox 19 for developers
+slug: Mozilla/Firefox/Releases/19
+translation_of: Mozilla/Firefox/Releases/19
+---
+<div>{{FirefoxSidebar}}</div><p>Firefox 19已于2013年2月19日正式发布.</p>
+
+<h2 id="Web开发者需要注意的变化">Web开发者需要注意的变化</h2>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li><code><a href="/zh-CN/docs/JavaScript/Reference/Global_Objects/Map" title="JavaScript/Reference/Global_Objects/Map">Map</a></code> 和 <code><a href="/zh-CN/docs/JavaScript/Reference/Global_Objects/Set" title="JavaScript/Reference/Global_Objects/Set">Set</a></code> 对象的 <code>size()</code> 方法变成了 <code>size</code> 属性. ({{bug("807001")}})</li>
+ <li><code><a href="/zh-CN/docs/JavaScript/Reference/Global_Objects/Map" title="JavaScript/Reference/Global_Objects/Map">Map</a></code> 和 <code><a href="/zh-CN/docs/JavaScript/Reference/Global_Objects/Set" title="JavaScript/Reference/Global_Objects/Set">Set</a></code> 对象新增了一个 clear() 方法. ({{bug("805003")}})</li>
+</ul>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>支持了几个 viewport-relative 的 {{cssxref("&lt;length&gt;")}} 单位: <code>vh</code>, <code>vw</code>, <code>vmin</code> 以及 <code>vmax</code> ({{bug("503720")}})</li>
+ <li>CSS Flexbox 脱前缀,但仍然被默认禁止 ({{bug("801098")}}).</li>
+ <li><code>-moz-initial</code> 脱前缀 ({{bug("806068")}}).不过 <code>-moz-initial</code> 仍然会作为别名保留一段时间,但仍然推荐你尽快改用 <code>initial</code>.</li>
+ <li>{{cssxref("text-transform")}} 属性现在支持了 <code>full-width</code> 关键字, which allows a more seamless inclusion of Latin characters in text using ideographic fixed-width characters, like Chinese or Japanese ({{bug("774560")}}).</li>
+ <li>实现了 {{cssxref("page-break-inside")}} ({{bug("685012")}}).</li>
+ <li>{{cssxref("calc", "calc()")}} 函数可以使用在 <code>&lt;color-stop&gt;</code> 上( {{cssxref("&lt;gradient&gt;")}}上的一个值).</li>
+ <li>实现了 {{cssxref("@page")}} @规则 ({{bug("115199")}}).但是 {{cssxref(":first")}}, {{cssxref(":right")}}, {{cssxref(":left")}} 仍没实现.</li>
+ <li>{{cssxref(":-moz-placeholder")}} 伪类替换成 {{cssxref("::-moz-placeholder")}} 伪元素 ({{bug("737786")}}).</li>
+</ul>
+
+<h3 id="DOM">DOM</h3>
+
+<ul>
+ <li>{{domxref("element.getElementsByTagName")}} 方法开始返回 <code>HTMLCollection</code> 对象,而不是以前的<code> NodeList 对象</code>. ({{bug("799464")}}).</li>
+ <li>实现了 {{domxref("File")}} 对象的 <code>mozLastModifiedDate</code> 属性. ({{bug("793955")}})</li>
+ <li>当 {{domxref("File")}} 对象的最后修改时间无法获取到时,它的 lastModifiedDate 属性会返回当前日期. ({{bug("793459")}}</li>
+ <li>实现了 {{domxref("CanvasRenderingContext2D")}}对象的 <code>isPointInStroke</code> 方法. ({{bug("803124")}}).</li>
+ <li>实现了 {{domxref("HTMLCanvasElement")}} 对象的 <code>toBlob</code> 方法 ({{bug("648610")}}).</li>
+ <li>{{domxref("Node.isSupported")}} 和 {{domxref("document.implementation", "document.implementation.hasFeature()")}} 方法会总是放回 <code>true</code> ({{bug("801425")}}).</li>
+ <li>当调用 <code>document.createElement(null)时</code>, <code>null</code> 会被转换成字符串,就像执行了 <code>document.createElement("null")</code>.</li>
+</ul>
+
+<h3 id="XForms">XForms</h3>
+
+<p><a href="http://www.philipp-wagner.com/blog/2011/07/the-future-of-mozilla-xforms/" title="http://www.philipp-wagner.com/blog/2011/07/the-future-of-mozilla-xforms/"><strong>删除</strong></a>了对<a href="/zh-CN/docs/XForms" title="XForms">XForms</a>的支持.</p>
+
+<h2 id="附加组件和Mozilla开发者需要注意的变化">附加组件和Mozilla开发者需要注意的变化</h2>
+
+<div class="note">
+<p><strong>注:</strong> A key change in Firefox 19 is that <a href="/zh-CN/docs/XPCOM_API_Reference/nsresult" title="XPCOM_API_Reference/nsresult"><code>nsresult</code></a> is now strongly typed. This will help make it easier to detect bugs that are caused by mishandling of return values, but may cause existing code to break if it's making incorrect assumptions in this regard.</p>
+</div>
+
+<ul>
+ <li><code>getBrowserSelection()</code> now returns the selected text in a text input field. As a result, <code>gContextMenu.isTextSelected</code> will be <code>true</code> when the user selects text in a text input field that is not a password field. ({{bug("565717")}})</li>
+ <li><a href="/zh-CN/docs/Mozilla/JavaScript_code_modules/Dict.jsm" title="Mozilla/JavaScript_code_modules/Dict.jsm">Dict.jsm</a>: <a href="/zh-CN/docs/Mozilla/JavaScript_code_modules/Dict.jsm#Creating_a_dictionary" title="Mozilla/JavaScript_code_modules/Dict.jsm#Creating_a_dictionary"><code>Dict()</code></a> now takes a JSON String. <a href="/zh-CN/docs/Mozilla/JavaScript_code_modules/Dict.jsm#toJSON()" title="Mozilla/JavaScript_code_modules/Dict.jsm#toJSON()"><code>Dict.toJSON()</code></a> was added, and it returns a JSON String. ({{bug("727967")}})</li>
+</ul>
+
+<h3 id="接口变化">接口变化</h3>
+
+<dl>
+ <dt>{{interface("nsIImgLoadingContent")}}</dt>
+ <dd>The parameter (aObserver) of <code>addObserver()</code> method changes from {{interface("imgIDecoderObserver")}} to {{interface("imgINotificationObserver")}}. The <code>notify()</code> method of {{interface("imgINotificationObserver")}} is not scriptable, so you need to use <code>createScriptedObserver()</code> from {{interface("imgITools")}}.</dd>
+ <dt>{{interface("nsIChannel")}}</dt>
+ <dd> <code>contentLength</code> 属性的类型由<code> long</code> 改成 <code>int64_t</code>.</dd>
+</dl>
+
+<h2 id="相关链接">相关链接</h2>
+
+<ul>
+ <li><a href="http://www.mozilla.org/zh-CN/firefox/19.0/releasenotes/">Firefox 19 发行说明</a></li>
+ <li><a href="/zh-CN/docs/Site_Compatibility_for_Firefox_19">Firefox 19 网站兼容性</a></li>
+ <li><a href="https://blog.mozilla.org/addons/2013/02/07/compatibility-for-firefox-19/">Firefox 19 附加组件兼容性</a></li>
+</ul>
+
+<h3 id="更早版本">更早版本</h3>
+
+<div>{{Firefox_for_developers('18')}}</div>
diff --git a/files/zh-cn/mozilla/firefox/releases/20/index.html b/files/zh-cn/mozilla/firefox/releases/20/index.html
new file mode 100644
index 0000000000..117426208d
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/20/index.html
@@ -0,0 +1,47 @@
+---
+title: Firefox 20 for developers
+slug: Mozilla/Firefox/Releases/20
+translation_of: Mozilla/Firefox/Releases/20
+---
+<div>{{FirefoxSidebar}}</div><p>Firefox 20正式版发布于<time datetime="2013-04-02">2013年4月2日.</time></p>
+<h2 id="Web开发者需要注意的变化">Web开发者需要注意的变化</h2>
+<h3 id="HTML">HTML</h3>
+<ul>
+ <li>实现了{{HTMLElement("a")}}和{{HTMLElement("area")}}元素上的{{htmlattrxref("download", "a") }}属性({{bug("676619")}}).</li>
+ <li><a href="/zh-CN/docs/HTML/Global_attributes" title="/zh-CN/docs/HTML/Global_attributes">全局属性</a> <a href="/zh-CN/docs/HTML/Global_attributes#attr-dir" title="/zh-CN/docs/HTML/Global_attributes"><code>dir</code></a> 的值开始支持 <code>auto</code> ({{bug("548206")}}).</li>
+</ul>
+<h3 id="JavaScript">JavaScript</h3>
+<ul>
+ <li>实现了<code><a href="/zh-CN/docs/JavaScript/Reference/Global_Objects/WeakMap" title="/zh-CN/docs/JavaScript/Reference/Global_Objects/WeakMap">Weakmap</a>.prototype.clear()</code>方法 ({{bug("814562")}}).</li>
+ <li>实现了<code><a href="/zh-CN/docs/JavaScript/Reference/Global_Objects/Math/imul" title="/zh-CN/docs/JavaScript/Reference/Global_Objects/Math/imul">Math.imul()</a></code>方法,可以进行C风格的32位整数乘法运算.还不属于harmony (EcmaScript 6)提案,所以是非标准的({{bug("808148")}}).</li>
+ <li>Web apps using draggable text with Kinetic 3.x are working, even when using the Cairo canvas backend. ({{bug("835064")}})</li>
+ <li>E4X规范中的<a href="/zh-CN/docs/JavaScript/Reference/Statements/for_each...in" title="/zh-CN/docs/JavaScript/Reference/Statements/for_each...in">for each...in</a>语句被废弃,请使用ES6中的<a href="/zh-CN/docs/JavaScript/Reference/Statements/for...of" title="/zh-CN/docs/JavaScript/Reference/Statements/for...of">for...of</a>语句代替 ({{Bug("804834")}}).</li>
+</ul>
+<h3 id="CSS">CSS</h3>
+<ul>
+ <li><a href="/zh-CN/docs/CSS/Using_CSS_flexible_boxes" title="/zh-CN/docs/CSS/Using_CSS_flexible_boxes">CSS Flexbox</a>默认开启,不需要设置about:config.</li>
+ <li>实现了<a href="https://dvcs.w3.org/hg/FXTF/raw-file/tip/masking/index.html" title="https://dvcs.w3.org/hg/FXTF/raw-file/tip/masking/index.html">CSS Masking specification</a>中的<code>mask-type属性</code>({{bug("793617")}}).</li>
+</ul>
+<h3 id="DOM">DOM</h3>
+<ul>
+ <li>{{domxref("HTMLMediaElement")}}支持可<code>playbackRate</code>属性(both read and write), with pitch correction. Pitch correction can be controlled using the property <code>mozPreservesPitch</code> ({{bug('495040')}}).</li>
+ <li>CSSOM: 实现了新的{{domxref("CSSGroupingRule")}}和{{domxref("CSSConditionRule")}} ({{bug("814907")}}).</li>
+ <li>CSSOM:{{domxref("CSSRule")}}上的常量<span id="summary_alias_container"><span id="short_desc_nonedit_display">CSSRule.MOZ_KEYFRAME_RULE</span></span>和<span id="summary_alias_container"><span id="short_desc_nonedit_display">CSSRule.MOZ_KEYFRAMES_RULE</span></span>去掉前缀成为了<span id="summary_alias_container"><span id="short_desc_nonedit_display">CSSRule.KEYFRAME_RULE</span></span>和<span id="summary_alias_container"><span id="short_desc_nonedit_display">CSSRule.KEYFRAMES_RULE</span></span>.带前缀的版本仍暂时保留让开发者过度他们的代码{{bug("816431")}}).</li>
+ <li>CSSOM: 现在可以设置{{domxref("CSSMediaRule")}}上的<code>conditionText属性的值</code> ({{bug("815021")}}).</li>
+ <li>{{domxref("DOMParser")}}上的 <code>parseFromStream和</code><code>parseFromBuffer</code>方法在web页面上被禁用.({{bug('816410')}}).</li>
+ <li><code><a href="/zh-CN/docs/XMLSerializer">XMLSerializer</a></code>上的<code>serializeToStream</code>方法在web页面上被禁用.({{bug('816410')}}).</li>
+ <li><code>TextDecoder</code>和<code>TextEncoder</code>接口可以在Worker中使用 ({{bug('795542')}}).</li>
+ <li>实现了<code>CSS.supports()方法</code>({{bug("779917")}}).</li>
+ <li>实现了<code>UndoManager</code>({{bug("617532")}}).</li>
+</ul>
+<h2 id="附加组件和Mozilla开发者需要注意的变化">附加组件和Mozilla开发者需要注意的变化</h2>
+<ul>
+ <li>移除了nsIDOMParserJS接口{{bug('816410')}}.使用<a href="/zh-CN/docs/nsIDOMParser" title="/zh-CN/docs/nsIDOMParser">nsIDOMParser</a>来代替.</li>
+</ul>
+<h2 id="相关链接">相关链接</h2>
+<ul>
+ <li><a href="http://www.mozilla.org/zh-CN/firefox/20.0a1/nightlynotes/">Firefox 20 Aurora Release Notes</a></li>
+ <li><a href="/zh-CN/docs/Site_Compatibility_for_Firefox_20">Site Compatibility for Firefox 20</a></li>
+</ul>
+<h3 id="更早版本">更早版本</h3>
+<p>{{Firefox_for_developers('19')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/21/index.html b/files/zh-cn/mozilla/firefox/releases/21/index.html
new file mode 100644
index 0000000000..9d0788dfa6
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/21/index.html
@@ -0,0 +1,107 @@
+---
+title: Firefox 21 for developers
+slug: Mozilla/Firefox/Releases/21
+translation_of: Mozilla/Firefox/Releases/21
+---
+<div>{{FirefoxSidebar}}</div><h2 id="Web开发者需要注意的变化">Web开发者需要注意的变化</h2>
+<h3 id="HTML">HTML</h3>
+<ul>
+ <li>实现了{{HTMLElement("style")}}元素上的{{htmlattrxref("scoped", "style")}}属性.拥有该属性的{{HTMLElement("style")}}元素可以通过在Firefox 20中实现的CSS伪类{{cssxref(":scope")}}选择器选择到.({{bug("508725")}}).</li>
+ <li>实现了新的{{HTMLElement("main")}}元素({{bug("820508")}}).</li>
+</ul>
+<h3 id="JavaScript">JavaScript</h3>
+<ul>
+ <li><a href="/zh-CN/docs/E4X" title="/zh-CN/docs/E4X">E4X</a>,一个古老的JavaScript扩展(ECMA-357),已经被删除.因为一直以来,只有Gecko支持它.({{bug("788293")}}).</li>
+ <li><a href="https://developer.mozilla.org/zh-CN/docs/JavaScript/Reference/Global_Objects/parseInt" title="/zh-CN/docs/">parseInt</a>不再将以"0"开头的字符串作为8进制数字来解析({{bug("786135")}}).</li>
+</ul>
+<h3 id="CSS">CSS</h3>
+<ul>
+ <li>{{cssxref("user-select", "-moz-user-select")}}属性的属性值在设置为<code>none时和设置为</code><code>-moz-none时</code><code>效果等同于</code>,这样才能让Gecko和其他内核WebKit(Chrome, Safari),Presto (Opera)以及Trident(Internet Explorer)中的表现相同({{bug("816298")}}).</li>
+ <li>On XHTML content, the <code>auto</code> value of {{cssxref("hyphens", "-moz-hyphens")}} incorrectly applied hyphenation rules when the language was not explicitly declared. This is fixed by ({{bug("702121")}}).</li>
+ <li>CSS属性{{cssxref("-moz-orient")}}现在支持新的值<code>auto</code>.当应用到一个{{HTMLElement("meter")}}元素或者{{HTMLElement("progress")}}元素上时,<code>auto就等同于</code><code>horizontal</code>({{bug("835883")}}).</li>
+</ul>
+<h3 id="DOM">DOM</h3>
+<ul>
+ <li>实现了{{domxref("window.location")}}上的<code>origin</code>属性 ({{bug("828261")}}).</li>
+ <li><code>实现了</code><code>&lt;input type="time"&gt;</code>对象上的<code>valueAsDate</code>和<code>valueAsNumber</code>方法({{bug("781570")}}).</li>
+ <li>实现了<code>&lt;input type="time"&gt;</code>对象上的<code>min</code>和<code>max</code>属性({{bug("781572")}}).</li>
+ <li>Some new keyCodes for volume control are supported ({{bug("674739")}}).</li>
+ <li>Some new keyCodes for ancient keyboard layout such as AS/400 are now supported on Windows and Linux ({{bug("833719")}}).</li>
+ <li>Various keyCode values for OEM sepecific keys on Windows are now supported again ({{bug("833719")}}).</li>
+ <li>实现了<a href="../../../../../zh-CN/docs/DOM/window.crypto.getRandomValues" title="DOM/window.crypto.getRandomValues"><code>window.crypto.getRandomValues</code></a>函数({{bug("440046")}}).</li>
+</ul>
+<h3 id="SVG">SVG</h3>
+<ul>
+ <li>实现了{{cssxref("paint-order")}}属性({{bug("828805")}}).</li>
+</ul>
+<h3 id="网络">网络</h3>
+<ul>
+ <li>更新CSP实现到最新的CSP规范1.0(CR):
+ <ul>
+ <li>Support for the spec-compliant <span id="summary_alias_container"><span id="short_desc_nonedit_display"><code>Content-Security-Policy</code> HTTP header (in addition to the experimental </span></span><span id="summary_alias_container"><span id="short_desc_nonedit_display"><code>X-Content-Security-Policy</code>) has been added ({{bug("783049")}}). <strong>Note</strong>: the patch for this new header landed in Firefox 21, it is disabled on builds</span></span> ({{bug("842657")}}).</li>
+ </ul>
+ </li>
+</ul>
+<h2 id="附加组件和Mozilla开发者需要注意的变化">附加组件和Mozilla开发者需要注意的变化</h2>
+<ul>
+ <li>FUEL applications cannot use the Livemarks service anymore ({{bug("834492")}}). The Livemarks service is deprecated and phased out in favor of the new async interface.</li>
+ <li>History API saw numerous deprecated API being removed:
+ <ul>
+ <li>Replaced by <code>mozIAsyncFavicons</code>:
+ <ul>
+ <li><code>nsIFaviconService::setFaviconUrlForPage</code></li>
+ <li><code>nsIFaviconService::setFaviconData</code></li>
+ <li><code>nsIFaviconService::getFaviconData</code></li>
+ <li><code>nsIFaviconService::getFaviconForPage</code></li>
+ <li><code>nsIFaviconService::setAndLoadFaviconForPage</code></li>
+ <li><code>nsIFaviconService::getFaviconImageForPage</code></li>
+ <li><code>nsIFaviconService::getFaviconDataAsDataURL</code></li>
+ </ul>
+ </li>
+ <li>Replaced by <code>mozIAsyncLivemarks</code>:
+ <ul>
+ <li><code>nsILivemarkService::*</code></li>
+ <li><code>PlacesUtils.itemIsLivemark</code></li>
+ <li><code>PlacesUtils.nodeIsLivemarkContainer</code></li>
+ <li><code>PlacesUtils.nodeIsLivemarkItem</code></li>
+ </ul>
+ </li>
+ <li>Removed only third argument:
+ <ul>
+ <li><code>PlacesUIUtils.showBookmarkDialog</code></li>
+ </ul>
+ </li>
+ <li>No more implemented by Places, use <code>mozIAsyncHistory</code> instead:
+ <ul>
+ <li><code>nsIGlobalHistory2::addURI</code></li>
+ <li><code>nsIGlobalHistory2::isVisited</code></li>
+ <li><code>nsIGlobalHistory2::setPageTitle</code></li>
+ </ul>
+ </li>
+ <li>No more needed, use <code>onDeleteURI</code> or <code>onItemRemoved</code>:
+ <ul>
+ <li><code>nsINavHistoryObserver::OnBeforeDeleteURI</code></li>
+ <li><code>nsINavBookmarkObserver::OnBeforeItemRemoved</code></li>
+ </ul>
+ </li>
+ <li>Never implemented properly:
+ <ul>
+ <li><code>nsINavHistoryFullVisitResultNode</code></li>
+ </ul>
+ </li>
+ <li>Deprecated, use<code> mozIAsyncHistory::updatePlaces</code> instead:
+ <ul>
+ <li><code>nsINavHistoryService::AddVisit</code></li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+</ul>
+<h2 id="相关链接">相关链接</h2>
+<ul>
+ <li><a href="http://www.mozilla.org/zh-CN/firefox/21.0/releasenotes/">Firefox 21发行说明</a></li>
+ <li><a href="../../../../../zh-CN/docs/Site_Compatibility_for_Firefox_21">Firefox 21网站兼容性</a></li>
+ <li><a href="https://blog.mozilla.org/addons/2013/04/26/compatibility-for-firefox-21/">Firefox 21附加组件兼容性</a></li>
+</ul>
+<h3 id="更早版本">更早版本</h3>
+<p>{{Firefox_for_developers('20')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/22/index.html b/files/zh-cn/mozilla/firefox/releases/22/index.html
new file mode 100644
index 0000000000..32177c38da
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/22/index.html
@@ -0,0 +1,89 @@
+---
+title: Firefox 22 for developers
+slug: Mozilla/Firefox/Releases/22
+tags:
+ - Firefox
+ - Firefox 22
+translation_of: Mozilla/Firefox/Releases/22
+---
+<div>{{FirefoxSidebar}}</div><h2 id="Web开发者需要注意的变化">Web开发者需要注意的变化</h2>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>实现了HTML5中的{{HTMLElement("data")}}元素({{bug(839371)}}).</li>
+ <li>The HTML5 {{HTMLElement("time")}} element has been implemented ({{bug(629801)}}).</li>
+ <li>The <code style="font-style: normal;">range</code> state of the {{HTMLElement("input")}} element (<code style="font-style: normal;">&lt;input type="range"&gt;</code>) has been implemented, behind the preference <code style="font-style: normal;">dom.experimental_forms_range</code>, only enabled by default on Nightly and Aurora channel ({{bug(841948)}}).</li>
+ <li>The support for the {{HTMLElement("template")}} element, part of the Web component specification has been implemented ({{bug(818976)}}).</li>
+</ul>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li><a href="http://asmjs.org/spec/latest/" title="http://asmjs.org/spec/latest/">Asm.js </a>optimizations are enabled, making it possible to compile C/C++ applications to a subset of JavaScript for better performance.</li>
+ <li>实现了ES6中的<a href="/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_functions">箭头函数</a>({{bug(846406)}}).</li>
+ <li>The new <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is" title="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is">Object.is</a> function has been added ({{bug(839979)}}).</li>
+ <li><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments">arguments</a></code> in generator expressions is now inherited from enclosing lexical scope ({{bug(848051)}}).</li>
+ <li>The ES2015 Proxy {{jsxref("Global_Objects/Proxy/handler/preventExtensions", "preventExtensions")}} trap have been implemented ({{bug(789897)}}).</li>
+</ul>
+
+<h3 id="DOM">DOM</h3>
+
+<ul>
+ <li>不再支持<code>XMLHttpRequest中的</code><code>multipart属性和</code><code>multipart/x-mixed-replac</code>响应.这是一个Gecko独有的特性,从来没被标准化过.你可以使用<a href="/en-US/docs/Server-sent_events" title="/en-US/docs/Server-sent_events">Server-Sent Events</a>, <a href="/en-US/docs/WebSockets" title="/en-US/docs/WebSockets">Web Sockets</a>或者在progress事件中查看<code>responseText</code>属性的变化来实现同样的效果.</li>
+ <li>实现了<a href="http://notifications.spec.whatwg.org/" title="http://notifications.spec.whatwg.org/">Web Notifications</a> ({{bug(782211)}}).</li>
+ <li>{{domxref("XMLHttpRequest/FormData", "FormData")}}对象的<code>append</code>方法现在开始接受第三个参数<code>filename</code>({{bug(690659)}}).</li>
+ <li>移除了{{domxref("Node.isSupported")}}方法({{bug(801562)}}).</li>
+ <li>{{domxref("Node.setUserData")}} and {{domxref("Node.getUserData")}} has been removed for web content and are deprecated for chrome content ({{bug(842372)}}).</li>
+ <li>The {{domxref("Element.attributes")}} property has been moved there from {{domxref("Node")}} as required by the spec ({{bug("844134")}}).</li>
+ <li>实现了Mac OS X中的{{domxref("DeviceLightEvent", "Ambient Light Events")}}后端.</li>
+ <li>Elements in the HTML namespace with local names {{HTMLElement("bgsound")}}, {{HTMLElement("multicol")}}, and {{HTMLElement("image")}} no longer implement the {{domxref("HTMLSpanElement")}} interface.  {{HTMLElement("bgsound")}} and {{HTMLElement("bgsound")}} implement {{domxref("HTMLUnknownElement")}} and {{HTMLElement("image")}} implements {{domxref("HTMLElement")}}.</li>
+ <li>The {{ domxref("NodeIterator.detach") }} method has been changed to do nothing ({{bug("823549")}}).</li>
+ <li>The {{domxref("BlobEvent")}} interface has been implemented ({{bug("834165")}}).</li>
+ <li>The properties <code>HTMLMediaElement.crossorigin</code> and <code>HTMLInputElement.inputmode</code> has been removed to match the spec in {{domxref("HTMLMediaElement.crossOrigin")}} and <code>HTMLInputElement.inputMode</code>, respectively ({{bug("847370")}} and {{bug("850346")}}).</li>
+ <li>WebRTC: the Media Stream API and Peer Connection API are now supported by default.</li>
+ <li>Web Components: the {{domxref("Document.register")}} method has been implemented ({{bug("783129")}}).</li>
+ <li>The {{domxref("ProgressEvent.initProgressEvent()")}} constructor method has been removed. Uses the standard constructor, {{domxref("ProgressEvent.ProgressEvent", "ProgressEvent()")}} to construc and initialize {{domxref("ProgressEvent")}} ({{bug("843489")}}).</li>
+ <li>Manipulated data associated with a {{event("cut")}}, {{event("copy")}}, or {{event("paste")}} event can now be accessed via the {{domxref("ClipboardEvent.clipboardData")}} property ({{bug("407983")}}).</li>
+ <li>The {{domxref("HTMLTimeElement")}} interface has been implemented ({{bug("629801")}}).</li>
+ <li>When a {{domxref("Worker")}} constructor is passed an invalid URL, it now throws {{domxref("DOMException")}} of type <code>SECURITY_ERR</code> ({{bug("587251")}}).</li>
+</ul>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>Support for <a href="https://developer.mozilla.org/en-US/docs/CSS/Tutorials/Using_CSS_flexible_boxes" title="CSS/Tutorials/Using_CSS_flexible_boxes">CSS Flexbox layout</a> has been enabled by default ({{bug("841876")}}).</li>
+ <li>Following a spec change, the initial value for {{cssxref("min-width")}} and {{cssxref("min-height")}} has been changed back to <code>0</code>, even on flex items ({{bug("848539")}}).</li>
+ <li>Support for CSS Conditionals ({{cssxref("@supports")}} and {{domxref("CSS.supports")}}) has been enabled by default ({{bug("855455")}}).</li>
+ <li>Support for {{cssxref("background-clip")}} and {{cssxref("background-origin")}} properties in the {{cssxref("background")}} shorthand has been implemented ({{bug("570896")}}).</li>
+</ul>
+
+<h2 id="附加组件和Mozilla开发者需要注意的变化">附加组件和Mozilla开发者需要注意的变化</h2>
+
+<ul>
+ <li>移除了下面这些方法中的<code>properties</code>参数: {{ifmethod('nsITreeView','getCellProperties')}}, {{ifmethod('nsITreeView','getColumnProperties')}} and {{ifmethod('nsITreeView','getRowProperties')}} methods of {{interface('nsITreeView')}}. These methods should now return a string of space-separated property names. ({{bug('407956')}})</li>
+ <li>The {{ifmethod('inIDOMUtils', 'getCSSPropertyNames')}} method has been implemented and will return all supported <a href="https://developer.mozilla.org/en-US/docs/CSS/CSS_Reference" title="/en-US/docs/CSS/CSS_Reference">CSS property</a> names.</li>
+ <li>See <a href="https://blog.mozilla.org/addons/2013/06/03/compatibility-for-firefox-22/" title="https://blog.mozilla.org/addons/2013/06/03/compatibility-for-firefox-22/">here </a>for more changes.</li>
+</ul>
+
+<h3 id="Firefox_Developer_Tools">Firefox Developer Tools</h3>
+
+<ul>
+ <li><a href="https://hacks.mozilla.org/2013/04/developer-tools-update-firefox-22/" title="https://hacks.mozilla.org/2013/04/developer-tools-update-firefox-22/">Font inspector</a> shows which fonts on your computer are applied to the page.</li>
+ <li>Visual paint feedback mode shows when and where a page is repainted.</li>
+ <li>The dev tools may now be docked to the right side, not just the bottom of the browser.</li>
+ <li>Some panes within the dev tools have switched from <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=875727" title="https://bugzilla.mozilla.org/show_bug.cgi?id=875727">XUL to HTML</a>. For example, the css rule viewer is now chrome://browser/content/devtools/cssruleview.xhtml, not <code>cssruleview.xul</code>. Instead of adding an overlay directly to extend features of these panes, you may add an overlay and script to the outer xul document, to add load listeners and change these html documents.</li>
+ <li>The stack trace is now shown as a breadcrumb near the top, and the script listing is now at the left panel of the debugger.</li>
+</ul>
+
+<h2 id="相关链接">相关链接</h2>
+
+<ul>
+ <li><a href="http://www.mozilla.org/en-US/firefox/22.0a1/auroranotes/">Firefox 22 Aurora Release Notes</a></li>
+ <li><a href="/en-US/docs/Site_Compatibility_for_Firefox_22">Site Compatibility for Firefox 22</a></li>
+ <li><a href="https://blog.mozilla.org/addons/2013/06/03/compatibility-for-firefox-22/">Add-on Compatibility for Firefox 22</a></li>
+</ul>
+
+<h3 id="Older_versions">Older versions</h3>
+
+<p>{{Firefox_for_developers('21')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/23/index.html b/files/zh-cn/mozilla/firefox/releases/23/index.html
new file mode 100644
index 0000000000..adaf75356f
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/23/index.html
@@ -0,0 +1,94 @@
+---
+title: Firefox 23 for developers
+slug: Mozilla/Firefox/Releases/23
+tags:
+ - Firefox
+ - Firefox 23
+translation_of: Mozilla/Firefox/Releases/23
+---
+<div>{{FirefoxSidebar}}</div><h2 id="Web开发者需要注意的变化">Web开发者需要注意的变化</h2>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>Mixed content blocking. Firefox will no longer load non-secure (http) resources on secure (https) pages ({{bug(834836)}}).</li>
+ <li>The standard syntax of <a href="https://developer.mozilla.org/en-US/docs/Security/CSP" title="/en-US/docs/Security/CSP">CSP</a> 1.0 policies are now implemented and enforced by default.</li>
+</ul>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<p> </p>
+
+<ul>
+ <li>The <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty" title="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty"><code>Object.defineProperty</code></a> method can now be used to redefine the <code>length</code>property of an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" title="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array"><code>Array</code></a> object.</li>
+ <li>The option to disable JavaScript, including the options to allow moving windows/replace context menu, have been removed. You may still disable JavaScript by double clicking the "javascript.enabled" option in about:config.</li>
+</ul>
+
+<h3 id="HTML_2">HTML</h3>
+
+<ul>
+ <li>The {{HTMLElement("blink")}} element support is now completely dropped. The <code>&lt;blink&gt;</code> tag now implements the {{domxref("HTMLUnknownElement")}} interface ({{bug(857820)}}).</li>
+ <li>The <code>range</code> type of the {{HTMLElement("input")}} element (<code><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range">&lt;input type="range"&gt;</a></code>) has been switched on by default ({{bug(841950)}}).</li>
+</ul>
+
+<p> </p>
+
+<h3 id="DOM">DOM</h3>
+
+<ul>
+ <li>D3E <a href="/en-US/docs/DOM/KeyboardEvent#Key_names_and_Char_values" title="/en-US/docs/DOM/KeyboardEvent#Key_names_and_Char_values"><code>KeyboardEvent.key</code></a> 现在只支持不可打印字符所在的键({{bug(842927)}}).</li>
+ <li>{{domxref("DOMImplementation.createHTMLDocument")}}方法的<code>title参数成为可选的</code>(根据最新规范).</li>
+ <li>The ability to add a sidebar panel (<code>window.sidebar.addPanel</code>) has been dropped ({{bug(691647)}}).</li>
+ <li>The unprefixed {{domxref("Window.requestAnimationFrame")}} and {{domxref("Window.cancelAnimationFrame")}} methods has been added ({{bug(704063)}}). The unprefixed {{domxref("Window.requestAnimationFrame")}} receives a {{domxref("DOMHighResTimeStamp")}} as argument; the prefixed version did, and still is, received a {{domxref("DOMTimeStamp")}}({{bug(753453)}}).</li>
+ <li>The text argument for {{domxref("window.alert")}} and {{domxref("window.confirm")}} is now optional ({{bug(861605)}}).</li>
+ <li>The {{domxref("HTMLMediaElement.initialTime")}} property, removed from the spec, is no more supported ({{bug(742537)}}).</li>
+ <li>The {{domxref("AnimationEvent.AnimationEvent", "AnimationEvent()")}} constructor has been added ({{bug(848293)}}).</li>
+ <li>The {{domxref("AnimationEvent.pseudoElement")}} property has been implemented ({{bug(848293)}}).</li>
+ <li>The {{domxref("TransitionEvent.TransitionEvent", "TransitionEvent()")}} constructor has been added ({{bug(848291)}}).</li>
+ <li>The {{domxref("TransitionEvent.pseudoElement")}} property has been implemented ({{bug(848291)}}).</li>
+ <li>The non-standard {{domxref("TransitionEvent.initTransitionEvent()")}} and {{domxref("AnimationEvent.initAnimationEvent()")}} have been removed ({{bug(868751)}}).</li>
+</ul>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>CSS属性<code><a href="/en-US/docs/CSS/text-decoration" title="/en-US/docs/CSS/text-decoration">text-decoration</a>: blink;带来的闪烁效果被删除</code>({{bug(857820)}}).</li>
+ <li>In-flow {{cssxref("::after")}} and {{cssxref("::before")}} pseudo-elements are now flex items ({{bug(867454)}}).</li>
+ <li>The way to compute <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/length#Viewport-percentage_lengths">viewport units</a> has been changed. In conjunction with <code>overflow:auto</code>, space taken by eventual scrollbars is not substracted from the viewport, whereas in the case of <code>overflow:scroll</code>, it is. ({{bug(811403)}})</li>
+</ul>
+
+<h3 id="WebRTC">WebRTC</h3>
+
+<ul>
+ <li>Instead of including usernames in the {{domxref("RTCIceServer.url")}} property (such as stun:username@stunserver.example.com), you now need to use the new {{domxref("RTCIceServer.username")}} property.</li>
+</ul>
+
+<h3 id="MathML">MathML</h3>
+
+<ul>
+ <li>{{MathMLElement("mspace")}}元素开始支持负数宽度 ({{bug(717546)}}).</li>
+ <li>The {{MathMLElement("semantics")}} element now determines the visible child as described in the MathML3 specification.</li>
+</ul>
+
+<h2 id="Changes_for_addon_and_Mozilla_developers">Changes for addon and Mozilla developers</h2>
+
+<h3 id="Firefox_developer_tools">Firefox developer tools</h3>
+
+<p>Addons that overlay chrome://browser/content/debugger.xul must now overlay chrome://browser/content/devtools/debugger.xul. You may add references to both these files in chrome.manifest for compatibility.</p>
+
+<p> </p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="http://www.mozilla.org/en-US/firefox/23.0a2/auroranotes/">Firefox 23 Aurora Notes</a></li>
+ <li><a href="https://www.fxsitecompat.com/en-US/versions/23/">Site Compatibility for Firefox 23</a></li>
+</ul>
+
+<p> </p>
+
+<p> </p>
+
+<h3 id="之前版本">之前版本</h3>
+
+<p>{{Firefox_for_developers('22')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/24/index.html b/files/zh-cn/mozilla/firefox/releases/24/index.html
new file mode 100644
index 0000000000..cd3dd112e2
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/24/index.html
@@ -0,0 +1,22 @@
+---
+title: Firefox 24 for developers
+slug: Mozilla/Firefox/Releases/24
+translation_of: Mozilla/Firefox/Releases/24
+---
+<div>{{FirefoxSidebar}}</div><p>{{ draft() }}</p>
+<h2 id="Web开发者需要注意的变化">Web开发者需要注意的变化</h2>
+<h3 id="Developer_Tools">Developer Tools</h3>
+<h3 id="HTML">HTML</h3>
+<h3 id="JavaScript">JavaScript</h3>
+<ul>
+ <li><a href="/zh-CN/docs/Web/JavaScript/Reference/arrow_functions" title="/zh-CN/docs/Web/JavaScript/Reference/arrow_functions">箭头函数</a>不再默认处于严格模式, 除非显示使用 <code>"use strict"</code>. ({{bug(852762)}})</li>
+</ul>
+<h3 id="DOM">DOM</h3>
+<h3 id="MathML">MathML</h3>
+<h2 id="相关链接">相关链接</h2>
+<ul>
+ <li><a href="http://www.mozilla.org/zh-CN/firefox/24.0a2/auroranotes/">Firefox 24 Aurora Notes</a></li>
+ <li><a href="/zh-CN/docs/Site_Compatibility_for_Firefox_24">Firefox 24 网站兼容性</a></li>
+</ul>
+<h3 id="更早版本">更早版本</h3>
+<p>{{Firefox_for_developers('23')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/25/index.html b/files/zh-cn/mozilla/firefox/releases/25/index.html
new file mode 100644
index 0000000000..a23b1fd7c7
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/25/index.html
@@ -0,0 +1,50 @@
+---
+title: Firefox 25 for developers
+slug: Mozilla/Firefox/Releases/25
+translation_of: Mozilla/Firefox/Releases/25
+---
+<div>{{FirefoxSidebar}}</div><p>{{ draft() }}</p>
+<h2 id="Web开发者需要注意的变化">Web开发者需要注意的变化</h2>
+<h3 id="CSS">CSS</h3>
+<ul>
+ <li>新增了 {{cssxref("background-attachment")}} 属性值 <code>local</code> ({{bug("483446")}}).</li>
+ <li>新增了一个 Mozilla 私有的媒体查询属性: <code><a href="/zh-CN/docs/Web/Guide/CSS/Media_queries#-moz-os-version" title="/zh-CN/docs/Web/Guide/CSS/Media_queries#-moz-os-version">-moz-os-version</a></code>, 目前该属性只支持 Windows ({{bug("810399")}}).</li>
+ <li>实现了新的 {{cssxref("-moz-osx-font-smoothing")}} CSS 属性 ({{bug("857142")}})</li>
+</ul>
+<h3 id="HTML">HTML</h3>
+<ul>
+ <li>实现了 {{HTMLElement("iframe")}} 元素的 {{htmlattrxref("srcdoc", "iframe")}} 属性, 可以用 HTML 代码来定义 {{HTMLElement("iframe")}} 元素的文档内容 ({{bug("802895")}}).</li>
+ <li style="padding: 0px;"><code style="font-style: inherit;">HTMLCanvasElement.toBlob</code> 方法, 当第二个参数指定为 <code style="font-style: inherit; font-size: 14px;">"image/jpeg"</code> 时, 会接受第三个参数, 用来指定 jpeg 图片质量. ({{bug("891884")}}).</li>
+</ul>
+<h3 id="JavaScript">JavaScript</h3>
+<p>下面都是 <a href="/zh-CN/docs/Web/JavaScript/ECMAScript_6_support_in_Mozilla" title="/zh-CN/docs/Web/JavaScript/ECMAScript_6_support_in_Mozilla">ECMAScript 6</a> (Harmony) 中的新特性!</p>
+<ul>
+ <li>实现了 <code>Array.of()</code> 方法 ({{bug("866849")}}).</li>
+ <li>实现了 <span id="summary_alias_container"><span id="short_desc_nonedit_display"><code>Number.parseInt()</code> 和 <code>Number.parseFloat()</code> 方法 ({{bug("886949")}})</span></span>.</li>
+ <li style="padding: 0px;">实现了 <span id="summary_alias_container"><code style="font-style: inherit;">Map.prototype.forEach()</code> 和 <code style="font-style: inherit;">Set.prototype.forEach()</code> 方法 ({{bug("866847")}})</span></li>
+ <li>实现了更多的数学函数: <code>Math.log10()</code>, <code>Math.log2()</code>, <code>Math.log1p()</code>, <code>Math.expm1()</code>, <code>Math.cosh()</code>, <code>Math.sinh()</code>, <code>Math.tanh()</code>, <code>Math.acosh()</code>, <code>Math.asinh()</code>, <code>Math.atanh()</code>, <code>Math.hypot()</code>, <code>Math.trunc()</code>, <code>Math.sign()</code> 以及 <code>Math.cbrt()</code> ({{bug("894026")}}).</li>
+ <li>实现了八进制整数字面量写法(比如<code>0o777</code>)和二进制整数字面量写法(比如<code>0b111</code>) ({{bug("717379")}}).</li>
+ <li>实现了 ECMAScript 国际化 API  <span style="color: rgb(68, 68, 68); font-family: arial, sans-serif; font-size: small; line-height: 17.77777862548828px;">—</span><span style="color: rgb(68, 68, 68); font-family: arial, sans-serif; font-size: small; line-height: 17.77777862548828px;">— ECMA 402 </span>({{bug("853301")}})</li>
+</ul>
+<h3 id="DOM">DOM</h3>
+<ul>
+ <li>在 Windows 上新增了<code> KeyboardEvent.key</code> 属性对几个与 IME 有关的键盘按键的支持 ({{bug("865565")}}), 查看 <a href="/zh-CN/docs/Web/API/KeyboardEvent#keyname_table_win" title="/zh-CN/docs/Web/API/KeyboardEvent#keyname_table_win">各按键对应的 key 属性列表</a> 了解详情.</li>
+ <li>Metrofox 的键盘事件和桌面版实现统一 ({{bug("843236")}}).</li>
+ <li>如果使用 <span style="font-family: monospace;">preventDefault() 阻止了 </span><span style="font-family: monospace;">keydown 事件的默认行为, 则后续的 </span><a href="https://developer.mozilla.org/zh-CN/docs/Web/Reference/Events/keydown#preventDefault()_of_keydown_event" title="https://developer.mozilla.org/zh-CN/docs/Web/Reference/Events/keydown#preventDefault()_of_keydown_event"><span style="font-family: monospace;">keypress 事件就不会触发</span></a> ({{bug("501496")}})</li>
+ <li>实现了 {{domxref("HTMLIFrameElement")}} 接口的 <code>srcDoc</code> 属性, 可以用 HTML 代码来定义 {{HTMLElement("iframe")}} 元素的文档内容 ({{bug("802895")}}).</li>
+ <li>实现了 {{domxref("HTMLTableElement")}} 接口的 <code>createTBody()</code> 方法, 可以用来获取 (创建) 表格的 {{HTMLElement("tbody")}} 子元素 ({{bug("813034")}}).</li>
+ <li>{{domxref("Range.collapse")}} 方法的 <code>toStart</code> 参数变为可选, 且默认值为 <code>false</code> ({{bug("891340")}}).</li>
+ <li><code style="font-size: 14px;">按照最新 DOM 规范, window.Future() <font face="Lucida Grande, Lucida Sans Unicode, DejaVu Sans, Lucida, Arial, Helvetica, sans-serif"><span style="line-height: 21px;">改名为</span></font></code><code style="font-size: 14px;"> window.Promise() </code>({{bug("884279")}}).</li>
+ <li>实现了 <span style="font-family: 'Courier New', 'Andale Mono', monospace; line-height: normal;">document.firstElementChild, </span><span style="font-family: 'Courier New', 'Andale Mono', monospace; line-height: normal;">document.lastElementChild, </span><span style="font-family: 'Courier New', 'Andale Mono', monospace; line-height: normal;">document.children, </span><span style="font-family: 'Courier New', 'Andale Mono', monospace; line-height: normal;">document.childElementCount 以及 </span>DocumentFragment 的 <code>parentNode</code> 等属性<code style="font-size: 14px;"> </code>({{bug("895974")}}).</li>
+ <li style="padding: 0px;"><code style="font-style: inherit;">navigator.geolocation</code> 属性更新以符合最新规范. 它永远不会返回 <code style="font-style: inherit;">null</code>. 当 <code style="font-style: inherit;">geo.enabled</code> 偏好设置为 <code style="font-style: inherit;">false 时</code>, 它会返回 <code style="font-style: inherit;">undefined</code> ({{bug("884921")}}).</li>
+ <li style="padding: 0px;">{{domxref("ImageData")}} API 在 {{domxref("Worker")}} 内也可用 ({{bug("845545")}}).</li>
+</ul>
+<h3 id="MathML">MathML</h3>
+<h3 id="SVG">SVG</h3>
+<h2 id="相关链接">相关链接</h2>
+<ul>
+
+ <li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/25/Site_Compatibility">Firefox 25网站兼容性</a></li>
+</ul>
+<h3 id="更早版本">更早版本</h3>
+<p>{{Firefox_for_developers('24')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/25/site_compatibility/index.html b/files/zh-cn/mozilla/firefox/releases/25/site_compatibility/index.html
new file mode 100644
index 0000000000..d808bf4007
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/25/site_compatibility/index.html
@@ -0,0 +1,40 @@
+---
+title: Firefox 25网站兼容性
+slug: Mozilla/Firefox/Releases/25/Site_Compatibility
+translation_of: Mozilla/Firefox/Releases/25/Site_Compatibility
+---
+<div>{{FirefoxSidebar}}</div><p>{{ draft() }}</p>
+<section id="sect1">
+ <h2 id="DOM">DOM</h2>
+ <section id="sect2">
+ <h3 id="ImageDocument_属性被删除"><code>ImageDocument</code> 属性被删除</h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=885177">Bug 885177 – Make window.ImageDocument ChromeOnly</a></li>
+ </ul>
+ <p>非标准的 {{ domxref("ImageDocument") }} 接口在普通页面中不能访问了.</p>
+ </section>
+ <section id="sect3">
+ <h3 id="worker_中的所有事件名都加上_Worker_前缀">worker 中的所有事件名都加上 <code>Worker 前缀</code></h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=887236">Bug 887236 – prefix the current events in workers with "Worker"</a></li>
+ </ul>
+ <p>为了能让 <a href="/zh-CN/docs/Web/Reference/Events">普通的 DOM 事件</a> 能在 worker 中正常使用, 目前 worker 中的事件 {{domxref("Event") }}, {{ domxref("MessageEvent") }}, {{ domxref("ErrorEvent") }} and {{ domxref("ProgressEvent") }}  被重命名为了 {{ domxref("WorkerEvent") }}, {{ domxref("WorkerMessageEvent") }}, {{ domxref("WorkerErrorEvent") }} and {{ domxref("WorkerProgressEvent") }}.</p>
+ </section>
+</section>
+<section id="sect4">
+ <h2 id="JavaScript">JavaScript</h2>
+ <section id="sect5">
+ <h3 id="Proxy_全局变量从对象类型修正到函数类型"><code>Proxy</code> 全局变量从对象类型修正到函数类型</h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=788172">Bug 788172 – Proxy is not a function (typeof Proxy should be 'function')</a></li>
+ </ul>
+ <p>以前, <a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy"><code>Proxy</code></a> 是一个对象类型的值. 现在 <code>typeof Proxy</code> 会返回 <code>function</code> ,且不需要在前面加 <a href="/zh-CN/docs/Web/JavaScript/Reference/Operators/new"><code>new</code></a> 运算符也可以正常调用了.</p>
+ </section>
+ <section id="sect6">
+ <h3 id="yield_without_a_value_has_been_deprecated"><code>yield</code> without a value has been deprecated</h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=885463">Bug 885463 – Warn about 'yield' without operand</a></li>
+ </ul>
+ <p><a href="/zh-CN/docs/Web/JavaScript/Reference/Operators/yield"><code>yield</code></a> 运算符不再需要一个操作数, 该变化遵循了 <a href="/zh-CN/docs/JavaScript/ECMAScript_6_support_in_Mozilla">ECMAScript 6</a> 规范草案.</p>
+ </section>
+</section>
diff --git a/files/zh-cn/mozilla/firefox/releases/26/index.html b/files/zh-cn/mozilla/firefox/releases/26/index.html
new file mode 100644
index 0000000000..621e9f87c9
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/26/index.html
@@ -0,0 +1,41 @@
+---
+title: Firefox 26 for developers
+slug: Mozilla/Firefox/Releases/26
+translation_of: Mozilla/Firefox/Releases/26
+---
+<div>{{FirefoxSidebar}}</div><h2 style="margin: 0px 0px 0.8em; padding: 0px;" id="Web开发者需要注意的变化">Web开发者需要注意的变化</h2>
+<h3 id="CSS">CSS</h3>
+<ul>
+ <li> <code><a href="/zh-CN/docs/Web/CSS/text-decoration-line">text-decoration-line</a> </code>属性仍然带有前缀, 不过现在它把 <code>'blink'</code> 也看看成了它的合法属性值, 虽然并不会真正的让内容产生闪烁效果 ({{bug("812995")}}).</li>
+ <li>非标准的 <code><a href="/zh-CN/docs/Web/CSS/-moz-text-blink">-moz-text-blink</a></code>  属性已被删除 ({{bug("812995")}}).</li>
+ <li>实现了 <a href="http://dev.w3.org/csswg/css-images-4/" title="http://dev.w3.org/csswg/css-images-4/">CSS Image Values Level 4</a> 中的 <a href="/zh-CN/docs/Web/CSS/image-orientation" title="/zh-CN/docs/Web/CSS/image-orientation"><code>image-orientation </code></a>属性, 比起 Level 3, Level 4 增加了对 <code>from-image</code> 关键字和 EXIF 的支持.</li>
+ <li>支持了 <code style="font-size: 14px;">position:sticky</code>, 需要开启 <code style="font-size: 14px;">layout.css.sticky.enabled</code> 选项({{bug(886646)}}).</li>
+</ul>
+<h3 id="HTML">HTML</h3>
+<p><em>No change.</em></p>
+<h3 id="JavaScript">JavaScript</h3>
+<ul style="margin: 0px 0px 1.286em; padding: 0px; list-style-type: none;">
+ <li style="padding: 0px;">实现了 ES6 中的 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math" title="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math"><code style="font-style: inherit;">Math</code></a>: <code style="font-style: inherit;"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/fround" title="/en-US/docs/JavaScript/Reference/Global_Objects/Math/fround">Math.fround()</a>方法 </code>({{bug("900125")}}).</li>
+</ul>
+<h3 id="InterfacesAPIsDOM">Interfaces/APIs/DOM</h3>
+<ul>
+ <li style="padding: 0px;">{{domxref("DOMImplementation.createDocument")}} 方法的第三个参数 <code>doctype </code>成为可选参数 ({{bug(909859)}}).</li>
+ <li>实现了新的 {{domxref("element.classList")}} 规范, 可以同时添加或删除多个类名, 比如 <code>element.classList.add("x", "y", "z")</code> ({{bug(814014)}}).</li>
+ <li style="padding: 0px;">实现了 {{domxref("URL.URL", "URL()")}} 构造函数 ({{bug("887364")}}).</li>
+ <li style="padding: 0px;">The properties {{domxref("URLUtils.origin")}}, {{domxref("URLUtils.password")}}, and {{domxref("URLUtils.username")}} are now available to all interfaces implementing {{domxref("URLUtils")}}: {{domxref("URL")}}, {{domxref("Location")}}, {{domxref("HTMLAnchorElement")}}, and {{domxref("HTMLAreaElement")}} ({{bug("887364")}}).</li>
+ <li style="padding: 0px;">The {{domxref("URL")}} interface is now accessible from Web Workers ({{bug("887364")}}).</li>
+ <li style="padding: 0px;">IndexedDB can now be used as a "optimistic" storage area so it doesn't require any prompts and data is stored in a pool with LRU eviction policy, in short temporary storage ({{bug("785884")}}).</li>
+ <li style="padding: 0px;">Path of the persistent storage has been changed from &lt;profile&gt;/indexedDB to &lt;profile&gt;/storage/persistent (on b2g from /data/local/indexedDB to /data/local/storage/persistent).</li>
+</ul>
+<h3 id="MathML">MathML</h3>
+<ul>
+ <li>Inconsistent renderings of {{MathMLElement("mmultiscripts")}},  {{MathMLElement("msub")}}, {{MathMLElement("msup")}} and {{MathMLElement("msubsup")}} have been unified and the error handling of these elements has been improved ({{bug("827713")}}).</li>
+</ul>
+<h3 id="SVG">SVG</h3>
+<p><em>No change.</em></p>
+<h2 id="相关链接">相关链接</h2>
+<ul>
+ <li><a href="/en-US/docs/Mozilla/Firefox/Releases/26/Site_Compatibility">Firefox 26网站兼容性</a></li>
+</ul>
+<h3 id="更早版本">更早版本</h3>
+<p>{{Firefox_for_developers('25')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/26/site_compatibility/index.html b/files/zh-cn/mozilla/firefox/releases/26/site_compatibility/index.html
new file mode 100644
index 0000000000..009959b5c0
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/26/site_compatibility/index.html
@@ -0,0 +1,104 @@
+---
+title: Site Compatibility for Firefox 26
+slug: Mozilla/Firefox/Releases/26/Site_Compatibility
+translation_of: Mozilla/Firefox/Releases/26/Site_Compatibility
+---
+<div>{{FirefoxSidebar}}</div><p>{{ draft() }}</p>
+<p>Firefox 26 <a href="http://www.mozilla.org/en-US/firefox/aurora/">Aurora</a> (pre-Beta) will be released on <time datetime="2013-09-20">September 20, 2013</time>. While it has been developed to maintain compatibility as much as possible, the new version includes some changes affecting backward compatibility aimed at improving interoperability with the other browsers or following the latest Web standards. Here's the list of such changes — hope this helps whenever you test your sites or applications.</p>
+<p><strong>This article only explains the changes that may affect backward compatibility for Websites</strong>. For the other new features and changes, please read the following documents:</p>
+<ul>
+
+ <li><a href="/en-US/docs/Mozilla/Firefox/Releases/26">Firefox 26 for developers</a></li>
+</ul>
+<p>This list may be updated until the release of the final version on <time datetime="2013-12-10">December 10, 2013</time>, so please check back later. Follow <a href="https://twitter.com/MozWebCompat">@MozWebCompat</a> on Twitter for further updates.</p>
+<section id="sect1">
+ <h2 id="CSS">CSS</h2>
+ <section id="sect2">
+ <h3 id="-moz-text-blink_has_been_removed_in_favor_of_-moz-text-decoration-lineblink"><code>-moz-text-blink</code> has been removed in favor of <code>-moz-text-decoration-line:blink</code></h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=812995">Bug 812995 – add 'blink' to -moz-text-decoration-line and drop -moz-text-blink</a></li>
+ </ul>
+ <p>The non-standard {{ cssxref("-moz-text-blink") }} property has been removed. Instead, the standard, still prefixed {{ cssxref("text-decoration-line") }} property now takes <code>blink</code> as a valid value. Actually it doesn't blink any content on Firefox though, from the perspective of <a href="/en-US/docs/Accessibility">accessibility</a>. Note that the blink effect with <code>text-decoration:blink</code> has been dropped with <a href="/en-US/docs/Site_Compatibility_for_Firefox_23">Firefox 23</a>.</p>
+ </section>
+</section>
+<section id="sect3">
+ <h2 id="DOM">DOM</h2>
+ <section id="sect4">
+ <h3 id="type_属性不是_image_的_HTMLInputElement_元素的_width_和_height_属性会返回_0">type 属性不是 image 的 HTMLInputElement 元素的 width 和 height 属性会返回 0</h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=905240">Bug 905240 – HTMLInputElement.{width,height} getter should return 0 for type!='image'</a></li>
+ </ul>
+ <p>Previously, the <code>width</code> and <code>height</code> properties of an {{ HTMLElement("input") }} returned the dimension of the element. To comply with the spec, those properties now return <code>0</code> if the <code>type</code> property is not <code>image</code>.</p>
+ </section>
+ <section id="sect5">
+ <h3 id="Setting_document.domain_in_a_sandboxed_iframe_is_no_longer_allowed">Setting <code>document.domain</code> in a sandboxed <code>iframe</code> is no longer allowed</h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=907892">Bug 907892 – Disallow setting document.domain in sandboxed iframes</a></li>
+ </ul>
+ <p>Setting the {{ domxref("document.domain") }} property on a page embedded in an {{ HTMLElement("iframe") }} with the <code>sandbox</code> attribute will throw a security error from now on.</p>
+ </section>
+ <section id="sect6">
+ <h3 id="元素的_id_改变后,旧_id_不再是_window_对象的属性"><code><font face="Georgia, Times, Times New Roman, serif">元素的 </font>id 改变后,旧 id 不再是 window 对象的属性</code></h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=790601">Bug 790601 – Javascript element should not exist with old id</a></li>
+ </ul>
+ <p>An element with <code>id</code> is accessible through <code>window.<var>&lt;id&gt;</var></code>. Previously, the DOM object remained on {{ domxref("window") }} even after the <code>id</code> of the element is programmatically changed. This odd behavior has been fixed with Firefox 26. The {{ domxref("document.getElementById") }} method, which is recommended to use in general, is not affected by this change.</p>
+ </section>
+ <section id="sect7">
+ <h3 id="MessageEvent_has_been_updated"><code>MessageEvent</code> has been updated</h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=848294">Bug 848294 – Update MessageEvent to be compatible with the spec</a></li>
+ </ul>
+ <p>The {{ domxref("MessageEvent") }} interface has been updated to comply with the latest spec. The <code>initMessageEvent</code> method has been removed while the interface is now a constructor.</p>
+ </section>
+ <section id="sect8">
+ <h3 id="HTMLCanvasElement.mozGetAsFile_has_been_deprecated"><code>HTMLCanvasElement.mozGetAsFile</code> has been deprecated</h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=803612">Bug 803612 – Add deprecation warnings for mozGetAsFile</a></li>
+ </ul>
+ <p>The non-standard <code>mozGetAsFile</code> method on the {{ domxref("HTMLCanvasElement") }} interface is now deprecated and will be removed soon. The standard <code>toBlob</code> method can be used instead.</p>
+ </section>
+ <section id="sect9">
+ <h3 id="UserDataHandler_has_been_removed"><code>UserDataHandler</code> has been removed</h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=910751">Bug 910751 – Hide UserDataHandler from content</a></li>
+ </ul>
+ <p>The deprecated {{ domxref("UserDataHandler") }} interface has been removed. The {{ domxref("Node.setUserData") }} and {{ domxref("Node.getUserData") }} methods have already been removed with <a href="/en-US/docs/Site_Compatibility_for_Firefox_22">Firefox 22</a>.</p>
+ </section>
+ <section id="sect10">
+ <h3 id="XBL-related_methods_have_been_removed">XBL-related methods have been removed</h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=912322">Bug 912322 – document.getAnonymous* should not be available to web content</a></li>
+ </ul>
+ <p>The following methods on the <a href="/en-US/docs/XBL/XBL_1.0_Reference/DOM_Interfaces">XBL DOM Interface</a> have been removed from the {{ domxref("Document") }} interface: <code>getAnonymousNodes</code>, <code>getAnonymousElementByAttribute</code>, <code>getBindingParent</code> and <code>loadBindingDocument</code>.</p>
+ </section>
+ <section id="sect11">
+ <h3 id="Various_non-standard_interfaces_have_been_removed">Various non-standard interfaces have been removed</h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=899388">Bug 899388 – Remove XUL-related interfaces and ChromeWindow from content</a></li>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=905739">Bug 905739 – Remove nsIDOMStorageIndexedDB</a></li>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=909340">Bug 909340 – Hide XULElement from content</a></li>
+ </ul>
+ <p>As part of the ongoing effort to standardize global objects, the following non-standard interfaces have been removed: <code>ChromeWindow</code>, <code>StorageIndexedDB</code>, <code>XULButtonElement</code>, <code>XULCheckboxElement</code>, <code>XULCommandDispatcher</code>, <code>XULCommandEvent</code>, <code>XULControlElement</code>, <code>XULDocument</code>, <code>XULElement</code>, <code>XULLabeledControlElement</code> and <code>XULPopupElement</code>.</p>
+ </section>
+</section>
+<section id="sect12">
+ <h2 id="JavaScript">JavaScript</h2>
+ <section id="sect13">
+ <h3 id="The_reserved_words_are_no_longer_allowed_as_function_names">The reserved words are no longer allowed as function names</h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=907958">Bug 907958 – Restrict function names to non-keywords</a></li>
+ </ul>
+ <p>The <a href="/en-US/docs/Web/JavaScript/Reference/Reserved_Words">reserved words</a> cannot be used for function names. Starting with Firefox 26, such a usage will throw a <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError"><code>SyntaxError</code></a>. For example, <code>function delete() { ... }</code> is illegal.</p>
+ </section>
+</section>
+<section id="sect14">
+ <h2 id="Plug-ins">Plug-ins</h2>
+ <section id="sect15">
+ <h3 id="All_plug-ins_except_Flash_are_now_defaulted_to_Click-to-Play">All plug-ins except Flash are now defaulted to Click-to-Play</h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=899080">Bug 899080 – Make plugins default to click-to-play</a></li>
+ </ul>
+ <p>Starting with Firefox 26, <a href="/en-US/docs/Plugins">plug-ins</a> require user interaction to be activated. With the exception of the popular Adobe Flash Player, all plug-in content embedded in a Web page is now disabled by default and enabled by user's click. This change has been made in order to improve security and performance of the browser. See the <a href="https://blog.mozilla.org/security/2013/01/29/putting-users-in-control-of-plugins/">Mozilla Security Blog</a> for details. Web developers are encouraged to leverage modern Web technologies, including <a href="/en-US/docs/Web/Guide/HTML/HTML5">HTML5</a>, to provide richer user experience.</p>
+ </section>
+</section>
diff --git a/files/zh-cn/mozilla/firefox/releases/27/index.html b/files/zh-cn/mozilla/firefox/releases/27/index.html
new file mode 100644
index 0000000000..7f9f6a9028
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/27/index.html
@@ -0,0 +1,45 @@
+---
+title: Firefox 27 for developers
+slug: Mozilla/Firefox/Releases/27
+translation_of: Mozilla/Firefox/Releases/27
+---
+<div>{{FirefoxSidebar}}</div><h2 id="Web_开发者需要注意的变化">Web 开发者需要注意的变化</h2>
+<h3 id="开发者工具">开发者工具</h3>
+<ul>
+ <li>可以在调试器中监控到 DOM 事件.</li>
+ <li>查看器可以直接编辑元素的 html 源码, 不再需要安装额外的扩展.</li>
+ <li>可以在查看器中直接预览背景图片和颜色值.</li>
+ <li>可以输出 reflow 日志.</li>
+</ul>
+<p>更多详情, 请看<a style="line-height: 1.572;" href="https://hacks.mozilla.org/2013/11/firefox-developer-tools-episode-27-edit-as-html-codemirror-more/">这篇文章</a>.</p>
+<h3 id="CSS">CSS</h3>
+<ul>
+ <li><code><span style="line-height: 21px;">CSS {{cssxref("cursor")}} 属性值中 </span>-moz-grab</code> 和 <code>-moz-grabbing</code> 关键字脱前缀, 成为 <code>grab</code> 和 <code>grabbing</code> ({{bug("880672")}}).</li>
+</ul>
+<h3 id="HTML">HTML</h3>
+<ul>
+ <li>桌面浏览器上实现了<code>&lt;input type = "color"&gt;</code></li>
+</ul>
+<h3 id="JavaScript">JavaScript</h3>
+<p><a href="/en-US/docs/Web/JavaScript/ECMAScript_6_support_in_Mozilla" title="/en-US/docs/Web/JavaScript/ECMAScript_6_support_in_Mozilla">EcmaScript 6</a> (Harmony) 实现了:</p>
+<ul>
+ <li><a href="http://wiki.ecmascript.org/doku.php?id=harmony:spread" title="http://wiki.ecmascript.org/doku.php?id=harmony:spread">展开运算符</a>支持在函数调用时的实参左边位置使用 ({{bug("762363")}}).</li>
+ <li>实现了多个数学函数 {{jsxref("Global_Objects/Math/hypot", "Math.hypot()")}}  ({{bug("896264")}}).</li>
+</ul>
+<h3 id="InterfacesAPIsDOM">Interfaces/APIs/DOM</h3>
+<p><em>No change.</em></p>
+<h3 id="MathML">MathML</h3>
+<p><em>No change.</em></p>
+<h3 id="SVG">SVG</h3>
+<p><em>No change.</em></p>
+<h2 id="附加组件和_Mozilla_开发者需要注意的变化">附加组件和 Mozilla 开发者需要注意的变化</h2>
+<ul>
+ <li><code>移除了 downloads-indicator</code>, 你应该使用 <code>downloads-button</code> 元素来代替.</li>
+ <li>Firefox 不再使用 <code>chrome://browser/skin/downloads/indicator.css</code> 样式.</li>
+</ul>
+<h2 id="相关链接">相关链接</h2>
+<ul>
+ <li><a href="/en-US/docs/Mozilla/Firefox/Releases/27/Site_Compatibility">Site Compatibility for Firefox 27</a></li>
+</ul>
+<h3 id="更早版本">更早版本</h3>
+<p>{{Firefox_for_developers('26')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/28/index.html b/files/zh-cn/mozilla/firefox/releases/28/index.html
new file mode 100644
index 0000000000..1e41a0b20d
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/28/index.html
@@ -0,0 +1,117 @@
+---
+title: Firefox 28 for developers
+slug: Mozilla/Firefox/Releases/28
+tags:
+ - Firefox
+ - Firefox 28
+translation_of: Mozilla/Firefox/Releases/28
+---
+<div>{{FirefoxSidebar}}</div><p>Firefox 28 was released on March 18, 2014. This article lists key changes that are useful not only for web developers, but also Firefox and Gecko developers as well as add-on developers.</p>
+
+<h2 id="Changes_for_Web_developers">Changes for Web developers</h2>
+
+<h3 id="Developer_Tools">Developer Tools</h3>
+
+<ul>
+ <li>The {{domxref("console.exception")}} property has been added ({{bug("922214")}}).</li>
+ <li>The {{domxref("console.assert")}} property has been added ({{bug("760193")}}).</li>
+ <li>App Manager: a new Manifest Editor was added.</li>
+ <li>App Manager: the toolbox used for debugging apps is now embedded in the app manager UI.</li>
+ <li>Web Console: added a "split console" mode - press Escape to quickly open the console in any other tool.</li>
+ <li>Web Console: added a dark theme for the output.</li>
+ <li>Debugger: pretty-print minified JavaScript.</li>
+ <li>Debugger: simply hover over any variable or click on it to bring up a pop-up that displays the current value.</li>
+ <li>Inspector: added a color picker in rules view and various tooltips.</li>
+ <li>Browser Toolbox: allows add-on and platform developers to use almost all of the developer tools while targeting the browser itself.</li>
+</ul>
+
+<p>More details in <a href="https://hacks.mozilla.org/2013/12/split-console-pretty-print-minified-js-and-more-firefox-developer-tools-episode-28/" title="Split console, pretty-print minified JS and more – Firefox Developer Tools Episode 28">this post</a>.</p>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>Support for multi-line <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes">flexbox</a> has been added ({{bug("939901")}}).</li>
+ <li>Longhand East Asian <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/list-style-type">counter styles</a> have been implemented ({{bug("934072")}}).</li>
+ <li>Experimental support for the {{cssxref("background-blend-mode")}} property has been added, but is disabled by default ({{bug("841601")}}).</li>
+ <li>The <code>none</code> value has been added to {{cssxref("font-variant-ligatures")}} ({{bug("913264")}}).</li>
+ <li>Support for the :hover user action pseudo-class on pseudo-elements({{bug("922669")}}).</li>
+</ul>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li><code>&lt;input type=color&gt;</code> and <code>&lt;input type=number&gt;</code> have been implemented, disabled by default.</li>
+</ul>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/ECMAScript_6_support_in_Mozilla" title="/en-US/docs/Web/JavaScript/ECMAScript_6_support_in_Mozilla">ECMAScript 2015</a> implementation continues:
+
+ <ul>
+ <li>New <code>Array</code> methods have been implemented: {{jsxref("Array.prototype.entries()")}} and {{jsxref("Array.prototype.keys()")}} ({{bug("894658")}}).</li>
+ </ul>
+ </li>
+ <li>A bug causing that {{jsxref("Object.getOwnPropertyNames()")}} did not see unresolved properties of {{jsxref("Error")}} objects has been fixed ({{bug("724768")}}).</li>
+</ul>
+
+<h3 id="InterfacesAPIsDOM">Interfaces/APIs/DOM</h3>
+
+<ul>
+ <li><code>HTMLVideoElement.canPlayType('video/webm')</code> now reports <code>maybe</code>.({{bug("884275")}}).</li>
+ <li>The {{domxref("DocumentFragment.getElementById()")}} method has been implemented. E.g. <code>document.createDocumentFragment().getElementById()</code>({{bug("933193")}}).</li>
+ <li>The {{domxref("KeyboardEvent.repeat")}} attribute has been implemented ({{bug("600117")}}).</li>
+ <li>The {{domxref("File")}} constructor, e.g. <code>new File(["foo"], "foo.txt")</code> has been implemented. ({{bug("819900")}}).</li>
+ <li>The {{domxref("NavigatorPlugins.plugins", "navigator.plugins")}} is no more enumerable, for privacy reasons ({{bug(757726)}}).</li>
+ <li>The two attributes {{domxref("Window.screenX")}} and {{domxref("Window.screenY")}} now return CSS pixels (and no more device pixels) ({{bug(943668)}}).</li>
+ <li>The two methods {{domxref("CanvasRenderingContext2D.drawSystemFocusRing()")}} and {{domxref("CanvasRenderingContext2D.drawCustomFocusRing()")}} have been implemented. The preference <code>canvas.focusring.enabled</code> must be set to <code>true</code> to activate both ({{bug(540456)}}).</li>
+ <li>The <code>willReadFrequently</code> context attribute for "<code>2d</code>" canvas contexts has been implemented (see {{domxref("HTMLCanvasElement.getContext()")}}) ({{bug(884226)}}).</li>
+ <li>The following attributes and methods of {{domxref("NavigatorID")}} have been implemented on {{domxref("WorkerNavigator")}} to allow their use in workers: {{domxref("NavigatorID.appCodeName", "appCodeName")}}, {{domxref("NavigatorID.product", "product")}}, and {{domxref("NavigatorID.taintEnabled", "taintEnabled()")}} ({{bug(925847)}}).</li>
+ <li>The {{domxref("NonDocumentTypeChildNode.previousElementSibling" , "previousElementSibling")}} and {domxref("NonDocumentTypeChildNode.nextElementSibling" , "nextElementSibling")}} properties has been removed from {{domxref("DocumentType")}}, because of compatibility problems ({{bug(932501)}}).</li>
+</ul>
+
+<h3 id="MathML">MathML</h3>
+
+<ul>
+ <li>Support of <span id="summary_alias_container"><span id="short_desc_nonedit_display">“</span></span>mathvariant<span id="summary_alias_container"><span id="short_desc_nonedit_display">”</span></span> attribute ({{bug("114365")}}).</li>
+</ul>
+
+<h3 id="SVG">SVG</h3>
+
+<p><em>No change.</em></p>
+
+<h3 id="AudioVideo">Audio/Video</h3>
+
+<ul>
+ <li><span id="summary_alias_container"><span id="short_desc_nonedit_display">Support Opus in WebM</span></span> ({{bug("887978")}}).</li>
+ <li><span id="summary_alias_container"><span id="short_desc_nonedit_display">Support VP9 video decoder</span></span> ({{bug("833023")}}).</li>
+</ul>
+
+<h3 id="Network">Network</h3>
+
+<ul>
+ <li>Support of <code>SPDY/2</code> has been removed.</li>
+</ul>
+
+<h2 id="Changes_for_addon_and_Mozilla_developers">Changes for addon and Mozilla developers</h2>
+
+<ul>
+ <li>The interface of <a href="https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/DeferredTask.jsm">DeferredTask.jsm</a> has been changed, and the <code>isPending()</code>, <code>start()</code>, <code>flush()</code>, and <code>cancel()</code> methods have been removed ({{bug("940408")}}).</li>
+</ul>
+
+<h2 id="Security">Security</h2>
+
+<ul>
+ <li>CSP was not enforced in sandboxed iframes. This has been fixed ({{bug(886164)}}).</li>
+ <li>The CSP 1.1 experimental <code>script-nonce</code> directive has been implemented. The preference <code>security.csp.experimentalEnabled</code> should be set to <code>true</code> to enable this functionality ({{bug(855326)}}).</li>
+</ul>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/Firefox/Releases/28/Site_Compatibility">Site Compatibility for Firefox 28</a></li>
+</ul>
+
+<h3 id="Older_versions">Older versions</h3>
+
+<p>{{Firefox_for_developers('27')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/28/site_compatibility/index.html b/files/zh-cn/mozilla/firefox/releases/28/site_compatibility/index.html
new file mode 100644
index 0000000000..c2a74bad9f
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/28/site_compatibility/index.html
@@ -0,0 +1,56 @@
+---
+title: Site Compatibility for Firefox 28
+slug: Mozilla/Firefox/Releases/28/Site_Compatibility
+translation_of: Mozilla/Firefox/Releases/28/Site_Compatibility
+---
+<div>{{FirefoxSidebar}}</div><p><span style="font-size: 30px; font-weight: 700; letter-spacing: -1px; line-height: 30px;">DOM</span></p>
+<section id="sect5">
+ <section id="sect1">
+ <h3 id="navigator.plugins_不再是可枚举的"><code>navigator.plugins</code> 不再是可枚举的</h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=757726">Bug 757726 – disallow enumeration of navigator.plugins</a></li>
+ </ul>
+ <p>{{ domxref("PluginArray") }} 接口, 通常就是指 {{ domxref("window.navigator.plugins") }} 属性, 现在不再是可以枚举的了. 这么做主要是为了防止网站通过某些技术手段窃取用户隐私. 不过开发人员仍然可以使用 {{ domxref("window.navigator.mimeTypes") }} 接口来判断浏览器支持哪些 MIME 类型. 这一变更可能会给一些已有的代码<a href="https://bugzilla.mozilla.org/showdependencytree.cgi?id=934107">带来兼容性问题</a>.</p>
+ </section>
+ <section id="sect2">
+ <h3 id="showModalDialog_has_been_deprecated"><code>showModalDialog</code> has been deprecated</h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=933040">Bug 933040 – Warn for showModalDialog uses</a></li>
+ </ul>
+ <p>The {{ domxref("window.showModalDialog") }} method, originally from Internet Explorer, is now considered deprecated. The {{ domxref("window.open") }} method should be used instead.</p>
+ </section>
+ <section id="sect3">
+ <h3 id="Make_sure_the_deep_argument_is_specified_for_cloneNode_and_importNode">Make sure the <code>deep</code> argument is specified for <code>cloneNode</code> and <code>importNode</code></h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=937465">Bug 937465 – Add a warning when cloneNode/importNode is used without a boolean argument on a node with children</a></li>
+ </ul>
+ <p>The {{ domxref("Node.cloneNode") }} and {{ domxref("document.importNode") }} methods take the boolean <code>deep</code> argument. It's optional in the DOM4 specification, and if omitted, these methods acted as if the value of <code>deep</code> was <code>true</code>. But this behavior has been changed in the latest spec, and if omitted, the methods will act as if the value was <code>false</code>. Though It's still optional, Firefox now warns developers in console not to omit the argument for the forward compatibility.</p>
+ </section>
+ <section id="sect4">
+ <h3 id="History_objects_now_throw_if_the_document_is_inactive"><code>History</code> objects now throw if the <code>document</code> is inactive</h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=940783">Bug 940783 – History objects should unconditionally throw if their inner is not current</a></li>
+ </ul>
+ <p>The spec of the {{ domxref("History") }} interface has been updated, and the properties and methods now throw a <code>SecurityError</code> exception when those are called on an inactive {{ domxref("document") }}. It would be a problem if you are manipulating {{ domxref("window.history") }} in an {{ HTMLElement("iframe") }}.</p>
+ </section>
+</section>
+<section id="sect6">
+ <h2 id="Networking">Networking</h2>
+ <section id="sect7">
+ <h3 id="SPDY2_support_has_been_dropped">SPDY/2 support has been dropped</h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=912550">Bug 912550 – remove spdy/2 support</a></li>
+ </ul>
+ <p>The support of SPDY Protocol Draft 2 has been removed. Web sites should upgrade to SPDY/3 or 3.1.</p>
+ </section>
+</section>
+<section id="sect8">
+ <h2 id="VideoAudio">Video/Audio</h2>
+ <section id="sect9">
+ <h3 id="canPlayType('videowebm')_now_returns_'maybe'"><code>canPlayType('video/webm')</code> now returns <code>'maybe'</code></h3>
+ <ul>
+ <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=884275">Bug 884275 – canPlayType('video/webm') should report 'maybe' instead of 'probably'</a></li>
+ </ul>
+ <p>The <code>canPlayType</code> method of the {{ domxref("HTMLMediaElement") }} interface has been updated to comply with the spec. <code>canPlayType('video/webm')</code> and <code>canPlayType('audio/webm')</code> now return <code>'maybe'</code> instead of <code>'probably'</code>, because media can be encoded with a codec that Firefox doesn't support. If a codec is specified in the <code>type</code> argument, the method returns <code>'probably'</code> or <code>''</code> (empty string) depending on the codec. For example, <code>canPlayType('video/webm; codecs=vp8')</code> returns <code>'probably'</code>.</p>
+ </section>
+</section>
diff --git a/files/zh-cn/mozilla/firefox/releases/3.6/index.html b/files/zh-cn/mozilla/firefox/releases/3.6/index.html
new file mode 100644
index 0000000000..8bc9182b45
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/3.6/index.html
@@ -0,0 +1,305 @@
+---
+title: Firefox 3.6 for developers
+slug: Mozilla/Firefox/Releases/3.6
+translation_of: Mozilla/Firefox/Releases/3.6
+---
+<div><section class="Quick_links" id="Quick_Links">
+ <ol>
+ <li class="toggle">
+ <details>
+ <summary>Firefox developer 发布说明</summary>
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/Firefox/Releases">Firefox developer 发布说明</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>附加组件</summary>
+ <ol>
+ <li><a href="/zh-CN/Add-ons/WebExtensions">浏览器扩展</a></li>
+ <li><a href="/zh-CN/Add-ons/Themes">主题</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Firefox 的内部机制</summary>
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/">Mozilla 项目</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Gecko">Gecko</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Firefox/Headless_mode">Headless mode</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/JavaScript_code_modules">JavaScript代码模块</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/js-ctypes">JS-ctypes</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/MathML_Project">MathML 项目</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/MFBT">MFBT</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Projects">Mozilla 项目</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Preferences">Preference 系统</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/WebIDL_bindings">WebIDL 绑定</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM">XPCOM</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Tech/XUL">XUL</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>构建与作出贡献</summary>
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/Developer_guide/Build_Instructions">构建说明</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Developer_guide/Build_Instructions/Configuring_Build_Options">配置构建选项</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Developer_guide/Build_Instructions/How_Mozilla_s_build_system_works">构建系统如何工作</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Developer_guide/Source_Code/Mercurial">Mozilla源代码</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Localization">本地化</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Mercurial">Mercurial</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/QA">质量保证</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Using_Mozilla_code_in_other_projects">在其他项目中使用来自Mozilla的代码</a></li>
+ </ol>
+ </details>
+ </li>
+ </ol>
+</section></div><p><a class="external" href="http://www.firefox.com/" title="http://www.firefox.com/">Firefox 3.6</a> offers support for new and developing web standards, increased performance, and an overall better experience for web users and developers. This page provides links to articles covering the new capabilities of Firefox 3.6.</p>
+
+<h2 id="For_web_site_and_application_developers">For web site and application developers</h2>
+
+<h3 id="CSS">CSS</h3>
+
+<dl>
+ <dt><a href="/zh-cn/CSS/Using_CSS_gradients" title="zh-cn/Using gradients">Using gradients</a></dt>
+ <dd>Firefox 3.6 adds support for the proposed <a href="/zh-CN/docs/Web/CSS/-moz-linear-gradient" title="此页面仍未被本地化, 期待您的翻译!"><code>-moz-linear-gradient</code></a> and <a href="/zh-CN/docs/Web/CSS/-moz-radial-gradient" title="此页面仍未被本地化, 期待您的翻译!"><code>-moz-radial-gradient</code></a> properties  for <a href="/zh-CN/docs/Web/CSS/background" title="background 是一种 CSS 简写属性,用于一次性集中定义各种背景属性,包括 color, image, origin 与 size, repeat 方式等等。"><code>background</code></a>.</dd>
+ <dt><a href="/zh-cn/CSS/Multiple_backgrounds" title="zh-cn/CSS/Multiple backgrounds">Multiple backgrounds</a></dt>
+ <dd>The <a href="/zh-CN/docs/Web/CSS/background" title="background 是一种 CSS 简写属性,用于一次性集中定义各种背景属性,包括 color, image, origin 与 size, repeat 方式等等。"><code>background</code></a> property (as well as <a href="/zh-CN/docs/Web/CSS/background-color" title='CSS属性中的 background-color 会设置元素的背景色, 属性的值为颜色值或关键字"transparent"二者选其一.'><code>background-color</code></a>, <a href="/zh-CN/docs/Web/CSS/background-image" title="CSS background-image 属性用于为一个元素设置一个或者多个背景图像。图像在绘制时,以z方向堆叠的方式进行。先指定的图像会在之后指定的图像上面绘制。因此指定的第一个图像最接近用户。"><code>background-image</code></a>, <a href="/zh-CN/docs/Web/CSS/background-position" title="background-position 为每一个背景图片设置初始位置。 这个位置是相对于由 background-origin 定义的位置图层的。"><code>background-position</code></a>, <a href="/zh-CN/docs/Web/CSS/background-repeat" title="background-repeat CSS 属性定义背景图像的重复方式。背景图像可以沿着水平轴,垂直轴,两个轴重复,或者根本不重复。"><code>background-repeat</code></a>, and <a href="/zh-CN/docs/Web/CSS/background-attachment" title="如果指定了 background-image ,那么 background-attachment 决定背景是在视口中固定的还是随包含它的区块滚动的。"><code>background-attachment</code></a>) now supports multiple backgrounds. This lets you specify multiple backgrounds that are rendered atop one another in layers.</dd>
+ <dt><a href="/zh-cn/CSS/Media_queries#Mozilla-specific_media_features" title="zh-cn/CSS/Media queries#Mozilla-specific media features">Mozilla-specific media features</a></dt>
+ <dd>Media features have been added for Mozilla-specific system metrics, so that <a href="/zh-cn/CSS/Media_queries" title="zh-cn/CSS/Media queries">media queries</a> can be used to more safely check on the availability of features such as touch support.</dd>
+ <dt><a href="/zh-cn/CSS/Scaling_background_images" title="zh-cn/CSS/Scaling background images">Scaling background images</a></dt>
+ <dd>The <code>background-size </code>property from the <a class="external" href="http://dev.w3.org/csswg/css3-background/" title="http://dev.w3.org/csswg/css3-background/#the-background-size-property">CSS 3 Backgrounds and Borders draft</a> is now supported under the name <a href="/zh-CN/docs/Web/CSS/-moz-background-size" title="此页面仍未被本地化, 期待您的翻译!"><code>-moz-background-size</code></a>.</dd>
+ <dt><a href="/zh-cn/WOFF" title="zh-cn/About WOFF">WOFF font support</a></dt>
+ <dd><a href="/zh-CN/docs/Web/CSS/@font-face" title="这是一个叫做@font-face 的CSS @规则 ,它允许网页开发者为其网页指定在线字体。 通过这种作者自备字体的方式,@font-face 可以消除对用户电脑字体的依赖。 @font-face 不仅可以放在在CSS的最顶层, 也可以放在 @规则 的 条件规则组 中。"><code>@font-face</code></a> now supports the WOFF downloadable font file format.</dd>
+ <dt><a href="/zh-cn/CSS/pointer-events" title="zh-cn/CSS/pointer-events">Pointer events</a></dt>
+ <dd>The <a href="/zh-CN/docs/Web/CSS/pointer-events" title="pointer-events CSS 属性指定在什么情况下 (如果有) 某个特定的图形元素可以成为鼠标事件的 target。"><code>pointer-events</code></a> property lets content specify whether or not an element may be the target of mouse pointer events.</dd>
+</dl>
+
+<h4 id="Miscellaneous_CSS_changes">Miscellaneous CSS changes</h4>
+
+<ul>
+ <li>The <a href="/zh-cn/CSS/length#Relative_length_units" title="zh-cn/CSS/length#Relative length units"><code>rem</code></a> length unit from <a class="external" href="http://www.w3.org/TR/css3-values/#lengths" title="http://www.w3.org/TR/css3-values/#lengths">CSS3 Values and Units</a> is now supported. <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=472195" title="FIXED: support css3 root em ('rem' or 're') units">bug 472195</a></li>
+ <li><a href="/zh-CN/docs/Web/CSS/image-rendering" title="image-rendering CSS 属性决定浏览器对缩放图像采取的缩放算法.它适用于元素本身和有其他属性的图像.它对非缩放图像没有影响。"><code>image-rendering</code></a> is supported for images, background images, videos and canvases. <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=423756" title="FIXED: Request: Switch for authors to turn on/off bilinear filtering when enlarging images">bug 423756</a></li>
+ <li><a href="/zh-CN/docs/Web/CSS/text-align" title="text-align CSS属性定义行内内容(例如文字)如何相对它的块父元素对齐。text-align 并不控制块元素自己的对齐,只控制它的行内内容的对齐。"><code>text-align</code></a>:end is now supported. <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=299837" title="FIXED: [FIX]add support for text-align: end">bug 299837</a></li>
+ <li>DOM changes to elements using the table <a href="/zh-CN/docs/Web/CSS/display" title="display CSS 属性指定了元素的显示类型,它包含两类基础特征,用于指定元素怎样生成盒模型——外部显示类型定义了元素怎样参与流式布局的处理,内部显示类型定义了元素内子元素的布局方式。"><code>display</code></a> types now work much better.</li>
+ <li>Added <a href="/zh-CN/docs/Web/CSS/:-moz-locale-dir(ltr)" title="此页面仍未被本地化, 期待您的翻译!"><code>:-moz-locale-dir(ltr)</code></a> and <a href="/zh-CN/docs/Web/CSS/:-moz-locale-dir(rtl)" title="此页面仍未被本地化, 期待您的翻译!"><code>:-moz-locale-dir(rtl)</code></a> to make it easier to customize layouts based on whether the user interface is being displayed using a left-to-right or a right-to-left locale. <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=478416" title="FIXED: Replace chromedir with something more sane">bug 478416</a></li>
+ <li>Added support for the <a href="/zh-CN/docs/Web/CSS/:indeterminate" title=":indeterminate CSS 伪类 表示状态不确定的表单元素:"><code>:indeterminate</code></a> pseudo-class, which matches <code>checkbox</code> <a class="internal" href="/zh-cn/HTML/Element/Input" title="zh-cn/HTML/Element/input"><code>input</code></a> elements whose <code>indeterminate</code> attribute is <code>true</code>.</li>
+ <li>Windowed plugins are no longer displayed in CSS transforms, because they can't be transformed properly by the compositor.</li>
+</ul>
+
+<h3 id="HTML">HTML</h3>
+
+<dl>
+ <dt><a href="/zh-cn/Using_files_from_web_applications" title="zh-cn/Using files from web applications">Using files from web applications</a></dt>
+ <dd>Support for the new HTML5 File API has been added to Gecko, making it possible for web applications to access local files selected by the user. This includes support for selecting multiple files using the <code>input type="file"</code> HTML element's new <code>multiple</code> attribute.</dd>
+ <dt>HTML5 video supports poster frames</dt>
+ <dd>The <code>poster</code> attribute is now supported for the <a class="internal" href="/zh-cn/HTML/Element/Video" title="zh-cn/HTML/Element/Video"><code>video</code></a> element, allowing content to specify a poster frame to be displayed until the video begins to play.</dd>
+ <dt>Checkboxes and radio buttons support the <code>indeterminate</code> property</dt>
+ <dd>HTML <a class="internal" href="/zh-cn/HTML/Element/Input" title="zh-cn/HTML/Element/input"><code>input</code></a> elements of types <code>checkbox</code> and <code>radio</code> now support the indeterminate property, which allows a third, "indeterminate" state.</dd>
+ <dt>Canvas image smoothing can be controlled</dt>
+ <dd>The new <a class="internal" href="/zh-cn/Canvas_tutorial/Using_images#Controlling_image_scaling_behavior" title="zh-cn/Canvas tutorial/Using images#Controlling image scaling behavior"><code>mozImageSmoothingEnabled</code></a> property can be used to turn on and off image smoothing when scaling in <a class="internal" href="/zh-cn/HTML/Element/canvas" title="zh-cn/HTML/Element/canvas"><code>canvas</code></a> elements.</dd>
+ <dt>Asynchronous script execution</dt>
+ <dd>By setting the <code>async</code> attribute on a <a href="/zh-cn/HTML/Element/Script" title="zh-cn/HTML/Element/Script"><code>script</code></a> element, the <code>script</code> will not block loading or display of the rest of the page. Instead the <code>script</code> executes as soon as it is downloaded.</dd>
+</dl>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<p>Gecko 1.9.2引入了JavaScript 1.8.2, 该版本的JavaScript添加了许多来自<a href="/zh-cn/JavaScript/ECMAScript_5_support_in_Mozilla" title="https://developer.mozilla.org/zh-cn/JavaScript/ECMAScript_5_support_in_Mozilla">ECMAScript 5</a>的新的语言特性:</p>
+
+<ul>
+ <li><a href="/zh-cn/JavaScript/Reference/Global_Objects/Date/parse" title="zh-cn/JavaScript/Reference/Global Objects/Date/parse"><code>Date.parse()</code></a>方法现在可以解析符合ISO 8601标准的日期格式字符串,像这样YYYY-MM-DD.</li>
+ <li>
+ <p>函数从原型链<a href="/zh-cn/JavaScript/Reference/Global_Objects/Function/prototype" title="zh-cn/JavaScript/Reference/Global Objects/Function/prototype"><code>prototype</code></a>上继承的属性不会再被遍历到.</p>
+ </li>
+</ul>
+
+<dl>
+</dl>
+
+<h3 id="DOM">DOM</h3>
+
+<dl>
+ <dt>Web workers可以自行终止</dt>
+ <dd><a href="/zh-cn/DOM/Using_web_workers" title="zh-cn/Using web workers">Workers</a> 开始支持<code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsIWorkerScope#close()">nsIWorkerScope.close()</a></code>方法, 该方法允许它们终止自身的运行.</dd>
+ <dt>支持文件的拖放</dt>
+ <dd><a href="/zh-cn/DragDrop/DataTransfer" title="zh-cn/DragDrop/DataTransfer"><code>DataTransfer</code></a>对象提供的拖拽监听器现在可以包含一个被拖拽的文件列表.</dd>
+ <dt>Checking to see if an element matches a specified CSS selector</dt>
+ <dd>The new <a href="/zh-CN/docs/Web/API/Node/mozMatchesSelector" title="此页面仍未被本地化, 期待您的翻译!"><code>element.mozMatchesSelector</code></a> method lets you determine whether or not an element matches a specified CSS selector. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=518003" title="FIXED: implement function to check whether element matches a CSS selector">bug 518003</a>.</dd>
+ <dt><a href="/zh-cn/Detecting_device_orientation" title="zh-cn/Detecting device orientation">Detecting device orientation</a></dt>
+ <dd>Content can now detect the orientation of the device if it has a supported accelerometer, using the <a href="/zh-cn/DOM/MozOrientation" title="zh-cn/DOM/MozOrientation"><code>MozOrientation</code></a> event. Firefox 3.6 supports the accelerometer in Mac laptops.</dd>
+ <dt><a href="/zh-cn/DOM/Detecting_document_width_and_height_changes" title="zh-cn/DOM/Detecting document width and height changes">Detecting document width and height changes</a></dt>
+ <dd>The new <code>MozScrollAreaChanged</code> event is dispatched whenever the document's <code>scrollWidth</code> and/or <code>scrollHeight</code> properties change.</dd>
+</dl>
+
+<h4 id="Miscellaneous_DOM_changes">Miscellaneous DOM changes</h4>
+
+<ul>
+ <li>The <code>getBoxObjectFor()</code> method has been <strong>removed</strong>, as it was non-standard and exposed even more non-standard stuff to the web. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=340571" title="FIXED: getBoxObjectFor leaking-onto-the-Web disaster">bug 340571</a>. Also affects <a class="external" href="http://mootools.net/" title="http://mootools.net/">MooTools</a> which uses this call for Gecko detection; this has been fixed in the latest version of MooTools, so be sure to update.</li>
+ <li>The new <a class="internal" href="/zh-cn/DOM/window.mozInnerScreenX" title="zh-cn/DOM/window.mozInnerScreenX"><code>mozInnerScreenX</code></a> and <a class="internal" href="/zh-cn/DOM/window.mozInnerScreenY" title="zh-cn/DOM/window.mozInnerScreenY"><code>mozInnerScreenY</code></a> properties on DOM windows have been added; these return the screen coordinates of the top-left corner of the window's viewport.</li>
+ <li>The new <code>mozScreenPixelsPerCSSPixel</code> attribute on the <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindowUtils" title="">nsIDOMWindowUtils</a></code> interface, accessible only to chrome, provides a conversion factor between CSS pixels and screen pixels; this value can vary based on the zoom level of the content.</li>
+ <li>When the page's URI's document fragment identifier (the part after the "#" (hash) character) changes, a new <code>hashchange</code> event is sent to the page. See <a class="internal" href="/zh-cn/DOM/window.onhashchange" title="window.onhashchange">window.onhashchange</a> for more information. <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=385434" title="FIXED: Add support for HTML5 onhashchange (event for named anchor changes)">bug 385434</a></li>
+ <li>The attribute <a class="internal" href="/zh-cn/DOM/document.readyState" title="zh-cn/DOM/document.readyState"><code>document.readyState</code></a> is now supported. <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=347174" title='FIXED: Implement document.readystate == "complete"'>bug 347174</a></li>
+ <li>Support for HTML5's <code><a class="internal" href="/zh-cn/DOM/element.classList" title="element.classList">element.classList</a></code> to allow easier handling of the class attribute. <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=501257" title="FIXED: Implement HTML 5's HTMLElement.classList property">bug 501257</a></li>
+ <li><code>localName</code> and <code>namespaceURI</code> in HTML documents now behave like they do in XHTML documents: <code>localName</code> returns in lower case and <code>namespaceURI</code> for HTML elements is <code>"<a class="external" href="http://www.w3.org/1999/xhtml" rel="freelink">http://www.w3.org/1999/xhtml</a>"</code>.</li>
+ <li><a href="/zh-cn/DOM/element.getElementsByTagNameNS" title="zh-cn/DOM/element.getElementsByTagNameNS"><code>element.getElementsByTagNameNS</code></a> no longer lowercases its argument, so upper-case ASCII letters in the argument make matches against HTML elements fail.  The same is true for <a href="/zh-cn/DOM/document.getElementsByTagNameNS" title="zh-cn/DOM/document.getElementsByTagNameNS"><code>document.getElementsByTagNameNS</code></a>.</li>
+ <li>Support has been added for addresses in geolocation via the <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMGeoPositionAddress" title="">nsIDOMGeoPositionAddress</a></code> interface and a new field added to <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMGeoPosition" title="">nsIDOMGeoPosition</a></code>.</li>
+ <li>The <a href="/zh-CN/docs/Web/API/Window/getComputedStyle" title="Window.getComputedStyle()方法返回一个对象,该对象在应用活动样式表并解析这些值可能包含的任何基本计算后报告元素的所有CSS属性的值。 私有的CSS属性值可以通过对象提供的API或通过简单地使用CSS属性名称进行索引来访问。"><code>window.getComputedStyle</code></a> function now returns quotes within <code>url()</code> values.</li>
+</ul>
+
+<h3 id="XPath">XPath</h3>
+
+<dl>
+ <dt>支持choose()方法</dt>
+ <dd><a href="/zh-cn/XPath" title="zh-cn/XPath">XPath</a>开始支持<a href="/zh-cn/XPath/Functions/choose" title="zh-cn/XPath/Functions/choose"><code>choose()</code></a><code>方法</code>.</dd>
+</dl>
+
+<h2 id="For_XUL_and_add-on_developers">For XUL and add-on developers</h2>
+
+<p>If you're an extension developer, you should start by reading <a class="internal" href="/zh-cn/Updating_extensions_for_Firefox_3.6" title="zh-cn/Updating extensions for Firefox 3.6">Updating extensions for Firefox 3.6</a>, which offers a helpful overview of what changes may affect your extension. Plug-in developers should read <a class="internal" href="/zh-cn/Updating_plug-ins_for_Firefox_3.6" title="zh-cn/Updating plug-ins for Firefox 3.6">Updating plug-ins for Firefox 3.6</a>.</p>
+
+<h3 id="New_features">New features</h3>
+
+<dl>
+ <dt><a href="/zh-cn/Detecting_device_orientation" title="zh-cn/Detecting device orientation">Detecting device orientation</a></dt>
+ <dd>Content can now detect the orientation of the device if it has a supported accelerometer, using the <a href="/zh-cn/DOM/MozOrientation" title="zh-cn/DOM/MozOrientation"><code>MozOrientation</code></a> event. Firefox 3.6 supports the accelerometer in Mac laptops.</dd>
+ <dt><a href="/zh-cn/Monitoring_HTTP_activity" title="zh-cn/Monitoring HTTP activity">Monitoring HTTP activity</a></dt>
+ <dd>You can now monitor HTTP transactions to observe requests and responses in real time.</dd>
+ <dt><a href="/zh-cn/Working_with_the_Windows_taskbar" title="zh-cn/Working with the Windows taskbar">Working with the Windows taskbar</a></dt>
+ <dd>It's now possible to customize the appearance of windows in the taskbar in Windows 7 or later. <em>This has been disabled by default in Firefox 3.6.</em></dd>
+</dl>
+
+<h3 id="Places">Places</h3>
+
+<ul>
+ <li>Places queries can now use the <code>redirectsMode</code> attribute on the <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsINavHistoryQueryOptions" title="">nsINavHistoryQueryOptions</a></code> interface to specify whether or not to include redirected pages in results.</li>
+ <li>Added the new <code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsIFaviconService#expireAllFavicons()">nsIFaviconService.expireAllFavicons()</a></code> method to the <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFaviconService" title="">nsIFaviconService</a></code> interface.</li>
+</ul>
+
+<h3 id="Storage">Storage</h3>
+
+<dl>
+ <dt><a href="/zh-cn/Storage#Collation_(sorting)" title="zh-cn/Storage#Collation (sorting)">Locale-aware collation of data is now supported by the Storage API</a></dt>
+ <dd>Gecko 1.9.2 added several new collation methods to provide optimized collation (sorting) of results using locale-aware techniques.</dd>
+ <dt><a href="/zh-cn/mozIStorageStatementParams#Enumeration_of_properties" title="zh-cn/mozIStorageStatementParams#Enumeration of properties">Properties on a statement can now be enumerated</a></dt>
+ <dd>You can now use a <code><a class="internal" href="/zh-cn/JavaScript/Reference/Statements/for...in" title="zh-cn/JavaScript/Reference/Statements/For...in">for..in</a></code> enumeration to enumerate all the properties on a statement.</dd>
+ <dt>mozIStorageStatement's getParameterIndex changed behavior between 3.5 and 3.6.</dt>
+ <dd>See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=528166" title="mozIStorageStatement getParameterIndex causes NS_ERROR_ILLEGAL_VALUE">bug 528166</a> for details.</dd>
+ <dt>Asynchronously bind multiple sets of parameters and execute a statement.</dt>
+ <dd>See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=490085" title="FIXED: Add ability to bind multiple sets of parameters and execute asynchronously">bug 490085</a> for details. Documentation coming soon.</dd>
+</dl>
+
+<h3 id="Preferences">Preferences</h3>
+
+<ul>
+ <li>The <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentPrefService" title="">nsIContentPrefService</a></code> interface has two new methods: <code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsIContentPrefService#getPrefsByName()">nsIContentPrefService.getPrefsByName()</a></code> and <code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsIContentPrefService#removePrefsByName()">nsIContentPrefService.removePrefsByName()</a></code>.</li>
+</ul>
+
+<h3 id="Themes">Themes</h3>
+
+<p>See <a class="internal" href="/zh-cn/Updating_themes_for_Firefox_3.6" title="zh-cn/Updating themes for Firefox 3.6">Updating themes for Firefox 3.6</a> for a list of changes related to themes.</p>
+
+<dl>
+ <dt><a href="/zh-cn/Themes/Lightweight_themes" title="zh-cn/Themes/Lightweight themes">Lightweight themes</a></dt>
+ <dd>Firefox 3.6 supports lightweight themes; these are easy-to-create themes that simply apply a background to the top (URL bar and button bar) and bottom (status bar) of browser windows. This is an integration of the existing <a class="external" href="http://www.getpersonas.com/" title="http://www.getpersonas.com/">Personas</a> theme architecture into Firefox.</dd>
+</dl>
+
+<h3 id="Miscellaneous">Miscellaneous</h3>
+
+<ul>
+ <li>Firefox will no longer load third-party components installed in its internal components directory. This helps to ensure stability by preventing buggy third-party components from being executed. Developers that install components this way must <a href="/zh-cn/Migrating_raw_components_to_add-ons" title="zh-cn/Migrating raw components to add-ons">repackage their components as XPI packages</a> so they can be installed as standard add-ons.</li>
+ <li><code>contents.rdf</code> is no longer supported for registering chrome in extensions. You must now use the <a class="internal" href="/zh-cn/Install_Manifests" title="zh-cn/Install manifests"><code>chrome.manifest</code></a> file instead. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=492008" title="FIXED: Drop support for contents.rdf chrome registrations">bug 492008</a>.</li>
+ <li>Added support for hiding the menu bar automatically. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=477256" title="FIXED: Implement menubar auto-hiding in toolkit">bug 477256</a>.</li>
+ <li>Added support for the <code>container-live-role</code> attribute to objects. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=391829" title="FIXED: Add support for container-live-role to object attributes">bug 391829</a>.</li>
+ <li>The <code>tabs-closebutton</code> binding has been removed. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=500971" title="FIXED: Remove obsolete tabs-closebutton binding">bug 500971</a>.</li>
+ <li>Added support to <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISound" title="">nsISound</a></code> for playing sounds based on events that have occurred. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=502799" title="FIXED: add new nsISound method for the event sounds">bug 502799</a>.</li>
+ <li>The syntax for the <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeView" title="">nsITreeView</a></code> methods <code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsITreeView#canDrop()">nsITreeView.canDrop()</a></code> and <code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsITreeView#drop()">nsITreeView.drop()</a></code> has changed to support the new drag &amp; drop API introduced in Gecko 1.9. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=455590" title="FIXED: Allow new dnd api with tree views">bug 455590</a>.</li>
+ <li>Added support to snap the mouse cursor to the default button of dialog or wizard on Windows, see <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=76053" title='FIXED: Windows mouse integration: "Snap to default button in dialog boxes"'>bug 76053</a>. This is processed automatically by dialog and wizard element. But if a XUL application creates a window using the <code>window</code> element and it has a default button, it needs to call <code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsIDOMChromeWindow#notifyDefaultButtonLoaded()">nsIDOMChromeWindow.notifyDefaultButtonLoaded()</a></code> during the window's <code>onload</code> event handler.</li>
+ <li>The <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFileMac" title="">nsILocalFileMac</a></code> interface has had two methods removed: <code>setFileTypeAndCreatorFromMIMEType()</code> and <code>setFileTypeAndCreatorFromExtension()</code>.</li>
+ <li>The new <a class="internal" href="/zh-cn/JavaScript_code_modules/NetUtil.jsm" title="zh-cn/JavaScript code modules/NetUtil.jsm"><code>NetUtils.jsm</code></a> code module provides an easy-to-use method for asynchronously copying data from an input stream to an output stream.</li>
+ <li>The new <a class="internal" href="/zh-cn/JavaScript_code_modules/openLocationLastURL.jsm" title="zh-cn/JavaScript code modules/openLocationLastURL.jsm"><code>openLocationLastURL.jsm</code></a> code module makes it easy to read and change the value of the "Open Location" dialog box's remembered URL while properly taking private browsing mode into account.</li>
+ <li>On Windows, the <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIScreen" title="">nsIScreen</a></code> interface now reports 24 bit per pixel color depths when the graphics driver claims 32 bits, since 24 more accurately represents the actual number of color pixels in use.</li>
+ <li>Menu bars can now be hidden on Windows, using the new <code id="a-autohide"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/autohide">autohide</a></code> attribute on the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbar" title="toolbar">toolbar</a></code> XUL element.</li>
+ <li>The <span id="m-loadOneTab"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/loadOneTab">loadOneTab</a></code></span> and <span id="m-addTab"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/addTab">addTab</a></code></span> methods now accept a new <code>relatedToCurrent</code> parameter and, in addition, allow the parameters to be specified by name, since nearly all of the parameters are optional.</li>
+ <li>The "<a href="/zh-cn/Install_Manifests#hidden" title="zh-cn/Install Manifests#hidden">hidden</a>" property is no longer supported in install manifests; it's no longer possible to prevent the user from seeing add-ons in the add-on manager window.</li>
+ <li>The <code>@mozilla.org/webshell;1</code> component no longer exists; you need to use <code>@mozilla.org/docshell;1</code> instead.</li>
+ <li>You can now register with the update-timer category to schedule timer events without having to instantiate the object that the timer will eventually call into; it will instead be instantiated when it's needed. See <code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsIUpdateTimerManager#registerTimer()">nsIUpdateTimerManager.registerTimer()</a></code> for details.</li>
+ <li>The <a href="/zh-cn/NPN_GetValue" title="zh-cn/NPN GetValue"><code>NPN_GetValue()</code></a> function no longer provides access to XPCOM through the variable values <code>NPNVserviceManager</code>, <code>NPNVDOMelement</code>, and <code>NPNVDOMWindow</code>. This is part of the work toward making plugins run in separate processes in a future version of Gecko.</li>
+ <li>Plugins are no longer scriptable through XPCOM (IDL) interfaces, <a href="/zh-cn/Gecko_Plugin_API_Reference/Scripting_plugins" title="zh-cn/Gecko Plugin API Reference:Scripting plugins">NPRuntime</a> is the API to use for making plugins scriptable, and <a href="/zh-cn/NPP_GetValue" title="zh-cn/NPP GetValue"><code>NPP_GetValue()</code></a> is no longer called to with the value <code>NPPVpluginScriptableInstance</code> or <code>NPPVpluginScriptableIID</code>. This is part of the work toward making plugins run in separate processes in a future version of Gecko.</li>
+</ul>
+
+<h2 id="FirefoxGecko开发">Firefox/Gecko开发</h2>
+
+<p>Certain changes are only really interesting if you work on the internals of Firefox itself.</p>
+
+<h3 id="Interfaces_merged">Interfaces merged</h3>
+
+<p>The following interfaces have been combined together:</p>
+
+<ul>
+ <li><code>nsIPluginTagInfo2</code> has been merged into <code>nsIPluginTagInfo</code>.</li>
+ <li><code>nsIPluginInstanceInternal</code>, <code>nsIPPluginInstancePeer</code>, <code>nsIPluginInstancePeer1</code>, <code>nsIPluginInstancePeer2</code>, and <code>nsIPluginInstancePeer3</code> have all been merged into <code>nsIPluginInstance</code>.</li>
+ <li><code>nsIWindowlessPlugInstPeer</code> has been merged into <code>nsIPluginInstance</code>.</li>
+ <li><code>nsIPluginManager</code> and <code>nsIPluginManager2</code> have been merged into <code>nsIPluginHost</code>.</li>
+</ul>
+
+<h3 id="Interfaces_removed">Interfaces removed</h3>
+
+<p>The following interfaces have been removed entirely because they were unused, unimplemented, or obsolete:</p>
+
+<ul>
+ <li><code>nsIFullScreen</code></li>
+ <li><code>nsIDOMSVGListener</code></li>
+ <li><code>nsIDOMSVGZoomListener</code></li>
+ <li><code>nsIInternetConfigService</code></li>
+ <li><code>nsIDKey</code></li>
+ <li><code>nsIEventHandler</code></li>
+ <li><code>nsIJRILiveConnectPIPeer</code></li>
+ <li><code>nsIJRILiveConnectPlugin</code></li>
+ <li><code>nsIScriptablePlugin</code></li>
+ <li><code>nsIClassicPluginFactory</code></li>
+ <li><code>nsIFileUtilities</code></li>
+</ul>
+
+<h3 id="Interfaces_moved">Interfaces moved</h3>
+
+<p>The following interfaces have been relocated from their previous IDL files into new ones:</p>
+
+<ul>
+ <li><code>nsIDOMNSCSS2Properties</code> is now located in its own IDL file (<code>dom/interfaces/css/nsIDOMCSS2Properties.idl</code>).</li>
+ <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIUpdateTimerManager" title="">nsIUpdateTimerManager</a></code> is now located in its own IDL file.</li>
+</ul>
+
+<p>A large number of interfaces have been moved. See <a href="/zh-cn/Interfaces_moved_in_Firefox_3.6" title="zh-cn/Interfaces moved in Firefox 3.6">Interfaces moved in Firefox 3.6</a> for a complete list.</p>
+
+<h3 id="Other_interface_changes">Other interface changes</h3>
+
+<p>The following assorted changes have been made:</p>
+
+<ul>
+ <li>The <code>nsIPlugin</code> interface now inherits from <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code> instead of <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFactory" title="">nsIFactory</a></code>.</li>
+ <li>The <code>nsIPluginHost</code> interface now inherits from <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code> instead of <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFactory" title="">nsIFactory</a></code>.</li>
+ <li>The <code>nsIFrame</code> interface now inherits from <code>nsQueryFrame</code> instead of <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code>.</li>
+ <li>The <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDeviceContext" title="">nsIDeviceContext</a></code> method <code>getPaletteInfo()</code> has been removed, as it was never implemented.</li>
+ <li>The <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIScriptContext" title="">nsIScriptContext</a></code> method <code>reportPendingException()</code> has been removed, since it was no longer being used.</li>
+</ul>
+
+<h3 id="Changes_in_accessibility_code">Changes in accessibility code</h3>
+
+<ul>
+ <li>The <span style="font-family: monospace;">EVENT</span><code>_REORDER</code> <a href="/zh-cn/XPCOM_Interface_Reference/nsIAccessibleEvent" title="zh-cn/XPCOM Interface Reference/nsIAccessibleEvent">accessibility event</a> is now sent when the children of frames and iframes change, as well as when the main document's children change. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=420845" title="FIXED: Fire event_reorder on any embedded frames/iframes whos document has just loaded.">bug 420845</a>.</li>
+ <li>The <code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsIAccessibleTable#selectRow()">nsIAccessibleTable.selectRow()</a></code> now correctly removes any current selection before selecting the specified row.</li>
+</ul>
+
+<h2 id="相关链接">相关链接</h2>
+
+<ul>
+ <li><a href="/zh-cn/Firefox_5_for_developers" title="zh-cn/Firefox 5 for developers">Firefox 5 for developers</a></li>
+ <li><a href="/zh-cn/Firefox_4_for_developers" title="zh-cn/Firefox 4 for developers">Firefox 4 for developers</a></li>
+ <li><a class="internal" href="/zh-cn/Firefox_3.5_for_developers" title="zh-cn/Firefox 3.5 for developers">Firefox 3.5 for developers</a></li>
+ <li><a class="internal" href="/zh-cn/Firefox_3_for_developers" title="zh-cn/Firefox 3 for developers">Firefox 3 for developers</a></li>
+ <li><a class="internal" href="/zh-cn/Firefox_2_for_developers" title="zh-cn/Firefox 2 for developers">Firefox 2 for developers</a></li>
+ <li><a class="internal" href="/zh-cn/Firefox_1.5_for_developers" title="zh-cn/Firefox 1.5 for developers">Firefox 1.5 for developers</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/firefox/releases/3/index.html b/files/zh-cn/mozilla/firefox/releases/3/index.html
new file mode 100644
index 0000000000..561c473cd3
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/3/index.html
@@ -0,0 +1,310 @@
+---
+title: 致Firefox 3开发者
+slug: Mozilla/Firefox/Releases/3
+tags:
+ - Firefox 3
+translation_of: Mozilla/Firefox/Releases/3
+---
+<div>{{FirefoxSidebar}}</div><p>如果你是一个Web开发人员,并且希望了解Firefox 3中所有的新特性,这里是一个很好的起点。这篇文章提供了一个覆盖所有Firefox 3新特性的列表。虽然他并不是能够包括所有微小的改动,但他能够帮助你学习到最主要的更新。</p>
+<p> </p>
+<h3 id="Firefox_3_.E4.B8.AD.E6.96.B0.E7.9A.84.E5.BC.80.E5.8F.91.E4.BA.BA.E5.91.98.E7.89.B9.E6.80.A7" name="Firefox_3_.E4.B8.AD.E6.96.B0.E7.9A.84.E5.BC.80.E5.8F.91.E4.BA.BA.E5.91.98.E7.89.B9.E6.80.A7">Firefox 3 中新的开发人员特性</h3>
+<h4 id=".E5.AF.B9.E7.BD.91.E7.AB.99.E5.92.8C.E7.A8.8B.E5.BA.8F.E5.BC.80.E5.8F.91.E8.80.85" name=".E5.AF.B9.E7.BD.91.E7.AB.99.E5.92.8C.E7.A8.8B.E5.BA.8F.E5.BC.80.E5.8F.91.E8.80.85">对网站和程序开发者</h4>
+<dl>
+ <dt>
+ <a href="/cn/%E6%9B%B4%E6%96%B0WEB%E5%BA%94%E7%94%A8%E4%BB%A5%E9%80%82%E5%BA%94Firefox_3" title="cn/更新WEB应用以适应Firefox_3">更新WEB应用以适应Firefox 3</a></dt>
+ <dd>
+ 提供了您用于更新WEB应用以受益于Firefox 3新特性所需的信息。</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/%E4%B8%8A%E7%BA%BF%E4%B8%8E%E7%A6%BB%E7%BA%BF%E4%BA%8B%E4%BB%B6" title="cn/上线与离线事件">上线与离线事件</a></dt>
+ <dd>
+ Firefox 3支持WHATWG的上线与离线事件,基于这一特性,程序可以检测当前是否有可用的互联网联接以及何时上线或下线。</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/%E8%B7%A8%E5%9F%9F%E7%9A%84XMLHttpRequest%E8%AF%B7%E6%B1%82" title="cn/跨域的XMLHttpRequest请求">跨域的XMLHttpRequest请求</a></dt>
+ <dd>
+ Firefox 3支持<a class="external" href="http://www.w3.org/TR/access-control/">W3C Access Control</a>工作草案,使你有能够使用<a href="/cn/XMLHttpRequest" title="cn/XMLHttpRequest">XMLHttpRequests</a>检索和操作其他站点的数据;使你能够创造令人印象深刻的以浏览器为基础的交互式应用(mashups)。</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/%E4%BA%A4%E9%94%99%E6%A0%BC%E5%BC%8F%E6%A0%B7%E8%A1%A8" title="cn/交错格式样表">交错格式样表</a></dt>
+ <dd>
+ Firefox 3 支持CSS 层叠式样式表 API.</dd>
+ <br>
+ <dd>
+ <a href="/cn/DOM/window.navigator.registerProtocolHandler" title="cn/DOM/window.navigator.registerProtocolHandler"><strong>基于web的协议处理</strong></a></dd>
+ <dd>
+ 你现在可以使用<code>navigator.registerProtocolHandler()方法</code>注册web应用</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/%E5%9C%A8%E7%94%BB%E7%94%BB%E5%B8%83%EF%BC%88canvas%EF%BC%89%E4%B8%AD%E2%80%9C%E7%BB%98%E2%80%9D%E5%87%BA%E6%96%87%E5%AD%97" title="cn/在画画布(canvas)中“绘”出文字">在画布(canvas)中“绘”出文字</a></dt>
+ <dd>
+ 您可以使用Firefox 3支持的非标准API在canvas上绘制文字。</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/Canvas_tutorial/Transformations#Transforms" title="cn/Canvas_tutorial/Transformations#Transforms">支持画布变换</a></dt>
+ <dd>
+ Firefox现在的canvas支持<code>transform()</code><span style="font-family: monospace;">和</span><code>setTransform()方法。</code></dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/%E4%BD%BF%E7%94%A8%E5%BE%AE%E6%A0%BC%E5%BC%8F" title="cn/使用微格式">使用微格式</a></dt>
+ <dd>
+ Firefox现在有一组微格式的API。</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/%E6%8B%96%E6%94%BE%E4%BA%8B%E4%BB%B6" title="cn/拖放事件">拖放事件</a></dt>
+ <dd>
+ Firefox 3 支持新的拖放事件,当拖放开始和结束时,该事件将会被发送至源节点。</dd>
+ <dd>
+ <a href="/cn/Focus_management_in_HTML" title="cn/Focus_management_in_HTML"><strong>HTML的焦点管理</strong></a></dd>
+</dl>
+<dl>
+ <dd>
+ 新的HTML 5 支持activeElement和hasFocus属性</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/%E7%A6%BB%E7%BA%BF%E6%B5%8F%E8%A7%88" title="cn/离线浏览">离线浏览</a></dt>
+ <dd>
+ 在Firefox中,WEB程序现在可以在离线时使用之前被缓存的资源。</dd>
+ <dt>
+ <a href="/cn/%E5%9C%A8Firefox_3%E4%B8%ADCSS%E7%9A%84%E6%94%B9%E8%BF%9B" title="cn/在Firefox_3中CSS的改进">在Firefox 3中CSS的改进</a></dt>
+ <dd>
+ Firefox 3 在支持CSS的功能上进行了一些完善。</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/%E5%9C%A8Firefox_3%E4%B8%ADDOM%E7%9A%84%E6%94%B9%E8%BF%9B" title="cn/在Firefox_3中DOM的改进">在Firefox 3中DOM的改进</a></dt>
+ <dd>
+ Firefox 3 在Firefox3 DOM执行方面提供了一些新的功能,包括支持一些扩展的浏览器的DOM。</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/%E5%AF%B9_JavaScript_1.8" title="cn/对_JavaScript_1.8">JavaScript 1.8 的支持</a></dt>
+ <dd>
+ Firefox 3 提供了 JavaScript 1.8 标准的支持。</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/EXSLT" title="cn/EXSLT">EXSLT支持</a></dt>
+ <dd>
+ Firefox 3 提供了对 <a href="/cn/EXSLT" title="cn/EXSLT">EXSLT</a>( <a href="/cn/XSLT" title="cn/XSLT">XSLT</a>的扩展)一个基本子集个支持。</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/Firefox_3%E4%B8%ADSVG%E7%9A%84%E6%94%B9%E8%BF%9B" title="cn/Firefox_3中SVG的改进">Firefox 3中SVG的改进</a></dt>
+ <dd>
+ Firefox 3 对SVG 的支持有了长足的改进:支持二十余个新透镜、一些新元素、一些新属性以及一些其他改进。</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/%E5%AF%B9PNG%E5%8A%A8%E7%94%BB%E7%9A%84%E6%94%AF%E6%8C%81" title="cn/对PNG动画的支持">对PNG动画的支持</a></dt>
+ <dd>
+ Firefox 3 提供了对色彩艳丽的 PNG (APNG) 图像格式的支持.</dd>
+</dl>
+<dl>
+ <dt>
+ <code><a href="/cn/HTML/Element/a" title="cn/HTML/Element/a">&lt;a ping&gt;</a></code></dt>
+ <dd>
+  <code>现在可以使用 &lt;a ping&gt;</code> 功能 ping 一个 URL ,并且此功能默认启用.</dd>
+</dl>
+<h4 id=".E5.AF.B9XUL.E5.92.8C.E6.89.A9.E5.B1.95.E6.8F.92.E4.BB.B6.E7.9A.84.E5.BC.80.E5.8F.91.E8.80.85" name=".E5.AF.B9XUL.E5.92.8C.E6.89.A9.E5.B1.95.E6.8F.92.E4.BB.B6.E7.9A.84.E5.BC.80.E5.8F.91.E8.80.85">对XUL和扩展插件的开发者</h4>
+<p> </p>
+<dl>
+</dl>
+<p>   提供了你需要做的事情的向导,更新您的Firefox 3 扩展。</p>
+<dl>
+ <dt>
+ <a href="/cn/%E6%9B%B4%E6%96%B0%E6%89%A9%E5%B1%95%E4%BB%A5%E5%85%BC%E5%AE%B9Firefox_3" title="cn/更新扩展以兼容Firefox_3">更新扩展以兼容Firefox 3</a></dt>
+</dl>
+<p><a href="/cn/FUEL" title="cn/FUEL"><strong>FUEL 知识库</strong></a></p>
+<dl>
+ <dd>
+ FUEL 使扩展开发者完成更有成效,更精悍的 XPCOM 规范代码并获得一些 "模式" JavaScript 思想。</dd>
+</dl>
+<p>   Firefox 3的提供了一些新的XUL元素,包括新的缩放法,日期和时间获取,以及旋转按钮。</p>
+<dl>
+ <dt>
+ <a href="/cn/XUL_improvements_in_Firefox_3" title="cn/XUL_improvements_in_Firefox_3">Firefox  3在 </a><a href="/cn/XUL_improvements_in_Firefox_3" title="cn/XUL_improvements_in_Firefox_3">XUL 上的改进</a>   </dt>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/Templates_in_Firefox_3" title="cn/Templates_in_Firefox_3">Firefox 3的模板</a></dt>
+ <dd>
+ Firefox 3的模板已显着改善 。关键的改进是,允许使用自定义查询处理器,除数据源之外还可以使用RDF。 </dd>
+</dl>
+<p><a href="/cn/XBL/XBL_1.0_Reference/Elements#binding" title="cn/XBL/XBL_1.0_Reference/Elements#binding"><strong>嵌入的XBL绑定</strong></a></p>
+<dl>
+ <dd>
+ 现在,您可以使用 data: 网络协议直接嵌入XBL绑定,而不是在单独的XML文件中使用他们。
+ <p> </p>
+ </dd>
+ <dt>
+ <a href="/cn/Localizing_extension_descriptions" title="cn/Localizing_extension_descriptions">本地化扩展描述</a></dt>
+ <dd>
+ 这可让本地化的详细信息在附加组件被下载时或被禁用即时生效。 </dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/Extension_Versioning,_Update_and_Compatibility#Securing_Updates" title="cn/Extension_Versioning,_Update_and_Compatibility#Securing_Updates">可靠更新</a></dt>
+</dl>
+<p>In order to provide a more secure add-on upgrade path for users, add-ons are now required to provide a secure method for obtaining updates before they can be installed. Add-ons hosted at</p>
+<p><a class="external" href="http://addons.mozilla.org/" rel="external nofollow" title="http://addons.mozilla.org">AMO</a></p>
+<p>automatically provide this. Any add-ons installed that do not provide a secure update method when the user upgrades to Firefox 3 will be automatically disabled. Firefox will however continue to check for updates to the extension over the insecure path and attempt to install any update offered (installation will fail if the update also fails to provide a secure update method).</p>
+<dl>
+ <dt>
+ <a href="/cn/NsIIdleService" title="cn/NsIIdleService">Idle service</a></dt>
+</dl>
+<dl>
+ <dd>
+ Firefox 3 offers the new {{ Interface("nsIIdleService") }} interface, which lets extensions determine how long it's been since the user last pressed a key or moved their mouse.</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/%E5%85%A8%E5%B1%8F%E7%BC%A9%E6%94%BE" title="cn/全屏缩放">全屏缩放</a></dt>
+</dl>
+<dl>
+ <dd>
+ Firefox 3 improves the user experience by offering full page zoom in addition to text-only zoom.</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/Interfacing_with_the_XPCOM_cycle_collector" title="cn/Interfacing_with_the_XPCOM_cycle_collector">Interfacing with the XPCOM cycle collector</a></dt>
+</dl>
+<dl>
+ <dd>
+ XPCOM code can now take advantage of the cycle collector, which helps ensure that unused memory gets released instead of leaking.</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/The_Thread_Manager" title="cn/The_Thread_Manager">The Thread Manager</a></dt>
+</dl>
+<dl>
+ <dd>
+ Firefox 3 provides the new {{ Interface("nsIThreadManager") }} interface, along with new interfaces for threads and thread events, which provides a convenient way to create and manage threads in your code.</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/JavaScript%E6%A8%A1%E5%9D%97" title="cn/JavaScript模块">JavaScript模块</a></dt>
+</dl>
+<dl>
+ <dd>
+ Firefox 3 now offers a new shared code module mechanism that lets you easily create modules in JavaScript that can be loaded by extensions and applications for use, much like shared libraries.</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/Places" title="cn/Places">Places</a></dt>
+</dl>
+<dl>
+ <dd>
+ The history and bookmarks APIs have been completely replaced by the new <a href="/cn/Places" title="cn/Places">Places</a> API.</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/Making_the_transition_to_Places" title="cn/Making_the_transition_to_Places">Making the transition to Places</a></dt>
+</dl>
+<dl>
+ <dd>
+ An article about how to update an existing extension to use the Places API.</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/Firefox_3%E4%B8%AD%E4%B8%8B%E8%BD%BD%E7%AE%A1%E7%90%86%E5%99%A8%E7%9A%84%E6%94%B9%E8%BF%9B" title="cn/Firefox_3中下载管理器的改进">Firefox 3中下载管理器的改进</a></dt>
+</dl>
+<dl>
+ <dd>
+ The Firefox 3 Download Manager features new and improved APIs, including support for multiple progress listeners.</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/Using_nsILoginManager" title="cn/Using_nsILoginManager">Using nsILoginManager</a></dt>
+</dl>
+<dl>
+ <dd>
+ 密码管理已经被新的登录管理所代替。</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/Using_content_preferences" title="cn/Using_content_preferences">Using content preferences</a></dt>
+</dl>
+<dl>
+ <dd>
+ Firefox 3 includes a new service for getting and setting arbitrary site-specific preferences that extensions as well as core code can use to keep track of their users' preferences for individual sites.</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/Notable_bugs_fixed_in_Firefox_3" title="cn/Notable_bugs_fixed_in_Firefox_3">Notable bugs fixed in Firefox 3</a></dt>
+</dl>
+<dl>
+ <dd>
+ 文章中所提供的相关Bug信息,已经在Firefox 3中进行了修改。</dd>
+</dl>
+<dl>
+ <dt>
+ <a href="/cn/Firefox_3_%E7%9A%84%E7%95%8C%E9%9D%A2%E6%94%B9%E5%8A%A8" title="cn/Firefox_3_的界面改动">Firefox 3 的界面改动</a></dt>
+</dl>
+<dl>
+ <dd>
+ Notes and information of use to people who want to create themes for Firefox 3.</dd>
+</dl>
+<h3 id=".E6.9C.80.E7.BB.88.E7.94.A8.E6.88.B7.E5.B0.86.E8.83.BD.E4.BD.93.E9.AA.8C.E5.88.B0.E7.9A.84.E6.96.B0.E7.89.B9.E6.80.A7" name=".E6.9C.80.E7.BB.88.E7.94.A8.E6.88.B7.E5.B0.86.E8.83.BD.E4.BD.93.E9.AA.8C.E5.88.B0.E7.9A.84.E6.96.B0.E7.89.B9.E6.80.A7">最终用户将能体验到的新特性</h3>
+<h4 id=".E7.94.A8.E6.88.B7.E4.BD.93.E9.AA.8C" name=".E7.94.A8.E6.88.B7.E4.BD.93.E9.AA.8C">用户体验</h4>
+<ul>
+ <li><strong>更轻松的密码管理.</strong> 当你成功登陆之后在浏览器顶端会出现一个信息栏,提示你是否保存此口令。</li>
+ <li><strong>附件组件安装更简便.</strong> 你可以更容易的通过第三方下载附件组件并安装它。</li>
+ <li><strong>新的下载管理器.</strong> 新的下载管理器使你更容易的定位下载文件。</li>
+ <li><strong>断点下载.</strong> 现在可以在重启浏览器或重新获得网络连接时继续尚未完成的下载任务。</li>
+ <li><strong>全屏缩放.</strong> 今后,你可以使用菜单或快捷键, 可以缩放整个网页的内容 -- 这个比例取决除了文字排版,还取决于更合适的图片排版 .</li>
+ <li><strong>标签滚动和快捷菜单.</strong> 通过新的标签滚动和标签快捷菜单可以更容易的定位标签。</li>
+ <li><strong>保存您当前的浏览内容.</strong> 当你退出Firefox 3 时,Firefox 3 会提示你是否保存当前标签。</li>
+ <li><strong>优化的标签打开方式.</strong> 在标签中打开一个书签文件夹时,会创建一个新标签二不是覆盖现有的。</li>
+ <li><strong>轻松更改搜索引挚工具框的大小和位置.</strong> 你可以简单的通过一个拖动鼠标改变搜索引擎工具栏和地址栏的分布。</li>
+ <li><strong>改进了文本选择.</strong> 使用 Crtl (Macintosh的Command)键选择多块文本. 双击可以选中个词(中文为一句)三击选中一段。</li>
+ <li><strong>查找工具.</strong> 查找工具以当前选中内容为默认查找内容.</li>
+ <li><strong>扩展管理.</strong> 用户可以在附件组件管理器中单独显示插件.</li>
+ <li><strong>与Windows Vista的整合.</strong> 火狐菜单用一个Vista本地主题显示.</li>
+ <li><strong>与</strong><strong>Mac OS X</strong><strong>的整合</strong><strong>.</strong> Firefox 现在使用Mac OS X 拼写检查器并使用 <a class="external" href="http://growl.info/">Growl</a> 来通知下载完成或有可用更新。</li>
+ <li><strong>星按钮.</strong> 地址栏上的“星”按钮使你通过一个点击添加一个新书签。一次双击保存并编辑你的新书签。</li>
+ <li><strong>标签.</strong> 可以为你的书签指定关键词,并按主题排序。</li>
+ <li><strong>地址栏和自动地址补全.</strong> 在地址栏键入页面标题或标签可以快速找到你在书签中的或是历史页面。图标、书签、标签可以帮助你判断结果的来源。</li>
+ <li><strong>智能书签菜单.</strong> Firefox 的智能书签会按照最新,访问频率来排序书签。</li>
+ <li><strong>书签和历史管理器.</strong> 书签和历史管理统一起来,让你可以通过多视图、按照频率组织的智能分组方便的同时检索书签及历史。</li>
+ <li><strong>基于Web的协议处理.</strong> 网络应用, 比如你最喜欢的电子邮件提供商可以代替本地邮件应用来处理<code> mailto:</code> 链接。对于其他也提供相似的支持。 (注意网络应用需要向火狐注册)</li>
+ <li><strong>易于使用的下载.</strong> 一个新的引用界面提供高级选项来配置对不同文件类型及协议策略的处理方案。</li>
+ <li><strong>改进的浏览器外观.</strong> 新的图形及字体处理方案使网页在你的屏幕上显示的更漂亮。包括清晰的文字渲染、连体字、复杂文字的更好支持。另外Mac 及 Linux (Gnome) 用户会发现 Firefox 感觉起来更像他们本地的应用或平台一样。</li>
+ <li><strong>支持颜色设置.</strong> 通过设置 <code>在{{ mediawiki.external('about:config') }} 的 </code><code>gfx.color_management.enabled</code> 优先级,您可以要求Firefox的按照新的配置文件中对图像的颜色进行调整,以符合您电脑的显示器。</li>
+ <li><strong>支持离线浏览.</strong>即使您没有Internet连接,Web应用程序仍可使用。</li>
+</ul>
+<h4 id=".E5.AE.89.E5.85.A8.E5.92.8C.E9.9A.90.E7.A7.81" name=".E5.AE.89.E5.85.A8.E5.92.8C.E9.9A.90.E7.A7.81">安全和隐私</h4>
+<ul>
+ <li><strong>一键网站信息.</strong> 想知道更多关于您所访问网站的信息?点击该网站的图标,在地址栏中看看是谁拥有它。信息更易理解。</li>
+ <li><strong>恶意软件防护.</strong>如果你访问了一个已知的安装病毒,间谍软件,木马,或其他危险软件(也称为恶意软件)的网站 Firefox 3 会警告你 。你可以<a class="link-https" href="https://www.mozilla.com/firefox/its-an-attack.html">点这里</a>看看警告是怎样的。</li>
+ <li><strong>伪造网站保护加强.</strong> 现在,当您访问的网站被怀疑是伪造时,会出现一个特殊的网页。<a class="link-https" href="https://www.mozilla.com/firefox/its-a-trap.html">点击这里</a>看看是什么样子。</li>
+</ul>
+<ul>
+ <li><strong>更容易理解的SSL错误</strong><strong>.</strong>遇到无效的SSL证书时会包含清楚的错误描述,使其更易于理解是哪里发生了问题。</li>
+ <li><strong>过期附件组件防护.</strong> 现在Firefox 3的自动检查插件和插件版本并禁用过时的,不安全的版本。</li>
+ <li><strong>安全附件更新</strong><strong>.</strong> 附件更新安全性提高了,不允许使用不安全的更新机制。</li>
+ <li><strong>防病毒一体化。</strong> Firefox 3 在下载文件的同时通知的反病毒软件。</li>
+ <li><strong>Windows Vista的家长控制功能的支持。 </strong>Firefox 3的支持Vista的全系统家长控制,禁用文件下载。</li>
+</ul>
+<h4 id=".E6.80.A7.E8.83.BD" name=".E6.80.A7.E8.83.BD">性能</h4>
+<ul>
+ <li><strong>可靠性.</strong>Firefox 3 使用安全的数据库格式保存书签,历史记录, cookies ,及偏好。这意味着,即使系统崩溃,您的数据也免受损失。</li>
+ <li><strong>速度.</strong> Firefox 3有了较大的性能提升,完全取代了部分软件:包括图形屏幕处理,以及页面布局工作的处理等。</li>
+ <li><strong>更少的内存占用.</strong> Firefox 3的内存使用比以往任何时候都有效,有超过300个内存“泄漏”漏洞得以修复,以及可帮助自动查找和处置泄漏内存的新功能被添加进来。</li>
+</ul>
+<h3 id=".E5.8F.82.E8.A7.81" name=".E5.8F.82.E8.A7.81">参见</h3>
+<ul>
+ <li><a href="/cn/Updating_extensions_for_Firefox_3" title="cn/Updating_extensions_for_Firefox_3">对Firefox 3的扩展进行更新</a></li>
+ <li><a href="/cn/Updating_web_applications_for_Firefox_3" title="cn/Updating_web_applications_for_Firefox_3">对Firefox 3的Web应用进行更新</a></li>
+ <li><a href="/cn/Firefox_2_for_developers" title="cn/Firefox_2_for_developers">Firefox 2 for developers</a></li>
+ <li><a href="/cn/Firefox_1.5_for_developers" title="cn/Firefox_1.5_for_developers">Firefox 1.5 for developers</a></li>
+</ul>
+<p>{{ languages( { "es": "es/Firefox_3_para_desarrolladores", "fr": "fr/Firefox_3_pour_les_d\u00e9veloppeurs", "ja": "ja/Firefox_3_for_developers", "zh-tw": "zh_tw/Firefox_3_for_developers", "zh-cn": "cn/Firefox_3_for_developers", "ko": "ko/Firefox_3_for_developers", "pl": "pl/Firefox_3_dla_programist\u00f3w", "pt": "pt/Firefox_3_para_desenvolvedores" } ) }}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/3/site_compatibility/index.html b/files/zh-cn/mozilla/firefox/releases/3/site_compatibility/index.html
new file mode 100644
index 0000000000..b8b2678b12
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/3/site_compatibility/index.html
@@ -0,0 +1,26 @@
+---
+title: Gecko 1.9 Changes affecting websites
+slug: Mozilla/Firefox/Releases/3/Site_compatibility
+translation_of: Mozilla/Firefox/Releases/3/Site_compatibility
+---
+<div>{{FirefoxSidebar}}</div><p>此页设法提供在 <a href="cn/Gecko">Gecko</a> 1.8 和 Gecko 1.9 之间的变动概要,这些变动可能会影响某些网站的行为或网页渲染。</p>
+<p>参见 <a href="cn/Firefox_3_for_developers">Firefox 3 开发者参考</a></p>
+<h2 id=".E4.BA.8B.E4.BB.B6" name=".E4.BA.8B.E4.BB.B6">事件</h2>
+<h3 id=".E6.8D.95.E8.8E.B7_load_.E4.BA.8B.E4.BB.B6.E7.9B.91.E5.90.AC" name=".E6.8D.95.E8.8E.B7_load_.E4.BA.8B.E4.BB.B6.E7.9B.91.E5.90.AC">捕获 load 事件监听</h3>
+<p>在 Gecko 1.8 中,不能在图片上设置 load 事件监听。 在 Gecko 1.9 中,已在 {{ Bug(234455) }} 中修复。 但是在某些网站中,由于捕获 load 事件的事件监听器不正确而导致问题。参见 {{ Bug(335251) }} 中的讨论。 要修复这个问题,出错的页面不再需要设置事件监听器。</p>
+<p>例如,如下:</p>
+<pre class="eval">window.addEventListener('load', yourFunction, true);
+</pre>
+<p>应该更改为:</p>
+<pre class="eval">window.addEventListener('load', yourFunction, false);
+</pre>
+<p>事件捕获如何工作的解释,参见 <a class="external" href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-flow-capture">DOM Level 2 事件捕获</a></p>
+<h3 id="preventBubble_.E5.B7.B2.E8.A2.AB.E7.A7.BB.E5.87.BA" name="preventBubble_.E5.B7.B2.E8.A2.AB.E7.A7.BB.E5.87.BA">preventBubble 已被移出</h3>
+<h3 id=".E5.B0.91.E8.AE.B8.E6.97.A7.E7.9A.84.E4.BA.8B.E4.BB.B6_API_.E4.B8.8D.E5.86.8D.E8.A2.AB.E6.94.AF.E6.8C.81" name=".E5.B0.91.E8.AE.B8.E6.97.A7.E7.9A.84.E4.BA.8B.E4.BB.B6_API_.E4.B8.8D.E5.86.8D.E8.A2.AB.E6.94.AF.E6.8C.81">少许旧的事件 API 不再被支持</h3>
+<h2 id="DOM" name="DOM">DOM</h2>
+<h3 id="WRONG_DOCUMENT_ERR" name="WRONG_DOCUMENT_ERR">WRONG_DOCUMENT_ERR</h3>
+<h2 id=".E8.8C.83.E5.9B.B4" name=".E8.8C.83.E5.9B.B4">范围</h2>
+<h3 id="intersectsNode_.E5.B7.B2.E8.A2.AB.E7.A7.BB.E5.87.BA" name="intersectsNode_.E5.B7.B2.E8.A2.AB.E7.A7.BB.E5.87.BA">intersectsNode 已被移出</h3>
+<h3 id="compareNode_.E5.B7.B2.E8.A2.AB.E7.A7.BB.E5.87.BA" name="compareNode_.E5.B7.B2.E8.A2.AB.E7.A7.BB.E5.87.BA">compareNode 已被移出</h3>
+<h2 id="HTML" name="HTML">HTML</h2>
+<h3 id=".3Cobject.3E_.E4.B8.AD.E7.9A.84.E8.AE.B8.E5.A4.9A_bug_.E5.B7.B2.E7.BB.8F.E4.BF.AE.E5.A4.8D" name=".3Cobject.3E_.E4.B8.AD.E7.9A.84.E8.AE.B8.E5.A4.9A_bug_.E5.B7.B2.E7.BB.8F.E4.BF.AE.E5.A4.8D">&lt;object&gt; 中的许多 bug 已经修复</h3>
diff --git a/files/zh-cn/mozilla/firefox/releases/31/index.html b/files/zh-cn/mozilla/firefox/releases/31/index.html
new file mode 100644
index 0000000000..a22131fe8c
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/31/index.html
@@ -0,0 +1,46 @@
+---
+title: Firefox 31 for developers
+slug: Mozilla/Firefox/Releases/31
+translation_of: Mozilla/Firefox/Releases/31
+---
+<div>{{FirefoxSidebar}}</div><p><span style="font-size: 30px; font-weight: 700; letter-spacing: -1px; line-height: 30px;">Web 开发者需要关注的变化</span></p>
+<h3 id="Developer_Tools">Developer Tools</h3>
+<p><em>No change.</em></p>
+<h3 id="CSS">CSS</h3>
+<ul>
+ <li>CSS变量的语法从旧的 "var-" 前缀更新为新的 "--" 前缀.({{Bug(985838)}})</li>
+ <li>Unwanted white space for multiple of 10,000 in Korean counte.({{Bug(985186)}})</li>
+</ul>
+<h3 id="HTML">HTML</h3>
+<p><em>No change.</em></p>
+<h3 id="JavaScript">JavaScript</h3>
+<p>实现了如下 ECMAScript 6 新特性:</p>
+<ul>
+ <li><code>Array</code> 方法: {{jsxref("Array.prototype.fill()")}} ({{Bug(911147)}})</li>
+ <li><code>Math</code> 函数: {{jsxref("Math.clz32()")}} ({{Bug(925123)}})</li>
+ <li><code>String</code> 方法: {{jsxref("String.prototype.normalize()")}} ({{Bug(918987)}}).</li>
+</ul>
+<h3 id="InterfacesAPIsDOM">Interfaces/APIs/DOM</h3>
+<ul>
+ <li>Constructor of <code>KeyboardEvent</code> has been implemented ({{Bug(930893)}}).</li>
+ <li><code>KeyboardEvent.initKeyboardEvent()</code> has been implemented ({{Bug(930893)}}).</li>
+ <li><code>KeyboardEvent.isComposing</code> attribute has been implemented ({{Bug(993234)}}).</li>
+ <li><code>InputEvent</code> interface has been implemented ({{Bug(993253)}}).</li>
+ <li><code>InputEvent.isComposing</code> attribute has been implemented ({{Bug(993253)}}).</li>
+</ul>
+<h3 id="MathML">MathML</h3>
+<p><em>No change.</em></p>
+<h3 id="SVG">SVG</h3>
+<p><em>No change.</em></p>
+<h3 id="AudioVideo">Audio/Video</h3>
+<p><em>No change.</em></p>
+<h2 id="Security">Security</h2>
+<p><em>No change.</em></p>
+<h2 id="Changes_for_add-on_and_Mozilla_developers">Changes for add-on and Mozilla developers</h2>
+<p><em>No change.</em></p>
+<h2 id="See_also">See also</h2>
+<ul>
+ <li><a href="/en-US/docs/Mozilla/Firefox/Releases/31/Site_Compatibility">Site Compatibility for Firefox 31</a></li>
+</ul>
+<h3 id="Older_versions">Older versions</h3>
+<p>{{Firefox_for_developers('30')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/32/index.html b/files/zh-cn/mozilla/firefox/releases/32/index.html
new file mode 100644
index 0000000000..b2bfbc3fd9
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/32/index.html
@@ -0,0 +1,154 @@
+---
+title: Firefox 32 for developers
+slug: Mozilla/Firefox/Releases/32
+tags:
+ - Firefox
+ - Firefox 31
+translation_of: Mozilla/Firefox/Releases/32
+---
+<div>{{FirefoxSidebar}}</div><h2 id="普通_Web_开发者应该注意的变化">普通 Web 开发者应该注意的变化</h2>
+
+<h3 id="开发者工具">开发者工具</h3>
+
+<p>Highlights:</p>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Web_Audio_Editor">Web Audio Editor</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Scratchpad#Code_completion_and_inline_documentation">Code completion and inline documentation in Scratchpad</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector#Rules_view">User agent styles in the Inspector's Rules view</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector#Firefox_32_onwards_2">Element picker button has moved</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector#Firefox_32_onwards">Node dimensions added to the Inspector's infobar</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Tools_Toolbox#Extra_tools">Full page screenshot button added</a></li>
+ <li>HiDPI images added to the tools</li>
+ <li>Nodes that have <code>display:none</code> are shown differently in the Inspector</li>
+</ul>
+
+<p><a href="https://bugzilla.mozilla.org/buglist.cgi?resolution=FIXED&amp;classification=Client%20Software&amp;chfieldto=2014-06-09&amp;chfield=resolution&amp;query_format=advanced&amp;chfieldfrom=2014-04-28&amp;chfieldvalue=FIXED&amp;bug_status=RESOLVED&amp;bug_status=VERIFIED&amp;component=Developer%20Tools&amp;component=Developer%20Tools%3A%203D%20View&amp;component=Developer%20Tools%3A%20App%20Manager&amp;component=Developer%20Tools%3A%20Canvas%20Debugger&amp;component=Developer%20Tools%3A%20Console&amp;component=Developer%20Tools%3A%20Debugger&amp;component=Developer%20Tools%3A%20Framework&amp;component=Developer%20Tools%3A%20Graphic%20Commandline%20and%20Toolbar&amp;component=Developer%20Tools%3A%20Inspector&amp;component=Developer%20Tools%3A%20Memory&amp;component=Developer%20Tools%3A%20Netmonitor&amp;component=Developer%20Tools%3A%20Object%20Inspector&amp;component=Developer%20Tools%3A%20Profiler&amp;component=Developer%20Tools%3A%20Responsive%20Mode&amp;component=Developer%20Tools%3A%20Scratchpad&amp;component=Developer%20Tools%3A%20Source%20Editor&amp;component=Developer%20Tools%3A%20Style%20Editor&amp;component=Developer%20Tools%3A%20User%20Stories&amp;component=Developer%20Tools%3A%20WebGL%20Shader%20Editor&amp;product=Firefox">All devtools bugs fixed between Firefox 31 and Firefox 32</a>.</p>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>默认开启 {{cssxref("mix-blend-mode")}} ({{Bug(952643)}})。</li>
+ <li>在正式版本中默认开启 <code>position:sticky</code> (之前只在 Nightly 和 Aurora 版本中才会开启) ({{Bug(916315)}})。</li>
+ <li>implement box-decoration-break: Left/right part of a box-shadow should only be drawn on the first/last continuation of an inline box ({{Bug(613659)}}).</li>
+ <li>允许  {{cssxref("flex-grow")}} / {{cssxref("flex-shrink")}} 在 0 和非 0 值之间作 transition ,  like 'flex-grow: 0.6'({{Bug(996945)}}).</li>
+</ul>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>Experimentally implemented, behind a pref, {{HTMLElement("img")}} {{HTMLattrxref("srcset", "img")}} property, To activate it  set <code>dom.image.srcset.enable</code> to <code>true</code> ({{Bug(870021)}}).</li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id"><strong>id</strong></a> and <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class"><strong>class</strong></a> are now true <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes">global attributes</a> and also apply to XML elements, in a namespace or not ({{bug(741295)}}).</li>
+</ul>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li>The following new ECMAScript 2015 built-in methods got implemented:</li>
+ <li>{{jsxref("Array.from()")}} ({{bug(904723)}}),</li>
+ <li>{{jsxref("Array.prototype.copyWithin()")}} ({{bug(934423)}}),</li>
+ <li>{{jsxref("Number.isSafeInteger()")}} ({{bug(1003764)}}).</li>
+</ul>
+
+<h3 id="InterfacesAPIsDOM">Interfaces/APIs/DOM</h3>
+
+<ul>
+ <li>实现了 {{domxref("NavigatorLanguage.languages", "navigator.languages")}} 属性和 <a href="/zh-CN/docs/Web/Reference/Events/languagechange">languagechange</a> 事件。 ({{Bug(889335)}})。</li>
+ <li>The {{domxref("Navigator.vibrate()")}} method behavior has been adapted to the latest specification: too long vibrations are now truncated ({{bug(1014581)}}).</li>
+ <li>{{domxref("KeyboardEvent.getModifierState")}}() 和 {{domxref("MouseEvent.getModifierState")}}() 支持了 "Accel" 虚拟修饰符 ({{Bug(1009388)}})。</li>
+ <li>实现了 {{domxref("KeyboardEvent.code")}} 属性,不过目前在正式版本中还是禁用状态 ({{Bug(865649)}})。</li>
+ <li>Scoped selectors for {{domxref("Document.querySelector()")}} and  {{domxref("Document.querySelectorAll()")}}, for example <code>querySelector(":scope &gt; li")</code>have been implemented ({{Bug(528456)}}).</li>
+ <li>The experimental implementation of the  {{domxref("Document.timeline")}} interface, related to the <a href="http://dev.w3.org/fxtf/web-animations/">Web Animation API</a>, has been added ({{bug("998246")}}). It is controlled by <code>layout.web-animations.api.enabled</code> preference, enabled only on Nightly and Aurora for the moment.</li>
+ <li>The <a href="https://developer.mozilla.org/en-US/docs/Web/API/Data_Store_API">Data Store API</a> has been made available to <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/Performance/Using_web_workers">Web Workers</a> ({{bug("949325")}}). It still is only activated for certified applications.</li>
+ <li>The <a href="https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker_API">ServiceWorker</a> {{domxref("InstallPhaseEvent")}} and {{domxref("InstallEvent")}} interfaces have been implemented ({{ Bug("967264") }}).</li>
+ <li> The <a href="https://developer.mozilla.org/en-US/docs/Web/API/MSISDN_Verification_API">MSISDN Verification API</a>, only activated for privileged apps, has been added ({{ Bug("988469") }}).</li>
+ <li>The <a href="https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API">Gamepad API</a> is now supported on Firefox for Android ({{bug(852935)}}).</li>
+ <li>To match the spec and the evolution of the CSS syntax, minor changes have been done to {{domxref("CSS.escape()")}}. The identifier now can begins with <code>'--'</code> and the second dash must not be escaped. Also vendor identifier are no more escaped. ({{bug(1008719)}})</li>
+ <li>To complete our Hit Regions implementation, {{domxref("MouseEvent.region")}} has been implemented ({{bug(979692)}}).</li>
+ <li>The {{domxref("CanvasRenderingContext2D.drawFocusIfNeeded()")}} method is now enabled by default ({{bug(1004579)}}).</li>
+ <li>The {{domxref("Navigator.doNotTrack")}} properties now returns <code>'1'</code> or <code>'0'</code>, reflecting the HTTP value, instead of  <code>'yes'</code> or <code>'no'</code> ({{bug(887703)}}).</li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseURL">XMLHttpRequest.responseURL</a> was implemented ({{bug(998076)}}).</li>
+</ul>
+
+<h3 id="MathML">MathML</h3>
+
+<ul>
+ <li>实现了 menclose 标记 <code>phasorangle</code>。</li>
+</ul>
+
+<h3 id="SVG">SVG</h3>
+
+<p><em>No change.</em></p>
+
+<h3 id="WebRTC">WebRTC</h3>
+
+<ul>
+ <li>New constraints for <a href="https://developer.mozilla.org/en-US/docs/Glossary/WebRTC">WebRTC</a>'s {{domxref("NavigatorUserMedia.getUserMedia", "getUserMedia()")}}, <code>width</code>, <code>height</code>, and <code>framerate</code>,  have been added, to limit stream dimensions and frame rate ({{bug("907352")}}):
+
+ <pre>{
+ mandatory: {
+ width: { min: 640 },
+ height: { min: 480 }
+ },
+ optional: [
+ { width: 650 },
+ { width: { min: 650 }},
+ { frameRate: 60 },
+ { width: { max: 800 }},
+ ]
+}</pre>
+ </li>
+ <li>WebRTC methods which previously used callback functions as input parameters are now also available using JavaScript <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">promises</a>.</li>
+</ul>
+
+<h3 id="AudioVideo">Audio/Video</h3>
+
+<p><em>No change.</em></p>
+
+<h2 id="Security">Security</h2>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Xray_vision#Xray_semantics_for_Object_and_Array">Privileged code now gets Xray vision for JavaScript <code>Object</code> and <code>Array</code> instances</a>.</li>
+</ul>
+
+<h2 id="附加组件_和_Mozilla_开发者应该注意的变化">附加组件 和 Mozilla 开发者应该注意的变化</h2>
+
+<p>Xray vision is now applied to JavaScript objects that are not themselves DOM objects: <a href="https://developer.mozilla.org/en-US/docs/Xray_vision#Xrays_for_JavaScript_objects">Xrays for JavaScript objects</a>.</p>
+
+<p>A <code><a href="https://developer.mozilla.org/en-US/Add-ons/Add-on_Manager/Addon#getDataDirectory()">getDataDirectory()</a></code> method has been added to <code><a href="https://developer.mozilla.org/en-US/Add-ons/Add-on_Manager/Addon">Addon</a></code> instances. This method returns the preferred location, within the current profile, for add-ons to store data.</p>
+
+<p> </p>
+
+<h3 id="Add-on_SDK">Add-on SDK</h3>
+
+<h4 id="Highlights">Highlights</h4>
+
+<ul>
+ <li>Added <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/page-mod#PageMod%28options%29"><code>exclude</code></a> option to <code>PageMod</code>.</li>
+ <li>Added <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/request#Request%28options%29"><code>anonymous</code></a> option to <code>Request</code>.</li>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/Add-on_Debugger">Add-on Debugger</a> now includes a Console and a Scratchpad.</li>
+</ul>
+
+<h4 id="Details">Details</h4>
+
+<p><a href="https://github.com/mozilla/addon-sdk/compare/firefox31...firefox32">GitHub commits made between Firefox 31 and Firefox 32</a>. This will not include any uplifts made after this release entered Aurora.</p>
+
+<p><a href="https://bugzilla.mozilla.org/buglist.cgi?resolution=FIXED&amp;chfieldto=2014-06-09&amp;chfield=resolution&amp;query_format=advanced&amp;chfieldfrom=2014-04-28&amp;chfieldvalue=FIXED&amp;bug_status=RESOLVED&amp;bug_status=VERIFIED&amp;bug_status=CLOSED&amp;product=Add-on%20SDK&amp;list_id=10493962">Bugs fixed between Firefox 31 and Firefox 32</a>. This will not include any uplifts made after this release entered Aurora.</p>
+
+<h3 id="XPCOM">XPCOM</h3>
+
+<ul>
+ <li>The {{interface("nsIUDPSocket")}} interface now provides multicast support through the addition of the new {{ifattribute("nsIUDPSocket", "multicastLoopback")}}, {{ifattribute("nsIUDPSocket", "multicastInterface")}}, and {{ifattribute("nsIUDPSocket", "multicastInterfaceAddr")}} attributes, as well as the {{ifmethod("nsIUDPSocket", "joinMulticast")}} and {{ifmethod("nsIUDPSocket", "leaveMulticast")}} methods.</li>
+</ul>
+
+<p> </p>
+
+<h2 id="相关链接">相关链接</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/Firefox/Releases/32/Site_Compatibility">Site Compatibility for Firefox 32</a></li>
+</ul>
+
+<h3 id="Older_versions">Older versions</h3>
+
+<p>{{Firefox_for_developers('31')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/33/index.html b/files/zh-cn/mozilla/firefox/releases/33/index.html
new file mode 100644
index 0000000000..accca764bf
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/33/index.html
@@ -0,0 +1,38 @@
+---
+title: Firefox 33 for developers
+slug: Mozilla/Firefox/Releases/33
+translation_of: Mozilla/Firefox/Releases/33
+---
+<div>{{FirefoxSidebar}}</div><h2 id="普通_Web_开发者应该注意的变化">普通 Web 开发者应该注意的变化</h2>
+<h3 id="Developer_Tools">Developer Tools</h3>
+<p><em>No change.</em></p>
+<h3 id="CSS">CSS</h3>
+<ul>
+ <li>实现了 @counter-style 规则 ({{bug(966166)}})。</li>
+ <li><strong>-moz-ethiopic-numeric </strong>去除前缀({{bug(985825)}})。</li>
+ <li>支持了<strong>disclosure-open/disclosure-closed </strong>计数器样式({{bug(982355)}})。</li>
+</ul>
+<h3 id="HTML">HTML</h3>
+<p><em>No change.</em></p>
+<h3 id="JavaScript">JavaScript</h3>
+<ul>
+ <li>移除了非标准的 {{jsxref("Number.toInteger()")}} 方法 ({{bug(1022396)}}).</li>
+</ul>
+<h3 id="InterfacesAPIsDOM">Interfaces/APIs/DOM</h3>
+<p><em>No change.</em></p>
+<h3 id="MathML">MathML</h3>
+<p><em>No change.</em></p>
+<h3 id="SVG">SVG</h3>
+<p><em>No change.</em></p>
+<h3 id="AudioVideo">Audio/Video</h3>
+<p><em>No change.</em></p>
+<h2 id="Security">Security</h2>
+<p><em>No change.</em></p>
+<h2 id="附加组件_和_Mozilla_开发者应该注意的变化">附加组件 和 Mozilla 开发者应该注意的变化</h2>
+<p><em>No change.</em></p>
+<h2 id="相关链接">相关链接</h2>
+<ul>
+ <li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/33/Site_Compatibility">Site Compatibility for Firefox 33</a></li>
+</ul>
+<h3 id="更早版本">更早版本</h3>
+<p>{{Firefox_for_developers('32')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/35/index.html b/files/zh-cn/mozilla/firefox/releases/35/index.html
new file mode 100644
index 0000000000..c7d75e5f94
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/35/index.html
@@ -0,0 +1,213 @@
+---
+title: Firefox 35 开发者相关变更清单
+slug: Mozilla/Firefox/Releases/35
+tags:
+ - Firefox
+ - Firefox 35
+translation_of: Mozilla/Firefox/Releases/35
+---
+<div><section class="Quick_links" id="Quick_Links">
+ <ol>
+ <li class="toggle">
+ <details>
+ <summary>Firefox developer 发布说明</summary>
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/Firefox/Releases">Firefox developer 发布说明</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>附加组件</summary>
+ <ol>
+ <li><a href="/zh-CN/Add-ons/WebExtensions">浏览器扩展</a></li>
+ <li><a href="/zh-CN/Add-ons/Themes">主题</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Firefox 的内部机制</summary>
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/">Mozilla 项目</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Gecko">Gecko</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Firefox/Headless_mode">Headless mode</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/JavaScript_code_modules">JavaScript代码模块</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/js-ctypes">JS-ctypes</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/MathML_Project">MathML 项目</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/MFBT">MFBT</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Projects">Mozilla 项目</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Preferences">Preference 系统</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/WebIDL_bindings">WebIDL 绑定</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM">XPCOM</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Tech/XUL">XUL</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>构建与作出贡献</summary>
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/Developer_guide/Build_Instructions">构建说明</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Developer_guide/Build_Instructions/Configuring_Build_Options">配置构建选项</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Developer_guide/Build_Instructions/How_Mozilla_s_build_system_works">构建系统如何工作</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Developer_guide/Source_Code/Mercurial">Mozilla源代码</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Localization">本地化</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Mercurial">Mercurial</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/QA">质量保证</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Using_Mozilla_code_in_other_projects">在其他项目中使用来自Mozilla的代码</a></li>
+ </ol>
+ </details>
+ </li>
+ </ol>
+</section></div><div>Firefox 35 was released on January 13th, 2015. This article lists key changes that are useful not only for web developers, but also Firefox and Gecko developers as well as add-on developers.</div>
+
+<h2 id="Web_开发者相关变更">Web 开发者相关变更</h2>
+
+<h3 id="开发者工具">开发者工具</h3>
+
+<p>Highlights:</p>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector#.3A.3Abefore_and_.3A.3Aafter">See ::before and ::after pseudo elements in the Page Inspector</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Style_Editor#Source_map_support">CSS source maps are now enabled by default</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector#Element_popup_menu_2">"Show DOM Properties" from the Page Inspector</a></li>
+</ul>
+
+<p><a class="external-icon external" href="https://bugzilla.mozilla.org/buglist.cgi?resolution=FIXED&amp;chfieldto=2014-10-13&amp;chfield=resolution&amp;query_format=advanced&amp;chfieldfrom=2014-09-02&amp;chfieldvalue=FIXED&amp;component=Developer%20Tools&amp;component=Developer%20Tools%3A%203D%20View&amp;component=Developer%20Tools%3A%20Canvas%20Debugger&amp;component=Developer%20Tools%3A%20Console&amp;component=Developer%20Tools%3A%20Debugger&amp;component=Developer%20Tools%3A%20Framework&amp;component=Developer%20Tools%3A%20Graphic%20Commandline%20and%20Toolbar&amp;component=Developer%20Tools%3A%20Inspector&amp;component=Developer%20Tools%3A%20Memory&amp;component=Developer%20Tools%3A%20Netmonitor&amp;component=Developer%20Tools%3A%20Object%20Inspector&amp;component=Developer%20Tools%3A%20Profiler&amp;component=Developer%20Tools%3A%20Responsive%20Mode&amp;component=Developer%20Tools%3A%20Scratchpad&amp;component=Developer%20Tools%3A%20Source%20Editor&amp;component=Developer%20Tools%3A%20Storage%20Inspector&amp;component=Developer%20Tools%3A%20Style%20Editor&amp;component=Developer%20Tools%3A%20Timeline&amp;component=Developer%20Tools%3A%20User%20Stories&amp;component=Developer%20Tools%3A%20Web%20Audio%20Editor&amp;component=Developer%20Tools%3A%20WebGL%20Shader%20Editor&amp;component=Developer%20Tools%3A%20WebIDE&amp;component=Simulator&amp;product=Firefox&amp;product=Firefox%20OS&amp;list_id=11184176">All devtools bugs fixed between Firefox 34 and Firefox 35</a>.</p>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li><a href="/zh-CN/docs/Web/CSS/mask-type" title="此页面仍未被本地化, 期待您的翻译!"><code>mask-type</code></a> 属性默认启用 (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1058519" title="FIXED: Ship mask-type CSS property">bug 1058519</a>)。</li>
+ <li><a href="/zh-CN/docs/Web/CSS/filter" title="CSS滤镜(filter)属提供的图形特效,像模糊,锐化或元素变色。过滤器通常被用于调整图片,背景和边界的渲染。"><code>filter</code></a> 属性默认启用 (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1057180" title="FIXED: Turn on CSS Filters by default (by enabling about:config pref)">bug 1057180</a>)。</li>
+ <li><a href="/zh-CN/docs/Web/CSS/@font-face" title="这是一个叫做@font-face 的CSS @规则 ,它允许网页开发者为其网页指定在线字体。 通过这种作者自备字体的方式,@font-face 可以消除对用户电脑字体的依赖。 @font-face 不仅可以放在在CSS的最顶层, 也可以放在 @规则 的 条件规则组 中。"><code>@font-face</code></a> at-rule 支持 WOFF2 字体 (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1064737" title="FIXED: support WOFF2 fonts via @font-face">bug 1064737</a>)。</li>
+ <li>支持 <a href="/zh-CN/docs/Web/CSS/symbol()" title="此页面仍未被本地化, 期待您的翻译!"><code>symbol()</code></a> 函数注解 (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=966168" title="FIXED: Implement symbols() CSS function">bug 966168</a>)。</li>
+ <li>实现 CSS Font Loading API  (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1028497" title="FIXED: implement the CSS Font Loading API">bug 1028497</a>)。</li>
+ <li><span id="summary_alias_container"><span id="short_desc_nonedit_display">在下拉框上设置 <a href="/zh-CN/docs/Web/CSS/appearance" title="此页面仍未被本地化, 期待您的翻译!"><code>-moz-appearance</code></a> 为 <code>none</code> 值,会移除下拉按钮</span></span> (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=649849" title="FIXED: Make -moz-appearance:none on a combobox remove the dropdown button">bug 649849</a>)。</li>
+ <li>The property accessor <code>element.style["css-property-name"]</code> has been added to match other browsers (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=958887" title='FIXED: Add support for element.style["css-property-name"] non-standard extension'>bug 958887</a>).</li>
+</ul>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>The obsolete and non-conforming <code>bottommargin</code>, <code>leftmargin</code>, <code>rightmargin</code> and <code>topmargin</code> attributes of the <code><a href="/zh-CN/docs/Web/HTML/Element/body" title="HTML body 元素表示文档的内容。document.body 属性提供了可以轻松访问文档的 body 元素的脚本。"><code>&lt;body&gt;</code></a> element</code> have been activated in non-quirks mode (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=95530" title="FIXED: topmargin and leftmargin attributes on the BODY element should be honored in all modes (not just Quirks mode)">bug 95530</a>).</li>
+</ul>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li>The "<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone_and_errors_with_let">temporal dead zone</a>" for <a href="/en-US/docs/Web/JavaScript/Reference/Statements/let"><code>let</code></a> declarations has been implemented. In conformance with ES6 <code>let</code> semantics, the following situations<br>
+ now throw errors. See also this<a href="https://groups.google.com/forum/#!topic/mozilla.dev.platform/tezdW299Zds"> newsgroup announcement</a> and <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1001090" title='FIXED: Implement ES6 "temporal dead zone" for let'>bug 1001090</a>.
+
+ <ul>
+ <li>Redeclaring existing variables or arguments using <code>let</code> within the same scope in function bodies is now a syntax error.</li>
+ <li>Using a variable declared using <code>let</code> in function bodies before the declaration is reached and evaluated is now a runtime error.</li>
+ </ul>
+ </li>
+ <li>ES6 <a href="/zh-CN/docs/Web/JavaScript/Reference/Symbols" title="此页面仍未被本地化, 期待您的翻译!"><code>Symbols</code></a> (only available in the Nightly channel) have been updated to conform with recent specification changes:
+ <ul>
+ <li><code>String(Symbol("1"))</code> now no longer throws a <a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypeError" title="TypeError(类型错误) 对象用来表示值的类型非预期类型时发生的错误。"><code>TypeError</code></a>; instead a string (<code>"Symbol(1)"</code>) gets returned (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1058396" title="FIXED: String(aSymbol) now returns the symbol’s description in ES6 draft rev 27">bug 1058396</a>).</li>
+ </ul>
+ </li>
+ <li>The various <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#TypedArray_objects"><em>TypedArray</em> constructors</a> now have as their <code>[[Prototype]]</code> a single function, denoted <code>%TypedArray%</code>  in ES6 (but otherwise not directly exposed).  Each typed array prototype now inherits from <code>%TypedArray%.prototype</code>.  (<code>%TypedArray%</code> and <code>%TypedArray%.prototype</code> inherit from <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/prototype"><code>Function.prototype</code></a> and <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype"><code>Object.prototype</code></a>, respectively, so that typed array constructors and instances still have the properties found on those objects.)  Typed array function properties now reside on <code>%TypedArray%.prototype</code> and work on any typed array.  See <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#Description"><em>TypedArray</em></a> and <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=896116" title="FIXED: Implement ES6 %TypedArray% superclass that all ArrayBufferViews inherit from">bug 896116</a> for more information.</li>
+ <li>ES6 semantics for <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#Prototype_mutation">prototype mutations using object literals</a> have been implemented (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1061853" title="FIXED: Implement ES6 object-literal __proto__ restrictions/semantics">bug 1061853</a>).
+ <ul>
+ <li>Now only a single member notated as <code>__proto__:value</code> will mutate the <code>[[Prototype]]</code> in the object literal syntax.</li>
+ <li>Method members like <code>__proto__() {}</code> will not overwrite the <code>[[Prototype]]</code> anymore.</li>
+ </ul>
+ </li>
+</ul>
+
+<h3 id="接口APIsDOM">接口/APIs/DOM</h3>
+
+<ul>
+ <li>The <a href="/zh-CN/docs/Web/API/NavigatorLanguage" title="NavigatorLanguage 包含涉及导航(Navigator)的语言特性的方法和属性。"><code>NavigatorLanguage</code></a> interface is now available to workers on <a href="/zh-CN/docs/Web/API/WorkerNavigator" title="此页面仍未被本地化, 期待您的翻译!"><code>WorkerNavigator</code></a> (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=925849" title="FIXED: WorkerNavigator does not implement NavigatorLanguage">bug 925849</a>).</li>
+ <li>The <a href="/zh-CN/docs/Web/API/Element/closest" title="Element.closest() 方法用来获取:匹配特定选择器且离当前元素最近的祖先元素(也可以是当前元素本身)。如果匹配不到,则返回 null。"><code>Element.closest()</code></a> method returns the closest ancestor of the current element (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1055533" title="FIXED: Implement Element.closest()">bug 1055533</a>).</li>
+ <li>Experimental support for the <a href="/zh-CN/docs/Web/API/CanvasRenderingContext2D/filter" title="CanvasRenderingContext2D.filter 是Canvas 2D API 提供模糊、灰度等过滤效果的属性 。它类似于 CSS filter 属性,并且接受相同的函数。"><code>CanvasRenderingContext2D.filter</code></a> property has been added behind the <code>canvas.filters.enabled</code> flag (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=927892" title="FIXED: Exposing the CSS/SVG Filters as Canvas APIs">bug 927892</a>).</li>
+ <li>Our experimental implementation of Web Animations progresses with the landing of the <a href="/zh-CN/docs/Web/API/Animation/target" title="此页面仍未被本地化, 期待您的翻译!"><code>Animation.target</code></a> property. This always is behind the <code>dom.animations-api.core.enabled</code> pref, off by default (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1067701" title="FIXED: Implement Animation.target">bug 1067701</a>).</li>
+ <li>The <a href="/zh-CN/docs/Web/API/Element/hasAttributes" title="hasAttributes属性返回一个布尔值true或false,来表明当前元素节点是否有至少一个的属性(attribute)."><code>hasAttributes()</code></a> method has been moved from <a href="/zh-CN/docs/Web/API/Node" title="Node是一个接口,许多DOM类型从这个接口继承,并允许类似地处理(或测试)这些各种类型。"><code>Node</code></a> to <a href="/zh-CN/docs/Web/API/Element" title="Element是非常通用的基类,所有 Document对象下的对象都继承它. 这个接口描述了所有相同种类的元素所普遍具有的方法和属性。 这些继承自Element并且增加了一些额外功能的接口描述了具体的行为. 例如,  HTMLElement 接口是所有HTML元素的基础接口, 而 SVGElement 接口是所有SVG元素的基本接口.大多数功能在类的层次中进一步制定."><code>Element</code></a> as required by the spec (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1055773" title="FIXED: Move hasAttributes() to Element">bug 1055773</a>).</li>
+ <li>The <code>crossOrigin</code> reflected attribute of <a href="/zh-CN/docs/Web/API/HTMLImageElement" title="HTMLImageElement 接口提供了特别的属性和方法 (在常规的 HTMLElement之外,它也能通过继承使用)来操纵 &lt;img> 元素的布局和图像."><code>HTMLImageElement</code></a>, <a href="/zh-CN/docs/Web/API/HTMLLinkElement" title="The HTMLLinkElement interface represents reference information for external resources and the relationship of those resources to a document and vice-versa. This object inherits all of the properties and methods of the HTMLElement interface."><code>HTMLLinkElement</code></a>, <a href="/zh-CN/docs/Web/API/HTMLMediaElement" title="从父级元素 HTML 元素继承属性"><code>HTMLMediaElement</code></a>, <a href="/zh-CN/docs/Web/API/HTMLScriptElement" title="HTML script elements expose the HTMLScriptElement interface, which provides special properties and methods (beyond the regular HTMLElement object interface they also have available to them by inheritance) for manipulating the layout and presentation of &lt;script> elements."><code>HTMLScriptElement</code></a>, and <a href="/zh-CN/docs/Web/API/SVGScriptElement" title="此页面仍未被本地化, 期待您的翻译!"><code>SVGScriptElement</code></a> only accepts valid values, and <code>""</code> isn't, <code>null</code> has to be used instead (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=880997" title="FIXED: Reflect crossOrigin as a limited enumerated attribute">bug 880997</a>).</li>
+ <li>The Resource Timing API has been activated by default (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1002855" title="FIXED: Turn on Resource Timing">bug 1002855</a>).</li>
+ <li>To match the spec, the first argument of <a href="/zh-CN/docs/Web/API/Selection/containsNode" title="Selection.containsNode() 判断指定的节点是否包含在Selection中(是否被选中)."><code>Selection.containsNode()</code></a> cannot be <code>null</code> anymore (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1068058" title="FIXED: Update Selection.containsNode according to the spec">bug 1068058</a>).</li>
+ <li>The new <a href="/zh-CN/docs/Web/API/ImageCapture" title="此页面仍未被本地化, 期待您的翻译!"><code>ImageCapture</code></a> API has been implemented: <a href="/zh-CN/docs/Web/API/ImageCapture/takePhoto" title="此页面仍未被本地化, 期待您的翻译!"><code>ImageCapture.takePhoto()</code></a> is available (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=916643" title="FIXED: ImageCapture - Implement WebIDL and takePhoto()">bug 916643</a>).</li>
+ <li>Non-HTTP <a href="/zh-CN/docs/Web/API/XMLHttpRequest" title="使用XMLHttpRequest (XHR)对象可以与服务器交互。您可以从URL获取数据,而无需让整个的页面刷新。这使得Web页面可以只更新页面的局部,而不影响用户的操作。XMLHttpRequest在 Ajax 编程中被大量使用。"><code>XMLHttpRequest</code></a> requests now return <code>200</code> in case of success (instead of the erroneous <code>0</code>) (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=716491" title="FIXED: Investigate the status code for non-HTTP XHR.">bug 716491</a>).</li>
+ <li><a href="/zh-CN/docs/Web/API/XMLHttpRequest/responseURL" title="如果URL为空,只读的XMLHttpRequest.responseURL属性返回响应的序列化URL或空字符串。当URL被返回的时候,任何包含在URL # 后面的fragment都会被删除。 responseURL 的值将会是经过任意多次重定向后的最终 URL 。"><code>XMLHttpRequest.responseURL</code></a> has been adapted to the latest spec and doesn't include the fragment (<code>'#xyz'</code>) of the URL, if relevant (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1073882" title="FIXED: XMLHttpRequest.prototype.responseURL should not have fragment per latest spec">bug 1073882</a>).</li>
+ <li>The internal, non-standard, <a href="/zh-CN/docs/Web/API/File/mozFullPath" title="此页面仍未被本地化, 期待您的翻译!"><code>File.mozFullPath</code></a> property is no more visible from content (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1048293" title="FIXED: File::mozFullPath attribute should not be exposed to content.">bug 1048293</a>).</li>
+ <li>The constructor of <a href="/zh-CN/docs/Web/API/File" title="文件(File) 接口提供有关文件的信息,并允许网页中的 JavaScript 访问其内容。"><code>File</code></a> has been extended to match the specification (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1047483" title="FIXED: Porting DOMFile/DOMBlob to WebIDL">bug 1047483</a>).</li>
+ <li>An experimental implementation of <a href="/zh-CN/docs/Web/API/AbortablePromise" title="此页面仍未被本地化, 期待您的翻译!"><code>AbortablePromise</code></a>, a promise that can be aborted by a different entity that the one who created it, has been added. It is prefixed with <code>Moz</code> and controlled by the <code>dom.abortablepromise.enabled </code>property, defaulting to <code>false</code> (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1035060" title="FIXED: Implement AbortablePromise">bug 1035060</a>).</li>
+ <li>The non-standard <a href="/zh-CN/docs/Web/API/Navigator/mozIsLocallyAvailable" title="查询某个URI上的资源是否是本地可用的."><code>Navigator.mozIsLocallyAvailable</code></a> property has been removed (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1066826" title="FIXED: Remove Navigator::MozisLocallyAvailable API">bug 1066826</a>).</li>
+ <li>The preference <code>network.websocket.enabled,</code> <code>true</code> by default, has been removed; <a href="https://developer.mozilla.org/en-US/docs/WebSockets">Websocket</a> API cannot be deactivated anymore (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1091016" title="FIXED: Pref network.websocket.enabled is no longer reasonable">bug 1091016</a>).</li>
+ <li>The non-standard methods and properties of <a href="/zh-CN/docs/Web/API/Window/crypto" title="Window.crypto只读属性返回与全局对象关联的 Crypto对象。 此对象允许网页访问某些加密相关服务。"><code>Window.crypto</code></a> have been removed (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1030963" title="FIXED: remove proprietary window.crypto functions/properties">bug 1030963</a>). Only methods and properties defined in the standard WebCrypto API are left.</li>
+ <li>Our experimental implementation of WebGL 2.0 is going forward!
+ <ul>
+ <li>The <a href="/zh-CN/docs/Web/API/WebGL2RenderingContext/copyBufferSubData" title="此页面仍未被本地化, 期待您的翻译!"><code>WebGL2RenderingContext.copyBufferSubData()</code></a> method has been implemented (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1048668" title="FIXED: WebGL2 - Implement CopyBufferSubData">bug 1048668</a>).</li>
+ </ul>
+ </li>
+</ul>
+
+<h3 id="MathML"> MathML</h3>
+
+<ul>
+ <li>The <code>dtls</code> OpenType feature (via the CSS <a href="/zh-CN/docs/Web/CSS/font-feature-settings" title="font-feature-settings CSS属性可让您控制OpenType字体中的高级印刷功能。"><code>font-feature-settings</code></a> on the default stylesheet) is now applied automatically to MathML elements when positioning scripts over it (e.g. dotless i with mathematical hat).</li>
+</ul>
+
+<h3 id="SVG">SVG</h3>
+
+<p><em>无变化。</em></p>
+
+<h3 id="音频视频">音频/视频</h3>
+
+<p><em>无变化。</em></p>
+
+<h2 id="网络_安全">网络 &amp; 安全</h2>
+
+<ul>
+ <li>HTTP/2 has been implemented and activated, with AEAD ciphers only (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1027720" title="FIXED: Restrict HTTP/2 connections to AEAD ciphers only">bug 1027720</a> and <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1047594" title="FIXED: Enable http/2 (and alpn) by default">bug 1047594</a>).</li>
+ <li>支持 HTTP/2 <code>alt-svc</code> header (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1003448" title="FIXED: http/2 alt-svc support">bug 1003448</a>)。</li>
+ <li>实现 HTTP (HPKP) 的 <a href="/en-US/docs/Web/Security/Public_Key_Pinning">Public Key Pinning</a> 扩展 (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=787133" title="FIXED: Implement Public Key Pinning Extension for HTTP (HPKP)">bug 787133</a>)。</li>
+ <li>The <a href="https://developer.mozilla.org/en-US/docs/Web/Security/CSP">CSP</a> 1.1 <code>base-uri</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives">directive</a> is now supported (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1045897" title="FIXED: Implement CSP 1.1 base-uri directive">bug 1045897</a>).</li>
+ <li>Path of the source is now considered too when host-source matching happens in <a href="https://developer.mozilla.org/en-US/docs/Web/Security/CSP">CSP</a> (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=808292" title="FIXED: Implement path-level host-source matching to CSP">bug 808292</a>).</li>
+</ul>
+
+<h2 id="附加组件和_Mozilla_开发者相关的变更">附加组件和 Mozilla 开发者相关的变更</h2>
+
+<h3 id="XUL_附加组件">XUL &amp; 附加组件</h3>
+
+<ul>
+ <li>The private <code>_getTabForBrowser()</code> method on the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/tabbrowser" title="tabbrowser">tabbrowser</a></code> element has been deprecated. In its place, we've added a new, public, method called <span id="m-getTabForBrowser"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getTabForBrowser">getTabForBrowser</a></code></span>. This returns, predictably, the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/tab" title="tab">tab</a></code> element that contains the specified <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/browser" title="browser">browser</a></code>.</li>
+ <li><code>Components.utils.now()</code>, matching <a href="/zh-CN/docs/Web/API/Performance/now" title="performance.now()方法返回一个精确到毫秒的  DOMHighResTimeStamp 。"><code>Performance.now()</code></a> has been implemented for non-window chrome code (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=969490" title="FIXED: Implement Components.utils.now() to match Performance.now() for non-window chrome code">bug 969490</a>).</li>
+</ul>
+
+<h3 id="Add-on_SDK">Add-on SDK</h3>
+
+<h4 id="Highlights">Highlights</h4>
+
+<ul>
+ <li>增加 <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Add_a_Context_Menu_Item#Adding_an_access_key">上下文菜单的快捷键</a>。</li>
+ <li>移除 <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/windows#BrowserWindow"><code>BrowserWindow</code></a> 的 <code>isPrivateBrowsing</code></li>
+ <li>added <code><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/url#toJSON%28%29">toJSON</a> </code>method to <code>URL</code> instances from <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/url">sdk/url</a></li>
+</ul>
+
+<h4 id="明细">明细</h4>
+
+<p><a class="external external-icon" href="https://github.com/mozilla/addon-sdk/compare/firefox34...firefox35">Firefox 34 到 Firefox 35 的</a><a class="external external-icon" href="https://github.com/mozilla/addon-sdk/compare/firefox34...firefox35"> GitHub 提交</a>. This will not include any uplifts made after this release entered Aurora.</p>
+
+<p><a class="external external-icon" href="https://bugzilla.mozilla.org/buglist.cgi?resolution=FIXED&amp;chfieldto=2014-10-13&amp;chfield=resolution&amp;query_format=advanced&amp;chfieldfrom=2014-09-02&amp;chfieldvalue=FIXED&amp;bug_status=RESOLVED&amp;bug_status=VERIFIED&amp;bug_status=CLOSED&amp;product=Add-on%20SDK&amp;list_id=11562840">Bugs fixed between Firefox 34 and Firefox 35</a>. This will not include any uplifts made after this release entered Aurora.</p>
+
+<p> </p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="https://www.fxsitecompat.com/en-US/versions/35/">Site Compatibility for Firefox 35</a></li>
+</ul>
+
+<p> </p>
+
+<h2 id="以往版本">以往版本</h2>
+
+<div class="multiColumnList">
+<ul>
+<li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/34">Firefox 34 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/33">Firefox 33 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/32">Firefox 32 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/31">Firefox 31 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/30">Firefox 30 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/29">Firefox 29 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/28">Firefox 28 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/27">Firefox 27 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/26">Firefox 26 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/25">Firefox 25 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/24">Firefox 24 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/23">Firefox 23 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/22">Firefox 22 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/21">Firefox 21 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/20">Firefox 20 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/19">Firefox 19 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/18">Firefox 18 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/17">Firefox 17 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/16">Firefox 16 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/15">Firefox 15 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/14">Firefox 14 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/13">Firefox 13 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/12">Firefox 12 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/11">Firefox 11 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/10">Firefox 10 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/9">Firefox 9 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/8">Firefox 8 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/7">Firefox 7 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/6">Firefox 6 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/5">Firefox 5 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/4">Firefox 4 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/3.6">Firefox 3.6 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/3">Firefox 3 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/2">Firefox 2 for developers</a></li><li><a href="/zh-CN/docs/Mozilla/Firefox/Releases/1.5">Firefox 1.5 for developers</a></li></ul>
+</div>
diff --git a/files/zh-cn/mozilla/firefox/releases/41/index.html b/files/zh-cn/mozilla/firefox/releases/41/index.html
new file mode 100644
index 0000000000..9e373c6bf7
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/41/index.html
@@ -0,0 +1,209 @@
+---
+title: Firefox 41 for developers
+slug: Mozilla/Firefox/Releases/41
+tags:
+ - Firefox
+ - Firefox 41
+translation_of: Mozilla/Firefox/Releases/41
+---
+<div>{{FirefoxSidebar}}</div><div class="column-container zone-callout"><a style="float: right; margin-bottom: 20px; padding: 10px; text-align: center; border-radius: 4px; display: inline-block; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;" href="https://nightly.mozilla.org/">To test the latest developer features of Firefox,<br>
+install Firefox Developer Edition</a> Firefox 41 was released on September 22, 2015. This article lists key changes that are useful not only for web developers, but also Firefox and Gecko developers as well as add-on developers.</div>
+
+<h2 id="Changes_for_Web_developers">Changes for Web developers</h2>
+
+<h3 id="开发工具">开发工具</h3>
+
+<p>Highlights:</p>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Examine_and_edit_HTML#Element_popup_menu">Take a screenshot of a DOM node</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor#CopySave_All_As_HAR">Copy as HAR/save as HAR</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Examine_and_edit_CSS#Add_rules">"Add Rule" button in the Rules view</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/View_source">View source in a tab</a> (Disabled by default)</li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Examine_and_edit_CSS#Copy_rules">More options to copy CSS rules</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/View_background_images">Copy image as data: URI in the Rules view</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/GCLI/Display_security_information">Added command to GCLI to display CSP info</a></li>
+</ul>
+
+<p><a href="https://bugzilla.mozilla.org/buglist.cgi?resolution=FIXED&amp;classification=Client%20Software&amp;chfieldto=2015-06-29&amp;query_format=advanced&amp;chfield=resolution&amp;chfieldfrom=2015-05-11&amp;chfieldvalue=FIXED&amp;bug_status=RESOLVED&amp;bug_status=VERIFIED&amp;component=Developer%20Tools&amp;component=Developer%20Tools%3A%203D%20View&amp;component=Developer%20Tools%3A%20Canvas%20Debugger&amp;component=Developer%20Tools%3A%20Console&amp;component=Developer%20Tools%3A%20Debugger&amp;component=Developer%20Tools%3A%20Framework&amp;component=Developer%20Tools%3A%20Graphic%20Commandline%20and%20Toolbar&amp;component=Developer%20Tools%3A%20Inspector&amp;component=Developer%20Tools%3A%20Memory&amp;component=Developer%20Tools%3A%20Netmonitor&amp;component=Developer%20Tools%3A%20Object%20Inspector&amp;component=Developer%20Tools%3A%20Performance%20Tools%20%28Profiler%2FTimeline%29&amp;component=Developer%20Tools%3A%20Responsive%20Mode&amp;component=Developer%20Tools%3A%20Scratchpad&amp;component=Developer%20Tools%3A%20Source%20Editor&amp;component=Developer%20Tools%3A%20Storage%20Inspector&amp;component=Developer%20Tools%3A%20Style%20Editor&amp;component=Developer%20Tools%3A%20User%20Stories&amp;component=Developer%20Tools%3A%20Web%20Audio%20Editor&amp;component=Developer%20Tools%3A%20WebGL%20Shader%20Editor&amp;component=Developer%20Tools%3A%20WebIDE&amp;product=Firefox&amp;list_id=12283503">All devtools bugs fixed between Firefox 40 and Firefox 41</a>: note that many of these bugs, especially those relating to the performance tools, were uplifted to Firefox 40.</p>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>Support for laying out vertical scripts has been activated by default ({{bug(1138384)}}). That means that the following CSS properties are now available:
+ <ul>
+ <li>Choosing the direction of writing: {{cssxref("writing-mode")}}.</li>
+ <li>Controlling orientation of characters: {{cssxref("text-orientation")}}.</li>
+ <li>Direction-independent equivalents of {{cssxref("width")}} and {{cssxref("height")}}: {{cssxref("block-size")}} and {{cssxref("inline-size")}}.</li>
+ <li>Direction-independent equivalents of {{cssxref("min-width")}} and {{cssxref("min-height")}}: {{cssxref("min-block-size")}} and {{cssxref("min-inline-size")}}.</li>
+ <li>Direction-independent equivalents of {{cssxref("max-width")}} and {{cssxref("max-height")}}: {{cssxref("max-block-size")}} and {{cssxref("max-block-size")}}.</li>
+ <li>Direction-independent equivalents of {{cssxref("margin-top")}}, {{cssxref("margin-right")}}, {{cssxref("margin-bottom")}} and {{cssxref("margin-left")}}: {{cssxref("margin-block-start")}}, {{cssxref("margin-block-end")}}, {{cssxref("margin-inline-start")}} and {{cssxref("margin-inline-end")}}.</li>
+ <li>Direction-independent equivalents of {{cssxref("padding-top")}}, {{cssxref("padding-right")}}, {{cssxref("padding-bottom")}} and {{cssxref("padding-left")}}: {{cssxref("padding-block-start")}}, {{cssxref("padding-block-end")}}, {{cssxref("padding-inline-start")}} and {{cssxref("padding-inline-end")}}.</li>
+ <li>Direction-independent equivalents of {{cssxref("border-top")}}, {{cssxref("border-right")}}, {{cssxref("border-bottom")}} and {{cssxref("border-left")}} and their longhands for width, style and color: {{cssxref("border-block-start")}}, {{cssxref("border-block-start-width")}}, {{cssxref("border-block-start-style")}}, {{cssxref("border-block-start-color")}}, {{cssxref("border-block-end")}}, {{cssxref("border-block-end-width")}}, {{cssxref("border-block-end-style")}}, {{cssxref("border-block-end-color")}}, {{cssxref("border-inline-start")}}, {{cssxref("border-inline-start-width")}}, {{cssxref("border-inline-start-style")}}, {{cssxref("border-inline-start-color")}}, {{cssxref("border-inline-end")}}, {{cssxref("border-inline-end-width")}}, {{cssxref("border-inline-end-style")}} and {{cssxref("border-inline-end-color")}}.</li>
+ <li>Direction-independent equivalents of {{cssxref("top")}}, {{cssxref("right")}}, {{cssxref("bottom")}} and {{cssxref("left")}}: {{cssxref("offset-block-start")}}, {{cssxref("offset-block-end")}}, {{cssxref("offset-inline-start")}} and {{cssxref("offset-inline-end")}}.</li>
+ </ul>
+ </li>
+ <li>Support the {{cssxref("transform-origin")}} property in SVG and implement the {{cssxref("transform-box")}} property  ({{bug(923193)}}).</li>
+</ul>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>{{HTMLElement("a")}} 没有 <code>href</code> 属性,并且不再被分类为交互内容. 点击 {{HTMLElement("label")}} 将会激活标签内容({{bug(1167816)}}).</li>
+ <li>SVG 图标现在支持站点图标(偏爱图标和快捷方式图标)({{bug(366324)}}).</li>
+ <li>The {{htmlattrxref('crossorigin', 'link')}} attribute is now supported for <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link">&lt;link rel='preconnect'&gt;</a> ({{bug(1174152)}}).</li>
+ <li> The picture element does not react to resize/viewport changes ({{bug(1135812)}}).</li>
+</ul>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li>{{jsxref("Date.prototype")}}现在是一个普通对象, 不再是一个 {{jsxref("Date")}} 实例 ({{bug(861219)}}).</li>
+ <li>{{jsxref("Date.prototype.toString")}} 现在是一般方法({{bug(861219)}}).</li>
+ <li>{{jsxref("Symbol.species")}}被增加到({{bug(1131043)}}).</li>
+ <li>{{jsxref("Map.@@species", "Map[@@species]")}} 和{{jsxref("Set.@@species", "Set[@@species]")}} 获取已经被增加 ({{bug(1131043)}}).</li>
+ <li>非标准 {{jsxref("Statements/let", "let expression", "#let_expressions", 1)}} 支持已经被废弃({{bug(1023609)}}).</li>
+ <li>{{jsxref("Functions/Default_parameters", "Destructured parameters with default value assignment","#Destructured_parameter_with_default_value_assignment", 1)}} 现在已经被支持 ({{bug(1018628)}}).</li>
+ <li>Per ES2015,  <a href="/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions">方法定义</a> 需要尖括号. 从现在开始语法没有尖括号将会失败({{bug(1150855)}}).</li>
+ <li><a href="/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions">方法定义</a> (除了生成方法) 已经不再可构造 ({{bug(1059908)}} 和{{bug(1166950)}}).</li>
+ <li>As part of ES2015 specification compliance, parenthesized <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment">destructuring</a> patterns, like <code>([a, b]) = [1, 2]</code> or <code>({a, b}) = { a: 1, b: 2 }</code>, are now considered invalid and will throw a {{jsxref("SyntaxError")}}. See <a href="http://whereswalden.com/2015/06/20/new-changes-to-make-spidermonkeys-and-firefoxs-parsing-of-destructuring-patterns-more-spec-compliant/">Jeff Walden's blog post</a> for more details.</li>
+ <li>The <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target">new.target</a></code> syntax has been added ({{bug(1141865)}}).</li>
+</ul>
+
+<h3 id="InterfacesAPIsDOM">Interfaces/APIs/DOM</h3>
+
+<ul>
+ <li>剪切、复制和粘贴命令处理已经被重新编码,并且现在允许JS编程实现网页内容复制和剪切。
+ <ul>
+ <li>使用 <code>'paste'</code>名利作为参数, {{domxref("Document.queryCommandSupported()")}}现在会返回<span style="font-family: courier,andale mono,monospace;">false如果不充分的权限被执行</span>({{bug(1161721)}}).</li>
+ <li>使用<code>'cut'</code> 或 <code>'copy'</code> 命令作为参数, {{domxref("Document.queryCommandSupported()")}} 现在返回<code style="font-style: normal;">true</code> 如果调用的上下文中包括用户发起的或特权代码({{bug(1162952)}}).</li>
+ <li>使用 <code>'cut'</code> 或<code>'copy' 命令作为参数</code>, {{domxref("Document.execCommand()")}} 将会执行, 但是仅仅在用户发起的或特权代码的上下文下({{bug(1012662)}}).</li>
+ </ul>
+ </li>
+</ul>
+
+<h4 id="Events">Events</h4>
+
+<ul>
+ <li>非标准的{{domxref("CloseEvent.initCloseEvent()")}} 方法和创建 {{domxref("CloseEvent")}} 使用 {{domxref("Event.createEvent", "Event.createEvent('CloseEvent')")}} 方法已经被移除. 相反可以使用标准的构造器{{domxref("CloseEvent.CloseEvent", "CloseEvent()")}} . ({{bug(1161950)}}).</li>
+ <li>On Desktop, {{domxref("PointerEvent")}} is now activated by default in Nightly; it is not activated in Developer Edition, Beta or Release and won't be for at least some versions ({{bug(1166347)}}).</li>
+ <li>The unprefixed version of {{domxref("MouseEvent.movementX")}} and {{domxref("MouseEvent.movementY")}}}} have been added; the prefixed versions are deprecated and will be removed at some point in the future ({{bug(1164981)}}).</li>
+</ul>
+
+<h4 id="Web_Crypto">Web Crypto</h4>
+
+<ul>
+ <li>{{domxref("SubtleCrypto.importKey()")}} 和{{domxref("SubtleCrypto.exportKey()")}} 现在支持 <code>ECDH</code> keys ({{bug(1050175)}}).</li>
+</ul>
+
+<h4 id="Canvas_API">Canvas API</h4>
+
+<ul>
+ <li>{{domxref("HTMLCanvasElement.captureStream()")}} and {{domxref("CanvasCaptureMediaStream")}} have been added and allow to stream the display of a {{HTMLElement("canvas")}} in real-time ({{bug(1032848)}}).</li>
+ <li>{{domxref("MediaStream.id")}} now returns the unique id of a stream ({{bug(1089798)}}).</li>
+ <li>The initial value of {{domxref("CanvasRenderingContext2D.filter")}} is now correctly set to <code>none</code> ({{bug(1163124)}}).</li>
+</ul>
+
+<h4 id="Service_Workers">Service Workers</h4>
+
+<ul>
+ <li>Improvement to our experimental <a href="https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker_API">Service Worker</a> implementation:
+
+ <ul>
+ <li>{{domxref("ServiceWorkerGlobalScope.skipWaiting()")}} has been implemented ({{bug(1131352)}}).</li>
+ <li>{{domxref("Clients.claim()")}} has been added ({{bug(1130684)}}).</li>
+ <li>The other functional events of Service Workers have been made to inherit from {{domxref("ExtendableEvent")}}, giving them access to the {{domxref("ExtendableEvent.waitUntil","waitUntil()")}} method ({{bug("1160527")}}).</li>
+ </ul>
+ </li>
+ <li>The {{domxref("CacheStorage")}} and {{domxref("Cache")}} interfaces are now supported ({{bug("1110144")}}).</li>
+</ul>
+
+<h4 id="WebGL">WebGL</h4>
+
+<ul>
+ <li>The <code>failIfMajorPerformanceCaveat</code> WebGL context attribute has been added and can be set when creating a WebGL context with {{domxref("HTMLCanvasElement.getContext()")}} to indicate if a context creation should fail if the system performance is low ({{bug(1164970)}}).</li>
+</ul>
+
+<h4 id="WebRTC">WebRTC</h4>
+
+<ul>
+ <li>Firefox no longer offers a default STUN server to be used if none are specified when constructing a new {{domxref("RTCPeerConnection")}}. You'll need to provide one in order to successfully establish a WebRTC connection.</li>
+</ul>
+
+<h4 id="Miscellaneous">Miscellaneous</h4>
+
+<ul>
+ <li>On OS X and Windows, {{domxref("NavigatorOnLine.onLine", "Navigator.onLine")}} now changes regarding network connectivity (it always returned <code>true</code>, , unless "Work offline" mode was selected) before ({{bug(654579)}}).</li>
+ <li>{{domxref("MessagePort")}} and {{domxref("MessageChannel")}} now available in <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API">Web workers</a>, and are enabled by default in all contexts ({{bug(952139)}}) and ({{bug(911972)}}).</li>
+ <li>The User Timing API is now available in <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API">Web workers</a> ({{bug(1155761)}}).</li>
+ <li>The <a href="https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API">Notifications API</a> is now available in <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API">Web workers</a> ({{bug(916893)}}).</li>
+ <li>{{domxref("DOMRequest")}} and {{domxref("DOMCursor")}} are now available in <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API">Web workers</a> ({{bug(1167650)}}).</li>
+ <li>The <a href="https://developer.mozilla.org/en-US/docs/Web/API/CSSFontLoading_API">CSS Font Loading API</a> has been completely implemented and is now enabled by default ({{bug(1149381)}}).</li>
+ <li>Shared workers can no longer be shared between private (i.e. browsing in a private window) and non-private documents (see {{bug(1177621)}}).</li>
+ <li>The {{domxref("URLUtilsSearchParams.searchParams")}} property is now read-only ({{bug(1174731)}}).</li>
+ <li>
+ <p>The {{domxref('URLUtils.hash')}} property no longer decodes URL fragment ({{bug(1093611)}}).</p>
+ </li>
+</ul>
+
+<h3 id="MathML">MathML</h3>
+
+<h4 id="新的默认、支持字体处理">新的默认、支持字体处理</h4>
+
+<p>数学公式需要特殊的字体. 到目前为止, 这些字体被硬编码在用户默认样式 <code>mathml.css</code> (使用{{MathMLElement("math")}} 标志设置字体组) 和偏好选项<code>font.mathfont-family</code> (为拉伸和大操作数设置支持字体). Firefox 41 引入一个能够自动设置<span style="font-family: courier,andale mono,monospace;">&lt;math&gt;标志和相应偏好选项的</span>内置<code>x-math</code> 语言 (例如<code>font.name.serif.x-math</code>). 用户默认样式现在将<span style="font-family: courier,andale mono,monospace;">&lt;math&gt;标志字体</span>设置为serif 并且<code>font.mathfont-family</code> 被替换为 <code>font.name.serif.x-math</code>.  所有平台现在基本使用相同列表的支持字体, "Latin Modern Math" 是首选.在标准的 per-language字体偏好菜单中,默认支持字体能够被设置. 更多细节,请参照{{bug(947654)}} 和 {{bug(1160456)}}.</p>
+
+<h3 id="SVG">SVG</h3>
+
+<ul>
+ <li>站点图片(偏爱图标,快捷方式图标) 现在支持SVG({{bug(366324)}})</li>
+</ul>
+
+<h3 id="音频视频">音频/视频</h3>
+
+<ul>
+ <li>The <code>media.autoplay.enabled</code> preference now also apply to untrusted {{domxref("HTMLMediaElement.play()")}} invocations too, that is calls from non-users activated scripts ({{bug(659285)}}).</li>
+</ul>
+
+<h2 id="Networking">Networking</h2>
+
+<ul>
+ <li>The <code>X-Content-Duration</code> header is no longer supported ({{Bug(1160695)}}).</li>
+ <li>Draft versions of the HTTP/2 protocol are no more supported ({{bug(1132357)}}).</li>
+</ul>
+
+<h2 id="Security">Security</h2>
+
+<ul>
+ <li>The <a href="https://developer.mozilla.org/en-US/docs/Web/Security/CSP">CSP</a> 1.1 <code>manifest-src</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives">directive</a> 已经被支持 ({{bug(1089255)}}).</li>
+ <li>Previous versions of Firefox incorrectly expected the <a href="https://developer.mozilla.org/en-US/docs/Web/Security/CSP">Content Security Policy</a> <a href="https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives#referrer">referrer</a>directive's value <code>origin-when-cross-origin</code> to be spelled <code>origin-when-crossorigin</code>. This has been corrected to include the missing dash character.</li>
+</ul>
+
+<h2 id="Changes_for_add-on_and_Mozilla_developers">Changes for add-on and Mozilla developers</h2>
+
+<h3 id="XUL">XUL</h3>
+
+<p><em>没有变化。</em></p>
+
+<h3 id="JavaScript_code_modules">JavaScript code modules</h3>
+
+<p><em>没有变化。</em></p>
+
+<h3 id="XPCOM">XPCOM</h3>
+
+<p><em>没有变化。</em></p>
+
+<h3 id="其他">其他</h3>
+
+<ul>
+ <li>A new, internal, and chrome-context-only API to render the root widget of a window into a {{HTMLElement("canvas")}} has been added: {{domxref("CanvasRenderingContext2D.drawWidgetAsOnScreen()")}}. This API uses the operating system to snapshot the widget on-screen. For more details see {{bug(1167477)}}.</li>
+</ul>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/Firefox/Releases/41/Site_Compatibility">Site Compatibility for Firefox 41</a></li>
+</ul>
+
+<h2 id="之前版本">之前版本</h2>
+
+<p>{{Firefox_for_developers('40')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/43/index.html b/files/zh-cn/mozilla/firefox/releases/43/index.html
new file mode 100644
index 0000000000..81566a6373
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/43/index.html
@@ -0,0 +1,173 @@
+---
+title: Firefox 43 for developers
+slug: Mozilla/Firefox/Releases/43
+tags:
+ - Firefox
+translation_of: Mozilla/Firefox/Releases/43
+---
+<div>{{FirefoxSidebar}}</div><p><a href="https://www.mozilla.org/firefox/developer/" style="float: right; margin-bottom: 20px; padding: 10px; text-align: center; border-radius: 4px; display: inline-block; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;">To test the latest developer features of Firefox,<br>
+ install Firefox Developer Edition</a> Firefox 43 was released on December 15, 2015. This article lists key changes that are useful not only for web developers, but also Firefox and Gecko developers as well as add-on developers.</p>
+
+<h2 id="Changes_for_Web_developers">Changes for Web developers</h2>
+
+<h3 id="Developer_Tools">Developer Tools</h3>
+
+<p>Highlights:</p>
+
+<ul>
+ <li><a href="/en-US/docs/Tools/Web_Console/Console_messages#Server">Server logging in the Web Console</a></li>
+ <li><a href="/en-US/docs/Tools/Page_Inspector/How_to/Examine_and_edit_CSS#Overridden_declarations">Quickly find the rule that overrode a CSS declaration</a></li>
+ <li><a href="/en-US/docs/Tools/Page_Inspector/How_to/Examine_and_edit_HTML#Element_popup_menu">"Use in Console" context menu item in Inspector</a></li>
+ <li><a href="/en-US/docs/Tools/Page_Inspector/How_to/Examine_and_edit_CSS#Strict_search">"Strict" option for filtering in the Rules view</a></li>
+ <li><a href="/en-US/docs/Tools/Web_Console/Console_messages#Network">Network entries in the Console now link to the Network Monitor</a></li>
+ <li><a href="/en-US/docs/Tools/Page_Inspector/How_to/Examine_and_edit_CSS#Setting_hover_active_focus">Markup view shows indicators for pseudo-classes locked for elements</a></li>
+ <li><span class="author-g-1scq3ywqbljc5puc">New sidebar UI for WebIDE</span></li>
+</ul>
+
+<p><a class="external external-icon" href="https://bugzilla.mozilla.org/buglist.cgi?resolution=FIXED&amp;classification=Client%20Software&amp;chfieldto=2015-09-19&amp;query_format=advanced&amp;chfield=resolution&amp;chfieldfrom=2015-08-10&amp;chfieldvalue=FIXED&amp;bug_status=RESOLVED&amp;bug_status=VERIFIED&amp;component=Developer%20Tools&amp;component=Developer%20Tools%3A%203D%20View&amp;component=Developer%20Tools%3A%20Canvas%20Debugger&amp;component=Developer%20Tools%3A%20Console&amp;component=Developer%20Tools%3A%20Debugger&amp;component=Developer%20Tools%3A%20Framework&amp;component=Developer%20Tools%3A%20Graphic%20Commandline%20and%20Toolbar&amp;component=Developer%20Tools%3A%20Inspector&amp;component=Developer%20Tools%3A%20Memory&amp;component=Developer%20Tools%3A%20Netmonitor&amp;component=Developer%20Tools%3A%20Object%20Inspector&amp;component=Developer%20Tools%3A%20Performance%20Tools%20%28Profiler%2FTimeline%29&amp;component=Developer%20Tools%3A%20Responsive%20Mode&amp;component=Developer%20Tools%3A%20Scratchpad&amp;component=Developer%20Tools%3A%20Source%20Editor&amp;component=Developer%20Tools%3A%20Storage%20Inspector&amp;component=Developer%20Tools%3A%20Style%20Editor&amp;component=Developer%20Tools%3A%20User%20Stories&amp;component=Developer%20Tools%3A%20Web%20Audio%20Editor&amp;component=Developer%20Tools%3A%20WebGL%20Shader%20Editor&amp;component=Developer%20Tools%3A%20WebIDE&amp;product=Firefox&amp;list_id=12582678">All devtools bugs fixed between Firefox 42 and Firefox 43</a>.</p>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>Support for the standard, unprefixed version of {{Cssxref("hyphens")}} has been landed ({{bug(953408)}}).</li>
+ <li>The shorthand property {{cssxref("font")}} has been updated to accept {{cssxref("font-stretch")}} values ({{bug(1057680)}}).</li>
+ <li>To match a latest evolution of the specification, the {{cssxref(":fullscreen")}} pseudo-class now selects the whole stack of elements in full screen, and not only the top-level one ({{bug(1199522)}}).</li>
+ <li>The deprecated SVG values for the {{cssxref("writing-mode")}}, <code>lr</code>, <code>lr-tb</code>, <code>rl</code>, <code>tb</code>, and <code>tb-rl</code>, have been added in CSS as aliases to standard properties ({{bug(1205787)}}).</li>
+</ul>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>For {{htmlelement("img")}} with ICO image containing multiple frames, the intrinsic dimension of the image is set to the one of the largest frame, and no more of the smallest frame {{bug(1201796)}}.</li>
+ <li>The value of the document's viewport (defined with <code>&lt;<a href="/en-US/docs/Web/HTML/Element/meta">meta</a> name="viewport&gt;</code>)can now dynamically be changed via JavaScript ({{bug(976616)}}).</li>
+</ul>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<h4 id="New_APIs">New APIs</h4>
+
+<ul>
+ <li>The new ES2016 methods {{jsxref("Array.prototype.includes()")}} and {{jsxref("TypedArray.prototype.includes()")}} are now enabled by default ({{bug(1070767)}}).</li>
+</ul>
+
+<h4 id="Changes_regarding_the_arguments_object">Changes regarding the <code>arguments</code> object</h4>
+
+<ul>
+ <li>To match the ES2015 specification, <a href="/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions">arrow functions</a> no longer have their own <code><a href="/en-US/docs/Web/JavaScript/Reference/Functions/arguments">arguments</a></code> object. The <code>arguments</code> object is now lexically bound (inherited from the outer function). In most cases, <a href="/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters">rest parameters</a> are a good alternative <code>(...args) =&gt; args[i]</code>, see {{bug(889158)}}.</li>
+ <li>The <a href="/en-US/docs/Web/JavaScript/Reference/Functions/arguments">arguments</a> object is now allowed in conjunction with <a href="/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters">rest parameters</a> ({{bug(1133298)}}).</li>
+ <li>From now on, a mapped <code><a href="/en-US/docs/Web/JavaScript/Reference/Functions/arguments">arguments</a></code> object in non-strict functions is only provided if the function does <strong>not</strong> contain any <a href="/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters">rest parameters</a>, any <a href="/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters">default parameters</a> or any <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment">destructured parameters</a> ({{bug(1175394)}}).</li>
+</ul>
+
+<h4 id="Other_changes">Other changes</h4>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*">Generators</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions">generator methods</a> are no longer constructable as per ES2016 ({{bug(1191486)}}).</li>
+</ul>
+
+<h3 id="InterfacesAPIsDOM">Interfaces/APIs/DOM</h3>
+
+<h4 id="DOM_HTML_DOM">DOM &amp; HTML DOM</h4>
+
+<p><em>No change.</em></p>
+
+<h4 id="IndexedDB">IndexedDB</h4>
+
+<ul>
+ <li>A new feature called <a href="/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB#Locale-aware_sorting">locale-aware sorting</a> has been added allowing for the creation of indexes with a locale specified, which can then then be used to sort data according to the rules of that locale ({{bug(871846)}}). This is a non-standard Firefox-specific feature.</li>
+</ul>
+
+<h4 id="Service_Workers">Service Workers</h4>
+
+<ul>
+ <li>As per the specification, if {{domxref("ExtendableEvent.waitUntil()")}} is called outside of the {{domxref("ExtendableEvent")}} handler, Firefox will now throw an <code>InvalidStateError</code>; in addition, multiple calls to {{domxref("ExtendableEvent.waitUntil","waitUntil()")}} will now stack up, and the resulting promises will be added to the list of <a href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#dfn-extend-lifetime-promises">extend lifetime promises</a> ({{bug(1180274)}}).</li>
+ <li>{{domxref("PushMessageData")}} methods have been implemented ({{bug(1149195)}}).</li>
+</ul>
+
+<h4 id="WebRTC">WebRTC</h4>
+
+<ul>
+ <li>The {{domxref("HTMLCanvasElement.captureStream()")}} method has been activated by default ({{bug(1177276)}}).</li>
+ <li>The non-standard constraint style option list for {{domxref("RTCOfferOptions")}} has been deprecated and will be removed entirely in Firefox 44; see <a href="https://www.fxsitecompat.com/en-USdocs/2015/constraint-like-rtcofferoptions-are-no-longer-supported/">this post on the site compatibility blog</a> for details.</li>
+</ul>
+
+<h4 id="Miscellaneous">Miscellaneous</h4>
+
+<ul>
+ <li>The <a href="/en-US/docs/Web/API/Battery_Status_API">Battery Status API</a> now uses the new promise syntax for {{domxref("Navigator.getBattery()")}}, as specified in the recent evolution of the specificiation ({{bug(1050749)}}).</li>
+ <li>The <code>User-Agent</code> header is no longer in the list of {{Glossary("Forbidden_header_name", "forbidden header names", 1)}} so it can now be set in a <a href="/en-US/docs/Web/API/Fetch_API">Fetch</a> {{domxref("Headers")}} object, via XHR {{domxref("XMLHttpRequest.setRequestHeader()")}},… ({{bug(1188932)}}).</li>
+ <li>The {{domxref("MediaRecorder.MediaRecorder()")}} constructor can now accept an options dictionary as a parameter, which allows you to set custom bitrates for the audio/video to be recorded ({{bug("1161276")}}).</li>
+ <li>The {{domxref("PerformanceObserver")}} interface, belonging to the <a href="/en-US/docs/Web/API/Performance_Timeline_API">Performance Timeline API</a> has been implemented ({{bug(1165796)}}).</li>
+ <li>The <a href="/en-US/docs/Web/API/Frame Timing API">Frame Timing API</a> has been added: the {{domxref("PerformanceRenderTiming")}} and {{domxref("PerformanceCompositeTiming")}} interfaces are now availble ({{bug(1191178)}}).</li>
+ <li>The modern <a href="/en-US/docs/Web/API/Screen_Orientation_API">Screen Orientation API</a> has been implemented: unprefixed {{domxref("Screen.orientation")}} and the {{domxref("ScreenOrientation")}} interface are now available ({{bug("1131470")}}). The non-standard {{domxref("Screen.mozOrientation")}}, {{domxref("Screen.onmozorientationchange")}}, {{domxref("Screen.mozLockOrientation()")}}, and {{domxref("Screen.mozUnlockOrientation()")}} will be removed in the future.</li>
+ <li>Under Linux, like under Windows, {{domxref("Event.timeStamp")}} now returns a {{domxref("DOMHighResTimeStamp")}} ({{bug(1026803)}}).</li>
+ <li>Experimental support for {{domxref("Selection")}} events {{event("selectionchange")}} and {{event("selectstart")}}, as well as the {{domxref("Document.onselectionchange")}} and {{domxref("GlobalEventHandlers.onselectstart")}} event handlers property has been added ({{bug(571294)}}). This feature is controlled by the <code>dom.select_events.enabled</code> preference, that defaults to <code>false</code>.</li>
+ <li>Support for {{domxref("MouseEvent.offsetX")}} and {{domxref("MouseEvent.offsetY")}} have been activated on Firefox for Android and Firefox OS ({{bug(1204841)}}).</li>
+ <li>The {{domxref("HTMLCanvasElement.mozFetchAsStream()")}} method has been removed ({{bug(1206030)}}).</li>
+ <li>The constructor {{domxref("Request.Request", "Request()")}} as well as {{domxref("Window.fetch", "fetch()")}} will now raise a {{exception("TypeError")}} exception when used with a URL containing a username and password ({{bug(1195820)}}).</li>
+</ul>
+
+<h3 id="MathML">MathML</h3>
+
+<p><em>No change.</em></p>
+
+<h3 id="SVG">SVG</h3>
+
+<p><em>No change.</em></p>
+
+<h3 id="AudioVideo">Audio/Video</h3>
+
+<p><em>No change.</em></p>
+
+<h2 id="HTTP">HTTP</h2>
+
+<p><em>No change.</em></p>
+
+<h2 id="Networking">Networking</h2>
+
+<p><em>No change.</em></p>
+
+<h2 id="Security">Security</h2>
+
+<ul>
+ <li>Access to Web Storage (i.e. <code>localStorage</code> and <code>sessionStorage</code>) from third-party IFrames is now denied if the user has <a href="https://support.mozilla.org/en-US/kb/disable-third-party-cookies">disabled third-party cookies</a> ({{bug("536509")}}).</li>
+ <li>This whitelist has even been removed in Nightly and Aurora/Dev Edition of the browser ({{bug(1201023)}}). It is currently scheduled that this removal will also happen for Beta and Release versions for the next version (Firefox 44).</li>
+ <li>Subresource integrity has been implemented for {{htmlelement("script")}} and {{htmlelement("link")}} that doesn't link to stylesheets ({{bug("992096")}}).</li>
+</ul>
+
+<h2 id="Changes_for_add-on_and_Mozilla_developers">Changes for add-on and Mozilla developers</h2>
+
+<h3 id="Interfaces">Interfaces</h3>
+
+<p><em>No change</em></p>
+
+<h3 id="XUL">XUL</h3>
+
+<p><em>No change.</em></p>
+
+<h3 id="JavaScript_code_modules">JavaScript code modules</h3>
+
+<p><em>No change.</em></p>
+
+<h3 id="XPCOM">XPCOM</h3>
+
+<p><em>No change.</em></p>
+
+<h3 id="Plugins">Plugins</h3>
+
+<ul>
+ <li>In preparation for future releases to switch over to multi-process content, <a href="https://developer.mozilla.org/en-US/Add-ons/Plugins">NPAPI</a>plugins can no longer be run in the same process as the page content. The preferences starting with <code>dom.ipc.plugins</code> are no longer used.</li>
+</ul>
+
+<h3 id="Other">Other</h3>
+
+<p><em>No change.</em></p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="https://www.fxsitecompat.com/en-US/versions/43/">Site Compatibility for Firefox 43</a></li>
+</ul>
+
+<h2 id="Older_versions">Older versions</h2>
+
+<p>{{Firefox_for_developers('42')}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/44/index.html b/files/zh-cn/mozilla/firefox/releases/44/index.html
new file mode 100644
index 0000000000..d18ac693ac
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/44/index.html
@@ -0,0 +1,222 @@
+---
+title: Firefox 44 for developers
+slug: Mozilla/Firefox/Releases/44
+translation_of: Mozilla/Firefox/Releases/44
+---
+<div>{{FirefoxSidebar}}</div><p><a style="float: right; margin-bottom: 20px; padding: 10px; text-align: center; border-radius: 4px; display: inline-block; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;" href="https://www.mozilla.org/firefox/developer/">为了测试火狐最新的开发人员特性,请安装火狐开发人员版(Firefox Developer Edition )</a>Firefox 44 于2016年1月26号发布。这个页面列出了对开发人员有用的关键变化。</p>
+
+<h2 id="对于Web开发人员的变化">对于Web开发人员的变化</h2>
+
+<h3 id="开发者工具">开发者工具</h3>
+
+<p>{{page('/en-US/docs/Tools/Release_notes', 'Firefox_44')}}</p>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li><code><a href="/en-US/docs/Web/HTTP/Link_prefetching_FAQ">&lt;link rel="prefetch"&gt;</a></code> 现在服从 {{htmlattrxref("crossorigin", "link")}} 属性 ({{bug(1214819)}}).</li>
+</ul>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li><code>position:</code> <code>fixed;</code> 现在会创建一个新的层叠上下文 ({{bug(1179288)}}).</li>
+ <li>默认支持 {{cssxref('unicode-range')}} ({{bug(1119062)}}).</li>
+ <li>Our experimental implementation of CSS Writing Modes has been updated to reflect the latest specification:
+ <ul>
+ <li>The value <code>sideways</code> of the {{cssxref("text-orientation")}} property has been implemented and <code>sideways-right</code> has been made an alias of it ({{bug(1193488)}}).</li>
+ <li>The value <code>sideways-rl</code> and <code>sideways-lr</code> of the {{cssxref("writing-mode")}} property ({{bug(1193488)}} and {{bug(1193519)}}).</li>
+ </ul>
+ </li>
+ <li>The non-standard properties {{cssxref("-moz-math-display")}} and {{cssxref("-moz-window-shadow")}} are no more available from Web content ({{bug(1207002)}}, {{bug(1211040)}}, and {{bug(1212607)}}).</li>
+ <li>The {{cssxref("font-style")}} property now distinguishes between <code>oblique</code> and <code>italic</code> when both variants are available ({{bug(543715)}}).</li>
+ <li>Though not supported, the properties {{cssxref("marks")}}, {{cssxref("orphans")}}, {{cssxref("page")}}, {{cssxref("size")}}, and {{cssxref("widows")}}, were parsed and {{cssxref("@supports")}} was incorrectly reporting them as supported; this has been fixed and the properties are not parsed anymore, nor marked as supported ({{bug(1215702)}}).</li>
+ <li>The internal value <code>-moz-mac-unified-toolbar</code> has been removed from the possible values for the {{cssxref("-moz-appearance")}} property ({{bug(1206468)}}).</li>
+</ul>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<h4 id="New_APIs">New APIs</h4>
+
+<ul>
+ <li>{{jsxref("Symbol.toPrimitive")}}, {{jsxref("Symbol.prototype.@@toPrimitive", "Symbol.prototype[@@toPrimitive]")}}, and {{jsxref("Date.prototype.@@toPrimitive", "Date.prototype[@@toPrimitive]")}} have been implemented ({{bug(1054756)}}).</li>
+</ul>
+
+<h4 id="Changes">Changes</h4>
+
+<ul>
+ <li>The <code><a href="/en-US/docs/Web/JavaScript/Reference/Statements/let">let</a></code> and <code><a href="/en-US/docs/Web/JavaScript/Reference/Statements/const">const</a></code> bindings in the global level have been made compliant with ES2015 semantics. See {{bug(589199)}} and the blog post <a href="https://blog.mozilla.org/addons/2015/10/14/breaking-changes-let-const-firefox-nightly-44/">"Breaking changes in let and const in Firefox Nightly 44"</a>. In addition, <code>let</code> is now available to default Web JavaScript (strict and non-strict) and does not require a version opt-in anymore ({{bug(932517)}}).</li>
+ <li>If <a href="/en-US/docs/Web/JavaScript/Typed_arrays">typed arrays'</a> (like {{jsxref("Int8Array", "Int8Array")}}) and {{jsxref("ArrayBuffer", "ArrayBuffer")}}) constructors are called as a function without the {{jsxref("Operators/new", "new")}} operator, a {{jsxref("TypeError")}} is now thrown as per the ES6 specification ({{bug(980945)}}, {{bug(1214936)}}).</li>
+ <li>The {{jsxref("RegExp")}} sticky flag now follows the ES2015 standard for<a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky#Anchored_sticky_flag"> anchored sticky regular expressions</a> ({{bug(773687)}}).</li>
+ <li>The <a href="/en-US/docs/Mozilla/Projects/SpiderMonkey/Introduction_to_the_JavaScript_shell">JavaScript shell</a> (SpiderMonkey's REPL) now defaults to the default, Web-compatible JS version (and not JS1.7+ anymore) ({{bug(1192329)}}).</li>
+</ul>
+
+<h4 id="Removals">Removals</h4>
+
+<ul>
+ <li>Support for the non-standard <a href="/en-US/docs/Web/JavaScript/Reference/Statements/let#let_blocks"><code>let</code> blocks</a> has been dropped ({{bug(1167029)}}.</li>
+ <li>The non-standard and deprecated property {{jsxref("Object.noSuchMethod", "Object.prototype.__noSuchMethod__")}} has been removed ({{bug(683218)}}).</li>
+</ul>
+
+<h3 id="InterfacesAPIsDOM">Interfaces/APIs/DOM</h3>
+
+<h4 id="DOM_HTML_DOM">DOM &amp; HTML DOM</h4>
+
+<ul>
+ <li>For compatibility with specific existing sites, the property {{domxref("Document.charset")}} has been implemented as an alias of {{domxref("Document.characterSet")}} ({{bug(647621)}}).</li>
+ <li>Support for the <code><a href="https://developer.mozilla.org/en-US/docs/Adding_search_engines_from_web_pages#Installing_Sherlock_plugins">window.sidebar.addSearchEngine()</a></code> method, which allowed Web pages to invoke an installation of a Sherlock plugin, has been dropped and now it just logs a warning in the Web Console ({{bug(862148)}}).</li>
+ <li>To fight unwanted pop-ups, prompts requested in {{domxref("Window.onbeforeunload")}} of pages that have not been interacted with are no more displayed ({{bug(636905)}}).</li>
+ <li>The deprecated method {{domxref("MessageEvent.initMessageEvent()")}} has been reimplemented for backward compatibility ({{bug(949376)}}).</li>
+ <li>The obsolete property <code>DocumentType.internalSubset</code> has been removed ({{bug(801545)}}).</li>
+ <li>For compatibility with existing sites, the properties {{domxref("Window.orientation")}} and {{domxref("Window.onorientationchange")}}, as well as the {{event("orientationchange")}} event have been implemented ({{bug(920734)}}).</li>
+ <li>An {{HTMLElement("iframe")}} with explicit fullscreen request should not exit fullscreen implicitly ({{bug(1187801)}}).</li>
+ <li>The events {{event("mouseover")}}, {{event("mouseout")}}, {{event("mouseenter")}}, {{event("mouseleave")}}, {{event("pointermove")}}, {{event("pointerover")}}, {{event("pointerout")}}, {{event("pointerenter")}} and {{event("pointerleave")}} are now triggered for disabled form elements ({{bug(218093)}}).</li>
+ <li>The method {{domxref("Element.webkitMatchesSelector()")}} has been added ({{bug(1216193)}}) to improve interoperability.</li>
+ <li>To match the spec, the method {{domxref("Document.createAttribute()")}} now converts the input to lower case ({{bug(1176313)}}).</li>
+ <li>The non-standard <code>dialog</code> feature for {{domxref("Window.open()")}} is no longer available to Web content. It is still available to extensions and other code with chrome privileges ({{bug(1095236)}}.</li>
+</ul>
+
+<h4 id="Canvas">Canvas</h4>
+
+<ul>
+ <li>A new experimental {{domxref("OffscreenCanvas")}} API that allows rendering contexts (such as <a href="/en-US/docs/Web/API/WebGL_API">WebGL</a>) to run in <a href="/en-US/docs/Web/API/Web_Workers_API">Web Workers</a> has been implemented. To use this experimental API set <code>gfx.offscreencanvas.enabled</code> to <code>true</code> in about:config ({{bug(709490)}}). This API includes:
+
+ <ul>
+ <li>The {{domxref("OffscreenCanvas")}} interface,</li>
+ <li>{{domxref("HTMLCanvasElement.transferControlToOffscreen()")}}, and</li>
+ <li>{{domxref("WebGLRenderingContext.commit()")}}.</li>
+ <li>Several WebGL interfaces are now also available in a worker context when this API is enabled.</li>
+ </ul>
+ </li>
+</ul>
+
+<h4 id="WebGL">WebGL</h4>
+
+<ul>
+ <li>Uniform Buffer Objects have been implemented ({{bug(1048747)}}).</li>
+</ul>
+
+<h4 id="IndexedDB">IndexedDB</h4>
+
+<ul>
+ <li>The {{domxref("IDBIndex.getAll()")}} and {{domxref("IDBIndex.getAllKeys()")}} are now available by default ({{bug(1196841)}}).</li>
+</ul>
+
+<h4 id="Service_Workers">Service Workers</h4>
+
+<ul>
+ <li>The {{domxref("ServiceWorkerMessageEvent")}} and {{domxref("ExtendableMessageEvent")}} interfaces have been implemented ({{bug(1143717)}} and {{bug(1207068)}}).</li>
+ <li>{{domxref("Headers")}} objects now support a pair iterator, meaning that the methods {{domxref("Headers.entries()")}}, {{domxref("Headers.keys()")}}, and {{domxref("Headers.values()")}} are now available; {{jsxref("Symbol.iterator")}} now also returns the default iterator for them ({{bug(1108181)}}).</li>
+ <li>The {{domxref('XMLHttpRequest')}} API has been disabled on Service Workers ({{bug(931243)}}).</li>
+ <li>The interface {{domxref("FetchEvent")}} now extends {{domxref("ExtendableEvent")}}, giving it access to the {{domxref("ExtendableEvent.waitUntil()")}} method. ({{bug(1214772)}}).</li>
+ <li>Following a recent change in the specification, {{domxref("FetchEvent.client")}} has been removed ({{bug(1218135)}}).</li>
+ <li>To match the latest specification, the {{domxref("ServiceWorkerContainer.onreloadpage")}} has been removed ({{bug(1218139)}}).</li>
+ <li>The event handlers {{domxref("ServiceWorkerGlobalScope.onbeforeevicted")}} and {{domxref("ServiceWorkerGlobalScope.onevicted")}} have been removed as they weren't following the spec. They will be reintroduced in the future, but their removal will allow feature detection to work as expected ({{bug(1218142)}}).</li>
+ <li>In the {{domxref("FetchEvent.FetchEvent", "FetchEvent()")}} constructor, if the <code>isReload</code> member is not present in the options dictionary, it now defaults to <code>false</code> ({{bug(1216401)}}).</li>
+ <li>The {{domxref("Client.frameType")}} property is now implemented on the right interface; it was on {{domxref("WindowClient")}} before ({{bug(1218146)}}).</li>
+ <li>When <a href="/en-US/docs/Web/HTML/Using_the_application_cache">AppCache</a> is used to provide offline support for a page, a warning message is now displayed in the console advising developers to use <a href="/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers">Service workers</a> instead ({{bug("1204581")}}.)</li>
+ <li>Service workers have been enabled by default in Gecko.</li>
+</ul>
+
+<h4 id="WebRTC">WebRTC</h4>
+
+<ul>
+ <li>WebRTC interfaces have been <em>unprefixed</em> ({{bug(1155923)}}). In particular:
+
+ <ul>
+ <li><code>mozRTCPeerConnection</code> is now {{domxref("RTCPeerConnection")}}.</li>
+ <li><code>mozRTCIceCandidate</code> is now {{domxref("RTCIceCandidate")}}.</li>
+ <li><code>mozRTCSessionDescription</code> is now {{domxref("RTCSessionDescription")}}.</li>
+ </ul>
+ </li>
+ <li>The {{domxref("RTCDataChannel.bufferedAmountLowThreshold")}} and {{domxref("RTCDataChannel.onbufferedamountlow")}} properties, as well as the {{event("bufferedamountlow")}} event, have been implemented ({{bug(1178091)}}).</li>
+ <li>The attribute {{domxref("RTCPeerConnection.canTrickleIceCandidates")}} has been added, the non-standard method {{domxref("RTCPeerConnection.updateIce()")}} removed ({{bug(1209744)}}).</li>
+ <li>The {{domxref("MediaStream")}} interface now supports the {{domxref("MediaStream.addTrack()")}} and {{domxref("MediaStream.removeTrack()")}} methods ({{bug(1103188)}}).</li>
+ <li>The constructor {{domxref("MediaStream.MediaStream", "MediaStream()")}} has been implemented ({{bug(1070216)}}).</li>
+ <li>Support for the non-standard constraint style option list for {{domxref("RTCOfferOptions")}} has been removed; see <a href="https://www.fxsitecompat.com/en-USdocs/2015/constraint-like-rtcofferoptions-are-no-longer-supported/">this post on the site compatibility blog</a> for details.</li>
+</ul>
+
+<h4 id="New_APIs_2">New APIs</h4>
+
+<ul>
+ <li>An experimental implementation of the Canvas API in Workers has landed: {{domxref("OfflineCanvas")}} and {{domxref("HTMLCanvasElement.transferControlToOffscreen()")}} are available behind the <code>gfx.offscreencanvas.enabled</code> preference, currently disabled by default ({{bug(709490)}}).</li>
+ <li>The Text2Speech API, part of Web Speech API, has now an OS X backend. But this is disabled by default ({{bug(1003452)}}).</li>
+</ul>
+
+<h4 id="Miscellaneous">Miscellaneous</h4>
+
+<ul>
+ <li>{{domxref("URLSearchParams")}} objects now support a pair iterator, meaning that the methods {{domxref("URLSearchParams.entries()")}}, {{domxref("URLSearchParams.keys()")}}, and {{domxref("URLSearchParams.values()")}} are now available; {{jsxref("Symbol.iterator")}} now also returns the default iterator for them ({{bug(1085284)}}).</li>
+ <li>{{domxref("FormData")}} objects now support a pair iterator, meaning that the methods {{domxref("FormData.entries()")}}, {{domxref("FormData.keys")}}, and {{domxref("FormData.values()")}} are now available; {{jsxref("Symbol.iterator")}} now also returns the default iterator for them ({{bug(1127703)}}).</li>
+ <li>When {{domxref("XMLHttpRequest.send()")}} is used with an HTML document, it now uses <code>text/html</code> instead of <code>application/xml</code> ({{bug(918771)}}).</li>
+ <li>Speech synthesis (text-to-speech) has been implemented in Firefox Desktop for Mac and Linux, hidden behind the <code>media.webspeech.synth.enabled</code> flag in <code>about:config</code> ({{bug("1003452")}}, {{bug("1003464")}}.) See <a href="/en-US/docs/Web/API/Web_Speech_API">Web Speech API</a> for more information.</li>
+ <li>Elements inside a {{HTMLElement("frame")}} or an {{HTMLElement('object')}} can't be set full-screen anymore ({{bug(1212299)}}).</li>
+</ul>
+
+<h3 id="MathML">MathML</h3>
+
+<p><em>No change.</em></p>
+
+<h3 id="SVG">SVG</h3>
+
+<p><em>No change.</em></p>
+
+<h3 id="AudioVideo">Audio/Video</h3>
+
+<p><em>No change.</em></p>
+
+<h2 id="HTTP">HTTP</h2>
+
+<ul>
+ <li>Support for the <a href="https://en.wikipedia.org/wiki/Brotli">Brotli</a> algorithm has been added and both <code><a href="/en-US/docs/Web/HTTP/Content_negotiation#The_Accept-Encoding_header">Accept-Encoding</a></code> and <code><a href="/en-US/docs/Web/HTTP/Headers/Content-Encoding">Content-Encoding </a></code>headers now support the <code>br</code> value ({{bug(366559)}} and {{bug(1211916)}}).</li>
+ <li>Incorrect support of HTTP/2 headers containing line breaks (<code>'/n'</code>) have been removed as the spec doesn't allow it, unlike HTTP/1 ({{bug(1197847)}}).</li>
+</ul>
+
+<h2 id="Networking">Networking</h2>
+
+<p><em>No change.</em></p>
+
+<h2 id="Security">Security</h2>
+
+<ul>
+ <li>RC4 is now also disabled by default on Beta and Release versions of the browser ({{bug(1201025)}}) and the whitelist is now empty by default ({{bug(1215796)}}).</li>
+</ul>
+
+<h2 id="Changes_for_add-on_and_Mozilla_developers">Changes for add-on and Mozilla developers</h2>
+
+<h3 id="Interfaces">Interfaces</h3>
+
+<p><em>No change</em></p>
+
+<h3 id="XUL">XUL</h3>
+
+<p><em>No change.</em></p>
+
+<h3 id="JavaScript_code_modules">JavaScript code modules</h3>
+
+<ul>
+ <li>Added <code>LIKE</code> support to {JSM("Sqlite.jsm")}} ({{bug(1188760)}}).</li>
+ <li>Added <a href="/en-US/docs/Mozilla/Add-ons/Firefox_for_Android/API/Snackbars.jsm">Snackbars.jsm</a> module to <a href="/en-US/docs/Mozilla/Firefox_for_Android" title="/en/docs/Mozilla/Firefox_for_Android">Firefox for Android</a> ({{bug(1215026)}})</li>
+</ul>
+
+<h3 id="XPCOM">XPCOM</h3>
+
+<ul>
+ <li>The {{interface("nsIDOMWindow")}} interface is now empty. Its contents were either no longer used, had moved elsewhere, or were only used from C++. The items available from C++ code now reside in the <code>{{source("dom/base/nsPIDOMWindow.h", "nsPIDOMWindow")}}</code> interface ({{bug(1216401)}}).</li>
+</ul>
+
+<h3 id="Other">Other</h3>
+
+<ul>
+ <li>Due to breaking changes in Firefox 44 (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1202902">bug 1202902</a>), add-ons packed with <a href="/en-US/docs/Mozilla/Add-ons/SDK/Tools/cfx">cfx</a> will not work any longer. To make your add-on compatible again, please use <a href="/en-US/docs/Mozilla/Add-ons/SDK/Tools/jpm">jpm</a>. You can find steps to migrate from <em>cfx</em> to <em>jpm</em> <a href="/en-US/docs/Mozilla/Add-ons/SDK/Tools/cfx_to_jpm">here</a>.</li>
+</ul>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="https://www.fxsitecompat.com/en-US/versions/44/">Site compatibility for Firefox 44</a></li>
+</ul>
+
+<h2 id="Older_versions">Older versions</h2>
+
+<p>{{Firefox_for_developers(43)}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/45/index.html b/files/zh-cn/mozilla/firefox/releases/45/index.html
new file mode 100644
index 0000000000..e288cbacc6
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/45/index.html
@@ -0,0 +1,187 @@
+---
+title: Firefox 45 for developers
+slug: Mozilla/Firefox/Releases/45
+tags:
+ - Firefox
+ - Firefox 45
+translation_of: Mozilla/Firefox/Releases/45
+---
+<div>{{FirefoxSidebar}}</div><p><a style="float: right; margin-bottom: 20px; padding: 10px; text-align: center; border-radius: 4px; display: inline-block; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;" href="https://www.mozilla.org/firefox/developer/">安装Firefox开发者版本,<br>
+ 以便测试Firefox最新的功能</a> Firefox 45 was released on March 8, 2016. This article lists key changes that are useful not only for web developers, but also Firefox and Gecko developers as well as add-on developers.</p>
+
+<h2 id="针对网络开发者的功能更新">针对网络开发者的功能更新</h2>
+
+<h3 id="开发工具">开发工具</h3>
+
+<p>{{page('/en-US/docs/Tools/Release_notes', 'Firefox_45')}}</p>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>现在可以在{{HTMLElement("meta")}}上直接设置内容安全策略(Content Security Policy)。 ({{bug(663570)}}).</li>
+ <li>The attribute <code>referrer</code> has been renamed into <code>referrerpolicy</code> on {{HTMLElement("image")}}, {{HTMLElement("area")}}, {{HTMLElement("a")}}, and {{HTMLElement("iframe")}} ({{bug(1187357)}}).</li>
+ <li>Changes in the viewport, or a resize, now trigger the reselection of responsive images for <code>&lt;img srcset&gt;</code> ({{bug(1166138)}}).<br>
+  </li>
+</ul>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>{{cssxref("word-spacing")}} now allows percentage values ({{bug(1038663)}}).</li>
+ <li>Our implementation of CSS Grids has been improved and is no more considered experimental; it is now activated by default in nightly and developer edition, but not for beta and release ({{bug(1000592)}}):
+ <ul>
+ <li>Gutters, that is the {{cssxref("grid-column-gap")}}, {{cssxref("grid-row-gap")}}, and {{cssxref("grid-gap")}} properties are now supported ({{bug(1176792)}}).</li>
+ <li>The implied minimum size of grid Items, that is the special {{cssxref("min-width")}} and {{cssxref("min-height")}} <code>auto</code> behavior has been implemented ({{bug(1176775)}}).</li>
+ <li>{{cssxref("align-self")}} and {{cssxref("justify-self")}} are now supported on grid layouts ({{bug(1151213)}}).</li>
+ <li>{{cssxref("align-content")}} and {{cssxref("justify-content")}} are now supported on grid layouts ({{bug(1151214)}}).</li>
+ <li>Resolved value of grid-template-columns,grid-template-rows in px units ({{bug(978212)}}).</li>
+ <li>The related feature {{cssxref("display")}}: contents has been supported since <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/37">Firefox 37</a></li>
+ </ul>
+ </li>
+ <li>Implement full support for CSS Box Alignment for CSS Grid, support the missing values: <code>start,</code> <code>end,</code> <code>self-start,</code> <code>self-end,</code> <code>left,</code> <code>right,last-baseline,space-evenly </code>({{bug(1176782)}}).  CSS Box Alignment currently applies only to CSS Flexbox and CSS Grid.</li>
+ <li> [css-grid][css-flexbox] Implement grid/flex layout for &lt;fieldset&gt; ({{bug(1230207)}}).</li>
+ <li>The <code>inline-start</code> and <code>inline-end</code> values have been added to {{cssxref("float")}} and {{cssxref("clear")}} ({{bug(1122918)}}). They are enabled by default on Nightly and Aurora (Dev edition), as well as on Firefox OS; to activate it on a release or beta version, you need to flip the <code>layout.css.float-logical-values.enabled</code> to <code>true</code>.</li>
+ <li>The {{cssxref("text-emphasis")}}, {{cssxref("text-emphasis-style")}}, {{cssxref("text-emphasis-color")}}, and {{cssxref("text-emphasis-position")}} have been implemented; they are disabled by default (set <code>layout.css.text-emphasis.enabled</code>  to true to activate them ({{bug(1040668)}}).</li>
+ <li>Several <code>-webkit</code> prefixed properties and values have been added for web compatibility, behind the preference <code>layout.css.prefixes.webkit</code>, defaulting to <code>false</code>:
+ <ul>
+ <li>Added {{cssxref("-webkit-backface-visibility")}}, {{cssxref("-webkit-perspective")}} and {{cssxref("-webkit-perspective-origin")}} for web compatibility, behind the preference <code>layout.css.prefixes.webkit</code>, defaulting to <code>false</code> ({{bug(1179444)}}).</li>
+ </ul>
+ </li>
+</ul>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li>ES2015 (ES6) <a href="/en-US/docs/Web/JavaScript/Reference/Classes">Classes</a> are now enabled by default ({{bug(1197932)}}).</li>
+ <li>{{jsxref("Operators/Expression_closures", "Expression closures", "", 1)}} are deprecated and will now present a warning in the console ({{bug(995610)}}).</li>
+ <li>{{jsxref("String.prototype.replace")}} does not restore {{jsxref("Global_Objects/RegExp/n", "RegExp static properties", "", 1)}} after executing function parameter anymore ({{bug(1226936)}}).</li>
+ <li>{{jsxref("Math.random()")}} has been updated to the better XorShift128+ algorithm ({{bug(322529)}}).</li>
+</ul>
+
+<h3 id="InterfacesAPIsDOM">Interfaces/APIs/DOM</h3>
+
+<h4 id="DOM_HTML_DOM">DOM &amp; HTML DOM</h4>
+
+<ul>
+ <li>For compatibility, the non-standard property <code><a href="https://developer.mozilla.org/en-US/docs/Web/API/Node/innerText">Node.innerText</a></code> has been implemented ({{bug(264412)}}).</li>
+ <li>The {{domxref("HTMLImageElement.srcset")}} attribute now reacts to resize/viewport changes ({{bug(1166138)}}).</li>
+ <li>{{domxref("Element.getAttributeNames()")}} has been implemented ({{bug(1228634)}}).</li>
+</ul>
+
+<h4 id="WebGL">WebGL</h4>
+
+<p>Our implementation of WebGL2 have been extended:</p>
+
+<ul>
+ <li>Support of programs and shaders has been added ({{bug(1048743)}}).</li>
+ <li>Support for uniforms and attributes has been added ({{bug(1048745)}}).</li>
+ <li>Framebuffer objects have been implemented ({{bug(1048732)}}).</li>
+ <li>Renderbuffer objects have been implemented ({{bug(1048733)}}).</li>
+</ul>
+
+<h4 id="IndexedDB">IndexedDB</h4>
+
+<p><em>No change.</em></p>
+
+<h4 id="Service_Workers">Service Workers</h4>
+
+<ul>
+ <li>{{domxref("Clients.get()")}} and {{domxref("FetchEvent.clientId")}} have been implemented ({{bug(1222464)}}.)</li>
+ <li>{{domxref("Clients.openWindow()")}} has been implemented ({{bug(1172870)}}.)</li>
+ <li>The options object that can be passed as a parameter when invoking {{domxref("Clients.matchAll()")}} can now include an <code>includeUncontrolled</code> property. This is a {{domxref("Boolean")}} — if set to <code>true</code>, the matching operation will return all service worker clients who share the same origin as the current service worker. Otherwise, it returns only the service worker clients controlled by the current service worker. The default is <code>false</code>.</li>
+</ul>
+
+<h4 id="WebRTC">WebRTC</h4>
+
+<p><em>No change.</em></p>
+
+<h4 id="New_APIs">New APIs</h4>
+
+<p><em>No change.</em></p>
+
+<h4 id="Miscellaneous">Miscellaneous</h4>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API">Web Speech Synthesis API</a> has been implemented on Firefox Desktop ({{bug(1003439)}}).</li>
+ <li>The {{domxref("Window.onstorage")}} event handler property has been added.</li>
+ <li>The interface {{domxref("ComputedTiming")}} have been added to our experimental implementation of <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API">Web Animations API</a> ({{bug(1108055)}}).</li>
+ <li>The {{domxref("Document.onselectionchange")}} event handler property has been added ({{bug(1231193)}}).</li>
+ <li>After removing a video track from a media stream by calling {{domxref("MediaStream.removeTrack()")}} you can nowadd another video track later using {{domxref("MediaStream.addTrack()")}} and have it played ({{bug(1223696)}}).</li>
+</ul>
+
+<h3 id="MathML">MathML</h3>
+
+<p> </p>
+
+<p><em>No change.</em></p>
+
+<h3 id="SVG">SVG</h3>
+
+<ul>
+ <li>SVG stroke hit-testing is buggy when cairo is the Moz2D backend ({{bug(676001)}}).</li>
+ <li>Unable to interact with elements who have large transform / translate values ({{bug(1217012)}}).</li>
+</ul>
+
+<h3 id="AudioVideo">Audio/Video</h3>
+
+<ul>
+ <li>Fixed: Regression (since Firefox 41) whereby audio playback was stuttering due to duration time rounding errors ({{bug(1222866)}}.)</li>
+</ul>
+
+<h2 id="HTTP">HTTP</h2>
+
+<ul>
+ <li>The <code>jar:</code> protocol has been disabled by default when accessed from Web content; you may enable this if necessary by setting the {{pref("network.jar.block-remote-files")}} preference to <code>false</code> ({{bug(1215235)}}).</li>
+</ul>
+
+<h2 id="Security">Security</h2>
+
+<ul>
+ <li>A {{HTTPHeader("Content-Security-Policy")}} can now be specified using a {{HTMLElement("meta")}} element ({{bug(663570)}}).</li>
+ <li>Support of the {{CSP("child-src")}} CSP policy directive has been implemented ({{bug(1045891)}}).</li>
+ <li>EV certificates with a validity greater than 27 months are now considered and handled as DV certificates ({{bug(1222903)}}).</li>
+</ul>
+
+<h2 id="Changes_for_add-on_and_Mozilla_developers">Changes for add-on and Mozilla developers</h2>
+
+<h3 id="Interfaces">Interfaces</h3>
+
+<p><em>No change.</em></p>
+
+<h3 id="XUL">XUL</h3>
+
+<ul>
+ <li>Tab Groups <a href="https://support.mozilla.org/kb/tab-groups-removal">have been removed</a>.</li>
+</ul>
+
+<h3 id="JavaScript_code_modules">JavaScript code modules</h3>
+
+<p><em>No change.</em></p>
+
+<h3 id="XPCOM">XPCOM</h3>
+
+<p><em>No change.</em></p>
+
+<h3 id="Search_plugins">Search plugins</h3>
+
+<p>Starting in Firefox 45, search plugins located in the user's profile's <code>searchplugins</code>directory are no longer automatically loaded on startup. Instead, a list of user-installed plugins is maintained and only those plugins are loaded. In effect, this means that the only ways to install new search plugins are for the user to do so in the Firefox UX (via <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/Creating_OpenSearch_plugins_for_Firefox">OpenSearch discovery</a>, for instance) or for an add-on to install it. Also, when a new search plugin is installed, more information is recorded about where it came from, for future use by profile debugging and cleaning tools.</p>
+
+<p> </p>
+
+<h3 id="Other">Other</h3>
+
+<ul>
+ <li>WebIDL constructors could be called without the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new"><code>new</code></a> operator in chrome context.  Now such code will raise a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError"><code>TypeError</code></a> as in Web content since Firefox 30. For example, <code>var req = XMLHttpRequest();</code> needs to be <code>var req = new XMLHttpRequest();</code>.</li>
+</ul>
+
+<p> </p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="https://www.fxsitecompat.com/en-US/versions/45/">Site Compatibility for Firefox 45</a></li>
+</ul>
+
+<h2 id="Older_versions">Older versions</h2>
+
+<p>{{Firefox_for_developers(44)}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/49/index.html b/files/zh-cn/mozilla/firefox/releases/49/index.html
new file mode 100644
index 0000000000..d1afa7f9a6
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/49/index.html
@@ -0,0 +1,348 @@
+---
+title: Firefox 49 for developers
+slug: Mozilla/Firefox/Releases/49
+tags:
+ - Firefox
+ - Firefox 49
+translation_of: Mozilla/Firefox/Releases/49
+---
+<div>{{FirefoxSidebar}}</div><p><a style="float: right; margin-bottom: 20px; padding: 10px; text-align: center; border-radius: 4px; display: inline-block; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;" href="https://www.mozilla.org/firefox/developer/">To test the latest developer features of Firefox,<br>
+ install Firefox Developer Edition</a> Firefox 49 was released on September 20, 2016. This article lists key changes that are useful not only for web developers, but also Firefox and Gecko developers as well as add-on developers.</p>
+
+<h2 id="对于Web开发者的改变">对于Web开发者的改变</h2>
+
+<h3 id="开发者工具">开发者工具</h3>
+
+<ul>
+ <li>控制台记录的JavaScript错误信息 <a href="https://hacks.mozilla.org/2016/06/helping-web-developers-with-javascript-errors/">现在提供了一个 [Learn more] 链接</a> 为了额外的调试帮助({{bug("1179876")}}).</li>
+ <li>CSS 自动完成: 显示更多的建议在自动完成弹窗 ({{bug("1260419")}}).</li>
+ <li>动画查看器现在 <a href="/en-US/docs/Tools/Page_Inspector/How_to/Work_with_animations#Further_information_about_animation_compositing">暴露出动画的性能信息</a> 在开发工具中 ({{bug("1254408")}}).</li>
+ <li><a href="/en-US/docs/Tools/Page_Inspector/How_to/Examine_and_edit_HTML#Element_popup_context_menu">查看器的上下文菜单</a>被重组的更清楚并且更加容易的使用 ({{bug("1211613")}}).</li>
+ <li>查看器现在支持 <code>#RRGGBBAA</code> 和 <code>#RGBA</code> 语法对于颜色的值 ({{bug("1271191")}}).</li>
+ <li>开发工具不在显示自关闭标签 (比如 {{HTMLElement("br")}} 和 {{HTMLElement("img")}} 好像它们在HTML页面拥有关闭标签; 这个行文在XHTML页面上没有改变 ({{bug("820926")}}).</li>
+ <li>可用性的提高!
+ <ul>
+ <li>工具可以做更好的工作去确保键盘聚焦的地方更加明显 ({{bug(1242851)}}).</li>
+ <li>Accessibility labels have been added to unlabeled controls ({{bug(1242715)}}).</li>
+ <li>增加合适的语义化的树状图和键盘导航到查看器的标记视图 ({{bug(1242694)}}).</li>
+ </ul>
+ </li>
+ <li><a href="/en-US/docs/Tools/Network_Monitor">网络监视器</a> 现在显示一个原因列, 该列提供导致每一个详细的网络请求的踪迹 ({{bug(1134073)}}).</li>
+ <li>在 <em>about:debugging</em> 附加组件页面, Reload 按钮现在只能在临时的附加组件开启. 这将禁用在其他的所有附加组件 ({{bug(1273184)}}).</li>
+ <li>在 <em>about:debugging</em> Workers 页面, 如果 <a href="/en-US/docs/Tools/about:debugging#Service_workers_not_compatible">service workers are incompatible</a> 在现在的浏览器上配置一个温馨的提示将会显示在 Service Workers 部分 ({{bug(1266415)}}).</li>
+ <li><em>about:debugging</em> 现在有一个 <a href="/en-US/docs/Tools/about:debugging#Tabs">新的标签页</a> 可用, 这个标签页提供一个完整的列表包含所有的在FireFox实例中打开的所有的调试标签 ({{bug(1266128)}}).</li>
+ <li><em>Disable Cache</em> 选项 在 <a href="/en-US/docs/Tools/Settings#Advanced_settings">工具箱高级设置</a> 已经被重命名成 Disable HTTP Cache, 来使它更加的清晰得标明这个选项影响 HTTP cache, 而不是 <a href="https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API">Service Workers</a>/the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Cache">Cache API</a> (bug(1253018)).</li>
+ <li><a href="/en-US/docs/Tools/Storage_Inspector#IndexedDB">存储查看器现在允许 IndexedDB 数据库可以被删除</a> 通过它们的上下文菜单 ({{bug("1205123")}}), 并且将显示一个温馨的提示如果 indexedDB因为一些原因没有被删除 (比如它们仍然有活动的链接) ({{bug(1268460)}}).</li>
+</ul>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>增加支持 {{HTMLElement("details")}} 和 {{HTMLElement("summary")}} 元素 ({{bug(1226455)}}).</li>
+ <li>{{htmlattrxref("pattern", "input")}} 属性对于 {{HTMLElement("input")}} 元素现在使用 <code>'u'</code> 参数在潜在的 JavaScript {{jsxref("RegExp")}} ({{bug(1227906)}}).</li>
+ <li>为了匹配规范的变化, {{HTMLElement("track")}}的属性值{{htmlattrxref("kind", "track")}}现在已经无效,现在用 "metadata" 代替 "subtitles" ({{bug(1269712)}}).</li>
+ <li>{{HTMLElement("iframe")}} 元素的 {{htmlattrxref("sandbox", "iframe")}} 属性现在已经支持 <code>'allow-popups-to-escape-sandbox'</code> <code>和 'allow-modals'</code> 值({{bug(1190641)}}).</li>
+ <li>支持 microdata 属性并且已经移除了 Microdata API  ({{bug(909633)}}).</li>
+ <li>{{htmlattrxref("referrerpolicy", "a")}} 属性在 {{HTMLElement("a")}} 元素现在已经支持 <code>'no-referrer-when-downgrade</code>' 和 <code>'origin-when-cross-origin'</code> ({{bug(1178337)}}).</li>
+ <li>{{HTMLElement("label")}}的属于某一个Form的属性{{htmlattrxref("form", "label")}} 现在已经被移除. 但是The {{domxref("HTMLLabelElement.form")}} 属性依旧存在, 但是现在返回的form是与label的控制权相关联的, 如果有控制(或者是与控制权相关联的form) ({{bug(1268852)}}).</li>
+</ul>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>增加{{cssxref("background-position-x")}} 和 {{cssxref("background-position-y")}}, 这允许去分别的指定水平和垂直偏移量来去绘画一个背景图片; 这两个属性是 {{cssxref("background-position")}} 的组件 ({{bug("550426")}}).</li>
+ <li>在 {{cssxref("background-repeat")}} 增加支持 <code>round</code> 和 <code>space</code> 关键字 ({{bug("548372")}}).</li>
+ <li>On {{cssxref("background-clip")}}, the keyword <code>text</code> is now activated by default ({{bug(1264905)}}).</li>
+ <li>增加支持去指定颜色的时候使用alpha通道,使用 4-或者是8-位的 CSS十六进制值 (#RRGGBBAA 或者是 #RGBA) ({{bug("567283")}}).</li>
+ <li>伪类选择器 {{cssxref(":dir()")}} 已经去除了浏览器前缀 ({{bug(859301)}}).</li>
+ <li>在我们的实验实现 (还没有在默认的情况下被激活) CSS属性 {{cssxref("clip-path")}}, 我们现在可以在 {{cssxref("&lt;basic-shape&gt;")}} 中间插入值 ({{bug(1110460)}}).</li>
+ <li>增加 <a href="/en-US/docs/Web/CSS/length#q"><code>q</code> 长度单位</a> ({{bug(1274526)}}).</li>
+ <li>属性值 {{cssxref("text-align-last")}} 已经去除里浏览器前缀 ({{bug(1039541)}}).</li>
+ <li>增加支持 {{cssxref("overflow-wrap")}}, 来替换replacing {{cssxref("word-wrap")}} ,但是现在被替换的依旧可用来作为一个可以替换的名字 ({{bug(955857)}}).</li>
+ <li>我们的实验 <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout">CSS Grids</a> 实现已经被增强:
+ <ul>
+ <li>实现{{cssxref("&lt;percentage&gt;")}} 支持对于 {{cssxref("grid-gap")}}, {{cssxref("grid-row-gap")}}, and {{cssxref("grid-column-gap")}} 属性 ({{bug(1266268)}}).</li>
+ <li>实现网格布局支持对于 {{cssxref("align")}}, {{cssxref("justify-self")}}<code>:baseline</code> 和 <code>last-baseline</code> (也称 "baseline self-alignment") ({{bug(1221525)}}).</li>
+ <li>实现网格子项目基线内容对齐 ({{bug(1256429)}}).</li>
+ </ul>
+ </li>
+ <li>我们的实验 <a href="/en-US/docs/Web/CSS/CSS_Masks">CSS Masks</a> 实现已经被增强:
+ <ul>
+ <li>{{cssxref("mask-origin")}} 属性现在使用 <code>border-box</code> 代替 of <code>padding-box</code> 作为初始值, 为了匹配规范 ({{bug(1258286)}}).</li>
+ <li>{{cssxref("mask-repeat")}} 属性现在支持 <code>space</code> 和 <code>round</code> 值 ({{bug(1258626)}}).</li>
+ <li>Fixed an issue preventing the {{cssxref("mask-position")}} attribute from being animated ({{bug(1273804)}}).</li>
+ </ul>
+ </li>
+ <li>偏好控制 {{cssxref("text-emphasis")}} 已经被移除. 所以支持该属性可以不再被禁用 ({{bug(1229609)}}).</li>
+</ul>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li>ES2015 (ES6) {{jsxref("Global_Objects/Proxy/handler/getPrototypeOf", "getPrototypeOf()")}} 和 {{jsxref("Global_Objects/Proxy/handler/setPrototypeOf", "setPrototypeOf()")}} {{jsxref("Proxy")}} traps属性已经被实现 ({{bug(888969)}}).</li>
+ <li>ES2015 (ES6) {{jsxref("RegExp.prototype.@@match()", "RegExp.prototype[@@match]()")}}, {{jsxref("RegExp.prototype.@@replace()", "RegExp.prototype[@@replace]()")}}, {{jsxref("RegExp.prototype.@@search()", "RegExp.prototype[@@search]()")}}, and {{jsxref("RegExp.prototype.@@split()", "RegExp.prototype[@@split]()")}} 方法, 和 {{jsxref("RegExp.@@species", "RegExp[@@species]")}} getter方法已经被实现 ({{bug(887016)}}).</li>
+ <li>不被赞成的, 非标准的标记参数 <code>String.prototype.</code>{{jsxref("String.prototype.match", "match")}}/{{jsxref("String.prototype.search", "search")}}/{{jsxref("String.prototype.replace", "replace")}} 已经被移除 ({{bug(1108382)}}).</li>
+ <li>{{jsxref("Date.parse()")}}方法在解析2位数年份的行为已经被改变为了更好地和 Google Chrome browser 更好地协作 ({{bug(1265136)}}).</li>
+</ul>
+
+<h3 id="InterfacesAPIsDOM">Interfaces/APIs/DOM</h3>
+
+<h4 id="DOM_HTML_DOM">DOM &amp; HTML DOM</h4>
+
+<ul>
+ <li>方法 {{domxref("DOMTokenList.supports()")}} 已经被增加 ({{bug(1257849)}}).</li>
+ <li>{{domxref("DOMTokenList.replace()")}} 方法已经被增加 ({{bug(1224186)}}).</li>
+ <li>第一位的 <code>'?'</code> 字符现在已经被忽视当作为参数在{{domxref("URLSearchParams.URLSearchParams", "URLSearchParams()")}} 构造器 ({{bug(1268361)}}).</li>
+ <li>The value returned by {{domxref("URL.origin")}}, {{domxref("HTMLAnchorElement.origin")}}, and {{domxref("HTMLAreaElement.origin")}} for URL using the <code>blob:</code> scheme is no longer incorrectly <code>null</code> but is instead the origin of the URL formed by removing the leading <code>blob:</code> ({{bug(1270451)}}).</li>
+ <li>在预渲染模式, {{domxref('Document.visibilityState')}} 属性现在返回 <code>'prerender'</code> ({{bug(1069772)}}).</li>
+ <li>{{domxref("Window.isSecureContext")}} 属性已经被实现 ({{bug(1162772)}}).</li>
+ <li>DOM4 {{domxref("ChildNode.before()")}}, {{domxref("ChildNode.after()")}}, {{domxref("ChildNode.replaceWith()")}}, {{domxref("ParentNode.append()")}} and {{domxref("ParentNode.prepend()")}} 方法已经被实现 ({{bug(911477)}}).</li>
+ <li>{{domxref("TouchList.identifiedTouch()")}} 方法已经被移除 ({{bug(1188539)}}).</li>
+ <li>在默认的情况下, <code>scrollbars</code> {{domxref("Window")}} 特性是开启的当调用{{domxref("Window.open()")}}. 在过去, 这种情况下被强烈推荐开启但却不是默认开启的 ({{bug(1257887)}}).</li>
+ <li>增加实验性并且非标准的 {{domxref("HTMLMediaElement.seekToNextFrame()")}} 方法, 它允许你which allows seeking frame-by-frame through video content ({{bug(1235301)}}). While you're encouraged to experiment with this method to help us understand how useful it is, <em>do not use it in production code!</em></li>
+ <li>The {{domxref("HTMLLabelElement.form")}} property now returns the form with which the label's control is associated, if there is a control (and if that control is associated with a form). Previously, labels were directly associated with forms using this property ({{bug(1268852)}}).</li>
+ <li>Support for the third parameter of {{domxref("EventTarget.addEventListener()")}}, either a {{jsxref("Boolean")}} or an {{interface("EventListenerOptions")}} has been added ({{bug(1266164)}} and {{bug(1266066)}}).</li>
+ <li>The audio volume related values for {{domxref("KeyboardEvent.key")}} have been renamed. <code>"VolumeDown"</code> is now <code>"AudioVolumeDown"</code>, <code>"VolumeUp"</code> is now <code>"AudioVolumeUp"</code>, and <code>"VolumeMute"</code> is now <code>"AudioVolumeMute".</code> This brings Firefox into alignment with the latest draft of the UI Events specification ({{bug(1272578)}}). See {{SectionOnPage("/en-US/docs/Web/API/KeyboardEvent/code", "Code values")}} for a full list of available key codes.</li>
+ <li>The keys previously referred to as <code>"MozHomeScreen"</code>, <code>"MozCameraFocusAdjust"</code>, and <code>"MozPhoneCall"</code> now have official names in the UI Events specification: <code>"GoHome"</code>, <code>"CameraFocus"</code>, and <code>"Call"</code>. Firefox 49 has been updated to use the new names ({{bug(1272599)}}). See {{SectionOnPage("/en-US/docs/Web/API/KeyboardEvent/code", "Code values")}} for a full list of available key codes.</li>
+ <li>The key values <code>"Separator"</code> and <code>"MediaSkip"</code> have been removed, as they were deprecated and unused ({{bug(1232919)}}).</li>
+ <li>Key values and the corresponding key codes <code>"Hyper"</code> and <code>"Super"</code> have been added to represent these legacy modifier keys ({{bug(1232919)}}).</li>
+ <li>两个键值为了多媒体数字小键盘已经被增加: <code>"Key11"</code> and <code>"Key12"</code> ({{bug(1232919)}}).</li>
+ <li>下面的心键值被增加为了音频控制按键: <code>"AudioBassBoostToggle"</code>, <code>"AudioTrebleDown"</code>, and <code>"AudioTrebleUp"</code> ({{bug(123919)}}).</li>
+ <li>键值被增加为了麦克风控制按键: <code>"</code><code>MicrophoneToggle"</code>, <code>"</code><code>MicrophoneVolumeDown"</code>, <code>"</code><code>MicrophoneVolumeUp"</code>, and <code>"</code><code>MicrophoneVolumeMute"</code> ({{bug(123919)}}).</li>
+ <li>新的键值被增加为了支持语音识别设备: "<code>SpeechCorrectionList"</code> and <code>"</code><code>SpeechInputToggle"</code> ({{bug(1232919)}}).</li>
+ <li>新的键值已经被增加去支持手机上的特别的按键: <code>"</code><code>AppSwitch"</code>, <code>"</code><code>Call"</code>, <code>"</code><code>CameraFocus"</code>, <code>"</code><code>EndCall"</code>, <code>"</code><code>GoBack"</code>, <code>"</code><code>GoHome"</code>, <code>"</code><code>HeadsetHook"</code>, <code>"</code><code>LastNumberRedial"</code>, <code>"</code><code>Notification"</code>, <code>"</code><code>MannerMode"</code>, and <code>"</code><code>VoiceDial"</code> ({{bug(1232919)}}).</li>
+ <li>这些新的应用程序键值已经被增加: <code>"</code><code>LaunchContacts"</code> and <code>"</code><code>LaunchPhone"</code> ({{bug(1232919)}}).</li>
+ <li>新的键值被增加去支持电视设备: <code>"</code><code>TV3DMode"</code>, <code>"</code><code>TVAntennaCable"</code>, <code>"</code><code>TVAudioDescription"</code>, <code>"</code><code>TVAudioDescriptionMixDown"</code>, <code>"</code><code>TVAudioDescriptionMixUp"</code>, <code>"</code><code>TVContentsMenu"</code>, <code>"</code><code>TVDataService"</code>, <code>"</code><code>TVInput"</code>, <code>"</code><code>TVInputComponent1"</code>, <code>"</code><code>TVInputComponent2"</code>, <code>"</code><code>TVInputComposite1"</code>, <code>"</code><code>TVInputComposite2"</code>, <code>"</code><code>TVInputHDMI1"</code>, <code>"</code><code>TVInputHDMI2"</code>, <code>"</code><code>TVInputHDMI3"</code>, <code>"</code><code>TVInputHDMI4"</code>, <code>"</code><code>TVInputVGA1"</code>, <code>"</code><code>TVMediaContext"</code>, <code>"</code><code>TVNetwork"</code>, <code>"</code><code>TVNumberEntry"</code>, <code>"</code><code>TVRadioService"</code>, <code>"</code><code>TVSatellite"</code>, <code>"</code><code>TVSatelliteBS"</code>, <code>"</code><code>TVSatelliteCS"</code>, <code>"</code><code>TVSatelliteToggle"</code>, <code>"</code><code>TVTerrestrialAnalog"</code>, <code>"</code><code>TVTerrestrialDigital"</code>, <code>"</code><code>TVTimer"</code>, and <code>"</code><code>DVR"</code> ({{bug(1232919)}}).</li>
+ <li>键值 <code>"</code><code>MediaSelect"</code> 已经被替换成标准的 <code>"</code><code>LaunchMediaPlayer"</code> 键值 ({{bug(1272592)}}).</li>
+ <li>Additional media player key values have been added as well. These are <code>"</code><code>MediaAudioTrack"</code>, <code>"</code><code>MediaSkipBackward"</code>, <code>"</code><code>MediaSkipForward"</code>, <code>"</code><code>MediaStepBackward"</code>, <code>"</code><code>MediaStepForward"</code>, <code>"</code><code>MediaTopMenu"</code>, <code>"</code><code>NavigateIn"</code>, <code>"</code><code>NavigateNext"</code>, <code>"</code><code>NavigateOut"</code>, and <code>"</code><code>NavigatePrevious"</code> ({{bug(1232919)}}).</li>
+</ul>
+
+<h4 id="Canvas">Canvas</h4>
+
+<ul>
+ <li>{{domxref("CanvasRenderingContext2D.filter")}} 属性, 它提供支持去增加滤镜在canvas中, 现在是默认被激活的并且不再需要去偏好选项中去开启 ({{bug(1173545)}}).</li>
+</ul>
+
+<h4 id="WebGL">WebGL</h4>
+
+<ul>
+ <li>{{domxref("EXT_color_buffer_float")}} {{domxref("WebGL2RenderingContext", "WebGL 2", "", 1)}} 扩展已经被实现 ({{bug(1129332)}}).</li>
+ <li>{{Event("webglcontextcreationerror")}} 事件, 它会被发送当 WebGL context 尝试创建但是失败的时候, 已经被实现 ({{bug(1271478)}}). 使用这个来帮助理解什么导致了错误, 可以用来调试代码和生产中的错误处理.</li>
+</ul>
+
+<h4 id="IndexedDB">IndexedDB</h4>
+
+<ul>
+ <li>现在你可以重命名 IndexedDB 索引; the {{domxref("IDBIndex.name")}} 属性不再是只读的 ({{bug(1118028)}}).</li>
+ <li>现在你可以重命名 {{domxref("IDBObjectStore")}}s; {{domxref("IDBObjectStore.name")}} 属性不再是只读的 ({{bug(1118028)}}).</li>
+</ul>
+
+<h4 id="Service_Workers_and_related">Service Workers and related</h4>
+
+<ul>
+ <li>The <a href="/en-US/docs/Web/API/Fetch_API">Fetch API</a>'s {{domxref("Response")}} object now implements the {{domxref("Response.redirected", "redirected")}} property, which indicates whether or not the response is for a request which was redirected. Please review the security related notes in the documentation before using this property ({{bug(1243792)}}).</li>
+ <li>In the <a href="/en-US/docs/Web/API/Permissions_API">Permissions API</a>, Firefox no longer supports the 'push' <code>PermissionDescriptor</code> dictionary type (referred to in the spec as <code>PushPermissionDescriptor</code>); this is because Firefox relies on a quota system for controlling the <code>userVisibleOnly</code> status instead, and was throwing an error when it encountered a <code>PushPermissionDescriptor</code> instance ({{bug(1266821)}}). With this dictionary removed, Firefox now simply ignores it.</li>
+</ul>
+
+<h4 id="Media_Streams">Media Streams</h4>
+
+<ul>
+ <li>In the past, it was possible for a call to {{domxref("MediaDevices.getUserMedia()")}} which requests both audio and video to succeed in cases where the user has only one of the two types of hardware available. This has been fixed ({{bug(802326)}}).</li>
+ <li>In prior versions of Firefox, it was possible for a call to {{domxref("MediaDevices.getUserMedia()")}} which requests both audio and video to succeed even though the user denied access to one but not both of the matching devices. This has been fixed ({{bug(802326)}}). This involves minor user interface changes as well, to remove the options to choose "No audio" or "No video" when the user is prompted for permissions.</li>
+ <li>The {{domxref("MediaStream.getTrackById()")}} method has been implemented ({{bug(1208390)}}).</li>
+</ul>
+
+<h4 id="WebRTC">WebRTC</h4>
+
+<ul>
+ <li>The {{domxref("RTCPeerConnection.addTrack()")}} method has been updated to allow tracks which are not components of the specified streams to be added to the connection. Instead, the streams are used to group tracks on the receiving end of the connection ({{bug(1271669)}}).</li>
+</ul>
+
+<h4 id="New_APIs">New APIs</h4>
+
+<ul>
+ <li>{{domxref("PerformanceObserver")}} API 现在在默认是被激活的在 Nightly. 这在其他版本的Firefox 49 在默认下是无效的 ({{bug(1271487)}}).</li>
+</ul>
+
+<h4 id="Others">Others</h4>
+
+<ul>
+ <li>{{domxref("XMLHttpRequest.getResponseHeader()")}} 和 {{domxref("XMLHttpRequest.getAllResponseHeaders()")}} 返回空头部在偏好选项中 <code>network.http.keep_empty_response_headers_as_empty_string</code> 被设置成 <code>true</code> ({{bug(669259)}}).</li>
+ <li>Firefox OS-only <a href="/en-US/docs/Archive/Firefox_OS/API/Data_Store_API">Data Store API</a> 已经被移除 ({{bug(1261009)}}).</li>
+ <li>The <a href="/en-US/docs/Web/API/Fullscreen_API">Fullscreen API</a> event handlers {{domxref("Document.onfullscreenchange")}} and {{domxref("Document.onfullscreenerror")}} have been removed from {{domxref("Element")}} as they were never fired there; the prefixed versions of these event handlers have been kept there for compatibility purposes, however ({{bug(1270386)}}). Note that this is not yet activated by default, but is behind the <code>full-screen-api.unprefix.enabled</code> preference ({{bug(1268749)}}).</li>
+ <li>The obsolete {{domxref("Document.mozFullScreen")}} property has been unprefixed to {{domxref("Document.fullscreen")}} {{bug(1269157)}}}. Note that this is not yet activated by default by behind the <code>full-screen-api.unprefix.enabled</code> preference ({{bug(1268749)}}).</li>
+ <li>The read-only properties {{domxref("Document.fullscreenElement")}} and {{domxref("Document.fullscreenEnabled")}} no longer throw an exception if an attempt is made to change their values; instead, the new value is silently ignored and the setter function is a no-op ({{bug(1269798)}}).</li>
+ <li>Any kind of data can now be retrieved from the clipboard using {{domxref("DataTransfer.getData()")}}: previously, only data of certain MIME types were supported {{bug(860857)}}.</li>
+ <li>Our implementation of the <a href="/en-US/docs/Web/API/Frame_Timing_API">Frame Timing API</a>, consisting of the two interfaces <code>PerformanceCompositeTiming</code> and <code>PerformanceRenderTiming</code>, has been removed as the spec has been completely rewritten ({{bug(1271846)}}).</li>
+ <li>To match the spec, the {{domxref("VTTCue.positionAlign")}} property now returns a <code>PositionAlign</code> enum instead of an <code>Align</code> enum ({{bug(1276129)}}).</li>
+ <li>The speech synthesis part of <a href="/en-US/docs/Web/API/Web_Speech_API#Speech_synthesis">Web Speech API</a> is now activated by default ({{bug(1268633)}}).</li>
+ <li>The <a href="/en-US/docs/Web/API/Performance_Timeline">Performance Timeline API</a> is now available by default in Nightly (though not in Aurora, Beta or Release).</li>
+ <li>The {{event("install")}} event, and the {{domxref("Window.oninstall")}} event handler, are now supported for <a href="/en-US/docs/Web/Manifest">Web Manifests</a> ({{bug(1265279)}}).</li>
+ <li>When using the {{domxref("AudioContext.createPeriodicWave()")}} method of the <a href="/en-US/docs/Web/API/Web_Audio_API">Web Audio API</a>, you can now specify whether the resulting periodic wave should be normalized by including a dictionary object as the third parameter, which includes a single parameter — <code>{disableNormalization: true}</code> ({{bug(1265405)}}).</li>
+ <li>In the WebVTT API, {{domxref("VTTCue.positionAlign")}} now correctly returns a <code>PositionAlignSetting</code> enum as per spec; previously it returned an <code>AlignSetting</code> enum ({{bug(1276129)}}).</li>
+ <li>The Speech Synthesis part of the Web Speech API is now enabled by default across all desktop browsers ({{bug(1268633)}}).</li>
+ <li>The {{domxref("Animation.Animation()", "Animation()")}} constructor of the <a href="/en-US/docs/Web/API/Web_Animations_API">Web Animations API</a> now accepts a null timeline ({{bug(1096776)}}).</li>
+</ul>
+
+<h3 id="MathML">MathML</h3>
+
+<p><em>No change.</em></p>
+
+<h3 id="SVG">SVG</h3>
+
+<ul>
+ <li>移除支持不被赞成的 {{SVGElement('altGlyph')}}, {{SVGElement('altGlyphDef')}} 和 {{SVGElement('altGlyphItem')}} 元素 ({{bug(1260032)}}).</li>
+</ul>
+
+<h3 id="AudioVideo">Audio/Video</h3>
+
+<p><em>没有改变.</em></p>
+
+<h3 id="Plugins_and_Flash">Plugins and Flash</h3>
+
+<p>Beginning in Firefox 49, Firefox, by default, blocks certain kinds of Flash content that aren't necessary for sites to function well. This behavior, controlled by the preference <code>browser.safebrowsing.blockedURIs.enabled</code>, helps to improve the performance of sites and Firefox in general without having significant impact on site usability. It also helps improve stability of the browsing experience by elminating a major cause of crashes. The blocked Flash modules include several used just for fingerprinting purposes, as well as a number of "supercookie" modules, and in the future may be expanded to include more types of blocked modules. See {{bug(1275591)}} for details.</p>
+
+<p>This marks the next step in the journey toward a plugin-free future. HTML is very close to the point where plugins will no longer be needed to get the job done.</p>
+
+<h2 id="HTTP">HTTP</h2>
+
+<ul>
+ <li><code><a href="/en-US/docs/Web/HTTP/Headers/Cache-Control">Cache-Control: immutable</a></code> 指令现在已经被实现 ({{bug(1267474)}}). 另见这篇文章 <a href="https://bitsup.blogspot.de/2016/05/cache-control-immutable.html">blog post</a> 得到更多信息.</li>
+ <li>The {{CSP("require-sri-for")}} {{HTTPHeader("Content-Security-Policy")}} has been implemented ({{bug(1265318)}}).</li>
+</ul>
+
+<h2 id="Networking">Networking</h2>
+
+<ul>
+ <li>The <a href="/en-US/docs/Mozilla/Projects/Necko/Proxy_Auto-Configuration_(PAC)_file">Proxy Auto-Configuration (PAC)</a> implementation has been updated. Now <code>weekdayRange</code>, <code>dateRange</code>, and <code>timeRange</code> support "reversed ranges", for example, <code>weekdayRange("SAT", "MON")</code> will evaluate <code>true</code> if the current day is Saturday, Sunday, or Monday ({{bug(1251332)}}).</li>
+</ul>
+
+<h2 id="Security">Security</h2>
+
+<ul>
+ <li>The {{domxref("Window.isSecureContext")}} property, indicating whether a context is capable of using features that require <a href="/en-US/docs/Web/Security/Secure_Contexts">secure contexts</a>, has been implemented ({{bug(1162772)}}).</li>
+</ul>
+
+<h2 id="Compatibility">Compatibility</h2>
+
+<p>为了增强兼容性对于现在已经存在的内容, Firefox 现在接受一些 webkit 前缀 properties and attributes.</p>
+
+<ul>
+ <li>    接下来的 properties 现在依旧工作在前缀 -webkit下:
+ <ul>
+ <li>{{cssxref("-webkit-align-items")}}</li>
+ <li>{{cssxref("-webkit-align-content")}}</li>
+ <li>{{cssxref("-webkit-align-self")}}</li>
+ <li>{{cssxref("-webkit-animation")}}</li>
+ <li>{{cssxref("-webkit-animation-delay")}}</li>
+ <li>{{cssxref("-webkit-animation-direction")}}</li>
+ <li>{{cssxref("-webkit-animation-duration")}}</li>
+ <li>{{cssxref("-webkit-animation-fill-mode")}}</li>
+ <li>{{cssxref("-webkit-animation-iteration-count")}}</li>
+ <li>{{cssxref("-webkit-animation-name")}}</li>
+ <li>{{cssxref("-webkit-animation-play-state")}}</li>
+ <li>{{cssxref("-webkit-animation-timing-function")}}</li>
+ <li>{{cssxref("-webkit-backface-visibility")}}</li>
+ <li>{{cssxref("-webkit-background-clip")}}</li>
+ <li>{{cssxref("-webkit-background-origin")}}</li>
+ <li>{{cssxref("-webkit-background-size")}}</li>
+ <li>{{cssxref("-webkit-border-bottom-left-radius")}}</li>
+ <li>{{cssxref("-webkit-border-bottom-right-radius")}}</li>
+ <li>{{cssxref("-webkit-border-image")}}</li>
+ <li>{{cssxref("-webkit-border-top-left-radius")}}</li>
+ <li>{{cssxref("-webkit-border-top-right-radius")}}</li>
+ <li>{{cssxref("-webkit-border-radius")}}</li>
+ <li>{{cssxref("-webkit-box-shadow")}}</li>
+ <li>{{cssxref("-webkit-filter")}}</li>
+ <li>{{cssxref("-webkit-flex")}}</li>
+ <li>{{cssxref("-webkit-flex-basis")}}</li>
+ <li>{{cssxref("-webkit-flex-direction")}}</li>
+ <li>{{cssxref("-webkit-flex-flow")}}</li>
+ <li>{{cssxref("-webkit-flex-grow")}}</li>
+ <li>{{cssxref("-webkit-flex-shrink")}}</li>
+ <li>{{cssxref("-webkit-flex-wrap")}}</li>
+ <li>{{cssxref("-webkit-justify-content")}}</li>
+ <li>{{cssxref("-webkit-order")}}</li>
+ <li>{{cssxref("-webkit-perspective")}}</li>
+ <li>{{cssxref("-webkit-perspective-origin")}}</li>
+ <li>{{cssxref("-webkit-text-size-adjust")}}</li>
+ <li>{{cssxref("-webkit-transform")}}</li>
+ <li>{{cssxref("-webkit-transform-origin")}}</li>
+ <li>{{cssxref("-webkit-transform-style")}}</li>
+ <li>{{cssxref("-webkit-transition")}}</li>
+ <li>{{cssxref("-webkit-transition-delay")}}</li>
+ <li>{{cssxref("-webkit-transition-duration")}}</li>
+ <li>{{cssxref("-webkit-transition-property")}}</li>
+ <li>{{cssxref("-webkit-transition-timing-function")}}</li>
+ <li>{{cssxref("-webkit-user-select")}}</li>
+ </ul>
+ </li>
+ <li>接下来的 properties 映射到(根据猜测,这里应该是没有前缀的属性,但是很奇怪这里的prefixed没有un) the equivalent prefixed property
+ <ul>
+ <li>{{cssxref("-webkit-box-flex")}}</li>
+ <li>{{cssxref("-webkit-box-ordinal-group")}}</li>
+ <li>{{cssxref("-webkit-box-orient")}}</li>
+ <li>{{cssxref("-webkit-box-align")}}</li>
+ <li>{{cssxref("-webkit-box-pack")}}</li>
+ </ul>
+ </li>
+ <li>对于{{cssxref("&lt;image&gt;")}} 值:
+ <ul>
+ <li>接下来的功能映射到它们的没有前缀的事物: {{cssxref("-webkit-linear-gradient", "-webkit-linear-gradient()")}}, {{cssxref("-webkit-radial-gradient", "-webkit-radial-gradient()")}}, {{cssxref("-webkit-repeating-linear-gradient", "-webkit-repeating-linear-gradient()")}}, and {{cssxref("-webkit-repeating-radial-gradient","-webkit-repeating-radial-gradient()")}}.</li>
+ <li>The outdated <code>-webkit-gradient</code> is supported (and translated to a regular gradient)</li>
+ </ul>
+ </li>
+ <li>接下来的 {{cssxref("display")}} 值被转换:
+ <ul>
+ <li><code>-webkit-box</code> to <code>-moz-box</code></li>
+ <li><code>-webkit-flex</code> to <code>flex</code></li>
+ <li><code>-webkit-inline-box</code> to <code>inline-flex</code></li>
+ <li><code>-webkit-inline-flex</code> to <code>-moz-inline-flex</code></li>
+ </ul>
+ </li>
+ <li> 接下来的属性被支持 (并且不会映射到任何没有前缀的事物and don't map to any unprefixed equivalent):
+ <ul>
+ <li>{{cssxref("-webkit-text-fill-color")}}</li>
+ <li>{{cssxref("-webkit-text-stroke-color")}}</li>
+ <li>{{cssxref("-webkit-text-stroke-width")}}</li>
+ <li>{{cssxref("-webkit-text-stroke")}}</li>
+ </ul>
+ </li>
+ <li>{{domxref("WebKitCSSMatrix")}} 接口是 {{domxref("DOMMatrix")}} 的别名</li>
+ <li>接下来的媒体查询功能已经被实现:
+ <ul>
+ <li><code>-webkit-min-device-pixel-ratio</code> as an alias of <code><a href="/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#resolution">min-resolution</a></code> with the same value (in <code>dppx)</code>, though this feature is <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1237720">disabled by default</a> (behind about:config pref <code>layout.css.prefixes.device-pixel-ratio-webkit</code>)</li>
+ <li><code>-webkit-max-device-pixel-ratio</code> as an alias of <code><a href="/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#resolution">max-resolution</a></code> of the same value (in <code>dppx</code>); this feature is also disabled by default, behind the same about:config pref.</li>
+ <li><code><a href="/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#-webkit-transform-3d">-webkit-transform-3d</a></code> always matching, indicating 3d transform support.</li>
+ </ul>
+ </li>
+</ul>
+
+<h2 id="改变对于_add-on_and_Mozilla_developers">改变对于 add-on and Mozilla developers</h2>
+
+<h3 id="WebExtensions">WebExtensions</h3>
+
+<ul>
+ <li>Support for the {{WebExtAPIRef("history")}} has been added. This provides access to the browser history, with methods available for searching the history, getting information about previously-visited pages, and adding and removing history entries.</li>
+ <li>Added the {{WebExtAPIRef("tabs.removeCSS()")}} method to the tabs API. This method lets you remove CSS which was previously injected by calling {{WebExtAPIRef("tabs.insertCSS()")}}.</li>
+</ul>
+
+<h3 id="Interfaces">Interfaces</h3>
+
+<ul>
+ <li>In {{domxref("EventTarget.addEventListener()")}}, the value <code>mozSystemGroup</code>,  active only in code running in XBL or in Firefox's chrome, is a {{jsxref("Boolean")}} which indicates if the listener is added to the system group. ({{bug(1274520)}})</li>
+</ul>
+
+<h3 id="Other">Other</h3>
+
+<p><em>没有改变.</em></p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="https://www.fxsitecompat.com/en-US/versions/49">Site Compatibility for Firefox 49</a></li>
+</ul>
+
+<h2 id="Older_versions">Older versions</h2>
+
+<p>{{Firefox_for_developers(48)}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/56/index.html b/files/zh-cn/mozilla/firefox/releases/56/index.html
new file mode 100644
index 0000000000..e7e2870e37
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/56/index.html
@@ -0,0 +1,129 @@
+---
+title: Firefox 56 for developers
+slug: Mozilla/Firefox/Releases/56
+translation_of: Mozilla/Firefox/Releases/56
+---
+<div>{{FirefoxSidebar}}</div><article class="text-content" id="wikiArticle">
+<p>本文介绍了一些在Firefox 56中的一些改进,这些改进会对开发者们产生影响。Firefox 56是当前Firefox的Beta版,预计在2017年9月26日正式发布。</p>
+
+<article class="text-content" id="wikiArticle">
+<h2 id="针对网页开发者们的若干改变">针对网页开发者们的若干改变</h2>
+
+<h3 id="开发者工具">开发者工具</h3>
+
+<ul>
+ <li>在CSS格检查器中显示以负号开始的行号({{bug(1369942)}}).</li>
+</ul>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>在打标签的窗体控件中采用<code>labels</code> 属性,比如 {{domxref("HTMLInputElement.labels")}} ({{bug(556743)}}).</li>
+ <li>实现了 <code>&lt;link rel="preload"&gt;</code>; 更详细的内容,可以参见 <a href="/en-US/docs/Web/HTML/Preloading_content">Preloading content with rel="preload"</a>  ({{bug(1222633)}}). 需要注意的是,当前的Firefox只支持对可缓存的资源进行预加载。</li>
+</ul>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>实现了Mozilla自有的属性 {{cssxref("&lt;color&gt;")}} 值为 <code>-moz-win-accentcolor</code> 以及 <code>-moz-win-accentcolortext</code> (可以参见 {{bug(1344910)}}), 以及专用的媒体查询语句 <code><a href="/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#-moz-windows-accent-color-in-titlebar">-moz-windows-accent-color-in-titlebar</a></code> (参见{{bug(1379938)}}).</li>
+</ul>
+
+<h3 id="SVG">SVG</h3>
+
+<p><em>无修改.</em></p>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li>The <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl">Intl API</a> has been enabled on Firefox for Android ({{bug(1344625)}}).</li>
+</ul>
+
+<h3 id="APIs">APIs</h3>
+
+<h4 id="New_APIs">New APIs</h4>
+
+<p><em>No changes.</em></p>
+
+<h4 id="DOM">DOM</h4>
+
+<ul>
+ <li>On Mac, {{domxref("Document.hidden")}} is now true when the window is behind another non-translucent application {{bug(1236512)}}.</li>
+ <li>The {{domxref("Gamepad.displayId")}} property has been implemented ({{bug(1375816)}}).</li>
+ <li>The {{domxref("PerformanceTiming.secureConnectionStart")}} property has been implemented ({{bug(772589)}}).</li>
+ <li>Firefox used to accept <code>iso-2022-jp-2</code> sequences silently when an <code>iso-2022-jp</code> {{domxref("TextDecoder.TextDecoder","TextDecoder()")}} was instantiated, however this has now been removed to simplify the API, as no other browsers support it and no pages seem to use it. ({{bug(715833)}}).</li>
+ <li>The 4ms clamping behaviour of {{domxref("WindowOrWorkerGlobalScope.setTimeout","setTimeout()")}} and {{domxref("WindowOrWorkerGlobalScope.setInterval","setInterval()")}} has been updated to be more in line with other browsers, as described in <a href="/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Timeouts_throttled_to_%3E4ms">Timeouts throttled to &gt;=4ms</a> ({{bug(1378586)}}).</li>
+ <li>The <a href="/en-US/docs/Web/API/Page_Visibility_API">Page Visibility API's</a> {{domxref("Document.onvisibilitychange")}} handler has been added ({{bug("1333912")}}).</li>
+ <li>The {{domxref("Window.showModalDialog()")}} method has been removed ({{bug(981796)}}).</li>
+</ul>
+
+<h4 id="DOM_events">DOM events</h4>
+
+<ul>
+ <li>{{domxref("GlobalEventHandlers.onwheel")}} is now available on {{domxref("HTMLElement")}} — it wasn't before ({{bug(1370550)}}).</li>
+</ul>
+
+<h4 id="WebRTC">WebRTC</h4>
+
+<ul>
+ <li>Firefox now supports the {{domxref("RTCPeerConnection")}} properties which let you examine the current and pending configurations of the local and remote ends of the connection, to help manage changes in configuration: {{domxref("RTCPeerConnection.currentLocalDescription", "currentLocalDescription")}}, {{domxref("RTCPeerConnection.pendingLocalDescription", "pendingLocalDescription")}}, {{domxref("RTCPeerConnection.currentRemoteDescription", "currentRemoteDescription")}}, and {{domxref("RTCPeerConnection.pendingRemoteDescription", "pendingRemoteDescription")}}.</li>
+</ul>
+
+<h4 id="Canvas_and_WebGL">Canvas and WebGL</h4>
+
+<ul>
+ <li>The {{domxref("CanvasRenderingContext2D.drawImage()")}} method has been updated so that smoothing occurs when downscaling even if <code>imageSmoothingEnabled</code> is <code>false</code>. This is not mandatory as per spec, but follows Chrome's behaviour. See {{bug(1360415)}}.</li>
+ <li>An {{domxref("SVGImageElement")}} can now be used as a {{domxref("CanvasImageSource")}}, e.g. as the image source in a {{domxref("CanvasRenderingContext2D.drawImage","drawImage()")}} call ({{bug(1382027)}}).</li>
+</ul>
+
+<h3 id="Security">Security</h3>
+
+<p><em>No changes.</em></p>
+
+<h3 id="Plugins">Plugins</h3>
+
+<p><em>No changes.</em></p>
+
+<h3 id="Other">Other</h3>
+
+<ul>
+ <li>Gecko now encodes URLs internally as <a href="https://en.wikipedia.org/wiki/Punycode">punycode</a>, to avoid URL encoding problems (see {{bug("945240")}}, also see discussion in {{bug("942074")}}).</li>
+ <li>Firefox on Windows and Mac OS X can now be made to run in <a href="/en-US/docs/Mozilla/Firefox/Headless_mode">headless mode</a> using the <code>-headless</code> flag (see {{bug(1355150)}} and {{bug(1355147)}}).</li>
+</ul>
+
+<h2 id="Removals_from_the_web_platform">Removals from the web platform</h2>
+
+<h3 id="HTML_2">HTML</h3>
+
+<ul>
+ <li>The {{htmlelement("isindex")}} element has been removed from the HTML parser, and from form submission ({{bug(1266495)}}).</li>
+ <li>The {{htmlelement("applet")}} element has been removed ({{bug(1279218)}}).</li>
+</ul>
+
+<h3 id="APIs_2">APIs</h3>
+
+<p><em>No changes.</em></p>
+
+<h3 id="SVG_2">SVG</h3>
+
+<p><em>No changes.</em></p>
+
+<h2 id="Changes_for_add-on_and_Mozilla_developers">Changes for add-on and Mozilla developers</h2>
+
+<h3 id="WebExtensions">WebExtensions</h3>
+
+<p><em>No changes.</em></p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="https://www.fxsitecompat.com/en-US/versions/56">Site Compatibility for Firefox 56</a></li>
+</ul>
+</article>
+
+<ul>
+</ul>
+
+<h2 id="Older_versions">Older versions</h2>
+
+<p>{{Firefox_for_developers(55)}}</p>
+</article>
diff --git a/files/zh-cn/mozilla/firefox/releases/59/index.html b/files/zh-cn/mozilla/firefox/releases/59/index.html
new file mode 100644
index 0000000000..aca2ace7c6
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/59/index.html
@@ -0,0 +1,130 @@
+---
+title: Firefox 59 for developers
+slug: Mozilla/Firefox/Releases/59
+tags:
+ - '29'
+ - 发布说明
+ - 火狐
+translation_of: Mozilla/Firefox/Releases/59
+---
+<div>{{FirefoxSidebar}}</div><div>{{draft}}</div>
+
+<p class="summary">本文提供了有关Firefox 59中会影响开发人员的更改的信息。 Firefox 59已于2018年3月13日发布。</p>
+
+<article class="text-content" id="wikiArticle">
+<h2 id="Web开发者应该注意的变化">Web开发者应该注意的变化</h2>
+
+<h3 id="开发工具">开发工具</h3>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor">网络监视器</a> 响应标签现在显示一个 <a href="https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor#HTML_preview">已渲染网页的预览</a>  — 如果响应是一个HTML的话 ({{bug(1353319)}}).</li>
+ <li>存储探查器显示的 Cookie信息  (见 <a href="https://developer.mozilla.org/en-US/docs/Tools/Storage_Inspector#Cookies">Cookies</a>) 现在包括一列 <em>“同站”</em> 显示每个cookie的同站状态 ({{bug(1298370)}})。</li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Rulers">标尺</a> 工具 现在包含了一个 readout 来显示当前视角的维度 ({{bug(1402633)}})。</li>
+ <li>在<a href="https://developer.mozilla.org/en-US/docs/Tools/Responsive_Design_Mode">响应式设计模式 </a>, 您现在可以使用光标键设置屏幕尺寸({{bug(1421663)}})。详见 <a href="https://developer.mozilla.org/en-US/docs/Tools/Responsive_Design_Mode#Setting_screen_size">Setting screen size</a> 。</li>
+ <li>The <em>Raw headers</em> display in the <a href="https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor">Network Monitor</a> <em>Headers</em> tab now includes the response's status code ({{bug(1419401)}}).</li>
+</ul>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>实现了{{HTMLElement("textarea")}} 元素的 {{htmlattrxref("autocomplete", "textarea")}}属性 . 这使得你可以启用或禁用元素的表单自动填写。</li>
+</ul>
+
+<h3 id="CSS">CSS</h3>
+
+<p><em>无变化。</em></p>
+
+<h3 id="SVG">SVG</h3>
+
+<p><em>无变化。</em></p>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<p><em>无变化。</em></p>
+
+<h3 id="APIs">APIs</h3>
+
+<h4 id="新增API">新增API</h4>
+
+<ul>
+ <li>在nightly中默认启用 <a href="/en-US/docs/Web/Web_Components/Custom_Elements">Custom elements</a> v1  ({{bug(1406825)}}).</li>
+</ul>
+
+<h4 id="DOM">DOM</h4>
+
+<p><em>无变化。</em></p>
+
+<h4 id="DOM_事件">DOM 事件</h4>
+
+<ul>
+ <li>实现了 {{domxref("EventTarget.EventTarget()")}} 构造函数({{bug(1379688)}}).</li>
+</ul>
+
+<h4 id="多媒体_和_WebRTC">多媒体 和 WebRTC</h4>
+
+<p><em>无变化。</em></p>
+
+<h4 id="Canvas_和_WebGL">Canvas 和 WebGL</h4>
+
+<p><em>无变化。</em></p>
+
+<h3 id="HTTP">HTTP</h3>
+
+<p><em>无变化。</em></p>
+
+<h3 id="安全">安全</h3>
+
+<ul>
+ <li>顶部导航URI <code>data://</code> 已经被屏蔽了 {{bug(1401895)}}. 更多细节参见 <span><a href="https://www.fxsitecompat.com/en-CA/docs/2017/data-url-navigations-on-top-level-window-will-now-be-blocked/">Data URL navigations on top level window will now be blocked</a> 。</span></li>
+ <li>修改了 {{httpheader("X-Frame-Options")}} 报头的 <code>SAMEORIGIN</code> 指令,现在它不仅会检查顶级 IFrame 是否来自同一来源 , 也会检查它的祖先。 ({{bug(725490)}}).</li>
+</ul>
+
+<h3 id="插件">插件</h3>
+
+<p><em>无变化。</em></p>
+
+<h3 id="其他">其他</h3>
+
+<p><em>无变化。</em></p>
+
+<h2 id="Web平台的删减">Web平台的删减</h2>
+
+<h3 id="HTML_2">HTML</h3>
+
+<p><em>无变化。</em></p>
+
+<h3 id="CSS_2">CSS</h3>
+
+<p><em>无变化。</em></p>
+
+<h3 id="APIs_2">APIs</h3>
+
+<ul>
+ <li>不标准的方法 <code>Event.getPreventDefault()</code> 已经被移除了. 请使用 {{domxref("Event.defaultPrevented")}} 来决定在{{domxref("Event")}}中是否要调用{{domxref("Event.preventDefault", "preventDefault()")}} 。</li>
+ <li>专用属性 <code><a href="/en-US/docs/Archive/API/Navigator/mozNotification">Navigator.mozNotification</a></code> 和 <code>DesktopNotification</code> 接口已被移除 , 推荐使用标准的 <a href="/en-US/docs/Web/API/Notifications_API">Notifications API</a> ({{bug(952453)}}).</li>
+ <li>专用方法 <code>window.external.addSearchEngine()</code>已被移除  ({{bug("862147")}})。欲了解更多细节,参见 {{domxref("Window.sidebar")}} 。</li>
+</ul>
+
+<h3 id="SVG_2">SVG</h3>
+
+<p><em>无变化</em></p>
+
+<h2 id="Mozilla和附加组件开发者应该注意的变化">Mozilla和附加组件开发者应该注意的变化</h2>
+
+<h3 id="WebExtensions">WebExtensions</h3>
+
+<p><em>无变化</em></p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>Firefox 59 的站点兼容性</li>
+</ul>
+</article>
+
+<ul>
+</ul>
+
+<h2 id="历史版本">历史版本</h2>
+
+<p>{{Firefox_for_developers(58)}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/62/index.html b/files/zh-cn/mozilla/firefox/releases/62/index.html
new file mode 100644
index 0000000000..10a5c5423a
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/62/index.html
@@ -0,0 +1,187 @@
+---
+title: Firefox 62 for developers
+slug: Mozilla/Firefox/Releases/62
+translation_of: Mozilla/Firefox/Releases/62
+---
+<div>{{FirefoxSidebar}}</div><div>{{FirefoxSidebar}}</div>
+
+<div>{{draft}}</div>
+
+<p class="summary">This article provides information about the changes in Firefox 62 that will affect developers. Firefox 62 is the current <a href="https://www.mozilla.org/en-US/firefox/channel/desktop/#beta">Beta version of Firefox</a>, and will ship on <a href="https://wiki.mozilla.org/RapidRelease/Calendar#Future_branch_dates">September 5, 2018</a>.</p>
+
+<h2 id="Changes_for_web_developers">Changes for web developers</h2>
+
+<h3 id="Developer_tools">Developer tools</h3>
+
+<ul>
+ <li>You now have four options for the location of the Developer Tools. In addition to the default location on the bottom of the window, you can choose to locate the tools on either the left or right sides of the main window or in a separate window.</li>
+ <li>You can now split the Rules view out into its own pane, separate from the other tabs on the CSS pane. See <a href="/en-US/docs/Tools/Page_Inspector/3-pane_mode">Page inspector 3-pane mode</a> for more details.</li>
+ <li>The Grid inspector has updated features, and all new documentation — see <a href="/en-US/docs/Tools/Page_Inspector/How_to/Examine_grid_layouts">CSS Grid Inspector: Examine grid layouts</a>.</li>
+ <li>The <a href="/en-US/docs/Tools/Accessibility_inspector">Accessibility inspector</a> has had a couple of minor updates:
+ <ul>
+ <li>It no longer exposes the <code>help</code> property, which isn't properly implemented in Gecko ({{bug(1467643)}}).</li>
+ <li>The <code>keyboardShortcut</code> property now correctly exposes any keyboard shortcut available to activate the currently inspected node ({{bug(1467381)}}).</li>
+ </ul>
+ </li>
+</ul>
+
+<h3 id="HTML">HTML</h3>
+
+<p><em>没有变化。</em></p>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li><code>:-moz-selection</code> has been unprefixed ({{bug(509958)}}).</li>
+ <li><code>x</code> is now supported as a unit for the <code><a href="/en-US/docs/Web/CSS/resolution">&lt;resolution&gt;</a></code> type ({{bug(1460655)}}).</li>
+ <li><code><a href="/en-US/docs/Web/CSS/shape-margin">shape-margin</a></code>, <code><a href="/en-US/docs/Web/CSS/shape-outside">shape-outside</a></code>, and <code><a href="/en-US/docs/Web/CSS/shape-image-threshold">shape-image-threshold</a></code> are now enabled by default ({{bug(1457297)}}).</li>
+</ul>
+
+<h3 id="SVG">SVG</h3>
+
+<p><em>No changes.</em></p>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li>The {{jsxref("Array.prototype.flat()")}} and {{jsxref("Array.prototype.flatMap()")}} methods are now enabled by default ({{bug(1435813)}}).</li>
+ <li>The <code><a href="/en-US/docs/Web/JavaScript/Reference/Statements/import.meta">import.meta</a></code> property has been implemented to expose context-specific metadata to a JavaScript module ({{bug(1427610)}}).</li>
+ <li>JavaScript <a href="/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#String_literals">string literals</a> may now directly contain U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR.  As a consequence, {{jsxref("JSON")}} syntax is now a subset of JavaScript literal syntax (see {{bug(1435828)}} and the tc39 proposal <a href="https://github.com/tc39/proposal-json-superset">json-superset</a>).</li>
+ <li>For out-of-bounds <a href="/en-US/docs/Web/JavaScript/Typed_arrays">typed array</a> indexes, {{jsxref("Reflect.defineProperty()")}} and {{jsxref("Reflect.set()")}} will now return <code>false</code> instead of <code>true</code> ({{bug(1308735)}}).</li>
+</ul>
+
+<h3 id="APIs">APIs</h3>
+
+<h4 id="New_APIs">New APIs</h4>
+
+<ul>
+ <li>The <a href="/en-US/docs/Web/API/Web_Speech_API">Speech Synthesis API (Text-to-Speech)</a> is now enabled by default on Firefox for Android ({{bug(1463496)}}).</li>
+</ul>
+
+<h4 id="DOM">DOM</h4>
+
+<ul>
+ <li>The {{domxref("DOMPointReadOnly")}} interface now supports the static function {{domxref("DOMPointReadOnly.fromPoint()")}}, which creates a new point object from a dictionary that's compatible with {{domxref("DOMPointInit")}}. This function is also available on {{domxref("DOMPoint")}} ({{bug(1186265)}}).</li>
+ <li>Related to the previous item, the <code>DOMPoint</code> and <code>DOMPointReadOnly</code> constructors no longer support an input parameter of type <code>DOMPointInit</code>; the values of the properties must be specified using the <code>x</code>, <code>y</code>, <code>z</code>, and <code>w</code> parameters ({{bug(1186265)}}).</li>
+ <li>The {{domxref("URL.createObjectURL()")}} method no longer supports creating object URLs to represent a {{domxref("MediaStream")}}. This capability has been obsolete for some time now, since you can simply set {{domxref("HTMLMediaElement.srcObject")}} to the <code>MediaStream</code> directly now ({{bug(1454889)}}).</li>
+ <li>For compatibility purposes, the {{domxref("Event.srcElement")}} property is now supported. It is an alias for {{domxref("Event.target")}} ({{bug(453968)}}).</li>
+ <li>{{domxref("Navigator.registerProtocolHandler()")}} now must only be called from a secure context ({{bug(1460506)}}).</li>
+ <li>The {{domxref("Navigator.registerContentHandler()")}} method has been disabled by default in preparation for being removed entirely, as it's been obsolete for some time ({{bug(1460481)}}).</li>
+</ul>
+
+<h4 id="DOM_events">DOM events</h4>
+
+<p><em>No changes.</em></p>
+
+<h4 id="Service_workers">Service workers</h4>
+
+<p><em>No changes.</em></p>
+
+<h4 id="Media_Web_Audio_and_WebRTC">Media, Web Audio, and WebRTC</h4>
+
+<ul>
+ <li>The <code>"media.autoplay.enabled"</code> preference now controls automatic playback of both audio and video media, instead of just video media ({{bug(1413098)}}).</li>
+ <li>The {{domxref("ChannelSplitterNode")}} has been fixed to correctly default to having 6 channels with the <code>channelInterpretation</code> set to <code>"discrete"</code> and the <code>channelCountMode</code> set to <code>"explicit"</code> per the specification ({{bug(1456265)}}).</li>
+</ul>
+
+<h4 id="Canvas_and_WebGL">Canvas and WebGL</h4>
+
+<p><em>No changes.</em></p>
+
+<ul>
+</ul>
+
+<h3 id="CSSOM">CSSOM</h3>
+
+<ul>
+ <li>Support for <code><a href="/en-US/docs/Web/API/CSSStyleDeclaration/getPropertyCSSValue">CSSStyleDeclaration.getPropertyCSSValue()</a></code> has been removed ({{bug(1408301)}}).</li>
+ <li>Support for <code><a href="/en-US/docs/Web/API/CSSValue">CSSValue</a></code>, <code><a href="/en-US/docs/Web/API/CSSPrimitiveValue">CSSPrimitiveValue</a></code>, and <code><a href="/en-US/docs/Web/API/CSSValueList">CSSValueList</a></code> has been removed ({{bug()}}).</li>
+ <li><code><a href="/en-US/docs/Web/API/Window/getComputedStyle">window.getComputedStyle()</a></code> no longer returns <code>null</code> when called on a <code>Window</code> which has no presentation ({{bug(1467722)}}).</li>
+</ul>
+
+<h3 id="HTTP">HTTP</h3>
+
+<ul>
+ <li>The deprecated CSP {{CSP("referrer")}} directive has been removed. Please use the  {{HTTPHeader("Referrer-Policy")}} header instead ({{bug(1302449)}}).</li>
+</ul>
+
+<h3 id="Security">Security</h3>
+
+<p><em>No changes.</em></p>
+
+<h3 id="Plugins">Plugins</h3>
+
+<p><em>No changes.</em></p>
+
+<h3 id="Other">Other</h3>
+
+<p><em>No changes.</em></p>
+
+<h2 id="Removals_from_the_web_platform">Removals from the web platform</h2>
+
+<h3 id="HTML_2">HTML</h3>
+
+<p><em>No changes.</em></p>
+
+<h3 id="CSS_2">CSS</h3>
+
+<p><em>No changes.</em></p>
+
+<h3 id="APIs_2">APIs</h3>
+
+<p><em>No changes.</em></p>
+
+<h3 id="SVG_2">SVG</h3>
+
+<p><em>No changes.</em></p>
+
+<h3 id="Other_2">Other</h3>
+
+<p><em>No changes.</em></p>
+
+<h2 id="Changes_for_add-on_and_Mozilla_developers">Changes for add-on and Mozilla developers</h2>
+
+<h3 id="WebExtensions">WebExtensions</h3>
+
+<h4 id="API_changes">API changes</h4>
+
+<ul>
+ <li><code><a href="/en-US/Add-ons/WebExtensions/API/webRequest/getSecurityInfo">webRequest.getSecurityInfo()</a></code> API to examine details of TLS connections ({{bug(1322748)}}).</li>
+ <li><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserSettings/newTabPosition">browserSettings.newTabPosition</a></code> to customize where new tabs open ({{bug(1344749)}}).</li>
+ <li><code>windowTypes</code> has been deprecated in <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/windows/get">windows.get()</a></code>, <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/windows/getCurrent">windows.getCurrent()</a></code> and <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/windows/getLastFocused">windows.getLastFocused()</a></code> ({{bug(1419132)}}).</li>
+ <li>It's now possible to modify a browser action on a per-window basis ({{bug(1419893)}}).</li>
+</ul>
+
+<h4 id="Manifest_changes">Manifest changes</h4>
+
+<ul>
+ <li>New <code>open_at_install</code> property of the <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action">sidebar_action</a></code> manifest key enables extensions to control whether their sidebars should open automatically on install or not ({{bug(1460910)}}).</li>
+ <li>Changed to the <code>browser_style</code> property of various manifest keys:
+ <ul>
+ <li>in <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/page_action">page_action</a></code> and <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_action">browser_action</a></code> it defaults to false</li>
+ <li>in <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action">sidebar_action</a></code> and <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/options_ui">options_ui</a></code> it defaults to true.</li>
+ </ul>
+ </li>
+</ul>
+
+<h4 id="Theme_changes">Theme changes</h4>
+
+<ul>
+ <li>New <code>tab_background_separator</code> property of the <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/theme">theme</a></code> manifest key enables extensions to change the color of the tab separator.</li>
+</ul>
+
+<h4 id="Other_changes">Other changes</h4>
+
+<ul>
+ <li>Support for unpacked sideloaded extensions has been removed ({{bug(1385057)}}).</li>
+</ul>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>Site compatibility for Firefox 62</li>
+</ul>
+
+<h2 id="Older_versions">Older versions</h2>
+
+<p>{{Firefox_for_developers(61)}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/65/index.html b/files/zh-cn/mozilla/firefox/releases/65/index.html
new file mode 100644
index 0000000000..548193494e
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/65/index.html
@@ -0,0 +1,128 @@
+---
+title: Firefox 65 for developers
+slug: Mozilla/Firefox/Releases/65
+tags:
+ - '65'
+translation_of: Mozilla/Firefox/Releases/65
+---
+<div>{{FirefoxSidebar}}{{Draft}}</div>
+
+<p class="summary">本文提供了有关 Firefox 65 中将影响开发者的更改信息。 Firefox 65 是当前的 <a href="https://www.mozilla.org/en-US/firefox/channel/desktop/#beta" rel="noopener">Nightly 版本</a>, 将于2019年1月29日发布。</p>
+
+<h2 id="为网页开发者带来的改变">为网页开发者带来的改变</h2>
+
+<h3 id="开发者工具">开发者工具</h3>
+
+<h4 id="移除">移除</h4>
+
+<h3 id="HTML">HTML</h3>
+
+<p>事件现在可以在禁用状态下的 HTML 元素上进行分发,如设置了 <code>disabled</code> 属性的 {{htmlelement("button")}}, {{htmlelement("fieldset")}}, {{htmlelement("input")}}, {{htmlelement("select")}},和 {{htmlelement("textarea")}} ({{bug(329509)}})。</p>
+
+<h4 id="移除_2">移除</h4>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>已去除 {{cssxref("image-rendering")}} 属性的 <code>crisp-edges</code> 值的前缀({{bug(1496617)}}) 。</li>
+ <li>{{cssxref("scrollbar-color")}} 的 <code>auto</code> 值现在现在被解析为 <code>auto</code>,而不是两种颜色 ({{bug(1501418)}})。</li>
+</ul>
+
+<h4 id="移除_3">移除</h4>
+
+<ul>
+ <li><code>layout.css.shape-outside.enabled</code> 设置已被移除;{{cssxref("shape-outside")}}, {{cssxref("shape-margin")}},和 {{cssxref("shape-image-threshold")}} 不再支持关闭 ({{bug(1504387)}})。</li>
+ <li>
+ <div class="textpanel-target-textblock"><span class="text-dst">Firefox 用户</span>{{cssxref("user-select")}}<span class="text-dst">的几个仅限的属性已被删除-</span></div>
+   — <code>-moz-all</code>, <code>tri-state</code>, <code>element</code>, <code>elements</code>, 和 <code>toggle</code>. Firefox<span class="text-dst"> 仅限</span> <code>-moz-text</code> <span class="text-dst">属性仍在内部使用,故只是在Web内容中禁用</span> <span class="text-dst">参见</span> {{bug(1492958)}}.</li>
+</ul>
+
+<h3 id="SVG">SVG</h3>
+
+<p><em>无变化。</em></p>
+
+<h4 id="移除_4">移除</h4>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<h4 id="移除_5">移除</h4>
+
+<h3 id="APIs">APIs</h3>
+
+<p><em>无变化。</em></p>
+
+<h4 id="新的_APIs">新的 APIs</h4>
+
+<h4 id="DOM">DOM</h4>
+
+<ul>
+ <li>{{domxref("Performance.toJSON()")}} has been exposed to <a href="/en-US/docs/Web/API/Web_Workers_API">Web Workers</a> ({{bug(1504958)}}).</li>
+ <li>{{domxref("XMLHttpRequest")}} requests will now throw a <code>NetworkError</code> if the requested content type is a <code>Blob</code>, and the request method is not <code>GET</code> ({{bug(1502599)}}).</li>
+</ul>
+
+<h4 id="DOM_events">DOM events</h4>
+
+<ul>
+ <li>Going forward, only one {{domxref("Window.open()")}} call is allowed per event ({{bug(675574)}}).</li>
+</ul>
+
+<h4 id="Service_workers">Service workers</h4>
+
+<ul>
+ <li>The {{domxref("Response.redirect()")}} method now correctly throws a <code>TypeError</code> if a non-valid URL is specified as the first parameter ({{bug(1503276)}}).</li>
+ <li>The {{domxref("ServiceWorkerContainer.register()")}} and {{domxref("WorkerGlobalScope.importScripts()")}} (when used by a service worker) methods will now accept any files with a valid <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#JavaScript_types">JavaScript MIME type</a> ({{bug(1354577)}}).</li>
+</ul>
+
+<h4 id="Media_Web_Audio_和_WebRTC">Media, Web Audio, 和 WebRTC</h4>
+
+<ul>
+ <li>增加了对 <a href="/en-US/docs/Glossary/webp">WebP</a> Google压缩图像文件的支持 (<a class="external external-icon" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1294490" rel="noopener" title="FIXED: Implement WebP image support">bug 1294490</a>) 。</li>
+</ul>
+
+<h4 id="Canvas_和_WebGL">Canvas 和 WebGL</h4>
+
+<h4 id="移除_6">移除</h4>
+
+<ul>
+ <li><a href="/en-US/docs/Web/Guide/Events/Mutation_events">Mutation events</a> 在shadow trees上已经被禁用 ({{bug(1489858)}}).</li>
+ <li>The non-standard {{domxref("MediaStream")}} property <code>currentTime</code> has been removed ({{bug(1502927)}}).</li>
+ <li>The obsolete {{domxref("BasicCardRequest.supportedTypes")}} property is no longer supported by the Payment Request API; instead of requiring the web app or site to figure out what type of card is being used, it's now the server's job to deal with it ({{bug(1504032)}}).</li>
+</ul>
+
+<h3 id="安全">安全</h3>
+
+<p><em>无变化。</em></p>
+
+<h4 id="移除_7">移除</h4>
+
+<h3 id="插件">插件</h3>
+
+<p><em>无变化。</em></p>
+
+<h4 id="移除_8">移除</h4>
+
+<h3 id="其他">其他</h3>
+
+<p><em>无变化。</em></p>
+
+<h4 id="移除_9">移除</h4>
+
+<h2 id="为附加组件开发者带来的改变">为附加组件开发者带来的改变</h2>
+
+<h3 id="API_变化">API 变化</h3>
+
+<h4 id="移除_10">移除</h4>
+
+<h3 id="Manifest_变化">Manifest 变化</h3>
+
+<h4 id="移除_11">移除</h4>
+
+<h2 id="参阅">参阅</h2>
+
+<ul>
+ <li><a href="https://www.fxsitecompat.com/en-CA/versions/65/">Site compatibility for Firefox 65</a></li>
+</ul>
+
+<h2 id="更早期的版本">更早期的版本</h2>
+
+<p>{{Firefox_for_developers(65)}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/68/index.html b/files/zh-cn/mozilla/firefox/releases/68/index.html
new file mode 100644
index 0000000000..621bd205fb
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/68/index.html
@@ -0,0 +1,240 @@
+---
+title: 为开发者的 Firefox 68 文档
+slug: Mozilla/Firefox/Releases/68
+translation_of: Mozilla/Firefox/Releases/68
+---
+<p>{{FirefoxSidebar}}</p>
+
+<p class="summary">本篇文章将提供关于在Firefox 68版本中,会影响到开发人员的更新的信息。Firefox 68版本发布于2019年7月9日。</p>
+
+<h2 id="面向开发者的变更">面向开发者的变更</h2>
+
+<h3 id="开发者工具">开发者工具</h3>
+
+<h4 id="浏览器网页控制台">浏览器/网页控制台</h4>
+
+<ul>
+ <li>现在网页控制台会展现更多关于CSS警告的信息, 其中包括使用该规则的DOM元素的节点列表 ({{bug(1093953)}})。</li>
+ <li>您可以在网页控制台中使用常规的表达式来过滤内容({{bug(1441079)}})。</li>
+ <li>现在浏览器控制台允许您通过设置勾选或不勾选名为“显示内容消息”的复选框来显示或隐藏来自内容进程的消息({{bug(1260877)}})。</li>
+</ul>
+
+<h4 id="JavaScript_调试器">JavaScript 调试器</h4>
+
+<ul>
+ <li>您现在可以在调试器中通过点击 <kbd>Shift</kbd> + <kbd>Ctrl</kbd> + <kbd>F</kbd> (Windows or Linux) 或 <kbd>Shift</kbd> + <kbd>Cmd</kbd> + <kbd>F</kbd> (macOS)在当前项目的所有文件进行 <a href="/en-US/docs/Tools/Debugger/How_to/Search#Searching_in_all_files">搜索</a> ({{bug(1320325)}})。</li>
+</ul>
+
+<h4 id="网络监视器">网络监视器</h4>
+
+<ul>
+ <li>网络监视器的 <a href="/en-US/docs/Tools/Network_Monitor/request_list#Filtering_requests">请求列表(request list)</a> 现在允许您封锁特定的URL地址 ({{bug(1151368)}})。</li>
+ <li>您现在不需要通过编辑方法、URL、参数和页眉的方式,而是可以通过使用在内容目录的 <a href="/en-US/docs/Tools/Network_Monitor/request_list#Context_menu">“重新发送(Resend)”</a> 命令,来重新发送一个网络请求 ({{bug(1422014)}})。</li>
+ <li>网络监视器内容目录里的 <a href="https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor/request_details#Headers">“页眉(Headers)”</a> 标签现在允许您以JSON格式,复制全部或部分页眉信息到剪切板 ({{bug(1442249)}})。</li>
+</ul>
+
+<h4 id="页面查看器">页面查看器</h4>
+
+<ul>
+ <li>一个允许您切换任何打印媒体查询 (print media queries) 显示的按钮已被添加页面查看器的<a href="/en-US/docs/Tools/Page_Inspector/How_to/Examine_and_edit_CSS#Examine_CSS_rules"> “规则仪表盘(rules panel)”</a> ({{bug(1534984)}})。</li>
+ <li> <a href="/en-US/docs/Tools/Page_Inspector/How_to/Edit_fonts">“字体仪表盘(fonts panel)”</a> 现在已包括一个可以调整<code>字母间距</code>的滑条 ({{bug(1536237)}}).</li>
+ <li>一个警告标志会出现在包含无效值的、不被支持的CSS属性或规则, 以帮助您了解为何某个特定的风格没有被渲染 ({{bug(1306054)}})。</li>
+</ul>
+
+<h4 id="存储查看器">存储查看器</h4>
+
+<ul>
+ <li>您现在可以通过选中在存储查看器的项目并点击退格键来 <a href="/en-US/docs/Tools/Storage_Inspector#Local_storage_Session_storage">删除本地和对话期存储</a> 词目 ({{bug(1522893)}})。</li>
+</ul>
+
+<h4 id="其它">其它</h4>
+
+<ul>
+ <li><a href="/en-US/docs/Tools/Accessibility_inspector">访问性查看器</a> 现在包含了一个新的 “<em>检查问题(Check for issues</em>)” 的特性, 其中包括很多可以高亮显示您的网页的访问性问题的检查工具。第一个可用的检查是<em>对比 (contrast)</em>, 用于突出颜色对比问题。</li>
+ <li>在 <a href="/en-US/docs/Tools/about:debugging">about:debugging</a> 页面的控制内部拓展可视性(系统附加组件和隐藏拓展)的偏好已由 <code>devtools.aboutdebugging.showSystemAddons</code> 变为 <code>devtools.aboutdebugging.showHiddenAddons</code> ({{bug(1544372)}}).</li>
+ <li><a href="/en-US/docs/Tools/Responsive_Design_Mode">响应设计模式(Responsive design mode</a>)已被重新设计— <em>设备设置</em> 对话框 (device selection menu &gt; <em>Edit List...</em>) 现在使用起来更加直观简单 ({{bug(1487857)}})。</li>
+</ul>
+
+<h4 id="移除">移除</h4>
+
+<ul>
+ <li>"Enable add-on debugging" 复选框已从 <a href="/en-US/docs/Tools/about:debugging">about:debugging</a> 页面移除 ({{bug(1544813)}})。</li>
+</ul>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>如果文本轨迹包含媒体元素,那么{{HTMLElement("track")}} 元素 — 由 {{domxref("HTMLTrackElement")}} 展现— 现在会收到除了{{domxref("TextTrack")}} 它本身外,{{domxref("HTMLTrackElement.cuechange_event", "cuechange")}} 事件({{bug(1548731)}})。</li>
+ <li>尽管有不同的表现,{{htmlelement("link")}} 元素已重新支持 <code>disabled</code> 属性。 当 <code>disabled</code> 被设定在一个连同<code>rel="stylesheet"</code> 的 <code>&lt;link&gt;</code> 元素 , 引用的样式表不会在页面加载时被加载, 当 <code>disabled</code> 属性被改变为 <code>false</code> 或移除时,该样表会被加载 ({{bug(1281135)}})。</li>
+</ul>
+
+<h4 id="移除_2"> 移除</h4>
+
+<ul>
+ <li>不再支持 <code><a href="/en-US/docs/Web/HTML/Element/meta">&lt;meta http-equiv="set-cookie"&gt;</a></code>  ({{bug(1457503)}})。</li>
+</ul>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Scroll_Snap">CSS Scroll Snapping</a> has been updated to the latest version of the specification ({{bug(1312163)}}) and ({{bug(1544136)}}), this includes:
+
+ <ul>
+ <li>The <code>scroll-padding</code> properties ({{bug(1373832)}})</li>
+ <li>The <code>scroll-margin</code> properties ({{bug(1373833)}})</li>
+ <li>{{CSSxRef("scroll-snap-align")}} ({{bug(1373835)}})</li>
+ </ul>
+ </li>
+ <li>The {{CSSxRef("-webkit-line-clamp")}} property has been implemented for compatibility with other browsers ({{bug(866102)}}).</li>
+ <li>Support has been added for the {{CSSxRef("::marker")}} pseudo-element ({{bug(205202)}}) and animation for <code>::marker</code> pseudos ({{bug(1538618)}})</li>
+ <li>We changed {{CSSxRef("currentColor")}} to be a computed value (except for the {{cssxref("color")}} property)  ({{bug(760345)}}).</li>
+ <li>Support has been fixed for the <code>ch</code> length unit so it now matches the spec (fallback for no '0' glyph, vertical metrics) ({{bug(282126)}})</li>
+ <li>The  {{CSSxRef("counter-set")}} property has been implemented. ({{bug(1518201)}}).</li>
+ <li>We now implement list numbering using a built-in "list-item" counter; this fixes list numbering bugs ({{bug(288704)}}).</li>
+ <li>Selector matching and parsing support has been implemented for <code><a href="/en-US/docs/Web/CSS/::part">::part()</a></code> ({{bug(1545430)}}) and ({{bug(1545425)}}).</li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Transforms">CSS Transforms</a> are now supported in indirectly rendered things e.g.)  {{SVGElement("mask")}},  {{SVGElement("marker")}},  {{SVGElement("pattern")}},  {{SVGElement("clipPath")}} ({{bug(1323962)}}).</li>
+ <li>
+ <p>While we're keeping the prefixed versions of the various gradient properties ({{cssxref("linear-gradient")}}, {{cssxref("radial-gradient")}}, and {{cssxref("repeating-radial-gradient")}} available for compatibility reasons, we have revised how they're parsed so that they're handled much more like the non-prefixed versions. This means that certain existing styles won't work correctly.</p>
+
+ <p>In particular, the complicated syntax taking both an angle and a position will no longer work, and the <code>to</code> keyword in the <code>&lt;side-or-corner&gt;</code> parameter is not required for the prefixed gradient properties. You are encouraged to use the standard, non-prefixed gradient properties instead, as they're now widely supported ({{bug(1547939)}}).</p>
+ </li>
+</ul>
+
+<h4 id="Removals">Removals</h4>
+
+<ul>
+ <li>{{CSSxRef("scroll-snap-coordinate")}}, {{CSSxRef("scroll-snap-destination")}}, {{CSSxRef("scroll-snap-type-x")}} and {{CSSxRef("scroll-snap-type-y")}} have been removed.</li>
+ <li>The {{CSSxRef("scroll-snap-type")}} property has become a longhand, so the old shorthand syntax like <code>scroll-snap-type:mandatory</code> will stop working. See the <a href="https://www.fxsitecompat.com/en-CA/docs/2019/legacy-css-scroll-snap-syntax-support-has-been-dropped/">Firefox Site Compatability</a> note.</li>
+</ul>
+
+<h3 id="SVG">SVG</h3>
+
+<p><em>No changes.</em></p>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li>The new {{jsxref("BigInt")}} primitive is enabled by default ({{bug(1527902)}}).</li>
+ <li>String generic methods have been removed ({{bug(1222552)}}). See the <a href="/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_String_generics">deprecation warning</a> for more information.</li>
+</ul>
+
+<h3 id="APIs">APIs</h3>
+
+<h4 id="CSS_Object_Model_CSSOM">CSS Object Model (CSSOM)</h4>
+
+<ul>
+ <li>The legacy {{domxref("CSSStyleSheet.rules", "rules")}} property and {{domxref("CSSStyleSheet.addRule", "addRule()")}} and {{domxref("CSSStyleSheet.removeRule", "removeRule()")}} methods have been added to the {{domxref("CSSStyleSheet")}} interface. These were introduced by Internet Explorer 9 and have never managed to quite be stamped out, so they have been added to improve compatibility with the small percentage of sites that still use them ({{bug(1545823)}}).</li>
+</ul>
+
+<h4 id="DOM">DOM</h4>
+
+<ul>
+ <li>The <a href="/en-US/docs/Web/API/Visual_Viewport_API">Visual Viewport API</a> has now been enabled by default on Android ({{bug(1512813)}}). Adding this API to desktop versions of Firefox is being tracked in {{bug(1551302)}}.</li>
+ <li>The {{domxref("Window")}} feature <code><a href="/en-US/docs/Web/API/Window/open#noreferrer">noreferrer</a></code> is now supported; if specified, the new window's content is loaded without sharing the hostname, IP address, URL, or other identifying information about the host device ({{bug(1527287)}}).</li>
+ <li>The {{domxref("HTMLImageElement.decode", "decode()")}} method on <code>HTMLImageElement</code> is now implemented. This can be used to trigger loading and decoding of an image prior to adding it to the DOM ({{bug(1501794)}}).</li>
+ <li>{{domxref("XMLHttpRequest")}} has been updated to no longer accept the non-standard <code>moz-chunked-arraybuffer</code> value for {{domxref("XMLHttpRequest.responseType", "responseType")}}. Code still using it should be updated to <a href="/en-US/docs/Web/API/Streams_API/Using_readable_streams#Consuming_a_fetch_as_a_stream">use the Fetch API as a stream</a> ({{bug(1120171)}}).</li>
+ <li><code>XMLHttpRequest</code> now outputs a warning to console if you perform a synchronous request while handling an {{domxref("Window.unload_event", "unload")}}, {{domxref("Window.beforeunload_event", "beforeunload")}}, or {{domxref("Window.pagehide_event", "pagehide")}} event ({{bug(980902)}}).</li>
+ <li>The {{domxref("Document.cookie", "cookie")}} property has moved from the {{domxref("HTMLDocument")}} interface to the {{domxref("Document")}} interface, allowing documents other than {{Glossary("HTML")}} to use cookies ({{bug(144795)}}).</li>
+ <li>The {{domxref("HTMLElement.focus()")}} and {{domxref("SVGElement.focus()")}} methods now accept an optional object that may contain a boolean <code>preventScroll</code> option specifying whether or not to block the browser from scrolling the newly-focused element into view ({{bug(1374045)}}).</li>
+</ul>
+
+<h4 id="DOM_events">DOM events</h4>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/Firefox_for_Android">Firefox for Android</a> no longer incorrectly sends a {{domxref("Window.resize_event", "resize")}} event until after the first frame is painted; this improves web compatibility with sites that don't expect this event to occur ({{bug(1528052)}}).</li>
+ <li>The dispatching of events for non-primary mouse buttons has been made to more closely follow the specification; the {{domxref("Element.click_event", "click")}} event is no longer sent when non-primary buttons are clicked, instead using {{domxref("Element.auxclick_event", "auxclick")}}. In addition, {{domxref("Element.dblclick_event", "dblclick")}} no longer fires for non-primary buttons ({{bug(1379466)}}).</li>
+ <li>The proprietary {{domxref("MouseEvent.mozPressure")}} property has been deprecated, and will now trigger a warning in the console ({{bug(1165211)}}).</li>
+</ul>
+
+<h4 id="Media_Web_Audio_and_WebRTC">Media, Web Audio, and WebRTC</h4>
+
+<ul>
+ <li>Due to changes in the Google Play store's policies, starting with Firefox 68 for Android, the OpenH264 codec used to handle AVC/H.264 video in WebRTC connections can no longer be downloaded and installed. Therefore, fresh installs of Firefox on Android devices no longer support AVC in WebRTC calls. If you upgrade from earlier versions of Firefox and already have the codec downloaded, it will continue to work. This does <em>not</em> affect other platforms. For more details, see <a href="https://support.mozilla.org/en-US/kb/firefox-android-openh264">this article on SUMO</a> or {{bug(1548679)}}.</li>
+ <li>WebRTC has been updated to recognize that a <code>null</code> candidate passed into the {{domxref("RTCPeerConnection.icecandidate", "icecandidate")}} event handler, indicating the receipt of a candidate, instead indicates that there are no further candidates coming; when this happens the ICE gathering ({{domxref("RTCPeerConnection.iceGatheringState", "iceGatheringState")}}) state reaches <code>complete</code> ({{bug(1318167)}}).</li>
+ <li>The {{domxref("RTCRtpReceiver")}} methods {{domxref("RTCRtpReceiver.getContributingSources", "getContributingSources()")}} and {{domxref("RTCRtpReceiver.getSynchronizationSources", "getSynchronizationSources()")}} now support video tracks; previously they only worked on audio ({{bug(1534466)}}).</li>
+ <li>The Web Audio API {{domxref("MediaStreamTrackAudioSourceNode")}} interface is now supported, as is the method {{domxref("AudioContext.createMediaStreamTrackSource()")}} ({{bug(1324548)}}).</li>
+ <li>{{domxref("RTCDataChannel.negotiated")}} is now implemented ({{bug(1529695)}}).</li>
+ <li>The {{domxref("MediaStreamAudioSourceNode.MediaStreamAudioSourceNode", "MediaStreamAudioSourceNode()")}} constructor has been updated to match the current specification's definition that the "first audio track" in the stream is the track whose ID comes first in lexicographical order ({{bug(1324548)}}).</li>
+ <li>
+ <p>{{domxref("MediaDevices.getUserMedia", "getUserMedia()")}} may no longer be used from a non-secure context; attempting to do so now throws a <code>NotAllowedError</code> exception. Secure contexts are those loaded using HTTPS, those located using the <code>file:///</code> scheme, and those loaded from <code>localhost</code>. For now, if you must, you can re-enable the ability to perform insecure calls to <code>getUserMedia()</code> by setting the preference <code>media.getusermedia.insecure.enabled</code> to <code>true</code> ({{bug(1335740)}}).</p>
+
+ <div class="blockIndicator note">
+ <p><strong>Note:</strong> In the future, Firefox will also remove the {{domxref("navigator.mediaDevices")}} property on insecure contexts, preventing all access to the {{domxref("MediaDevices")}} APIs. <strong>This is already the case in Nightly builds.</strong></p>
+ </div>
+ </li>
+</ul>
+
+<h4 id="Removals_2">Removals</h4>
+
+<ul>
+ <li>Removed the non-standard {{DOMxRef("XMLDocument.load()")}} method ({{bug(332175)}}).</li>
+ <li>Removed the non-standard {{DOMxRef("XMLDocument.async")}} property ({{bug(1328138)}}).</li>
+ <li>The {{domxref("RTCIceCredentialType")}} <code>token</code> value has been removed ({{bug(1529595)}}).</li>
+</ul>
+
+<h3 id="HTTP">HTTP</h3>
+
+<ul>
+ <li>The <a href="/en-US/docs/Web/HTTP">HTTP</a> {{HTTPHeader("Clear-Site-Data")}} header no longer supports the <code>executionContexts</code> directive. This was removed due to problems with interactions between interconnections among different kinds of data at different points in the navigation process and the way the specification is designed. It <a href="https://github.com/w3c/webappsec-clear-site-data/issues/59">has been proposed</a> that this directive be removed from the specification for this reason, among others ({{bug(1548034)}}).</li>
+</ul>
+
+<h4 id="Removals_3">Removals</h4>
+
+<ul>
+ <li>The {{HTTPHeader("Content-Security-Policy")}} directive <code>require-sri-for</code> is no longer supported due to concerns about its standardization status. It was previously available only behind a preference, which was off by default ({{bug(1386214)}}).</li>
+</ul>
+
+<h3 id="Security">Security</h3>
+
+<ul>
+ <li>Due to <a href="https://www.mozilla.org/en-US/security/advisories/mfsa2019-21/#CVE-2019-11730">CVE-2019-11730: Same-origin policy treats all files in a directory as having the same-origin</a>, changes have been made so that Firefox now treats files in the same directory as being from different origins. This has a number of side-effects on what will work in documents loaded via file:// URLs (see {{bug("file-fallout")}} for useful background research). For example, workers can no longer be loaded.</li>
+</ul>
+
+<h3 id="WebDriver_conformance_Marionette">WebDriver conformance (Marionette)</h3>
+
+<h4 id="Bug_fixes">Bug fixes</h4>
+
+<ul>
+ <li>If <code>WebDriver:SwitchToWindow</code> changes the selection to a different window it now waits for its <code>focus</code> and <code>activate</code> events before returning ({{bug(1335085)}}).</li>
+ <li>Fixed the <code>TypeError: this.tabModal is null</code> failure, which sometimes appeared when interacting with modal dialogs or user prompts ({{bug(1538782)}})</li>
+</ul>
+
+<h4 id="Other">Other</h4>
+
+<ul>
+ <li>Disabled the feature to force unloading background tabs on low memory conditions, to prevent top-level browser contexts from magically disappearing ({{bug(1553748)}}).</li>
+ <li>Disabled priviledged content processes that caused HTTP authentication dialogs not to appear when navigating to a website after opening a new tab ({{bug(1558763)}}).</li>
+</ul>
+
+<h3 id="Plugins">Plugins</h3>
+
+<p><em>No changes.</em></p>
+
+<h2 id="Changes_for_add-on_developers">Changes for add-on developers</h2>
+
+<h3 id="API_changes">API changes</h3>
+
+<ul>
+ <li>The The <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/proxy/register">proxy.register()</a></code> and <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/proxy/unregister">proxy.unregister()</a></code> functions have been deprecated and will be removed from Firefox 71 ({{bug(1545811)}}).</li>
+ <li>A <code>boolean</code> flag, <code>incognito</code>, has been added to the <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/proxy/RequestDetails">proxy.RequestDetails</a>. object. When <code>true</code>, it indicates that this was a private browsing request ({{bug(1545163)}}).</li>
+ <li>The <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/RequestFilter">webRequest.RequestFilter</a> parameters can include an incognito parameter. If provided, requests that do not match the incognito state (<code>true</code> or <code>false</code>) will be filtered out ({{bug(1548177)}}).</li>
+ <li>A <code>string</code> value, <code>cookieStoreId</code>, representing the cookie store ID of the current context, has been added to the <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/proxy/RequestDetails">proxy.RequestDetails</a>. object ({{bug(1545420)}}).</li>
+ <li>When an add-on attempts to add a bookmark folder to the root folder, the resulting error message is now much more intuitive ({{bug(1512171)}}).</li>
+ <li>The promise returned by <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/duplicate">browser.tabs.duplicate()</a></code> now resolves immediately, before the tabs are completely loaded ({{bug(1394376)}}).</li>
+ <li>Support has been added for chrome.storage.managed, allowing web extension settings to be implemented via enterprise policy ({{bug(1230802)}}).</li>
+ <li>There is now a Group Policy option to blacklist <em>all</em> extensions except the ones that have been whitelisted ({{bug(1522823)}}).</li>
+</ul>
+
+<h3 id="显著变更">显著变更</h3>
+
+<p><em>无变更。</em></p>
+
+<h2 id="还可以看看">还可以看看</h2>
+
+<ul>
+ <li><a href="https://www.fxsitecompat.com/en-CA/versions/68/">Site compatibility for Firefox 68</a></li>
+</ul>
+
+<h2 id="更早的版本">更早的版本</h2>
+
+<p>{{Firefox_for_developers(67)}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/69/index.html b/files/zh-cn/mozilla/firefox/releases/69/index.html
new file mode 100644
index 0000000000..88f1c741aa
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/69/index.html
@@ -0,0 +1,185 @@
+---
+title: 面向开发者的Firefox 69
+slug: Mozilla/Firefox/Releases/69
+translation_of: Mozilla/Firefox/Releases/69
+---
+<p>{{FirefoxSidebar}}</p>
+
+<p class="summary">这篇文章将会围绕Firefox 69对于开发者产生的影响展开。</p>
+
+<p class="summary">Firefox 69 发布于2019年9月3日。</p>
+
+<h2 id="对于web开发者的变化">对于web开发者的变化</h2>
+
+<h3 id="开发者工具">开发者工具</h3>
+
+<h4 id="Debugger调试器">Debugger(调试器)</h4>
+
+<ul>
+ <li><a href="/en-US/docs/Tools/Debugger/Set_event_listener_breakpoints">Event Listener Breakpoints(事件监听断点)</a> 让你诊断中的代码执行的页面响应浏览器事件。你可以选择特殊的类型,比如 <code>click(点击)</code> 或者 <code>keydown(按下键盘)</code>, 亦或所有类型的事件,诸如所有的鼠标输入事件。 ({{bug(1526082)}}).</li>
+ <li>调试其中的  <a href="https://developer.mozilla.org/en-US/docs/Tools/Debugger/UI_Tour#Source_list_pane">源列表窗格</a> 所显示的脚本可以通过 <em>Download file(下载文件)</em> 内容菜单选项来完成保存。 ({{bug(888161)}}).</li>
+ <li>在调试期的源列表窗格中,被加载的扩展会根据他们的名字被逐一罗列出来,而非是他们的UUID {bug(1486416)}}),使它更为容易地找你你要调试的扩展代码</li>
+ <li>通过延迟加载脚本,调试器的加载速率得到了明显地改善{{bug(1527488)}}).</li>
+</ul>
+
+<h4 id="Console控制台">Console(控制台)</h4>
+
+<ul>
+ <li><a href="/en-US/docs/Tools/Browser_Console">浏览器控制台</a> 的消息来自于 <a href="/en-US/docs/Mozilla/Firefox/Privacy/Tracking_Protection">tracking protection errors(跟踪保护错误)</a>, <a href="/en-US/docs/Web/HTTP/CSP">CSP errors( ContentSecurityPolicy 内容安全策略错误 )</a>, and <a href="/en-US/docs/Web/HTTP/CORS/Errors">CORS errors( CrossOriginResourceShring 跨域资源共享错误 )</a> 他们会被自动分组以此可以减少来自重复的阻塞资源和存储访问的警告。 ({{bug(1522396)}}).</li>
+ <li>所有在控制台可见的日志都可以通过<strong>内容菜单列表(鼠标右击可见)</strong>被保存成一份文件或者复制到剪贴板后经由新的<em>消息可视化界面</em> (复制到文本编辑器查看)。({{bug(1517728)}}).</li>
+ <li>控制栏的高度现在调整到了在垂直方向上一行就可以完成。({{bug(972530)}}).</li>
+ <li>我们可以在控制台隐藏来自内容的消息以便更多的关注Firefox的用户界面日志({{bug(1523842)}}).</li>
+</ul>
+
+<h4 id="Network网络">Network(网络)</h4>
+
+<ul>
+ <li>由于<a href="/en-US/docs/Web/HTTP/CSP">CSP</a> 或者 <a href="/en-US/docs/Web/Security/Mixed_content">Mixed Content</a> 所阻塞的资源现在可以在<strong>网络面板</strong>上得到显示,并且对其缘由有着细节展示。 ({{bug(1556451)}}).</li>
+ <li>在<strong>网络面板</strong>上,一个新的且可选择的<em>URL</em>栏能够为我们展示你资源所有的全部的URL ({{bug(1341155)}}).</li>
+</ul>
+
+<h4 id="Inspector查看器">Inspector(查看器)</h4>
+
+<ul>
+ <li>当你的光标悬停在<a href="/en-US/docs/Tools/Page_Inspector">页面选择器</a>中的某个元素,现在信息栏将会显示这个元素是一个弹性容器还是一个弹性项目的事实。 ({{bug(1521188)}}).</li>
+</ul>
+
+<h4 id="Remote_debugging远程调试">Remote debugging(远程调试)</h4>
+
+<ul>
+ <li>对于我们的移动端web开发者,我们已经将远程调试从旧的WebIDE迁移到了重新设计的 <a href="/en-US/docs/Tools/about:debugging">about:debugging</a>上, 这样会使得通过USB调试远程设备上的 <a href="https://hacks.mozilla.org/2019/06/geckoview-in-2019/">GeckoView</a> 的体验得到改善。 ({{bug(1462208)}}).</li>
+</ul>
+
+<h4 id="General日常">General(日常)</h4>
+
+<ul>
+ <li>开发工具的面板布局已经为了迎合流行元素而做出了改动。{{bug(1558630)}}).</li>
+</ul>
+
+<h3 id="HTML">HTML</h3>
+
+<ul>
+ <li>In order to align more closely to the specification, the text track associated with a {{HTMLElement("track")}} element no longer loads the WebVTT file containing the text cues if the element is created in its default <code>disabled</code> {{domxref("TextTrack.mode", "mode")}}. To access or manipulate the cues when the <code>mode</code> is <code>disabled</code>, change the <code>mode</code> to either <code>started</code> or <code>hidden</code>; this will trigger loading of the WebVTT data ({{bug(1550633)}}).</li>
+</ul>
+
+<h4 id="Removals"> Removals</h4>
+
+<ul>
+ <li>The HTML {{HTMLElement("keygen")}} element has been removed from Firefox. It was deprecated some time ago, and its purpose has generally been supplanted by other technologies ({{bug(1315460)}}).</li>
+</ul>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>We implemented the <code>break-spaces</code> value of the {{cssxref("white-space")}} property ({{bug(1351432)}}).</li>
+ <li>The SVG geometry attributes (such as {{SVGAttr("width")}} and {{SVGAttr("height")}}) can now also be defined as CSS properties ({{bug(1383650)}}).</li>
+ <li>The {{cssxref("::cue")}} selector — used to style the captions ("cues") displayed by <a href="/en-US/docs/Web/API/WebVTT_API">WebVTT</a> — now enforces the limitations on which CSS properties may be used within cues, as per the specification ({{bug(1321488)}}).</li>
+ <li>We've restricted the properties that may apply to {{cssxref("::marker")}} as per the specification ({{bug(1552578)}})</li>
+ <li>The {{cssxref("overflow-block")}} and {{cssxref("overflow-inline")}} properties have been implemented ({{bug(1470695)}}).</li>
+ <li>We added the ability to test for support of a selector when using CSS Feature Queries ({{cssxref("@supports")}}), with the <code>selector()</code> method ({{bug(1513643)}}).</li>
+ <li>The {{cssxref("user-select")}} property — which specifies whether or not the user is able to select text in the affected element — has been unprefixed ({{bug(1492739)}}).</li>
+ <li>We implemented local-specific casing behavior for Lithuanian ({{bug(1322992)}}), <a href="/en-US/docs/Web/CSS/text-transform#lowercase_lithuanian">as seen in this example</a>.</li>
+ <li>We've implemented the {{cssxref("line-break")}} property of CSS Text ({{bug(1011369)}} and {{bug(1531715)}}).</li>
+ <li>The {{cssxref("contain")}} property — which allows developers to define that an element and its contents are mostly independent of the rest of the DOM tree — got implemented {{bug(1487493)}}.</li>
+</ul>
+
+<h3 id="SVG">SVG</h3>
+
+<ul>
+ <li>We've added support for gzip-compressed SVG-in-OpenType ({{bug(1359240)}}).</li>
+ <li>The {{domxref("SVGGeometryElement.isPointInFill()")}} and {{domxref("SVGGeometryElement.isPointInStroke()")}} methods have been implemented ({{bug(1325319)}}).</li>
+</ul>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li><a href="/en-US/docs/Web/JavaScript/Reference/Classes#Field_declarations">Public class fields</a> are enabled by default ({{bug(1555464)}}). See also <a href="/en-US/docs/Web/JavaScript/Reference/Classes/Class_fields">Class fields</a> for more information.</li>
+ <li>The promise rejection events <code><a href="/en-US/docs/Web/API/Window/unhandledrejection_event">unhandledrejection</a></code> and <code><a href="/en-US/docs/Web/API/Window/rejectionhandled_event">rejectionhandled</a></code> are now enabled by default ({{bug(1362272)}}). To learn more about how these work, see {{SectionOnPage("/en-US/docs/Web/JavaScript/Guide/Using_promises", "Promise rejection events")}}.</li>
+</ul>
+
+<h3 id="HTTP">HTTP</h3>
+
+<ul>
+ <li>The HTTP headers {{HTTPHeader("Access-Control-Expose-Headers")}}, {{HTTPHeader("Access-Control-Allow-Methods")}}, and {{HTTPHeader("Access-Control-Allow-Headers")}} now accept a wildcard value "<code>*</code>" for requests without credentials ({{bug(1309358)}}). This change has also been uplifted to Firefox 68 ESR.</li>
+</ul>
+
+<h3 id="APIs">APIs</h3>
+
+<h4 id="New_APIs">New APIs</h4>
+
+<ul>
+ <li>The <a href="/en-US/docs/Web/API/Resize_Observer_API">Resize Observer API</a> is supported by default ({{bug(1543839)}}).</li>
+ <li>The Microtask API ({{domxref("WindowOrWorkerGlobalScope.queueMicrotask()")}}) has been implemented ({{bug(1480236)}}).</li>
+</ul>
+
+<h4 id="DOM">DOM</h4>
+
+<ul>
+ <li>The {{domxref("DOMMatrix")}}, {{domxref("DOMPoint")}}, and related objects are now supported in workers ({{bug(1420580)}}).</li>
+ <li>The <code>pageX</code> and <code>pageY</code> properties have been moved from {{domxref("UIEvent")}} to {{domxref("MouseEvent")}}, for better spec compliance ({{bug(1178763)}}). These properties are no longer exposed to the {{domxref("CompositionEvent")}}, {{domxref("FocusEvent")}}, {{domxref("InputEvent")}}, {{domxref("KeyboardEvent")}}, and {{domxref("TouchEvent")}} interfaces, which all inherit from <code>UIEvent</code>.</li>
+ <li>The {{domxref("Blob.text()")}}, {{domxref("Blob.arrayBuffer()")}}, and {{domxref("Blob.stream()")}} methods are now implemented ({{bug(1557121)}}).</li>
+ <li>{{domxref("DOMMatrix.fromMatrix()")}} has been implemented ({{bug(1560462)}}).</li>
+ <li>We now support the six-parameter version of the {{domxref("DOMMatrix.scale()")}} method ({{bug(1397945)}}).</li>
+ <li>The arguments for {{domxref("DOMMatrix.translate()")}}, {{domxref("DOMMatrix.skewX()")}}, and {{domxref("DOMMatrix.skewY()")}} are now all optional, as per spec ({{bug(1397949)}}).</li>
+ <li>The {{domxref("navigator.userAgent")}}, {{domxref("navigator.platform")}}, and {{domxref("navigator.oscpu")}} properties no longer reveal whether a user is running 32-bit Firefox on a 64-bit OS ({{bug(1559747)}}). They now say <code>Linux x86_64</code> instead of <code>Linux i686 on x86_64</code>, and <code>Win64</code> instead of <code>WOW64</code>.</li>
+ <li>The remaining methods of {{domxref("HTMLDocument")}} have been moved to {{domxref("Document")}}. This should have no appreciable impact on your work in most cases. In particular, the {{domxref("document.close", "close()")}}, {{domxref("document.open", "open()")}}, and {{domxref("document.write", "write()")}} methods have been moved. So have the various editor related methods, including {{domxref("document.execCommand", "execCommand()")}} as well as various properties ({{bug(1549560)}}).</li>
+ <li>
+ <p>We have implemented {{domxref("AbstractRange")}} and {{domxref("StaticRange")}} ({{bug(1444847)}}).</p>
+ </li>
+</ul>
+
+<h4 id="Media_Web_Audio_and_WebRTC">Media, Web Audio, and WebRTC</h4>
+
+<ul>
+ <li>For improved user security, and in-keeping with the latest versions of the <a href="/en-US/docs/Web/API/Media_Streams_API">Media Capture and Streams</a> specification, the {{domxref("navigator.mediaDevices")}} property is no longer present if the context is insecure. To use {{domxref("MediaDevices.getUserMedia", "getUserMedia()")}}, {{domxref("MediaDevices.getDisplayMedia", "getDisplayMedia()")}}, {{domxref("MediaDevices.enumerateDevices", "enumerateDevices()")}}, and so forth, be sure your content is loaded using {{Glossary("HTTPS")}} ({{bug(1528031)}}).</li>
+ <li>The Web Audio API's {{domxref("AudioParam.value")}} property now returns the actual value of the property at the current time, taking into account all scheduled or gradiated value changes. Previously, Firefox only returned the most recent explicitly-set value (as through using the <code>value</code> setter) ({{bug(893020)}}).</li>
+ <li>We've updated {{domxref("MediaStreamAudioSourceNode")}} to use the new, lexicographical, ordering for tracks. Previously, track ordering was up to the individual browser, and could even change arbitrarily. In addition, attempting to create a <code>MediaStreamAudioSourceNode</code> using a stream that has no audio tracks now throws an <code>InvalidStateError</code> exception ({{bug(1553215)}}).</li>
+ <li>The {{domxref("MediaTrackSettings.facingMode", "facingMode")}}, {{domxref("MediaTrackSettings.deviceId", "deviceId")}}, and {{domxref("MediaTrackSettings.groupId", "groupId")}} settings are now included as members of the {{domxref("MediaTrackSettings")}} object returned by calls to {{domxref("MediaStreamTrack.getSettings()")}} ({{bug(1537986)}}).</li>
+</ul>
+
+<h4 id="Removals_2">Removals</h4>
+
+<ul>
+ <li>The {{domxref("DOMMatrix.scaleNonUniformSelf()")}} method has been removed ({{bug(1560119)}}).</li>
+</ul>
+
+<h3 id="WebDriver_conformance_Marionette">WebDriver conformance (Marionette)</h3>
+
+<h4 id="Other">Other</h4>
+
+<ul>
+ <li>
+ <p>Marionette now dynamically handles the opening and closing of modal dialogs and user prompts ({{bug(1477977)}}), which also means that multiple open prompts will be handled ({{bug(1487358)}}).</p>
+ </li>
+ <li>
+ <p>Tracking protection and DOM push features are now disabled by default to avoid the removal of parts of the DOM, and extra notifications ({{bug(1542244)}}).</p>
+ </li>
+ <li>
+ <p>Automatic unloading of background tabs if Firefox runs into a low memory condition is now disabled — this badly interacts with automation when switching between tabs ({{bug(1553748)}}).</p>
+ </li>
+</ul>
+
+<h2 id="Changes_for_add-on_developers">Changes for add-on developers</h2>
+
+<h3 id="API_changes">API changes</h3>
+
+<ul>
+ <li>The <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/userScripts">UserScripts API</a> is now enabled by default.</li>
+ <li>The <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/topSites/get">topSites.get()</a></code> method now has new options available — <code>includePinned</code> and <code>includeSearchShortcuts</code> ({{bug(1547669)}}).</li>
+</ul>
+
+<h3 id="Other_changes">Other changes</h3>
+
+<ul>
+ <li>There are now <a href="https://github.com/mozilla/policy-templates/blob/master/README.md#extensionsettings">Group Policy options</a> to blacklist all extensions except the ones that have been whitelisted ({{bug(1522823)}}).</li>
+</ul>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="https://www.fxsitecompat.com/en-CA/versions/69/">Site compatibility for Firefox 69</a></li>
+</ul>
+
+<h2 id="Older_versions">Older versions</h2>
+
+<p>{{Firefox_for_developers(68)}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/78/index.html b/files/zh-cn/mozilla/firefox/releases/78/index.html
new file mode 100644
index 0000000000..1c28b03a7a
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/78/index.html
@@ -0,0 +1,116 @@
+---
+title: 对于开发人员的Firefox 78
+slug: Mozilla/Firefox/Releases/78
+translation_of: Mozilla/Firefox/Releases/78
+---
+<p>{{FirefoxSidebar}}</p>
+
+<p class="summary">本文提供了有关Firefox 78中将影响开发人员的更改的信息。 Firefox 78发布于<a href="https://wiki.mozilla.org/RapidRelease/Calendar#Future_branch_dates/docs/">2020年6月30日</a>.</p>
+
+<p class="summary">另请参阅Firefox 78中的新增功能:<a href="https://hacks.mozilla.org/2020/06/new-in-firefox-78/">DevTools的改进,新的正则表达式引擎以及Mozilla hacks上大量的Web平台更新。</a></p>
+
+<h2 id="对于Web开发人员的更改">对于Web开发人员的更改</h2>
+
+<h3 id="开发者工具">开发者工具</h3>
+
+<h4 id="调试器">调试器</h4>
+
+<ul>
+ <li><span class="tlid-translation translation" lang="zh-CN"><span title="">现在,您可以从</span></span><a href="/en-US/docs/Tools/about:debugging#Connecting_to_a_remote_device">关于:调试</a><span class="tlid-translation translation" lang="zh-CN"><span title="">面板更改远程设备访问的URL。</span></span>({{bug("1617237")}})</li>
+ <li><span class="tlid-translation translation" lang="zh-CN"><span title="">现在,<a href="/en-US/docs/Tools/Debugger/UI_Tour">调试器</a>中的</span></span> <strong>禁用JavaScript</strong> <span class="tlid-translation translation" lang="zh-CN"><span title="">菜单项仅影响当前选项卡</span></span>,<span class="tlid-translation translation" lang="zh-CN"><span title="">并且在关闭“开发人员工具”后会重置。</span></span>({{bug("1640318")}})</li>
+ <li>如果在<a href="/en-US/docs/Tools/Debugger/UI_Tour#Scopes">作用域</a>中启用<strong>映射</strong>,则<a href="/en-US/docs/Tools/Debugger/Set_a_logpoint">日志点</a>可以将源映射代码中的变量名称映射回其原始名称。({{bug("1536857")}})</li>
+</ul>
+
+<h4 id="网络监控器">网络监控器</h4>
+
+<ul>
+ <li>In the <a href="/en-US/docs/Tools/Network_Monitor/request_list#Network_request_columns">Network Monitor</a>, you can now resize the columns of the request list by dragging the column borders anywhere in the table. ({{bug("1618409")}})</li>
+ <li>The <a href="/en-US/docs/Tools/Network_Monitor/request_details">request details panel</a> in the Network Monitor has some UX improvements. ({{bug("1631302")}}, {{bug("1631295")}})</li>
+ <li>If a request was blocked, the <a href="/en-US/docs/Tools/Network_Monitor/request_list">request list</a> now shows the reason, such as an add-on, CSP, CORS, or Enhanced Tracking Protection. ({{bug("1555057")}}, {{bug("1445637")}}, {{bug("1556451")}})</li>
+</ul>
+
+<h4 id="其他工具">其他工具</h4>
+
+<ul>
+ <li>The <a href="/en-US/docs/Tools/Accessibility_inspector">Accessibility</a> inspector is out of beta. You can use it to check for various accessibility issues on your site. ({{bug("1602075")}})</li>
+ <li>Uncaught promise errors now provide all details in the Console, including their name and stack. ({{bug("1636590")}})</li>
+</ul>
+
+<h3 id="CSS">CSS</h3>
+
+<ul>
+ <li>The {{CSSxRef(":is", ":is()")}} and {{CSSxRef(":where", ":where()")}} pseudo-classes are now enabled by default ({{bug(1632646)}}).</li>
+ <li>The {{CSSxRef(":read-only")}} and {{CSSxRef(":read-write")}} pseudo-classes are now supported without prefixes ({{bug(312971)}}).
+ <ul>
+ <li>In addition, <code>:read-write</code> styles are no longer applied to disabled <code><a href="/en-US/docs/Web/HTML/Element/input">&lt;input&gt;</a></code> and <code><a href="/en-US/docs/Web/HTML/Element/textarea">&lt;textarea&gt;</a></code> elements, which was a violation of <a href="https://html.spec.whatwg.org/#selector-read-write">the HTML spec</a> ({{bug(888884)}}).</li>
+ </ul>
+ </li>
+</ul>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<ul>
+ <li>The <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat">Intl.ListFormat</a></code> API is now supported ({{bug(1589095)}}).</li>
+ <li>The <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat">Intl.NumberFormat()</a></code> constructor has been extended to support new options specified in the <a href="https://github.com/tc39/proposal-unified-intl-numberformat">Intl.NumberFormat Unified API Proposal</a> ({{bug(1633836)}}). This includes among other things:
+ <ul>
+ <li><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#Scientific_engineering_or_compact_notations">Support for scientific notations</a></li>
+ <li><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#Unit_formatting">Unit</a>, <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#Currency_formatting">currency</a> and <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#Displaying_signs">sign display</a> formatting</li>
+ </ul>
+ </li>
+ <li>The {{JSxRef("RegExp")}} engine <a href="https://hacks.mozilla.org/2020/06/a-new-regexp-engine-in-spidermonkey/">has been updated</a> and now supports all new features introduced in ECMAScript 2018:
+ <ul>
+ <li><a href="/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Assertions">Lookbehind assertions</a> ({{bug(1225665)}})</li>
+ <li>{{JSxRef("RegExp.prototype.dotAll")}} ({{bug(1361856)}})</li>
+ <li><a href="/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Unicode_Property_Escapes">Unicode property escapes</a> ({{bug(1361876)}})</li>
+ <li><a href="/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Groups_and_Ranges">Named capture groups</a> ({{bug(1362154)}})</li>
+ </ul>
+ </li>
+ <li>Due to a <a href="https://github.com/heycam/webidl/pull/357">WebIDL spec change</a> in mid-2020, we've <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag#toStringTag_available_on_all_DOM_prototype_objects">added a <code>Symbol.toStringTag</code> property to all DOM prototype objects</a> ({{bug(1277799)}}).</li>
+ <li>The garbage collection of {{jsxref("WeakMap")}} objects has been improved. <code>WeakMaps</code> are now marked incrementally ({{bug(1167452)}}).</li>
+</ul>
+
+<h3 id="一些API">一些API</h3>
+
+<h4 id="DOM">DOM</h4>
+
+<ul>
+ <li>The {{DOMxRef("ParentNode.replaceChildren()")}} method has been implemented ({{bug(1626015)}}).</li>
+</ul>
+
+<h4 id="服务工作者">服务工作者</h4>
+
+<ul>
+ <li><a href="https://www.mozilla.org/en-US/firefox/organizations/">Extended Support Releases (ESR)</a>: Firefox 78 is the first ESR release that supports <a href="/en-US/docs/Web/API/Service_Worker_API">Service workers</a> (and the <a href="/en-US/docs/Web/API/Push_API">Push API</a>). Earlier ESR releases had no support ({{bug(1547023)}}).</li>
+</ul>
+
+<h3 id="Web组装">Web组装</h3>
+
+<ul>
+ <li><a href="https://hacks.mozilla.org/2019/11/multi-value-all-the-wasm/">Wasm Multi-value</a> is now supported, meaning that WebAssembly functions can now return multiple values, and instruction sequences can consume and produce multiple stack values ({{bug(1628321)}}).</li>
+ <li>WebAssembly now supports import and export of 64-bit integer function parameters (i64) using <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt">BigInt</a></code> from JavaScript ({{bug(1608770)}}).</li>
+</ul>
+
+<h3 id="TLS_1.0和1.1已被移除">TLS 1.0和1.1已被移除</h3>
+
+<ul>
+ <li><span class="tlid-translation translation" lang="zh-CN"><span title="">所有浏览器都不再支持</span></span><a href="/en-US/docs/Web/Security/Transport_Layer_Security">传输层安全</a> (TLS) <span class="tlid-translation translation" lang="zh-CN"><span title="">协议的1.0和1.1版本。阅读</span></span><a href="https://hacks.mozilla.org/2019/05/tls-1-0-and-1-1-removal-update/">TLS 1.0和1.1删除更新</a><span class="tlid-translation translation" lang="zh-CN"><span title="">以获取先前的公告,以及如果受到影响应采取的措施</span></span> ({{bug(1643229)}}).</li>
+</ul>
+
+<h2 id="对于附加组件开发人员的更改">对于附加组件开发人员的更改</h2>
+
+<ul>
+ <li>{{WebExtAPIRef("browsingData.removeCache")}} 和 {{WebExtAPIRef("browsingData.removePluginData")}} 现在支持按主机名删除。({{bug(1636784)}}).</li>
+ <li><span class="tlid-translation translation" lang="zh-CN"><span title="">使用</span></span><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/proxy/onRequest">proxy.onRequest</a></code><span class="tlid-translation translation" lang="zh-CN"><span title="">时,现在可以正确应用基于选项卡ID或窗口ID限制的过滤器。</span> <span title="">这对于希望仅在一个窗口中提供代理功能的加载项很有用。</span></span></li>
+ <li><span class="tlid-translation translation" lang="zh-CN"><span title="">现在,从“所有选项卡”下拉菜单中</span></span><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/menus/onClicked">单击上下文菜单</a><span class="tlid-translation translation" lang="zh-CN"><span title="">即可传递适当的选项卡对象。</span> <span title="">过去,活动选项卡被错误地传递了。</span></span></li>
+ <li><span class="tlid-translation translation" lang="zh-CN"><span title="">当使用带有另存为选项的</span></span><code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/downloads/download">downloads.download</a></code><span class="tlid-translation translation" lang="zh-CN"><span title="">时,可以记住最近使用的目录。</span> <span title="">尽管此信息对开发人员用处不大,但对用户而言却非常方便。</span></span></li>
+</ul>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li><a href="https://www.fxsitecompat.com/en-CA/versions/78/">Firefox 78的网站兼容性</a></li>
+</ul>
+
+<h2 id="旧版本">旧版本</h2>
+
+<p>{{Firefox_for_developers(77)}}</p>
diff --git a/files/zh-cn/mozilla/firefox/releases/index.html b/files/zh-cn/mozilla/firefox/releases/index.html
new file mode 100644
index 0000000000..9f16917cdc
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/releases/index.html
@@ -0,0 +1,12 @@
+---
+title: 与Firefox开发者相关的发行说明
+slug: Mozilla/Firefox/Releases
+tags:
+ - Firefox
+ - NeedsTranslation
+ - TopicStub
+translation_of: Mozilla/Firefox/Releases
+---
+<div>{{FirefoxSidebar}}</div><p>本页提供每个Firefox的版本的“与Firefox开发者相关的发行说明”文章的链接。这些日志文章可以让你查看每个Firefox版本增加了哪些功能和修复的错误。</p>
+
+<div class="multiColumnList">{{ListSubpages("",1,1,1)}}</div>
diff --git a/files/zh-cn/mozilla/firefox/the_about_protocol/index.html b/files/zh-cn/mozilla/firefox/the_about_protocol/index.html
new file mode 100644
index 0000000000..9b889c3338
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox/the_about_protocol/index.html
@@ -0,0 +1,163 @@
+---
+title: Firefox 与 "about" 协议
+slug: Mozilla/Firefox/The_about_protocol
+translation_of: Mozilla/Firefox/The_about_protocol
+---
+<div>{{FirefoxSidebar}}</div><p>Firefox 在 <code>about:</code> URL 协议中藏有很多隐藏的功能和有用的信息。最常用的 URL 就是 <code>about:config</code>,它提供首选项的显示和修改功能。以下是 <code>about: </code>伪协议的完整列表:</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col"><code>about:</code> 页面</th>
+ <th scope="col">描述</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>about:</code></td>
+ <td>显示版本和构建信息,以及查阅贡献者、许可信息和构建配置的链接。</td>
+ </tr>
+ <tr>
+ <td><code>about:about</code></td>
+ <td>提供 about: 页面的完整列表</td>
+ </tr>
+ <tr>
+ <td><code>about:accounts</code></td>
+ <td><a href="https://www.mozilla.org/en-US/firefox/sync/">同步</a> 功能使用的页面</td>
+ </tr>
+ <tr>
+ <td><code>about:addons</code></td>
+ <td>附加组件管理器</td>
+ </tr>
+ <tr>
+ <td><code>about:app-manager</code></td>
+ <td>应用管理器</td>
+ </tr>
+ <tr>
+ <td><code>about:buildconfig</code></td>
+ <td>显示构建此 Firefox 所用的配置和平台</td>
+ </tr>
+ <tr>
+ <td><code>about:cache</code></td>
+ <td>显示有关内存、磁盘和应用缓存的信息</td>
+ </tr>
+ <tr>
+ <td><code>about:compartments</code></td>
+ <td>显示有关 <a href="/en-US/docs/SpiderMonkey/SpiderMonkey_compartments">compartments</a> 的信息。从 Firefox 26 开始,此信息可在 about:memory 的 "Other Measurements"  部分找到</td>
+ </tr>
+ <tr>
+ <td><code>about:config</code></td>
+ <td>允许查看和更改 Firefox 内部的首选项(偏好和设置)</td>
+ </tr>
+ <tr>
+ <td><code>about:crashes</code></td>
+ <td>列出所有崩溃报告</td>
+ </tr>
+ <tr>
+ <td><code>about:credits</code></td>
+ <td>列出所有参与 Firefox 产品的贡献者姓名</td>
+ </tr>
+ <tr>
+ <td><code>about:customizing</code></td>
+ <td>切换到“定制”模式,允许用户定制 Firefox 的用户界面</td>
+ </tr>
+ <tr>
+ <td><code>about:downloads</code></td>
+ <td>显示用 Firefox 进行的下载</td>
+ </tr>
+ <tr>
+ <td><code>about:healthreport</code></td>
+ <td>显示 Firefox 的性能信息(如果用户已启用“健康报告”功能)</td>
+ </tr>
+ <tr>
+ <td><code>about:home</code></td>
+ <td>Firefox 原生的开始页(新窗口的第一个页面)</td>
+ </tr>
+ <tr>
+ <td><code>about:license</code></td>
+ <td>显示许可信息</td>
+ </tr>
+ <tr>
+ <td><code>about:logo</code></td>
+ <td>Firefox 标志</td>
+ </tr>
+ <tr>
+ <td><code>about:memory</code></td>
+ <td>提供一种方法探查内存使用情况,以及保存为报告,还有运行 GC 和 CC</td>
+ </tr>
+ <tr>
+ <td><code>about:mozilla</code></td>
+ <td>一个特殊页面,显示“Mozilla 之书”摘录</td>
+ </tr>
+ <tr>
+ <td><code>about:networking</code></td>
+ <td>显示网络相关的信息</td>
+ </tr>
+ <tr>
+ <td><code>about:newtab</code></td>
+ <td>新建一个标签页时显示的页面</td>
+ </tr>
+ <tr>
+ <td><code>about:permissions</code></td>
+ <td>提供一种方法来显示和管理网站权限。在 Firefox 45 中已去除({{bug(933917)}})</td>
+ </tr>
+ <tr>
+ <td><code>about:plugins</code></td>
+ <td>显示已安装插件的信息</td>
+ </tr>
+ <tr>
+ <td><code>about:preferences</code></td>
+ <td>Firefox 设置(也可通过 Firefox &gt; 选项 来打开)</td>
+ </tr>
+ <tr>
+ <td><code>about:privatebrowsing</code></td>
+ <td>打开新的隐私浏览窗口时显示的页面</td>
+ </tr>
+ <tr>
+ <td><code>about:reader</code></td>
+ <td>指示在一个页面上开启了阅读视图。 参见<a href="https://support.mozilla.org/en-US/kb/firefox-reader-view-clutter-free-web-pages">Firefox 排除干扰的阅读视图</a></td>
+ </tr>
+ <tr>
+ <td><code>about:rights</code></td>
+ <td>显示权利信息</td>
+ </tr>
+ <tr>
+ <td><code>about:robots</code></td>
+ <td>显示有关机器人的信息,一个特殊的页面</td>
+ </tr>
+ <tr>
+ <td><code>about:sessionrestore</code></td>
+ <td>会话恢复(Firefox 从崩溃恢复时显示)</td>
+ </tr>
+ <tr>
+ <td><code>about:support</code></td>
+ <td>故障排除信息(也称“疑难解答”信息)。也可通过 Firefox 菜单 &gt; <em>? (问号)</em> &gt;<em> 故障排除信息 </em>打开</td>
+ </tr>
+ <tr>
+ <td><code>about:sync-log</code></td>
+ <td>显示 <a href="https://www.mozilla.org/en-US/firefox/sync/">同步</a> 功能所用的同步协议的日志</td>
+ </tr>
+ <tr>
+ <td><code>about:sync-progress</code></td>
+ <td>这是 <a href="https://www.mozilla.org/en-US/firefox/sync/">同步</a> 功能设置完成后显示的页面</td>
+ </tr>
+ <tr>
+ <td><code>about:sync-tabs</code></td>
+ <td>列出 <a href="https://www.mozilla.org/en-US/firefox/sync/">同步</a> 功能同步的标签页</td>
+ </tr>
+ <tr>
+ <td><code>about:telemetry</code></td>
+ <td>显示在 Firefox 运行时已收集和将发送到 Mozilla 的遥测数据(如果用户已启用“遥测”功能)</td>
+ </tr>
+ <tr>
+ <td><code>about:webrtc</code></td>
+ <td>有关 WebRTC 的使用情况</td>
+ </tr>
+ <tr>
+ <td><code>about:welcomeback</code></td>
+ <td>在 Firefox 被重置后显示的信息页面</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>这些 URL 在 {{source("docshell/base/nsAboutRedirector.cpp")}} 中的 <code>kRedirMap</code> 数组定义。该数组映射大部分 URL,比如 <code>config</code> 指向 <code>chrome:</code> 伪协议,例如 <code>chrome://global/content/config.xul</code>。about 的位置信息在 {{source("docshell/build/nsDocShellModule.cpp")}} 也存有副本。</p>
diff --git a/files/zh-cn/mozilla/firefox_for_android/index.html b/files/zh-cn/mozilla/firefox_for_android/index.html
new file mode 100644
index 0000000000..955aa200c0
--- /dev/null
+++ b/files/zh-cn/mozilla/firefox_for_android/index.html
@@ -0,0 +1,65 @@
+---
+title: Firefox for Android
+slug: Mozilla/Firefox_for_Android
+translation_of: Mozilla/Firefox_for_Android
+---
+<p>对于越来越多的人来说,移动设备是他们上网的主要方式,甚至是唯一方式。Firefox Android版(代号 Fennec)是一个开放的,可定制的,基于标准的浏览器,就像桌面版的Firefox。</p>
+
+<p>Firefox Android版从原生的Android小部件构建用户界面而不是XUL:这极大的提高了性能,特别是启动时间和内存消耗上。</p>
+
+<h2 id="有助于Firefox_for_Android">有助于Firefox for Android</h2>
+
+<p>关于Firefox for Android项目主要出发点的一些信息参见 <a href="https://wiki.mozilla.org/Mobile/Get_Involved">“Get Involved” 页</a>。</p>
+
+<p>你可以帮助我们建立和改善 Firefox for Android:</p>
+
+<ul>
+ <li><span id="result_box" lang="zh-CN"><span>帮助我们</span><span>进行</span><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_for_Android/Compatibility_Testing"><span>兼容性测试</span> </a></span></li>
+ <li>订阅 <a href="https://mail.mozilla.org/listinfo/mobile-firefox-dev">mobile-firefox-dev 邮件列表</a></li>
+ <li>
+ <div><span id="Dst[5][17:20:0:0]">在</span><a href="irc://irc.mozilla.org/#mobile"><span> </span><span id="Dst[5][22:24:2:4]">IRC</span><span> </span></a><span id="Dst[5][0:6:6:7]">联系我们的</span><span id="Dst[5][12:15:8:9]">团队</span></div>
+ </li>
+ <li>参加我们的<a href="https://wiki.mozilla.org/Mobile/Notes">周三开发会议</a></li>
+ <li>通过<a class="external" href="http://planet.firefox.com/mobile/">Planet Firefox Mobile</a>, <a href="http://fennecnightly.tumblr.com/">Tumblr</a> 和 <a class="link-https" href="https://twitter.com/FennecNightly" title="https://twitter.com/#!/mozmobile">Twitter</a> 关注我们的最新信息</li>
+ <li>在 <a href="https://wiki.mozilla.org/Mobile/Fennec/Android">Firefox for Android (Fennec) </a>上建立和修改</li>
+</ul>
+
+<h2 id="为移动web开发">为移动web开发</h2>
+
+<p class="ordinary-output target-output"><span>我们已经开始了一个</span><a href="https://developer.mozilla.org/En/Mobile"><span>为</span></a><span><a href="https://developer.mozilla.org/En/Mobile">移动设备</a></span><span><a href="https://developer.mozilla.org/En/Mobile"><span>设计</span></a>网站的指南</span><span>。</span></p>
+
+<p>With Firefox for Android, you've got access a number of APIs that expose the underlying capabilities of the device, closing the gap between the Web and native applications:</p>
+
+<ul>
+ <li><a class="external" href="http://hacks.mozilla.org/2012/02/using-the-battery-api-part-of-webapi/" title="http://hacks.mozilla.org/2012/02/using-the-battery-api-part-of-webapi/">Battery</a></li>
+ <li><a href="/en/DOM/Using_the_Camera_API" title="Using the Camera API">Camera</a></li>
+ <li><a href="/en/API/WebTelephony/Introduction_to_WebTelephony" title="Introduction to WebTelephony">WebTelephony</a></li>
+ <li><a href="/en/API/WebSMS/Introduction_to_WebSMS" title="Introduction to WebSMS">WebSMS</a></li>
+ <li><a href="/En/Using_geolocation" title="Using geolocation">Geolocation</a></li>
+ <li><a href="/en/Detecting_device_orientation" title="https://developer.mozilla.org/en/detecting_device_orientation">Orientation</a></li>
+</ul>
+
+<p>To test your web site on Firefox for Android, you can <a class="link-https" href="https://www.mozilla.org/en-US/mobile/">install it on an Android device</a> or <a class="link-https" href="https://wiki.mozilla.org/Mobile/Fennec/Android/Emulator">run it on your desktop using the Android Emulator</a>.</p>
+
+<h2 id="构建Mobile附加组件">构建Mobile附加组件</h2>
+
+<p><a href="/en/Extensions/Mobile" title="en/Extensions/Firefox_on_Android">Firefox for Android supports add-ons</a> using the exact same <a href="/en/Extensions" title="en/Extensions">extension system</a> used by all other Gecko-based applications. We did not invent a new add-on system. This means that building an add-on for Firefox on Android is the <a href="/en/Building_an_Extension" title="en/Building_an_Extension">same process</a> that would be used for desktop Firefox. Add-ons that work with desktop Firefox <strong>do not</strong> automatically work in Firefox on Android. The user interfaces are just too different.</p>
+
+<div class="note">Firefox on Android has a unique application identifier which must be used in <code>install.rdf</code>. The identifier is <code>{aa3c5121-dab2-40e2-81ca-7ea25febc110}</code></div>
+
+<p>Both classic restart-required and newer <a href="/en/Extensions/Bootstrapped_extensions" title="en/Extensions/Bootstrapped_extensions">restartless</a> add-on approaches are supported. Using the restartless approach is preferred whenever possible because the user experience is far superior to forcing an application restart when installing or removing an add-on.</p>
+
+<h3 id="快速概览">快速概览</h3>
+
+<ul>
+ <li>There is no visible XUL in the UI, so using overlays to try to add or change UI is useless.</li>
+ <li>Internal code and objects, like <code>gBrowser</code>, do not exist. Look at the Firefox on Android <a class="external" href="http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js" title="http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js"><code>browser.js</code></a> file to learn about the internals. Much of the same fundamental functionality exists.</li>
+ <li>Services like <code>nsIPromptService</code> and <code>nsIAlertsService</code> are implemented to use native Android UI.</li>
+ <li>There is a simple JavaScript object, called <a href="/en/Extensions/Mobile/API/NativeWindow" title="en/Extensions/Mobile/NativeWindow"><code>NativeWindow</code></a>, that allows you to manipulate parts of the native Android UI.</li>
+</ul>
+
+<h2 id="获取Firefox_for_Android的帮助">获取Firefox for Android的帮助</h2>
+
+<p>Documentation and tutorials for using and troubleshooting Firefox for Android are available on the <a class="external" href="http://support.mozilla.org/mobile" title="http://support.mozilla.org/mobile">Mozilla Support website</a>.</p>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/gecko/index.html b/files/zh-cn/mozilla/gecko/index.html
new file mode 100644
index 0000000000..a5863d1b6d
--- /dev/null
+++ b/files/zh-cn/mozilla/gecko/index.html
@@ -0,0 +1,74 @@
+---
+title: Gecko
+slug: Mozilla/Gecko
+tags:
+ - Gecko
+ - Mozilla
+translation_of: Mozilla/Gecko
+---
+<div>{{FirefoxSidebar}}</div>
+
+<div class="summary">
+<p><span style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>Gecko</strong> 是由 Mozilla 工程开发出的布局引擎的名字。它的原名是 NGLayout。Gecko 的功能就是读取 web 内容,如<a href="/zh-CN/docs/learn/HTML">HTML</a>,</span><a href="https://developer.mozilla.org/en-US/docs/CSS" title="CSS">CSS</a>,<a href="https://developer.mozilla.org/en-US/docs/XUL" title="XUL">XUL</a>,<a href="https://developer.mozilla.org/en-US/docs/JavaScript" title="JavaScript">JavaScript</a>, 之后将其渲染到用户界面上。在基于 XUL 的应用中,Gecko 也同样用来渲染应用程序的用户界面。</p>
+</div>
+
+<p>Gecko 被使用在许多应用程序中,包括一些浏览器,如 Firefox,SeaMonkey等(要获取完整的列表,请参考 <a class="external external-icon" href="http://en.wikipedia.org/wiki/Gecko_%28layout_engine%29#Web_browsers" rel="external" style="text-decoration: underline; white-space: pre-line;" title="http://en.wikipedia.org/wiki/Gecko_(layout_engine)#Web_browsers">Wikipedia's article on Gecko</a>)。使用相同 Gecko 版本的产品对标准则有同样的支持。</p>
+
+<table class="topicpage-table" style="">
+ <tbody>
+ <tr>
+ <td style="width: 283px;">
+ <h2 class="Documentation" id="文档" style="margin-bottom: 20px; font-family: 'Open Sans Light', sans-serif; line-height: 30px;">文档</h2>
+
+ <dl>
+ <dt><a href="https://developer.mozilla.org/en-US/docs/Gecko_FAQ" title="Gecko_FAQ">Gecko FAQ</a></dt>
+ <dd>关于 Gecko 常见的问题。</dd>
+ <dt> <a href="https://developer.mozilla.org/en-US/docs/Gecko_DOM_Reference" title="https://developer.mozilla.org/en-US/docs/Gecko_DOM_Reference">Gecko DOM 参考文档</a></dt>
+ <dd>DOM参考文档。</dd>
+ <dt><a href="https://developer.mozilla.org/en-US/docs/Gecko-Specific_DOM_Events" title="Gecko/Gecko event reference">Gecko event 参考文档</a></dt>
+ <dd>使用在 Gecko 和 Mozilla 应用中 event 的参考文档。要获取 web 标准的 DOM event, 请参考 <a href="https://developer.mozilla.org/en-US/docs/DOM/DOM_event_reference" title="DOM/DOM event reference">DOM event reference</a>.</dd>
+ <dt><a href="https://developer.mozilla.org/en-US/docs/Gecko/Versions" title="Gecko/Versions">Gecko 版本和应用程序版本</a></dt>
+ <dd>它们使用的Gecko和应用程序版本。</dd>
+ <dt><a class="external external-icon" href="https://developer.mozilla.org/en-US/docs/Introduction_to_Layout_in_Mozilla" style="white-space: pre-line;" title="https://developer.mozilla.org/en-US/docs/Introduction_to_Layout_in_Mozilla"> Mozilla 中对布局的介绍</a></dt>
+ <dd>关于布局的技术性介绍。</dd>
+ <dt><a href="https://developer.mozilla.org/en-US/docs/Embedding_Mozilla" title="Embedding_Mozilla">嵌入 Mozilla</a></dt>
+ <dd>在您的应用中使用 Gecko。</dd>
+ <dt><a href="https://developer.mozilla.org/en-US/docs/Character_Sets_Supported_by_Gecko" title="Character Sets Supported by Gecko">由 Gecko 支持的字符集</a></dt>
+ <dd>Gecko所支持的字符集列表。</dd>
+ <dt><a href="https://developer.mozilla.org/en-US/docs/Gecko/HTML_parser_threading" title="Gecko/HTML_parser_threading">HTML 解析器线程</a></dt>
+ <dd>在 HTML 解析器中的多线程描述。</dd>
+ <dt>{{interwiki('wikimo', 'Gecko:Home_Page', 'Gecko Home Page on MozillaWiki')}}</dt>
+ <dd>活跃开发者之家。路线图以及最新的资源。</dd>
+ </dl>
+
+ <p><span class="alllinks"><a href="https://developer.mozilla.org/en-US/docs/tag/Gecko" title="tag/Gecko">View All...</a></span></p>
+ </td>
+ <td style="width: 283px;">
+ <h2 class="Community" id="社区" style="margin-bottom: 20px; font-family: 'Open Sans Light', sans-serif; line-height: 30px;">社区</h2>
+
+ <ul>
+ <li>View Mozilla forums... {{DiscussionList("dev-tech-layout", "mozilla.dev.tech.layout")}}</li>
+ </ul>
+
+ <h2 class="Related_Topics" id="相关主题" style="margin-bottom: 20px; font-family: 'Open Sans Light', sans-serif; line-height: 30px;">相关主题</h2>
+
+ <div>
+ <ul>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web_Standards">Web Standards</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/XUL">XUL</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Embedding_Mozilla">Embedding Mozilla</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Developer_Guide">Developing Mozilla</a></li>
+ </ul>
+ </div>
+
+ <dl>
+ <dd> </dd>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p> </p>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/gecko/versions/index.html b/files/zh-cn/mozilla/gecko/versions/index.html
new file mode 100644
index 0000000000..cd2989399c
--- /dev/null
+++ b/files/zh-cn/mozilla/gecko/versions/index.html
@@ -0,0 +1,130 @@
+---
+title: Gecko版本和对应的应用程序版本
+slug: Mozilla/Gecko/Versions
+tags:
+ - Gecko
+translation_of: Mozilla/Gecko/Versions
+---
+<p>下面的表格记录了 Gecko 的每个版本以及建立在该版本 Gecko 之上的应用程序的版本.</p>
+<p>注意在 Gecko 2.0 之后(也就是 Gecko 5.0 开始), Firefox 和 Thunderbird 同 Gecko 采用同一个版本号.</p>
+<p><span style="line-height: 1.5;">另外从 Gecko 17开始, SpiderMoneky 也开始使用这个版本号, 比如</span><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Projects/SpiderMonkey/17" style="line-height: 1.5;"> SpiderMonkey 17</a><span style="line-height: 1.5;">, </span><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Projects/SpiderMonkey/24" style="line-height: 1.5;">SpiderMonkey 24</a><span style="line-height: 1.5;">,</span><span style="line-height: 1.5;"> 抛弃了之前使用的 1.8.x 小版本号方式, </span><span style="line-height: 1.5;">SpiderMoneky </span><span style="line-height: 1.5;">最后一个小版本号是 <a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Projects/SpiderMonkey/1.8.8">1.8.8</a>, 最后一个稳定版的小版本号是 <a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Projects/SpiderMonkey/1.8.5">1.8.5</a>. 这些版本号也可以从 Mozilla 发布的 <a href="http://ftp.mozilla.org/pub/mozilla.org/js/">SpiderMonkey 源码包</a>的文件名中看出 </span></p>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Gecko  版本</th>
+ <th>基于它的应用程序版本</th>
+ </tr>
+ <tr>
+ <td>Gecko 24</td>
+ <td><a href="/zh-CN/docs/Mozilla/Firefox/Releases/24">Firefox 24</a>, <a href="/zh-CN/docs/Mozilla/Thunderbird/Releases/24">Thunderbird 24</a>, <a href="http://www.seamonkey-project.org/releases/seamonkey2.21/changes">SeaMonkey 2.21</a></td>
+ </tr>
+ <tr>
+ <td>Gecko 23</td>
+ <td><a href="/zh-CN/docs/Mozilla/Firefox/Releases/23">Firefox 23</a>, <a href="http://www.seamonkey-project.org/releases/seamonkey2.20/changes">SeaMonkey 2.20</a></td>
+ </tr>
+ <tr>
+ <td>Gecko 22</td>
+ <td><a href="/zh-CN/docs/Mozilla/Firefox/Releases/22">Firefox 22</a>, <a href="http://www.seamonkey-project.org/releases/seamonkey2.19/changes">SeaMonkey 2.19</a></td>
+ </tr>
+ <tr>
+ <td>Gecko 21</td>
+ <td><a href="/zh-CN/docs/Mozilla/Firefox/Releases/21">Firefox 21</a>, {{ interwiki('wikimo', 'SeaMonkey/Features/2.18', 'SeaMonkey 2.18') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 20</td>
+ <td><a href="/zh-CN/docs/Mozilla/Firefox/Releases/20">Firefox 20</a>, {{ interwiki('wikimo', 'SeaMonkey/Features/2.17', 'SeaMonkey 2.17') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 19</td>
+ <td><a href="/zh-CN/docs/Mozilla/Firefox/Releases/19">Firefox 19</a>, {{ interwiki('wikimo', 'SeaMonkey/Features/2.16', 'SeaMonkey 2.16') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 18</td>
+ <td><a href="/zh-CN/docs/Firefox_18_for_developers" title="/zh-CN/docs/Firefox_18_for_developers">Firefox 18</a>, <a href="/zh-CN/docs/Mozilla/Firefox_OS" title="/zh-CN/docs/Mozilla/Firefox_OS">Firefox OS 1.0</a>, {{ interwiki('wikimo', 'SeaMonkey/Features/2.15', 'SeaMonkey 2.15') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 17</td>
+ <td><a href="/zh-CN/docs/Firefox_17_for_developers" title="/zh-CN/docs/Firefox_17_for_developers">Firefox 17</a>, Thunderbird 17, {{ interwiki('wikimo', 'SeaMonkey/Features/2.14', 'SeaMonkey 2.14') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 16</td>
+ <td><a href="/zh-CN/docs/Firefox_16_for_developers" title="/zh-CN/docs/Firefox_16_for_developers">Firefox 16</a>, Thunderbird 16, {{ interwiki('wikimo', 'SeaMonkey/Features/2.13', 'SeaMonkey 2.13') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 15</td>
+ <td><a href="/zh-CN/docs/Firefox_15_for_developers" title="/zh-CN/docs/Firefox_15_for_developers">Firefox 15</a>, <a href="https://wiki.mozilla.org/Thunderbird/Support/TB15UserChanges" title="https://wiki.mozilla.org/Thunderbird/Support/TB15UserChanges">Thunderbird 15</a>, {{ interwiki('wikimo', 'SeaMonkey/Features/2.12', 'SeaMonkey 2.12') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 14</td>
+ <td><a href="/zh-CN/docs/Firefox_14_for_developers" title="/zh-CN/docs/Firefox_14_for_developers">Firefox 14</a>, <a href="https://wiki.mozilla.org/Thunderbird/Support/TB14UserChanges" title="https://wiki.mozilla.org/Thunderbird/Support/TB14UserChanges">Thunderbird 14</a>, {{ interwiki('wikimo', 'SeaMonkey/Features/2.11', 'SeaMonkey 2.11') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 13</td>
+ <td><a href="/zh-CN/docs/Firefox_13_for_developers" title="zh-CN/docs/Firefox_13_for_developers">Firefox 13</a>, <a class="link-https" href="https://wiki.mozilla.org/Thunderbird/Support/TB13UserChanges" title="https://wiki.mozilla.org/Thunderbird/Support/TB13UserChanges">Thunderbird 13</a>, {{ interwiki('wikimo', 'SeaMonkey/Features/2.10', 'SeaMonkey 2.10') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 12</td>
+ <td><a href="/zh-CN/docs/Firefox_12_for_developers" title="zh-CN/docs/Firefox_12_for_developers">Firefox 12</a>, <a class="link-https" href="https://wiki.mozilla.org/Thunderbird/Support/TB12UserChanges" title="https://wiki.mozilla.org/Thunderbird/Support/TB12UserChanges">Thunderbird 12</a>, {{ interwiki('wikimo', 'SeaMonkey/Features/2.9', 'SeaMonkey 2.9') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 11</td>
+ <td><a href="/zh-CN/docs/Firefox_11_for_developers" title="zh-CN/docs/Firefox_11_for_developers">Firefox 11</a>, <a class="link-https" href="https://wiki.mozilla.org/Thunderbird/Support/TB11UserChanges" title="https://wiki.mozilla.org/Thunderbird/Support/TB11UserChanges">Thunderbird 11</a>, {{ interwiki('wikimo', 'SeaMonkey/Features/2.8', 'SeaMonkey 2.8') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 10</td>
+ <td><a class="internal" href="/zh-CN/docs/Firefox_10_for_developers" title="zh-CN/docs/Firefox 10 for developers">Firefox 10</a>, <a class="link-https" href="https://wiki.mozilla.org/Thunderbird/Support/TB10UserChanges" title="https://wiki.mozilla.org/Thunderbird/Support/TB10UserChanges">Thunderbird 10</a>, {{ interwiki('wikimo', 'SeaMonkey/Features/2.7', 'SeaMonkey 2.7') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 9</td>
+ <td><a class="internal" href="/zh-CN/docs/Firefox_9_for_developers" title="zh-CN/docs/Firefox 9 for developers">Firefox 9</a>, <a class="link-https" href="https://wiki.mozilla.org/Thunderbird/Support/TB9UserChanges" title="https://wiki.mozilla.org/Thunderbird/Support/TB9UserChanges">Thunderbird 9</a>, {{ interwiki('wikimo', 'SeaMonkey/Features/2.6', 'SeaMonkey 2.6') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 8</td>
+ <td><a class="internal" href="/zh-CN/docs/Firefox_8_for_developers" title="zh-CN/docs/Firefox 8 for developers">Firefox 8</a>, <a class="link-https" href="https://wiki.mozilla.org/Thunderbird/Support/TB8UserChanges" title="https://wiki.mozilla.org/Thunderbird/Support/TB8UserChanges">Thunderbird 8</a>, {{ interwiki('wikimo', 'SeaMonkey/Features/2.5', 'SeaMonkey 2.5') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 7</td>
+ <td><a class="internal" href="/zh-CN/docs/Firefox_7_for_developers" title="zh-CN/docs/Firefox 7 for developers">Firefox 7</a>, <a href="/zh-CN/docs/Thunderbird_7_for_developers" title="zh-CN/docs/Thunderbird 7 for developers">Thunderbird 7</a>, {{ interwiki('wikimo', 'SeaMonkey/Features/2.4', 'SeaMonkey 2.4') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 6</td>
+ <td><a class="internal" href="/zh-CN/docs/Firefox_6_for_developers" title="zh-CN/docs/Firefox 6 for developers">Firefox 6</a>, <a href="/zh-CN/docs/Thunderbird_6_for_developers" title="zh-CN/docs/Thunderbird 6 for developers">Thunderbird 6</a>, {{ interwiki('wikimo', 'SeaMonkey/Features/2.3', 'SeaMonkey 2.3') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 5</td>
+ <td><a href="/zh-CN/docs/Firefox_5_for_developers" title="zh-CN/docs/Firefox 5 for developers">Firefox 5</a>, <a href="/zh-CN/docs/Thunderbird_5_for_developers" title="zh-CN/docs/Thunderbird 5 for developers">Thunderbird 5</a>, {{ interwiki('wikimo', 'SeaMonkey/Features/2.2', 'SeaMonkey 2.2') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 2</td>
+ <td><a class="internal" href="/zh-CN/docs/Firefox_4_for_developers" title="zh-CN/docs/Firefox 4 for developers">Firefox 4</a>, <span class="st">Thunderbird 3.3, </span>{{ interwiki('wikimo', 'SeaMonkey/Features/2.1', 'SeaMonkey 2.1') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 1.9.2</td>
+ <td><a class="internal" href="/zh-CN/docs/Firefox_3.6_for_developers" title="zh-CN/docs/Firefox 3.6 for developers">Firefox 3.6</a>, Thunderbird 3.1</td>
+ </tr>
+ <tr>
+ <td>Gecko 1.9.1</td>
+ <td><a class="internal" href="/zh-CN/docs/Firefox_3.5_for_developers" title="zh-CN/docs/Firefox 3.5 for developers">Firefox 3.5</a>, <a class="internal" href="/zh-CN/docs/Thunderbird_3_for_developers" title="zh-CN/docs/Thunderbird 3 for developers">Thunderbird 3</a>, {{ interwiki('wikimo', 'SeaMonkey:New_for_2.0', 'SeaMonkey 2.0') }}</td>
+ </tr>
+ <tr>
+ <td>Gecko 1.9</td>
+ <td><a href="/zh-CN/docs/Firefox_3_for_developers" title="zh-CN/docs/Firefox_3_for_developers">Firefox 3</a></td>
+ </tr>
+ <tr>
+ <td>Gecko 1.8.1</td>
+ <td><a href="/zh-CN/docs/Firefox_2_for_developers" title="zh-CN/docs/Firefox_2_for_developers">Firefox 2</a>, Thunderbird 2, SeaMonkey 1.1</td>
+ </tr>
+ <tr>
+ <td>Gecko 1.8</td>
+ <td><a href="/zh-CN/docs/Firefox_1.5_for_developers" title="zh-CN/docs/Firefox_1.5_for_developers">Firefox 1.5</a>, Thunderbird 1.5, SeaMonkey 1.0</td>
+ </tr>
+ <tr>
+ <td>Gecko 1.7</td>
+ <td>Firefox 1.0, Thunderbird 1.0, Nvu 1.0, Mozilla Suite 1.7</td>
+ </tr>
+ <tr>
+ <td colspan="2"><strong>older versions of Gecko match the Mozilla Suite versions</strong></td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
diff --git a/files/zh-cn/mozilla/gecko/嵌入mozilla/index.html b/files/zh-cn/mozilla/gecko/嵌入mozilla/index.html
new file mode 100644
index 0000000000..e2e5daa728
--- /dev/null
+++ b/files/zh-cn/mozilla/gecko/嵌入mozilla/index.html
@@ -0,0 +1,49 @@
+---
+title: 嵌入 Mozilla
+slug: Mozilla/Gecko/嵌入Mozilla
+tags:
+ - 㠌入Mozilla
+translation_of: Mozilla/Gecko/Embedding_Mozilla
+---
+<div><a href="/en-US/docs/Gecko" title="Gecko">Gecko允许第三方开发人员使用与Mozilla相同的技术。这意味着您可以将Web浏览器嵌入到第三方应用程序中,通过网络后端打开通道和流,遍历DOM等等。甚至可以使用用最新版chrome构建的应用程序。</a></div>
+
+<div></div>
+
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h2 class="Documentation" id="Documentation" name="Documentation">大纲</h2>
+
+ <dl>
+ <dt><a href="/en-US/docs/Gecko_Embedding_Basics" title="Gecko_Embedding_Basics">Gecko 基础绑定</a></dt>
+ <dd>嵌入gecko渲染引擎的介绍.</dd>
+ <dt><a href="/en-US/docs/Gecko/Embedding_Mozilla/FAQ/How_do_I..." title="/en-US/docs/Gecko/Embedding_Mozilla/FAQ/How_do_I...">嵌入提示</a></dt>
+ <dd>一些关于嵌入的常见问题。</dd>
+ <dt><a href="/en-US/docs/Mozilla_embedding_APIs_overview" title="Mozilla_embedding_APIs_overview">Mozilla 㠌入 API 概述</a></dt>
+ <dd>Mozilla嵌入API简介.</dd>
+ <dt><a href="/en-US/docs/Embedding_the_Editor" title="Embedding_the_Editor">嵌入编辑器</a></dt>
+ <dd>本文档描述了编辑器可嵌入性的当前状态、现有实现中的问题、我们需要处理的一些可能的嵌入场景,以及将满足这些情况的嵌入解决方案。</dd>
+ <dt><a href="/en-US/docs/Roll_your_own_browser_-_An_embedding_HowTo" title="Roll_your_own_browser_-_An_embedding_HowTo">玩转你自己的浏览器-一个嵌入方法</a></dt>
+ <dd>关于嵌入Mozilla的简单介绍。</dd>
+ </dl>
+
+ <p><span class="alllinks"><a href="/en-US/docs/tag/Embedding_Mozilla" title="tag/Embedding_Mozilla">View All...</a></span></p>
+ </td>
+ <td>
+ <h2 class="Community" id="Community" name="Community">社区</h2>
+
+ <ul>
+ <li>查看Mozilla论坛.. {{ DiscussionList("dev-embedding", "mozilla.dev.embedding") }}</li>
+ <li><a class="link-irc" href="irc://irc.mozilla.org/embedding">#绑定 IRC 信道</a></li>
+ </ul>
+
+ <h2 class="Related_Topics" id="Related_Topics" name="Related_Topics">相关主题</h2>
+
+ <ul>
+ <li><a href="/en-US/docs/Gecko" title="Gecko">Gecko</a>, <a href="/en-US/docs/XPCOM" title="XPCOM">XPCOM</a></li>
+ </ul>
+ </td>
+ </tr>
+ </tbody>
+</table>
diff --git a/files/zh-cn/mozilla/how_mozilla_determines_mime_types/index.html b/files/zh-cn/mozilla/how_mozilla_determines_mime_types/index.html
new file mode 100644
index 0000000000..fbe9917902
--- /dev/null
+++ b/files/zh-cn/mozilla/how_mozilla_determines_mime_types/index.html
@@ -0,0 +1,94 @@
+---
+title: How Mozilla determines MIME Types
+slug: Mozilla/How_Mozilla_determines_MIME_Types
+translation_of: Mozilla/How_Mozilla_determines_MIME_Types
+---
+<h2 id="Introduction" name="Introduction">Introduction</h2>
+
+<p>All data handling in Mozilla is based on the MIME type of the content. This means that every time an URI is loaded, Mozilla must find out its MIME type. The several ways how this happens are described in this document.</p>
+
+<h2 id="Content-Type_.22hints.22" name="Content-Type_.22hints.22">Content-Type "hints"</h2>
+
+<p>Mozilla has a concept of "content-type hints". This means that, for example, if Mozilla encounters a <code>&lt;link type="text/css" rel="stylesheet" href="..."&gt;</code> element, a type of text/css will be assumed. This is, however, overridden by the actual MIME type the server sends (if any). (For this specific example, the server override only happens in standards-compliant mode. See <a href="/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode" title="Mozilla's_Quirks_Mode">Mozilla's Quirks Mode</a> or <a href="/en-US/docs/Mozilla/Mozilla_Web_Developer_FAQ">Web Author FAQ</a>).</p>
+
+<p>Similar handling happens for <code>&lt;a href="..." type="foo/bar"&gt;</code>, starting in Mozilla 1.6alpha.</p>
+
+<h2 id="HTTP" name="HTTP">HTTP</h2>
+
+<p>For HTTP URIs Mozilla usually gets a MIME type sent from the server, and uses it. Contrary to <a class="external external-icon" href="https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775147(v=vs.85)">Internet Explorer's MIME type guessing</a>, Mozilla will generally not sniff the type of the document. However, starting in Mozilla 1.7alpha, Mozilla does do content sniffing, like this:</p>
+
+<p>When the Content-Type sent by the server is one of (case-sensitively)</p>
+
+<ul>
+ <li>text/plain</li>
+ <li>text/plain; charset=ISO-8859-1</li>
+ <li>text/plain; charset=iso-8859-1</li>
+</ul>
+
+<p>and the server did not send a Content-Encoding header, Mozilla will sniff the first block of data it gets and check for non-text bytes. Text bytes are 9-13, 27, and 31-255. When encountering a non-text byte, the helper app dialog will be shown, showing the MIME type corresponding to the extension of the file.</p>
+
+<p>Also, for images loaded via <code>&lt;img src&gt;</code>, Mozilla's image library will do content sniffing (never extension sniffing) to find out the real type of the image.</p>
+
+<p>If the server did not send a Content-Type header, Mozilla uses the unknown decoder to find a MIME type.</p>
+
+<h2 id="File_URIs" name="File_URIs">File URIs</h2>
+
+<p>For file: URIs, Mozilla will ask the <a href="#ExternalHelperAppService">ExternalHelperAppService</a> for a MIME type.</p>
+
+<h2 id="FTP" name="FTP">FTP</h2>
+
+<p>Like HTTP URIs without a MIME type, FTP URIs go through the unknown decoder.</p>
+
+<h2 id="Unknown_Decoder" name="Unknown_Decoder">Unknown Decoder</h2>
+
+<p>Located at {{ Source("netwerk/streamconv/converters/nsUnknownDecoder.cpp") }}, the interesting part starts at {{ Source("netwerk/streamconv/converters/nsUnknownDecoder.cpp#287", "line 287") }}, the sSnifferEntries array together with the DetermineContentType function. It does the following:</p>
+
+<ul>
+ <li>Checks the start of the file for "magic numbers"; this can currently detect PDF and Postscript.</li>
+ <li>If the file starts with <code>&lt;?xml</code>, asks the <a href="#ExternalHelperAppService">ExternalHelperAppService</a> for a MIME type for the URI. This is done because the generic <code>text/xml</code> MIME type does not work for XUL files, and XHTML files get a different DOM when interpreted as <code>text/xml</code>.</li>
+ <li>The Image Library will be asked for the MIME type given the content. This should allow reliable detection of all image types Mozilla supports.</li>
+ <li>Checks whether the data is HTML by looking for some common HTML tags.</li>
+ <li>The URI is handed to the ExternalHelperAppService for MIME type guessing</li>
+ <li>If all else fails, the buffer (i.e. the first few bytes of the file) is searched for embedded nulls; if none are found, <code>text/plain</code> will be used, otherwise <code>application/octet-stream</code>.</li>
+</ul>
+
+<h2 id="ExternalHelperAppService" name="ExternalHelperAppService">ExternalHelperAppService</h2>
+
+<p>(located at {{ Source("uriloader/exthandler/nsExternalHelperAppService.cpp") }})</p>
+
+<p>The file-&gt;MIME type mapping works like this:</p>
+
+<ul>
+ <li>On BeOS, the operating system is asked for the type of the file (not quite yet, {{ Bug(217723) }})</li>
+ <li>On MacOS, the type and creator code will be used to lookup the type of the file from the OS</li>
+ <li>a hardcoded list of extensions is checked (containing currently 13 entries, {{ Source("uriloader/exthandler/nsExternalHelperAppService.cpp#463", "nsExternalHelperAppService.cpp line 463") }} (This is done for speed – it is faster to find data in the hardcoded list than asking the OS or looking in preferences)</li>
+ <li>If the extension is not listed there, it becomes interesting. Firstly, the Operating System is asked for a MIME type. (On Unix, this means checking <code>mime.types</code>.)</li>
+ <li>If that fails, a user-supplied helper app is searched for by extension, and the specified MIME type will be used. (i.e. the list in Edit/Preferences/Helper Applications) If that failed, a list of "extra" MIME types is searched for an extension match. See {{ Source("uriloader/exthandler/nsExternalHelperAppService.cpp#507", "line 507") }} for the complete list.</li>
+ <li>If that also failed, the list of loaded plugins is checked for a plugin that can handle this extension, and is asked for the MIME type</li>
+ <li>If no plugin is registered, the ext-to-type-mapping XPCOM category is searched for the extension. This allows extensions to register additional mappings. The key of the category entry is the extension without leading dot, the value is the MIME type. The extension must be lowercase.</li>
+ <li>If no ext-to-type-mapping category is found, the ExternalHelperAppService returns <code>application/x-extension-EXT</code>, where EXT is the extension of the file.</li>
+</ul>
+
+<h2 id="Helper_Applications" name="Helper_Applications">Helper Applications</h2>
+
+<p>A somewhat related issue are the helper applications. When loading an URI with a type that Mozilla can not handle, a helper app dialog shows up, and the displayed information comes from these sources:</p>
+
+<ul>
+ <li>Ask the OS for a handler of the given &lt;extension, MIME Type&gt; pair. Note that the extension here comes from the Content-Disposition header if present, and from the URL itself otherwise. This is where the listed "default application" comes from.</li>
+ <li>The "data source" (that is, the list of helper applications) is searched for an entry with the MIME type of the URI. The data source is the <code>mimeTypes.rdf</code> file in the profile directory. If this fails, the data source is searched via the extension (Content-Disposition as above). If one of these lookups succeed, this is where the application in the "Open with" field comes from, and also where the description of the type comes from.</li>
+ <li>If this also failed, the extras are searched again, and will supply the extension-list and a description of the MIME type.</li>
+</ul>
+
+<h2 id="Related_Information">Related Information</h2>
+
+<p><a class="internal" href="/en-US/docs/Archive/Mozilla/Firefox/Document_Loading" title="Document Loading - From Load Start to Finding a Handler">Document Loading - From Load Start to Finding a Handler</a></p>
+
+<div class="originaldocinfo">
+<h2 id="Original_Document_Information" name="Original_Document_Information">Original Document Information</h2>
+
+<ul>
+ <li>Author(s): <a class="link-mailto" href="mailto:cbiesinger@web.de">Christian Biesinger</a></li>
+ <li>Last Updated Date: March 7, 2005</li>
+ <li>Copyright Information: Copyright (C) <a class="link-mailto" href="mailto:cbiesinger@web.de">Christian Biesinger</a></li>
+</ul>
+</div>
diff --git a/files/zh-cn/mozilla/how_to_get_a_process_dump_with_windows_task_manager/index.html b/files/zh-cn/mozilla/how_to_get_a_process_dump_with_windows_task_manager/index.html
new file mode 100644
index 0000000000..9833241199
--- /dev/null
+++ b/files/zh-cn/mozilla/how_to_get_a_process_dump_with_windows_task_manager/index.html
@@ -0,0 +1,48 @@
+---
+title: 怎样在任务管理器中获取进程的dump
+slug: Mozilla/How_to_get_a_process_dump_with_Windows_Task_Manager
+translation_of: Mozilla/How_to_get_a_process_dump_with_Windows_Task_Manager
+---
+<h2 id="介绍">介绍</h2>
+
+<p>当追踪进程为何挂起的时候,获取运行进程的dump是很有用的。这篇文章描述怎样从任务管理器中提取进程dump。 (为了获取thunderbird或者其他产品的dump,用一些指令替换火狐中的一些名称)</p>
+
+<h2 id="起因">起因</h2>
+
+<p>一个内存dump被创建代表了创建者文件时的火狐状态的快照,它包含了,活动tab的URL,历史信息,可能甚至包含密码,依赖于你获取快照的时机,当重现问题的时候,适当创建一个新的说明文件,并且抓取dump。请帮忙做这些。</p>
+
+<h2 id="Requirements" name="Requirements">要求</h2>
+
+<dl>
+ <dt></dt>
+ <dt id="Debugging_Tools_for_Windows">Windows</dt>
+ <dd>为了获取进程度dump,你需要Wndows Vista及以上系统</dd>
+ <dt></dt>
+ <dt id="A_Firefox_nightly_or_release">一个火狐日构建版本或发布版</dt>
+ <dd>你需要火狐的符号表 <a href="/en-US/docs/Using_the_Mozilla_symbol_server" title="Using_the_Mozilla_symbol_server">Mozilla symbol server</a>. 你可以用 <a class="external external-icon" href="https://ftp.mozilla.org/pub/firefox/nightly/">官方日构建版本</a> 或者发布版本. 你可以获取最新的日构建版本在 <a class="external" href="http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/" rel="freelink">http://ftp.mozilla.org/pub/mozilla.o.../latest-trunk/</a>.</dd>
+</dl>
+
+<h2 id="Debugging" name="Debugging">创建dump文件</h2>
+
+<p>确保火狐没有在运行.</p>
+
+<p>运行火狐,重现问题</p>
+
+<p>打开火狐,重现引起问题的步骤.  一旦出现,继续以下步骤</p>
+
+<h3 id="挂起之后">挂起之后</h3>
+
+<ol>
+ <li>打开任务管理器 (CTRL+SHIFT+ESC).</li>
+ <li>在进程列表中查找 Firefox.exe</li>
+ <li>右键 Firefox.exe 选择 "创建dump文件". 任务管理器需要dump写的位置.</li>
+</ol>
+
+<h2 id="See_also" name="See_also">其他</h2>
+
+<ul>
+ <li><a href="/en-US/docs/How_to_get_a_stacktrace_for_a_bug_report" title="/en-US/docs/How_to_get_a_stacktrace_for_a_bug_report">怎样获取一个bug的堆栈 [en-US]</a></li>
+ <li><a class="external external-icon" href="https://docs.microsoft.com/en-us/windows/client-management/generate-kernel-or-complete-crash-dump#manually-generate-a-memory-dump-file">怎样在 Windows Vista 和 in Windows 7 创建一个用户模式下的dump(MSDN)</a></li>
+</ul>
+
+<div id="divCleekiAttrib" style="display: none;"></div>
diff --git a/files/zh-cn/mozilla/implementing_pontoon_in_a_mozilla_website/index.html b/files/zh-cn/mozilla/implementing_pontoon_in_a_mozilla_website/index.html
new file mode 100644
index 0000000000..2964582ca0
--- /dev/null
+++ b/files/zh-cn/mozilla/implementing_pontoon_in_a_mozilla_website/index.html
@@ -0,0 +1,76 @@
+---
+title: 在 Mozilla 项目中使用 Pontoon
+slug: Mozilla/Implementing_Pontoon_in_a_Mozilla_website
+tags:
+ - 本地化
+translation_of: Mozilla/Implementing_Pontoon_in_a_Mozilla_website
+---
+<p><a class="external external-icon" href="https://pontoon.mozilla.org">Pontoon</a> 是一个基于 web 的所见即所得(WYSIWYG)的本地化(l10n)工具。在 Mozilla ,我们都是使用 Pontoon 去本地化众多的 Mozilla 项目和被称为 Gaia 的 Firefox OS app 接口。Pontoon 是一个非常简单、直接的工具,本地化人员只需要很少甚至没有技术能力就可以使用它,这将减少项目本地化版本的发布时间。下面我们来谈谈怎么将 Pontoon 加入到你的 Mozilla 项目里。</p>
+
+<div class="note">
+<p><strong>你想帮忙改进 Pontoon 吗?</strong>了解如何在 <a href="https://github.com/mozilla/pontoon">GitHub</a> 上参与。</p>
+</div>
+
+<div class="note">
+<p><strong>只是开始你项目的 l10n?</strong> 查看 <a href="https://wiki.mozilla.org/L10n:NewProjects">本地化你的项目</a> 上的 wiki。</p>
+</div>
+
+<h2 id="A._本地化你的项目">A. 本地化你的项目</h2>
+
+<p>我们意识到这些已经被认为是 Mozilla 本地化项目的标准<a class="external external-icon" href="https://mozweb.readthedocs.org/en/latest/reference/l10n.html">最佳实践</a> ,但我们觉得还是应该在这里做个小小的提醒。</p>
+
+<ol>
+ <li>确保你的项目支持下列任一种 l10n 框架(<font face="Arial,x-locale-body,sans-serif"><a class="external external-icon" href="https://www.gnu.org/software/gettext/" style="margin: 0px; padding: 0px; border: 0px; text-align: left; color: rgb(61, 126, 154); text-transform: none; text-indent: 0px; letter-spacing: normal; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; white-space: normal;">gettext</a><font color="#b01600">、</font><a class="external external-icon" href="https://docs.oasis-open.org/xliff/xliff-core/v2.0/xliff-core-v2.0.html" style="margin: 0px; padding: 0px; border: 0px; text-align: left; color: rgb(61, 126, 154); text-transform: none; text-indent: 0px; letter-spacing: normal; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; white-space: normal;">XLIFF</a><font color="#b01600">、</font><a class="external external-icon" href="https://projectfluent.org/" style="margin: 0px; padding: 0px; border: 0px; text-align: left; color: rgb(61, 126, 154); text-transform: none; text-indent: 0px; letter-spacing: normal; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; white-space: normal;">L20n</a><font color="#b01600">、</font><a class="external external-icon" href="https://github.com/mozilla-l10n/langchecker/wiki/.lang-files-format" style="margin: 0px; padding: 0px; border: 0px; text-align: left; color: rgb(61, 126, 154); text-transform: none; text-indent: 0px; letter-spacing: normal; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; white-space: normal;">lang</a><font color="#b01600">、</font><a class="external external-icon" href="https://wikipedia.org/wiki/.properties" style="margin: 0px; padding: 0px; border: 0px; text-align: left; color: rgb(61, 126, 154); text-transform: none; text-indent: 0px; letter-spacing: normal; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; white-space: normal;">properties</a><span style="background-color: #ffffff; color: #333333; display: inline !important; float: none; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal;">等等</span></font>).</li>
+ <li>将可本地化的字符串提取到资源文件中。</li>
+ <li>推送源文件到存储库中(<span style="background-color: #ffffff; color: #333333; display: inline !important; float: none; font-family: Arial,x-locale-body,sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal;">SVN、HG、Git</span>)。
+ <ul>
+ <li>各个区域的本地化文件夹必须位于<span style="background-color: #ffffff; color: #000000; display: inline !important; float: none; font-family: Times New Roman; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal;">同一级</span>目录下。区域的本地化需要起名为 <code>templates</code>、<code>en-US</code>、<code>en-us</code> 或者 <code>en</code>。如果存储库中存在同名的多个本地化文件夹,并且文件夹内的文件都是受支持的格式,则只会使用第一个文件夹。这样的话,你可能需要把所有的本地化文件夹都放在一个专用的 <code>locales</code> 目录下。 文件名中请务必不要包含本地化代码。</li>
+ <li>正确的模式:
+ <pre>/locales/{本地化代码}/path/to/file.extension</pre>
+ </li>
+ <li>错误模式:
+ <pre>/locales/{本地化代码}/path/to/file.{本地化代码}.extension</pre>
+ </li>
+ </ul>
+ </li>
+ <li>确保 Pontoon 有存储库的写入权限。
+ <ul>
+ <li>如果用的是 GitHub,在你的项目中添加 <a class="external external-icon" href="https://github.com/mozilla-pontoon">mozilla-pontoon</a> 或者 <a href="https://github.com/orgs/mozilla/teams/pontoon-l10n-robots">pontoon-l10n-robots</a> 作为项目的 collaborator。</li>
+ </ul>
+ </li>
+</ol>
+
+<h2 id="B._optional_Enable_in-page_localization_of_your_web_project">B. (optional) Enable in-page localization of your web project</h2>
+
+<ol>
+ <li>Link a script from your HTML <code>&lt;body&gt;</code> element, so Pontoon can talk to your site, detect content and make it localizable in place. You only need to do this in the environment that will be used for in-page localization, e.g. staging server:
+
+ <ul>
+ <li>
+ <pre id="line1"><span> </span><span>&lt;<span class="start-tag">script</span> <span class="attribute-name">src</span>="<a class="attribute-value">https://pontoon.mozilla.org/pontoon.js</a>"</span><span>&gt;&lt;/<span class="end-tag">script</span>&gt;</span></pre>
+ </li>
+ </ul>
+ </li>
+ <li>If your site uses <a class="external external-icon" href="/zh-CN/docs/Web/HTTP/CSP">CSP</a>,  please make sure that the following is permitted for domain <code>pontoon.mozilla.org</code>:
+ <ol>
+ <li>loading inside iframe</li>
+ <li>loading remote CSS</li>
+ <li>loading remote images</li>
+ </ol>
+ </li>
+ <li>If your site uses the <a class="external external-icon" href="/zh-CN/docs/Web/HTTP/X-Frame-Options">X-Frame-Options</a> header, please make sure loading inside iframe is permitted for domain <code>pontoon.mozilla.org</code>.</li>
+ <li>Make sure your site supports HTTPS. It's free, automated and open. <a href="https://letsencrypt.org/">Let's encrypt</a>!</li>
+</ol>
+
+<h2 id="C._Add_your_project_to_Pontoon">C. Add your project to Pontoon</h2>
+
+<p>Your project is now ready to be set up in Pontoon. Please file a bug in <a class="external external-icon" href="https://bugzilla.mozilla.org/enter_bug.cgi?product=Localization%20Infrastructure%20and%20Tools&amp;component=Administration%20%2F%20Setup">Localization Infrastructure and Tools :: Administration / Setup</a> and provide the following information:</p>
+
+<ul>
+ <li>Project name</li>
+ <li>Repository URL</li>
+ <li>List of requested locales</li>
+ <li>Website URL, including all subpage URLs (only if using in-page localization)</li>
+</ul>
+
+<p>For more details, please get in touch with the <a class="external external-icon" href="mailto:pontoon-team@mozilla.com">Project Management Team</a>.</p>
diff --git a/files/zh-cn/mozilla/index.html b/files/zh-cn/mozilla/index.html
new file mode 100644
index 0000000000..efab963ead
--- /dev/null
+++ b/files/zh-cn/mozilla/index.html
@@ -0,0 +1,8 @@
+---
+title: Mozilla 产品与私有技术
+slug: Mozilla
+translation_of: Mozilla
+---
+<p>以下文章内容,与如何下载并组建 Mozilla 程式的代码相关。此外,也会收录一些有助理解代码如何运作、如何组建 Mozilla 程式的附加元件之类的文章。</p>
+
+<p>{{LandingPageListSubpages}}</p>
diff --git a/files/zh-cn/mozilla/instantbird/index.html b/files/zh-cn/mozilla/instantbird/index.html
new file mode 100644
index 0000000000..67c7285a5f
--- /dev/null
+++ b/files/zh-cn/mozilla/instantbird/index.html
@@ -0,0 +1,62 @@
+---
+title: Instantbird
+slug: Mozilla/Instantbird
+translation_of: Mozilla/Instantbird
+---
+<p><span class="seoSummary"><strong>Instantbird(及时鸟) 是一个和</strong></span>Mozilla很有渊源的<span class="seoSummary"><strong>即时通讯软件</strong>.  当前文档指向的<em>通讯内核</em>文档同样被应用于Thunderbird(雷鸟)</span></p>
+
+<p>及时鸟和火狐浏览器基于相同的技术平台。它源自于谷歌的一个 夏日炎炎爱编程 项目。目的是为了给libpurple(Pidgin 的后端)创建一个 XUL界面。当时及时鸟并没有被认可 。尽管如此,从2007年开始,它不断发展壮大,有了自己的协议,并且已经不再局限于libpurple的前端。</p>
+
+
+
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h2 class="Documentation" id="Documentation" name="Documentation">文档</h2>
+
+ <dl>
+ <dt></dt>
+ <dt></dt>
+ <dt>创建及时鸟</dt>
+ <dd>从comm-central仓库创建及时鸟。</dd>
+ <dt><span class="seoSummary">通讯内核</span></dt>
+ <dd>后端代码,包含了通讯协议的大体文档({{ Interface("prplIProtocol") }} 和 friends)。</dd>
+ <dt>消息格式</dt>
+ <dd>展示了消息的主题相关信息。</dd>
+ <dt>键盘快捷键</dt>
+ <dd>键盘快捷键列表</dd>
+ <dt>
+ <h2 id="链接">链接</h2>
+ </dt>
+ <dt><a href="http://ftp.instantbird.com/instantbird/nightly/latest-trunk/">Latest nightly builds</a>最新创建</dt>
+ <dd>These are generally stable, but expect some breakage from time to time and file <a href="https://bugzilla.mozilla.org/" title="Instantbird:Bugzilla">bugs</a>.大体稳定,但有可能会有bug</dd>
+ </dl>
+
+ <p><span class="alllinks"><a href="/en-US/docs/tag/Instantbird" title="tag/Thunderbird">View All...</a></span></p>
+ </td>
+ <td>
+ <h2 class="Community" id="Community" name="Community">社区</h2>
+
+ <ul>
+ <li><a class="link-irc" href="irc://irc.mozilla.org/instantbird">#instantbird on irc.mozilla.org</a> (for users and developers)</li>
+ <li>Support is handled on the support-instantbird mailing list or on IRC: {{ DiscussionList("support-instantbird", "mozilla.support.instantbird") }}</li>
+ <li>Extension questions can be discussed on the dev-chat group or on IRC: {{ DiscussionList("dev-chat", "mozilla.dev.chat") }}</li>
+ <li>a list of all <a class="external external-icon" href="https://wiki.mozilla.org/Instantbird/CommunicationChannels" title="Thunderbird communication channels">Instantbird communication channels</a></li>
+ </ul>
+
+ <h2 class="Tools" id="Tools" name="Tools">工具</h2>
+
+ <ul>
+ <li><a href="/zh-cn/docs/DOM_Inspector" title="DOM_Inspector">DOM</a> 监视器</li>
+ </ul>
+
+ <h2 class="Related_Topics" id="Related_Topics" name="Related_Topics">相关主题</h2>
+
+ <ul>
+ <li>拓展</li>
+ </ul>
+ </td>
+ </tr>
+ </tbody>
+</table>
diff --git a/files/zh-cn/mozilla/introduction_to_layout_in_mozilla/index.html b/files/zh-cn/mozilla/introduction_to_layout_in_mozilla/index.html
new file mode 100644
index 0000000000..3a2df97afb
--- /dev/null
+++ b/files/zh-cn/mozilla/introduction_to_layout_in_mozilla/index.html
@@ -0,0 +1,360 @@
+---
+title: Mozilla 中对布局的介绍
+slug: Mozilla/Introduction_to_Layout_in_Mozilla
+tags:
+ - cn
+translation_of: Mozilla/Introduction_to_Layout_in_Mozilla
+---
+<h2 id="Overview" name="Overview"><font><font>概要</font></font></h2>
+
+<ul>
+ <li><font><font>基本数据流</font></font></li>
+ <li><font><font>关键数据结构</font></font></li>
+ <li><font><font>详细执行步骤</font></font></li>
+ <li><font><font>渐进模式</font></font></li>
+ <li><font><font>未来高科技会谈</font></font></li>
+ <li><font><font>总结起来,Q&A</font></font></li>
+</ul>
+
+<h2 id="Basic_Data_Flow" name="Basic_Data_Flow"><font><font>基本数据流</font></font></h2>
+
+<ul>
+ <li><font><font>通过网络APIs获取源文档</font></font></li>
+ <li><font><font>在单线程布局引擎中依次执行下面步骤:</font></font>
+ <ul>
+ <li><font><font>解析,计算样式,渲染;重复</font></font></li>
+ <li><font><font>CSS 用于渲染所有的内容</font></font></li>
+ </ul>
+ </li>
+ <li><font><font>理论上,内容与“展示”是相分离的</font></font></li>
+</ul>
+
+<p><img src="/files/464/Gecko_Overview_9.png" style="height: 316px; width: 688px;"></p>
+
+<h2 id="Key_Data_Structures" name="Key_Data_Structures"><font><font>关键数据结构</font></font></h2>
+
+<p><img src="/files/454/Gecko_Overview_10.png" style="height: 122px; width: 638px;"></p>
+
+<ul>
+ <li><font><font>内容节点</font></font>
+
+ <ul>
+ <li><font><font>元素,属性,叶(leaves)</font></font></li>
+ <li><font><font>DOM</font></font></li>
+ </ul>
+ </li>
+ <li><font><font>帧(Frame)</font></font>
+ <ul>
+ <li><font><font>矩形格式</font></font></li>
+ <li><font><font>几何信息</font></font></li>
+ <li><font><font>{{mediawiki.external('0..n')}} 每个内容节点</font></font></li>
+ <li><font><font>从第2个到第n个是“连续到”</font></font></li>
+ </ul>
+ </li>
+ <li><font><font>样式上下文(Style context)</font></font>
+ <ul>
+ <li><font><font>非几何信息</font></font></li>
+ <li><font><font>可由相邻帧共享</font></font></li>
+ <li><font><font>引用计数,从属于帧(frame)</font></font></li>
+ </ul>
+ </li>
+ <li><font><font>视图(View)</font></font>
+ <ul>
+ <li><font><font>裁剪,z顺序,透明度</font></font></li>
+ <li><font><font>{{mediawiki.external('0..1')}} 仅与一个帧(frame)对应, 从属于帧(frame)</font></font></li>
+ </ul>
+ </li>
+ <li><font><font>小工具</font></font>
+ <ul>
+ <li><font><font>本地窗口</font></font></li>
+ <li><font><font>{{mediawiki.external('0..1')}} 仅与一个视图(view)对应,从属于视图(view)</font></font></li>
+ </ul>
+ </li>
+</ul>
+
+<p><img src="/files/455/Gecko_Overview_15.png" style="height: 397px; width: 680px;"></p>
+
+<h2 id="Key_Data_Structures_2" name="Key_Data_Structures_2"><font><font>关键数据结构</font></font></h2>
+
+<ul>
+ <li><em><font><font> document</font></font></em><font><font>对象中包含内容模型,以及一个或多个</font></font><em><font><font>presentations</font></font></em>
+
+ <ul>
+ <li><font><font>通过DOM API 以编程方式暴露在外</font></font></li>
+ </ul>
+ </li>
+ <li><em><font><font>presentation</font></font></em><font><font>包含框架层级关系</font></font>
+ <ul>
+ <li><font><font>帧包含样式上下文,视图,控件</font></font></li>
+ <li><font><font>演示包含的媒体类型,尺寸等</font></font></li>
+ <li><font><font>可能不会直接操控</font></font></li>
+ </ul>
+ </li>
+</ul>
+
+<h2 id="Detailed_Walk-Through" name="Detailed_Walk-Through"><font><font>详细执行步骤</font></font></h2>
+
+<ul>
+ <li><font><font>设置</font></font></li>
+ <li><font><font>内容模型的构建</font></font></li>
+ <li><font><font>框架Frame 的构建</font></font></li>
+ <li><font><font>样式Style 的決議</font></font></li>
+ <li><font><font>回流</font></font></li>
+ <li><font><font>繪畫</font></font></li>
+</ul>
+
+<h2 id="Setting_Up" name="Setting_Up"><font><font>设置</font></font></h2>
+
+<ul>
+ <li><font><font>假設此處您已經熟悉嵌入和network API (doc shell, stream) 的基本知識。</font></font></li>
+ <li><font><font>Content DLL自動註冊一个文档裝載工厂</font></font><em><font><font>(DLF)</font></font></em>
+ <ul>
+ <li><code><font><font>@ mozilla.org /内容查看器工厂/视图; 1类型= text / html的</font></font></code></li>
+ <li><font><font>所有MIME types 都与同一个類nsContentDLF 相对应</font></font></li>
+ </ul>
+ </li>
+ <li><code><font><font>nsDocShell</font></font></code>
+ <ul>
+ <li><font><font>通过  </font></font><code><font><font>nsDSURIContentListener</font></font></code><font><font>接收获取的内容(原始数据)</font></font></li>
+ <li><font><font>调用</font></font><code><font><font>nsIDLF::CreateInstance</font></font></code><font><font>方法,傳遞MIME type给DLF</font></font></li>
+ </ul>
+ </li>
+ <li><font><font>nsContentDLF</font></font>
+ <ul>
+ <li><font><font>创建一个</font></font><code><font><font>nsHTMLDocument</font></font></code><font><font>对象,调用</font></font><code><font><font>StartDocumentLoad</font></font></code>
+ <ul>
+ <li><font><font>创建一个解析器parser,将</font></font><code><font><font>nsIStreamListener</font></font></code><font><font>对象返回给docshell</font></font></li>
+ <li><font><font>创建一个content sink (它会将解析器parser 与文档doucment 相連接)</font></font></li>
+ </ul>
+ </li>
+ <li><font><font>创建一个</font></font><code><font><font>DocumentViewerImpl</font></font></code><font><font>对象,将</font></font><code><font><font>nsIContentViewer</font></font></code><font><font>对象返回给docshell</font></font></li>
+ </ul>
+ </li>
+ <li><code><font><font>DocumentViewerImpl</font></font></code><font><font>创建pres context和pres shell</font></font></li>
+</ul>
+
+<p><img src="/files/456/Gecko_Overview_19.png" style="height: 350px; width: 663px;"></p>
+
+<h2 id="Content_Model_Construction" name="Content_Model_Construction"><font><font>内容模型的构建</font></font></h2>
+
+<ul>
+ <li><font><font>從網絡上通过</font></font><code><font><font>nsIStreamListener::OnDataAvailable</font></font></code><font><font>获取内容</font></font></li>
+ <li><font><font>解析器对内容進行標記&amp;處理;使用  </font></font><em><font><font>parser node</font></font></em><font><font>对象在</font></font><code><font><font>nsIContentSink</font></font></code><font><font>上调用方法</font></font>
+ <ul>
+ <li><font><font>一些緩衝和修正发生在这里</font></font></li>
+ <li><font><code><font>OpenContainer,CloseContainer,AddLeaf</font></code></font></li>
+ </ul>
+ </li>
+ <li><font><font>内容水槽创建並使用附加内容節點</font></font><code><font><font>nsIContent</font></font></code><font><font>接口</font></font>
+ <ul>
+ <li><font><font>内容水槽保持棧的“活”元素</font></font></li>
+ <li><font><font>更多緩衝和修正发生在这里</font></font></li>
+ <li><font><code><font>InsertChildAt,AppendChildTo,RemoveChildAt</font></code></font></li>
+ </ul>
+ </li>
+</ul>
+
+<p><img src="/files/457/Gecko_Overview_21.png" style="height: 179px; width: 662px;"></p>
+
+<h2 id="Frame_Construction" name="Frame_Construction"><font><font>框架Frame 的构建</font></font></h2>
+
+<ul>
+ <li><font><font>内容接收器使用</font></font><code><font><font>nsIDocument</font></font></code><font><font>接口,在内容模型通知ΔS的</font></font>
+
+ <ul>
+ <li><font><code><font>ContentAppended,ContentInserted,ContentRemoved</font></code></font></li>
+ </ul>
+ </li>
+ <li><code><font><font>PresShell</font></font></code><font><font>被註冊作为文件觀察者</font></font>
+ <ul>
+ <li><font><font>接收</font></font><code><font><font>ContentAppended</font></font></code><font><font>等通知</font></font></li>
+ <li><font><font>它傳遞给样式集的对象,誰又将傳遞给帧构造</font></font></li>
+ </ul>
+ </li>
+ <li><font><font>框架构造函數创建帧</font></font>
+ <ul>
+ <li><code><font><font>ConstructFrameInternal</font></font></code><font><font>遞歸散步内容樹,解決作風和创建帧</font></font></li>
+ <li><font><font>或者通过標籤创建</font></font><code><font><font>(&lt; </font><font>選擇</font></font></code><font><font>&gt;)</font><font>或顯示类型</font><font>(&lt;P&gt;)</font></font></li>
+ </ul>
+ </li>
+ <li><font><font>帧管理者保持映射從内容到框架</font></font></li>
+</ul>
+
+<p><img src="/files/458/Gecko_Overview_23.png" style="height: 359px; width: 697px;"></p>
+
+<h2 id="Style_Resolution" name="Style_Resolution"><font><font>Style 選定</font></font></h2>
+
+<ul>
+ <li><font><font>计算依據適用於框架的内容節點样式規則文體信息</font></font></li>
+ <li><font><font>分成不同的结构样式数据</font></font>
+ <ul>
+ <li><font><font>顯示,能見度,字體,顏色,背景,...</font></font></li>
+ <li><font><font>繼承与復位</font></font></li>
+ </ul>
+ </li>
+ <li><font><font>样式上下文对象是一个占位符部分计算文體数据</font></font>
+ <ul>
+ <li><font><font>样式数据懶洋洋地计算,因为它要求</font></font></li>
+ </ul>
+ </li>
+</ul>
+
+<h2 id="Reflow" name="Reflow"><font><font>回流</font></font></h2>
+
+<ul>
+ <li><font><font>遞歸计算幾何</font><em><font>(x,Ÿ,W¯¯,^</font></em><font> </font><em><font>h)为框架,视图和小部件</font></em></font>
+
+ <ul>
+ <li><font><font>鑑於“根帧”计算(W&H約束</font><em><font>x,ÿ,W¯¯,^</font></em><font> </font><em><font>h)为所有兒童</font></em></font></li>
+ <li><font><font>通过約束傳播“向下</font></font><code><font><font>”nsHTMLReflowState</font></font></code></li>
+ <li><font><font>所需的大小返回“向上”通过</font></font><code><font><font>nsHTMLReflowMetrics</font></font></code></li>
+ </ul>
+ </li>
+ <li><font><font>基本模式</font></font>
+ <ul>
+ <li><font><font>父框架初始化子回流狀態(可</font><em><font>W¯¯,^ </font></em><font>h); </font><font>地方子帧</font><font>(x,ÿ); </font><font>调用孩子的</font><code><font>回流</font></code><font>方法</font></font></li>
+ <li><font><font>子帧计算所需的</font><em><font>(W¯¯,^</font></em><font> </font><em><font>h),通过回流焊指標回報</font></em></font></li>
+ <li><font><font>家長外形尺寸为子框架和观点的基礎上孩子的指標</font></font></li>
+ </ul>
+ </li>
+ <li><font><font>注:很多</font></font><em><font><font>並不</font></font></em><font><font>這樣工作!</font><font>(表,塊,XUL盒)</font></font></li>
+</ul>
+
+<h2 id="Reflow_2" name="Reflow_2"><font><font>回流</font></font></h2>
+
+<ul>
+ <li><font><font>“環球”回流</font></font>
+
+ <ul>
+ <li><em><font><font>最初,調整大小,风格變化</font></font></em></li>
+ <li><font><font>通过立即處理</font></font><code><font><font>PresShell</font></font></code><font><font>方法</font></font></li>
+ </ul>
+ </li>
+ <li><font><font>增量回流</font></font>
+ <ul>
+ <li><font><font>針对特定的帧</font></font></li>
+ <li><em><font><font>臟</font></font></em><font><font>,</font></font><em><font><font>内容改變</font></font></em><font><font>,</font></font><em><font><font>风格改變了</font></font></em><font><font>,</font></font><em><font><font>用戶自定義</font></font></em></li>
+ <li><code><font><font>nsHTMLReflowCommand</font></font></code><font><font>对象封裝信息</font></font></li>
+ <li><font><font>排隊和異步處理</font></font><code><font><font>,nsIPressShell </font><font>:: </font></font></code><code><font><font>AppendReflowCommand,ProcessReflowCommands</font></font></code></li>
+ </ul>
+ </li>
+</ul>
+
+<h2 id="Incremental_Reflow" name="Incremental_Reflow"><font><font>增量回流</font></font></h2>
+
+<p><img src="/files/459/Gecko_Overview_28.png" style="height: 331px; width: 319px;"></p>
+
+<ul>
+ <li><font><font>遞歸下降到目標</font></font><em><font><font>恢復回流狀態</font></font></em>
+
+ <ul>
+ <li><font><font>兒童rs.reason设置为</font></font><em><font><font>增量</font></font></em></li>
+ </ul>
+ </li>
+</ul>
+
+<h2 id="Incremental_Reflow_2" name="Incremental_Reflow_2"><font><font>增量回流</font></font></h2>
+
+<p><img src="/files/460/Gecko_Overview_29.png" style="height: 331px; width: 319px;"></p>
+
+<ul>
+ <li><font><font>流程回流“正常”的目標框架</font></font>
+
+ <ul>
+ <li><font><font>兒童rs.reason一套基於RC的</font></font><em><font><font>类型</font></font></em></li>
+ </ul>
+ </li>
+</ul>
+
+<h2 id="Incremental_Reflow_3" name="Incremental_Reflow_3"><font><font>增量回流</font></font></h2>
+
+<p><img src="/files/461/Gecko_Overview_30.png" style="height: 332px; width: 319px;"></p>
+
+<ul>
+ <li><em><font><font>傳播損害</font></font></em><font><font>到“在流動”帧之后</font></font></li>
+</ul>
+
+<h2 id="Incremental_Reflow_4" name="Incremental_Reflow_4"><font><font>增量回流</font></font></h2>
+
+<p><img src="/files/462/Gecko_Overview_31.png" style="height: 331px; width: 319px;"></p>
+
+<ul>
+ <li><font><font>多次回流焊命令批處理</font></font>
+
+ <ul>
+ <li><code><font><font>nsReflowPath</font></font></code><font><font>維持目標帧的一棵樹</font></font></li>
+ <li><font><font>攤銷狀態的恢復和損傷擴展成本</font></font></li>
+ </ul>
+ </li>
+</ul>
+
+<h2 id="Painting" name="Painting"><font><font>繪畫</font></font></h2>
+
+<ul>
+ <li><font><font>當回流繼續通过帧層次结构,區域</font></font><em><font><font>無效</font></font></em><font><font>通过</font></font><code><font><font>nsIViewManager ::更新视图</font></font></code></li>
+ <li><font><font>除非</font></font><em><font><font>直接</font></font></em><font><font>的,無效的區域合併,並通过操作系統的異步處理</font></font><em><font><font>揭露</font></font></em><font><font>事件</font></font></li>
+ <li><font><font>本機暴露事件分派到小部件; </font><font>小部件委託给视图管理器</font></font></li>
+ <li><font><font>查看經理描繪的意見后到前,调用</font></font><code><font><font>PresShell</font></font></code><font><font>的</font></font><code><font><font>畫圖</font></font></code><font><font>方法</font></font></li>
+ <li><code><font><font>PresShell ::油漆</font></font></code><font><font>遍歷從视图帧; </font><font>将调用</font></font><code><font><font>nsIFrame ::油漆</font></font></code><font><font>每個</font></font><em><font><font>層</font></font></em></li>
+</ul>
+
+<h2 id="Incrementalism" name="Incrementalism"><font><font>漸進</font></font></h2>
+
+<ul>
+ <li><font><font>單線程</font></font>
+
+ <ul>
+ <li><font><font>簡單(無鎖)</font></font></li>
+ <li><font><font>不能離開事件隊列無人值守</font></font></li>
+ </ul>
+ </li>
+ <li><font><font>内容建設開卷“隨意”</font></font>
+ <ul>
+ <li><font><font>解析器和内容接收器做一些緩衝</font></font></li>
+ <li><font><font>内容散熱器具有“通知限制”</font></font></li>
+ <li><font><font>效率与響應速度的權衡</font></font></li>
+ </ul>
+ </li>
+ <li><font><font>框架结构運行完成</font></font></li>
+ <li><font><font>CSS解析運行完成</font></font></li>
+ <li><font><font>回流焊運行完成(主要)</font></font></li>
+ <li><font><font>繪畫運行完成</font></font></li>
+</ul>
+
+<p><img src="/files/463/Gecko_Overview_34.png" style="height: 380px; width: 694px;"></p>
+
+<h2 id="Future_.28.3F.29_Tech_Talks" name="Future_.28.3F.29_Tech_Talks"><font><font>未来(?)技术讲座</font></font></h2>
+
+<ul>
+ <li><font><font>内容模型和DOM - </font><em><font>jst,jkeiser</font></em></font></li>
+ <li><font><font>解析器和内容接收器(ESP無效的内容) - </font></font><em><font><font>harishd</font></font></em></li>
+ <li><font><font>事件- </font></font><em><font><font>薩里</font></font></em><font><font>,</font></font><em><font><font>條既納</font></font></em></li>
+ <li><font><font>塊和行回流焊- </font><em><font>沃特森,dbaron</font></em></font></li>
+ <li><font><font>表回流焊- </font></font><em><font><font>karnaze</font></font></em></li>
+ <li><font><font>窗體控件- </font><em><font>棒,礪石</font></em></font></li>
+ <li><font><font>风格解析和規則樹- </font></font><em><font><font>dbaron</font></font></em></li>
+ <li><font><font>视图,窗口小部件,和繪畫- </font></font><em><font><font>大鵬</font></font></em><font><font> </font></font><em><font><font>,kmcclusk</font></font></em></li>
+ <li><font><font>編輯器- </font><em><font>健,Jfrancis</font></em></font></li>
+ <li><font><font>XUL和箱的佈局- </font></font><em><font><font>休伊特</font></font></em><font><font>,</font></font><em><font><font>本</font></font></em></li>
+ <li><font><font>XBL - </font></font><em><font><font>休伊特</font></font></em><font><font>,</font></font><em><font><font>本</font></font></em></li>
+</ul>
+
+<h2 id="Conclusion" name="Conclusion"><font><font>最后</font></font></h2>
+
+<ul>
+ <li><font><font>数据流</font></font></li>
+ <li><font><font>关键数据结构</font></font></li>
+ <li><font><font>详细演练</font></font></li>
+ <li><font><font>渐进</font></font></li>
+ <li><font><font>Q&A?</font></font></li>
+</ul>
+
+<div class="originaldocinfo">
+<h2 id="Original_Document_Information" name="Original_Document_Information"><font><font>原始文档信息</font></font></h2>
+
+<ul>
+ <li><a class="link-mailto" href="mailto:waterson@netscape.com"><font><font>作者:克里斯·沃特森</font></font></a></li>
+ <li><font><font>最后更新日期:2002年6月10日,</font></font></li>
+ <li><font><font>版权信息:部分内容由mozilla贡献者制作:1998-2007;</font><font>内容受《知识共享许可协议》保护。|</font><a href="http://www.mozilla.org/foundation/licensing/website-content.html"><font>详细信息</font></a></font></li>
+</ul>
+</div>
diff --git a/files/zh-cn/mozilla/ipdl/creating_a_new_protocol/index.html b/files/zh-cn/mozilla/ipdl/creating_a_new_protocol/index.html
new file mode 100644
index 0000000000..d256886913
--- /dev/null
+++ b/files/zh-cn/mozilla/ipdl/creating_a_new_protocol/index.html
@@ -0,0 +1,32 @@
+---
+title: 创建一个新的协议
+slug: Mozilla/IPDL/Creating_a_New_Protocol
+translation_of: Mozilla/IPDL/Creating_a_New_Protocol
+---
+<p><font><font>这是有关如何向构建中添加新IPDL协议的详细信息的快速入门。</font><font>您应该首先</font></font><a href="https://developer.mozilla.org/en/IPDL/Tutorial" title="zh / IPDL /教程"><font><font>了解IPDL的工作原理</font></font></a><font><font>!</font></font></p>
+
+<h3 id="创建协议文件"><font><font>创建协议文件</font></font></h3>
+
+<p><font><font>协议文件应与实现它的代码位于同一目录中。</font><font>协议名称以P开头,并且协议文件必须命名为PProtocolName.ipdl。</font><font>IPDL协议应位于mozilla命名空间或子命名空间中。</font></font></p>
+
+<p><font><font>要将文件连接到构建,需要将IPDL文件添加到最近的moz.build文件中的IPDL_SOURCES。</font><font>有关</font><font>示例,</font><font>请参见</font></font> <a href="http://mxr.mozilla.org/mozilla-central/source/dom/ipc/moz.build?rev=8a595b6c5750#71">dom/ipc/moz.build</a> <font><font>。</font></font></p>
+
+<h3 id="协议层次结构"><font><font>协议层次结构</font></font></h3>
+
+<p><font><font>除非您正在从事某些特殊项目,否则您的协议将适合多进程插件或选项卡的协议层次结构。</font><font>插件的顶级协议是PPluginModule。</font><font>选项卡的顶级协议是PContent。</font><font>您应该知道哪种协议将管理新协议,以及会导致哪些生存期问题。</font><font>如有疑问,请在#content频道中询问IRC。</font></font></p>
+
+<h3 id="建立新协议"><font><font>建立新协议</font></font></h3>
+
+<p><font><font>要构建新的协议声明并生成标头,请在</font></font>ipc/ipdl<font><font>中创建:</font></font></p>
+
+<pre><code>make -C objdir/ipc/ipdl</code></pre>
+
+<p><font><font>如果存在协议级别的错误,则IPDL编译器将打印相关的错误消息并停止。</font><font>要查看生成的标题,请在中查看</font></font><code><em>objdir</em>/ipc/ipdl/_ipdlheaders</code><font><font>。</font></font></p>
+
+<h3 id="创建实现"><font><font>创建实现</font></font></h3>
+
+<p><font><font>C ++实现从IPDL生成的抽象类PNewProtocolParent和PNewProtocolChild继承。</font><font>它必须实现抽象方法以在每一侧接收适当的消息。</font><font>可以从生成的PNewProtocolParent.h和PNewProtocolChild.h标头中读取方法签名。</font></font></p>
+
+<h3 id="编写测试"><font><font>编写测试</font></font></h3>
+
+<p><font><font>PBrowser管理的协议必须使用带有的mochitest-chrome测试框架进行测试</font></font><code>&lt;browser remote="true"&gt;</code><font><font>。</font><font>出于测试目的,可以在JPW包装器上使用同步调用。</font><font>使用xpcshell测试框架可以测试与特定窗口无关的协议,该框架在Electrolysis中具有其他原语,用于在内容过程中启动和运行JS命令。</font></font></p>
diff --git a/files/zh-cn/mozilla/ipdl/index.html b/files/zh-cn/mozilla/ipdl/index.html
new file mode 100644
index 0000000000..051c353f2c
--- /dev/null
+++ b/files/zh-cn/mozilla/ipdl/index.html
@@ -0,0 +1,33 @@
+---
+title: IPC Protocol Definition Language (IPDL)
+slug: Mozilla/IPDL
+tags:
+ - IPC
+ - IPDL
+ - NeedsTranslation
+ - PBackground
+ - TopicStub
+translation_of: Mozilla/IPDL
+---
+<p class="summary">IPDL是“IPC(进程间通信)协议定义语言”的缩写,是一种特定于Mozilla的语言,允许C++代码以有组织和安全的方式在进程或线程之间传递消息。Firefox中多进程插件和选项卡的所有消息都是用IPDL语言声明的。</p>
+
+<h2 id="当前文档">当前文档</h2>
+
+<ul>
+ <li><a href="/zh-CN/docs/Mozilla/IPDL/入门">IPDL 入门</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/IPDL/Creating_a_New_Protocol">快速开始:创建一个新的协议</a></li>
+ <li><a href="/en-US/docs/Mozilla/IPDL/Extending_a_Protocol">Quick Start: Extending a Protocol</a></li>
+ <li><a href="/en-US/docs/Mozilla/IPDL/Type_Serialization">IPDL Type Serialization</a></li>
+ <li><a href="/en-US/docs/Mozilla/IPDL/Best_Practices">IPDL Best Practices</a></li>
+ <li><a href="/en-US/docs/Mozilla/IPDL/Glossary">IPDL Glossary</a></li>
+ <li><a href="/en-US/docs/Mozilla/IPDL/PBackground">PBackground</a></li>
+</ul>
+
+<h2 id="Future_planned_docs">Future planned docs</h2>
+
+<ul>
+ <li><a href="/en-US/docs/IPDL/Reference" title="en-US/docs/IPDL/Reference">IPDL Language Reference</a></li>
+ <li><a href="/en-US/docs/IPDL/Error_Handling" title="en-US/docs/IPDL/Error Handling">Error and shutdown handling in IPDL protocols</a></li>
+ <li><a href="/en-US/docs/IPDL/Processes_and_Threads" title="en-US/docs/IPDL/Processes and Threads">How IPDL Uses Processes, Threads, and Sockets</a></li>
+ <li><a href="/en-US/docs/IPDL/Shared_Memory" title="en-US/docs/IPDL/Shared Memory">IPDL Shared Memory</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/ipdl/入门/index.html b/files/zh-cn/mozilla/ipdl/入门/index.html
new file mode 100644
index 0000000000..b710a91971
--- /dev/null
+++ b/files/zh-cn/mozilla/ipdl/入门/index.html
@@ -0,0 +1,670 @@
+---
+title: IPDL入门
+slug: Mozilla/IPDL/入门
+translation_of: Mozilla/IPDL/Tutorial
+---
+<p>IPDL – IPC Inter-process communication Protocol Definition Language,全称的意思是进程间通信协议定义语言。这是Mozilla特有的一种使C++代码能以有组织地、安全地在进程或者线程间传递信息的语言。Firefox中有关多进程插件和选项卡的所有消息均以IPDL语言声明。</p>
+
+<div class="note">如果想尝试添加一个新的IPDL协议, 参考 <a href="/zh-CN/docs/Mozilla/IPDL/Creating_a_New_Protocol">创建一个新的协议</a>.</div>
+
+<p>所有的IPDL信息都是由 <strong>父端</strong> 和 <strong>子端</strong> 发送,二者也被称为 <strong>角色</strong>。 IPDL <strong>协议 </strong>声明了 角色间该如何进行通信:它声明了角色间可能发送的消息,以及描述了何时允许发送消息的状态机。</p>
+
+<p>父端角色通常是对话中更持久的一方:</p>
+
+<table>
+ <caption>父端/子端角色</caption>
+ <thead>
+ <tr>
+ <th scope="col"></th>
+ <th scope="col">父端</th>
+ <th scope="col">子端</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th scope="row">IPC 选项卡</th>
+ <td>Chrome 进程</td>
+ <td>Content 进程</td>
+ </tr>
+ <tr>
+ <th scope="row">IPC 插件</th>
+ <td>Content 进程</td>
+ <td>Plugin 进程</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>每个协议都会在单独的文件中声明。IPDL 编译器会据每个IPDL 协议中生成一些 C++头文件。生成的代码帮忙解决了 底层通信层(套接字和管道)的一些细节、构造和发送消息,以及确保所有角色遵守其规范,并处理一些错误情况。以下 IPDL代码 定义了 浏览器角色 和 插件角色 的非常基本的交互:</p>
+
+<pre><strong>async protocol</strong> PPlugin
+{
+<strong>child:</strong>
+  <strong>async</strong> Init(nsCString pluginPath);
+ <strong>async</strong> Shutdown();
+
+<strong>parent:</strong>
+ <strong>async</strong> Ready();
+};
+</pre>
+
+<p>这段代码声明了 <code>PPlugin</code> 协议。 有两条消息从 父端发送到了子端, <code>Init()</code> 和<code>Shutdown()</code>。 另外还有一条消息从子端发送到了父端, <code>Ready()</code>。</p>
+
+<div class="note">IPDL 协议要以字母 P开头. 声明了该协议的文件也必须是对应的名称,如 PPlugin.ipdl.</div>
+
+<h3 id="生成的_C_代码"><span class="mw-headline">生成的 C++ 代码</span></h3>
+
+<p>PPlugin.ipdl 被编译后会在构建树目录 ipc/ipdl/_ipdlheaders/ 生成头文件<code>PPluginParent.h</code>,和  <code>PPluginChild.h</code>。PPluginParent 和 PPluginChild 都是待实现的抽象类. 每个传出消息都是可以调用的C++方法。每个传入的消息都是必须实现的纯虚拟C++^方法:</p>
+
+<pre>class PPluginParent
+{
+public:
+ bool SendInit(const nsCString&amp; pluginPath) {
+ // generated code to send an Init() message
+ }
+
+ bool SendShutdown() {
+ // generated code to send a Shutdown() message
+ }
+
+protected:
+ /**
+ * A subclass of PPluginParent must implement this method to handle the Ready() message.
+ */
+  bool RecvReady() = 0;
+};
+
+class PPluginChild
+{
+protected:
+ bool RecvInit(const nsCString&amp; pluginPath) = 0;
+ bool RecvShutdown() = 0;
+
+public:
+ bool SendReady() {
+ // generated code to send a Ready() message
+ }
+};
+</pre>
+
+<p>这些父级和子级抽象类负责所有的 “协议层” 问题, 如序列化数据,发送和接收消息,以及检查协议安全性。实现者需要做的是创建子类来执行每条消息中涉及的实际工作。下面是浏览器实现者 使用 PPluginParent 的一个非常简单的方法示例。</p>
+
+<pre>class PluginParent : public PPluginParent
+{
+public:
+ PluginParent(const nsCString&amp; pluginPath) {
+ // launch child plugin process
+ SendInit(pluginPath);
+ }
+
+ ~PluginParent() {
+ SendShutdown();
+ }
+
+protected:
+ bool RecvReady() {
+ mObservers.Notify("ready for action");
+ }
+};
+</pre>
+
+<p>下面是C++实现者在增加插件过程中如何使用PPluginChild的代码:</p>
+
+<pre>class PluginChild : public PPluginChild
+{
+protected:
+ void RecvInit(const nsCString&amp; pluginPath) {
+ mPluginLibrary = PR_LoadLibrary(pluginPath.get());
+ SendReady();
+ }
+ void RecvShutdown() {
+ PR_UnloadLibrary(mPluginLibrary);
+ }
+
+private:
+ PRLibrary* mPluginLibrary;
+};
+</pre>
+
+<p>调用子流程并将这些协议角色 关联到我们的IPC “传输层” 超出了本文档的范围。有关更多详细信息,请参见<a href="https://wiki.developer.mozilla.org/en-US/docs/IPDL/Processes_and_Threads"> IPDL进程和线程</a>。<br>
+ <br>
+ 因为 协议消息 被表示为C++方法,所以很容易忘记它们实际上是异步消息:默认情况下,C++方法将在消息被分发之前立即返回。<br>
+ <br>
+ Recv* 方法的参数(本例中的 <em>const nsCString&amp; pluginPath</em>) 是对临时对象的引用,因此如果需要保留它们的数据,请复制它们。</p>
+
+<h3 id="方向"><span class="mw-headline">方向</span></h3>
+
+<p>每种消息类型都包括一个“方向”。消息方向 是指 消息是可以从父端 发送到 子端,抑或是从子端发送到父端,或者两种方式都可以。有三个关键字充当了方向说明符。上面介绍的 <strong>child</strong>,第二个是 <strong>parent</strong>,这意味着在 parent 标签下声明的消息只能从 子端发送到父端。第三个是<strong>both</strong>,这意味着声明的消息可以进行双向发送。下面的简要示例 显示了如何使用这些 说明符,以及这些说明符如何 影响 生成的 抽象角色类。</p>
+
+<pre>// PDirection.ipdl
+<strong>async protocol</strong> PDirection
+{
+<strong>child:</strong>
+  <strong>async</strong> Foo(); // can be sent from-parent-to-child
+<strong>parent:</strong>
+ <strong>async</strong> Bar(); // can be sent from-child-to-parent
+<strong>both:</strong>
+  <strong>async</strong> Baz(); // can be sent both ways
+};
+</pre>
+
+<pre>// PDirectionParent.h
+class PDirectionParent
+{
+protected:
+ virtual void RecvBar() = 0;
+ virtual void RecvBaz() = 0;
+
+public:
+ void SendFoo() { /* boilerplate */ }
+ void SendBaz() { /* boilerplate */ }
+};
+</pre>
+
+<pre>// PDirectionChild.h
+class PDirectionChild
+{
+protected:
+ virtual void RecvFoo() = 0;
+ virtual void RecvBaz() = 0;
+
+public:
+ void SendBar() { /* boilerplate */ }
+ void SendBaz() { /* boilerplate */ }
+};
+</pre>
+
+<p>您可以在协议规范中多次使用  <code>child</code>, <code>parent</code>, 和 <code>both</code>标签。它们的行为类似于C++中的<code>public</code>, <code>protected</code>, 和 <code>private </code>标签。</p>
+
+<h3 id="参数"><span class="mw-headline">参数</span></h3>
+
+<p>消息声明允许任意数量的 <strong>参数</strong>。参数指定与消息一起发送的数据。它们的值由 发送方 序列化,由 接收方 反序列化。IPDL支持内置 和 自定义基元类型,以及 联合union 和数组。</p>
+
+<div>
+<div>
+<div class="f">
+<p>内置的简单类型包括C++整型(bool,char,int,double) 和 XPCOM字符串类型(nsString,nsCString)。IPDL会自动导入这些类型,因为它们很常见,而且base IPC 库知道如何序列化和反序列化这些类型。有关自动导入类型的最新列表,请参见 <code>ipc/ipdl/ipdl/builtin.py</code> 。</p>
+
+<p>角色 可以作为参数传递。C++签名将在一侧接受 PProtocolParent*,在另一侧将其转换为PProtocolChild*。</p>
+
+<h4 id="Maybe_类型">Maybe 类型</h4>
+
+<p>如果要传递可能未定义的参数,可以在类型名称后添加<code>?</code> 后缀。接下来你就可以传递 <code>mozilla::Maybe </code>对象而不是具体的值。</p>
+
+<pre>protocol PMaybe
+{
+child:
+ async Maybe(nsCString? maybe);
+};
+</pre>
+
+<h4 id="自定义基本类型">自定义基本类型</h4>
+
+<p>当需要发送 IPDL内置类型 之外的 类型数据 时,可以在IPDL规范中添加  <code>using </code>声明。您的C++代码必须提供 <a href="https://wiki.developer.mozilla.org/en-US/docs/IPDL/Type_Serialization">自定义序列化程序和反序列化 </a>程序。</p>
+
+<pre><strong>using</strong> mozilla::plugins::NPRemoteEvent;
+
+<strong>sync protocol</strong> PPluginInstance
+{
+<strong>child:</strong>
+  <strong>async</strong> HandleEvent(NPRemoteEvent);
+};
+</pre>
+
+<h4 id="联合Union">联合Union</h4>
+
+<p>IPDL 内置支持声明 联合Union 类型。</p>
+
+<pre><strong>using</strong> struct mozilla::void_t from "ipc/IPCMessageUtils.h";
+
+<strong>union</strong> Variant
+{
+ void_t;
+ bool;
+ int;
+ double;
+ nsCString;
+ PPluginScriptableObject;
+};</pre>
+
+<p>此 联合Union 生成一个C++接口,其内容如下:</p>
+
+<pre><strong style="font-weight: bold;">struct</strong> Variant
+{
+ enum Type {
+ Tvoid_t, Tbool, Tint, Tdouble, TnsCString, TPPlugionScriptableObject
+ };
+ Type type();
+ void_t&amp; get_void_t();
+ bool&amp; get_bool();
+ int&amp; get_int();
+ double&amp; get_double();
+ nsCString&amp; get_nsCString();
+ PPluginScriptableObject* get_PPluginScriptableObject();
+};
+</pre>
+
+<p>Union.type() 可用于确定 IPDL 消息处理程序中接收到的联合Union 类型,其余函数 给予对其内容的访问权限。要初始化 联合Union ,只需为其分配一个有效值,如下所示:</p>
+
+<pre>aVariant = false;
+</pre>
+
+<h4 id="结构_Struct">结构 Struct</h4>
+
+<p>IPDL 具有对 可序列化数据类型 的 任意集合 的内置支持。</p>
+
+<pre><strong>struct</strong> NameValuePair
+{
+ nsCString name;
+ nsCString value;
+};</pre>
+
+<p>在实现代码中,可以像这样创建和使用这些结构:</p>
+
+<pre>NameValuePair entry(aString, anotherString);
+foo(entry.name(), entry.value()); // Named accessor functions return references to the members
+</pre>
+
+<h4 id="数组_Array">数组 Array</h4>
+
+<p>IPDL具有简单的数组语法:</p>
+
+<pre>InvokeMethod(nsCString[] args);</pre>
+
+<p>·在C++中,这被转换为 <a href="https://wiki.developer.mozilla.org/en-US/docs/XPCOM_array_guide#nsTArray.3cT.3e" title="en-US/docs/XPCOM array guide#nsTArray.3cT.3e">nsTArray</a> 引用:</p>
+
+<pre>virtual bool RecvInvokeMethod(nsTArray&lt;nsCString&gt;&amp; args);
+</pre>
+</div>
+</div>
+</div>
+
+<p>如果在单独的  <em>.ipdlh</em> 文件中定义了  IPDL生成的数据结构,则可以在多个 协议 中使用它们。这些文件必须像常规 <em>.ipdl</em> 文件一样添加到<em>ipdl.mk</em>  makefile中,并且它们使用相同的语法(除了它们不能声明协议)。要使用  <em>Foo.ipdlh </em>中定义的结构,请按如下方式包含它。</p>
+
+<pre>// in a .ipdl file
+<strong>include</strong> Foo;
+</pre>
+
+<h3 id="同步和RPC消息传递">同步和RPC消息传递</h3>
+
+<p>到目前为止,所有消息都是异步的。消息发送出去的同时,C++方法会立即返回。但是,如果我们希望等待消息被处理,或者从消息中获取返回值,该怎么办呢?</p>
+
+<p>在 IPDL 中,有三种不同的语义:</p>
+
+<ol>
+ <li><strong>异步</strong>(<strong>asynchronous</strong>) 语义;发送方未被阻塞。</li>
+ <li>等待,直到接收方确认它收到了消息。我们称之为 <strong>同步(synchronous</strong> <strong>) </strong>语义,因为发送方阻塞,直到接收方接收到消息并发回回复。消息可能具有返回值。</li>
+ <li> <strong>rpc </strong>语义是同步语义的变体,见下文。</li>
+</ol>
+
+<p>请注意,父端 可以向 子端 发送消息,反之亦然,因此上述三种情况下的“发送者”和“接收者”可以是父端  或 子端 。消息传递语义以 同样的方式 应用于两个方向。因此,例如在从 子端 到 父端的同步语义中, 子端 将阻塞,直到 父端 接收到消息 和 响应到达为止,而在从父端 到 子端 的异步语义中,父端 不会阻塞。</p>
+
+<p>创建插件实例时,浏览器应该阻塞,直到实例创建完成,并且需要插件返回的一些信息:</p>
+
+<pre><strong>sync protocol</strong> PPluginInstance
+{
+<strong>child:</strong>
+    <strong>sync</strong> Init() <strong>returns</strong> (bool windowless, bool ok);
+};
+</pre>
+
+<p>我们在插件协议中添加了两个新的关键字,<strong>sync </strong>和 <strong>returns </strong>。<strong>同步</strong>(<strong>sync)  </strong>将消息标记为正在同步发送。<strong>returns </strong>关键字 标识了 在对消息的响应中 返回的值列表的开始。</p>
+
+<h4 id="异步消息的返回值">异步消息的返回值</h4>
+
+<p><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1313200">Bug 1313200</a> 引入了 将 <strong>returns</strong>  与 <strong>async</strong><strong>异步 </strong>消息一起使用的能力:</p>
+
+<pre><strong>protocol</strong> PPluginInstance
+{
+<strong>child:
+ async</strong> AsyncInit() <strong>returns</strong> (bool windowless, bool ok);
+ <strong>async </strong>OtherFunction() <strong>returns</strong> (bool ok);
+};
+</pre>
+
+<p>对于调用方,每个带有 <strong>returns</strong> 块的 <strong>async </strong>异步消息 <code>MessageName </code>都将为 <code>SendMessageName </code>生成两个重载。第一个重载将有一个 resolve回调 和 reject 回调 作为其最后两个参数;第二个重载将没有任何 <em>额外 </em>参数,但它将返回 <code>PProtocol{Parent,Child}::MessageNamePromise </code>,这是一个 <code>MozPromise</code>类型。</p>
+
+<p>第一个重载的 resolve 回调 以及 <code>MozPromise </code>的<code>Then()</code> 方法的成功回调都只有一个参数。如果消息只返回<strong>returns</strong> 一个值 (例如上面的<code>OtherFunction</code>),则对于resolve 和success回调,参数都是<strong>returns</strong>返回值本身(作为<code>const</code>常量引用);如果消息<strong>returns</strong> 返回多个值(例如上面的<code>InitAsync</code>),则对于resolve 和success 回调,参数都是返回值的元组(例如,<code>Tuple&lt;bool, bool&gt;</code>)。另一方面, reject/failure  回调接受 <code>mozilla::ipc::ResponseRejectReason&amp;&amp;</code>,并在发生致命错误(如IPC错误)时调用。因此,除了 callback/promise 样式响应处理之外,这两个重载在功能上是等效的。</p>
+
+<p>生成的C++代码如下:</p>
+
+<pre>class PPluginInstanceParent
+{
+ public:
+ typedef MozPromise&lt;Tuple&lt;bool, bool&gt; ResponseRejectReason, true&gt; AsyncInitPromise;
+ typedef MozPromise&lt;bool, ResponseRejectReason, true&gt; OtherFunctionPromise;
+
+ void
+ SendAsyncInit(mozilla::ipc::ResolveCallback&lt;Tuple&lt;bool, bool&gt;&gt;&amp;&amp; aResolve,
+ mozilla::ipc::RejectCallback&amp;&amp; aReject);
+
+ RefPtr&lt;AsyncInitPromise&gt;
+ SendAsyncInit();
+
+ void
+ SendOtherFunction(mozilla::ipc::ResolveCallback&lt;bool&gt;&amp;&amp; aResolve,
+ mozilla::ipc::RejectCallback&amp;&amp; aReject);
+
+ RefPtr&lt;OtherFunctionPromise&gt;
+ SendOtherFunction();
+};
+</pre>
+
+<p>在被调用方,除了声明的消息参数外,<code>RecvMessageName </code>将有一个 <code>MessageNameResolver&amp;&amp; </code>函数作为其最终(附加)参数。调用此函数将 初始化 调用传递给<code>SendMessageName</code>的回调 或 <code>SendMessageName</code>返回的promise解析。<br>
+ <br>
+ 生成的C++将产生如下所示的结果:</p>
+
+<pre>class PPluginInstanceChild
+{
+ public:
+ typedef std::function&lt;void(Tuple&lt;const bool&amp;, const bool&amp;&gt;)&gt; AsyncInitResolver;
+ typedef std::function&lt;void(const bool&amp;)&gt; OtherFunctionResolver;
+
+ virtual mozilla::ipc::IPCResult
+ RecvAsyncInit(AsyncInitResolver&amp;&amp; aResolve) = 0;
+
+ virtual mozilla::ipc::IPCResult
+ RecvOtherFunction(OtherFunctionResolver&amp;&amp; aResolver) = 0
+};
+</pre>
+
+<p>为了使程序员更容易注意到阻塞的本质,Synchronous和RPC消息的C++方法名称是不同的:</p>
+
+<table>
+ <thead>
+ <tr>
+ <th scope="col"></th>
+ <th scope="col">发送方</th>
+ <th scope="col">接收方</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th scope="row">async/sync</th>
+ <td>Send<em>MessageName</em></td>
+ <td>Recv<em>MessageName</em></td>
+ </tr>
+ <tr>
+ <th scope="row">rpc</th>
+ <td>Call<em>MessageName</em></td>
+ <td>Answer<em>MessageName</em></td>
+ </tr>
+ </tbody>
+</table>
+
+<h4 id="消息语义强度">消息语义强度<span class="mw-headline"> </span></h4>
+
+<p>IPDL协议 也像消息一样具有 “语义限定符”。这里的不同之处在于这里的语语义限定符是可选的; 默认语义是异步的。 必须指出的是 协议的语义至少与其 最强的消息语义 一样“强”,其中<strong>同步语义 “强于” 异步</strong>。这意味着异步协议无法在不违反 此类型规则 的情况下声明同步消息,而<strong>同步协议可以声明异步消息</strong>。下面显示了具有同步消息的恰当协议。</p>
+
+<pre><strong>sync protocol</strong> PPluginInstance
+{
+<strong>child:
+    </strong><strong>sync</strong> Init() <strong>returns</strong> (bool windowless, bool ok);
+};</pre>
+
+<p>该方法生成的C++代码将 外参指针 用于 返回值:</p>
+
+<pre>class PPluginInstanceParent
+{
+ ...
+ bool SendInit(bool* windowless, bool* ok) { ... };
+};
+
+class PPluginInstanceChild
+{
+ ...
+ virtual bool RecvInit(bool* windowless, bool* ok) = 0;
+}</pre>
+
+<h4 id="RPC_语义"><span class="mw-headline">RPC 语义</span></h4>
+
+<p>“RPC” 代表“远程过程调用”,该第三种语义对 过程调用语义 进行建模。RPC 和 sync 语义之间的差别, 快速总结一下就是,RPC 允许“重入”消息处理程序:虽然参与者在等待RPC“调用”的“应答”时被阻塞,但它可以被 <em>解除阻塞</em> 以处理新的传入RPC<em>调用</em>。</p>
+
+<p>在下面的示例协议中,子端角色 提供了一个 “CallMeCallYou()” RPC接口,父接口提供一个 “CallYou()” RPC接口。 <code><strong>rpc</strong></code> 限定符意味着,如果父对象对子参与者调用“CallMeCallYou()”,那么子参与者在服务这个调用时,可以回调到父参与者的 “CallYou()” 消息。</p>
+
+<pre><strong>rpc</strong> <strong>protocol</strong> Example {
+<strong>child</strong>:
+ <strong>rpc</strong> CallMeCallYou() <strong>returns</strong> (int rv);
+
+<strong>parent</strong>:
+ <strong>rpc</strong> CallYou() <strong>returns</strong> (int rv);
+};
+</pre>
+
+<p>如果这是一个sync 同步协议,那么在为“CallMeCallYou()”消息提供服务时,将不允许 子端角色 调用 父端角色 的 “CallYou()” 方法。(子端角色 将被 极端“偏见” 终止。)</p>
+
+<h4 id="首选语义">首选语义<span class="mw-headline"> </span></h4>
+
+<p>尽可能使用异步<strong>async</strong> 语义。<br>
+ <br>
+ 不鼓励对 消息回复 进行阻塞。如果您真的需要阻塞 回复,请 <em>非常小心 </em>地使用<strong>sync</strong> 同步语义。不小心使用同步消息可能会陷入麻烦;虽然 IPDL 可以检查 和/或 保证您的代码不会死锁,但很容易通过阻塞导致严重的性能问题。<br>
+ <br>
+ 请不要使用RPC语义。RPC语义的存在主要是为了支持 远程插件(NPAPI),这我们别无选择。</p>
+
+<div class="note">Chrome 对 content调用(用于IPC选项卡) 必须仅使用异步语义。为了保持响应性,chrome 进程需要永不阻塞 可能处于繁忙或挂起的 content 进程。</div>
+
+<h3 id="消息分发顺序">消息分发顺序</h3>
+
+<p>传递是“按顺序”的,也就是说,消息按照发送的顺序传递给接收者,而不考虑消息的语义。如果角色A发送消息M1,接着是M2来发送给角色B,B将被唤醒以处理M1,然后是M2。</p>
+
+<h2 id="子协议和协议管理">子协议和协议管理</h2>
+
+<p>到目前为止,我们已经看到了一个单一的协议,但现实世界中没有一个孤立的情况会有一个单一的协议。相反,协议被安排在<strong>子协议</strong>的受管层次结构中。子协议绑定到追踪其生命周期并充当工厂的“管理器”。协议层次结构从一个顶级协议开始,所有的 子协议角色 最终都是从该协议创建的。在Mozilla中有两个主要的顶层协议:用于远程插件的 <a class="external" href="http://mxr.mozilla.org/mozilla-central/source/dom/plugins/ipc/PPluginModule.ipdl" title="http://mxr.mozilla.org/projects-central/source/electrolysis/dom/plugins/PPluginModule.ipdl">PPluginModule</a>和用于远程选项卡的 <a class="external" href="http://mxr.mozilla.org/mozilla-central/source/dom/ipc/PContent.ipdl" title="http://mxr.mozilla.org/mozilla-central/source/dom/ipc/PContent.ipdl">PContent</a>。</p>
+
+<p>以下示例扩展了 顶级的 plugin协议来管理插件实例。</p>
+
+<pre><code>// ----- file PPlugin.ipdl
+
+<strong>include protocol</strong> PPluginInstance;</code>
+
+<code><strong>rpc protocol</strong> PPlugin
+{
+<strong>    manages</strong> PPluginInstance;
+<strong>child:</strong>
+    <strong>rpc</strong> Init(nsCString pluginPath) <strong>returns</strong> (bool ok);
+ // This part creates constructor messages
+    <strong style="font-weight: bold;">rpc </strong>PPluginInstance(nsCString type, nsCString[] args) <strong>returns</strong> (int rv);
+</code><code>};</code>
+</pre>
+
+<pre><code>// ----- file PPluginInstance.ipdl
+
+<strong>include protocol</strong> PPlugin;
+
+<strong>rpc protocol</strong> PPluginInstance
+{
+<strong>    manager</strong> PPlugin;
+<strong>child:</strong>
+    <strong>rpc</strong> __delete__();
+    SetSize(int width, int height);
+};</code>
+</pre>
+
+<p>这个例子有几个新元素:`include protocol`将另一个协议声明导入到这个文件中。请注意,这不是预处理器指令,而是IPDL语言的一部分。生成的C++代码将为 导入的协议 提供适当的#include预处理器指令。<br>
+ <br>
+ `manages`语句声明此协议管理PPluginInstance。PPlugin协议必须为PPluginInstance角色声明构造函数和析构函数消息。`manages`语句还意味着PPluginInstance角色与创建它们的插件角色的生命周期有关:如果此PPlugin实例被销毁,则与其关联的所有PPluginInstance都将失效或销毁。<br>
+ <br>
+ 令人困惑的是,强制 构造函数和析构函数消息(分别为PPluginInstance 和 __delete__ )存在于不同的位置。 构造函数必须位于管理协议中,而析构函数属于 被管理的子协议。·这些消息具有与C++构造函数相似的语法,但行为不同。构造函数和析构函数像其他IPDL消息一样具有参数、方向、语义和返回值。必须为每个托管协议声明构造函数和析构函数消息。</p>
+
+<p>每个子协议必须包含一个`manager`语句。<br>
+ <br>
+ 在C++层,子类和父类中的子类都必须实现用于allocate和deallocate子协议角色的方法。构造函数和析构函数被转换为消息的标准C++方法。<br>
+ <br>
+ 注意:__delete__是一个内置构造,并且是唯一不需要重写实现的IPDL消息(即Recv/Answer__delete__)。然而,当应该对协议的析构 进行某些操作而不是使用DeallocPProtocol功能时,鼓励被覆盖的实现。</p>
+
+<pre>class PPluginParent
+{
+ /* Allocate a PPluginInstanceParent when the first form of CallPluginInstanceConstructor is called */
+ virtual PPluginInstanceParent* AllocPPluginInstance(const nsCString&amp; type, const nsTArray&lt;nsCString&gt;&amp; args, int* rv) = 0;
+
+ /* Deallocate the PPluginInstanceParent after PPluginInstanceDestructor is done with it */
+ virtual bool DeallocPPluginInstance(PPluginInstanceParent* actor) = 0;
+
+ /* constructor message */
+ virtual CallPPluginInstanceConstructor(const nsCString&amp; type, const nsTArray&lt;nsCString&gt;&amp; args, int* rv) { /* generated code */ }
+
+ /* alternate form of constructor message: supply your own PPluginInstanceParent* to bypass AllocPPluginInstance */
+ virtual bool CallPPluginInstanceConstructor(PPluginInstanceParent* actor, const nsCString&amp; type, const nsTArray&lt;nsCString&gt;&amp; args, int* rv)
+ { /* generated code */ }
+
+ /* destructor message */
+ virtual bool Call__delete__(PPluginInstanceParent* actor) { /* generated code */ }
+
+ /* Notification that actor deallocation is imminent, IPDL mechanisms are now unusable */
+ virtual void ActorDestroy(ActorDestroyReason why);
+
+ ...
+};
+
+class PPluginChild
+{
+ /* Allocate a PPluginInstanceChild when we receive the PPluginInstance constructor */
+ virtual PPluginInstanceChild* AllocPPluginInstance(const nsCString&amp; type, const nsTArray&lt;nsCString&gt;&amp; args, int* rv) = 0;
+
+ /* Deallocate a PPluginInstanceChild after we handle the PPluginInstance destructor */
+ virtual bool DeallocPPluginInstance(PPluginInstanceChild* actor) = 0;
+
+ /* Answer the constructor message. Implementing this method is optional: it may be possible to answer the message directly in AllocPPluginInstance. */
+ virtual bool AnswerPPluginInstanceConstructor(PPluginInstanceChild* actor, const nsCString&amp; type, const nsTArray&lt;nsCString&gt;&amp; args, int* rv) { }
+
+ /* Answer the destructor message. */
+ virtual bool Answer__delete__(PPluginInstanceChild* actor) = 0;
+
+ /* Notification that actor deallocation is imminent, IPDL mechanisms are now unusable */
+ virtual void ActorDestroy(ActorDestroyReason why);
+
+ ...
+};</pre>
+
+<h4 id="子协议角色的生命周期">子协议角色的生命周期</h4>
+
+<p>AllocPProtocol 和 DeallocPProtocol 是一对匹配的函数。这些功能的典型实现是使用' new '和' delete ':</p>
+
+<pre>class PluginChild : PPluginChild
+{
+ virtual PPluginInstanceChild* AllocPPluginInstance(const nsCString&amp; type, const nsTArray&lt;nsCString&gt;&amp; args, int* rv)
+ {
+ return new PluginInstanceChild(type, args, rv);
+ }
+
+ virtual bool DeallocPPluginInstanceChild(PPluginInstanceChild* actor)
+ {
+ delete actor; // actor destructors are always virtual, so it's safe to call delete on them!
+ return true;
+ }
+
+ ...
+};</pre>
+
+<p>然而,在某些情况下,外部代码可能包含对需要引用计数或其他生命周期策略的角色实现的引用。在这种情况下,alloc/dealloc 可以执行不同的操作。以下是引用计数的示例:</p>
+
+<pre>class ExampleChild : public nsIObserver, public PExampleChild { ... };
+
+virtual PExampleChild* TopLevelChild::AllocPExample()
+{
+ RefPtr&lt;ExampleChild*&gt; actor = new ExampleChild();
+ return actor.forget();
+}
+
+virtual bool TopLevelChild::DeallocPExample(PExampleChild* actor)
+{
+ NS_RELEASE(static_cast&lt;ExampleChild*&gt;(actor));
+ return true;
+}
+</pre>
+
+<p>如果实现协议的对象不能在AllocPFoo内构造,先前已经构造,并且在其整个生命周期中不需要IPDL连接,或者实现引用计数的协议(第一种形式的构造函数不可用),则可以使用第二种形式的 SendPFooConstructor:</p>
+
+<pre>class ExampleChild
+{
+public:
+    void DoSomething() {
+        aManagerChild-&gt;SendPExampleConstructor(this, ...);
+    }
+};
+</pre>
+
+<p>在内部,第一个构造函数表单只需调用</p>
+
+<pre>PExample(Parent|Child)* actor = AllocPExample(...);
+SendPExampleConstructor(actor, ...);
+return actor;
+</pre>
+
+<p>效果一致。</p>
+
+<h4 id="子协议删除">子协议删除</h4>
+
+<p>值得了解协议删除过程。·考虑到简单的协议:</p>
+
+<pre>// --- PExample.ipdl
+<strong>include protocol</strong> PSubExample;
+
+<strong>async protocol</strong> PExample
+{
+    <strong>manages</strong> PSubExample;
+
+<strong>p</strong><strong>arent:
+    async </strong>PChild();
+};
+
+// --- PSubExample.ipdl
+<strong>include protocol</strong> PExample;
+
+<strong>async protocol</strong> PSubExample
+{
+    <strong>manager </strong>PExample;
+
+<strong>child:
+</strong>    <strong>async</strong> __delete__();
+};
+</pre>
+
+<p>我们假设存在 PSubExampleParent/Child,这样一些元素现在希望从父端触发协议的删除。</p>
+
+<pre><code><code>aPSubExampleParent-&gt;Send__delete__();</code></code></pre>
+
+<p>will trigger the following ordered function calls:</p>
+
+<pre>PSubExampleParent::ActorDestroy(Deletion)
+/* Deletion is an enumerated value indicating
+ that the destruction was intentional */
+PExampleParent::DeallocPSubExample()</pre>
+
+<pre>PSubExampleChild::Recv__delete__()
+PSubExampleChild::ActorDestroy(Deletion)
+PExampleChild::DeallocPSubExample()</pre>
+
+<p>ActorDestroy是一个生成的函数,它允许代码在知道参与者释放即将到来的情况下运行。·这对于生命周期在IPDL之外的角色很有用 。例如,可以设置一个标志,表明与IPDL相关的功能不再安全使用。</p>
+
+<h4 id="从C访问协议树">从C++访问协议树</h4>
+
+<p>The IPDL compiler generates methods that allow actors to access their manager (if the actor isn't top-level) and their managees (if any) from C++.  For a protocol PFoo managed by PManager, that manages PManagee, the methods are</p>
+
+<p>IPDL编译器生成允许参与者从C++访问其管理器(如果参与者不是顶级)和受管对象(如果有的话)的方法。对于协议PFoo,由 管理 PManagee的 PManager管理,这些方法是</p>
+
+<pre>PManager* PFoo::Manager()
+const InfallibleTArray&lt;PManagee*&gt; PFoo::ManagedPManagee();
+void PFoo::ManagedPManagee(InfallibleTArray&lt;PManagee*&gt;&amp;);
+</pre>
+
+<h2 id="关闭和错误处理">关闭和错误处理</h2>
+
+<p>实现IPDL消息的C++方法返回<code>bool</code>:true表示成功,false表示灾难性失败。如果数据已损坏或格式错误,则消息实现应从消息实现返回false。只要消息实现返回false,IPDL就会立即开始灾难性的错误处理:子进程(tab或plugin)的通信通道将被断开,并且进程将终止。对于“正常”错误条件,如无法加载网络请求,不要从消息处理程序返回false!正常的错误应该用消息或返回值发出信号。</p>
+
+<p><em>注意: 以下段落尚未实施</em><em>.</em> IPDL跟踪两个端点之间的所有活动协议。如果子侧崩溃或挂起::</p>
+
+<ul>
+ <li>当前活动的任何同步或RPC消息都将返回false。</li>
+ <li>将不再接受进一步的消息(C++方法将返回false)。</li>
+ <li>每个IPDL参与者都将收到OnError消息。</li>
+ <li>将在每个管理器协议上调用 DeallocPSubprotocol,以解除分配任何活动子协议。</li>
+</ul>
+
+<p>销毁管理器协议时,将通知所有子协议:</p>
+
+<ul>
+ <li>不再接受进一步的消息。</li>
+ <li>将在管理器协议上调用DeallocPSubprotocol,以解除分配任何活动子协议</li>
+</ul>
+
+<p>当顶层协议被破坏时,这等同于关闭该连接的整个IPDL机制,因为不能再发送更多的消息,并且所有子协议都被销毁。</p>
diff --git a/files/zh-cn/mozilla/javascript-dom_prototypes_in_mozilla/index.html b/files/zh-cn/mozilla/javascript-dom_prototypes_in_mozilla/index.html
new file mode 100644
index 0000000000..5136550830
--- /dev/null
+++ b/files/zh-cn/mozilla/javascript-dom_prototypes_in_mozilla/index.html
@@ -0,0 +1,145 @@
+---
+title: JavaScript-DOM Prototypes in Mozilla
+slug: Mozilla/JavaScript-DOM_Prototypes_in_Mozilla
+translation_of: Mozilla/JavaScript-DOM_Prototypes_in_Mozilla
+---
+<div class="blockIndicator note">
+<h2 id="Prototype_setup_on_an_XPConnect_wrapped_DOM_node_in_Mozilla" name="Prototype_setup_on_an_XPConnect_wrapped_DOM_node_in_Mozilla">Prototype setup on an XPConnect wrapped DOM node in Mozilla</h2>
+</div>
+
+<p>When a <a href="/en/DOM" title="en/DOM">DOM</a> node is accessed from <a href="/en/JavaScript" title="en/JavaScript">JavaScript</a> in Mozilla, the native C++ DOM node is wrapped using <a href="/en/XPConnect" title="en/XPConnect">XPConnect</a> and the wrapper is exposed to JavaScript as the JavaScript representation of the DOM node. When XPConnect wraps a C++ object it will create a <code>JSObject</code> that is unique to this C++ object. In the case where the C++ object has class info (<a href="/en/nsIClassInfo" title="en/nsIClassInfo">nsIClassInfo</a>), the <code>JSObject</code> is a more or less empty <code>JSObject</code> which is not really that special. All the methods that are supposed to show up on this <code>JSObject</code> are actually not properties of the object itself, but rather properties of the prototype of the <code>JSObject</code> for the wrapper (unless the C++ object's class info has the flag <code>nsIXPCScriptable::DONT_SHARE_PROTOTYPE</code> set, but lets assume that's not the case here).</p>
+
+<p>As an example of this let's look at an HTML image element in a document.</p>
+
+<pre class="eval">var obj = document.images[0];
+</pre>
+
+<p>Here, <code>obj</code> will not really have any properties (except for the standard <code>JSObject</code> properties such as <code>constructor</code>, and the non-standard <code>__parent__</code>, <code>__proto__</code>, etc.), all the DOM functionality of <code>obj</code> comes from <code>obj</code>'s prototype (<code>obj.__proto__</code>) that XPConnect sets up when exposing the first image in <code>document</code> to JavaScript. Here are a few of the properties of obj's prototype:</p>
+
+<pre class="eval">obj.__proto__
+ parentNode (getter Function)
+ src (getter and setter Functions)
+ getElementsByTagName (Function)
+ TEXT_NODE (Number property, constant)
+ ...
+</pre>
+
+<p>All those properties come from the interfaces that the C++ image object (<code>nsHTMLImageElement</code>) implements and chooses to expose to XPConnect through the object's class info. One of these interfaces is <code>nsIDOMHTMLImageElement</code>, others are <code>nsIDOMNSHTMLImageElement</code> (Netscape extensions to the standard interface), <code>nsIDOMEventTarget</code>, <code>nsIDOMEventListener</code>, <code>nsIDOM3Node</code>, and so on.</p>
+
+<p>The prototype object that XPConnect creates for the classes that have class info are shared within a scope (<code>window</code>). Because of this, the following holds true (assuming <code>img1</code> and <code>img2</code> are two different image objects in the same document):</p>
+
+<pre class="eval">img1.__proto__ === img2.__proto__
+</pre>
+
+<p>If <code>img1</code> would come from one document and <code>img2</code> from another document, then the above would not be true. Both prototypes would look identical, but they would be two different <code>JSObject</code>'s.</p>
+
+<p>This sharing of prototypes lets users do cool things like modify how all instances of a given class works by modifying the prototype of one instance. As an example:</p>
+
+<pre class="eval">function bar() {
+ alert("Hello world!");
+}
+
+document.images[0].__proto__.foo = bar;
+</pre>
+
+<p>This would make every image in this document have a callable <code>foo</code> property (i.e. a <code>foo()</code> method).</p>
+
+<p>Alternatively, one can access and modify the prototype of an <code>HTMLImageElement</code> through the <code>prototype</code> property of the constructor:</p>
+
+<pre class="eval">HTMLImageElement.prototype.foo = bar;
+</pre>
+
+<p>Modifying the prototype of a Host object is not guaranteed by <a href="/en/ECMAScript" title="en/ECMAScript">ECMAScript specification</a>. Moreover, no specification guarantees that there will be a globally available <code>HTMLImageElement</code>, or that such object will be the constructor for any arbitrary image's <span class="nowiki">[[Prototype]]</span>.</p>
+
+<p>A third way through which one can access the prototype of an object is through the <code>constructor</code> property of the object, which itself points (initially) to the constructor:</p>
+
+<pre class="eval">document.images[0].constructor.prototype.foo = bar;
+</pre>
+
+<p>Note though, the above may or may not work in Mozilla.</p>
+
+<p>So far so good; we have shared prototypes, and XPConnect gives us most of this automatically. But this is not good enough, in addition to being able to share and represent each "class" with a constructor, we also want users to be able to extend interfaces, like <code>Node</code>. <code>Node</code> is a DOM interface, but there are no pure <code>Node</code> instances; there are lots of different classes that implement <code>Node</code> (<code>HTMLImageElement</code>, <code>HTMLDocument</code>, <code>ProcessingInstruction</code>, et c.).</p>
+
+<p>But the fact that an instance of a <code>Node</code> will never exist in Mozilla does not mean that the <code>Node</code> interface is useless, in fact, <code>Node can be extended just as we've been doing.</code> If you think back to the <code>HTMLImageElement</code> examples above, those examples let you define new properties on all image elements. By modifying the <code>Node</code> top-level object, you can do similar things to <em>all</em> objects that implement <code>Node</code>. This means you can add a property to every node in a DOM tree by doing something like this:</p>
+
+<pre class="eval">Node.prototype.foo = bar;
+</pre>
+
+<p>Again, modifying host objects is an unsafe practice. It is not guaranteed to work or be error-free in any implementation. It is not standard and cannot be expected to have any result.</p>
+
+<p>Here is an attempt to modify a host object:</p>
+
+<pre class="eval"> (function(){
+ try {
+ Image.prototype.src = 1;
+ }
+ catch(ex){ alert(ex); }
+ })();
+</pre>
+
+<p>This demonstrates that the <code>Image</code> constructor, a host object supported in nearly all browsers for Mac and Windows, has a <code>prototype</code> property, and that an attempt to modify the <code>prototype</code>'s <code>src</code> - property results in an error.</p>
+
+<p>Another example would be modifying the <code>pageX</code> property of a <code>MouseEvent</code> instance. The <code>pageX</code> property actually needs a patch because it doesn't get set correctly in <code>initMouseEvent</code> {{ Bug(411031) }}.</p>
+
+<p>Here is a diagram that shows the prototype layout of a <code>HTMLDivElement</code> in Mozilla:</p>
+
+<pre class="eval"> HTMLDivElement.prototype
+ |
+ |.__proto__
+ |
+ HTMLElement.prototype
+ |
+ |.__proto__
+ |
+ Element.prototype
+ |
+ |.__proto__
+ |
+ Node.prototype
+ |
+ |.__proto__
+ |
+ Object.prototype
+ |
+ |.__proto__
+ |
+ null
+</pre>
+
+<p>If you have an instance of a <code>HTMLDivElement</code> in JavaScript, the following will hold true:</p>
+
+<pre class="eval">div.__proto__ === HTMLDivElement.prototype
+</pre>
+
+<p>which means that the following should also be true:</p>
+
+<pre class="eval">div.__proto__ === div.constructor.prototype
+</pre>
+
+<h3 id="Non_Standard" name="Non_Standard">Non Standard</h3>
+
+<p>No browser is required to provide modifiable <code>__proto__</code>, nor a global <code>Node</code>, nor provide any way to get at host objects nor their associated prototypes. If such objects are provided, they are not guaranteed by any specification to have any effect on the environment. Results in other browsers is not guaranteed.</p>
+
+<h2 id="So_how_does_all_this_work_in_the_Mozilla_DOM_code.3F" name="So_how_does_all_this_work_in_the_Mozilla_DOM_code.3F">So how does all this work in the Mozilla DOM code?</h2>
+
+<p>It all happens in XPConnect and <code>nsDOMClassInfo.{cpp,h}</code> in the DOM code. During startup, the <code>nsDOMClassInfo</code> code registers two different types of "global names", these are names of properties of the global object with special meaning to the DOM code. The two types of "global names" are class constructor names and class prototype names. What's the difference? Class constructor names are names of real classes, and class prototype names are names of "classes" that are inherited by real classes, but are not real classes. A few examples of class constructor names would be <code>HTMLImageElement</code>, <code>HTMLDocument</code>, <code>Element</code>, <code>NodeList</code>, and two examples of class prototype names would be <code>Node</code> and <code>CharacterData</code>.</p>
+
+<p>This registration is done with the <code>nsScriptNameSpaceManager</code>, which is in charge of keeping track of what names are registered in the global namespace, and what kinds of names those names are (i.e. class constructor name, class prototype name). When a class constructor name is registered (<code>nsGlobalNameStruct::eTypeClassConstructor</code>), the <code>nsScriptNameSpaceManager</code> is given a DOM class info ID (a 32 bit ID that identifies class info defined in <code>nsDOMClassInfo</code>). When a class prototype name is registered (<code>nsGlobalNameStruct::eTypeClassProto</code>), the <code>nsScriptNameSpaceManager</code> is given the <code>nsIID</code> of the interface that is inherited by the class which the registered name is a prototype of (e.g. <code>NS_GET_IID(nsIDOMNode)</code> for <code>Node</code>). <code>nsScriptNameSpaceManager</code> also deals with other types of names, but those are unrelated to the DOM object prototype setup, so we will ignore those here.</p>
+
+<p>Once the registration is done, the <code>nsDOMClassInfo</code> code uses the registry every time a named property is resolved on a global object (because of this, the <code>nsScriptNameSpaceManager</code> needs to be pretty fast at looking things up in its registry; that's why it is a hash table). When a property is resolved on the global object, the <code>nsDOMClassInfo</code> code will ask the <code>nsScriptNameSpaceManager</code> if the name is a known name (in <code>nsWindowSH::GlobalResolve()</code>), and if the name is known, the code will look at the type of the name and act accordingly.</p>
+
+<p>If a class constructor or class prototype name is resolved, the class info code will define the constructor for that class, and also define the prototype property of that constructor (i.e. <code>HTMLImageElement.prototype</code>). The prototype of a constructor will either be the prototype object that XPConnect creates for a class (if the name is the name of a real class) or simply an empty <code>JSObject</code> of a specific <code>JSClass</code> that is defined in <code>nsDOMClassInfo.cpp</code> (<code>nsDOMClassInfo::sDOMConstructorProtoClass</code>).</p>
+
+<p>As the <code>prototype</code> property of the constructor is being defined, the code also sets up the prototype of the <code>prototype</code> property of the constructor (i.e. <code>HTMLImageElement.prototype.__proto__</code>). To do this, the code figures out what the name of the immediate prototype of the class is by looking at the parent of the primary interface in the class info (if the name is a class constructor, such as <code>HTMLImageElement</code>) or by looking at the parent of the interface that the IID stored in the <code>nsScriptNameSpaceManager</code> for this name represents (if the name is a class prototype, such as <code>Node</code>). Once the name of the parent interface is known (and the name is not <code><a href="/en/nsISupports" title="en/nsISupports">nsISupports</a></code>) the code will look up a property by that name on the global object. This will cause the code to recurse down along the parent chain of the interface of interest for the name we started out resolving (i.e. <code>nsWindowSH::GlobalResolve()</code> will be called for every name on the parent chain). The result of this recursion is that by resolving the name <code>HTMLImageElement</code>, we'll create the constructor <code>HTMLImageElement</code>, <code>HTMLElement</code>, <code>Element</code>, and <code>Node</code>, and the <code>prototype</code> properties on all those constructor will be correctly set up. This means that the next time the name of a class constructor is resolved in the same scope, say <code>HTMLAnchorElement</code>, the code will resolve the name <code>HTMLAnchorElement</code>, find the parent name, which is <code>HTMLElement</code>, and resolve that, but since we've already resolved <code>HTMLElement</code> as a result of resolving the name <code>HTMLImageElement</code> earlier, the recursion will stop right there.</p>
+
+<p>Ok, so that's how class constructor and their prototype properties are set up, what about the actual prototype chain of a XPConnected DOM object? The beauty of this code is that the <code>prototype</code> property of a class constructor is the real XPConnect prototype for that class. When XPConnect wraps a DOM object (i.e. creates a XPConnect JavaScript wrapper for a DOM object), XPConnect will call the scriptable helper method <code>nsDOMClassInfo::PostCreate()</code> which will make sure the prototype chain of the wrapper <code>JSObject</code> is properly set up. In this call, the <code>nsDOMClassInfo</code> code just needs to resolve the name of the class on the global object, and the prototype will be set up by the resolving code (<code>nsWindowSH::GlobalResolve()</code>). This is also done only once per class, <code>nsDOMClassInfo::PostCreate()</code> checks if the prototype of the prototype of the wrapper <code>JSObject</code> (i.e. <code>obj.__proto__.__proto__</code>) has been set up already, if it has, then there's nothing left to do in <code>nsDOMClassInfo::PostCreate()</code>.</p>
+
+<div class="originaldocinfo">
+<h2 id="Original_Document_Information" name="Original_Document_Information">Original Document Information</h2>
+
+<ul>
+ <li>Author(s): <a class="link-mailto" href="mailto:fguisset@softhome.net">Fabian Guisset</a></li>
+ <li>Last Updated Date: February 2, 2002</li>
+ <li>Copyright Information: Copyright (C) <a class="link-mailto" href="mailto:fguisset@softhome.net">Fabian Guisset</a></li>
+</ul>
+</div>
diff --git a/files/zh-cn/mozilla/javascript_code_modules/assert.jsm/index.html b/files/zh-cn/mozilla/javascript_code_modules/assert.jsm/index.html
new file mode 100644
index 0000000000..a9cbfe6aeb
--- /dev/null
+++ b/files/zh-cn/mozilla/javascript_code_modules/assert.jsm/index.html
@@ -0,0 +1,448 @@
+---
+title: Assert.jsm
+slug: Mozilla/JavaScript_code_modules/Assert.jsm
+translation_of: Mozilla/JavaScript_code_modules/Assert.jsm
+---
+<p>{{ gecko_minversion_header("31") }}</p>
+
+<p>The <code>Assert.jsm</code> JavaScript code module implements the <a href="http://wiki.commonjs.org/wiki/Unit_Testing/1.1" title="http://wiki.commonjs.org/wiki/Unit_Testing/1.1">CommonJS Unit Testing specification version 1.1</a>, which provides a basic, standardized interface for performing in-code logical assertions with optional, customizable error reporting. To use it, you first need to import the code module into your JavaScript scope:</p>
+
+<pre class="brush: js">Components.utils.import("resource://testing-common/Assert.jsm");
+</pre>
+
+<p>Assert 类提供了执行常见逻辑断言的方法。</p>
+
+<h2 id="Method_overview">Method overview</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code><a href="/en-US/JavaScript/Reference/Global_Objects/undefined" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined">undefined</a> <a href="#ok()" title="en/JavaScript code modules/Assert.jsm#ok()">ok</a>(value, message);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/JavaScript/Reference/Global_Objects/undefined" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined">undefined</a> <a href="#equal()" title="en/JavaScript code modules/Assert.jsm#equal()">equal</a>(actual, expected, message);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/JavaScript/Reference/Global_Objects/undefined" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined">undefined</a> <a href="#notEqual()" title="en/JavaScript code modules/Assert.jsm#notEqual()">notEqual</a>(actual, expected, message);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/JavaScript/Reference/Global_Objects/undefined" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined">undefined</a> <a href="#deepEqual()" title="en/JavaScript code modules/Assert.jsm#deepEqual()">deepEqual</a>(actual, expected, message);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/JavaScript/Reference/Global_Objects/undefined" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined">undefined</a> <a href="#notDeepEqual()" title="en/JavaScript code modules/Assert.jsm#notDeepEqual()">notDeepEqual</a>(actual, expected, message);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/JavaScript/Reference/Global_Objects/undefined" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined">undefined</a> <a href="#strictEqual()" title="en/JavaScript code modules/Assert.jsm#strictEqual()">strictEqual</a>(actual, expected, message);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/JavaScript/Reference/Global_Objects/undefined" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined">undefined</a> <a href="#notStrictEqual()" title="en/JavaScript code modules/Assert.jsm#notStrictEqual()">notStrictEqual</a>(actual, expected, message);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/JavaScript/Reference/Global_Objects/undefined" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined">undefined</a> <a href="#throws()" title="en/JavaScript code modules/Assert.jsm#throws()">throws</a>(block, expected, message);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en/Web/JavaScript/Reference/Global_Objects/Promise" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined">Promise</a> <a href="#rejects()" title="en/JavaScript code modules/Assert.jsm#rejects()">rejects</a>(promise, expected, message);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/JavaScript/Reference/Global_Objects/undefined" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined">undefined</a> <a href="#greater()" title="en/JavaScript code modules/Assert.jsm#greater()">greater</a>(lhs, rhs, message);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/JavaScript/Reference/Global_Objects/undefined" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined">undefined</a> <a href="#greaterOrEqual()" title="en/JavaScript code modules/Assert.jsm#greaterOrEqual()">greaterOrEqual</a>(lhs, rhs, message);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/JavaScript/Reference/Global_Objects/undefined" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined">undefined</a> <a href="#less()" title="en/JavaScript code modules/Assert.jsm#less()">less</a>(lhs, rhs, message);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/JavaScript/Reference/Global_Objects/undefined" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined">undefined</a> <a href="#lessOrEqual()" title="en/JavaScript code modules/Assert.jsm#lessOrEqual()">lessOrEqual</a>(lhs, rhs, message);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/JavaScript/Reference/Global_Objects/undefined" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined">undefined</a> <a href="#setReporter()" title="en/JavaScript code modules/Assert.jsm#setReporter()">setReporter</a>(reporterFunc);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/JavaScript/Reference/Global_Objects/undefined" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined">undefined</a> <a href="#report()" title="en/JavaScript code modules/Assert.jsm#report()">report</a>(failed, actual, expected, message, operator);</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Constructor">Constructor</h2>
+
+<p>Creates a new <code>Assert</code> object.</p>
+
+<pre>let assert = new Assert(reporterFunc);
+</pre>
+
+<p>The new Assert instance, <code>assert</code>, uses <code>reporterFunc</code> to <a href="/en/JavaScript_code_modules/Assert.jsm#report()" title="en/JavaScript code modules/Assert.jsm#report()">report</a> assertion results or throws an <a href="/en/JavaScript_code_modules/Assert.jsm#AssertionError" title="en/JavaScript code modules/Assert.jsm#AssertionError">AssertionError</a> when an assertion fails, as default behavior.</p>
+
+<p>ok, equal, notEqual, deepEqual, notDeepEqual, strictEqual, notStrictEqual, throws, setReporter, report</p>
+
+<h2 id="Methods">Methods</h2>
+
+<h3 id="ok()">ok()</h3>
+
+<p>Pure assertion tests whether a value is truthy, as determined by !!guard.<br>
+ This statement is equivalent to <code>assert.<a href="/en/JavaScript_code_modules/Assert.jsm#equal()" title="en/JavaScript code modules/Assert.jsm#equal()">equal</a>(true, !!guard, message_opt);</code>. To test strictly for the value true, use <code>assert.<a href="/en/JavaScript_code_modules/Assert.jsm#strictEqual()" title="en/JavaScript code modules/Assert.jsm#strictEqual()">strictEqual</a>(true, guard, message_opt);</code>.</p>
+
+<pre>undefined ok(
+  actual,
+  message
+);
+</pre>
+
+<h6 id="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>actual</code></dt>
+ <dd>Test subject to be evaluated as truthy</dd>
+ <dt><code>message</code></dt>
+ <dd>Short explanation of the expected result</dd>
+</dl>
+
+<h3 id="equal()">equal()</h3>
+
+<p>The equality assertion tests shallow, coercive equality with ==.</p>
+
+<pre>undefined equal(
+  actual,
+  expected,
+  message
+);
+</pre>
+
+<h6 id="Parameters_2">Parameters</h6>
+
+<dl>
+ <dt><code>actual</code></dt>
+ <dd>Test subject to be evaluated as equivalent to <code>expected</code></dd>
+ <dt><code>expected</code></dt>
+ <dd>Test reference to evaluate against <code>actual</code></dd>
+ <dt><code>message</code></dt>
+ <dd>Short explanation of the expected result</dd>
+</dl>
+
+<h3 id="notEqual()">notEqual()</h3>
+
+<p>The non-equality assertion tests for whether two objects are not equal with !=.</p>
+
+<pre>undefined notEqual(
+  actual,
+  expected,
+  message
+);
+</pre>
+
+<h6 id="Parameters_3">Parameters</h6>
+
+<dl>
+ <dt><code>actual</code></dt>
+ <dd>Test subject to be evaluated as <strong>not</strong> equivalent to <code>expected</code></dd>
+ <dt><code>expected</code></dt>
+ <dd>Test reference to evaluate against <code>actual</code></dd>
+ <dt><code>message</code></dt>
+ <dd>Short explanation of the expected result</dd>
+</dl>
+
+<h3 id="deepEqual()">deepEqual()</h3>
+
+<p>The equivalence assertion tests a deep equality relation.<br>
+ We check using the most exact approximation of equality between two objects to keep the chance of false positives to a minimum.<br>
+ <code>JSON.stringify</code> is not designed to be used for this purpose; objects may have ambiguous <code>toJSON()</code> implementations that would influence the test.</p>
+
+<pre>undefined deepEqual(
+  actual,
+  expected,
+  message
+);
+</pre>
+
+<h6 id="Parameters_4">Parameters</h6>
+
+<dl>
+ <dt><code>actual</code></dt>
+ <dd>Test subject to be evaluated as equivalent to <code>expected</code>, including nested properties</dd>
+ <dt><code>expected</code></dt>
+ <dd>Test reference to evaluate against <code>actual</code></dd>
+ <dt><code>message</code></dt>
+ <dd>Short explanation of the expected result</dd>
+</dl>
+
+<h3 id="notDeepEqual()">notDeepEqual()</h3>
+
+<p>The non-equivalence assertion tests for any deep inequality.</p>
+
+<pre>undefined notDeepEqual(
+  actual,
+  expected,
+  message
+);
+</pre>
+
+<h6 id="Parameters_5">Parameters</h6>
+
+<dl>
+ <dt><code>actual</code></dt>
+ <dd>Test subject to be evaluated as <strong>not</strong> equivalent to <code>expected</code>, including nested properties</dd>
+ <dt><code>expected</code></dt>
+ <dd>Test reference to evaluate against <code>actual</code></dd>
+ <dt><code>message</code></dt>
+ <dd>Short explanation of the expected result</dd>
+</dl>
+
+<h3 id="strictEqual()">strictEqual()</h3>
+
+<p>The strict equality assertion tests strict equality, as determined by ===.</p>
+
+<pre>undefined strictEqual(
+  actual,
+  expected,
+  message
+);
+</pre>
+
+<h6 id="Parameters_6">Parameters</h6>
+
+<dl>
+ <dt><code>actual</code></dt>
+ <dd>Test subject to be evaluated as strictly equivalent to <code>expected</code></dd>
+ <dt><code>expected</code></dt>
+ <dd>Test reference to evaluate against <code>actual</code></dd>
+ <dt><code>message</code></dt>
+ <dd>Short explanation of the expected result</dd>
+</dl>
+
+<h3 id="notStrictEqual()">notStrictEqual()</h3>
+
+<p>The strict non-equality assertion tests for strict inequality, as determined by !==.</p>
+
+<pre>undefined notStrictEqual(
+  actual,
+  expected,
+  message
+);
+</pre>
+
+<h6 id="Parameters_7">Parameters</h6>
+
+<dl>
+ <dt><code>actual</code></dt>
+ <dd>Test subject to be evaluated as <strong>not</strong> strictly equivalent to <code>expected</code></dd>
+ <dt><code>expected</code></dt>
+ <dd>Test reference to evaluate against <code>actual</code></dd>
+ <dt><code>message</code></dt>
+ <dd>Short explanation of the expected result</dd>
+</dl>
+
+<h3 id="throws()">throws()</h3>
+
+<p>Expected to throw an error.</p>
+
+<pre>undefined throws(
+  block,
+  expected,
+  message
+);
+</pre>
+
+<h6 id="Parameters_8">Parameters</h6>
+
+<dl>
+ <dt><code>block</code></dt>
+ <dd><a href="/en/JavaScript/Reference/Global_Objects/Function" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function">Function</a> block to evaluate and catch eventual thrown errors</dd>
+ <dt><code>expected</code></dt>
+ <dd>Test reference to evaluate against the thrown result from <code>block</code></dd>
+ <dt><code>message</code></dt>
+ <dd>Short explanation of the expected result</dd>
+</dl>
+
+<h3 id="rejects()">rejects()</h3>
+
+<p>Expected to reject a promise. Returns a <a href="/en/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a> that resolves when the promise either resolves or rejects.</p>
+
+<pre>Promise rejects(
+  promise,
+  expected,
+  message
+);
+</pre>
+
+<h6 id="Parameters_9">Parameters</h6>
+
+<dl>
+ <dt><code>promise</code></dt>
+ <dd><a href="/en/Web/JavaScript/Reference/Global_Objects/Promise" title="https://developer.mozilla.org/en/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a> promise to wait for rejection and catch eventual thrown errors</dd>
+ <dt><code>expected</code></dt>
+ <dd>Test reference to evaluate against the thrown result from <code>block</code></dd>
+ <dt><code>message</code></dt>
+ <dd>Short explanation of the expected result</dd>
+</dl>
+
+<h3 id="greater()">greater()</h3>
+
+<p>The greater than assertion tests two numbers with the &gt; operator.</p>
+
+<pre>undefined greater(
+  lhs,
+  rhs,
+  message
+);
+</pre>
+
+<h6 id="Parameters_10">Parameters</h6>
+
+<dl>
+ <dt><code>lhs</code></dt>
+ <dd>The left hand side of the operator</dd>
+ <dt><code>rhs</code></dt>
+ <dd>The right hand side of the operator</dd>
+ <dt><code>message</code></dt>
+ <dd>Short explanation of the expected result</dd>
+</dl>
+
+<h3 id="greaterOrEqual()">greaterOrEqual()</h3>
+
+<p>The greater or equal than assertion tests two numbers with the &gt;= operator.</p>
+
+<pre>undefined greaterOrEqual(
+  lhs,
+  rhs,
+  message
+);
+</pre>
+
+<h6 id="Parameters_11">Parameters</h6>
+
+<dl>
+ <dt><code>lhs</code></dt>
+ <dd>The left hand side of the operator</dd>
+ <dt><code>rhs</code></dt>
+ <dd>The right hand side of the operator</dd>
+ <dt><code>message</code></dt>
+ <dd>Short explanation of the expected result</dd>
+</dl>
+
+<h3 id="less()">less()</h3>
+
+<p>The lesser than assertion tests two numbers with the &lt; operator.</p>
+
+<pre>undefined less(
+  lhs,
+  rhs,
+  message
+);
+</pre>
+
+<h6 id="Parameters_12">Parameters</h6>
+
+<dl>
+ <dt><code>lhs</code></dt>
+ <dd>The left hand side of the operator</dd>
+ <dt><code>rhs</code></dt>
+ <dd>The right hand side of the operator</dd>
+ <dt><code>message</code></dt>
+ <dd>Short explanation of the expected result</dd>
+</dl>
+
+<h3 id="lessOrEqual()">lessOrEqual()</h3>
+
+<p>The lesser or equal than assertion tests two numbers with the &lt;= operator.</p>
+
+<pre>undefined lessOrEqual(
+  lhs,
+  rhs,
+  message
+);
+</pre>
+
+<h6 id="Parameters_13">Parameters</h6>
+
+<dl>
+ <dt><code>lhs</code></dt>
+ <dd>The left hand side of the operator</dd>
+ <dt><code>rhs</code></dt>
+ <dd>The right hand side of the operator</dd>
+ <dt><code>message</code></dt>
+ <dd>Short explanation of the expected result</dd>
+</dl>
+
+<h3 id="setReporter()">setReporter()</h3>
+
+<p>Set a custom assertion report handler function.</p>
+
+<pre>undefined setReporter(
+  reporterFunc
+);
+</pre>
+
+<h6 id="Parameters_14">Parameters</h6>
+
+<dl>
+ <dt><code>reporterFunc</code></dt>
+ <dd>Reporter handler <a href="/en/JavaScript/Reference/Global_Objects/Function" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function">function</a>.<br>
+ Arguments passed in to this function are:
+ <dl>
+ <dt><code>err</code></dt>
+ <dd>An error object when the assertion failed or null when it passed</dd>
+ <dt><code>message</code></dt>
+ <dd>Message describing the assertion</dd>
+ <dt><code>stack</code></dt>
+ <dd>Stack trace of the assertion function.</dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id="report()">report()</h3>
+
+<p>All of the aforementioned functions must throw an <code>AssertionError</code> when a corresponding condition is not met, with a message that may be <code>undefined</code> if not provided.<br>
+ All assertion methods provide both the actual and expected values to the assertion error for display purposes.<br>
+ <br>
+ This report method only throws errors on assertion failures, as per spec, but consumers of this module (think: xpcshell-test, mochitest) may want to override this default implementation.</p>
+
+<pre>undefined report(
+  failed,
+  actual,
+  expected,
+  message,
+  operator
+);
+</pre>
+
+<h6 id="Parameters_15">Parameters</h6>
+
+<dl>
+ <dt><code>failed</code></dt>
+ <dd>Indicates if the assertion failed or not</dd>
+ <dt><code>actual</code></dt>
+ <dd>The result of evaluating the assertion</dd>
+ <dt><code>expected</code></dt>
+ <dd>Expected result from the test author</dd>
+ <dt><code>message</code></dt>
+ <dd>Short explanation of the expected result</dd>
+ <dt><code>operator</code></dt>
+ <dd>Operation qualifier used by the assertion method (ex: '==')</dd>
+</dl>
+
+<h2 id="Examples">Examples</h2>
+
+<h3 id="Custom_reporter_example">Custom reporter example</h3>
+
+<pre class="brush: js">Components.utils.import("resource://testing-common/Assert.jsm");
+
+let assert = new Assert();
+
+assert.setReporter(function customReporter(err, message, stack) {
+ if (err) {
+ do_report_result(false, err.message, err.stack);
+ } else {
+ do_report_result(true, message, stack);
+ }
+});
+</pre>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a class="internal" href="/en-US/docs/JavaScript_code_modules/Using" title="en-US/docs/JavaScript code modules/Using JavaScript code modules">Using JavaScript code modules</a></li>
+ <li><a class="internal" href="/en-US/docs/Mozilla/JavaScript_code_modules" title="en-US/docs/Mozilla/JavaScript code modules">JavaScript code modules</a></li>
+ <li><a class="internal" href="/en-US/docs/Components.utils.import" title="en-US/docs/Components.utils.import"><code>Components.utils.import</code></a></li>
+ <li><a href="/en-US/docs/Browser_chrome_tests" title="/en-US/docs/Browser_chrome_tests">Browser Chrome tests</a></li>
+ <li><a href="/en-US/docs/Mozilla/QA/Writing_xpcshell-based_unit_tests" title="/en-US/docs/Mozilla/QA/Writing_xpcshell-based_unit_tests">Writing xpcshell-based unit tests</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/javascript_code_modules/dict.jsm/index.html b/files/zh-cn/mozilla/javascript_code_modules/dict.jsm/index.html
new file mode 100644
index 0000000000..b27d445241
--- /dev/null
+++ b/files/zh-cn/mozilla/javascript_code_modules/dict.jsm/index.html
@@ -0,0 +1,344 @@
+---
+title: Dict.jsm
+slug: Mozilla/JavaScript_code_modules/Dict.jsm
+translation_of: Mozilla/JavaScript_code_modules/Dict.jsm
+---
+<p>{{ gecko_minversion_header("5.0") }}</p>
+
+<p>{{ warning("This is obsolete - new code should use <code>Map()</code>.") }}</p>
+
+<p>The <code>Dict.jsm</code> JavaScript code module offers routines for managing dictionaries of key/value pairs. To use it, you first need to import the code module into your JavaScript scope:</p>
+
+<pre>Components.utils.import("resource://gre/modules/Dict.jsm");
+</pre>
+
+<h2 id="创建一个字典">创建一个字典</h2>
+
+<p>You can create a new, empty dictionary by simply calling the <code>Dict()</code> constructor:</p>
+
+<pre>var newDict = new Dict();
+</pre>
+
+<p>If you wish, you may also pass in an <a href="/zh-CN/JavaScript/Guide/Values,_variables,_and_literals#Object_literals" title="zh-CN/JavaScript/Guide/Values,_variables,_and_literals#Object_literals">object literal</a> of key/value pairs with which to initialize the dictionary:</p>
+
+<pre>var someObj = {};
+var newDict = new Dict({key1: "foo", key2: someObj});
+</pre>
+
+<p>Note that values may be any JavaScript object type.</p>
+
+<div class="note"><strong>Note:</strong> You can actually specify non-strings as keys; these are converted to strings before being used, so they're documented here as if they were a string parameter.</div>
+
+<p>从Firefox 19开始,你可以通过传入一个<a href="/zh-CN/JSON" title="zh-CN/JSON">JSON字符串</a>来初始化字典对象:</p>
+
+<pre>var someJSON = '{key1: "foo", key2: {}}';
+var newDict = new Dict(someJSON);
+</pre>
+
+<div class="note"><strong>注:</strong> 传入的任意字符串都会被当成JSON字符串来对待.</div>
+
+<h2 id="Method_overview" name="Method_overview">方法概述</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>Dict <a href="/zh-CN/JavaScript_code_modules/Dict.jsm#copy()" title="zh-CN/JavaScript code modules/Dict.jsm#copy()">copy</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="/zh-CN/JavaScript_code_modules/Dict.jsm#del()" title="zh-CN/JavaScript code modules/Dict.jsm#del()">del</a>(<a href="/zh-CN/JavaScript/Reference/Global_Objects/String" title="zh-CN/JavaScript/Reference/Global Objects/String">String</a> aKey);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/zh-CN/JavaScript/Reference/Global_Objects/Object" title="zh-CN/JavaScript/Reference/Global Objects/Object">Object</a> <a href="/zh-CN/JavaScript_code_modules/Dict.jsm#get()" title="zh-CN/JavaScript code modules/Dict.jsm#get()">get</a>(</code><code><a href="/zh-CN/JavaScript/Reference/Global_Objects/String" title="zh-CN/JavaScript/Reference/Global Objects/String">String</a></code><code> </code><code>aKey</code><code>, [optional] </code><code><a href="/zh-CN/JavaScript/Reference/Global_Objects/Object" title="zh-CN/JavaScript/Reference/Global Objects/Object">Object</a></code><code> aDefault);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="/zh-CN/JavaScript_code_modules/Dict.jsm#has()" title="zh-CN/JavaScript code modules/Dict.jsm#has()">has</a>(</code><code><a href="/zh-CN/JavaScript/Reference/Global_Objects/String" title="zh-CN/JavaScript/Reference/Global Objects/String">String</a></code><code> </code><code>aKey</code><code>);</code></td>
+ </tr>
+ <tr>
+ <td><code>Array <a href="/zh-CN/JavaScript_code_modules/Dict.jsm#listitems()" title="zh-CN/JavaScript code modules/Dict.jsm#listitems()">listitems</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>Array <a href="/zh-CN/JavaScript_code_modules/Dict.jsm#listkeys()" title="zh-CN/JavaScript code modules/Dict.jsm#listkeys()">listkeys</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>Array <a href="/zh-CN/JavaScript_code_modules/Dict.jsm#listvalues()" title="zh-CN/JavaScript code modules/Dict.jsm#listvalues()">listvalues</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="/zh-CN/JavaScript_code_modules/Dict.jsm#set()" title="zh-CN/JavaScript code modules/Dict.jsm#set()">set</a>(String </code><code>aKey</code><code>, </code><code><a href="/zh-CN/JavaScript/Reference/Global_Objects/Object" title="zh-CN/JavaScript/Reference/Global Objects/Object">Object</a></code><code> aValue);</code></td>
+ </tr>
+ <tr>
+ <td>{{ fx_minversion_inline("19") }} <code><a href="/zh-CN/JavaScript/Reference/Global_Objects/String" title="zh-CN/JavaScript/Reference/Global Objects/String">String</a></code><code> <a href="/zh-CN/JavaScript_code_modules/Dict.jsm#toJSON()" title="zh-CN/JavaScript code modules/Dict.jsm#toJSON()">toJSON</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/zh-CN/JavaScript/Reference/Global_Objects/String" title="zh-CN/JavaScript/Reference/Global Objects/String">String</a></code><code> <a href="/zh-CN/JavaScript_code_modules/Dict.jsm#toString()" title="zh-CN/JavaScript code modules/Dict.jsm#toString()">toString</a>();</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="属性">属性</h2>
+
+<table class="standard-table" style="width: auto;">
+ <tbody>
+ <tr>
+ <td class="header">属性名</td>
+ <td class="header">类型</td>
+ <td class="header">描述</td>
+ </tr>
+ <tr>
+ <td><code>count</code></td>
+ <td><a href="/zh-CN/JavaScript/Reference/Global_Objects/Number" title="zh-CN/JavaScript/Reference/Global Objects/Number"><code>Number</code></a></td>
+ <td>字典中键值对的个数</td>
+ </tr>
+ <tr>
+ <td><code>items</code></td>
+ <td><code>Iterator</code></td>
+ <td>
+ <p>Returns an iterator over all of the items in the dictionary; each item is returned as a pair (a two-element array) with the first element being the key and the second being the value.</p>
+
+ <div class="note"><strong>Note:</strong> The order in which items are returned is arbitrary, and may change without notice. In addition, if the dictionary changes during iteration, no guarantees are made as to what will happen.</div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>keys</code></td>
+ <td><code>Iterator</code></td>
+ <td>
+ <p>Returns an iterator over all the keys in the dictionary.</p>
+
+ <div class="note"><strong>Note:</strong> The order in which items are returned is arbitrary, and may change without notice. In addition, if the dictionary changes during iteration, no guarantees are made as to what will happen.</div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>values</code></td>
+ <td><code>Iterator</code></td>
+ <td>
+ <p>Returns an iterator over all the values in the dictionary.</p>
+
+ <div class="note"><strong>Note:</strong> The order in which items are returned is arbitrary, and may change without notice. In addition, if the dictionary changes during iteration, no guarantees are made as to what will happen.</div>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="构造器">构造器</h2>
+
+<h2 id="Dict()">Dict()</h2>
+
+<p>创建并返回一个新的字典对象.</p>
+
+<pre>Dict Dict();
+
+Dict Dict(
+  Object initalKeysAndValues
+);
+</pre>
+
+<h6 id="参数">参数</h6>
+
+<dl>
+ <dt><code>initialKeysAndValues</code> {{ optional_inline() }}</dt>
+ <dd>A object containing key/value pairs with which to initialize the dictionary.</dd>
+</dl>
+
+<h6 id="返回值">返回值</h6>
+
+<p>一个新的字典对象,实现有下面这些方法.</p>
+
+<h2 id="Methods" name="Methods">方法</h2>
+
+<h2 id="copy()">copy()</h2>
+
+<p>返回一个字典对象的浅拷贝; that is, a copy of the dictionary including the items immediately included within the dictionary; however, any objects referenced by those top-level objects are not copied.</p>
+
+<pre>Dict copy();
+</pre>
+
+<h6 id="参数_2">参数</h6>
+
+<p>无</p>
+
+<h6 id="返回值_2">返回值</h6>
+
+<p>A new dictionary object containing the same top-level items as the original dictionary on which the <code>copy()</code> method was called.</p>
+
+<h2 id="del()">del()</h2>
+
+<p>根据指定的键,从该字典中删除一个键值对.</p>
+
+<pre>boolean del(
+  String aKey
+);
+</pre>
+
+<h6 id="参数_3">参数</h6>
+
+<dl>
+ <dt><code>aKey</code></dt>
+ <dd>从该字典中要删除的键.</dd>
+</dl>
+
+<h6 id="返回值_3">返回值</h6>
+
+<p>如果成功删除指定的键值对,则返回<code>true</code>,如果指定的键不存在,则返回<code>false</code>.</p>
+
+<h2 id="get()">get()</h2>
+
+<p>返回该字典对象中指定键所对应的值.</p>
+
+<pre><code>Object get(
+  String </code><code>aKey</code><code>,
+  [optional] Object aDefault
+);</code>
+</pre>
+
+<h6 id="参数_4">参数</h6>
+
+<dl>
+ <dt><code>aKey</code></dt>
+ <dd>The key whose value should be returned.</dd>
+ <dt><code>aDefault</code> {{ optional_inline() }}</dt>
+ <dd>The value to return if the specified key isn't found. If you don't specify a default value, <code>undefined</code> is returned for keys that aren't found.</dd>
+</dl>
+
+<h6 id="返回值_4">返回值</h6>
+
+<p>The value of the specified key, or <code>undefined</code> if no matching key was found.</p>
+
+<h2 id="has()">has()</h2>
+
+<p>判断指定的键是否存在与当前字典对象中.</p>
+
+<pre><code>boolean has(
+  String </code><code>aKey
+</code><code>);</code>
+</pre>
+
+<h6 id="参数_5">参数</h6>
+
+<dl>
+ <dt><code>aKey</code></dt>
+ <dd>判断该键是否存在与当前字典对象中..</dd>
+</dl>
+
+<h6 id="返回值_5">返回值</h6>
+
+<p>如果指定的键存在与当前字典中,则返回<code>true</code>,否则返回<code>false</code>.</p>
+
+<h2 id="listitems()">listitems()</h2>
+
+<p>返回一个由当前字典中所有键值对组成的数组.</p>
+
+<div class="note">注: 数组中元素的排列顺序是任意的.</div>
+
+<pre>Array listitems();
+</pre>
+
+<h6 id="参数_6">参数</h6>
+
+<p>无</p>
+
+<h6 id="返回值_6">返回值</h6>
+
+<p>一个由当前字典中所有键值对组成的数组.</p>
+
+<h2 id="listkeys()">listkeys()</h2>
+
+<p>返回一个由当前字典中所有键组成的数组.</p>
+
+<div class="note"><strong>注:</strong> 数组中元素的排列顺序是任意的.</div>
+
+<pre>Array listkeys();
+</pre>
+
+<h6 id="参数_7">参数</h6>
+
+<p>无</p>
+
+<h6 id="返回值_7">返回值</h6>
+
+<p>一个由当前字典中所有键组成的数组.</p>
+
+<h2 id="listvalues()">listvalues()</h2>
+
+<p>返回一个由当前字典中所有值组成的数组.</p>
+
+<div class="note"><strong>注:</strong> 数组中元素的排列顺序是任意的.</div>
+
+<pre>Array listvalues();
+</pre>
+
+<h6 id="参数_8">参数</h6>
+
+<p>无</p>
+
+<h6 id="返回值_8">返回值</h6>
+
+<p>一个由当前字典中所有值组成的数组.</p>
+
+<h2 id="set()">set()</h2>
+
+<p>设置指定键所对应的值,如果该键不存在,则添加上这个新键.</p>
+
+<pre><code>void set(
+  String </code><code>aKey</code><code>,
+  Object aValue
+);</code>
+</pre>
+
+<h6 id="参数_9">参数</h6>
+
+<dl>
+ <dt><code>aKey</code></dt>
+ <dd>设置改建所对应的值.</dd>
+ <dt><code>aValue</code></dt>
+ <dd>为指定键所设置的新值.</dd>
+</dl>
+
+<h2 id="toJSON()">toJSON()</h2>
+
+<p>返回一个代表当前字典的 <a href="/zh-CN/JSON" title="zh-CN/JSON">JSON字符串</a>.</p>
+
+<pre>String toJSON();
+</pre>
+
+<h6 id="参数_10">参数</h6>
+
+<p>无</p>
+
+<h6 id="返回值_9">返回值</h6>
+
+<p>返回一个代表了该字典对象中所有键值对的JSON字符串,空字典将返回"{}".</p>
+
+<h2 id="toString()">toString()</h2>
+
+<p>返回一个代表该字典对象的字符串.</p>
+
+<pre>String toString();
+</pre>
+
+<h6 id="参数_11">参数</h6>
+
+<p>无</p>
+
+<h6 id="返回值_10">返回值</h6>
+
+<p>返回一个代表了该字典对象中所有键值对的字符串,空字典将返回"{}".</p>
+
+<h2 id="示例">示例</h2>
+
+<h3 id="创建和填充字典">创建和填充字典</h3>
+
+<p>下面的例子首先创建一个新的空字典,然后添加进一些键值对.</p>
+
+<pre class="brush: js">var myDict = new Dict();
+myDict.set("name", "John Smith");
+myDict.set("email", "jsmith@example.com");
+myDict.set("phone", "650-555-1234");
+</pre>
+
+<h3 id="判断字典中指定的键是否存在">判断字典中指定的键是否存在</h3>
+
+<p>接着上面的个例子,你可以检测某个键是否存在于<code>myDict</code>中:</p>
+
+<pre class="brush: js">if (myDict.has("email")) {
+  /* an "email" key exists on the object */
+}
+</pre>
diff --git a/files/zh-cn/mozilla/javascript_code_modules/downloads.jsm/download/index.html b/files/zh-cn/mozilla/javascript_code_modules/downloads.jsm/download/index.html
new file mode 100644
index 0000000000..41230df3c4
--- /dev/null
+++ b/files/zh-cn/mozilla/javascript_code_modules/downloads.jsm/download/index.html
@@ -0,0 +1,335 @@
+---
+title: Download
+slug: Mozilla/JavaScript_code_modules/Downloads.jsm/Download
+translation_of: Mozilla/JavaScript_code_modules/Downloads.jsm/Download
+---
+<p> <code>Download</code> 对象仅仅表示下载,同时包含相关的状态和行为。这个对象是短时存在的,但是它可被包含在<a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadList" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadList"><code>DownloadList</code></a> 对象,因此它能够通过用户接口调用和跨sessions.</p>
+
+<p>调用<a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm#createDownload()" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm#createDownload()"><code>Downloads.createDownload()</code></a> 方法可以创建一个新的<code>Download</code> 对象。</p>
+
+<h2 id="方法概览">方法概览</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise">Promise</a> <a href="#start()">start</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise">Promise</a> <a href="#launch()">launch</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise">Promise</a> <a href="#showContainingDirectory()">showContainingDirectory</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise">Promise</a> <a href="#cancel()">cancel</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise">Promise</a> <a href="#removePartialData()">removePartialData</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise">Promise</a> <a href="#whenSucceeded()">whenSucceeded</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise">Promise</a> <a href="#finalize()">finalize</a>([optional] boolean aRemovePartialData);</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="属性">属性</h2>
+
+<table class="standard-table" style="width: auto;">
+ <tbody>
+ <tr>
+ <td class="header">属性</td>
+ <td class="header">类型</td>
+ <td class="header">描述</td>
+ </tr>
+ <tr>
+ <td><code>canceled</code> {{ReadOnlyInline()}}</td>
+ <td><code>boolean</code></td>
+ <td>
+ <p>表示下载被取消。这个属性可设置为true,当被取消下载重新下载时被设置为false。</p>
+
+ <p>This property becomes true as soon as the <a href="#cancel()" title="#cancel()"><code>cancel()</code></a> method is called, though the <code>stopped</code> property might remain false until the cancellation request has been processed. Temporary files or part files may still exist even if they are expected to be deleted, until the <code>stopped</code> property becomes true.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>contentType</code></td>
+ <td><code>string</code></td>
+ <td>
+ <p>The MIME type of the download, for example "<code>text/plain</code>", or <code>null</code> if the MIME type is not available.</p>
+
+ <p>This property may be populated or changed while the download is in progress, using the MIME type provided by the server.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>currentBytes</code> {{ReadOnlyInline()}}</td>
+ <td><code>number</code></td>
+ <td>
+ <p>Number of bytes currently transferred. This value starts at zero, and may be updated regardless of the value of <code>hasProgress</code>.</p>
+
+ <div class="note"><strong>Note:</strong> You shouldn't rely on this property being equal to <code>totalBytes</code> to determine whether the download is completed.  You should use the individual state properties instead, since this value may not be updated after the last piece of data is transferred.</div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>error</code> {{ReadOnlyInline()}}</td>
+ <td><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadError" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadError"><code>DownloadError</code></a></td>
+ <td>When the download fails, this is set to a <code>DownloadError</code> instance indicating the cause of the failure. If the download has been completed successfully or has been canceled, this property is <code>null</code>. This property is reset to <code>null</code> when a failed download is restarted.</td>
+ </tr>
+ <tr>
+ <td><code>hasPartialData</code> {{ReadOnlyInline()}}</td>
+ <td><code>boolean</code></td>
+ <td>
+ <p>Indicates whether, at this time, there is any partially downloaded data that can be used when restarting a failed or canceled download.</p>
+
+ <p>This property is relevant while the download is in progress, and also if it failed or has been canceled. If the download has been completed successfully, this property is not relevant anymore.</p>
+
+ <p>Whether partial data can actually be retained depends on the saver and the download source, and may not be known before the download is started.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>hasProgress</code> {{ReadOnlyInline()}}</td>
+ <td><code>boolean</code></td>
+ <td>Indicates whether this download's <code>progress</code> property is able to report partial progress while the download proceeds, and whether the value in <code>totalBytes</code> is relevant. This depends on the saver and the download source.</td>
+ </tr>
+ <tr>
+ <td><code>launchWhenSucceeded</code></td>
+ <td><code>boolean</code></td>
+ <td>If this property is <code>true</code> when the download finishes successfully, the target file will be opened or executed automatically.</td>
+ </tr>
+ <tr>
+ <td><code>launcherPath</code></td>
+ <td><code>string</code></td>
+ <td>Local file path of the application to be used to launch the target file, or <code>null</code> if the file should be launched with the default application associated with the <code>contentType</code> property or the extension of the target file.</td>
+ </tr>
+ <tr>
+ <td><code>onchange</code></td>
+ <td><code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Function" title="/en-US/docs/JavaScript/Reference/Global_Objects/Function">Function</a></code></td>
+ <td>
+ <p>This can be set to a function that is called after other properties change.</p>
+
+ <div class="warning">
+ <p><strong>Warning:</strong> This property cannot be used if the download is part of a <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadList" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadList"><code>DownloadList</code></a>.</p>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>progress</code> {{ReadOnlyInline()}}</td>
+ <td><code>number</code></td>
+ <td>
+ <p>Progress percent, from 0 to 100. Intermediate values are reported only if <code>hasProgress</code> is true.</p>
+
+ <div class="note"><strong>Note:</strong> You shouldn't rely on this property being equal to 100 to determine whether the download is completed. You should use the individual state properties (for example, the <code>succeeded</code> property) instead.</div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>saver</code> {{ReadOnlyInline()}}</td>
+ <td><code>DownloadSaver</code></td>
+ <td>Saver object associated with this download.</td>
+ </tr>
+ <tr>
+ <td><code>source</code> {{ReadOnlyInline()}}</td>
+ <td><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadSource" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadSource"><code>DownloadSource</code></a></td>
+ <td>Source of this download.</td>
+ </tr>
+ <tr>
+ <td><code>startTime</code> {{ReadOnlyInline()}}</td>
+ <td><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Date" title="/en-US/docs/JavaScript/Reference/Global_Objects/Date"><code>Date</code></a></td>
+ <td>Indicates the start time of the download. When the download starts, this property is set to a valid <code>Date</code> object. The default value is <code>null</code> before the download starts.</td>
+ </tr>
+ <tr>
+ <td><code>stopped</code> {{ReadOnlyInline()}}</td>
+ <td><code>boolean</code></td>
+ <td>Indicates that the download never started, has been completed successfully, failed, or has been canceled. This property becomes <code>false</code> when a download is started for the first time, or when a failed or canceled download is restarted.</td>
+ </tr>
+ <tr>
+ <td><code>succeeded</code> {{ReadOnlyInline()}}</td>
+ <td><code>boolean</code></td>
+ <td>This propery is <code>true</code> if the download has been completed successfully.</td>
+ </tr>
+ <tr>
+ <td><code>target</code> {{ReadOnlyInline()}}</td>
+ <td><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadTarget" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadTarget"><code>DownloadTarget</code></a></td>
+ <td>Target of this download.</td>
+ </tr>
+ <tr>
+ <td><code>totalBytes</code> {{ReadOnlyInline()}}</td>
+ <td><code>number</code></td>
+ <td>
+ <p>When <code>hasProgress</code> is <code>true</code>, this indicates the total number of bytes to be transferred before the download finishes; this value can be zero if the file is empty.</p>
+
+ <p><strong>Note:</strong> This property's value may not match the actual final size of the downloaded file if the download is encoded during the network transfer. You can use the <code>DownloadTarget.size</code> property to get the actual size of the completely-downloaded file once the download has succeeded.</p>
+
+ <p>When <code>hasProgress</code> is <code>false</code>, this property is always zero.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>tryToKeepPartialData</code></td>
+ <td><code>boolean</code></td>
+ <td>
+ <p>Indicates whether any partially downloaded data should be retained, to use when restarting a failed or canceled download. The default is <code>false</code>.</p>
+
+ <p>Whether partial data can actually be retained depends on the saver and the download source, and may not be known before the download is started.</p>
+
+ <p>To have any effect, this property must be set before starting the download. Resetting this property to <code>false</code> after the download has already started will not remove any partial data.</p>
+
+ <div class="note"><strong>Note:</strong> If this property is set to <code>true</code>, care should be taken that partial data is removed before the reference to the download is discarded. This can be done using the <a href="#removePartialData()" title="#removePartialData()"><code>removePartialData()</code></a> or the <a href="#finalize()" title="#finalize()"><code>finalize()</code></a> methods.</div>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="方法">方法</h2>
+
+<h3 id="start()">start()</h3>
+
+<p>Starts the download for the first time, or restarts a download that failed or has been canceled.</p>
+
+<p>Calling this method when the download has been completed successfully has no effect, and the method returns a resolved promise. If the download is in progress, the method returns the same promise as the previous call.</p>
+
+<p>If the <code><a href="#cancel()" title="#cancel()">cancel()</a></code> method was called but the cancellation process has not finished yet, this method waits for the cancellation to finish, then restarts the download immediately.</p>
+
+<div class="note"><strong>Note:</strong> If you need to start a new download from the same source, rather than restarting a failed or canceled one, you should create a separate <code>Download</code> object with the same source as the current one.</div>
+
+<pre>Promise start();
+</pre>
+
+<h6 id="Parameters">Parameters</h6>
+
+<p>None.</p>
+
+<h6 id="Promise_resolves_to">Promise resolves to</h6>
+
+<p><code>undefined</code> when the download has finished successfully and you can access the target file.</p>
+
+<h6 id="Promise_can_be_rejected_with">Promise can be rejected with</h6>
+
+<p><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadError" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadError"><code>DownloadError</code></a> if the download failed.</p>
+
+<h3 id="launch()">launch()</h3>
+
+<p>Opens or executes the target file after download has completed.</p>
+
+<p>If the <code>launcherPath</code> property is <code>null</code>, the file will be opened with the default application for the MIME type specified in the <code>contentType</code> property. If the content type is not available, an attempt will be made to obtain it from the extension of the target file.</p>
+
+<p>If the <code>launcherPath</code> property is set, the file will be opened with the specified custom application.</p>
+
+<pre>Promise launch();
+</pre>
+
+<h6 id="Parameters_2">Parameters</h6>
+
+<p>None.</p>
+
+<h6 id="Promise_resolves_to_2">Promise resolves to</h6>
+
+<p><code>undefined</code> when the instruction to launch the file has been successfully given to the operating system. Note that the OS might still take a while until the file is actually launched.</p>
+
+<h3 id="showContainingDirectory()">showContainingDirectory()</h3>
+
+<p>Shows the folder containing the target file, or where the target file will be saved. This may be called at any time, even if the download failed or is currently in progress.</p>
+
+<pre>Promise showContainingDirectory();
+</pre>
+
+<h6 id="Parameters_3">Parameters</h6>
+
+<p>None.</p>
+
+<h6 id="Promise_resolves_to_3">Promise resolves to</h6>
+
+<p><code>undefined</code> when the instruction to open the containing folder has been successfully given to the operating system. Note that the OS might still take a while until the folder is actually opened.</p>
+
+<h3 id="cancel()">cancel()</h3>
+
+<p>Cancels the download.</p>
+
+<p>The cancellation request is asynchronous. Until the cancellation process finishes, temporary files or part files may still exist even if they are expected to be deleted.</p>
+
+<p>In case the download completes successfully before the cancellation request could be processed, this method has no effect, and it returns a resolved promise. You should check the properties of the download at the time the returned promise is resolved to determine if the download was canceled.</p>
+
+<p>Calling this method when the download has been completed successfully, failed, or has been canceled has no effect, and the method returns a resolved promise. This behavior is designed for the case where the call to <code>cancel</code> happens asynchronously, and is consistent with the case where the cancellation request could not be processed in time.</p>
+
+<pre>Promise cancel();
+</pre>
+
+<h6 id="Parameters_4">Parameters</h6>
+
+<p>None.</p>
+
+<h6 id="Promise_resolves_to_4">Promise resolves to</h6>
+
+<p><code>undefined</code> when the cancellation process has finished.</p>
+
+<h6 id="Promise_can_be_rejected_with_2">Promise can be rejected with</h6>
+
+<p>Never rejected.</p>
+
+<h3 id="removePartialData()">removePartialData()</h3>
+
+<p>Removes any partial data kept as part of a canceled or failed download.</p>
+
+<p>If the download is not canceled or failed, this method has no effect, and it returns a resolved promise. If the <code><a href="#cancel()" title="#cancel()">cancel()</a></code> method was called but the cancellation process has not finished yet, this method waits for the cancellation to finish, then removes the partial data.</p>
+
+<p>After this method has been called, if the <code>tryToKeepPartialData</code> property is still <code>true</code> when the download is restarted, partial data will be retained during the new download attempt.</p>
+
+<pre>Promise removePartialData();
+</pre>
+
+<h5 id="Parameters_5">Parameters</h5>
+
+<p>None.</p>
+
+<h5 id="Promise_resolves_to_5">Promise resolves to</h5>
+
+<p><code>undefined</code> when the partial data has been successfully removed.</p>
+
+<h3 id="whenSucceeded()">whenSucceeded()</h3>
+
+<p>Returns a promise that is resolved as soon as this download finishes successfully, even if the download was stopped and restarted meanwhile.</p>
+
+<p>You can use this property for scheduling download completion actions in the current session, for downloads that are controlled interactively. If the download is not controlled interactively, you should use the promise returned by the <a href="#start()" title="#start()"><code>start()</code></a> method instead, to check for success or failure.</p>
+
+<pre>Promise whenSucceeded();
+</pre>
+
+<h5 id="Parameters_6">Parameters</h5>
+
+<p>None.</p>
+
+<h5 id="Promise_resolves_to_6">Promise resolves to</h5>
+
+<p><code>undefined</code> when the download has finished successfully and you can access the target file.</p>
+
+<h5 id="Promise_can_be_rejected_with_3">Promise can be rejected with</h5>
+
+<p>Never rejected.</p>
+
+<h3 id="finalize()">finalize()</h3>
+
+<p>Ensures that the download is stopped, and optionally removes any partial data kept as part of a canceled or failed download. After this method has been called, the download cannot be started again.</p>
+
+<div class="note"><strong>Note:</strong> This method should be used in place of the <code><a href="#cancel()" title="#cancel()">cancel()</a></code> and <a href="#removePartialData()" title="#removePartialData()"><code>removePartialData()</code></a> methods while shutting down or disposing of the download object, to prevent other callers from interfering with the operation. This is required because cancellation and other operations are asynchronous.</div>
+
+<pre>Promise finalize(
+ boolean aRemovePartialData
+);
+</pre>
+
+<h5 id="Parameters_7">Parameters</h5>
+
+<dl>
+ <dt><code>aRemovePartialData</code> {{optional_inline()}}</dt>
+ <dd>Whether any partially downloaded data should be removed after the download has been stopped. The default is <code>false</code>.</dd>
+</dl>
+
+<h5 id="Promise_resolves_to_7">Promise resolves to</h5>
+
+<p><code>undefined</code> when the operation has finished successfully.</p>
+
+<h2 id="查看其他">查看其他</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm">Downloads.jsm</a></li>
+ <li><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadTarget">DownloadTarget</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/javascript_code_modules/downloads.jsm/index.html b/files/zh-cn/mozilla/javascript_code_modules/downloads.jsm/index.html
new file mode 100644
index 0000000000..1df73bfd16
--- /dev/null
+++ b/files/zh-cn/mozilla/javascript_code_modules/downloads.jsm/index.html
@@ -0,0 +1,306 @@
+---
+title: Downloads.jsm
+slug: Mozilla/JavaScript_code_modules/Downloads.jsm
+tags:
+ - Add-ons
+ - Download Manager
+ - Extensions
+ - Files
+ - JavaScript
+ - Modules
+ - NeedsTranslation
+ - TopicStub
+translation_of: Mozilla/JavaScript_code_modules/Downloads.jsm
+---
+<p>{{ gecko_minversion_header("26") }}</p>
+
+<p>The <code>Downloads.jsm</code> JavaScript code module provides a single entry point to interact with the downloading capabilities of the platform, including starting new downloads, controlling ongoing downloads, and retrieving download-related configuration. To use it, you first need to import the code module into your JavaScript scope:</p>
+
+<pre>Components.utils.import("resource://gre/modules/Downloads.jsm");
+</pre>
+
+<h2 id="Method_overview">Method overview</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise">Promise</a>&lt;<a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download">Download</a>&gt; <a href="#createDownload()">createDownload</a>(<a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object" title="/en-US/docs/JavaScript/Reference/Global_Objects/Object">Object</a> aProperties);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise">Promise</a>&lt;void&gt; <a href="#fetch()">fetch</a>(aSource, aTarget, [optional] <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object" title="/en-US/docs/JavaScript/Reference/Global_Objects/Object">Object</a> </code><code>aOptions);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise">Promise</a>&lt;<a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadList" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadList">DownloadList</a>&gt; <a href="#getList()">getList</a>(aType);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise">Promise</a>&lt;<a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadSummary" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadSummary">DownloadSummary</a>&gt; <a href="#getSummary()">getSummary</a>(aType);</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Constants">Constants</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Constant</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>PUBLIC</code></td>
+ <td>Work on downloads that were not started from a private browsing window.</td>
+ </tr>
+ <tr>
+ <td><code>PRIVATE</code></td>
+ <td>Work on downloads that were started from a private browsing window.</td>
+ </tr>
+ <tr>
+ <td><code>ALL</code></td>
+ <td>Work on both <code>Downloads.PRIVATE</code> and <code>Downloads.PUBLIC</code> downloads.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Properties">Properties</h2>
+
+<table class="standard-table" style="width: auto;">
+ <tbody>
+ <tr>
+ <td class="header">Attribute</td>
+ <td class="header">Type</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>Error</code> <span class="inlineIndicator readOnly readOnlyInline" title="This value may not be changed.">Read only </span></td>
+ <td><a href="/en-US/docs/JavaScript/Guide/Working_with_Objects#Using_a_constructor_function" title="/en-US/docs/JavaScript/Guide/Working_with_Objects#Using_a_constructor_function"><code>Constructor</code></a></td>
+ <td>Constructor for a <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadError" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadError"><code>DownloadError</code></a> object. When you catch an exception during a download, you can use this to verify if <code>ex instanceof Downloads.Error</code>, before reading the exception properties with the error details. Example (using <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Task.jsm" title="/en-US/docs/Mozilla/JavaScript_code_modules/Task.jsm"><code>Task.jsm</code></a>):
+ <pre class="brush: js">
+try {
+ yield Downloads.fetch(sourceUri, targetFile);
+} catch (ex if ex instanceof Downloads.Error &amp;&amp; ex.becauseTargetFailed) {
+ console.log("Unable to write to the target file, ignoring the error.");
+}</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Methods">Methods</h2>
+
+<h3 id="createDownload()">createDownload()</h3>
+
+<p>Creates a new <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download"><code>Download</code></a> object.</p>
+
+<pre>Promise&lt;Download&gt; createDownload(
+ Object aProperties
+);
+</pre>
+
+<h5 id="Parameters">Parameters</h5>
+
+<dl>
+ <dt><code>aProperties</code></dt>
+ <dd>Provides the initial properties for the newly created download. This matches the serializable representation of a <code><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download">Download</a></code> object. Some of the most common properties in this object include:
+ <ul>
+ <li><code>source</code>: String containing the URI for the download source. Alternatively, may be an {{Interface("nsIURI")}}, a <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadSource" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadSource"><code>DownloadSource</code></a> object, or an object with the following properties:
+ <ul>
+ <li><code>url</code>: String containing the URI for the download source.</li>
+ <li><code>isPrivate</code>: {{optional_inline()}} Indicates whether the download originated from a private window. If omitted, the download is public.</li>
+ <li><code>referrer</code>: {{optional_inline()}} String containing the referrer URI of the download source. Can be omitted or <code>null</code> if no referrer should be sent or the download source is not HTTP.</li>
+ </ul>
+ </li>
+ <li><code>target</code>: String containing the path of the target file. Alternatively, may be an {{Interface("nsIFile")}}, a <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadTarget" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadTarget"><code>DownloadTarget</code></a> object, or an object with the following properties:
+ <ul>
+ <li><code>path</code>: String containing the path of the target file.</li>
+ </ul>
+ </li>
+ <li><code>saver</code>: {{optional_inline()}} String representing the class of the download operation. If omitted, defaults to "copy". Alternatively, may be the serializable representation of a <code>DownloadSaver</code> object.</li>
+ </ul>
+ </dd>
+</dl>
+
+<h5 id="Promise_resolves_to">Promise resolves to</h5>
+
+<p>The newly created <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download"><code>Download</code></a> object.</p>
+
+<h3 id="fetch()">fetch()</h3>
+
+<p>Downloads data from a remote network location to a local file.</p>
+
+<p>This download method does not provide user interface or the ability to cancel or restart the download programmatically. For that, you should obtain a reference to a <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download"><code>Download</code></a> object using the <a href="#createDownload()" title="#createDownload()"><code>createDownload()</code></a> function.</p>
+
+<p>Since the download cannot be restarted, any partially downloaded data will not be kept in case the download fails.</p>
+
+<pre>Promise fetch(
+ aSource,
+ aTarget,
+ Object aOptions
+);
+</pre>
+
+<h5 id="Parameters_2">Parameters</h5>
+
+<dl>
+ <dt><code>aSource</code></dt>
+ <dd>String containing the URI for the download source. Alternatively, may be an {{Interface("nsIURI")}} or a <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadSource" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadSource"><code>DownloadSource</code></a> object.</dd>
+ <dt><code>aTarget</code></dt>
+ <dd>String containing the path of the target file. Alternatively, may be an {{Interface("nsIFile")}} or a <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadTarget" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadTarget"><code>DownloadTarget</code></a> object.</dd>
+ <dt><code>aOptions</code> {{optional_inline()}}</dt>
+ <dd>An optional object used to control the behavior of this function. You may pass an object with a subset of the following fields:
+ <ul>
+ <li><code>isPrivate</code>: {{optional_inline()}} Indicates whether the download originated from a private window. If omitted, the download is public.</li>
+ </ul>
+ </dd>
+</dl>
+
+<h5 id="Promise_resolves_to_2">Promise resolves to</h5>
+
+<p><code>undefined</code> when the download has finished successfully and you can access the target file.</p>
+
+<h5 id="Promise_can_be_rejected_with">Promise can be rejected with</h5>
+
+<p><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadError" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadError"><code>DownloadError</code></a> if the download failed.</p>
+
+<h3 id="getList()">getList()</h3>
+
+<p>Retrieves the specified type of <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadList" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadList"><code>DownloadList</code></a> object. There is one download list for each type, and this method always retrieves a reference to the same download list when called with the same argument.</p>
+
+<p>Calling this function may cause the download list to be reloaded from the previous session, if it wasn't loaded already.</p>
+
+<pre>Promise&lt;DownloadList&gt; getList(aType);
+</pre>
+
+<h5 id="Parameters_3">Parameters</h5>
+
+<dl>
+ <dt><code>aType</code></dt>
+ <dd>This can be <code>Downloads.PUBLIC</code>, <code>Downloads.PRIVATE</code>, or <code>Downloads.ALL</code>. Downloads added to the <code>Downloads.PUBLIC</code> and <code>Downloads.PRIVATE</code> lists are reflected in the <code>Downloads.ALL</code> list, and downloads added to the <code>Downloads.ALL</code> list are also added to either the <code>Downloads.PUBLIC</code> or the <code>Downloads.PRIVATE</code> list based on their properties.</dd>
+</dl>
+
+<h5 id="Promise_resolves_to_3">Promise resolves to</h5>
+
+<p>The requested <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadList" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadList"><code>DownloadList</code></a> object.</p>
+
+<h3 id="getSummary()">getSummary()</h3>
+
+<p>Retrieves the specified type of <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadSummary" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadSummary"><code>DownloadSummary</code></a> object. There is one download summary for each type, and this method always retrieves a reference to the same download summary when called with the same argument.</p>
+
+<p>Calling this function does not cause the list of public downloads to be reloaded from the previous session. The summary will behave as if no downloads are present until the <a href="#getList()" title="#getList()"><code>getList()</code></a> method is called.</p>
+
+<pre>Promise&lt;DownloadSummary&gt; getSummary(aType);
+</pre>
+
+<h5 id="Parameters_4">Parameters</h5>
+
+<dl>
+ <dt><code>aType</code></dt>
+ <dd>This can be <code>Downloads.PUBLIC</code>, <code>Downloads.PRIVATE</code>, or <code>Downloads.ALL</code>.</dd>
+</dl>
+
+<h5 id="Promise_resolves_to_4">Promise resolves to</h5>
+
+<p>The requested <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadSummary" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadSummary"><code>DownloadSummary</code></a> object.</p>
+
+<h2 id="Examples">Examples</h2>
+
+<h3 id="Downloading_to_a_local_file">Downloading to a local file</h3>
+
+<p>This example downloads an HTML file without showing progress, handling errors programmatically.</p>
+
+<pre class="brush: js">Components.utils.import("resource://gre/modules/Downloads.jsm");
+Components.utils.import("resource://gre/modules/osfile.jsm")
+Components.utils.import("resource://gre/modules/Task.jsm");
+
+Task.spawn(function () {
+
+ yield Downloads.fetch("http://www.mozilla.org/",
+ OS.Path.join(OS.Constants.Path.tmpDir,
+ "example-download.html"));
+
+ console.log("example-download.html has been downloaded.");
+
+}).then(null, Components.utils.reportError);
+</pre>
+
+<h3 id="Observing_downloads">Observing downloads</h3>
+
+<p>This example logs a message every time a change occurs in one of the global download lists.</p>
+
+<p>To demonstrate the logging, a new download is started while a message box is being shown. The download is stopped and removed from the list when the message box is closed, regardless of whether it has been completed or not.</p>
+
+<pre class="brush: js">Components.utils.import("resource://gre/modules/Downloads.jsm");
+Components.utils.import("resource://gre/modules/osfile.jsm")
+Components.utils.import("resource://gre/modules/Task.jsm");
+
+Task.spawn(function () {
+
+ let list = yield Downloads.getList(Downloads.ALL);
+
+ let view = {
+ onDownloadAdded: download =&gt; console.log("Added", download),
+ onDownloadChanged: download =&gt; console.log("Changed", download),
+ onDownloadRemoved: download =&gt; console.log("Removed", download)
+ };
+
+ yield list.addView(view);
+ try {
+ let download = yield Downloads.createDownload({
+ source: "http://www.mozilla.org/",
+ target: OS.Path.join(OS.Constants.Path.tmpDir, "example-download.html"),
+ });
+ list.add(download);
+ try {
+ download.start();
+ alert("Now monitoring all downloads. Close the message to stop.");
+ } finally {
+ yield list.remove(download);
+ yield download.finalize(true);
+ }
+ } finally {
+ yield list.removeView(view);
+ }
+
+}).then(null, Components.utils.reportError);
+</pre>
+
+<h2 id="Conversion_from_nsIDownloadManager">Conversion from nsIDownloadManager</h2>
+
+<p>Starting in Firefox for Desktop version 26, the {{interface("nsIDownloadManager")}} and {{interface("nsIDownload")}} interfaces are not available anymore.</p>
+
+<p>The new module works differently from the old component. In general, you should be aware of the following highlights:</p>
+
+<ul>
+ <li>There is no difference between active downloads and finished downloads. The <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download"><code>Download</code></a> object can be used without requiring direct database access.</li>
+ <li>Observer notifications (for example, <code>"dl-done"</code>) and download listeners are replaced by views on the <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadList" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/DownloadList"><code>DownloadList</code></a> object returned by the <a href="#getList()" title="#getList()"><code>getList()</code></a> method.</li>
+ <li>Object identity replaces the use of numeric identifiers. You can use <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download"><code>Download</code></a> objects as keys in a <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set"><code>Set</code></a> or <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map"><code>Map</code></a> to associate your own state to them for the session.</li>
+ <li>There is no separate count of active downloads. If a count is needed, it should be maintained using a view on a <code>DownloadList</code>.</li>
+ <li>The <code><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download#start()" title="/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm/Download#start()">start()</a></code> method can be used to restart a failed download. Handling of downloads that have been paused is also different.</li>
+</ul>
+
+<p>While some of the legacy methods and properties have an equivalent in <code>Downloads.jsm</code>, there might be subtle differences in behavior. For example, the properties that handle progress are now more detailed and don't use the special value <code>-1</code> anymore. You may see the documentation of the new methods and properties for details.</p>
+
+<h2 id="Using_it_in_a_XUL_app">Using it in a XUL app</h2>
+
+<p>In a XUL standalone application (running with XULRunner or <code>firefox --app</code>), you have to do additionnal things in order to use the new download manager. By default it is not enabled. It will be enabled when the <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=851471">bug 851471</a> will be closed. If you don't activate it, you could use Downloads.jsm, but your view will not be called by the external helper app service (when a user click on a file to download, in a web page). To enable the new download manager :</p>
+
+<ul>
+ <li>First you have to set the pref {{pref("browser.download.useJSTransfer")}} to <code>true</code>.</li>
+ <li>Then you should declare the new {{interface("nsITransfer")}} object during the startup of your app.</li>
+</ul>
+
+<pre> Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar)
+                   .registerFactory(Components.ID("{1b4c85df-cbdd-4bb6-b04e-613caece083c}"), "", "@mozilla.org/transfer;1", null);
+
+</pre>
+
+<p> </p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a class="internal" href="/en-US/docs/JavaScript_code_modules/Using" title="en-US/docs/JavaScript code modules/Using JavaScript code modules">Using JavaScript code modules</a></li>
+ <li><a class="internal" href="/en-US/docs/Mozilla/JavaScript_code_modules" title="en-US/docs/Mozilla/JavaScript code modules">JavaScript code modules</a></li>
+ <li><a class="internal" href="/en-US/docs/Components.utils.import" title="en-US/docs/Components.utils.import"><code>Components.utils.import</code></a></li>
+</ul>
+
+<div id="xunlei_com_thunder_helper_plugin_d462f475-c18e-46be-bd10-327458d045bd"> </div>
diff --git a/files/zh-cn/mozilla/javascript_code_modules/geometry.jsm/index.html b/files/zh-cn/mozilla/javascript_code_modules/geometry.jsm/index.html
new file mode 100644
index 0000000000..bc18819d7a
--- /dev/null
+++ b/files/zh-cn/mozilla/javascript_code_modules/geometry.jsm/index.html
@@ -0,0 +1,19 @@
+---
+title: Geometry.jsm
+slug: Mozilla/JavaScript_code_modules/Geometry.jsm
+translation_of: Mozilla/JavaScript_code_modules/Geometry.jsm
+---
+<p>{{ gecko_minversion_header("2.0") }}</p>
+<p>The <code>Geometry.jsm</code> JavaScript code module provides routines for performing common geometry operations on points and rectangles. It exports two classes: <code>Point</code> and <code>Rect</code>.</p>
+<p>To use these routines, you first need to import the code module into your JavaScript scope:</p>
+<pre class="eval"><span class="nowiki">Components.utils.import("resource://gre/modules/Geometry.jsm");</span>
+</pre>
+<p>Once you've imported the module, you can then use the <a href="/zh-CN/JavaScript_code_modules/Geometry.jsm/Point" title="zh-CN/JavaScript code modules/Geometry.jsm/Point"><code>Point</code></a> and <a href="/zh-CN/JavaScript_code_modules/Geometry.jsm/Rect" title="https://developer.mozilla.org/zh-CN/JavaScript_code_modules/Geometry.jsm/Rect"><code>Rect</code></a> classes.</p>
+<div class="note">
+ <strong>Note:</strong> Although this module is usable from mobile, and is present in Firefox 4, it's currently not used in Firefox 4 and attempting to use it may produce unreliable results there.</div>
+<h2 id="See_also">See also</h2>
+<ul>
+ <li><a class="internal" href="/zh-CN/JavaScript_code_modules/Using" title="zh-CN/JavaScript code modules/Using JavaScript code modules">Using JavaScript code modules</a></li>
+ <li><a class="internal" href="/zh-CN/JavaScript_code_modules" title="zh-CN/JavaScript code modules">JavaScript code modules</a></li>
+ <li><a class="internal" href="/zh-CN/Components.utils.import" title="zh-CN/Components.utils.import"><code>Components.utils.import</code></a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/javascript_code_modules/geometry.jsm/services.jsm/index.html b/files/zh-cn/mozilla/javascript_code_modules/geometry.jsm/services.jsm/index.html
new file mode 100644
index 0000000000..1acdc77cdf
--- /dev/null
+++ b/files/zh-cn/mozilla/javascript_code_modules/geometry.jsm/services.jsm/index.html
@@ -0,0 +1,25 @@
+---
+title: Services.jsm
+slug: Mozilla/JavaScript_code_modules/Geometry.jsm/Services.jsm
+translation_of: Mozilla/JavaScript_code_modules/Services.jsm
+---
+<p>{{ gecko_minversion_header("2") }}</p>
+<p>The <code>Services.jsm</code>  模块提供了一系列的javascript模块,用来简化各种常用的操作.</p>
+<p>在使用它们之前,你必须首先将<code>Services</code>模块导入到自己的作用域内:</p>
+<pre class="eval"><span class="nowiki">Components.utils.import("resource://gre/modules/Services.jsm");</span>
+</pre>
+<p>然后你可以通过服务访问器来轻松的从<code>Services对象导出所需要的模块</code>. 例如,要想获取一个preferences服务,你可以用下面的语句:</p>
+<pre class="brush: js">var prefsService = Services.prefs;
+</pre>
+<h2 id="服务访问器">服务访问器</h2>
+<table class="standard-table" style="width: auto;"> <tbody> <tr> <td class="header"><span class="short_text" id="result_box" lang="zh-CN"><span>服务</span><span class="alt-edited">访问器</span></span></td> <td class="header">服务接口</td> <td class="header">服务名</td> </tr> <tr> <td><code>appinfo</code></td> <td>{{ interface("nsIXULAppInfo") }}<br> {{ interface("nsIXULRuntime") }}</td> <td>Application information service</td> </tr>
+ <tr> <td><code>console</code></td> <td>{{ interface("nsIConsoleService") }}</td> <td>Error console service</td> </tr> <tr> <td><code>contentPrefs</code></td> <td>{{ interface("nsIContentPrefService") }}</td> <td> <p>Content Preferences service</p> </td> </tr> <tr> <td><code>cookies</code></td> <td>{{ interface("nsICookieManager2") }}</td> <td> <p>Cookie Manager 2 service</p> </td> </tr> <tr> <td><code>dirsvc</code></td> <td>{{ interface("nsIDirectoryService") }}<br> {{ interface("nsIProperties") }}</td> <td>Directory service</td> </tr> <tr> <td><code>droppedLinkHandler</code></td> <td>{{ interface("nsIDroppedLinkHandler") }}</td> <td>Dropped link handler service</td> </tr> <tr> <td><code>eTLD</code></td> <td>{{ interface("nsIEffectiveTLDService") }}</td> <td> <p>EffectiveTLD service</p> </td> </tr> <tr> <td><code>io</code></td> <td>{{ interface("nsIIOService") }}<br> {{ interface("nsIIOService2") }}</td> <td>I/O Service</td> </tr> <tr> <td><code>locale</code></td> <td>{{ interface("nsILocaleService") }}</td> <td>Locale service</td> </tr> <tr> <td><code>logins</code></td> <td>{{ interface("nsILoginManager") }}</td> <td> <p>Password Manager service</p> </td> </tr> <tr> <td><code>obs</code></td> <td>{{ interface("nsIObserverService") }}</td> <td>Observer service</td> </tr> <tr> <td><code>perms</code></td> <td>{{ interface("nsIPermissionManager") }}</td> <td>Permission manager service</td> </tr> <tr> <td><code>prefs</code></td> <td>{{ interface("nsIPrefBranch") }}<br> {{ interface("nsIPrefBranch2") }}<br> {{ interface("nsIPrefService") }}</td> <td>Preferences service</td> </tr> <tr> <td><code>prompt</code></td> <td>{{ interface("nsIPromptService") }}</td> <td>Prompt service</td> </tr> <tr> <td><code>scriptloader</code></td> <td>{{ interface("mozIJSSubScriptLoader") }}</td> <td>JavaScript subscript loader service</td> </tr> <tr> <td><code>search</code></td> <td>{{ interface("nsIBrowserSearchService") }}</td> <td>Browser search service1</td> </tr> <tr> <td><code>startup</code></td> <td>{{ interface("nsIAppStartup") }}</td> <td>Application startup service</td> </tr> <tr> <td><code>storage</code></td> <td>{{ interface("mozIStorageService") }}</td> <td><a href="/zh-cn/Storage" title="zh-cn/Storage">Storage API</a> service</td> </tr> <tr> <td><code>strings</code></td> <td>{{ interface("nsIStringBundleService") }}</td> <td>String bundle service</td> </tr> <tr> <td><code>sysinfo</code></td> <td>{{ interface("nsIPropertyBag2") }}</td> <td>System info service</td> </tr> <tr> <td><code>telemetry</code></td> <td>{{ interface("nsITelemetry") }}</td> <td>Telemetry service</td> </tr> <tr> <td><code>tm</code></td> <td>{{ interface("nsIThreadManager") }}</td> <td><a href="/zh-cn/The_Thread_Manager" title="zh-cn/The Thread Manager">Thread Manager</a> service</td> </tr> <tr> <td><code>urlFormatter</code></td> <td>{{ interface("nsIURLFormatter") }}</td> <td> <p>URL Formatter service</p> </td> </tr> <tr> <td><code>vc</code></td> <td>{{ interface("nsIVersionComparator") }}</td> <td>Version comparator service</td> </tr> <tr> <td><code>wm</code></td> <td>{{ interface("nsIWindowMediator") }}</td> <td>Window mediator service</td> </tr> <tr> <td><code>ww</code></td> <td>{{ interface("nsIWindowWatcher") }}</td> <td>Window watcher service</td> </tr> <tr> <td><code>DOMRequest</code></td> <td>{{ interface("nsIDOMRequestService") }}</td> <td>DOMRequest service</td> </tr> <tr> <td><code>cpmm</code></td> <td>{{ interface("nsIFrameMessageManager") }}</td> <td>Child Process Message Manager</td> </tr> <tr> <td>ppmm</td> <td>{{ interface("nsIFrameMessageManager") }}</td> <td>Parent Process Message Manager</td> </tr> </tbody>
+</table>
+<p>Thunderbird 和 SeaMonkey中该特性不可用.</p>
+<h2 id="相关链接">相关链接</h2>
+<ul> <li><a class="internal" href="/zh-cn/JavaScript_code_modules/Using" title="zh-cn/JavaScript code modules/Using
+ JavaScript code
+ modules">Using JavaScript code modules</a></li> <li><a class="internal" href="/zh-cn/JavaScript_code_modules" title="zh-cn/JavaScript code
+ modules">JavaScript code modules</a></li> <li><a class="internal" href="/zh-cn/XPCOM/mozilla::services_namespace" title="mozilla::services C++ namespace">mozilla::services C++ namespace</a></li>
+</ul>
+<p>{{ languages( { "en": "en/JavaScript_code_modules/Services.jsm" } ) }}</p>
diff --git a/files/zh-cn/mozilla/javascript_code_modules/http.jsm/index.html b/files/zh-cn/mozilla/javascript_code_modules/http.jsm/index.html
new file mode 100644
index 0000000000..1e77c4e852
--- /dev/null
+++ b/files/zh-cn/mozilla/javascript_code_modules/http.jsm/index.html
@@ -0,0 +1,74 @@
+---
+title: Http.jsm
+slug: Mozilla/JavaScript_code_modules/Http.jsm
+tags:
+ - API
+ - HTTP
+translation_of: Mozilla/JavaScript_code_modules/Http.jsm
+---
+<h2 id="HTTP.jsm">HTTP.jsm</h2>
+
+<p>Http.jsm 提供了 httpRequest-XMLHttpRequest的包装器,它为处理HTTP请求提供了方便和简化的API。</p>
+
+<p>httpRequest 支持以下参数:</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">name</th>
+ <th scope="col">meaning</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>headers</td>
+ <td>header 的数组</td>
+ </tr>
+ <tr>
+ <td>postData</td>
+ <td>
+ <p>取值范围:</p>
+
+ <ul>
+ <li>string: 按原样发送</li>
+ <li>数组: 编码为表单值</li>
+ <li>null/undefined: 没有POST数据.</li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>method</p>
+ </td>
+ <td>GET, POST , PUT (如果postData存在,将自动设置).</td>
+ </tr>
+ <tr>
+ <td>onLoad</td>
+ <td>
+ <p>加载完成时调用的方法,它接受两个参数:responseText和XHR对象。</p>
+ </td>
+ </tr>
+ <tr>
+ <td>onError</td>
+ <td>
+ <p>当错误发生时调用的方法,它接受三个参数:error、responseText和XHR对象。</p>
+ </td>
+ </tr>
+ <tr>
+ <td>logger</td>
+ <td>
+ <p>实现调试和日志方法的对象(例如log.jsm)。</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>header 或 postData 是作为二维数组给出的,对于每个内部数组,第一个值是键,第二个值是值。例如: [["key1", "value1"], ["key2", "value2"]].</p>
+
+<h2 id="提交_post_数据">提交 post 数据</h2>
+
+<p>httpRequest允许向post请求附加数据。可以通过postData选项指定数据。postData可以有两种类型:字符串或数组。当给出null/undefined时,将不发送任何数据。如果给定一个字符串,数据将按原样追加到请求中。如果给定一个参数数组,它将被视为一个键值对数组。数组的元素将采用url编码,并会强制设置content type为“application/x-www-form-urlencoded;charset=utf-8"。Http.jsm只在post数据是数组时强行设置content type,并自动序列化它。如果提供的postdata是一个字符串,则不设置内容类型。在这种情况下,可以通过header参数设置content type。</p>
+
+<h2 id="可选的XHR_配置">可选的XHR 配置</h2>
+
+<p>在调用httpRequest之后,可以手动修改XHR对象上的内容。httpRequest返回一个XHR对象,该对象可用于设置请求的附加参数。例如,可以将XHR配置为在处理响应时使用任何自定义mime类型,而不管服务器返回什么。为此,可以通过调用httpRequest获得XHR对象,然后调用它的<a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#overrideMimeType%28%29">overrideMimeType()</a>方法去设置MIME-Type。另一个<a href="http://mxr.mozilla.org/comm-central/source/chat/protocols/twitter/twitter.js#690">例子</a>可以在这里找到。</p>
diff --git a/files/zh-cn/mozilla/javascript_code_modules/index.html b/files/zh-cn/mozilla/javascript_code_modules/index.html
new file mode 100644
index 0000000000..415663945b
--- /dev/null
+++ b/files/zh-cn/mozilla/javascript_code_modules/index.html
@@ -0,0 +1,84 @@
+---
+title: JavaScript 代码模块
+slug: Mozilla/JavaScript_code_modules
+tags:
+ - Add-ons(加载项)
+ - JavaScript
+ - TopicStub
+ - XPCOM
+ - mo
+ - 扩展
+ - 模块
+translation_of: Mozilla/JavaScript_code_modules
+---
+<p>{{Non-standard_Header}}</p>
+
+<div class="blockIndicator note">
+<p><strong>注意:</strong> JavaScript代码模块和JavaScript 标准中的模块(module)不是一回事。 要学习如何使用标准中的模块,请点击 {{JSxRef("Statements/export", "export")}} 和 {{JSxRef("Statements/import", "import")}} 查看。</p>
+</div>
+
+<p>JavaScript 代码模块用于具备不同权限的作用域之间的代码共享。例如,Firefox 可以使用模块,也可以通过扩展来使用模块,以避免重复代码。</p>
+
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h2 id="话题总览">话题总览</h2>
+
+ <dl>
+ <dt><a href="/en-US/docs/JavaScript_code_modules/Using" title="./Using">使用JavaScript代码模块</a></dt>
+ <dd>介绍如何使用JavaScript代码模块</dd>
+ <dt><a href="/en-US/docs/Components.utils.import" title="Components.utils.import">Component.utils.import</a></dt>
+ <dd>如何导入一个JavaScript的代码模块。</dd>
+ <dt><a href="/en-US/docs/Components.utils.unload" title="Components.utils.unload">Component.utils.unload</a> {{gecko_minversion_inline("7.0")}}</dt>
+ <dd>如何上传一个JavaScript的代码模块</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Modules" title="Code_snippets/Modules">代码片段: Module</a></dt>
+ <dd>如何使用模块代码的实例。</dd>
+ <dt><a class="external" href="http://wiki.mozilla.org/Labs/JS_Modules">Mozilla实验室的 JS Modules</a></dt>
+ <dd>本页面列出了JS模块的列表,以及下载链接和文档,扩展开发人员可以在代码中使用它们。</dd>
+ </dl>
+
+ <dl>
+ </dl>
+ </td>
+ <td>
+ <h2 id="标准代码模块">标准代码模块</h2>
+
+ <dl>
+ <dt><a href="/en-US/docs/Mozilla/js-ctypes" title="./ctypes.jsm">ctypes.jsm</a> {{fx_minversion_inline("3.6")}}</dt>
+ <dd>提供一个允许JS代码在不需要开发一个XPCOM元素的前提下调用本地库的接口。</dd>
+ <dt><a href="/en-US/docs/JavaScript_code_modules/FileUtils.jsm" title="./FileUtils.jsm"><strong style="font-weight: bold;">FileUtils.jsm</strong></a> {{gecko_minversion_inline("1.9.2")}}</dt>
+ <dd>提供处理文件的有用的方法</dd>
+ <dt><a href="/en-US/docs/JavaScript_code_modules/Geometry.jsm" title="JavaScript code modules/Geometry.jsm">Geometry.jsm</a> {{gecko_minversion_inline("2.0")}}</dt>
+ <dd>提供用于对点和矩形执行基本几何操作的方法。</dd>
+ <dt><a href="/en-US/docs/JavaScript_code_modules/ISO8601DateUtils.jsm" title="./ISO8601DateUtils.jsm">ISO8601DateUtils.jsm</a></dt>
+ <dd>提供在JavaScript <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Date" title="JavaScript/ Reference/Global Objects/Date"><code>Date</code></a> 对象和ISO 8601 data字符串之间转换的方法。</dd>
+ <dt><a href="/en-US/docs/JavaScript_code_modules/Dict.jsm" title="JavaScript code modules/Dict.jsm">Dict.jsm</a> {{gecko_minversion_inline("5.0")}}</dt>
+ <dd>提供一个可以访问键值对词典的API。</dd>
+ <dt><a href="/en-US/docs/JavaScript_code_modules/NetUtil.jsm" title="./NetUtil.jsm"><strong style="font-weight: bold;">NetUtil.jsm</strong></a></dt>
+ <dd>提供一些有用的网络实用函数,使您能够轻松地将输入流中的数据异步复制到输出流的。</dd>
+ <dt><a href="/en-US/docs/JavaScript_code_modules/PopupNotifications.jsm" title="JavaScript code modules/PopupNotifications.jsm">PopupNotifications.jsm</a> {{gecko_minversion_inline("2.0")}}</dt>
+ <dd>提供一种给用户弹出非模态(non-modal)通知的简便方法</dd>
+ <dt><a href="/en-US/docs/JavaScript_code_modules/openLocationLastURL.jsm" title="./openLocationLastURL.jsm">openLocationLastURL.jsm</a> {{gecko_minversion_inline("1.9.1.4")}}</dt>
+ <dd>提供读取使用文件菜单中的“打开定位(Open Location)” 时打开的最后一个URL的能力。</dd>
+ <dt><a href="/en-US/docs/JavaScript_code_modules/DownloadLastDir.jsm" title="JavaScript/Code modules/DownloadLastDir.jsm">DownloadLastDir.jsm</a> {{gecko_minversion_inline("2.0")}}</dt>
+ <dd>提供最后一次下载时的目录路径。</dd>
+ <dt><a href="/en-US/docs/Localization_and_Plurals" title="Localization and Plurals">PluralForm.jsm</a></dt>
+ <dd>提供获取当前区域使用的正确的复数形式的一种简便方法,当然也可以使用一种指定的复数规则来将一个词语复数化。</dd>
+ <dt><a href="/en-US/docs/JavaScript_code_modules/Services.jsm" title="./Services.jsm">Services.jsm</a> {{gecko_minversion_inline("2.0")}}</dt>
+ <dd>提供getter来方便地获取对一些常用服务的访问。</dd>
+ <dt><a href="/en-US/docs/JavaScript_code_modules/source-editor.jsm" title="JavaScript_code_modules/source-editor.jsm">source-editor.jsm</a> {{fx_minversion_inline("11.0")}}</dt>
+ <dd>源编辑器(Souce Editor)是指那些you开发者工具所提供的编辑器,如样式编辑器;此接口实现了源编辑器,并且允许你与之交互。</dd>
+ <dt><a href="/en-US/docs/JavaScript_code_modules/XPCOMUtils.jsm" title="./XPCOMUtils.jsm">XPCOMUtils.jsm</a></dt>
+ <dd>包含一些为JS组件加载器所加载的JavaScript组件的实用程序。</dd>
+ <dt><a href="/en-US/docs/JavaScript_code_modules/PerfMeasurement.jsm" title="JavaScript/Code_modules/PerfMeasurement.jsm">PerfMeasurement.jsm</a> {{fx_minversion_inline("4.0")}}</dt>
+ <dd>提供对底层硬件和操作系统性能测量工具的访问。</dd>
+ <dt><a href="/en-US/docs/Addons/Add-on_Manager" title="Addons/Add-on_Manager">AddonManager.jsm</a> {{gecko_minversion_inline("2.0")}}</dt>
+ <dd>安装、管理和卸载加载项(add-ons)的接口。</dd>
+ <dt><a href="/en-US/docs/Addons/Add-on_Repository" title="Addons/Add-on Repository">AddonRepository.jsm</a> {{gecko_minversion_inline("2.0")}}</dt>
+ <dd>允许搜索加载项(add-ons)列表。</dd>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
diff --git a/files/zh-cn/mozilla/javascript_code_modules/promise.jsm/deferred/index.html b/files/zh-cn/mozilla/javascript_code_modules/promise.jsm/deferred/index.html
new file mode 100644
index 0000000000..aa0d921e0c
--- /dev/null
+++ b/files/zh-cn/mozilla/javascript_code_modules/promise.jsm/deferred/index.html
@@ -0,0 +1,190 @@
+---
+title: Deferred
+slug: Mozilla/JavaScript_code_modules/Promise.jsm/Deferred
+translation_of: Mozilla/JavaScript_code_modules/Promise.jsm/Deferred
+---
+<p> <code>Deferred</code> 对象返回了一个已经被废弃的方法<code>Promise.defer()</code> 并提供给新的promise用来改变promise的状态。</p>
+
+<p>从Gecko 30开始,该对象就已经被废弃,并建议不再使用。可以通过 <a href="/Mozilla/JavaScript_code_modules/Promise.jsm/Promise#Constructor" title="/Mozilla/JavaScript_code_modules/Promise.jsm/Promise#Constructor"><code>new Promise()</code></a> 构造新的promise取代,(或者使用向后/向前兼容的Deferred方法实现,如下:)。等价方法如下: </p>
+
+<pre class="brush: js">var deferred = Promise.defer();
+doSomething(function cb(good) {
+    if (good)
+        deferred.resolve();
+    else
+        deferred.reject();
+});
+return deferred.promise;</pre>
+
+<p>应写成:</p>
+
+<pre class="brush: js">return new Promise(function(resolve, reject) {
+    doSomething(function cb(good) {
+        if (good)
+            resolve();
+        else
+            reject();
+    });
+});</pre>
+
+<h2 id="方法概览">方法概览</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>void <a href="#resolve()">resolve</a>([optional] aValue);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#reject()">reject</a>([optional] aReason);</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="属性">属性</h2>
+
+<table class="standard-table" style="width: auto;">
+ <tbody>
+ <tr>
+ <td class="header">Attribute</td>
+ <td class="header">Type</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>promise</code> {{ReadOnlyInline()}}</td>
+ <td><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise"><code>Promise</code></a></td>
+ <td>新创建的promise,在pending阶段被初始化</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="方法">方法</h2>
+
+<h3 id="resolve()">resolve()</h3>
+
+<p>将指定的值赋给新建的promise,或者改变已存在的 promise 状态。如果关联的 promise 已经调用过 resolve 方法,无论是传入值、rejection,或另一个 promise,此方法都不会起效果。</p>
+
+<div class="note"><strong>Note:</strong> This function is bound to its associated promise when <a href="https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm#defer()" title="https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm#defer()"><code>Promise.defer()</code></a> is called, and can be called with any value of <code>this</code>.</div>
+
+<div class="note"><strong>Note:</strong> Calling this method with a pending promise as the <code>aValue</code> argument, and then calling it again with another value before the promise is resolved or rejected, will have no effect the second time, as the associated promise is already resolved to the pending promise value as its resolution.</div>
+
+<pre>void resolve(
+ aValue
+);
+</pre>
+
+<h6 id="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>aValue</code> <span class="inlineIndicator optional optionalInline">Optional</span></dt>
+ <dd>If this value is not a promise, including <code>undefined</code>, it becomes the fulfillment value of the associated promise. If this value is a promise, then the associated promise will be resolved to the passed promise, and follow the state as the provided promise (including any future transitions).</dd>
+</dl>
+
+<h3 id="reject()">reject()</h3>
+
+<p>Rejects the associated promise with the specified reason. If the promise has already been resolved, either to a value, a rejection, or another promise, this method does nothing.</p>
+
+<div class="note"><strong>Note:</strong> This function is bound to its associated promise when <a href="https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm#defer()" title="https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm#defer()"><code>Promise.defer()</code></a> is called, and can be called with any value of <code>this</code>.</div>
+
+<pre>void reject(
+ aReason
+);
+</pre>
+
+<h6 id="Parameters_2">Parameters</h6>
+
+<dl>
+ <dt><code>aReason</code> <span class="inlineIndicator optional optionalInline">Optional</span></dt>
+ <dd>
+ <p>The rejection reason for the associated promise. Although the reason can be <code>undefined</code>, it is generally an <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error" title="/en-US/docs/JavaScript/Reference/Global_Objects/Error"><code>Error</code></a> object, like in exception handling.</p>
+
+ <div class="note"><strong>Note:</strong> This argument should not be a promise. Specifying a rejected promise would make the rejection reason equal to the rejected promise itself, and not its rejection reason.</div>
+ </dd>
+</dl>
+
+<h2 id="Backwards_and_forwards_compatible_helper">Backwards and forwards compatible helper<a id="backwards_forwards_compatible" name="backwards_forwards_compatible"></a></h2>
+
+<p>This Deferred function can be used for backwards and forwards compatibility, due to a change that took place in Firefox 30.</p>
+
+<pre>function Deferred() {
+ // update 062115 for typeof
+ if (typeof(Promise) != 'undefined' &amp;&amp; Promise.defer) {
+ //need import of Promise.jsm for example: Cu.import('resource:/gree/modules/Promise.jsm');
+ return Promise.defer();
+ } else if (typeof(PromiseUtils) != 'undefined' &amp;&amp; PromiseUtils.defer) {
+ //need import of PromiseUtils.jsm for example: Cu.import('resource:/gree/modules/PromiseUtils.jsm');
+ return PromiseUtils.defer();
+ } else {
+ /* A method to resolve the associated Promise with the value passed.
+ * If the promise is already settled it does nothing.
+ *
+ * @param {anything} value : This value is used to resolve the promise
+ * If the value is a Promise then the associated promise assumes the state
+ * of Promise passed as value.
+ */
+ this.resolve = null;
+
+ /* A method to reject the assocaited Promise with the value passed.
+ * If the promise is already settled it does nothing.
+ *
+ * @param {anything} reason: The reason for the rejection of the Promise.
+ * Generally its an Error object. If however a Promise is passed, then the Promise
+ * itself will be the reason for rejection no matter the state of the Promise.
+ */
+ this.reject = null;
+
+ /* A newly created Promise object.
+ * Initially in pending state.
+ */
+ this.promise = new Promise(function(resolve, reject) {
+ this.resolve = resolve;
+ this.reject = reject;
+ }.bind(this));
+ Object.freeze(this);
+ }
+}</pre>
+
+<p>and use this function as would Promise.defer:</p>
+
+<pre class="brush: js">function funcWithDefer() {
+ var deferred = new Deferred();
+ var promise = deferred.promise;
+ promise.then(
+ function(aVal) {
+ console.log('Fullfilled - ', aVal);
+ },
+ function(aReason) {
+ console.error('Rejected - aReason:', aReason)
+ }
+ );
+
+ //deferred.resolve('aVal of resolved');
+ deferred.reject('reject val');
+
+ return promise;
+}
+
+var promise_funcWithDefer = funcWithDefer();
+promise_funcWithDefer.then(
+ function(aVal) {
+ console.log('Fullfilled - promise_funcWithDefer - ', aVal);
+ },
+ function(aReason) {
+ var refObj = {name:'promise_funcWithDefer', aReason:aReason};
+ console.error('Rejected - promise_funcWithDefer - ', refObj);
+ }
+).catch(
+ function(aCatch) {
+ console.error('Caught - promise_funcWithDefer - ', aCatch);
+ throw aCatch;
+ }
+);</pre>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm">Promise.jsm</a></li>
+</ul>
+
+<p>
+ <audio style="display: none;"> </audio>
+</p>
diff --git a/files/zh-cn/mozilla/javascript_code_modules/promise.jsm/index.html b/files/zh-cn/mozilla/javascript_code_modules/promise.jsm/index.html
new file mode 100644
index 0000000000..a02f5f0385
--- /dev/null
+++ b/files/zh-cn/mozilla/javascript_code_modules/promise.jsm/index.html
@@ -0,0 +1,172 @@
+---
+title: Promise.jsm
+slug: Mozilla/JavaScript_code_modules/Promise.jsm
+tags:
+ - NeedsTranslation
+ - TopicStub
+translation_of: Mozilla/JavaScript_code_modules/Promise.jsm
+---
+<p>{{ gecko_minversion_header("25") }}</p>
+<p>The <code>Promise.jsm</code> JavaScript code module implements the <a href="https://github.com/promises-aplus/promises-spec/blob/1.0.0/README.md" title="https://github.com/promises-aplus/promises-spec/blob/1.0.0/README.md">Promises/A+</a> proposal as known in April 2013. To use it, you first need to import the code module into your JavaScript scope:</p>
+<pre>Components.utils.import("resource://gre/modules/Promise.jsm");
+</pre>
+<div class="note">
+ <p><strong>Note:</strong> A preliminary promise module is also available starting from Gecko 17, though it didn't conform to the Promises/A+ proposal until Gecko 25:</p>
+ <pre>Components.utils.import("<strike>resource://gre/modules/commonjs/promise/core.js</strike>"); // Gecko 17 to 20
+Components.utils.import("<strike>resource://gre/modules/commonjs/sdk/core/promise.js</strike>"); // Gecko 21 to 24
+</pre>
+ <p>This implementation also includes helper functions that are specific to the Add-on SDK. While you may still import this module from the above paths, the recommended way for loading it is through the <a href="https://addons.mozilla.org/en-US/developers/docs/sdk/latest/modules/toolkit/loader.html" title="https://addons.mozilla.org/en-US/developers/docs/sdk/latest/modules/toolkit/loader.html">Add-on SDK loader</a>.</p>
+</div>
+<h2 id="Introduction">Introduction</h2>
+<p>For an introduction to promises, you may start from the <a class="external" href="https://addons.mozilla.org/en-US/developers/docs/sdk/latest/modules/sdk/core/promise.html" title="https://addons.mozilla.org/en-US/developers/docs/sdk/1.9/packages/api-utils/promise.html">Add-on SDK documentation</a>, keeping in mind that only the core subset is implemented in this module.</p>
+<p><u>A promise is an object representing a value that may not be available yet</u>. Internally, a promise can be in one of three states:</p>
+<ul>
+ <li><strong>Pending</strong>, when the final value is not available yet. This is the only state that may transition to one of the other two states.</li>
+ <li><strong>Fulfilled</strong>, when and if the final value becomes available. A <em>fulfillment value</em> becomes permanently associated with the promise. This may be any value, including <code>undefined</code>.</li>
+ <li><strong>Rejected</strong>, if an error prevented the final value from being determined. A <em>rejection reason</em> becomes permanently associated with the promise. This may be any value, including <code>undefined</code>, though it is generally an <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Error" title="/en-US/docs/JavaScript/Reference/Global_Objects/Error"><code>Error</code></a> object, like in exception handling.</li>
+</ul>
+<p>A reference to an existing promise may be received by different means, for example as the return value of a call into an asynchronous API. In this case, the state of the promise can be observed but not directly controlled.</p>
+<p>To observe the state of a promise, its <code>then</code> method must be used. This method registers callback functions that are called as soon as the promise is either fulfilled or rejected. The method returns a new promise, that in turn is fulfilled or rejected depending on the state of the original promise and on the behavior of the callbacks. For example, unhandled exceptions in the callbacks cause the new promise to be rejected, even if the original promise is fulfilled. See the documentation of the <code>then</code> method for details.</p>
+<p>Promises may also be created using the <a href="#defer()" title="#defer()"><code>Promise.defer()</code></a> function, the main entry point of this module. The function, along with the new promise, returns separate methods to resolve or reject the promise. See the documentation of the <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Deferred" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Deferred"><code>Deferred</code></a> object for details.</p>
+<h2 id="Method_overview">Method overview</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Deferred" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Deferred">Deferred</a> <a href="#defer()">defer</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise">Promise</a> <a href="#resolve()">resolve</a>([optional] aValue);</code></td>
+ </tr>
+ <tr>
+ <td><code><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise">Promise</a> <a href="#reject()">reject</a>([optional] aReason);</code></td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Methods">Methods</h2>
+<h3 id="defer()">defer()</h3>
+<p>Creates a new pending promise and provides methods to resolve or reject it.</p>
+<pre>Deferred defer();
+</pre>
+<h6 id="Parameters">Parameters</h6>
+<p>None.</p>
+<h6 id="Return_value">Return value</h6>
+<p>A new object, containing the new promise in the <code>promise</code> property, and the methods to change its state in the <code>resolve</code> and <code>reject</code> properties. See the <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Deferred" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Deferred"><code>Deferred</code></a> documentation for details.</p>
+<h3 id="resolve()">resolve()</h3>
+<p>Creates a new promise fulfilled with the specified value, or propagates the state of an existing promise.</p>
+<pre>Promise resolve(
+ aValue
+);
+</pre>
+<h6 id="Parameters_2">Parameters</h6>
+<dl>
+ <dt>
+ <code>aValue</code> {{ optional_inline() }}</dt>
+ <dd>
+ If this value is not a promise, including <code>undefined</code>, it becomes the fulfillment value of the returned promise. If this value is a promise, then the returned promise will be resolved with the value, i.e. it will eventually assume the same state as the provided promise.</dd>
+</dl>
+<h6 id="Return_value_2">Return value</h6>
+<p>A promise that can be pending, fulfilled, or rejected.</p>
+<h3 id="reject()">reject()</h3>
+<p>Creates a new promise rejected with the specified reason.</p>
+<pre>Promise reject(
+ aReason
+);
+</pre>
+<h6 id="Parameters_3">Parameters</h6>
+<dl>
+ <dt>
+ <code>aReason</code> {{ optional_inline() }}</dt>
+ <dd>
+ <p>The rejection reason for the returned promise. Although the reason can be <code>undefined</code>, it is generally an <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Error" title="/en-US/docs/JavaScript/Reference/Global_Objects/Error"><code>Error</code></a> object, like in exception handling.</p>
+ <div class="note">
+ <strong>Note:</strong> This argument should not be a promise. Specifying a rejected promise would make the rejection reason equal to the rejected promise itself, and not its rejection reason.</div>
+ </dd>
+</dl>
+<h6 id="Return_value_3">Return value</h6>
+<p>A rejected promise.</p>
+<h2 id="Examples">Examples</h2>
+<pre class="brush: js">Components.utils.import("resource://gre/modules/Promise.jsm");
+
+// This function creates and returns a new promise.
+function promiseValueAfterTimeout(aValue, aTimeout)
+{
+ let deferred = Promise.defer();
+
+ try {
+ // An asynchronous operation will trigger the resolution of the promise.
+ // In this example, we don't have a callback that triggers a rejection.
+ setTimeout(function () {
+ deferred.resolve(aValue);
+ }, aTimeout);
+ } catch (ex) {
+ // Generally, functions returning promises propagate exceptions through
+ // the returned promise, though they may also choose to fail early.
+ deferred.reject(ex);
+ }
+
+ // We don't return the deferred to the caller, but only the contained
+ // promise, so that the caller cannot accidentally change its state.
+ return deferred.promise;
+}
+
+// This code uses the promise returned be the function above.
+let promise = promiseValueAfterTimeout("Value", 1000);
+
+let newPromise = promise.then(function onFulfill(aValue) {
+ console.log("Fulfilled with this value: " + aValue);
+}, function onReject(aReason) {
+ console.log("Rejected with this reason: " + aReason);
+});
+
+// Unexpected errors should always be reported at the end of a promise chain.
+newPromise.then(null, Components.utils.reportError);</pre>
+<div class="note">
+ <strong>Note:</strong> More examples for consuming promises are available in the <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise">Promise object documentation</a>.</div>
+<h2 id="The_case_of_unhandled_rejections">The case of unhandled rejections</h2>
+<p>One of the difficult problems with promises is locating uncaught rejections.</p>
+<div class="warning">
+ <p><strong>Warning:</strong> When consuming promises, you should always handle or report errors (rejection reasons). See <a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise#Handling_errors_and_common_pitfalls" title="#Handling_errors_and_common_pitfalls">handling errors and common pitfalls</a>.</p>
+</div>
+<p>Rejection handlers provide information about the exact error time and location, but the handlers may sometimes be forgotten. Consider the following cases:</p>
+<pre class="brush: js" style="text-align: justify;">function f() {
+ return Promise.reject(new Error("BOOM!")); // If nobody catches the error, how will it be reported?
+}
+
+
+function g() {
+ return Promise.resolve().then(function() {
+ throw new Error("BOOM!"); // If nobody catches the error, how will it be reported?
+ });
+}
+
+function h() {
+ Promise.reject(new Error("BOOM!"); // Oops, we forgot to return the promise, nobody can catch it!
+}
+</pre>
+<p>We adopt the following strategy: if a promise is rejected at the time of its garbage-collection <strong>and</strong> if the promise is at the end of a promise chain (i.e. <code>thatPromise.then</code> has never been called), then we print a warning.</p>
+<div class="note">
+ <strong>Note:</strong> This warning is generated some time after the error occurred, and may provide less information about the error location. It generally indicates the need to insert a proper error handler. When a proper rejection handler is used, it effectively replaces this delayed reporting.</div>
+<pre class="brush: js">let deferred = Promise.defer();
+let p = deferred.promise.then();
+deferred.reject(new Error("I am an uncaught error"));
+deferred = null;
+p = null;</pre>
+<p><br>
+ In this snippet, since <code>deferred.promise</code> is not the last in the chain, no error will be reported for that promise. However, since <code>p</code> is the last promise in the chain, the error will be reported for <code>p</code>.<br>
+ <br>
+ Note that this may, in some cases, cause an error to be reported more than once. For instance, consider:</p>
+<pre class="brush: js">let deferred = Promise.defer();
+let p1 = deferred.promise.then();
+let p2 = deferred.promise.then();
+deferred.reject(new Error("I am an uncaught error"));
+p1 = p2 = deferred = null;</pre>
+<p><br>
+ In this snippet, the error is reported both at <code>p1</code> and at <code>p2</code>.</p>
+<h2 id="See_also">See also</h2>
+<ul>
+ <li><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise">Promise</a></li>
+ <li><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Deferred" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Deferred">Deferred</a></li>
+ <li><a class="internal" href="/en-US/docs/JavaScript_code_modules/Using" title="en-US/docs/JavaScript code modules/Using JavaScript code modules">Using JavaScript code modules</a></li>
+ <li><a class="internal" href="/en-US/docs/Mozilla/JavaScript_code_modules" title="en-US/docs/Mozilla/JavaScript code modules">JavaScript code modules</a></li>
+ <li><a class="internal" href="/en-US/docs/Components.utils.import" title="en-US/docs/Components.utils.import"><code>Components.utils.import</code></a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/javascript_code_modules/promise.jsm/promise/index.html b/files/zh-cn/mozilla/javascript_code_modules/promise.jsm/promise/index.html
new file mode 100644
index 0000000000..947fd3acdc
--- /dev/null
+++ b/files/zh-cn/mozilla/javascript_code_modules/promise.jsm/promise/index.html
@@ -0,0 +1,226 @@
+---
+title: Promise
+slug: Mozilla/JavaScript_code_modules/Promise.jsm/Promise
+translation_of: Mozilla/JavaScript_code_modules/Promise.jsm/Promise
+---
+<p><strong>Promise对象代表暂时不可用的值。</strong></p>
+
+<p>一个已存在的promise引用可以通过不同的方式被接收,如作为异步API的返回值。一旦得到一个promise对象,就可以调用其 <a href="#then()" title="#then()"><code>then()</code></a> 方法,以在其值可用时或者出现异常时执行一个动作。</p>
+
+<p>可以通过 <a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise$edit#Constructor" title="#Constructor"><code>new Promise()</code></a><code> </code>方法创建Promise对象,当使用一个已存在的Promise对象时,不需要引入 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm" title="#defer()"><code>Promise.jsm</code></a> 模块。</p>
+
+<p>promise内部状态可为以下三种之一:</p>
+
+<ul>
+ <li><strong>未完成状态(pending)</strong>,此时完成值还不可用,它是唯一一个能够转换为其他状态的状态。</li>
+ <li><strong>已完成状态(fulfilled)</strong>,此时<em>完成值</em>可用,完成值与promise永久绑定,可为任意值,包括<code>undefined。</code></li>
+ <li><strong>拒绝状态(rejected)</strong>,出现错误时,<em>拒绝理由</em>与promise永久绑定,可为任意值,包括<code>undefined</code>,一般情况下为 <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error" title="/en-US/docs/JavaScript/Reference/Global_Objects/Error"><code>Error</code></a> 对象。</li>
+</ul>
+
+<div class="note">
+<p><strong>备注: </strong>使用promise时,应该始终对异常(拒绝理由)进行处理或报告。如果你看见了"<strong>A promise chain failed to handle a rejection</strong>"的错误信息,你可能就需要检查你的代码。参见下面的 <a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise$edit#Handling_errors_and_common_pitfalls">异常处理和常见误区</a>。</p>
+</div>
+
+<h2 id="文档约定">文档约定</h2>
+
+<p>文档规定,完成值的类型通过尖括号内的内容指定。如 <code style="font-style: normal;"><a href="/en-US/docs/JavaScript_OS.File/OS.File_for_the_main_thread#OS.File.exists()" title="/en-US/docs/JavaScript_OS.File/OS.File_for_the_main_thread#OS.File.exists()">OS.File.exists</a></code> 方法返回一个完成值类型为<code>boolean</code>的promise:</p>
+
+<pre>Promise&lt;boolean&gt; exists(string path);
+</pre>
+
+<p>拒绝理由可能在function文档中单独规定,除非特别指定,一般使用 <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error" title="/en-US/docs/JavaScript/Reference/Global_Objects/Error"><code>Error</code></a> 对象作为拒绝理由。</p>
+
+<h2 id="方法概览">方法概览</h2>
+
+<table>
+ <tbody>
+ <tr>
+ <td><code>Promise <a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise$edit#then()">then</a>([optional] <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function" title="/en-US/docs/JavaScript/Reference/Global_Objects/Function">Function</a> onFulfill, </code><code>[optional] </code><code><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function" title="/en-US/docs/JavaScript/Reference/Global_Objects/Function">Function</a> onReject</code><code>);</code></td>
+ </tr>
+ <tr>
+ <td><code>Promise <a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise$edit#catch">catch</a>([optional] <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function">Function</a> onReject);</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="构造函数">构造函数</h2>
+
+<p>创建一个新的promise,初始化为等待状态,并提供解决函数的引用,用于改变其状态。</p>
+
+<pre><code>new Promise(executor);</code></pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>executor</code></dt>
+ <dd>
+ <p>该函数会马上被调用,它带有两个参数的函数对象:</p>
+
+ <p> </p>
+ </dd>
+ <dd>
+ <pre><code>executor(resolve, reject);</code></pre>
+
+ <p>构造函数直到执行完成才会返回。解决函数可以在任何时间被调用,在执行过程完成前后都可以,其目标是控制promise的最终状态。如果执行过程抛出异常,异常值会被传递到reject解决函数中。</p>
+ </dd>
+</dl>
+
+<h3 id="解决函数">解决函数</h3>
+
+<h4 id="resolve()">resolve()</h4>
+
+<p>用特定值满足绑定的promise,或者把状态传递到一个已存在的promise。如果绑定的promise已经被解决(可能是一个值,也可能是一个rejection,或者是另一个promise),该方法不会做任何事。</p>
+
+<div class="note">
+<p><strong>备注:</strong> 调用该方法时,如果用一个pending状态的promise作为aValue参数,然后在该promise状态改变为fullfilled或者rejected前用另一个值再次调用,第二次调用将不会生效,因为这个绑定的promise已经被pending promise所解决了。</p>
+</div>
+
+<pre><code>void resolve(
+ aValue
+);</code></pre>
+
+<h6 id="参数_2">参数</h6>
+
+<dl>
+ <dt><code>aValue</code>  可选</dt>
+ <dd>如果这个值不是一个promise,包括  <code>undefined</code>, 它会变成绑定promise的实现值。如果这个值是promise,绑定promise会被传递的promise解决,并跟随所提供的promise的状态(包括任何未来的转变)。</dd>
+</dl>
+
+<h4 id="reject()">reject()</h4>
+
+<p>用特定原因拒绝绑定的promise。如果promise已经被解决了,不管是值,拒绝,还是另一个promise,这个方法都不会做任何事。</p>
+
+<pre><code>void reject(
+ aReason
+);</code></pre>
+
+<h6 id="参数_3">参数</h6>
+
+<dl>
+ <dt><code>aReason</code> 可选</dt>
+ <dd>绑定promise的拒绝原因。通常是一个 <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error">Error</a> 对象,就像在异常处理那样,尽管理由也可以是 <code>undefined。</code></dd>
+</dl>
+
+<div class="note">
+<p><strong>备注:</strong> 该参数不应该是promise。要说明一个被拒绝的promise,应该让拒绝原因等于被拒绝promise自身,而非其拒绝原因。</p>
+</div>
+
+<h2 id="方法">方法</h2>
+
+<h3 id="then()">then()</h3>
+
+<p><span style="line-height: 1.5;">一旦promise完成或被拒绝,就立即执行一个回调函数,并返回一个新的promise对象,新promise的状态取决于promise和传入的回调函数</span></p>
+
+<div>回调函数始终会在<code>then</code>返回值后被调用,即使promise早已完成或已被拒绝。也可对多次调用同一个promise的<code>then</code>方法。所有的回调函数会按照其注册的顺序被调用。</div>
+
+<p> </p>
+
+<div class="warning">
+<p><strong>警告</strong>: 如果 <code>onFulfill</code> 抛出异常,不会调用 <code>onReject</code> ,异常也不会被捕获和输出到控制台(你会看到一个promise chain失败错误),可以在返回的promise上注册一个错误处理函数,以处理在任一回调中出现的异常(使用 catch() 或者 then() ),来处理发生在任何一个注册回调函数的异常。</p>
+</div>
+
+<p> </p>
+
+<div class="note">
+<p><strong>注意</strong>:当多次调用同一个promise的then方法,所有注册的回调函数独立执行。如,当在一个回调函数中出现异常时,不会影响后面回调函数的执行。回调函数的结果只会对其注册所使用的then方法返回的promise产生影响,每一次调用then方法返回的都是不同的promise对象。</p>
+</div>
+
+<pre>Promise then(
+ Function onFulfill,
+ Function onReject
+);
+</pre>
+
+<h6 id="参数_4">参数</h6>
+
+<dl>
+ <dt><code>onFulfill</code> {{optional_inline()}}</dt>
+ <dd>当promise完成时,会调用该函数,并将完成值作为其唯一参数传入,该函数的输出会决定新的promise的状态。如果该参数不是函数(通常为<code>null</code>),则由then返回的新的promise的状态为已完成,且完成值与原promise相同</dd>
+ <dt><code>onReject</code> {{optional_inline()}}</dt>
+ <dd>
+ <p>当promise被拒绝时,会调用该函数,并将拒绝理由作为其唯一参数传入,且该函数的输出会决定新的promise的状态。如果该参数不是函数(通常为<code>undefined</code>),则由<code>then</code>返回的新的promise的状态为拒绝,且拒绝理由与原promise相同。</p>
+ </dd>
+</dl>
+
+<h6 id="返回值">返回值</h6>
+
+<p>新的promise对象,初始状态为未完成,最终状态取决于回调函数的输出:</p>
+
+<ul>
+ <li>
+ <div>如果返回的不是promise,包括<code>undefined</code>,则新promise的状态为已完成,并将该返回值作为其完成值,即使原promises被拒绝</div>
+ </li>
+ <li>
+ <div><span style="line-height: 1.5;">如果抛出异常,则新的promise的状态为拒绝,并将该异常作为其拒绝理由,即使原promise已完成</span></div>
+ </li>
+ <li>
+ <div><span style="line-height: 1.5;">如果返回promise,则新promise的最终状态与回调函数返回的promise状态相同。</span></div>
+ </li>
+</ul>
+
+<div>
+<h3 id="catch()"><a name="catch">catch()</a></h3>
+
+<p>等价于调用<code>onFulfill参数为undefined的</code> <code>then()</code> 方法。如果你链式调用then( onFulfill ).catch( onReject ),onFulfill中抛出的异常会被捕捉并传递到onReject。</p>
+
+<pre><code>Promise catch(
+ Function onReject
+);</code></pre>
+
+<p>等价于以下调用:</p>
+
+<pre><code>p.then(undefined, logError);
+p.catch(logError);</code></pre>
+</div>
+
+<div> </div>
+
+<h2 id="调试">调试</h2>
+
+<p>按照设计,在不调用 <code style="font-style: normal;"><a href="#then()" title="#then()">then()</a></code>的情况下,promise的即时状态和值不能通过代码同步检测到。</p>
+
+<p>为了有助于调试,只有当手动检查promise时,才能看到那些不能通过代码访问的特殊属性的信息(目前由于缺少复杂的语言或调试器的支持,属性名是随机生成的)。</p>
+
+<p>这些代码可访问和可审查的属性有:</p>
+
+<ul>
+ <li><code><strong><span>{</span>{private:status}}</strong></code>: 0代表未完成,1代表已完成,2代表拒绝。</li>
+ <li><code><strong><span>{</span>{private:value}}</strong></code>:完成值或拒绝理由,仅在promise已完成或已拒绝时有值。</li>
+ <li><code><strong><span>{</span>{private:handlers}}</strong></code>: 对象数组,这些对象保存了对回调函数的引用,仅在未完成状态下可用。</li>
+</ul>
+
+<p style="text-align: center;"><img alt="Promise properties are visible in the debugger." src="https://mdn.mozillademos.org/files/6471/Promise-Debug-1.png" style="border-style: solid; border-width: 2px; height: 482px; margin-bottom: 15px; margin-top: 15px; width: 403px;"><img alt="Promise handlers can be watched from the Console." src="https://mdn.mozillademos.org/files/6473/Promise-Debug-2.png" style="border-style: solid; border-width: 2px; height: 161px; width: 977px;"></p>
+
+<h2 id="示例">示例</h2>
+
+<p id="如何抛出拒绝">请看 <a href="https://developer.mozilla.org/Mozilla/JavaScript_code_modules/Promise.jsm/Examples">示例</a> 页面.</p>
+
+<h2 id="异常处理和常见误区">异常处理和常见误区</h2>
+
+<p>promise应该报告未处理的错误,除非交给其他程序处理该错误。</p>
+
+<pre class="brush: js">// ###### WRONG: Silently drops any rejection notified by "OS.File.Exists".
+OS.File.exists(path).then(exists =&gt; { if (exists) myRead(path); });
+
+// ###### WRONG: Silently drops any exception raised by "myRead".
+OS.File.exists(path).then(exists =&gt; { if (exists) myRead(path); }, Components.utils.reportError);
+
+// CORRECT (for example, might report the exception "myRead is not defined")
+OS.File.exists(path).then(exists =&gt; { if (exists) myRead(path); })
+ .catch(null, Components.utils.reportError);
+
+// CORRECT (the function returns a promise, and the caller will handle the rejection)
+function myReadIfExists(path)
+{
+ return OS.File.exists(path).then(exists =&gt; { if (exists) myRead(path); });
+}</pre>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm">Promise.jsm</a></li>
+ <li><a href="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Deferred" title="/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Deferred">Deferred</a></li>
+ <li><a href="/en-US/docs/JavaScript_OS.File" title="/en-US/docs/JavaScript_OS.File">JavaScript OS.File</a></li>
+ <li><a href="http://kryogenix.org/days/2013/12/12/promises-promises">Promises, Promises</a>: a useful simple explanation by Stuart Langridge</li>
+ <li><a href="http://dom.spec.whatwg.org/#promises">WHATWG Living Standard</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/javascript_code_modules/timer.jsm/index.html b/files/zh-cn/mozilla/javascript_code_modules/timer.jsm/index.html
new file mode 100644
index 0000000000..83ae26b154
--- /dev/null
+++ b/files/zh-cn/mozilla/javascript_code_modules/timer.jsm/index.html
@@ -0,0 +1,33 @@
+---
+title: Timer.jsm
+slug: Mozilla/JavaScript_code_modules/Timer.jsm
+tags:
+ - JavaScript
+ - JavaScript计时器
+ - 插件
+ - 模块
+translation_of: Mozilla/JavaScript_code_modules/Timer.jsm
+---
+<p>{{ gecko_minversion_header("22") }}</p>
+
+<p>Timer.jsm JavaScript模块包含纯JavaScript对<a href="/en-US/docs/DOM/window.setTimeout" title="/en-US/docs/DOM/window.setTimeout"><code>setTimeout</code></a>、<code><a href="/en-US/docs/DOM/window.clearTimeout" title="/en-US/docs/DOM/window.clearTimeout">clearTimeout</a><font face="Open Sans, Arial, sans-serif">、</font></code><code><a href="/en-US/docs/Web/API/WindowTimers/setInterval">setInterval</a></code>和<a href="/en-US/docs/Web/API/WindowTimers/clearInterval"><code>clearInterval</code></a>功能的实现且适用于DOM窗口函数,但它还可以被那些无法访问DOM窗口的代码(如<a href="/en-US/docs/Mozilla/JavaScript_code_modules" title="/en-US/docs/Mozilla/JavaScript_code_modules">JavaScript模块</a>或<a href="/en-US/docs/The_message_manager" title="/en-US/docs/The_message_manager">框架里的脚本</a>)使用。</p>
+
+<p> </p>
+
+<p><code><font face="Open Sans, Arial, sans-serif">要使用</font>Timer.jsm,首先导入它:</code></p>
+
+<pre class="brush: js">Components.utils.import("resource://gre/modules/Timer.jsm");
+</pre>
+
+<p>然后如同在DOM窗口中一样使用setTimeout和clearTimeout,例如:</p>
+
+<pre class="brush: js">let timeoutID = setTimeout(function() { console.log("Hello!"); }, 500);
+
+clearTimeout(timeoutID);
+</pre>
+
+<p>类似地,你可以使用<code>setInterval和</code><code>clearInterval,比如:</code></p>
+
+<pre class="brush: js">let intervalID = setInterval(function() { console.log("Happening every 500ms!"); }, 500);
+
+clearInterval(intervalID);</pre>
diff --git a/files/zh-cn/mozilla/javascript_code_modules/using/index.html b/files/zh-cn/mozilla/javascript_code_modules/using/index.html
new file mode 100644
index 0000000000..41fdf9970e
--- /dev/null
+++ b/files/zh-cn/mozilla/javascript_code_modules/using/index.html
@@ -0,0 +1,194 @@
+---
+title: 使用 JavaScript 代码 modules 模式
+slug: Mozilla/JavaScript_code_modules/Using
+tags:
+ - Add-ons
+ - Extensions
+ - Guide
+ - JavaScript
+ - XPCOM
+translation_of: Mozilla/JavaScript_code_modules/Using
+---
+<p>{{ gecko_minversion_header("1.9") }}</p>
+
+<p>JavaScript code modules 在Gecko1.9中引入并被用于具备不同权限的作用域之间的代码共享。 Modules 也可以用于创建全局js单例,这在之前是通过使用XPCOM(跨平台组件模型)实现的。一个 JavaScript code module 是仅仅是位于注册位置的一些 JavaScript 代码。Module 被载入特定的js域,比如 XUL script or JavaScript XPCOM script, 通过<code><a href="/en/Components.utils.import" title="en/Components.utils.import">Components.utils.import()</a></code> or <code><a href="/en/Components.utils.import" title="en/Components.utils.import">Components.utils["import"]()</a></code>.</p>
+
+<h2 id="创建_JavaScript_code_module">创建 JavaScript code module</h2>
+
+<p>一个简单的例子my_module.jsm:</p>
+
+<pre class="brush: js notranslate" style="width: 900px;">var EXPORTED_SYMBOLS = ["foo", "bar"];
+
+function foo() {
+ return "foo";
+}
+
+var bar = {
+ name : "bar",
+ size : 3
+};
+
+var dummy = "dummy";
+</pre>
+
+<p>可以看到 module 使用规范的js语言来创建函数,对象,常量以及其他的数据类型。 Module 还定义了一个名为 <code>EXPORTED_SYMBOLS 的特殊数组,这个数组中的每一项都会被输出到声明中并且被注入到引入的作用域中。例如:</code></p>
+
+<pre class="brush: js notranslate">Components.utils.import("resource://app/my_module.jsm");
+
+alert(foo()); // displays "foo"
+alert(bar.size + 3); // displays "6"
+alert(dummy); // displays "dummy is not defined" because 'dummy' was not exported from the module
+</pre>
+
+<div class="note"><strong>Note:</strong> When you're testing changes to a code module, be sure to change the application's build ID (e.g. the version) before your next test run; otherwise, you may find yourself running the previous version of your code module's code still.</div>
+
+<h3 id="The_URL_for_a_code_module">The URL for a code module</h3>
+
+<p>正如你在上例中看到的, 你需要一个 URL 来导入一个代码块 (code module)。 (就像例子中的 "<a class="external" rel="freelink">resource://app/my_module.jsm</a>".)</p>
+
+<p>有三种模式的URL可供选择: <strong>chrome:……</strong>({{ gecko_minversion_inline("2") }}), <strong>resource:……</strong>, 或者 <strong>file:……</strong>.</p>
+
+<ul>
+ <li>如果你在为 Firefox 4 写一个扩展并且已经有了一个 <a href="/en/Chrome_Registration" title="en/Chrome registration">chrome.manifest</a>(里面是内容指示), 你可以将代码块 code module 放入你的内容文件夹并通过<code>chrome://&lt;yourextension&gt;/content/&lt;yourmodule&gt;.jsm指向它。</code></li>
+ <li>如果你的扩展或应用需要支持 Mozilla 1.9.x (Firefox 3.x), 你需要注册一个新的资源URL. 具体细节在这: <a href="#resource-urls">"Extending resource: URLs" section</a> .</li>
+</ul>
+
+<h3 id="通过code_modules共享对象">通过code modules共享对象</h3>
+
+<p><code><a href="/en/Components.utils.import" title="en/Components.utils.import">Components.utils.import()</a></code> 的一个非常重要行为就是 module 加载后会被缓存起来, 并且随后的的导入不会重新加载一个新版的module, 而是使用之前缓存的版本。这就意味着当导入 module 多次时, 一个给定的 module 会被共享多次。只要引入某个module,任何对数据,对象和函数的变化都会体现在不同的引入该module的域中。比如,一个简单的module被引入到两个不同的域中,在其中一个域中做改变,另一个域也共享这种改变。如下例 :</p>
+
+<p>Scope 1:</p>
+
+<pre class="brush: js notranslate">Components.utils.import("resource://app/my_module.jsm");
+
+alert(bar.size + 3); // displays "6"
+
+bar.size = 10;
+</pre>
+
+<p>Scope 2:</p>
+
+<pre class="brush: js notranslate">Components.utils.import("resource://app/my_module.jsm");
+
+alert(foo()); // displays "foo"
+alert(bar.size + 3); // displays "13"
+</pre>
+
+<p>这种共享行为可以被用来创建单例对象(singleton objects)并且可以被 跨windows 和 XUL script 和 XPCOM 组件所共享。</p>
+
+<p>注意:引入某个module的域获得了一组该module中定义的输出符号的按值复制的副本( by-value copy )。 对这些输出符号的改变或者重新定义不会传播到其他的域中。 (虽然对象的属性会通过引用来改变。)。例子如下:</p>
+
+<p>Scope 1:</p>
+
+<pre class="brush: js notranslate">Components.utils.import("resource://app/my_module.jsm");
+
+bar = "foo";
+alert(bar); // displays "foo"
+</pre>
+
+<p>Scope 2:</p>
+
+<pre class="brush: js notranslate">Components.utils.import("resource://app/my_module.jsm");
+
+alert(bar); // displays "[object Object]"
+</pre>
+
+<p>按值复制的主要效果就是简单类型的全局变量不会在不同的域之间共享。所以我们经常将变量放在大括号中,然后以对象的形式输出 (就像上例中的bar)。</p>
+
+<p>{{ h2_gecko_minversion("Unloading code modules", "7.0") }}</p>
+
+<p><code><a href="/en/Components.utils.unload" title="en/Components.utils.unload">Components.utils.unload()</a></code> 允许你卸载之前引入的module。该方法被调用后, 指向该module的引用可以继续工作,但是后续对该module的引入,就会重新加载并重新分配指向该module的引用值。</p>
+
+<h2 id="Extending_resource_URLs">Extending resource: URLs</h2>
+
+<p>{{ Gecko("2.0") }}之前,加载code module最常用的方式是—— <strong>resource:</strong> URLs. Resource URL 的基本语法如下:</p>
+
+<pre class="eval notranslate">resource://&lt;alias&gt;/&lt;relative-path&gt;/&lt;file.js|jsm&gt;
+</pre>
+
+<p><code>&lt;alias&gt;</code> 是某个位置的别称,通常是一个相对于应用程序或者 XUL runtime的物理位置。这是一些由XUL runtime设置的预定义的别称:</p>
+
+<ul>
+ <li><code>app</code> - XUL application 位置的别名</li>
+ <li><code>gre</code> -  XUL runtime 位置的别名</li>
+</ul>
+
+<p><code>&lt;relative-path&gt;</code> 可以是多层的,经常是相对于alias的位置。最常见的相对路径是 "modules" 并常常被XUL Runner and Firefox使用. Code modules 是简单的js文件以 .js or .jsm 作为后缀。</p>
+
+<p><code>&lt;alias&gt;</code> 对于你的插件必须是唯一的,因为应用和其他的扩展共享同样的命名空间对所有的别称。</p>
+
+<h3 id="使用chrome.manifest">使用chrome.manifest</h3>
+
+<p>The easiest way for extensions and XUL applications to add custom aliases is by registering an alias in the <a href="/en/Chrome_Registration" title="en/Chrome_Registration">chrome manifest</a> using a line like this:</p>
+
+<pre class="eval notranslate">resource <em>aliasname</em> <em>uri/to/files/</em>
+</pre>
+
+<p>For example, if the XPI for your <em>foo</em> extension includes a top-level modules/ directory containing the <em>bar.js</em> module (that is, the modules/ directory is a sibling to chrome.manifest and install.rdf), you could create an alias to that directory via the instruction:</p>
+
+<pre class="eval notranslate">resource foo modules/
+</pre>
+
+<p>(Don't forget the trailing slash!) You could then import the module into your JavaScript code via the statement:</p>
+
+<pre class="brush: js notranslate">Components.utils.import("resource://foo/bar.js");
+</pre>
+
+<h4 id="Programmatically_adding_aliases">Programmatically adding aliases</h4>
+
+<p>Custom aliases to paths that can be represented as an {{ interface("nsILocalFile") }} can be programmatically added as well. For example:</p>
+
+<pre class="brush: js notranslate">// Import Services.jsm unless in a scope where it's already been imported
+Components.utils.import("resource://gre/Services.jsm");
+
+var resProt = Services.io.getProtocolHandler("resource")
+ .QueryInterface(Components.interfaces.nsIResProtocolHandler);
+
+var aliasFile = Components.classes["@mozilla.org/file/local;1"]
+ .createInstance(Components.interfaces.nsILocalFile);
+aliasFile.initWithPath("/some/absolute/path");
+
+var aliasURI = Services.io.newFileURI(aliasFile);
+resProt.setSubstitution("myalias", aliasURI);
+
+// assuming the code modules are in the alias folder itself
+</pre>
+
+<h2 id="Notes">Notes</h2>
+
+<h3 id="自定义_modules_和_XPCOM_components">自定义 modules 和 XPCOM components</h3>
+
+<p>Note that prior to {{ Gecko("2.0") }} JavaScript XPCOM components are loaded before chrome registration. This means you can't use <code><a href="/en/Components.utils.import" title="en/Components.utils.import">Components.utils.import()</a></code> with your own resource URL at the top level in a component source. A possible solution is moving the call to <code><a href="/en/Components.utils.import" title="en/Components.utils.import">Components.utils.import()</a></code> into the XPCOM component constructor (<a class="external" href="http://groups.google.com/group/mozilla.dev.apps.firefox/browse_thread/thread/e178d41afa2ccc87?hl=en#" title="http://groups.google.com/group/mozilla.dev.apps.firefox/browse_thread/thread/e178d41afa2ccc87?hl=en#">discussion</a>).</p>
+
+<h3 id="Packaging_notes">Packaging notes</h3>
+
+<p>It's important to note that you should not typically put your JavaScript code modules in a JAR file in your add-on. Firefox 3.6 doesn't support them at all, and there's only one case in which it's remotely useful: a Firefox 4-only add-on which must be installed unpacked. Otherwise placing code modules in a JAR file breaks compatibility unnecessarily.</p>
+
+<h2 id="Importing_CommonJS_modules">Importing CommonJS modules</h2>
+
+<p>The JavaScript code modules described here are not the same thing as <a href="http://www.commonjs.org/specs/modules/1.0/">CommonJS modules</a>, but you can import CommonJS modules into any scope where you can use <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.import">Components.utils.import</a>. Just call the following:</p>
+
+<pre class="brush: js line-numbers language-js notranslate"><code class="language-js"><span class="keyword token">const</span> <span class="punctuation token">{</span> require <span class="punctuation token">}</span> <span class="operator token">=</span> Cu<span class="punctuation token">.</span><span class="keyword token">import</span><span class="punctuation token">(</span><span class="string token">"resource://gre/modules/commonjs/toolkit/require.js"</span><span class="punctuation token">,</span> <span class="punctuation token">{</span><span class="punctuation token">}</span><span class="punctuation token">)</span></code></pre>
+
+<p>This will import <code>require()</code> into your scope.</p>
+
+<p>You can then use that to import CommonJS modules. You can import <a href="/en-US/docs/Mozilla/Add-ons/SDK">Add-on SDK</a> modules in just the same way you could from an SDK add-on:</p>
+
+<pre class="brush: js notranslate">// import the SDK's base64 module
+
+var base64 = require("sdk/base64");
+base64.encode("hello"); // "aGVsbG8="</pre>
+
+<p>You can import other CommonJS modules, too, as long as you know the path to them:</p>
+
+<pre class="brush: js notranslate">// import my module
+
+var myModule = require("resource://path/to/my/module.js");</pre>
+
+<p>In this case, though, you might be better off <a href="/en-US/Add-ons/SDK/Low-Level_APIs/_loader">creating your own loader</a>, so you can specify the <code><a href="/en-US/Add-ons/SDK/Low-Level_APIs/_loader#paths">paths</a></code> property yourself.</p>
+
+<h2 id="See_also" name="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/JavaScript_code_modules">JavaScript code modules</a> topic page</li>
+</ul>
diff --git a/files/zh-cn/mozilla/javascript_tips/index.html b/files/zh-cn/mozilla/javascript_tips/index.html
new file mode 100644
index 0000000000..2de76fff08
--- /dev/null
+++ b/files/zh-cn/mozilla/javascript_tips/index.html
@@ -0,0 +1,112 @@
+---
+title: JavaScript 编程技巧
+slug: Mozilla/JavaScript_Tips
+translation_of: Mozilla/JavaScript_Tips
+---
+<h2 id="Function_and_variable_naming" name="Function_and_variable_naming">XUL 技巧</h2>
+
+<ul>
+ <li>在使用 XUL 覆盖层来插入代码时, 使用一个唯一的名称将函数和变量封装在对象内部,以避免与当前或未来的函数,变量名称发生冲突。</li>
+</ul>
+
+<pre class="eval">var UniqueName = {
+ _privateMember: 3,
+ publicMember: "A string",
+
+ init: function UN_init() {
+ this.doSomething(this.anotherMember);
+ },
+
+ doSomething: function UN_doSomething(aParam) {
+ alert(aParam);
+ }
+};
+</pre>
+
+<h2 id="XPConnect" name="XPConnect">XPConnect</h2>
+
+<ul>
+ <li>Don't use object methods and properties more than you have to. It is often faster to store the result in a temporary variable.</li>
+ <li>Don't call methods that you don't have to. For instance, <code>windowManager.getEnumerator(aType).hasMoreElements()</code> may be replaced with <code>windowManager.getMostRecentWindow(aType) != null for a single window</code>.</li>
+ <li>Don't query interfaces unless you need to access methods and properties of that interface. You do not have to query interfaces to compare objects, nor to pass objects as parameters (This is different from C++, where you <em>do</em> have to query interfaces in both cases).</li>
+ <li>Don't call <code>QueryInterface</code> unless you expect to succeed. Instead, use <code>instanceof</code>, e,g,:</li>
+</ul>
+
+<pre>if (target instanceof Components.interfaces.nsIRDFResource)
+ return target.Value;
+if (target instanceof Components.interfaces.nsIRDFLiteral)
+ return target.Value;
+return null;
+</pre>
+
+<ul>
+ <li>Don't test the return value of <code>QueryInterface</code>, it always returns the original variable if it succeeds. XPConnect knows all about tearoffs and modifies the object that you <code>QueryInterface</code> or <code>instanceof</code> to cache all its known interfaces.</li>
+ <li>When passing an object to an XPCOM method it is helpful if the object you pass is an XPCOM object, so that the C++ method access a C++ object. However, this is not always necessary or desirable. For instance the offline observer declared above is a JavaScript object that is registered with an XPCOM object, so that the call back from XPCOM executes the JavaScript method. Some XPCOM methods expect an object that implements several interfaces thus requiring you to write a <code>QueryInterface</code> method. However, in JavaScript this is quite simple even in the case of a weak reference which in C++ requires a helper class:</li>
+</ul>
+
+<pre>var weakObserver = {
+ QueryInterface: function QueryInterface(aIID) {
+ if (aIID.equals(Components.interfaces.nsIObserver) ||
+ aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
+ aIID.equals(Components.interfaces.nsISupports))
+ return this;
+ throw Components.results.NS_NOINTERFACE;
+ },
+ observe: function observe(aSubject, aTopic, aState) {
+ }
+}
+</pre>
+
+<ul>
+ <li>When declaring XPCOM methods, try to use the same names for method parameters as are used in the interface definition.</li>
+</ul>
+
+<h2 id="DOM_elements" name="DOM_elements">DOM 元素</h2>
+
+<ul>
+ <li>DOM 元素只是带有一些预缓存的接口的 XPCOM 对象。</li>
+ <li>不要调用 <a href="/zh-CN/docs/Web/API/Element/getAttribute">getAttribute</a> 方法来检查属性是否存在,使用<a href="/zh-CN/docs/Web/API/Element/hasAttribute"> hasAttribute</a> 代替。</li>
+ <li>倾向于通过childNode 循环的方式去遍历, 而不是对 first/lastChild 使用 next/previousSibling 。 使用 hasChildNodes() 而不是 <code>childNodes.length &gt; 0</code>. 类似的,使用 <code>document.getElementsByTagName(aTag).item(0) != null</code> 而不是 <code>document.getElementsByTagName(aTag).length &gt; 0</code>.</li>
+ <li>使用 localName 而不是 tagName.</li>
+ <li>XUL 元素有许多特性与属性相映射。这样做是有原因的,所以要使用它们!属性有:
+ <ul>
+ <li>id</li>
+ <li>align</li>
+ <li>dir</li>
+ <li>flex</li>
+ <li>orient</li>
+ <li>pack</li>
+ <li>observes</li>
+ <li>contextMenu</li>
+ <li>tooltip</li>
+ <li>width</li>
+ <li>height</li>
+ <li>minWidth</li>
+ <li>minHeight</li>
+ <li>maxWidth</li>
+ <li>maxHeight</li>
+ <li>persist</li>
+ <li>left</li>
+ <li>top</li>
+ <li>datasources</li>
+ <li>ref</li>
+ <li>tooltipText</li>
+ <li>statusText</li>
+ <li>allowEvents</li>
+ </ul>
+ </li>
+ <li>XUL also maps the <code>ordinal</code> attribute but this defaults to "1" if it is not present.</li>
+ <li>XUL also maps the <code>class</code> attribute, but unfortunately <code>class</code> is a reserved identifier, so the property is named <code>className</code>. (The property could have been implemented as <code>{{ mediawiki.external('"class"') }}</code> but that just looks silly.)</li>
+ <li>XUL also maps the <code>hidden</code> and <code>collapsed</code> attributes to properties, but note that these are boolean properties whereas the above list are all string properties.</li>
+ <li>XUL also maps other useful properties and methods using XBL bindings; these vary from element to element.</li>
+ <li>For best performance give ids to all important elements. However in addition to locating elements by tag name XUL also allows you to locate an element by attribute, starting at any element in the document.</li>
+</ul>
+
+<h2 id="References" name="References">References</h2>
+
+<ul>
+ <li>This was started as a reprint of <a class="external" href="http://neil.rashbrook.org/JS.htm" title="http://neil.rashbrook.org/JS.htm">Neil's guide</a></li>
+ <li>Some more current info on this <a class="external" href="http://autonome.wordpress.com/2006/03/24/">blog post</a></li>
+</ul>
+
+<p>{{ languages( { "ja": "ja/JavaScript_style_guide" } ) }}</p>
diff --git a/files/zh-cn/mozilla/js-ctypes/index.html b/files/zh-cn/mozilla/js-ctypes/index.html
new file mode 100644
index 0000000000..fc3eb24564
--- /dev/null
+++ b/files/zh-cn/mozilla/js-ctypes/index.html
@@ -0,0 +1,53 @@
+---
+title: js-ctypes
+slug: Mozilla/js-ctypes
+translation_of: Mozilla/js-ctypes
+---
+<p><strong>js-ctype</strong>可以让应用程序和浏览器扩展代码调用用C/C++语言编写的本地代码.C++的支持程度有限,查看{{bug("505907")}}了解更多详情.和二进制的XPCOM组件不同的是,用户编写的二进制文件可以用在多个版本的Firefox中.</p>
+<div class="note">
+ <strong>注:</strong> js-ctype只能在chrome代码中使用,也就是说,普通网页不能使用js-ctype,只有在扩展程序中可用.</div>
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h2 class="Documentation" id="Documentation" name="Documentation">文档</h2>
+ <dl>
+ <dt>
+ <a href="/zh-CN/docs/Mozilla/js-ctypes/Using_js-ctypes" title="Mozilla/js-ctypes/Using_js-ctypes">介绍:使用js-ctype</a></dt>
+ <dd>
+ 开始使用js-ctype.</dd>
+ <dt>
+ <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference" title="js-ctypes/js-ctypes_reference">JS-ctype参考</a></dt>
+ <dd>
+ 关于js-ctype API的参考指南.</dd>
+ <dt>
+ <a href="/zh-CN/docs/Mozilla/js-ctypes/Standard_OS_Libraries" title="Mozilla/js-ctypes/Standard_Libraries_per_OS">OS标准库</a></dt>
+ <dd>
+ 不同操作系统的标准库文档(比如:在Windows上哪个函数存在于哪个dll文件上的文档)</dd>
+ <dt>
+ <a href="/zh-CN/docs/Mozilla/js-ctypes/FAQ" title="js-ctypes/FAQ">相关问题</a></dt>
+ <dd>
+ 关于js-ctype的常见问题解答</dd>
+ </dl>
+ <p><span class="alllinks"><a href="/zh-CN/docs/tag/js-ctypes" title="tag/js-ctypes">View All...</a></span></p>
+ <h2 class="Tools" id="Examples" name="Examples"><a href="/zh-CN/docs/Mozilla/js-ctypes/Examples" title="Mozilla/js-ctypes/Examples">代码示例</a></h2>
+ <a href="/zh-CN/docs/Mozilla/js-ctypes/Examples/Add_to_iPhoto" title="Mozilla/js-ctypes/Examples/Add_to_iPhoto">添加到iPhoto</a>
+ <dl>
+ <dd>
+ 一个Firefox扩展,使用js-ctype调用了Mac OS X中的核心基础框架,从而在Firefox中实现了一个"添加到iPhoto"的功能.</dd>
+ </dl>
+ </td>
+ <td>
+ <h2 class="Community" id="Community" name="Community">社区</h2>
+ <ul>
+ <li>查看Mozilla论坛...{{DiscussionList("dev-extensions", "mozilla.dev.extensions")}}</li>
+ </ul>
+ <h2 class="Related_Topics" id="Related_Topics" name="Related_Topics">相关话题</h2>
+ <ul>
+ <li><a href="/zh-CN/docs/Extensions" title="Extensions">扩展</a></li>
+ </ul>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
diff --git a/files/zh-cn/mozilla/js-ctypes/js-ctypes_reference/ctypes/index.html b/files/zh-cn/mozilla/js-ctypes/js-ctypes_reference/ctypes/index.html
new file mode 100644
index 0000000000..e375c3df54
--- /dev/null
+++ b/files/zh-cn/mozilla/js-ctypes/js-ctypes_reference/ctypes/index.html
@@ -0,0 +1,534 @@
+---
+title: ctypes
+slug: Mozilla/js-ctypes/js-ctypes_reference/ctypes
+translation_of: Mozilla/js-ctypes/js-ctypes_reference/ctypes
+---
+<section class="Quick_links" id="Quick_Links">
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/js-ctypes"><strong><em>js-ctypes</em></strong></a></li>
+ <li class="toggle">
+ <details>
+ <summary>Introduction</summary>
+ <ol><li><a href="/zh-CN/docs/Mozilla/js-ctypes/Using_js-ctypes/Declaring_and_Using_Callbacks" title="C函数偶尔将函数指针作为参数,它们通常用作回调。.在这些情况下,js-ctypes允许您传递常规JavaScript函数作为回调。这是非常强大的,因为它允许本地代码透明地调用JavaScript。">Declaring and Using Callbacks</a> <a href="/zh-CN/docs/Mozilla/js-ctypes/Using_js-ctypes/Declaring_and_Using_Callbacks$translate" style="opacity: 0.5;" title="此页面仍未被本地化, 期待您的翻译!">[我来译!]</a></li></ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details open>
+ <summary>References</summary>
+ <ol><li><a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/ctypes" title="The ctypes object contains methods and predefined data types used to create and manage a library."><code>ctypes</code></a> <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/ctypes$translate" style="opacity: 0.5;" title="此页面仍未被本地化, 期待您的翻译!">[我来译!]</a></li></ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Examples</summary>
+
+ </details>
+ </li>
+ </ol>
+</section>
+
+
+
+<div class="blockIndicator draft">
+ <p><strong>草案</strong><br>
+ 本页尚未完工.</p>
+
+</div>
+
+<p>The <code>ctypes</code> object contains methods and predefined data types used to create and manage a library.</p>
+
+<h2 id="方法概览">方法概览</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>CType <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/ArrayType" title="此页面仍未被本地化, 期待您的翻译!"><code>ArrayType</code></a>(type[, length]);</code></td>
+ </tr>
+ <tr>
+ <td><code>CData <a href="#cast%28%29">cast</a>(data, type);</code></td>
+ </tr>
+ <tr>
+ <td><code>CType <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/FunctionType" title="此页面仍未被本地化, 期待您的翻译!"><code>FunctionType</code></a>(abi, returnType[, argType1, ...]);</code></td>
+ </tr>
+ <tr>
+ <td><code>CData <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/Int64" title="此页面仍未被本地化, 期待您的翻译!"><code>Int64</code></a>(n);</code></td>
+ </tr>
+ <tr>
+ <td><code>String <a href="#libraryName%28%29">libraryName</a>(name);</code></td>
+ </tr>
+ <tr>
+ <td><code>Library <a href="#open%28%29">open</a>(libSpec);</code></td>
+ </tr>
+ <tr>
+ <td><code>CType <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/PointerType" title="此页面仍未被本地化, 期待您的翻译!"><code>PointerType</code></a>(typeSpec);</code></td>
+ </tr>
+ <tr>
+ <td><code>CType <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/StructType" title="此页面仍未被本地化, 期待您的翻译!"><code>StructType</code></a>(name[, fields]);</code></td>
+ </tr>
+ <tr>
+ <td><code>CData <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/UInt64" title="此页面仍未被本地化, 期待您的翻译!"><code>UInt64</code></a>(n);</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="属性">属性</h2>
+
+<table class="standard-table" style="width: auto;">
+ <tbody>
+ <tr>
+ <td class="header">Property</td>
+ <td class="header">Type</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>errno</code></td>
+ <td><code>Number</code></td>
+ <td>最后一次的系统错误。与库中的errno一样,所有平台都一样,不能被设置。.</td>
+ </tr>
+ <tr>
+ <td><code>winLastError</code></td>
+ <td><code>Number|undefined</code></td>
+ <td>最后一次发生的Windows 的错误。与Windows下的 GetLastError类似,只在Window下有效,不能被设置。</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="常量">常量</h2>
+
+<h3 id="ABI_constants">ABI constants</h3>
+
+<p>这些常量是用于调用库的方法时使用。</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Constant</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>default_abi</code></td>
+ <td>Corresponds to <code>cdecl</code>; standard libraries use this ABI. You also use this for all system calls on Mac OS X and Linux.</td>
+ </tr>
+ <tr>
+ <td><code>stdcall_abi</code></td>
+ <td>Used for calling functions declared with <code>stdcall</code> on Windows. These functions' names are automatically mangled for you by js-ctypes.</td>
+ </tr>
+ <tr>
+ <td><code>winapi_abi</code></td>
+ <td>用于调用Windows 系统函数。与楼上的不同之处在于不能自己指定函数名字.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="预定义的数据类型">预定义的数据类型</h2>
+
+<h4 id="原始类型">原始类型</h4>
+
+<p>这些类型在所有平台的表现方式都一样</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Type</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>int8_t</code></td>
+ <td>Signed 8-bit integer.</td>
+ </tr>
+ <tr>
+ <td><code>uint8_t</code></td>
+ <td>Unsigned 8-bit integer.</td>
+ </tr>
+ <tr>
+ <td><code>int16_t</code></td>
+ <td>Signed 16-bit integer.</td>
+ </tr>
+ <tr>
+ <td><code>uint16_t</code></td>
+ <td>Unsigned 16-bit integer.</td>
+ </tr>
+ <tr>
+ <td><code>int32_t</code></td>
+ <td>Signed 32-bit integer.</td>
+ </tr>
+ <tr>
+ <td><code>uint32_t</code></td>
+ <td>Unsigned 32-bit integer.</td>
+ </tr>
+ <tr>
+ <td><code>int64_t</code></td>
+ <td>Signed 64-bit integer.</td>
+ </tr>
+ <tr>
+ <td><code>uint64_t</code></td>
+ <td>Unsigned 64-bit integer.</td>
+ </tr>
+ <tr>
+ <td><code>float32_t</code></td>
+ <td>32-bit floating-point value.</td>
+ </tr>
+ <tr>
+ <td><code>float64_t</code></td>
+ <td>64-bit floating-point value.</td>
+ </tr>
+ </tbody>
+</table>
+
+<div class="note"><strong>Note:</strong> Some 64-bit values are outside the range of numeric values supported by JavaScript. Because of this, <code>ctypes.int64</code> and <code>ctypes.uint64</code> do not automatically convert to JavaScript numbers. Instead, they convert to objects of the wrapper types <code>ctypes.Int64</code> and <code>ctypes.UInt64</code>, which are JavaScript objects rather than CData objects. See <a href="/en/Mozilla/js-ctypes/Using_js-ctypes/Working_with_data#64-bit_integers" title="en/js-ctypes/Using js-ctypes/Working with data#64-bit integers">64-bit integers</a> for details.</div>
+
+<h4 id="C语言特定类型">C语言特定类型</h4>
+
+<p>These types are designed to work exactly like the corresponding type on the native platform.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Type</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>bool</code></td>
+ <td>A Boolean type that behaves like the corresponding C type on the platform.</td>
+ </tr>
+ <tr>
+ <td><code>short</code></td>
+ <td>A short integer type that behaves like the corresponding C type on the platform.</td>
+ </tr>
+ <tr>
+ <td><code>unsigned_short</code></td>
+ <td>An unsigned short integer type that behaves like the corresponding C type on the platform.</td>
+ </tr>
+ <tr>
+ <td><code>int</code></td>
+ <td>An integer type that behaves like the <code>int</code> C type on the platform.</td>
+ </tr>
+ <tr>
+ <td><code>unsigned_int</code></td>
+ <td>An unsigned integer type that behaves like the <code>unsigned int</code> C type on the platform.</td>
+ </tr>
+ <tr>
+ <td><code>long</code></td>
+ <td>
+ <p>A long integer type that behaves like the corresponding C type on the platform.</p>
+
+ <div class="warning">
+ <p><strong>NOTE</strong> This automatically converts to an <code>Int64</code> JavaScript object on all platforms, since it's unknown whether this is a 32-bit or 64-bit value. This is done for compatibility's sake.</p>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>unsigned_long</code></td>
+ <td>
+ <p>An unsigned long integer type that behaves like the corresponding C type on the platform.</p>
+
+ <div class="warning">
+ <p><strong>NOTE</strong> This automatically converts to a <code>UInt64</code> JavaScript object on all platforms, since it's unknown whether this is a 32-bit or 64-bit value. This is done for compatibility's sake.</p>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>long_long</code></td>
+ <td>A integer type at least 64 bits wide.</td>
+ </tr>
+ <tr>
+ <td><code>unsigned_long_long</code></td>
+ <td>An unsigned integer type at least 64 bits wide.</td>
+ </tr>
+ <tr>
+ <td><code>float</code></td>
+ <td>A floating point value that behaves like the <code>float</code> type on the platform.</td>
+ </tr>
+ <tr>
+ <td><code>double</code></td>
+ <td>A double-precision floating point value that behaves like the <code>double</code> type on the platform.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h4 id="字符类型">字符类型</h4>
+
+<p>Character types are 8-bit values that behave like their C counterparts. They're similar to the <code>int8_t</code> and <code>uint8_t</code> types, except conversion is handled differently.</p>
+
+<p>For example, <code>ctypes.char.array(30)(str)</code> converts the string <code>str</code> to UTF-8 and returns a new <code>CData</code> object of array type.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Type</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>char</code></td>
+ <td>
+ <p>A character type that behaves like the <code>char</code> C type on the platform.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>signed_char</code></td>
+ <td>A signed character that behaves like the <code>char</code> type on the platform.</td>
+ </tr>
+ <tr>
+ <td><code>unsigned_char</code></td>
+ <td>An unsigned character that behaves like the <code>unsigned char</code> type on the platform.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h5 id="大小与处理器位数有关的类型"><strong>大小与处理器位数有关的类型</strong></h5>
+
+<p>Because it's unknown whether these values will be 32-bit or 64-bit, they are not automatically converted into JavaScript numbers. Instead, these convert into <code>ctypes.Int64</code> or <code>ctypes.UInt64</code> JavaScript objects; see <a href="/en/Mozilla/js-ctypes/Using_js-ctypes/Working_with_data#64-bit_integers" title="en/js-ctypes/Using js-ctypes/Working with data#64-bit integers">64-bit integers</a> for details.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Type</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>size_t</code></td>
+ <td>A platform-dependent size type.</td>
+ </tr>
+ <tr>
+ <td><code>ssize_t</code></td>
+ <td>A platform-dependent size type.</td>
+ </tr>
+ <tr>
+ <td><code>intptr_t</code></td>
+ <td>A platform-dependent integer representation of a pointer.</td>
+ </tr>
+ <tr>
+ <td><code>uintptr_t</code></td>
+ <td>A platform-dependent unsigned integer representation of a pointer.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h4 id="JavaScript_characters">JavaScript characters</h4>
+
+<p>16-bit C Unicode characters are handled by js-ctypes using the <code>jschar</code> type.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Type</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>jschar</code></td>
+ <td>A 16-bit unsigned character. This is different from <code>uint16_t</code> in that C <code>jschar</code> values are automatically converted into 1-character JavaScript strings. These are Unicode characters.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h4 id="Special_C_types">Special C types</h4>
+
+<p>These types represent C types that have special meanings.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Type</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>void_t</code></td>
+ <td>
+ <p>The special C type <code>void</code>. This can only be used as a return value type.</p>
+
+ <div class="note"><strong>Note:</strong> You must use <code>void_t</code>, not <code>void</code>, since <code>void</code> is a keyword in JavaScript.</div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>voidptr_t</code></td>
+ <td>The C type <code>void *</code>. This is a pointer to an indeterminate type of data.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h4 id="Large_integer_types">Large integer types</h4>
+
+<p>Because JavaScript doesn't support large (64-bit) integers, js-ctypes provides two data types allowing access to 64-bit integer data.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Type</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>Int64</code></td>
+ <td>A JavaScript object representing a 64-bit signed integer.</td>
+ </tr>
+ <tr>
+ <td><code>UInt64</code></td>
+ <td>A JavaScript object representing a 64-bit unsigned integer.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Methods">Methods</h2>
+
+<h3 id="cast" name="cast()">cast()</h3>
+
+<p>把某个对象转换成新的类型,返回值是拥有这些值的新类型的对象。更多了解可以查看<a href="/en/Mozilla/js-ctypes/Using_js-ctypes/Working_with_data#Type_casting" title="en/js-ctypes/Using js-ctypes/Working with data#Type casting">Type casting</a>。</p>
+
+<pre>CData cast(
+ data,
+ type
+);</pre>
+
+<h6 id="Parameters_2">Parameters</h6>
+
+<dl>
+ <dt><code>data</code></dt>
+ <dd>要转换的数据对象。</dd>
+ <dt><code>type</code></dt>
+ <dd>转换后的数据类型,可以是 <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/ctypes#Predefined_data_types" title="The ctypes object contains methods and predefined data types used to create and manage a library.">Predefined data types</a>, 也可以是任何自定义类型。</dd>
+</dl>
+
+<h6 id="Return_value">Return value</h6>
+
+<p>拥有相同数据的,不过类型是type的一个新对象。</p>
+
+<h3 id="libraryName" name="libraryName()">libraryName()</h3>
+
+<p>Returns the correct platform-specific filename for a given library name (e.g. <code>libnss3.dylib</code> for <code>nss3</code> on OS X.)</p>
+
+<pre class="eval">String libraryName(
+ name
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>name</code></dt>
+ <dd>The name of the library.</dd>
+</dl>
+
+<h6 id="Return_value_2">Return value</h6>
+
+<p>String containing the platform-specific filename of the library.</p>
+
+<h3 id="open" name="open()">open()</h3>
+
+<p>Opens a library, specified by a pathname. The library is loaded from the specified full path, or, if a partial path is specified, from the appropriate library directory based on the platform on which the application is running. See <a href="/en/Mozilla/js-ctypes/Using_js-ctypes#Library_search_paths" title="en/js-ctypes/Using js-ctypes#Library search paths">Library search paths</a> for more details.</p>
+
+<pre class="eval">Library open(
+ libSpec
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>libSpec</code></dt>
+ <dd>The native library to open, specified as a pathname string.</dd>
+</dl>
+
+<h6 id="Return_value_3">Return value</h6>
+
+<p>A <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/Library" title="此页面仍未被本地化, 期待您的翻译!"><code>Library</code></a> object representing the opened library.</p>
+
+<h2 id="举些栗子">举些栗子</h2>
+
+<p><code>Windows下使用StructType()的例子</code></p>
+
+<p>好了,上帝说要有按钮<code>TB_BUTTON</code>,所以我们到MSDN上找<code>TB_BUTTON</code> 的结构体 (<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb760476%28v=vs.85%29.aspx">MSDN :: TB_BUTTON Structure</a>) ,然后找到了:</p>
+
+<pre class="brush: cpp">typedef struct {
+ int iBitmap;
+ int idCommand;
+ BYTE fsState;
+ BYTE fsStyle;
+#ifdef _WIN64
+ BYTE bReserved[6];
+#else
+#if defined(_WIN32)
+ BYTE bReserved[2];
+#endif
+#endif
+ DWORD_PTR dwData;
+ INT_PTR iString;
+} TBBUTTON, *PTBBUTTON, *LPTBBUTTON;</pre>
+
+<p>所以我们现在注意到64位和32位是不同的。所以我们将会指出这个不同之处,然后创造结构体。代码看起来会是这样的:</p>
+
+<pre class="brush: js">var struct_TBButton;
+if (ctypes.voidptr_t.size == 4 /* 32-bit */) {
+ struct_TBButton = ctypes.StructType('TBButton', [
+ {'iBitmap': ctypes.int},
+ {'idCommand': ctypes.int},
+ {'fbState': ctypes.unsigned_char},
+ {'fsStyle': ctypes.unsigned_char},
+ {'bReserved': ctypes.unsigned_char},
+ {'bReserved2': ctypes.unsigned_char},
+ {'dwData': ctypes.uintptr_t},
+ {'iString': ctypes.intptr_t}
+ ]);
+}
+else if (ctypes.voidptr_t.size == 8 /* 64-bit */) {
+ struct_TBButton = ctypes.StructType('TBButton', [
+ {'iBitmap': ctypes.int},
+ {'idCommand': ctypes.int},
+ {'fbState': ctypes.unsigned_char},
+ {'fsStyle': ctypes.unsigned_char},
+ {'bReserved': ctypes.unsigned_char},
+ {'bReserved2': ctypes.unsigned_char},
+ {'bReserved3': ctypes.unsigned_char},
+ {'bReserved4': ctypes.unsigned_char},
+ {'bReserved5': ctypes.unsigned_char},
+ {'bReserved6': ctypes.unsigned_char},
+ {'dwData': ctypes.uintptr_t},
+ {'iString': ctypes.intptr_t}
+ ]);
+}
+else {
+ throw new Error("wut?!");
+}
+
+console.log(struct_TBButton.size);
+// 20 on 32-bit, 32 on 64-bit if I'm not mistaken</pre>
+
+<p>There is another way to do this, we can use <code>ArrayType</code>, but example for this I don't know at this time.</p>
+
+<p>Credit for this example is to nmaier (<a href="http://stackoverflow.com/a/24117551/1828637">StackOverflow :: Getting TB_BUTTON is crashing and not working</a>)</p>
+
+<h3 id="Example_of_cast_and_FunctionType_on_Windows">Example of <code>cast </code>and <code>FunctionType</code> on Windows</h3>
+
+<pre class="brush: js">Components.utils.import("resource://gre/modules/ctypes.jsm");
+
+var kernel = ctypes.open("kernel32.dll");
+var HMODULE = ctypes.uint32_t;
+var HWND = ctypes.uint32_t;
+var LPCTSTR = ctypes.jschar.ptr;
+var LPCSTR = ctypes.char.ptr;
+var LoadLibrary = kernel.declare("LoadLibraryW", ctypes.winapi_abi, HMODULE, LPCTSTR);
+var GetProcAddress = kernel.declare("GetProcAddress", ctypes.winapi_abi, ctypes.void_t.ptr, HMODULE, LPCSTR);
+
+var hUser = LoadLibrary("user32");
+var funcPtr = GetProcAddress(hUser, "MessageBoxW");
+
+// Now we have a pointer to a function, let's cast it to the right type
+var MessageBoxType = ctypes.FunctionType(ctypes.winapi_abi, ctypes.int32_t, [HWND, LPCTSTR, LPCTSTR, ctypes.uint32_t]);
+funcPtr = ctypes.cast(funcPtr, MessageBoxType.ptr);
+funcPtr(0, "Test1", "Test2", 0);
+</pre>
+
+<p>Credit for this example is to Wladimir Palant (<a href="http://stackoverflow.com/a/16384129/1828637">StackOverflow :: How to call a function using pointer in js-ctypes</a>)</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en/Mozilla/js-ctypes" title="en/JavaScript code modules/ctypes.jsm">ctypes.jsm</a></li>
+ <li><a href="/en/Mozilla/js-ctypes/Using_js-ctypes" title="en/js-ctypes/Using js-ctypes">Using js-ctypes</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/ArrayType" title="此页面仍未被本地化, 期待您的翻译!"><code>ArrayType</code></a></li>
+ <li><a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/FunctionType" title="此页面仍未被本地化, 期待您的翻译!"><code>FunctionType</code></a></li>
+ <li><a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/PointerType" title="此页面仍未被本地化, 期待您的翻译!"><code>PointerType</code></a></li>
+ <li><a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/StructType" title="此页面仍未被本地化, 期待您的翻译!"><code>StructType</code></a></li>
+ <li><a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/Int64" title="此页面仍未被本地化, 期待您的翻译!"><code>Int64</code></a></li>
+ <li><a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/UInt64" title="此页面仍未被本地化, 期待您的翻译!"><code>UInt64</code></a></li>
+ <li><a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/ABI" title="此页面仍未被本地化, 期待您的翻译!"><code>ABI</code></a></li>
+ <li><a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/Library" title="此页面仍未被本地化, 期待您的翻译!"><code>Library</code></a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/js-ctypes/js-ctypes_reference/index.html b/files/zh-cn/mozilla/js-ctypes/js-ctypes_reference/index.html
new file mode 100644
index 0000000000..d451510edb
--- /dev/null
+++ b/files/zh-cn/mozilla/js-ctypes/js-ctypes_reference/index.html
@@ -0,0 +1,96 @@
+---
+title: js-ctypes reference
+slug: Mozilla/js-ctypes/js-ctypes_reference
+tags:
+ - JavaScript
+ - NeedsTranslation
+ - TopicStub
+ - js-ctypes
+translation_of: Mozilla/js-ctypes/js-ctypes_reference
+---
+<section class="Quick_links" id="Quick_Links">
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/js-ctypes"><strong><em>js-ctypes</em></strong></a></li>
+ <li class="toggle">
+ <details>
+ <summary>Introduction</summary>
+ <ol><li><a href="/zh-CN/docs/Mozilla/js-ctypes/Using_js-ctypes/Declaring_and_Using_Callbacks" title="C函数偶尔将函数指针作为参数,它们通常用作回调。.在这些情况下,js-ctypes允许您传递常规JavaScript函数作为回调。这是非常强大的,因为它允许本地代码透明地调用JavaScript。">Declaring and Using Callbacks</a> <a href="/zh-CN/docs/Mozilla/js-ctypes/Using_js-ctypes/Declaring_and_Using_Callbacks$translate" style="opacity: 0.5;" title="此页面仍未被本地化, 期待您的翻译!">[我来译!]</a></li></ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details open>
+ <summary>References</summary>
+ <ol><li><a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/ctypes" title="The ctypes object contains methods and predefined data types used to create and manage a library."><code>ctypes</code></a> <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/ctypes$translate" style="opacity: 0.5;" title="此页面仍未被本地化, 期待您的翻译!">[我来译!]</a></li></ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Examples</summary>
+
+ </details>
+ </li>
+ </ol>
+</section>
+
+<p>This doc is a work in progress.</p>
+
+<h2 id="ctypes_Reference">ctypes Reference</h2>
+
+<p>The <code>ctypes</code> object is the base of the ctypes API. It is obtained by by loading the ctypes module:</p>
+
+<p><code>Components.utils.import("<a class="external" rel="freelink">resource://gre/modules/ctypes.jsm</a>");</code></p>
+
+<p>You can use the <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/ctypes" title="The ctypes object contains methods and predefined data types used to create and manage a library."><code>ctypes</code></a> object to load libraries, construct types, and perform miscellaneous tasks such as type casting. The <code><code>ctypes</code></code> object also provides numerous <a href="/en/Mozilla/js-ctypes/js-ctypes_reference/ctypes#Predefined_data_types" title="en/js-ctypes/js-ctypes reference/ctypes#Predefined data types">predefined types</a> that correspond to primitives and common typedefs in C.</p>
+
+<h2 id="Working_with_libraries">Working with libraries</h2>
+
+<p>To load a <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/Library" title="此页面仍未被本地化, 期待您的翻译!"><code>Library</code></a>, use <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/ctypes#open()" title="The ctypes object contains methods and predefined data types used to create and manage a library."><code>ctypes.open()</code></a>.</p>
+
+<p>The <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/Library" title="此页面仍未被本地化, 期待您的翻译!"><code>Library</code></a> object is used mostly to declare native functions provided by the library so that js-ctypes knows how to call them. See <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/Library#declare()" title="此页面仍未被本地化, 期待您的翻译!"><code>Library.declare()</code></a> for instructions on how to declare these functions.</p>
+
+<p>Once you have finished working with a Library, call <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/Library#close()" title="此页面仍未被本地化, 期待您的翻译!"><code>Library.close()</code></a>.</p>
+
+<h2 id="Calling_conventions">Calling conventions</h2>
+
+<p>See <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/ABI" title="此页面仍未被本地化, 期待您的翻译!"><code>ABI</code></a>.</p>
+
+<h2 id="Types_and_data">Types and data</h2>
+
+<p>To use js-ctypes effectively, it is important to understand the different kinds of objects that the module provides. There are three major categories:</p>
+
+<h3 id="Types">Types</h3>
+
+<p>These represent a type in C, and are thus represented by <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/CType" title="此页面仍未被本地化, 期待您的翻译!"><code>CType</code></a> objects. These objects have two main purposes. First, they provide a concrete representation of different data types, allowing the programmer to describe the arguments and return type of a native function (see <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/Library#declare()" title="此页面仍未被本地化, 期待您的翻译!"><code>Library.declare()</code></a>).  Second, they serve as constructors to create concrete instances of the given type, i.e. <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/CData" title="此页面仍未被本地化, 期待您的翻译!"><code>CData</code></a> objects.</p>
+
+<p>Out of the box, js-ctypes supports a number of <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/ctypes#Predefined_data_types" title="The ctypes object contains methods and predefined data types used to create and manage a library.">predefined types</a>.</p>
+
+<h3 id="Type_constructors">Type constructors</h3>
+
+<p>These are functions that define new types, and thus return a <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/CType" title="此页面仍未被本地化, 期待您的翻译!"><code>CType</code></a> object. These include</p>
+
+<ul>
+ <li><a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/PointerType" title="此页面仍未被本地化, 期待您的翻译!"><code>ctypes.PointerType(type)</code></a> and the <code>.ptr</code> property, which creates a new type describing a pointer to an existing type.</li>
+ <li><a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/ArrayType" title="此页面仍未被本地化, 期待您的翻译!"><code>ctypes.ArrayType(type, [length])</code></a> and the <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/CType#array()" title="此页面仍未被本地化, 期待您的翻译!"><code>.array()</code></a> method, which creates a new type describing an array of objects of an existing type.</li>
+ <li><a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/StructType" title="此页面仍未被本地化, 期待您的翻译!"><code>ctypes.StructType()</code></a>, which creates a new type describing a C struct.</li>
+ <li><a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/FunctionType" title="此页面仍未被本地化, 期待您的翻译!"><code>ctypes.FunctionType(abi, returnType, argType1 [, argType2 ...])</code></a>, which creates a new type describing a C function.</li>
+</ul>
+
+<h3 id="Data">Data</h3>
+
+<p>These are instances of types, represented by <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/CData" title="此页面仍未被本地化, 期待您的翻译!"><code>CData</code></a> objects and instantiated by calling <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/CType" title="此页面仍未被本地化, 期待您的翻译!"><code>CType</code></a> objects as functions.<span id="1314129036225E" style="display: none;"> </span></p>
+
+<p>These distinctions are crucial, and understanding them will alleviate much of the confusion surrounding js-ctypes. Calling a Type Constructor will return a <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/CType" title="此页面仍未被本地化, 期待您的翻译!"><code>CType</code></a>. Calling a <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/CType" title="此页面仍未被本地化, 期待您的翻译!"><code>CType</code></a> will return a <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/CData" title="此页面仍未被本地化, 期待您的翻译!"><code>CData</code></a>. You <em>declare</em> the arguments and return value of a native function with <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/CType" title="此页面仍未被本地化, 期待您的翻译!"><code>CType</code></a> objects. You <em>call</em> a native function with <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/CData" title="此页面仍未被本地化, 期待您的翻译!"><code>CData</code></a> objects.</p>
+
+<h2 id="Other_Features">Other Features</h2>
+
+<h3 id="Error-handling">Error-handling</h3>
+
+<p>js-ctypes supports both <a href="/en/Mozilla/js-ctypes/js-ctypes_reference/ctypes#Properties" title="en/Mozilla/js-ctypes/js-ctypes_reference/ctypes#Properties">errno</a> (on all platforms) and <a href="/en/Mozilla/js-ctypes/js-ctypes_reference/ctypes#Properties" title="en/Mozilla/js-ctypes/js-ctypes_reference/ctypes#Properties">GetLastError</a> (on Windows platforms).</p>
+
+<h3 id="Callbacks">Callbacks</h3>
+
+<p>You can pass regular JavaScript functions as callbacks to native functions. See the <a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Declaring_and_Using_Callbacks" title="en/js-ctypes/js-ctypes reference/Callbacks">Callbacks</a> page for details.</p>
+
+<h3 id="64-Bit_integer_handling">64-Bit integer handling</h3>
+
+<p>Because JavaScript <a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Number" title="JavaScript 的 Number 对象是经过封装的能让你处理数字值的对象。Number 对象由 Number() 构造器创建。"><code>Number</code></a> objects can't directly represent every possible 64-bit integer value, js-ctypes provides new types for these. See <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/Int64" title="此页面仍未被本地化, 期待您的翻译!"><code>Int64</code></a> and <a href="/zh-CN/docs/Mozilla/js-ctypes/js-ctypes_reference/UInt64" title="此页面仍未被本地化, 期待您的翻译!"><code>UInt64</code></a>.</p>
diff --git a/files/zh-cn/mozilla/js-ctypes/using_js-ctypes/declaring_and_using_callbacks/index.html b/files/zh-cn/mozilla/js-ctypes/using_js-ctypes/declaring_and_using_callbacks/index.html
new file mode 100644
index 0000000000..ae8223ec83
--- /dev/null
+++ b/files/zh-cn/mozilla/js-ctypes/using_js-ctypes/declaring_and_using_callbacks/index.html
@@ -0,0 +1,100 @@
+---
+title: Declaring and Using Callbacks
+slug: Mozilla/js-ctypes/Using_js-ctypes/Declaring_and_Using_Callbacks
+tags:
+ - 回调
+ - 声明和使用回调
+ - 立即调用函数表达式
+translation_of: Mozilla/js-ctypes/Using_js-ctypes/Declaring_and_Using_Callbacks
+---
+<p>{{jsctypesSidebar("Introduction")}}</p>
+
+<p>C函数偶尔将函数指针作为参数,它们通常用作回调。.在这些情况下,js-ctypes允许您传递常规JavaScript函数作为回调。这是非常强大的,因为它允许本地代码透明地调用JavaScript。</p>
+
+<div class="warning">警告<strong>: </strong>回调必须在它们注册的同一线程上调用。js-ctypes中没有并发逻辑,因此在其他线程上调用回调会导致事情崩溃。</div>
+
+<h2 id="先决条件">先决条件</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/ABI">ABI</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/FunctionType">FunctionType</a></li>
+</ul>
+
+<h2 id="声明回调">声明回调</h2>
+
+<p>A callback is declared by using <code><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/FunctionType">ctypes.FunctionType</a></code>. The first argument is the calling convention, the second argument is the return type, and the third is an array of arguments the callback expects.</p>
+
+<p>The return type of the javascript callback must match the return type declared, otherwise js-ctypes will throw an error saying "unexpected return type".</p>
+
+<h3 id="范例">范例</h3>
+
+<h4 id="例子_1">例子 1</h4>
+
+<p>这个回调返回bool并有两个参数。</p>
+
+<pre class="brush: js">var myFuncTypeDeclaration = ctypes.FunctionType(ctypes.default_abi, ctypes.bool, [ctypes.int, ctypes.voidptr_t]);
+
+function myJSCallback(cInt, cPtr) {
+ return true; // as the return of the FunctionType was ctypes.bool we must make our javascript callback return bool otherwise js-ctypes will throw error saying unexpected type return
+}
+
+var myCCallback = myFuncTypeDeclaration.ptr(myJSCallback);
+</pre>
+
+<h4 id="例子_2">例子 2</h4>
+
+<p>这个回调返回void,没有参数。当void是返回类型时,javascript回调一定不能返回,或者它应该返回未定义。</p>
+
+<pre class="brush: js">var myFuncTypeDeclaration = ctypes.FunctionType(ctypes.default_abi, ctypes.void_t, []);
+
+function myJSCallback() {
+ return undefined; // as the return of the FunctionType was ctypes.void_t we must return undefined OR dont return at all otherwise js-ctypes will throw an error saying unexpected type
+}
+
+var myCCallback = myFuncTypeDeclaration.ptr(myJSCallback);
+</pre>
+
+<h2 id="使用回调">使用回调</h2>
+
+<p>Since callbacks are function pointers in C, js-ctypes has special handling for function pointer types. Consider the following code:</p>
+
+<pre class="brush: js">function myJSCallback(foo, bar) { .... };
+var funcType = ctypes.FunctionType(...);
+var funcPtrType = funcType.ptr;
+var regularFuncPtr = funcPtrType();
+var callback = funcPtrType(myJSCallback);
+</pre>
+
+<p>js-ctypes detects that <code>funcPtrType</code> is a type of function pointer, and adds a special case to its constructor. In the ordinary case, invoking the type object creates a regular <a href="/en/Mozilla/js-ctypes/js-ctypes_reference/CData" title="en/js-ctypes/js-ctypes reference/CData"><code>CData</code></a> object containing a pointer to the data. However, if the first argument is a function, js-ctypes creates a special object (known internally as a CClosure) that wraps the JavaScript function within an ordinary C function. This can all be done in a single line of code, like so:</p>
+
+<pre class="brush: js">var callback = ctypes.FunctionType(...).ptr(function(...) {...});
+</pre>
+
+<div class="note"><strong>Note:</strong> The use of <code>.ptr()</code> here isn't a method call; we're accessing a property that dynamically creates a callable object, and then invoking the result.</div>
+
+<p>If two arguments are passed to the callback constructor, the second is used as the <code>this</code> parameter:</p>
+
+<pre class="brush: js">function myJSCallback() {
+  alert(this.message);
+};
+
+var receiver = { message: 'hi there!' };
+var callback = funcPtrType(myJSCallback, receiver); // alerts with 'hi there' when the callback is invoked
+</pre>
+
+<p>If three arguments are passed to the callback constructor, the third argument is used as a sentinel value which the callback returns if an exception is thrown. The sentinel value must be convertible to the return type of the callback:</p>
+
+<pre class="brush: js">function myJSCallback() {
+  throw "uh oh";
+};
+
+var callback1 = funcPtrType(myJSCallback, null, -1); // Returns -1 to the native caller when the exception is thrown.
+</pre>
+
+<div class="warning"><strong>Warning: </strong>You <em>must</em> store a reference to the callback object as long as the native code might call it. If you don't, the GC might collect the relevant data structures, and the browser will crash when native code attempts to invoke your callback.</div>
+
+<h2 id="参数和返回值">参数和返回值</h2>
+
+<p>js-ctypes automatically handles the conversion between JavaScript and C value representations. Before the JavaScript callback function is invoked, js-ctypes converts the arguments passed by the caller to JavaScript values. Where possible, js-ctypes will convert arguments to primitive types. For arguments of complex types, temporary <a href="/en/Mozilla/js-ctypes/js-ctypes_reference/CData" title="https://developer.mozilla.org/en/js-ctypes/js-ctypes_reference/CData"><code>CData</code></a> objects will be created.</p>
+
+<p>The return value is converted in a similar manner.</p>
diff --git a/files/zh-cn/mozilla/js-ctypes/using_js-ctypes/index.html b/files/zh-cn/mozilla/js-ctypes/using_js-ctypes/index.html
new file mode 100644
index 0000000000..6a91cfb28f
--- /dev/null
+++ b/files/zh-cn/mozilla/js-ctypes/using_js-ctypes/index.html
@@ -0,0 +1,210 @@
+---
+title: 使用 js-ctypes
+slug: Mozilla/js-ctypes/Using_js-ctypes
+translation_of: Mozilla/js-ctypes/Using_js-ctypes
+---
+<p>{{ gecko_minversion_header("2.0") }}</p>
+
+<p>{{ draft() }}</p>
+
+<p>在使用 js-ctypes 前,你需要导入 ctypes.jsm 代码模块(Javascript Code Module)。这非常简单,只需要在所需的 Javascript scope 内包含下面这行代码 :</p>
+
+<pre class="eval"><span class="nowiki">Components.utils.import("resource://gre/modules/ctypes.jsm")</span></pre>
+
+<h2 id="加载本地库">加载本地库</h2>
+
+<p>在引入上述的代码模块后,你可以调用 <a href="/en/js-ctypes/js-ctypes_reference/ctypes#open()" title="en/js-ctypes/js-ctypes reference/ctypes#open()"><code>ctypes.open()</code></a> 来加载你想使用的本地库。例如:在Windows下,你可以这样引入系统的user32库:</p>
+
+<pre>var lib = ctypes.open("user32.dll");</pre>
+
+<p>On Mac OS X, you can load the Core Foundation library from the Core Foundation framework like this:</p>
+
+<pre>var coreFoundation = ctypes.open("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation");</pre>
+
+<p>返回值是一个库对象,你可以用这个库对象去声明方法和数据类型,以供使用。</p>
+
+<div class="note"><strong>Note:</strong> js-ctypes only works with C libraries; you can't use C++ methods directly. Instead, you'll need to create a shim library that uses C functions that then call into the C++ library for you.</div>
+
+<h3 id="库搜索路径">库搜索路径</h3>
+
+<p>如果你指定了库的完整路径,那么就可以直接加载该库. 否则,系统会以一套标准的流程来搜索该库。</p>
+
+<h4 id="Windows">Windows</h4>
+
+<p>在Window下,搜索库的顺序如下:</p>
+
+<ol>
+ <li>The application's directory.</li>
+ <li>The system directory.</li>
+ <li>The 16-bit system directory.</li>
+ <li>The Windows directory.</li>
+ <li>The current working directory</li>
+ <li>The directories listed in the <code>PATH</code> environment variable.</li>
+</ol>
+
+<div class="note"><strong>Note:</strong> 该内容来至于 <a class="external" href="http://msdn.microsoft.com/en-us/library/ms682586(VS.85).aspx" title="http://msdn.microsoft.com/en-us/library/ms682586(VS.85).aspx">this article on MSDN</a>.</div>
+
+<h2 id="用完了">用完了</h2>
+
+<p>当你使用完库之后,你应该通过调用库对象的<code><a href="/en/js-ctypes/js-ctypes_reference/Library#close()" title="en/js-ctypes/js-ctypes reference/Library#close()">close()</a>方法来</code>关闭它。</p>
+
+<pre>lib.close();</pre>
+
+<p>如果关闭库失败,库会在垃圾回收时,自动关闭。</p>
+
+<h2 id="使用库">使用库</h2>
+
+<p>你可能需要声明一些新类型。这些类型可能是简单的,也可能是像结构体这样较复杂的类型,欲知详情请查看 <a href="/en/js-ctypes/Using_js-ctypes/Declaring_types" title="en/js-ctypes/Using js-ctypes/Declaring types">Declaring types</a>。大多数情况下,你会需要 声明一个或多个函数(<a href="/en/js-ctypes/Using_js-ctypes/Declaring_and_calling_functions" title="en/js-ctypes/Using js-ctypes/Declaring and calling functions">declare one or more functions</a>),以供调用。 </p>
+
+<p>只要你声明了类型和方法,你就可以使用他们。 实例化C 类型的数据对象和引用他们可以参考 <a href="/en/js-ctypes/Using_js-ctypes/Working_with_data" title="en/js-ctypes/Using js-ctypes/Working with data">Working with data</a>。</p>
+
+<h2 id="内存管理">内存管理</h2>
+
+<p>If JS code creates a structure or array, that memory will be valid as long as the JS object stays alive. Pointers to that memory must be carefully managed to make sure the underlying memory is still referenced.</p>
+
+<p>When binary code hands back a pointer/handle to allocated memory, the JS code must make sure to free that memory with the correct allocator. It is usually best to expose a freeing function from the binary.</p>
+
+<h3 id="保持活着的对象">保持活着的对象</h3>
+
+<p>The following js-ctypes objects will hold references to objects, keeping them alive. This is not an exhaustive list, but will help you understand memory management and how it affects your use of js-ctypes:</p>
+
+<ul>
+ <li>A function or static data declared using the <a href="/en/js-ctypes/js-ctypes_reference/Library#declare()" title="en/js-ctypes/js-ctypes reference/Library#declare()"><code>declare()</code></a> method will hold that library alive.</li>
+ <li>A <a href="/en/js-ctypes/js-ctypes_reference/CType" title="en/js-ctypes/js-ctypes reference/CType"><code>CType</code></a> will hold referent <a href="/en/js-ctypes/js-ctypes_reference/CType" title="en/js-ctypes/js-ctypes reference/CType"><code>CType</code></a> objects alive.</li>
+ <li>A <code><a href="/en/js-ctypes/js-ctypes_reference/CData" title="en/js-ctypes/js-ctypes reference/CData">CData</a></code> will hold referent <code><a href="/en/js-ctypes/js-ctypes_reference/CData" title="en/js-ctypes/js-ctypes reference/CData">CData</a></code> objects alive, in specific circumstances. For example, a <code><a href="/en/js-ctypes/js-ctypes_reference/CData" title="en/js-ctypes/js-ctypes reference/CData">CData</a></code> object produced by accessing a field of a structure or the internals of an array will hold the referent objects alive.</li>
+</ul>
+
+<h3 id="究竟会不会保持活着的对象">究竟会不会保持活着的对象</h3>
+
+<p>It's important to note that getting direct access to the contents of a <code><a href="/en/js-ctypes/js-ctypes_reference/CData" title="en/js-ctypes/js-ctypes reference/CData">CData</a></code> object using <a href="/en/js-ctypes/js-ctypes_reference/CData#address()" title="en/js-ctypes/js-ctypes reference/CData#address()"><code>address()</code></a>, <a href="/en/js-ctypes/js-ctypes_reference/CData#addressOfElement()" title="en/js-ctypes/js-ctypes reference/CData#addressOfElement()"><code>addressOfElement()</code></a>, or <a href="/en/js-ctypes/js-ctypes_reference/CData#contents" title="en/js-ctypes/js-ctypes reference/CData#contents"><code>contents</code></a>, will result in a <code><a href="/en/js-ctypes/js-ctypes_reference/CData" title="en/js-ctypes/js-ctypes reference/CData">CData</a></code> object that <strong>does not</strong> hold its referent alive. Be sure to hold an explicit reference to be sure the referent object doesn't get garbage collected before you're done using it.</p>
+
+<h3 id="闭包">闭包</h3>
+
+<p>You also need to be sure to retain references to any JavaScript code that native code may call back into. This should be obvious, but is important enough to be worth stating explicitly.</p>
+
+<h3 id="当有疑问时_malloc()">当有疑问时, malloc()</h3>
+
+<p>When you absolutely, positively need to keep data around, you can use <code>malloc()</code> to allocate it directly. This bypasses JavaScript's memory management and lets you handle memory management yourself.</p>
+
+<h2 id="示例">示例</h2>
+
+<p>这些例子提供对js-ctypes使用的快速浏览。 要看更复杂的例子,请翻阅<a href="/en/js-ctypes/Examples" title="en/js-ctypes/Examples">js-ctypes examples</a>。</p>
+
+<h3 id="调用_Windows_例程">调用 Windows 例程</h3>
+
+<p>这个例子演示了怎么使用ctypes来调用Win32 API。</p>
+
+<pre class="brush: js">Components.utils.import("resource://gre/modules/ctypes.jsm");
+
+var lib = ctypes.open("C:\\WINDOWS\\system32\\user32.dll");
+
+/* Declare the signature of the function we are going to call */
+var msgBox = lib.declare("MessageBoxW"/* 函数名称*/,
+ ctypes.winapi_abi,/*ABI类型,有3种,这里指调用系统的接口*/
+ ctypes.int32_t,/*返回值*/
+ ctypes.int32_t,/*告警类型*/
+ ctypes.jschar.ptr,/*告警内容*/
+ ctypes.jschar.ptr,/*标题*/
+ ctypes.int32_t);/*按钮类型*/
+var MB_OK = 0;
+
+var ret = msgBox(0, "Hello world", "title", MB_OK);
+
+lib.close();</pre>
+
+<p>第三行, 就是 <code>user32.dll</code> 系统库被加载的地方。第六行声明了 <code>msgBox()</code> 函数是一个调用系统函数<code><a class="external" href="http://msdn.microsoft.com/en-us/library/ms645505%28VS.85%29.aspx" title="http://msdn.microsoft.com/en-us/library/ms645505(VS.85).aspx">MessageBoxW</a>的方法</code>. 第十五行调用了<code>msgBox()</code> ,会显示出一个告警框哦~。</p>
+
+<p>最后当我们完成使用之后,千万记得用close来关闭它。</p>
+
+<p>相较于给定完整的路径,通常只是给一个文件名。</p>
+
+<p><strong>关于声明函数</strong></p>
+
+<p>我们已经知道可以通过MSDN来获取MessageBox (MessageBoxW is just a unicode version of same function) 的相关信息,用以声明函数。也学习了关于lib.declare怎么使用:<a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/Library#declare%28%29" title="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/Library#declare%28%29">lib.declare</a>. 学习了数据类型的使用: <a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/ctypes?redirectlocale=en-US&amp;redirectslug=js-ctypes%2Fjs-ctypes_reference%2Fctypes#Predefined_data_types" title="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/ctypes?redirectlocale=en-US&amp;redirectslug=js-ctypes%2Fjs-ctypes_reference%2Fctypes#Predefined_data_types">Data Types</a>. 我们知道了它可以这样来声明:</p>
+
+<pre><span style="color: Blue;">int</span> WINAPI MessageBox(
+ _In_opt_  HWND hWnd,
+ _In_opt_  LPCTSTR lpText,
+ _In_opt_  LPCTSTR lpCaption,
+ _In_      UINT uType
+);</pre>
+
+<p>所以我们阅读这个文章关于类型定义和使用: <a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Declaring_types" title="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Declaring_types">Declaring Types</a></p>
+
+<pre>var lib = ctypes.open("user32.dll");
+</pre>
+
+<p>甚至不用后缀:</p>
+
+<pre>var lib = ctypes.open("user32");
+</pre>
+
+<h3 id="在_Mac_OS_X_上调用_Carbon_例程">在 Mac OS X 上调用 Carbon 例程</h3>
+
+<p>This example demonstrates how to use ctypes to call a Carbon function on Mac OS X.</p>
+
+<div class="note"><strong>Note:</strong>This example will not work on 64bit OS X, you will likely need to change to the Cocoa API.</div>
+
+<pre class="brush: js">/* build a Str255 ("Pascal style") string from the passed-in string */
+
+function makeStr(str) {
+ return String.fromCharCode(str.length) + str;
+}
+
+Components.utils.import("resource://gre/modules/ctypes.jsm");
+
+var carbon = ctypes.open("/System/Library/Frameworks/Carbon.framework/Carbon");
+
+stdAlert = carbon.declare("StandardAlert", /* function name */
+ ctypes.default_abi, /* ABI type */
+ ctypes.int16_t, /* return type */
+ ctypes.int16_t, /* alert type */
+ ctypes.char.ptr,       /* primary text */
+ ctypes.char.ptr,       /* secondary text */
+ ctypes.uint32_t, /* alert param */
+ ctypes.int16_t); /* item hit */
+
+var hit = 0;
+var msgErr = makeStr("Carbon Says...");
+var msgExp = makeStr("We just called the StandardAlert Carbon function from JavaScript!");
+
+var err = stdAlert(1, msgErr, msgExp, 0, hit);
+
+carbon.close();</pre>
+
+<p>The <code>makeStr()</code> function is a utility routine that takes as input a standard JavaScript string and returns a Carbon-style "Pascal" string, which is a length byte followed by the characters of the string itself. Note that this only works correctly if the string is in fact under 256 characters; if it's longer, this will fail spectacularly.</p>
+
+<p>In line 9, the Carbon library is loaded from the system's Carbon framework.</p>
+
+<p>Line 11 declares the <code>stdAlert()</code> function, which will call the Carbon <code>StandardAlert</code> routine. It uses the default ABI, returns a 16-bit integer (which is a Carbon <code>OSErr</code> value), and accepts an integer (the alert type), two strings, a pointer to a parameter block, which we aren't using, and another integer, which is used to return the hit item. See Apple's documentation for <a class="external" href="http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/Dialog_Manager/Reference/reference.html#//apple_ref/c/func/StandardAlert" title="http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/Dialog_Manager/Reference/reference.html#//apple_ref/c/func/StandardAlert"><code>StandardAlert</code></a> for details.</p>
+
+<p>After that, we simply set up our parameters by using <code>makeStr()</code> to generate the two <code>Str255</code> strings we need, then call <code>stdAlert()</code>, which produces the following alert window:</p>
+
+<p><img alt="ctype-mac-dialog.png" class="default internal" src="/@api/deki/files/4559/=ctype-mac-dialog.png"></p>
+
+<p>The last thing we do is call <code>carbon.close()</code> to close the library when we're done using it.</p>
+
+<h3 id="在_LinuxPOSIX_上调用_LibC_例程">在 Linux/POSIX 上调用 LibC 例程</h3>
+
+<p>This example demonstrates how to use ctypes to call a libc function on Linux.</p>
+
+<pre class="brush: js">/* import js-ctypes */
+Components.utils.import("resource://gre/modules/ctypes.jsm");
+
+/* Open the library */
+try {
+ /* Linux */
+ var libc = ctypes.open("libc.so.6");
+} catch (e) {
+ /* Most other Unixes */
+ libc = ctypes.open("libc.so");
+}
+
+/* Import a function */
+var puts = libc.declare("puts", /* function name */
+ ctypes.default_abi, /* call ABI */
+ ctypes.int, /* return type */
+ ctypes.char.ptr); /* argument type */
+
+var ret = puts("Hello World from js-ctypes!");
+wge</pre>
diff --git a/files/zh-cn/mozilla/js-ctypes/using_js-ctypes/memory_management/index.html b/files/zh-cn/mozilla/js-ctypes/using_js-ctypes/memory_management/index.html
new file mode 100644
index 0000000000..291ef8205d
--- /dev/null
+++ b/files/zh-cn/mozilla/js-ctypes/using_js-ctypes/memory_management/index.html
@@ -0,0 +1,88 @@
+---
+title: 内存管理
+slug: Mozilla/js-ctypes/Using_js-ctypes/Memory_Management
+tags:
+ - GC
+ - js-ctypes
+ - 内存管理
+translation_of: Mozilla/js-ctypes/Using_js-ctypes/Memory_Management
+---
+<section class="Quick_links" id="Quick_Links">
+<ol>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes"><strong><em>js-ctypes</em></strong></a></li>
+ <li class="toggle">
+ <details><summary>Introduction</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Debugging_Tips" title="Editorial review completed.">Debugging Tips</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Declaring_and_calling_functions" title="Functions are declared using the Library object's declare() method. Once declared, functions can be called using standard function syntax.">Declaring and Calling Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Declaring_and_Using_Callbacks" title="C functions occasionally take function pointers as arguments, which are generally used as callbacks. In these cases, js-ctypes allows you to pass a regular JavaScript function as the callback. This is very powerful, since it allows native code to transparently call into JavaScript.">Declaring and Using Callbacks</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Declaring_types" title="The ctypes object offers a number of constructor methods that let you declare types. Every type is represented by a CType object, which, in turn, provides a constructor method you can call to define values of those types. Each type you declare using js-ctypes corresponds to a compatible C declaration.">Declaring types</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Memory_Management" title="If JS code creates a structure or an array, that memory will be valid as long as the JS object stays alive. Pointers to that memory must be carefully managed to make sure the underlying memory is still referenced.">Memory Management</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Standard_OS_Libraries" title="This article gives the names of standard libraries that can be accessed with js-ctypes. These libraries are what enable js-ctypes to work. The alternative to standard libraries is creating your own DLL (for Windows) or SO (for Linux) file with C functions that can be called from your add-on with js-ctypes. The DLL/SO/etc file you make must be shipped with your add-on. Standard libraries offer the advantage of not having to ship anything. They are already available on the operating system for you. You just need to supply the path to appropriate files and set up the proper types of values/arguments in the js-ctypes code. This article allows you to find out what types to give to values/arguments by supplying links to the documentation of the OS libraries.">Standard OS Libraries</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Type_conversion" title="In js-ctypes, data could be converted implicitly when passing to or returning from a FunctionType call, or setting pointer content, an array element or a struct field.">Type conversion</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Working_with_ArrayBuffers" title="An ArrayBuffer is a simply byte array. The js-ctypes equivalent is a ctypes.uint8_t.array(###) (ctypes.unsigned_char are also ctypes.uint8_t).">Working with ArrayBuffers</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Working_with_data" title="Data types for use with js-ctypes are represented by CType objects. These are JavaScript constructors; as such, they're callable functions that you can use to create new CData objects of that type. There are several ways you can go about creating new CData objects.">Working with data</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/ctypes.open" title="At the heart of js-ctypes is the ctypes.open() function. This must be called before any work can commence. There are two options:">ctypes.open</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>References</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/ABI" title="This article describes the calling conventions with respect to js-ctypes while programming x86 and x86-64/x64/AMD64 architectures. A calling convention is an implementation-level (low-level) scheme regarding how subroutines receive parameters from their caller and how they revert."><code>ABI</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/ArrayType" title="ArrayType represents C arrays"><code>ArrayType</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/CData" title="A CData object represents a C value or function located in memory."><code>CData</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/CType" title="All data types declared using the js-ctypes API are represented by CType objects. These objects have assorted methods and properties that let you create objects of these types, find out information about them, and so forth. The specific properties and methods on each object vary depending on the data type represented."><code>CType</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/FunctionType" title=""><code>FunctionType</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/Int64" title="Because JavaScript doesn't currently include standard support for 64-bit integer values, js-ctypes offers the Int64 and UInt64 objects to let you work with C functions and data that need (or may need) values represented using a 64-bit data type."><code>Int64</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/Library" title="The Library object represents a native library loaded by the ctypes open() method. Its methods let you declare symbols exported by the library, and to manage the library."><code>Library</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/PointerType" title="Returns a new CType object describing a new pointer data type."><code>PointerType</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/StructType" title="Returns a CType object describing a new structure data type. This data type provides the ability to define and manipulate values of the C struct type."><code>StructType</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/UInt64" title="As JavaScript doesn't currently include standard support for 64-bit integer values, js-ctypes offers the Int64 and UInt64 objects to let you work with C functions and data that need (or may need) to use data represented using a 64-bit data type."><code>UInt64</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/ctypes" title="The ctypes object contains methods and predefined data types used to create and manage a library."><code>ctypes</code></a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Examples</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Examples/Add_to_iPhoto" title="This extension for Mac OS X serves as a demonstration of how to use js-ctypes to call Mac OS X Carbon, Core Foundation, and other system frameworks from an extension written entirely in JavaScript.">Add to iPhoto</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Examples/Using_C_structs_and_pointers" title="In this example, we show how to use C structs and pointers with js-ctypes.">Using C struct and pointers</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Examples/Using_COM_from_js-ctypes" title="The Windows API mostly concerns itself with the interaction between the operating system and an application. For communication between the different Windows applications among themselves, Microsoft has developed a series of technologies alongside the main Windows API. This started out with Dynamic Data Exchange (DDE), which was superseded by Object Linking and Embedding (OLE) and later by the Component Object Model (COM), Automation Objects, ActiveX controls, and the .NET Framework.">Using COM from js-ctypes</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Examples/Using_Objective-C_from_js-ctypes" title="Objective-C has its own syntax, it cannot be written directly with js-ctypes. This guide explains how to convert Objective-C code into js-ctypes code.">Using Objective-C from js-ctypes</a></li>
+ </ol>
+ </details>
+ </li>
+</ol>
+</section>
+
+<h2 id="内存管理">内存管理</h2>
+
+<p>If JS code creates a structure or an array, that memory will be valid as long as the JS object stays alive. Pointers to that memory must be carefully managed to make sure the underlying memory is still referenced.</p>
+
+<p>When binary code hands back a pointer/handle to allocated memory, the JS code must make sure to free that memory with the correct allocator. It is usually best to expose a freeing function from the binary.</p>
+
+<h3 id="保持_objects_活着">保持 objects 活着</h3>
+
+<p>The following js-ctypes objects will hold references to objects, keeping them alive. This is not an exhaustive list, but will help you to  understand memory management and how it affects your use of js-ctypes:</p>
+
+<ul>
+ <li>A function or static data declared using the <a href="https://wiki.developer.mozilla.org/en-US/docs/js-ctypes/js-ctypes_reference/Library#declare()"><code>declare()</code></a> method will hold that library alive.</li>
+ <li>A <a href="https://wiki.developer.mozilla.org/en-US/docs/js-ctypes/js-ctypes_reference/CType"><code>CType</code></a> will hold referent <a href="https://wiki.developer.mozilla.org/en-US/docs/js-ctypes/js-ctypes_reference/CType"><code>CType</code></a> objects alive.</li>
+ <li>A <code><a href="https://wiki.developer.mozilla.org/en-US/docs/js-ctypes/js-ctypes_reference/CData">CData</a></code> will hold referent <code><a href="https://wiki.developer.mozilla.org/en-US/docs/js-ctypes/js-ctypes_reference/CData">CData</a></code> objects alive, under specific circumstances. For example, a <code><a href="https://wiki.developer.mozilla.org/en-US/docs/js-ctypes/js-ctypes_reference/CData">CData</a></code> object produced by accessing a field of a structure or the internals of an array will hold the referent objects alive.</li>
+</ul>
+
+<h3 id="什么不保持_objects_活着">什么不保持 objects 活着</h3>
+
+<p>It's important to note that getting direct access to the contents of a <code><a href="https://wiki.developer.mozilla.org/en-US/docs/js-ctypes/js-ctypes_reference/CData">CData</a></code> object using <a href="https://wiki.developer.mozilla.org/en-US/docs/js-ctypes/js-ctypes_reference/CData#address()"><code>address()</code></a>, <a href="https://wiki.developer.mozilla.org/en-US/docs/js-ctypes/js-ctypes_reference/CData#addressOfElement()"><code>addressOfElement()</code></a>, or <a href="https://wiki.developer.mozilla.org/en-US/docs/js-ctypes/js-ctypes_reference/CData#contents"><code>contents</code></a>, will result in a <code><a href="https://wiki.developer.mozilla.org/en-US/docs/js-ctypes/js-ctypes_reference/CData">CData</a></code> object that <strong>does not</strong> hold its referent alive. Be sure to hold an explicit reference so that the referent object doesn't get into garbage collection, before you're done using it.</p>
+
+<h3 id="闭包">闭包</h3>
+
+<p>You also need to be sure to retain references to any JavaScript code that native code may call back into. This should be obvious, but is important enough to be worth stating explicitly.</p>
+
+<h3 id="有疑问时_malloc">有疑问时, malloc()</h3>
+
+<p>When you need to keep data around, you can use <code>malloc()</code> to allocate it directly. This bypasses JavaScript's memory management and lets you handle memory management yourself.</p>
+
+<ul>
+</ul>
diff --git a/files/zh-cn/mozilla/js-ctypes/using_js-ctypes/working_with_arraybuffers/index.html b/files/zh-cn/mozilla/js-ctypes/using_js-ctypes/working_with_arraybuffers/index.html
new file mode 100644
index 0000000000..521fa9030f
--- /dev/null
+++ b/files/zh-cn/mozilla/js-ctypes/using_js-ctypes/working_with_arraybuffers/index.html
@@ -0,0 +1,212 @@
+---
+title: Working with ArrayBuffers
+slug: Mozilla/js-ctypes/Using_js-ctypes/Working_with_ArrayBuffers
+translation_of: Mozilla/js-ctypes/Using_js-ctypes/Working_with_ArrayBuffers
+---
+<section class="Quick_links" id="Quick_Links">
+<ol>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes"><strong><em>js-ctypes</em></strong></a></li>
+ <li class="toggle">
+ <details open><summary>Introduction</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Debugging_Tips" title="Editorial review completed.">Debugging Tips</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Declaring_and_calling_functions" title="Functions are declared using the Library object's declare() method. Once declared, functions can be called using standard function syntax.">Declaring and Calling Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Declaring_and_Using_Callbacks" title="C functions occasionally take function pointers as arguments, which are generally used as callbacks. In these cases, js-ctypes allows you to pass a regular JavaScript function as the callback. This is very powerful, since it allows native code to transparently call into JavaScript.">Declaring and Using Callbacks</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Declaring_types" title="The ctypes object offers a number of constructor methods that let you declare types. Every type is represented by a CType object, which, in turn, provides a constructor method you can call to define values of those types. Each type you declare using js-ctypes corresponds to a compatible C declaration.">Declaring types</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Memory_Management" title="If JS code creates a structure or an array, that memory will be valid as long as the JS object stays alive. Pointers to that memory must be carefully managed to make sure the underlying memory is still referenced.">Memory Management</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Standard_OS_Libraries" title="This article gives the names of standard libraries that can be accessed with js-ctypes. These libraries are what enable js-ctypes to work. The alternative to standard libraries is creating your own DLL (for Windows) or SO (for Linux) file with C functions that can be called from your add-on with js-ctypes. The DLL/SO/etc file you make must be shipped with your add-on. Standard libraries offer the advantage of not having to ship anything. They are already available on the operating system for you. You just need to supply the path to appropriate files and set up the proper types of values/arguments in the js-ctypes code. This article allows you to find out what types to give to values/arguments by supplying links to the documentation of the OS libraries.">Standard OS Libraries</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Type_conversion" title="In js-ctypes, data could be converted implicitly when passing to or returning from a FunctionType call, or setting pointer content, an array element or a struct field.">Type conversion</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Working_with_ArrayBuffers" title="An ArrayBuffer is a simply byte array. The js-ctypes equivalent is a ctypes.uint8_t.array(###) (ctypes.unsigned_char are also ctypes.uint8_t).">Working with ArrayBuffers</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Working_with_data" title="Data types for use with js-ctypes are represented by CType objects. These are JavaScript constructors; as such, they're callable functions that you can use to create new CData objects of that type. There are several ways you can go about creating new CData objects.">Working with data</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/ctypes.open" title="At the heart of js-ctypes is the ctypes.open() function. This must be called before any work can commence. There are two options:">ctypes.open</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>References</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/ABI" title="This article describes the calling conventions with respect to js-ctypes while programming x86 and x86-64/x64/AMD64 architectures. A calling convention is an implementation-level (low-level) scheme regarding how subroutines receive parameters from their caller and how they revert."><code>ABI</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/ArrayType" title="ArrayType represents C arrays"><code>ArrayType</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/CData" title="A CData object represents a C value or function located in memory."><code>CData</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/CType" title="All data types declared using the js-ctypes API are represented by CType objects. These objects have assorted methods and properties that let you create objects of these types, find out information about them, and so forth. The specific properties and methods on each object vary depending on the data type represented."><code>CType</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/FunctionType" title=""><code>FunctionType</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/Int64" title="Because JavaScript doesn't currently include standard support for 64-bit integer values, js-ctypes offers the Int64 and UInt64 objects to let you work with C functions and data that need (or may need) values represented using a 64-bit data type."><code>Int64</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/Library" title="The Library object represents a native library loaded by the ctypes open() method. Its methods let you declare symbols exported by the library, and to manage the library."><code>Library</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/PointerType" title="Returns a new CType object describing a new pointer data type."><code>PointerType</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/StructType" title="Returns a CType object describing a new structure data type. This data type provides the ability to define and manipulate values of the C struct type."><code>StructType</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/UInt64" title="As JavaScript doesn't currently include standard support for 64-bit integer values, js-ctypes offers the Int64 and UInt64 objects to let you work with C functions and data that need (or may need) to use data represented using a 64-bit data type."><code>UInt64</code></a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/ctypes" title="The ctypes object contains methods and predefined data types used to create and manage a library."><code>ctypes</code></a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Examples</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Examples/Add_to_iPhoto" title="This extension for Mac OS X serves as a demonstration of how to use js-ctypes to call Mac OS X Carbon, Core Foundation, and other system frameworks from an extension written entirely in JavaScript.">Add to iPhoto</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Examples/Using_C_structs_and_pointers" title="In this example, we show how to use C structs and pointers with js-ctypes.">Using C struct and pointers</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Examples/Using_COM_from_js-ctypes" title="The Windows API mostly concerns itself with the interaction between the operating system and an application. For communication between the different Windows applications among themselves, Microsoft has developed a series of technologies alongside the main Windows API. This started out with Dynamic Data Exchange (DDE), which was superseded by Object Linking and Embedding (OLE) and later by the Component Object Model (COM), Automation Objects, ActiveX controls, and the .NET Framework.">Using COM from js-ctypes</a></li>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Examples/Using_Objective-C_from_js-ctypes" title="Objective-C has its own syntax, it cannot be written directly with js-ctypes. This guide explains how to convert Objective-C code into js-ctypes code.">Using Objective-C from js-ctypes</a></li>
+ </ol>
+ </details>
+ </li>
+</ol>
+</section>
+
+<h2 id="导读">导读</h2>
+
+<p>类型转换页的指针类型部分解释了此操作的基本原理。第二个代码示例提供了操作的具体说明。</p>
+
+<p class="summary"><span class="seoSummary"><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" title="The ArrayBuffer object is used to represent a generic, fixed-length raw binary data buffer. You cannot directly manipulate the contents of an ArrayBuffer; instead, you create one of the typed array objects or a DataView object which represents the buffer in a specific format, and use that to read and write the contents of the buffer."><code>ArrayBuffer</code></a> 是简单的字节数组 ,这种js 类型 等同于 <code>ctypes.uint8_t.array(###)</code> (<code>ctypes.unsigned_char</code> are also <code>ctypes.uint8_t</code>).</span></p>
+
+<p><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=732936" title="FIXED: Feeding ArrayBuffer to js-ctypes">bug 732936</a> 包括使用ArrayBuffer的讨论.</p>
+
+<p>This feature is based on the following work:</p>
+
+<p><a href="https://dxr.mozilla.org/mozilla-central/source/js/src/ctypes/CTypes.cpp#3080" title="https://dxr.mozilla.org/mozilla-central/source/js/src/ctypes/CTypes.cpp#3080 (new window)">https://dxr.mozilla.org/mozilla-central/source/js/src/ctypes/CTypes.cpp#3080</a></p>
+
+<p><a href="https://dxr.mozilla.org/mozilla-central/source/js/src/vm/ArrayBufferObject.cpp#1301" title="https://dxr.mozilla.org/mozilla-central/source/js/src/vm/ArrayBufferObject.cpp#1301 (new window)">https://dxr.mozilla.org/mozilla-central/source/js/src/vm/ArrayBufferObject.cpp#1301</a></p>
+
+<h3 id="Example_1_-_Image_Data">Example 1 - Image Data</h3>
+
+<p>The following example illustrates how to transfer a byte array pointed by <code>ctypes.uint8_t.ptr</code> to <a href="/en-US/docs/Web/API/ImageData" title="The ImageData interface represents the underlying pixel data of an area of a &lt;canvas> element. It is created using the ImageData() constructor or creator methods on the CanvasRenderingContext2D object associated with a canvas: createImageData() and getImageData(). It can also be used to set a part of the canvas by using putImageData()."><code>ImageData</code></a> of canvas. This example is based on the fact that the ImageData returned from <a href="/en-US/docs/Web/API/CanvasRenderingContext2D/getImageData" title="The CanvasRenderingContext2D method getImageData() of the Canvas 2D API returns an ImageData object representing the underlying pixel data for a specified portion of the canvas."><code>CanvasRenderingContext2D.getImageData</code></a> is a <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray" title="The Uint8ClampedArray typed array represents an array of 8-bit unsigned integers clamped to 0-255; if you specified a value that is out of the range of [0,255], 0 or 255 will be set instead; if you specify a non-integer, the nearest integer will be set. The contents are initialized to 0. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation)."><code>Uint8ClampedArray</code></a> view for an <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" title="The ArrayBuffer object is used to represent a generic, fixed-length raw binary data buffer. You cannot directly manipulate the contents of an ArrayBuffer; instead, you create one of the typed array objects or a DataView object which represents the buffer in a specific format, and use that to read and write the contents of the buffer."><code>ArrayBuffer</code></a>.</p>
+
+<p>The following codeblock provides a basic example of getting and setting <code>Uint8ClampedArray</code> and <code>ArrayBuffer</code> of <code>ImageData:</code></p>
+
+<pre>// context is a CanvasRenderingContext2D of some canvas
+var imageData = context.getImageData(x, y, w, h);
+var array = imageData.data; // array is a Uint8ClampedArray
+var buffer = imageData.data.buffer; // buffer is a ArrayBuffer
+
+// incomingBuffer is a TypedArray
+var imageData2 = context.createImageData(w, h);
+imageData2.data.set(incomingBuffer);
+</pre>
+
+<p>Further, if you have a byte array <code>pixelBuffer</code>, and you need to create <code>ImageData</code> from it. The <code>data</code> property holds an array of bytes.</p>
+
+<p>We start with the following:</p>
+
+<pre>// pixelBuffer is a pointer to a RGBA pixel buffer of 400x400 image.
+pixelBuffer.toString(); // "ctypes.uint8_t.ptr(ctypes.UInt64("0x352e0000"))"
+
+var imgWidth = 400;
+var imgHeight = 400;
+var myImgDat = new ImageData(imgWidth, imgHeight);
+</pre>
+
+<h4 id="Method_1_Passing_ArrayType_CData_to_Uint8ClampedArray.prototype.set">Method 1: Passing ArrayType CData to Uint8ClampedArray.prototype.set</h4>
+
+<p>One method is to get into a js-ctypes array, and then set it into the <code>ImageData</code>, as illustrated by the following code example.</p>
+
+<pre class="brush: js">// Cast pointer to array, to pass to Uint8ClampedArray.prototype.set.
+var casted = ctypes.cast(pixelBuffer.address(), ctypes.uint8_t.array(myImgData.data.length).ptr).contents; // myImgDat.data.length is imgWidth * imgHeight * 4 because per pixel there is r, g, b, a numbers
+casted.toString(); // "ctypes.uint8_t.array(640000)([45, 66, 135, 255, 99, 86, 55, 255, .......... ])"
+myImgDat.data.set(casted);
+</pre>
+
+<p>The <code>ctypes.cast</code> takes a couple of milliseconds, however, the <code>myImgDat.data.set</code> takes up to 800ms for a size of 52,428,800 (which is image size of 1280 x 1024 pixels). So, for the size of 640,000 it takes about 98ms.</p>
+
+<h4 id="Method_2_Manually_Handled">Method 2: Manually Handled</h4>
+
+<p>Another strategy is to handle it manually, as illustrated by the following code example:</p>
+
+<pre class="brush: js">var casted = ctypes.cast(pixelBuffer.address(), ctypes.uint8_t.array(myImgData.data.length).ptr).contents; // myImgDat.data.length is imgWidth * imgHeight *4 because per pixel there is r, g, b, a numbers
+
+/** METHOD A **/
+for (var nIndex = 0; nIndex &lt; casted.length; nIndex = nIndex + 4) { // casted.length is same as myImgDat.data.length
+ var r = casted[nIndex];
+ var g = casted[nIndex + 1];
+ var b = casted[nIndex + 2];
+ var a = casted[nIndex + 3];
+
+ myImgDat.data[nIndex] = r;
+ myImgDat.data[nIndex + 1] = g;
+ myImgDat.data[nIndex + 2] = b;
+ myImgDat.data[nIndex + 3] = a;
+}
+
+
+/***** OR DO THE BELOW WHICH USES THE .set METHOD *****/
+
+/** METHOD B **/
+var normalArr = [];
+for (var nIndex = 0; nIndex &lt; cast.length; nIndex = nIndex + 4) { // casted.length is same as myImgDat.data.length
+ var r = casted[nIndex];
+ var g = casted[nIndex + 1];
+ var b = casted[nIndex + 2];
+ var a = casted[nIndex + 3];
+
+ normalArr.push(r);
+ normalArr.push(g);
+ normalArr.push(b);
+ normalArr.push(a);
+}
+myImgDat.data.set(normalArr);
+</pre>
+
+<p>The preceding example, however, does not take advantage of Method 1, but instead manually goes through the array and sets the <code>ImageData</code> array. The cast takes a couple of milliseconds, roughly the same as Method 1. However, the manual Method A, in the preceding example, takes ~1300 ms. Method B takes ~1400 ms, for an array length of 52,428,800 (which is image size of 1280 x 1024 pixels).</p>
+
+<h4 id="Method_3_Transfer_byte_array_by_calling_memcpy">Method 3: Transfer byte array by calling memcpy</h4>
+
+<p>This is the recommended method, as it only takes a couple of milliseconds, even for large arrays. Notice that the following example does not cast the <code>pixelBuffer</code>. Passing an <code>ArrayBuffer</code> object to pointer type will pass the pointer to buffer (Based on <a href="https://dxr.mozilla.org/mozilla-central/source/js/src/ctypes/CTypes.cpp#3080">https://dxr.mozilla.org/mozilla-central/source/js/src/ctypes/CTypes.cpp#3080</a>). Further, it returns <code>dataPointer</code>, and there is no extra allocation (Based on <a href="https://dxr.mozilla.org/mozilla-central/source/js/src/vm/ArrayBufferObject.cpp#1301">https://dxr.mozilla.org/mozilla-central/source/js/src/vm/ArrayBufferObject.cpp#1301</a>).</p>
+
+<pre class="brush: js">var lib;
+switch (OS.Constants.Sys.Name.toLowerCase()) {
+ case 'winnt':
+ case 'winmo':
+ case 'winnt': //windows
+ lib = ctypes.open('msvcrt');
+ break;
+ case 'darwin': // mac
+ lib = ctypes.open('libc.dylib');
+ break;
+ case 'freebsd':
+ lib = ctypes.open('libc.so.7');
+ break;
+ case 'openbsd':
+ lib = ctypes.open('libc.so.61.0');
+ break;
+ case 'android':
+ case 'sunos':
+ case 'netbsd':
+ case 'dragonfly':
+ lib = ctypes.open('libc.so');
+ break;
+ case 'linux':
+ lib = ctypes.open('libc.so.6');
+ break;
+ case 'gnu/kfreebsd':
+ lib = ctypes.open('libc.so.0.1');
+ break;
+ default:
+ //assume unix
+ try {
+ lib = ctypes.open(ctypes.libraryName('c'));
+ } catch (ex) {
+ throw new Error('I dont know where to memcpy is defined on your operating system, "' + OS.Constants.Sys.Name + '"');
+ lib.close();
+ }
+}
+
+try {
+ var memcpy = lib.declare('memcpy', OS.Constants.Sys.Name.toLowerCase().indexOf('win') == 0 ? ctypes.winapi_abi : ctypes.default_abi,
+ ctypes.void_t, // return
+ ctypes.void_t.ptr, // *dest
+ ctypes.void_t.ptr, // *src
+ ctypes.size_t // count
+ );
+} catch (ex) {
+ throw new Error('I dont know where to memcpy is defined on your operating system, "' + OS.Constants.Sys.Name + '"');
+ lib.close()
+}
+
+memcpy(myImgDat.data, pixelBuffer, myImgDat.data.length); // myImgDat.data.length is imgWidth * imgHeight *4 because per pixel there is r, g, b, a numbers
+
+lib.close();
+</pre>
+
+<h2 id="See_Also">See Also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Type_conversion">Type Conversion</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/localization/faq/index.html b/files/zh-cn/mozilla/localization/faq/index.html
new file mode 100644
index 0000000000..33cecd28f0
--- /dev/null
+++ b/files/zh-cn/mozilla/localization/faq/index.html
@@ -0,0 +1,17 @@
+---
+title: 本地化 FAQ
+slug: Mozilla/Localization/FAQ
+tags:
+ - 本地化
+translation_of: Mozilla/Localization/FAQ
+---
+<p> </p>
+
+<p>本页列出了可能不需要完整页面的调整和提示。 有关通用本地化的更多详细文档,请参阅我们的 <a href="/docs/Mozilla/Localization">本地化</a> 页面。<br>
+ <br>
+ <strong>我如何在实体中保留空白?</strong><br>
+         如果你真的想保留空格,或者你正在寻找一个不间断的空间,你可以通过<code>&amp;ua0;</code> 或 <code>\ua0</code> 到DTD和属性文件,<br>
+ <strong>如何在 .properties 条目中不显示变量?</strong><br>
+         您可以简单地将该值设置为零宽度,即使用<code>%1$0.S</code></p>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/localization/index.html b/files/zh-cn/mozilla/localization/index.html
new file mode 100644
index 0000000000..b74757ccc1
--- /dev/null
+++ b/files/zh-cn/mozilla/localization/index.html
@@ -0,0 +1,20 @@
+---
+title: 参与 Mozilla 本地化工作
+slug: Mozilla/Localization
+tags:
+ - Landing
+ - Localization
+ - Mozilla
+ - NeedsTranslation
+ - TopicStub
+ - Translation
+ - l10n
+translation_of: Mozilla/Localization
+---
+<p><span class="seoSummary"><strong>Localization</strong> (L10n) is the process of translating software user interfaces from one language to another and adapting it to suit a foreign culture. These resources are for anyone with an interest in the technical aspects involved in localization.</span> They are for developers and all contributors</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Project:MDN/Localizing" title="/en-US/docs/Project:MDN/Localizing">Localizing MDN</a> (About localization of the documentation here on MDN)</li>
+</ul>
diff --git a/files/zh-cn/mozilla/localization/l10n_style_guide/index.html b/files/zh-cn/mozilla/localization/l10n_style_guide/index.html
new file mode 100644
index 0000000000..86e242c5ca
--- /dev/null
+++ b/files/zh-cn/mozilla/localization/l10n_style_guide/index.html
@@ -0,0 +1,482 @@
+---
+title: Mozilla 本地化风格指南
+slug: Mozilla/Localization/L10n_Style_Guide
+translation_of: Mozilla/Localization/L10n_Style_Guide
+---
+<h3 id="前言"><span class="author-a-z87zt8dz75zn14z76zz71z8z82zz86z2uq">前言</span></h3>
+
+<div id="magicdomid8"><span class="author-a-z87zt8dz75zn14z76zz71z8z82zz86z2uq">      风格指南定义</span><span id="result_box" lang="zh-CN"><span>风格指南</span><span>用于定义</span><span>我们</span><span>用来评价</span><span>翻译</span><span>质量的</span><span>标准</span><span>。</span><span>它</span><span>由</span><span> Mozilla 和 Mozilla 的</span><span>本地化</span><span>社区</span><span>定义的规则</span></span><span lang="zh-CN"><span>组成,主要针对如何以最佳的方式翻译 </span><span>Mozilla </span><span>的产品</span><span>、</span><span>网站和其他</span><span>项目。风格指南</span><span>可以用来</span><span>同时翻译</span><span>和评估</span><span>翻译</span><span>的</span><span>质量。</span><span>通过遵循这些</span><span>规则</span><span>,翻译人员会更容易得到</span><span>高质量的翻译,便于更好的</span><span>展示 Mozilla 的价值观和文化。这里我们列出国际上其他组织制定的一些风格指南的例子</span></span><span class="author-a-z87zt8dz75zn14z76zz71z8z82zz86z2uq">:</span></div>
+
+<ul>
+ <li id="magicdomid9"><span class="author-a-z87zt8dz75zn14z76zz71z8z82zz86z2uq url"><a href="https://help.apple.com/asg/mac/2013/ASG_2013.pdf">https://help.apple.com/asg/mac/2013/ASG_2013.pdf</a></span></li>
+ <li id="magicdomid10"><span class="author-a-z87zt8dz75zn14z76zz71z8z82zz86z2uq url"><a href="https://www.microsoft.com/Language/zh-CN/StyleGuides.aspx">https://www.microsoft.com/Language/zh-CN/StyleGuides.aspx</a></span></li>
+ <li><a href="https://www.facebook.com/translations/style_guides">https://www.facebook.com/translations/style_guides</a></li>
+</ul>
+
+<div><span id="result_box" lang="zh-CN"><span>本风格</span><span>指南</span><span>分为</span><span>两个主要</span><span>部分:第一部分</span><span>和</span><span>特定语言相关</span><span>,必须由</span><span>每个</span><span> Mozilla 的</span><span>本地化社区</span><span>(包括</span><span>特定的语言</span><span>风格</span><span>,术语和</span><span>单位</span><span>)来定义的</span><span>规则;</span><span>第二个是由 </span><span>Mozilla </span><span>为所有</span><span>语言</span><span>定义的一般规则,可以帮助你</span><span>较好的翻译</span><span>(包括</span><span>准确度和</span><span>流畅性</span><span>原则</span><span>)</span><span>。</span></span></div>
+
+<h3 id="sect1"> </h3>
+
+<h2 id="简体中文相关_Mozilla_风格">简体中文相关 Mozilla 风格</h2>
+
+<ol style="margin-left: 80px;">
+</ol>
+
+<div id="magicdomid16">
+<h4 dir="ltr" id="基本要求" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 12.75pt;"><strong style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline;">基本要求</strong></h4>
+
+<ol style="margin-top: 0pt; margin-bottom: 0pt;">
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">准确表述原文的意思、情感、立场、价值观;</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">既要避免翻译后反而模糊,也要避免翻译无须翻译的词语,力求浅显易懂;</span></p>
+
+ <ul>
+ <li style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">若有译法尚有争议的单词,应采用最常使用的译法,并在词语后以全角括号标注英文</span></p>
+ </li>
+ </ul>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">中文应该意思清晰且符合中文表达习惯,</span>同一句里不要重复出现相同主语(如“if you forget your password”应译为“如果您忘记了密码”),且应适当减少数词与量词<span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;"> ;</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">明显是美国文化的,或在中国大陆当代文化下难以理解的,可用相近的中国大陆文化代替,但不能与第 1 点抵触;</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">不必字对字、句对句翻译,原文如果表达不清晰,中文应该意译,并且应根据上下文和注释进行推断并填补或删减相应的信息,但不能与第 1 点抵触;</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">情况 5 不能太多;</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">对同样短语的翻译,前后必须一致,可利用 Pontoon 的 Translation Memory 查看以往译法,也可参考<a href="https://wiki.mozilla.org/L10n:Teams:zh-CN#L10n_Kits">其他工具</a>;</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;">对用户和开发者称“您”,对职员和志愿者称“你”<span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">,若需轻松的语气则一律用“你”;</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">不要使用机器翻译的成果来提交,也就是说您可以使用 Google Translate 来帮助您理解内容,但是不能不经考虑就把其自动翻译的结果放在翻译里;</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">若产品内显示的中文换行不理想,应适当增删文字,在网页上也可使用 \n 强制换行。</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">不太有把握的,请大胆地通过<a href="https://wiki.mozilla.org/L10n:Teams:zh-CN#How_to_join_this_team">这些方式</a>进行讨论。</span></p>
+ </li>
+</ol>
+</div>
+
+<div> </div>
+
+<div>
+<h3 id="术语表"><span class="author-a-w6z79zlakz82zxz85zz65zz86zz78zz89zz122zz89zd b"><strong>术语表</strong></span></h3>
+
+<div id="magicdomid29"><span class="author-a-z87zt8dz75zn14z76zz71z8z82zz86z2uq">这里我们列出一些可参考的 软件/互联网 相关的术语和定义的列表:</span></div>
+
+<ul>
+ <li>Mozilla 简体中文名词术语表:<a href="https://wiki.mozilla.org/Glossary_of_substantival_term_in_zh-CN_locale">https://wiki.mozilla.org/Glossary_of_substantival_term_in_zh-CN_locale</a></li>
+ <li>Mozilla 简体中文动词术语表: <a href="https://wiki.mozilla.org/Glossary_of_verbal_term_in_zh-CN_locale">https://wiki.mozilla.org/Glossary_of_verbal_term_in_zh-CN_locale</a></li>
+ <li id="magicdomid30"><span class="author-a-z87zt8dz75zn14z76zz71z8z82zz86z2uq">Microsoft 术语表  </span><span class="author-a-z87zt8dz75zn14z76zz71z8z82zz86z2uq url"><a href="https://www.microsoft.com/Language/zh-CN/Default.aspx">https://www.microsoft.com/Language/zh-CN/Default.aspx</a></span></li>
+ <li id="magicdomid31"><span class="author-a-z87zt8dz75zn14z76zz71z8z82zz86z2uq">Pootle的术语表: </span><span class="author-a-z87zt8dz75zn14z76zz71z8z82zz86z2uq url"><a href="https://mozilla.locamotion.org/zh-CN/terminology/essential.po">https://mozilla.locamotion.org/zh-CN/terminology/essential.po</a></span><span class="author-a-z87zt8dz75zn14z76zz71z8z82zz86z2uq"> </span></li>
+</ul>
+
+<div id="magicdomid33"><span class="author-a-z87zt8dz75zn14z76zz71z8z82zz86z2uq">使用对应术语翻译的时候,请注意要保持一致性。而且要注意避免以下几点:</span></div>
+
+<ul>
+ <li id="magicdomid34"><span class="author-a-z87zt8dz75zn14z76zz71z8z82zz86z2uq">同一项目内术语不一致</span></li>
+ <li>多项目术语不一致</li>
+ <li id="magicdomid37"><span class="author-a-z87zt8dz75zn14z76zz71z8z82zz86z2uq">使用其他领域的术语</span><span class="author-a-w6z79zlakz82zxz85zz65zz86zz78zz89zz122zz89zd">(例如, 请勿在 Firefox 中使用医学用语)。</span></li>
+</ul>
+
+<div id="magicdomid100"> </div>
+
+<h4 id="词语形式"><span class="author-a-z66zuz70zqiz67zz73z3z90zhp4z68zz73zpj b"><strong>词语形式</strong></span></h4>
+
+<h5 id="复数"><span class="author-a-z66zuz70zqiz67zz73z3z90zhp4z68zz73zpj">复数  </span></h5>
+
+<div id="magicdomid106"><span class="author-a-z66zuz70zqiz67zz73z3z90zhp4z68zz73zpj">Pontoon 上 zh-CN 区分单复数。汉语由于没有区分单复数形式</span>,所以一般单数和复数翻译成一样即可。但有时区分单复数会带来更好效果。</div>
+
+<div id="magicdomid107"> </div>
+
+<h5 id="特殊符号"><span class="author-a-z66zuz70zqiz67zz73z3z90zhp4z68zz73zpj b"><strong>特殊符号</strong></span></h5>
+
+<div> </div>
+
+<div id="magicdomid117">
+<p dir="ltr" id="docs-internal-guid-bc308f52-cb22-5930-b22c-3ea64140e53f" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">常用的有以下几个:</span></p>
+
+<ul style="margin-top: 0pt; margin-bottom: 0pt;">
+ <li dir="ltr" style="list-style-type: disc; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">\n   换行</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: disc; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">\t   水平制表符</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: disc; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">\v  竖直制表符</span></p>
+ </li>
+</ul>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">您不需要将同样数量的格式标记放在翻译中,但是如果它们之一有在原文开始或者结束位置的时候,您必须在翻译中使之包含在对应的开始或者结束之处。</span></p>
+
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">如果要显示非转义字符,则需要使用 \ 来表明取消转义,如 " (半角双引号)表示字符串的开始或者结束,如果要在内容中使用该符号,则需输入 \",还可以参考以下例子:</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">----------------------------------------------------------------</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">\"\\t\"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">----------------------------------------------------------------</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">在运行时显示的结果是 "t"</span></p>
+
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">(2)XML 中的角括号和“&amp;”号</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 12.75pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">有一些模块中 XML 被频繁地使用,XML 将“&lt;”“&gt;”和“&amp;”视为保留字符,您不能将其直接添加到翻译中。必须将其实体以下面的形式表示:</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 12.75pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">&amp;lt 代表 &lt;; &amp;gt 代表 &gt;; &amp;amp 代表 &amp;。</span></p>
+
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 12.75pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">(3) TRUE 和 FALSE</span></p>
+<span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">“TRUE”和“FALSE”多不要翻译它们。如果程序读不到正确的值,可能会出现问题。</span></div>
+
+<div id="magicdomid118"> </div>
+
+<h5 id="标点的使用">标点的使用</h5>
+
+<p dir="ltr" id="docs-internal-guid-bc308f52-cb23-3790-6d9d-94db4a56c221" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">一般的原则是:除了小括号、省略号和破折号保留不变以外,都应该使用中文(全角)标点符号。英文标点符号后方常常跟随有一个半角空格,请在翻译成中文标点符号时将其去除。</span></p>
+
+
+<ol style="margin-top: 0pt; margin-bottom: 0pt;">
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">英文中的 , 在中文中可能是 ,或者 、</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">英文中的 . 在中文中应该是 ,或者 。,视上下文而定,多数是 。</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">英文中的 \"%s\" 在 GUI 程序中应该翻译为 “%s”, 而不是 \"%s\" 或者 \“%s\”,而且后者是不符合换码序列要求的。即在 GUI 程序中`something' 和 'something' 以及 \"something\" 都应该翻译为 “某事”</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">英文中的 : 应该翻译为:(全角)而不是 :(半角), 而作为分隔符时(例如时间),: 保留为英文(半角)的, 因为这个时候不是标点符号</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">英文中的 ( ) 应该一般都翻译成全角小括号( )。</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">英文中的“…”或“...”,应该保持不变,前者等价于半个全角中文省略号</span>。</p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">英文中的 -- 应该保持不变。由于全角破折号 —— 兼容性不好,有时显示为两个方格,所以不再使用。</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">其他标点符号的使用参见<a href="http://www.moe.gov.cn/s78/A19/yxs_left/moe_810/s230/201001/t20100115_75611.html">中华人民共和国 GB/T 15834-2011</a>。</span></p>
+ </li>
+</ol>
+
+<div id="magicdomid130"> </div>
+
+<h5 id="空格"><span class="author-a-z66zuz70zqiz67zz73z3z90zhp4z68zz73zpj">空格 </span></h5>
+
+<div id="magicdomid135">
+<p dir="ltr" id="docs-internal-guid-bc308f52-cb25-8cbb-98d0-542b0c943575" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">为了美观,通常建议在中文与英文、中文与阿拉伯数字、英文与阿拉伯数字之间加入一个半角空格。例如:</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">----------------------------------------------------------------</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">原文 "Installing driver for %1"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">翻译 "正在安装 %1 的驱动程序"</span></p>
+
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">原文 ""</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"Parameter start_num specifies the character at which to start the search. "</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"The first character is character number 1. If start_num is omitted, it is "</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"assumed to be 1."</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">翻译 ""</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"参数 start_num 指定开始搜索的字符位置。第一个字符序号为 1。如果省略 "</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"start_num,默认它为 1。"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">----------------------------------------------------------------</span></p>
+
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">对于小括号和全角双引号,其两侧不加空格:</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">----------------------------------------------------------------</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">原文 "Original idea and author (KDE1)"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">翻译 "原始创意和作者(KDE1)"</span></p>
+
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">原文 ""</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"The APM Management subsystem seems to be disabled.\n"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"Try executing \"apm -e 1\" (FreeBSD) and see if \n"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"that helps.\n"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">翻译 ""</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"APM 管理子系统似乎被禁用了。\n"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"试试执行“apm -e 1”(FreeBSD)并看看\n"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 12.75pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"是否有用。\n"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 12.75pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">----------------------------------------------------------------</span></p>
+
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 12.75pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">包含 XML/HTML 标签的条目,如要在标签中的内容两侧添加空格,请把空格置于标签外侧,否则空格可能显示不出来。</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 12.75pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">----------------------------------------------------------------</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 12.75pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">这是 &amp;lt;b&amp;gt;HTML&amp;lt;/b&amp;gt; 的语法手册</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">----------------------------------------------------------------</span></p>
+</div>
+
+<h5 id="sect2"> </h5>
+
+<h5 id="菜单项中的快捷字符">菜<strong>单项中的快捷字符</strong></h5>
+
+<p><strong>  </strong>与 Gnome 或者 KDE 菜单不同,Firefox 中的菜单快捷键无需添加到翻译的字符串中。</p>
+
+<p>例如:</p>
+
+<p dir="ltr" id="docs-internal-guid-bc308f52-cb2a-3f5a-5f1d-c645a95edb1f" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 12.75pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">KDE 菜单:</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 12.75pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">----------------------------------------------------------------</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">msgid "C&amp;lear"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">msgstr "清除(&amp;L)"</span></p>
+
+<p><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">----------------------------------------------------------------</span></p>
+
+<p><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">而 Firefox 中,直接翻译为 "清除"即可,不可添加 "(&amp;L)"。</span></p>
+
+<h5 id="翻译中参数的位置"><span class="author-a-z66zuz70zqiz67zz73z3z90zhp4z68zz73zpj">翻译中参数的位置</span></h5>
+
+<p dir="ltr" id="docs-internal-guid-bc308f52-cb2d-272c-c8cc-dbacc8044e5b" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">有时候原来的参数顺序不符合中文的语法,一方面, 翻译可以通过调整副词、语序等手法来符合中文习惯,另外一方面,在必要的情况下,需要改变参数的位置,例如:</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">----------------------------------------------------------------</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">原文 "%1$S articles match rule %2$S"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">翻译 "匹配规则 %2$S 的文章有 %1$S 个"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">----------------------------------------------------------------</span></p>
+
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 12.75pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">即用 %1$S、%2$S、%3$S 等符号标明参数在原文里出现的位置。同时,任何一个参数的顺序进行了调整,则在这一句译文中所有参数都必须注明原文位置,否则无法通过格式检查。</span></p>
+
+<h5 id="关于换行"><span class="author-a-z66zuz70zqiz67zz73z3z90zhp4z68zz73zpj">关于换行</span></h5>
+
+<p dir="ltr" id="docs-internal-guid-bc308f52-cb31-4d94-da10-a5b7e01d9684" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">对于很长的译文,就涉及到了换行问题。多数情况下没有限制,因为不影响最终的显示效果,只要阅读起来方便就行。下面几种格式都是正确的:</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">----------------------------------------------------------------</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">原文 ""</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"Preview failed: neither the internal KDE PostScript viewer (KGhostView) nor "</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"any other external PostScript viewer could be found."</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">翻译 ""</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"预览失败:找不到 KDE 内建的 PostScript 查看器(KGhostView)或其它外部"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"的 PostScript 查看器。"</span></p>
+
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">原文 ""</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"Preview failed: neither the internal KDE PostScript viewer (KGhostView) nor "</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"any other external PostScript viewer could be found."</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">翻译 "预览失败:找不到 KDE 内建的 PostScript 查看器(KGhostView)或其它外部"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"的 PostScript 查看器。"</span></p>
+
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">原文 ""</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"Preview failed: neither the internal KDE PostScript viewer (KGhostView) nor "</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"any other external PostScript viewer could be found."</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">翻译 ""</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"预览失败:找不到 KDE 内建的 PostScript 查"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"看器(KGhostView)或其它外部"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">"的 PostScript 查看器。"</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: 'Courier New'; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">----------------------------------------------------------------</span></p>
+
+<h5 id="sect3"><span class="author-a-z66zuz70zqiz67zz73z3z90zhp4z68zz73zpj">  </span></h5>
+
+<h5 id="关于时间的翻译"><span class="author-a-z66zuz70zqiz67zz73z3z90zhp4z68zz73zpj">关于时间的翻译</span></h5>
+
+<p dir="ltr" id="docs-internal-guid-bc308f52-cb32-7220-071f-4828037fcd32" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">鉴于关于日期和时间的译法十分复杂,现在将国家标准中有关规定简要介绍一下,并给出推荐译法。</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">国标 GB/T 7408-94</span><a href="http://people.ubuntu.com/~happyaron/l10n/GB(T)7408-94.pdf" style="text-decoration: none;"><u>《数据元和交换格式 信息交换 日期和时间表示法》</u></a></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">1994-12-06 发布,1995-08-01 实施   国家技术监督局发布</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">本标准等效采用国际标准 ISO 8601-1988《数据元和交换格式  信息交换 日期和时间表示法》</span></p>
+
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">以下是最需要注意的几个要点:</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">(1) 在日期格式中不能出现空格,即“2003 年”这样的格式是不符合国标的。</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">(2) 表示日期时,必须按照年月日的顺序;年份一般用四位数字,而月、日必须使用带前导零的两位数字;必须使用“-”作为分隔符,或完全不使用分隔符。 即“2004-01-03”或“20040103”来表示 2004年1月3日。</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">(3) 表示时间时,时、分、秒都必须使用两位数字,中间用“:”(半角括号)分隔,或完全不使用分隔符。小时计法采用 24 小时制,不区分上下午。</span></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">(4) 日期和时间写在一起的时候,应先写日期再写时间。在日期和时间都不使用分隔符的情况下,在中间添加字母“T”进行分隔,即“19850412T101530”。</span></p>
+
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">时间的表示方法同 date 命令的表示方法,现将常见的几个对应其含义列表如下:</span></p>
+
+<ol style="margin-top: 0pt; margin-bottom: 0pt;">
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%%     一个 % 字符</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%A      星期几(如“星期一”)</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%B      月份(如“八月”)</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%d      日期(00-31)</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%D      日期,格式等于 %m/%d/%y (例如:08/25/09)</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%F      日期,格式等于 %Y-%m-%d (例如:2009-08-25)</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%g      ISO-8601 格式年份的最后两位(例如:09)</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%G      ISO-8601 格式年份(例如:2009)</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%H      小时(00-23)</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%i       小时(00-12)</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%m     月份(01-12)</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%M     分钟(00-59)</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%n      换行</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%p      显示“上午”或者“下午”两个字</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%S      秒(00-60)</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%t       制表符</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%T      时间,等于 %H:%M:%S</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%x      日期(例如:12/31/99)</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%X      时间(例如:23:13:48)</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%y      年份的最后两位(例如:09)</span></p>
+ </li>
+ <li dir="ltr" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; margin-left: -8px;">
+ <p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"><span style="background-color: transparent; color: #000000; font-family: Verdana; font-size: 13.333333333333332px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline;">%Y      年份(例如:2009)</span></p>
+ </li>
+</ol>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"> </p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;">参考文档: <a href="http://people.ubuntu.com/~happyaron/l10n/l10n-guide-zh-cn.pdf">开源软件简体中文翻译指南</a></p>
+
+<p dir="ltr" style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;"> </p>
+</div>
+
+<h2 id="Mozilla_l10n_通用翻译风格">Mozilla l10n 通用翻译风格</h2>
+
+<h3 id="准确度">准确度</h3>
+
+<h4 id="意译"><span class="author-p-1460 b"><strong>意译</strong></span></h4>
+
+<div id="magicdomid3"><span class="author-p-1460">翻译的重中之重是达意。译者需要首先本身理解文字的确切意思,然后尽量寻找自己语言中最贴切的文字,尽量不增加或删减任何多余的意义。 有时,要找到完全一致的翻译可能会很困难,当发生这样的情况时,多问问自己如下这些问题:</span></div>
+
+<ul>
+ <li><span class="author-p-1460">这个词语/句子/字符串 在英语中是什么意思?</span></li>
+ <li><span class="author-p-1460">作者想表达的真实意思是什么?</span></li>
+ <li><span class="author-p-1460">我应该如何使用我自己的语言表达那个意思?</span></li>
+</ul>
+
+<p><span class="author-p-1460">有些时候,旧的翻译记录以及机器翻译工具可能会提供错误的建议。如果您的翻译流程中使用了其中任何一种,请确保在提交翻译之前检查并修正。要完全避免文字直译,特别是对那些看起来在中英文之间相似,但是实际上意思可能不同的词。</span></p>
+
+<h4 id="不应翻译的内容">不应翻译的内容</h4>
+
+<h5 id="快捷键以及访问键">快捷键以及访问键</h5>
+
+<p>在 Firefox 或其他软件中,均可以使用键盘快捷键来调用特定的命令。例如,可以使用组合键 <code>CTRL+O</code> (Mac 为 <code>Cmd+O</code>  ) 打开一个文件。加速键则因操作系统而异,但是对应的字符一般也是可本地化的。这通常被称为快捷键或者命令键。例如,打开文件<code>… 菜单通常对应:</code></p>
+
+<pre class="sourcelines stripes"><span id="l61"><span class="k">&lt;!ENTITY</span> <span class="ni">openFileCmd.label</span> <span class="s2">"Open File…"</span><span class="k">&gt;</span></span>
+<span id="l62"><span class="k">&lt;!ENTITY</span> <span class="ni">openFileCmd.accesskey</span> <span class="s2">"O"</span><span class="k">&gt;</span></span>
+<span id="l63"><span class="k">&lt;!ENTITY</span> <span class="ni">openFileCmd.commandkey</span> <span class="s2">"o"</span><span class="k">&gt;</span></span></pre>
+
+<p>命令键保存在键 <code>openFileCmd.commandkey 中。一般情况下不应修改这个字符,因为通常即使不同的操作系统也</code>使用一样的快捷键(例如 CTRL+S 保存)或者类似的软件中同样的功能都会使用同样的快捷键(例如 CTRL+T 打开新的标签页)。除非该字符在对应的键盘布局中没有,我们才需对其进行修改。例如,意大利语中字母 [ 需要使用 ALT+<code>è 组合键,因此这样的命令键就无法正常工作。</code></p>
+
+<p>在如上的代码片段中也为 打开文件<code>… </code>定义了一个访问键,访问键用于使用键盘访问图形界面中的项目,例如:如果 文件 菜单定义了访问键 F,同时  打开文件<code>… 菜单定义了访问键 O,那么你可以按 ALT+F 来访问文件菜单,然后按 O 键来打开一个文件。</code></p>
+
+<p>访问键以及命令键,在 .dtd 和 .properties 文件中通常使用单独的行进行定义,而且在键 ID 中通常会包含 .accesskey 字符串。</p>
+
+<h5 id="变量"><span class="author-p-1460">变量</span></h5>
+
+<p><span class="author-p-1460">变量不应该被翻译。变量通常以特殊字符开始(例如 $,#,% 等),并后面无空格紧跟着词。例如:$BrandShortName 和 %S。如有需要,你可以移动变量在字符串中的位置。</span></p>
+
+<h5 id="品牌,版权以及商标"><strong><span class="author-p-1460">品牌,版权以及商标</span></strong></h5>
+
+<p><span class="author-p-1460">品牌名称,以及版权声明和商标不应被翻译,或者使用非拉丁语字符替换。详情请查看 <a href="https://www.mozilla.org/en-US/styleguide/communications/translation/">Mozilla 品牌指南</a> 。</span></p>
+
+<p><span style="font-family: open sans light,helvetica,arial,sans-serif; font-size: 1.286rem; letter-spacing: -0.014em; line-height: 1;">翻译特定文化相关的引用</span></p>
+
+<p>有时候,Mozilla 产品或网站项目(例如 市场宣传)中可能会引用美国文化相关的一些概念。翻译这些内容的时候,最好是找到自己文化中等同的一些文化概念。例如,一个美国人可能会说“干的漂亮,本垒打!”,本垒打指的是垒球中的成功范例。对应较贴切的翻译就是要使用类似等同的比喻,以足球为例,就可以翻译为“干的漂亮,好球!”。</p>
+
+<h4 id="法律相关内容">法律相关内容</h4>
+
+<p>Mozilla 项目也常包含一些法律内容,如最终用户许可,隐私政策等等。在进行这些内容的翻译时,要特别注意按 Mozilla 的文化以及价值观,确保翻译的精确,流畅,谨慎的进行审核。</p>
+
+<h3 id="流畅"><span class="author-a-w6z79zlakz82zxz85zz65zz86zz78zz89zz122zz89zd">流畅</span></h3>
+
+<div id="magicdomid153"> </div>
+
+<div id="magicdomid154"><span class="author-a-w6z79zlakz82zxz85zz65zz86zz78zz89zz122zz89zd">要做到流畅的翻译,翻译者不应仅根据语言对应的标准语法,标点和拼写规则,还需尽量避免出现二义性,不一致性,难以理解等问题。</span></div>
+
+<div id="magicdomid155"> </div>
diff --git a/files/zh-cn/mozilla/localization/localizing_extension_descriptions/index.html b/files/zh-cn/mozilla/localization/localizing_extension_descriptions/index.html
new file mode 100644
index 0000000000..9b9bfcac8f
--- /dev/null
+++ b/files/zh-cn/mozilla/localization/localizing_extension_descriptions/index.html
@@ -0,0 +1,60 @@
+---
+title: 本地化
+slug: Mozilla/Localization/Localizing_extension_descriptions
+tags:
+ - Localization
+translation_of: Mozilla/Localization/Localizing_extension_descriptions
+---
+<p>     </p>
+<div>
+ <p><strong>本地化</strong> 是指将软件的用户界面从一种语言翻译成另一种语言并且适应相应文化习惯的过程。 下面这些是关于基于 Mozilla 的 程序/扩展 本地化的资源。</p>
+</div>
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h4 id=".E6.96.87.E6.91.98" name=".E6.96.87.E6.91.98">文摘</h4>
+ <dl>
+ <dt>
+ <a class="internal" href="/en/Create_a_new_localization" title="en/Create a new localization">创建一个新的本地化</a></dt>
+ <dd>
+ <small>创建新的本地化的</small><small>志愿者</small><small>必读.</small></dd>
+ </dl>
+ <dl>
+ <dt>
+ <a class="internal" href="/cn/XUL%20%E6%95%99%E7%A8%8B" title="cn/XUL 教程">XUL 教程:本地化</a></dt>
+ <dd>
+ <small>本地化 XUL 应用程序的</small><small><a href="/cn/XUL_%E6%95%99%E7%A8%8B" title="cn/XUL_教程">XUL 教程</a>部分.</small></dd>
+ </dl>
+ <dl>
+ <dt>
+ <a href="/cn/Writing_localizable_code" title="cn/Writing_localizable_code">编写本地化代码</a></dt>
+ <dd>
+ <small>给予编程者玩好本地化的最好的文章和指南.</small></dd>
+ </dl>
+ <dl>
+ <dt>
+ <a href="/cn/Localizing_extension_descriptions" title="cn/Localizing_extension_descriptions">本地化扩展描述</a></dt>
+ <dd>
+ <small>要本地化一个扩展的描述(在【扩展】窗口中显示在扩展名称下面的字符串),你需要使用特殊的首选项键去忽略在你的 install.rdf 文件中指定的描述. 这篇文章包含如何修改这个首选项键的说明.</small></dd>
+ </dl>
+ <p><span class="alllinks"><a href="/Special:Tags?tag=Localization&amp;language=zh-cn" title="Special:Tags?tag=Localization&amp;language=zh-cn">查看全部...</a></span></p>
+ </td>
+ <td>
+ <h4 id=".E5.85.B6.E4.BB.96.E9.A1.B5.E9.9D.A2" name=".E5.85.B6.E4.BB.96.E9.A1.B5.E9.9D.A2">其他页面</h4>
+ <ul>
+ <li><a href="/Special:Tags?tag=Localization&amp;language=zh-cn" title="Special:Tags?tag=Localization&amp;language=zh-cn">文章</a></li>
+ <li><a href="/Special:Tags?tag=Localization:Tools&amp;language=zh-cn" title="Special:Tags?tag=Localization:Tools&amp;language=zh-cn">工具</a></li>
+ <li><a href="/cn/Localization/Community" title="cn/Localization/Community">社区</a></li>
+ </ul>
+ <h4 id=".E7.9B.B8.E5.85.B3.E6.96.87.E7.AB.A0" name=".E7.9B.B8.E5.85.B3.E6.96.87.E7.AB.A0">相关文章</h4>
+ <dl>
+ <dd>
+ <a href="/cn/Extensions" title="cn/Extensions">Extensions</a>, <a href="/cn/XUL" title="cn/XUL">XUL</a></dd>
+ </dl>
+ <p><span class="alllinks"><a class="external" href="/webwatch?cat=8" title="webwatch?cat=8">查看全部...</a></span></p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
diff --git a/files/zh-cn/mozilla/mercurial/basics/index.html b/files/zh-cn/mozilla/mercurial/basics/index.html
new file mode 100644
index 0000000000..26c4d7cb03
--- /dev/null
+++ b/files/zh-cn/mozilla/mercurial/basics/index.html
@@ -0,0 +1,56 @@
+---
+title: Mercurial basics
+slug: Mozilla/Mercurial/Basics
+translation_of: Mozilla/Mercurial/Basics
+---
+<p>我要跟你啰嗦一些关于Mercurial的东西,它可以帮助您少入坑。本页言辞较喷且是以生存型为导向(什么是生存型请自行渡娘)。但我依然坚信Mercurial要比CVS强。——Jorendorff于2008年5月12日16:06(PDT)</p>
+
+<h3 id="Expectations" name="Expectations">期望什么</h3>
+
+<p><strong>Mercurial is not CVS.</strong> The commands aren't the same. The concepts aren't the same. <a href="/en/Mozilla/Mercurial/How_Is_Mercurial_different_from_CVS" title="en/Mozilla/Mercurial/How_Is_Mercurial_different_from_CVS">How is Mercurial different from CVS?</a></p>
+
+<p><strong>This gun is loaded.</strong> You can shoot yourself in the foot. You can lose work. The tool tries to protect you, but it can happen anyway. The two common failure modes are: (a) you run a command without knowing what it's going to do; (b) you <code>hg commit</code> or <code>hg qrefresh</code> with a mistaken understanding of the state of your working directory. So you accidentally commit changes that you didn't want to commit; or you accidentally commit a broken merge; etc. Often it's not immediately obvious that anything is wrong.</p>
+
+<p>Forewarned is forearmed. Don't do these things. Don't run commands without knowing what they're going to do—<code>hg help</code> is your friend. Don't commit without diffing and thinking. And don't let yourself get into "play mode" and stop paying attention to the fact that what you're playing with is your own uncommitted work.</p>
+
+<p><strong>Mercurial is not magic dust.</strong> Mercurial is flexible, powerful, and fun. It lets you attempt stuff you never would have tried in CVS. But of course not everything turns out to have been a good idea. (For example, we tried sharing patch queues. It sort of sucked.)</p>
+
+<h3 id="Avoiding_trouble" name="Avoiding_trouble">避免入坑</h3>
+
+<p><strong>Use the latest stable release of Mercurial.</strong></p>
+
+<p><strong>Learn how to get your bearings.</strong> Use read-only commands (like <code>hg status</code>, <code>hg head</code>, <code>hg parents</code>, <code>hg log</code>, <code>hg diff</code>, <code>hg outgoing</code>) to check the status of your repository. This is a key skill.</p>
+
+<p><strong>Configure a <a class="external" href="https://www.mercurial-scm.org/wiki/MergeToolConfiguration">merge program</a> and make sure you know how to use it. DO IT NOW.</strong> Otherwise you will likely screw up your repository at some point.</p>
+
+<p>Mercurial doesn't leave conflict markers in your files; instead, it wants you to fix the conflicts <em>immediately</em>, using a merge program (like <code>kdiff3</code>) which it can launch for you.</p>
+
+<p>This can be error-prone. By default, Mercurial uses the first merge program it finds on your system, and merge programs can have a learning curve. Mercurial does not do a good job of detecting busted merges and refusing to proceed, so just by closing a window you can unwittingly put yourself in a bad state. Bad merges may lead to seemingly inexplicable Mercurial behavior in the future.</p>
+
+<p><strong>If a merge fails, make sure Mercurial knows that it has failed.</strong> When you're first learning the ropes, merges often go wrong. You might see this message:</p>
+
+<pre class="eval">0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+There are unresolved merges, you can redo the full merge using:
+ hg update -C 2
+ hg merge 1
+</pre>
+
+<p>This means some conflicts weren't resolved during the merge. If you don't know exactly what they are and how to fix them, use that <code>hg update -C</code> command to tell Mercurial that you've given up on that merge.</p>
+
+<p>If you don't, Mercurial won't know, and the next time you commit, it'll make a merge changeset. This is bad. The result can look a lot like accidentally destroying a bunch of work, actually, but the damage can be undone.</p>
+
+<p>If <code>hg parents</code> shows two parents, you're merging.</p>
+
+<p><strong>If you use <a href="/en/Mercurial_Queues" title="Mercurial_Queues">Mercurial Queues</a>, back up your work.</strong> <code>hg qrefresh</code> destructively replaces the old patch with the new one! Use <code>hg qinit -c</code> to create a separate backup repository for your patches and <code>hg commit --mq -m backup</code> regularly.</p>
+
+<p><strong>Don't use Mercurial Queues in a repository that someone might pull from since applied (non-public) patches would also be pulled.</strong></p>
+
+<h3 id="Recovering" name="Recovering">Recovering</h3>
+
+<p>握了个草! Mercurial 这么宝——Mercurial剁你手!</p>
+
+<p><strong>千万别轻易试玩(亵玩)</strong>Mercurial<strong>哦.</strong> 想想你的手,想想你的臂膀,别呀,你还可有个完整.</p>
+
+<p><strong>寻求帮助IRC频道.</strong> 在 Mozilla IRC 或 <a class="link-irc" href="irc://irc.freenode.net/mercurial">#mercurial on freenode</a> 中输入 <a class="link-irc" href="irc://irc.mozilla.org/hg">#hg</a> 或者 <a class="link-irc" href="irc://irc.mozilla.org/developers">#developers</a> .</p>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/mercurial/index.html b/files/zh-cn/mozilla/mercurial/index.html
new file mode 100644
index 0000000000..64029a1d1e
--- /dev/null
+++ b/files/zh-cn/mozilla/mercurial/index.html
@@ -0,0 +1,43 @@
+---
+title: Mercurial
+slug: Mozilla/Mercurial
+tags:
+ - Developing Mozilla
+ - Mercurial
+ - NeedsTranslation
+ - TopicStub
+translation_of: Mozilla/Mercurial
+---
+<p> </p>
+
+<div class="note">
+<p><a href="https://mozilla-version-control-tools.readthedocs.org/en/latest/hgmozilla/index.html">Please refer to Mercurial For Mozillians at ReadTheDocs</a> for current best-practices around Mercurial, including many helpful extra tools and guidelines that make using Mercurial fast and easy.</p>
+</div>
+
+<p><a class="external" href="https://www.mercurial-scm.org/"><strong>Mercurial</strong></a> (also known as "hg"), is the <a class="external" href="https://en.wikipedia.org/wiki/Distributed_revision_control">distributed version control</a> software used for the development of Firefox, Thunderbird, and the shared Gecko core. It replaced <a href="/en-US/docs/Developer_Guide/Source_Code/CVS" title="en-US/docs/Developer_Guide/Source_Code/CVS">CVS</a> after Mozilla 1.9 was branched.</p>
+
+<p><strong><code>hg</code></strong> is the Mercurial command-line tool, Hg being the chemical symbol for the element mercury.</p>
+
+<h2 id="Learning_to_use_Mercurial" name="Learning_to_use_Mercurial">Installation, configuration, and getting the source</h2>
+
+<p>See <a href="/en-US/docs/Installing_Mercurial" title="/en-US/docs/Installing_Mercurial">Installing Mercurial</a> for installation and configuration tips.</p>
+
+<p>See <a href="/en-US/docs/Developer_Guide/Source_Code/Mercurial" title="en-US/docs/Developer_Guide/Source_Code/Mercurial">Getting Mozilla Source Code Using Mercurial</a> for getting a tree to build.</p>
+
+<h2 id="Learning_to_use_Mercurial" name="Learning_to_use_Mercurial">Learning to use Mercurial</h2>
+
+<p>If you are new to Mercurial, you should start with the <a href="https://www.mercurial-scm.org/guide">official guide</a>.</p>
+
+<p>Then, move on to <a href="/en-US/docs/Mercurial_basics" title="en-US/docs/Mercurial_basics">Mercurial basics</a> and <a href="/en-US/docs/Mercurial_FAQ" title="en-US/docs/Mercurial_FAQ">Mercurial FAQ</a> and the <a href="https://mozilla-version-control-tools.readthedocs.org/en/latest/hgmozilla/">version control tool docs</a> for Mozilla-centric Mercurial information.</p>
+
+<h2 id="Further_reading" name="Further_reading">Further reading</h2>
+
+<p>The <a href="https://developer.mozilla.org/en-US/docs/tag/Mercurial" title="https://developer.mozilla.org/en-US/docs/tag/Mercurial">Mercurial tag</a> lists the Mercurial-related articles on MDN.</p>
+
+<p>And on wiki.mozilla.org, these helpful pages:</p>
+
+<ul>
+ <li>{{ interwiki('wikimo', 'Using_Mercurial_locally_with_CVS', 'Using Mercurial locally with CVS') }}, a how-to. (Note that this is only useful for code that's still exclusively in CVS.)</li>
+ <li>{{ interwiki('wikimo', 'Mercurial_on_Windows', 'Mercurial on Windows') }}</li>
+ <li><a href="/en-US/docs/Creating_Mercurial_User_Repositories" title="en-US/docs/Creating_Mercurial_User_Repositories">Creating Mercurial User Repositories</a> - If you have a LDAP account that allows you to push to hg.mozilla.org you can also create your own user repositories on the server to share work.</li>
+</ul>
diff --git a/files/zh-cn/mozilla/mercurial/installing_mercurial/index.html b/files/zh-cn/mozilla/mercurial/installing_mercurial/index.html
new file mode 100644
index 0000000000..1ea2cc22e3
--- /dev/null
+++ b/files/zh-cn/mozilla/mercurial/installing_mercurial/index.html
@@ -0,0 +1,145 @@
+---
+title: Installing Mercurial
+slug: Mozilla/Mercurial/Installing_Mercurial
+translation_of: Mozilla/Mercurial/Installing_Mercurial
+---
+<p>{{ Note('If you have not yet read the <a href="/en-US/docs/Mercurial_basics">Mercurial basics</a> do so now, or see <a href="/en-US/docs/Mercurial">Mercurial</a> for other resources.') }}</p>
+
+<div class="note">
+<p>Please refer to <a href="https://mozilla-version-control-tools.readthedocs.org/en/latest/hgmozilla/index.html"> Mercurial For Mozillians at ReadTheDocs</a> for current best-practices around Mercurial, including many helpful extra tools and guidelines that make using Mercurial fast and easy.</p>
+</div>
+
+<h2 id="Installing" name="Installing">安装</h2>
+
+<p>See <a href="http://mozilla-version-control-tools.readthedocs.org/en/latest/hgmozilla/installing.html">Installing Mercurial</a> from the Mozilla Version Control Guide.</p>
+
+<h2 id="基本设置">基本设置</h2>
+
+<p>You should configure Mercurial before submitting patches to Mozilla.</p>
+
+<p>If you will be pulling the Firefox source code or one of the derived repositories, the easiest way to configure Mercurial is to run the <em>mercurial-setup</em> mach command:</p>
+
+<pre>./mach mercurial-setup</pre>
+
+<p>This command starts an interactive wizard that will help ensure your Mercurial is configured with the latest recommended settings. This command will not change any files on your machine without your consent.</p>
+
+<p>If you don't have the Firefox source code available, you should edit your Mercurial configuration file to look like the following:</p>
+
+<pre class="eval">[ui]
+username = Your Real Name &lt;<a class="link-mailto" href="mailto:user@example.com" rel="freelink">user@example.com</a>&gt;
+merge = <em>your-merge-program</em> (or internal:merge)
+
+[diff]
+git = 1
+showfunc = 1
+unified = 8
+
+[defaults]
+commit = -v
+</pre>
+
+<p>On Windows, these settings can be added to <code>$HOME\.hgrc</code> or <code>$HOME\Mercurial.ini</code>, or, if you'd like global settings, <code>C:\mozilla-build\hg\Mercurial.ini</code> or <code>C:\Program Files\Mercurial\Mercurial.ini</code>. On UNIX-like systems, they should be in your <code>$HOME/.hgrc</code> file.</p>
+
+<p>You can configure the editor to use for commit messages using the <code>editor</code> option in the <code>[ui]</code> section or by setting the <code>EDITOR</code> environment variable.</p>
+
+<p>If you are trying to access the repository through a proxy server, see <a class="external" href="http://www.selenic.com/mercurial/hgrc.5.html#http-proxy" title="http://www.selenic.com/mercurial/hgrc.5.html#http-proxy">these instructions</a>.</p>
+
+<h2 id="其他设置">其他设置</h2>
+
+<h3 id="Merge_program" name="Merge_program">Merge 合并程序</h3>
+
+<p>After installing, <strong>choose a <a class="external" href="https://www.mercurial-scm.org/wiki/MergeToolConfiguration">merge program</a></strong>. Seriously. Do it now. If you don't, Mercurial will choose one for you and spring it on you when you least expect it.</p>
+
+<p>A reasonable thing to do is to set <code>ui.merge=internal:merge</code> in the Mercurial configuration file (see below), which makes Mercurial try to merge changes and add the conflict markers (a la CVS) to the files that couldn't be merged.</p>
+
+<p>Under Ubuntu, you can install meld package, then in in the Mercurial configuration file (see below) set <code>ui.merge=meld</code></p>
+
+<p>You can see the list of merge conflicts by looking for "merging ... failed!" in the update output.</p>
+
+<h4 id="配置_kdiff3_作为合并工具">配置 kdiff3 作为合并工具</h4>
+
+<p>If you're on Linux and you have kdiff3 installed, you probably want to configure kdiff3 as a merge tool.  (It's better than meld because it will actually resolve a bunch of the conflicts without prompting you, generally quite accurately.)  You can do this by adding the following lines (which come from <code>contrib/mergetools.hgrc</code> in the Mercurial distribution):</p>
+
+<pre>[merge-tools]
+kdiff3.args=--auto -L1 base --L2 local --L3 other $base $local $other -o $output
+kdiff3.regkey=Software\KDiff3
+kdiff3.regappend=\kdiff3.exe
+kdiff3.fixeol=True
+kdiff3.gui=True
+
+</pre>
+
+<h3 id="Extensions">Extensions</h3>
+
+<p>There's a number of extensions you can enable. See <a href="http://mercurial.selenic.com/wiki/UsingExtensions" title="http://mercurial.selenic.com/wiki/UsingExtensions">http://mercurial.selenic.com/wiki/UsingExtensions</a>. Almost everyone should probably enable the following:</p>
+
+<ul>
+ <li>color - Colorize terminal output</li>
+ <li>histedit - Provides <em>git rebase --interactive</em> behavior.</li>
+ <li>pager - Feed command output into a pager (like <em>less</em>)</li>
+ <li>progress - Draw progress bars on long-running operations.</li>
+ <li>rebase - Ability to easily rebase patches on top of other heads.</li>
+ <li>transplant - Easily move patches between repositories, branches, etc.</li>
+</ul>
+
+<p>These can all be turned on by just adding this to your .hgrc file:</p>
+
+<pre>[extensions]
+color =
+rebase =
+histedit =
+progress =
+transplant =
+pager =
+</pre>
+
+<p>In addition, there are some 3rd party extensions that are incredibly useful for basic development:</p>
+
+<dl>
+ <dt><a href="https://hg.mozilla.org/hgcustom/version-control-tools/file/default/hgext/mozext" title="https://hg.mozilla.org/users/gszorc_mozilla.com/hgext-gecko-dev">mozext</a></dt>
+ <dd>Mozilla-specific functionality to aid in developing Firefox/Gecko.</dd>
+ <dt><a href="https://github.com/pbiggar/trychooser">trychooser</a></dt>
+ <dd>Automatically creates a try commit message and then pushes changes to Mozilla's Try infrastructure. Just run:
+ <pre>hg trychooser</pre>
+ </dd>
+ <dt><a href="https://hg.mozilla.org/users/robarnold_cmu.edu/qimportbz">qimportbz</a></dt>
+ <dd>Import patches from Bugzilla. Creates a filename and commit message for you based on the bug's metadata.
+ <pre>hg qimport bz://1234567
+ </pre>
+ </dd>
+ <dt><a href="https://hg.mozilla.org/users/tmielczarek_mozilla.com/bzexport">bzexport</a></dt>
+ <dd>Export patches to Bugzilla. There are quite a few optional arguments here to create new or update existing bugs with the attment, as well as auto matically request reviews. Type hg help bzexport for a full list but the basic syntax is:
+ <pre>hg bzexport -i 1234567</pre>
+ </dd>
+</dl>
+
+<p>Installing these is fairly easy. You'll just need to find a place on your system to store the extensions, and clone the extension repos into it:</p>
+
+<pre>hg clone https://bitbucket.org/edgimar/crecord
+hg clone https://bitbucket.org/sfink/mqext
+hg clone https://hg.mozilla.org/users/robarnold_cmu.edu/qimportbz
+git clone https://github.com/pbiggar/trychooser
+</pre>
+
+<p>And then add then to your .hgrc file</p>
+
+<pre>[extensions]
+qcrecord = /path/to/crecord/crecord
+mqext = path/to/mqext
+qimportbz = path/to/qimportbz
+trychooser = path/to/trychooser/trychooser
+</pre>
+
+<h3 id="Configuring_the_try_repository">Configuring the try repository</h3>
+
+<p>If you have access to the <a class="link-https" href="https://wiki.mozilla.org/Build:TryServer" title="https://wiki.mozilla.org/Build:TryServer">try server</a> you may want to configure Mercurial so you can refer to it simply as "try", since it can be useful from all your trees.  This can be done by adding this to your ~/.hgrc (or Mercurial.ini):</p>
+
+<p> </p>
+
+<pre>[paths]
+try = ssh://hg.mozilla.org/try/
+</pre>
+
+<p>You can also configure short names like this that are specific to a particular repository by adding a [paths] section to the .hg/hgrc file within a repository.  There are two magic names, "default" and "default-push", which are used as the default push/pull targets.  (If "default" is specified and "default-push" is not, "default" is used for both.)</p>
+
+<p>Alternatively, you can install the <a class="link-https" href="https://bitbucket.org/sfink/trychooser" title="https://bitbucket.org/sfink/trychooser">trychooser extension</a> (<a class="link-https" href="https://github.com/pbiggar/trychooser" title="https://github.com/pbiggar/trychooser">older version</a>).</p>
diff --git a/files/zh-cn/mozilla/mfbt/index.html b/files/zh-cn/mozilla/mfbt/index.html
new file mode 100644
index 0000000000..a8b644e23f
--- /dev/null
+++ b/files/zh-cn/mozilla/mfbt/index.html
@@ -0,0 +1,48 @@
+---
+title: Mozilla Framework Based on Templates (MFBT)
+slug: Mozilla/MFBT
+translation_of: Mozilla/MFBT
+---
+<p><span class="seoSummary">The Mozilla Framework Based on Templates ("mfbt") is the central repository for macros, functions, and data structures used throughout Mozilla code, including in the JavaScript engine.</span> Its code resides in the <code>{{ Source("mfbt/") }}</code> source directory, but headers within it should be included using paths like <code>"mozilla/StandardInteger.h"</code>. It is fairly new, so its functionality is currently sparse. Feel free to <a class="link-https" href="https://bugzilla.mozilla.org/enter_bug.cgi?product=Core&amp;component=MFBT" title="https://bugzilla.mozilla.org/enter_bug.cgi?product=Core&amp;product=MFBT">file bugs</a> to add new functionality to it, or to move existing functionality into it, as needed. </p>
+
+<p>mfbt code goes to some length to document all its interfaces in comments, including examples when possible. It also attempts to define its functionality in well-named files, such that simply skimming the contents of <code>{{ Source("mfbt/") }}</code> will quickly suggest the relevant header to examine. Therefore this document primarily attempts to direct readers to the correct file to read those comments. Feel free to file a <a class="link-https" href="https://bugzilla.mozilla.org/enter_bug.cgi?bug_status=NEW&amp;cc=mfbt%40core.bugs&amp;comment=&amp;component=Documentation%20Requests&amp;product=Mozilla%20Developer%20Network&amp;qa_contact=doc-request%40mdn.bugs&amp;rep_platform=All&amp;op_sys=All" title="https://bugzilla.mozilla.org/enter_bug.cgi?bug_status=NEW&amp;cc=mfbt%40core.bugs&amp;comment=&amp;component=Documentation%20Requests&amp;product=Mozilla%20Developer%20Network&amp;qa_contact=doc-request%40mdn.bugs&amp;rep_platform=All&amp;op_sys=All">documentation bug</a> if you think this approach could be improved, and feel free to make improvements to this document if you see them.</p>
+
+<h2 id="Functionality">Functionality</h2>
+
+<h3 id="Types_and_type_manipulation">Types and type manipulation</h3>
+
+<p><code>{{ Source("mfbt/StandardInteger.h", "StandardInteger.h") }}</code> implements the <code>&lt;stdint.h&gt;</code> interface. (The <code>&lt;stdint.h&gt;</code> standard header is not available on all platforms and so cannot be used directly. This header also provides a useful "hook" for embeddings that must customize the types underlying the fixed-size integer types.)</p>
+
+<p><code>{{ Source("mfbt/Types.h", "Types.h") }}</code> includes <code>StandardInteger.h</code> and further provides <code>size_t</code>.</p>
+
+<p><code>{{ Source("mfbt/CheckedInt.h", "CheckedInt.h") }}</code> implements checked integers. They behave like integers, but safely check for integer overflow and divide-by-zero. Useful for input validation.</p>
+
+<p><code>{{ Source("mfbt/FloatingPoint.h", "FloatingPoint.h") }}</code> provides various operations for examining and working upon double-precision floating point values, and for producing various special floating point values.</p>
+
+<h3 id="Core">Core</h3>
+
+<p><code>{{ Source("mfbt/Types.h", "Types.h") }}</code> further provides macros to define imported and exported C symbols.</p>
+
+<p><code>{{ Source("mfbt/Attributes.h", "Attributes.h") }}</code> implements various function and class attribute macros. The function macros control inlining, note whether a function returns, and enforce various C++-related restrictions on inheritance and use. The class macros permit controlling the inheritability of a class.</p>
+
+<p><code>{{ Source("mfbt/Likely.h", "Likely.h") }}</code> provides <code>MOZ_LIKELY</code> and <code>MOZ_UNLIKELY</code> macros to annotate conditions with their expected truthiness.</p>
+
+<p><code>{{ Source("mfbt/Util.h", "Util.h") }}</code> implements various other bits of useful functionality. (This header will likely be further split up so that its functionality is less grab-bag.)</p>
+
+<h3 id="Debugging">Debugging</h3>
+
+<p><code>{{ Source("mfbt/Assertions.h", "Assertions.h") }} </code>provides assertion macros in implementing runtime assertions and compile-time assertions.</p>
+
+<p><code>{{ Source("mfbt/GuardObjects.h", "GuardObjects.h") }}</code> provides macros which can be used to annotate an <a class="external" href="http://en.wikipedia.org/wiki/RAII" title="http://en.wikipedia.org/wiki/RAII">RAII</a>-style guard class, so that any attempt to create an unnamed temporary for it will assert. (An unnamed temporary lives for a shorter period of time than the scope where it's found, so it usually isn't what was desired.)</p>
+
+<h3 id="Data_structures">Data structures</h3>
+
+<p><code>{{ Source("mfbt/LinkedList.h", "LinkedList.h") }}</code> implements a type-safe doubly-linked list class. Most new code should use this rather than <code>{{ Source("nsprpub/pr/include/prclist.h", "PRCList") }}</code>.</p>
+
+<p><code>{{ Source("mfbt/RangedPtr.h", "RangedPtr.h") }} </code>implements <code>RangedPtr</code>, a smart pointer template whose value may be manipulated only within a range specified at construction time, and which may be dereferenced only at valid locations in that range.  This pointer is a useful way to expose access to values within an array.</p>
+
+<p><code>{{ Source("mfbt/RefPtr.h", "RefPtr.h") }} </code>implements various smart pointer templates to simplify reference counting of values of particular classes.</p>
+
+<p><code>{{ Source("mfbt/Scoped.h", "Scoped.h") }}</code> implements scope-based resource management, to simplify the task of cleaning up resources when leaving a scope.</p>
+
+<p><code>{{ Source("mfbt/ThreadLocal.h", "ThreadLocal.h") }}</code> implements thread-local storage, aka "TLS", also called thread-specific storage. It should be used only for static-storage-duration variables, such as global variables or static class members.</p>
diff --git a/files/zh-cn/mozilla/mozilla_on_github/index.html b/files/zh-cn/mozilla/mozilla_on_github/index.html
new file mode 100644
index 0000000000..a215aef188
--- /dev/null
+++ b/files/zh-cn/mozilla/mozilla_on_github/index.html
@@ -0,0 +1,121 @@
+---
+title: GitHub上的Mozilla项目
+slug: Mozilla/Mozilla_on_GitHub
+translation_of: Mozilla/Mozilla_on_GitHub
+---
+<p><span class="seoSummary">Although Mozilla's major, core projects are located on the Mozilla <a href="/en-US/docs/Mercurial">Mercurial</a> server, such as <a href="/en-US/docs/mozilla-central">mozilla-central</a>, there are a number of tools, services, and so forth whose code is hosted on <a href="https://github.com/">GitHub</a>. This article offers a quick guide to getting started with Mozilla code on GitHub as well as a list of many of the most interesting GitHub repositories containing Mozilla project code.</span></p>
+
+<h2 id="起步">起步</h2>
+
+<p>You can look at code on GitHub without an account; that's the first thing you should know. To do more—that is, to contribute to the code or to fork it and start your own project based on Mozilla-related code—you'll need a GitHub account. You can learn more about <a href="https://help.github.com/articles/set-up-git">setting up an account</a> on the GitHub site.</p>
+
+<p>Most Mozilla project code is located in repositories owned by <a href="https://github.com/mozilla/">the user Mozilla</a>. That's a great place to start looking for any projects not listed below.</p>
+
+<h2 id="项目">项目</h2>
+
+<p>This list covers the larger-scale and more important projects we have hosted on GitHub. It's not an authoritative, complete list, since it's hard to keep track of all the smaller projects that crop up (and even, at times, the large ones!). You can see a <a href="https://github.com/mozilla">complete list of Mozilla projects on GitHub</a>.</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Project name</th>
+ <th scope="col">Description</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a href="https://github.com/mozilla/pdf.js">PDF.js</a></td>
+ <td>A Portable Document Format (PDF) reader written entirely in <a href="/en-US/docs/Web/JavaScript">JavaScript</a>.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/mozilla/shumway">Shumway</a></td>
+ <td><a href="/en-US/docs/Mozilla/Projects/Shumway">Shumway</a> is a Flash VM and runtime written in JavaScript.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/mozilla/addon-sdk">addon-sdk</a></td>
+ <td>The Mozilla Add-on SDK.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/jdm/asknot">asknot</a></td>
+ <td>The <a href="http://whatcanidoformozilla.org/">What Can I Do For Mozilla</a> web site, which helps you figure out how you can contribute to Mozilla.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/jdm/bugsahoy">bugsahoy</a></td>
+ <td>A <a href="http://www.joshmatthews.net/bugsahoy/">Web page to help</a> new Mozilla contributors find bugs to work on.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/Yoric/bugzilla-dashboard">bugzilla-dashboard</a></td>
+ <td>A convenient dashboard to help you get an overview of your bugs.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/bbondy/codefirefox">codefirefox</a></td>
+ <td>The <a href="http://codefirefox.com/">CodeFirefox</a> site, with videos and tutorials about how to contribute to the Firefox project and Mozilla code in general.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/mozilla/dxr">dxr</a></td>
+ <td>An intelligent tool for browsing source code.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/kripken/emscripten">emscripten</a></td>
+ <td>The <a href="/en-US/docs/Mozilla/Projects/Emscripten">Emscripten</a> LLVM-to-JavaScript compiler.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/campd/fxdt-adapters">fxdt-adapters</a></td>
+ <td>The Firefox Developer Tools Adapter lets you debug various remote targets from the Firefox Developer Tools.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/mozilla/gecko-dev">gecko-dev</a></td>
+ <td>A read-only mirror of the <a href="/en-US/docs/Mozilla/Mercurial">Mercurial</a> repositories used for Mozilla private code.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/mozilla/kitsune">kitsune</a></td>
+ <td><a href="http://kitsune.readthedocs.org/">Kitsune</a> is the platform that drives the <a href="https://support.mozilla.org/">Mozilla support web site</a>, SUMO.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/mozilla/kuma">kuma</a></td>
+ <td>The <a href="https://www.djangoproject.com/">Django</a> project that powers this site (MDN).</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/mdn">mdn</a></td>
+ <td>Code samples for the <a href="https://developer.mozilla.org/">MDN Web site</a>.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/mozbrick">mozbrick</a></td>
+ <td>The Mozilla <a href="/en-US/Apps/app_layout/Mozilla_Brick_ready_made_UI_components">Brick</a> project.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/mozilla-b2g">mozilla-B2G</a></td>
+ <td>The <a href="/en-US/Firefox_OS">Firefox OS</a> project.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/mozilla-appmaker">mozilla-appmaker</a></td>
+ <td>The Appmaker project -- a Web tool to let non-programmers create apps.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/mozilla-l10n/">mozilla-l10n</a></td>
+ <td>Scripts and tools used by the <a href="/en-US/docs/Mozilla/Localization">localization</a> drivers.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/mozilla-metrics">mozilla-metrics</a></td>
+ <td>Tools used to collect metrics about Mozilla code.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/mozilla-services">mozilla-services</a></td>
+ <td>Mozilla <a href="http://blog.mozilla.com/services">cloud services</a> projects.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/opennews">opennews</a></td>
+ <td>The Knight-Mozilla Open News project, helping the journalism/technology community do great work through shared knowledge and code.</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/rust-lang">rust-lang</a></td>
+ <td>Rust编程语言, 为安全地进行高并发编码而设计!</td>
+ </tr>
+ <tr>
+ <td><a href="https://github.com/servo">servo</a></td>
+ <td>The next-generation rendering engine.</td>
+ </tr>
+ </tbody>
+</table>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/mozilla_persona/index.html b/files/zh-cn/mozilla/mozilla_persona/index.html
new file mode 100644
index 0000000000..583cb6cb5a
--- /dev/null
+++ b/files/zh-cn/mozilla/mozilla_persona/index.html
@@ -0,0 +1,155 @@
+---
+title: Mozilla Persona
+slug: Mozilla/Mozilla_Persona
+tags:
+ - Mozilla
+ - Persona
+---
+<div class="callout-box">
+ <p><strong>保持联系或获取帮助!</strong></p>
+ <p>关注 <a class="external" href="http://identity.mozilla.com/" title="http://identity.mozilla.com/">我们的 blog</a>,加入 <a class="link-https" href="https://lists.mozilla.org/listinfo/dev-identity" title="https://lists.mozilla.org/listinfo/dev-identity">我们的邮件列表</a>,或在 <a class="link-https" href="https://wiki.mozilla.org/IRC" title="https://wiki.mozilla.org/IRC">IRC</a> 中的 <a class="link-irc" href="irc://irc.mozilla.org/identity" title="irc://irc.mozilla.org/identity">#identity</a> 找到我们。</p>
+</div>
+<p><a class="link-https" href="https://www.mozilla.org/zh-CN/persona/" title="https://www.mozilla.org/zh-CN/persona/">Mozilla Persona</a> 是一个用于 web 的完全去中心化且安全的验证系统,基于开放 BrowserID 协议。Mozilla 当前管理一个 Persona 相关的一个<a href="/zh-CN/docs/Persona/Bootstrapping_Persona" title="/zh-CN/docs/Persona/Bootstrapping_Persona">可选的、中心化服务</a>的一小组套件。</p>
+<p>为什么你和你的站点应该使用 Persona?</p>
+<ol>
+ <li><strong>Persona 完全消除了站点特定的密码,</strong> 把用户和网站从创建、管理和安全存放密码的责任中解放出来。</li>
+ <li><strong>Persona 易于使用。</strong>只需点击两次,一个 Persona 用户可以登入到一个诸如 <a href="http://voo.st" title="http://voo.st">Voost</a> 或 <a href="http://crossword.thetimes.co.uk/" title="http://crossword.thetimes.co.uk/">The Times Crossword</a> 的新站点,绕开了账户创建相关的摩擦。</li>
+ <li><strong>Persona 易于实现。</strong>开发人员在一个下午就可以把 Persona 添加到站点上。</li>
+ <li>最好的是,<strong>不会被锁定</strong>。 开发人员获取所有他们用户的验证过的邮件地址,而用户可以在 Persona 上使用任何邮件地址。</li>
+ <li><strong>Persona 基于 BrowserID 协议构建。</strong>一旦流行的浏览器供应商实现了 BrowserID<strong>,它们不再需要依赖于 Mozilla 来登入。</strong></li>
+</ol>
+<p>继续阅读来开始!</p>
+<div class="note">
+ <strong>注意:</strong>Persona 在活跃开发中。关注<a class="external" href="http://identity.mozilla.com/" title="http://identity.mozilla.com/">我们的 blog</a> 来了解新特性,或加入<a class="link-https" href="https://lists.mozilla.org/listinfo/dev-identity" title="https://lists.mozilla.org/listinfo/dev-identity">我们的邮件列表</a>来提供反馈!</div>
+<h2 id="在你的站点上使用_Persona">在你的站点上使用 Persona</h2>
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h3 id="准备开始">准备开始</h3>
+ <dl>
+ <dt>
+ <a href="/zh-CN/docs/Persona/Why_Persona" title="zh-CN/BrowserID/Why_BrowserID">为什么使用 Persona?</a></dt>
+ <dd>
+ 了解在你的站点上支持 Persona 的原因和它与其它身份验证系统的区别。</dd>
+ <dt>
+ <a href="/zh-CN/Persona/Quick_Setup" title="BrowserID/Quick setup">快速安装</a></dt>
+ <dd>
+ 一份快捷的攻略,展示了如何向你的网站中添加 Persona。</dd>
+ </dl>
+ </td>
+ <td>
+ <h3 id="Persona_API_参考">Persona API 参考</h3>
+ <dl>
+ <dt>
+ <a href="/zh-CN/DOM/navigator.id" title="navigator.id">navigator.id API 参考</a></dt>
+ <dd>
+ <code>navigator.id</code> 对象的参考,web 开发者可以用此来把 Persona 继承到站点中。</dd>
+ <dt>
+ <a href="/zh-CN/Persona/Remote_Verification_API" title="zh-CN/BrowserID/Remote_Verification_API">验证 API 参考</a></dt>
+ <dd>
+ 建立在 <code>https://verifier.login.persona.org/verify</code> 上的远程验证 API 的参考。</dd>
+ </dl>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <h3 id="指导">指导</h3>
+ <dl>
+ <dt>
+ <a href="/zh-CN/Persona/Security_Considerations" title="BrowserID/Security considerations">安全考虑</a></dt>
+ <dd>
+ 确保 Persona 部署安全的实践和技术。</dd>
+ <dt>
+ <a href="/zh-CN/Persona/Browser_compatibility" title="/Browser_compatibility">浏览器兼容性</a></dt>
+ <dd>
+ 准确获知哪些浏览器支持 Persona。</dd>
+ <dt>
+ <a href="/zh-CN/Persona/Internationalization" title="/Internationalization">国际化</a></dt>
+ <dd>
+ 了解 Persona 如何处理不同的语言。</dd>
+ </dl>
+ </td>
+ <td>
+ <h3 id="资源">资源</h3>
+ <dl>
+ <dt>
+ <a class="link-https" href="https://github.com/mozilla/browserid/wiki/Persona-Libraries" title="https://github.com/mozilla/browserid/wiki/BrowserID-Libraries">库和插件</a></dt>
+ <dd>
+ 寻找你偏好的编程语言、web 框架、博客或是内容管理系统(CMS)的即插库。</dd>
+ <dt>
+ <a class="link-https" href="https://github.com/mozilla/browserid-cookbook" title="https://github.com/mozilla/browserid-cookbook">Persona cookbook</a></dt>
+ <dd>
+ Persona 站点的示例源代码。包括 PHP、Node.JS 等等的片段。</dd>
+ <dt>
+ <a href="/zh-CN/docs/persona/branding" title="/zh-CN/docs/persona/branding">品牌资源</a></dt>
+ <dd>
+ 登入按钮和其它向用户表现 Persona 的图形。</dd>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h2 id="给身份提供者的信息">给身份提供者的信息</h2>
+ <p>如果你是一个电子邮件提供商或另一个身份提供服务,翻阅下面的链接来获知如何成为一个 Persona 身份提供者。</p>
+ <dl>
+ <dt>
+ <a href="/zh-CN/docs/Persona/Identity_Provider_Overview" title="IdP">IdP 概述</a></dt>
+ <dd>
+ Persona 身份提供者的高层视角。</dd>
+ <dt>
+ <a href="/zh-CN/Persona/Implementing_a_Persona_IdP" title="Guide to Implementing a Persona IdP">实现一个 IdP</a></dt>
+ <dd>
+ 成为一个 IdP 的详细技术细节指导。</dd>
+ <dt>
+ <a href="/zh-CN/Persona/IdP_Development_tips" title="Developer tips">开发提示</a></dt>
+ <dd>
+ 开发一个新的身份提供者的一系列开发提示和技巧。</dd>
+ <dt>
+ <a href="/zh-CN/docs/Persona/.well-known-browserid" title="https://developer.mozilla.org/zh-CN/docs/Persona/.well-known-browserid">.well-known/browserid</a></dt>
+ <dd>
+ <code>.well-known/browserid</code> 文件的结构和用途概述,这个文件被 IdPs 用于通知它们支持这个协议。</dd>
+ </dl>
+ </td>
+ <td>
+ <h2 id="Persona_项目">Persona 项目</h2>
+ <dl>
+ <dt>
+ <a href="/zh-CN/Persona/Glossary" title="navigator.id">术语表</a></dt>
+ <dd>
+ BrowserID 和 Persona 定义的术语。</dd>
+ <dt>
+ <a href="/zh-CN/Persona/FAQ" title="zh-CN/BrowserID/FAQ">FAQ</a></dt>
+ <dd>
+ 常见问题的回答。</dd>
+ <dt>
+ <a href="/zh-CN/Persona/Protocol_Overview" title="BrowserID/Protocol overview">协议概述</a></dt>
+ <dd>
+ 底层 BrowserID 协议的中等技术概述。</dd>
+ <dt>
+ <a href="/zh-CN/persona/Crypto" title="MDN">加密</a></dt>
+ <dd>
+ 一瞥 Persona 和 BrowserID 背后的密码学概念。</dd>
+ <dt>
+ <a class="link-https" href="https://github.com/mozilla/id-specs/blob/master/browserid/index.md" title="https://github.com/mozilla/id-specs/blob/master/browserid/index.md">协议规范</a></dt>
+ <dd>
+ 这里是深层技术细节。</dd>
+ <dt>
+ <a href="/Persona/Bootstrapping_Persona" title="zh-CN/BrowserID/Bootstrapping_BrowserID">Persona 网站</a></dt>
+ <dd>
+ 要让 Persona 运作, 我们在<a class="link-https" href="https://login.persona.org" rel="freelink">https://login.persona.org</a> 建立了三个服务:一个备用身份提供者、一个可迁移的 {{ domxref("navigator.id") }} API 实现以及一个身份断言验证服务。</dd>
+ <dt>
+ <a href="https://github.com/mozilla/browserid">Persona 源码</a></dt>
+ <dd>
+ Persona 网站背后的源码托管在 GitHub 的一个仓库上。欢迎提交补丁!</dd>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
diff --git a/files/zh-cn/mozilla/participating_in_the_mozilla_project/index.html b/files/zh-cn/mozilla/participating_in_the_mozilla_project/index.html
new file mode 100644
index 0000000000..1de9ed81ad
--- /dev/null
+++ b/files/zh-cn/mozilla/participating_in_the_mozilla_project/index.html
@@ -0,0 +1,94 @@
+---
+title: 加入Mozilla项目
+slug: Mozilla/Participating_in_the_Mozilla_project
+translation_of: Mozilla/Participating_in_the_Mozilla_project
+---
+<p>如果你有兴趣帮助解决bug或者参与Mozilla平台的代码工作,这里是找到为你指出正确方向的文档的地方。</p>
+<table class="mainpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h2 id="通用话题">通用话题</h2>
+ <dl>
+ <dt>
+ <a class="internal" href="/cn/Developer_Guide" title="Mozilla开发者手册">Mozilla开发者手册</a></dt>
+ <dd>
+ 为Mozilla代码库做贡献的开发向导和提示。</dd>
+ <dt>
+ <a class="internal" href="/Cn/Developer_Guide/Source_Code" title="Cn/Developer Guide/Source Code">Mozilla源代码</a></dt>
+ <dd>
+ 通过下载或者版本控制来获取Mozilla代码的方法,以及怎样将你的代码加入到代码树中。</dd>
+ <dt>
+ <a class="internal" href="/En/Developer_Guide/Build_Instructions" title="En/Build Documentation">编译</a></dt>
+ <dd>
+ 编译Mozilla项目(包括Firefox和Thunderbird)。</dd>
+ <dt>
+ <a class="internal" href="/En/The_Mozilla_platform" title="En/The Mozilla platform">Mozilla平台</a></dt>
+ <dd>
+ 关于Mozilla平台的信息,包括所有的API接口和所包含的技术,以及如何在你的自己的项目中使用它们。</dd>
+ <dt>
+ <a class="internal" href="/Project:en/How_to_Help" title="Project:en/How to Help">Mozilla文档</a></dt>
+ <dd>
+ 帮助我们创建和改进Mozilla及开放互联网的文档。</dd>
+ <dt>
+ <a class="internal" href="/cn/调试" title="en/Debugging">调试</a></dt>
+ <dd>
+ 调试Mozilla代码时有用的提示和参考。</dd>
+ <dt>
+ <a class="internal" href="/en/QA" title="en/QA">质量保证</a></dt>
+ <dd>
+ 关于测试及bug跟踪的相关信息。</dd>
+ <dt>
+ <a class="internal" href="/en/Localization" title="En/Localization">本地化</a></dt>
+ <dd>
+ 关于翻译Mozilla项目及其文档等到各种语言。</dd>
+ </dl>
+ <h2 id="项目主页">项目主页</h2>
+ <dl>
+ <dt>
+ <a class="internal" href="/en/Thunderbird" title="en/Thunderbird">Thunderbird</a></dt>
+ <dd>
+ Mozilla的邮件客户端。</dd>
+ <dt>
+ <a class="internal" href="/en/Calendar" title="en/Calendar">Sunbird</a></dt>
+ <dd>
+ Mozilla的日历项目。</dd>
+ </dl>
+ </td>
+ <td>
+ <h2 id="工具">工具</h2>
+ <dl>
+ <dt>
+ <a class="link-https" href="https://bugzilla.mozilla.org/" title="https://bugzilla.mozilla.org/">Bugzilla</a></dt>
+ <dd>
+ <a class="internal" href="/en/Bugzilla" title="En/Bugzilla">Bugzilla</a>数据库用来跟踪Mozilla项目的相关事件。</dd>
+ <dt>
+ <a class="external" href="http://mxr.mozilla.org/" title="http://mxr.mozilla.org/">MXR</a></dt>
+ <dd>
+ 基于Web浏览及搜索Mozilla源代码库。</dd>
+ <dt>
+ <a class="external" href="http://bonsai.mozilla.org/cvsqueryform.cgi" title="http://bonsai.mozilla.org/cvsqueryform.cgi">Bonsai</a></dt>
+ <dd>
+ <a class="internal" href="/en/Bonsai" title="En/Bonsai">Bonsai</a>工具帮助你找到谁在何时对代码库进行了什么修改。</dd>
+ <dt>
+ <a class="external" href="http://tinderbox.mozilla.org/showbuilds.cgi" title="http://tinderbox.mozilla.org/showbuilds.cgi">Tinderbox</a></dt>
+ <dd>
+ <a class="internal" href="/en/Tinderbox" title="En/Tinderbox">Tinderbox</a>显示树的状态(无论当前是否编译成功)。 在check-in和check-out之前都要进行检查以确认你正工作在一个working tree上。</dd>
+ <dt>
+ <a class="internal" href="/en/Crash_reporting" title="en/Crash reporting">崩溃跟踪</a></dt>
+ <dd>
+ <a class="link-https" href="https://crash-reports.mozilla.com/reports" title="https://crash-reports.mozilla.com/reports">Socorro</a>与<a class="external" href="http://talkback-public.mozilla.org/search/start.jsp" title="http://talkback-public.mozilla.org/search/start.jsp">Talkback</a>提供崩溃跟踪服务。</dd>
+ <dt>
+ <a class="external" href="http://graphs.mozilla.org/" title="http://graphs.mozilla.org/">性能跟踪</a></dt>
+ <dd>
+ Mozilla项目的性能跟踪。</dd>
+ <dt>
+ <a class="external" href="http://www.mozilla.org/community/developer-forums.html" title="http://www.mozilla.org/community/developer-forums.html">开发者论坛</a></dt>
+ <dd>
+ 一个有针对性主题的论坛。在这里你可以讨论开发的各种事件。</dd>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>  {{ languages( { "en": "en/Participating_in_the_Mozilla_project", "ja": "ja/Participating_in_the_Mozilla_project"} ) }}</p>
diff --git a/files/zh-cn/mozilla/performance/about_colon_memory/index.html b/files/zh-cn/mozilla/performance/about_colon_memory/index.html
new file mode 100644
index 0000000000..6710a2441b
--- /dev/null
+++ b/files/zh-cn/mozilla/performance/about_colon_memory/index.html
@@ -0,0 +1,144 @@
+---
+title: 'about:memory'
+slug: 'Mozilla/Performance/about:memory'
+translation_of: 'Mozilla/Performance/about:memory'
+---
+<p>about:memory 是一个 Firefox 内置的特殊页面,你可以在此查看、保存、载入和比较 Firefox 内存使用的详细测量数据。你还可以执行其他与内存有关的操作,例如执行 GC 和 CC、转储 GC 和 CC 日志记录,以及转储 DMD 报告。这个页面在所有版本当中都可以找到,并且无需任何准备工作就可以使用。</p>
+<h2 id="如何生成内存报告">如何生成内存报告</h2>
+<p>假设你要测量 Firefox 的内存使用情况(也许你是想自己研究,或者是他人要你用 about:memory 生成“内存报告”以便帮你分析问题),你都可以按照下列步骤进行操作。</p>
+<ul>
+ <li>在你需要的时候(例如 Firefox 内存占用量偏高时)新建一个标签页,在地址栏输入 "about:memory" 并按回车键。</li>
+ <li>如果你使用的是一个可以发送文件的通信方式,比如 Bugzilla 或电子邮件,请点击 "Measure and save..." 按钮,这会打开一个对话框让你将内存报告保存为本地文件,文件后缀名为 .json.gz。然后你就可以上传或发送它为附件,对方获取后可以在自己的 Firefox 中打开 about:memory 页面来查看该文件。</li>
+ <li>如果你使用的是只能发送文本的通信方式,比如一个网站的评论区,请点击 "Measure..." 按钮,这会生成并显示一系列类似树形结构的文字。你可以复制该结构中的任何文字并粘贴到任意文本框当中,这样就无需采取截图方式。相比内存报告文件,文本形式包含的数据虽然较少,但通常也足够用来诊断问题。</li>
+</ul>
+<p>请注意,上述方式生成的数据会包含一些与隐私有关的内容,例如你此时所打开网页的完整清单。如果你不想分享这些信息,可以在点击 "Measure and save..." 或 "Measure..." 按钮之前先勾上 “anonymize” 复选框。这样就会去除所有隐私相关的数据,虽然这有可能不太便于他人帮你分析内存占用情况。</p>
+<h2 id="从文件载入内存报告">从文件载入内存报告</h2>
+<p>从文件载入内存报告最简单的方式是点击 "Load..." 按钮,你也可以点击 "Load and diff..." 按钮来找出两个内存报告文件间的不同之处。</p>
+<p>单个内存报告文件也可以直接被自动载入,只需在 about:memory 后面加上一个文件查询字符串,例如:</p>
+<pre>about:memory?file=/home/username/reports.json.gz
+</pre>
+<p>这种方式在载入 Firefox OS 设备上已转储的内存报告文件时尤为实用。</p>
+<p>内存报告所保存的文件使用的是用 gzip 压缩的 JSON 格式。这些文件既可以直接载入,也可以解压后再载入。</p>
+<h2 id="分析内存报告">分析内存报告</h2>
+<p>你在 about:memory 页面中看到的几乎所有事物都有着相应的工具提示来解释。将鼠标悬停在任意按钮上就可以看到关于其作用的描述。将鼠标悬停在任意测量数据上就可以查看对它所指内容的描述。</p>
+<h3 id="测量数据基础介绍"><span class="mw-headline" id="Basics">测量数据基础介绍</span></h3>
+<p>大多数测量数据的单位都是字节,少部分使用的是计数值或百分比。</p>
+<p>测量数据大多以树形结构呈现,例如:</p>
+<pre> 585 (100.0%) -- preference-service
+ └──585 (100.0%) -- referent
+ ├──493 (84.27%) ── strong
+ └───92 (15.73%) -- weak
+ ├──92 (15.73%) ── alive
+ └───0 (00.00%) ── dead
+</pre>
+<p>叶节点代表实际的测量数据值,每个内部节点的值都是它子节点值的总和。</p>
+<p>使用树形结构是为了让测量数据可以根据需要进一步分成类、子类、子类的子类……,直至任意深度。单个树形下的所有测量数据都不会有任何重叠。</p>
+<p>树的路径可以使用 '/' 来分隔,例如,<code>preference/referent/weak/dead</code> 表示上述例子中直到最终叶节点的整个路径。</p>
+<p>单击每个子树都可以收起或展开它们。如果你发现某些树所占空间特别大,可以试试先收起所有隶属于它的子树,然后根据需要逐步展开。</p>
+<h3 id="区段"><span class="mw-headline" id="Sections">区段</span></h3>
+<p>内存报告是在每个进程的基础上显示,每个区段为一个进程。每个进程中的测量数据都包含以下一些子区段。</p>
+<h4 id="Explicit_Allocations">Explicit Allocations</h4>
+<p>这个区段包含单个叫做 "explicit" 的树,它测量的是通过显式调用堆积分配(heap allocations)函数和非堆积分配函数方式分配的所有内存,堆积分配函数像是 malloc 和 new,而非堆积分配函数可以是 mmap 和 VirtualAlloc。</p>
+<p>下面的例子是一个打开了 cnn.com、techcrunch.com 和 arstechnica.com 这几个标签页的浏览器会话。为了更好地呈现,我们将部分子树展开,其他部分全部收起。</p>
+<pre>191.89 MB (100.0%) -- explicit
+├───63.15 MB (32.91%) -- window-objects
+│ ├──24.57 MB (12.80%) -- top(http://edition.cnn.com/, id=8)
+│ │ ├──20.18 MB (10.52%) -- active
+│ │ │ ├──10.57 MB (05.51%) -- window(http://edition.cnn.com/)
+│ │ │ │ ├───4.55 MB (02.37%) ++ js-compartment(http://edition.cnn.com/)
+│ │ │ │ ├───2.60 MB (01.36%) ++ layout
+│ │ │ │ ├───1.94 MB (01.01%) ── style-sheets
+│ │ │ │ └───1.48 MB (00.77%) -- (2 tiny)
+│ │ │ │ ├──1.43 MB (00.75%) ++ dom
+│ │ │ │ └──0.05 MB (00.02%) ── property-tables
+│ │ │ └───9.61 MB (05.01%) ++ (18 tiny)
+│ │ └───4.39 MB (02.29%) -- js-zone(0x7f69425b5800)
+│ ├──15.75 MB (08.21%) ++ top(http://techcrunch.com/, id=20)
+│ ├──12.85 MB (06.69%) ++ top(http://arstechnica.com/, id=14)
+│ ├───6.40 MB (03.33%) ++ top(chrome://browser/content/browser.xul, id=3)
+│ └───3.59 MB (01.87%) ++ (4 tiny)
+├───45.74 MB (23.84%) ++ js-non-window
+├───33.73 MB (17.58%) ── heap-unclassified
+├───22.51 MB (11.73%) ++ heap-overhead
+├────6.62 MB (03.45%) ++ images
+├────5.82 MB (03.03%) ++ workers/workers(chrome)
+├────5.36 MB (02.80%) ++ (16 tiny)
+├────4.07 MB (02.12%) ++ storage
+├────2.74 MB (01.43%) ++ startup-cache
+└────2.16 MB (01.12%) ++ xpconnect</pre>
+<p>要弄懂这里的所有细节需要一些专业知识才行,不过还是有几点内容需要指出。</p>
+<ul>
+ <li>树形结构根节点处的 "explicit" 值表示所有通过显式调用分配函数所分配的内存。</li>
+ <li>"window-objects" 这个子树表示所有 JavaScript 窗口对象,包括浏览器标签页的窗口和用户界面窗口。举例来说,"top(http://edition.cnn.com/, id=8)" 这个子树表示打开了 cnn.com 的标签页,而 "top(chrome://browser/content/browser.xul, id=3)" 表示浏览器主界面窗口。</li>
+ <li>每个 window 的测量数据都包含 JavaScript ("js-compartment(...)" 和 "js-zone(...)")、layout、style-sheets、DOM 以及其他东西的子树。</li>
+ <li>显然 cnn.com 标签页所占用的内存比 techcrunch.com 标签页的多,后者又比 arstechnica.com 标签页的多。</li>
+ <li>带有 "(2 tiny)" 这样名字的子树是人为插入的节点,是为了默认收起一些不重要子树。如果你在测量前勾上 "verbose" 复选框,则会完整展开显示所有树层,并且不会插入任何人为节点。</li>
+ <li>"js-non-window" 这个子树表示来自浏览器内核而非窗口的 JavaScript 内存占用。</li>
+ <li>"heap-unclassified" 这个值表示不被任何内存报告工具所测量的堆积分配内存,通常占到 "explicit" 的 10% 到 20%。一旦超出这个比例就意味着需要增加额外的内存报告工具。<a href="/en-US/docs/Mozilla/Performance/DMD" title="Performance/MemShrink/DMD">DMD</a> 可以用来测定这些应该被增补的内存报告。</li>
+ <li>还有一些测量数据是用于其他一些内容,比如图片和 worker,以及 Startup cache 和 XPConnec 这样的浏览器子系统。</li>
+</ul>
+<p>部分附加组件的内存占用也会被识别出来,如下例所示。</p>
+<pre>├───40,214,384 B (04.17%) -- add-ons
+│ ├──21,184,320 B (02.20%) ++ {d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}/js-non-window/zones/zone(0x100496800)/compartment([System Principal], jar:file:///Users/njn/Library/Application%20Support/Firefox/Profiles/puna0zr8.new/extensions/%7Bd10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d%7D.xpi!/bootstrap.js (from: resource://gre/modules/addons/XPIProvider.jsm:4307))
+│ ├──11,583,312 B (01.20%) ++ jid1-xUfzOsOFlzSOXg@jetpack/js-non-window/zones/zone(0x100496800)
+│ ├───5,574,608 B (00.58%) -- {59c81df5-4b7a-477b-912d-4e0fdf64e5f2}
+│ │ ├──5,529,280 B (00.57%) -- window-objects
+│ │ │ ├──4,175,584 B (00.43%) ++ top(chrome://chatzilla/content/chatzilla.xul, id=4293)
+│ │ │ └──1,353,696 B (00.14%) ++ top(chrome://chatzilla/content/output-window.html, id=4298)
+│ │ └─────45,328 B (00.00%) ++ js-non-window/zones/zone(0x100496800)/compartment([System Principal], file:///Users/njn/Library/Application%20Support/Firefox/Profiles/puna0zr8.new/extensions/%7B59c81df5-4b7a-477b-912d-4e0fdf64e5f2%7D/components/chatzilla-service.js)
+│ └───1,872,144 B (00.19%) ++ treestyletab@piro.sakura.ne.jp/js-non-window/zones/zone(0x100496800)</pre>
+<p>此外还有一些内容需要指出:</p>
+<ul>
+ <li>部分附加组件会被识别出它的名字,比如 Tree Style Tab,其他则仅仅被识别为一个十六进制标识符,你可以在 about:support 查看某个标识符属于哪个附加组件。例如 <code>59c81df5-4b7a-477b-912d-4e0fdf64e5f2</code> 就是 Chatzilla。</li>
+ <li>每个附加组件的所有 JavaScript 内存占用都是单独测量并显示在这个子树之中。</li>
+ <li>像 Chatzilla 这样使用单独窗口的附加组件,所有单独窗口所占用的内存都会显示在这个子树之中。</li>
+ <li>像 AdBlock Plus 这样使用 XUL overlay 的附加组件,所有 overlay 所占用的内存都不显示在这个子树中,而是显示在 add-on 以外的子树中,所以不会被识别为该附加组件所占用的内存。</li>
+</ul>
+<h4 id="Other_Measurements">Other Measurements</h4>
+<p>这个区段包含多个树,包括与 "explicit" 树中测量数据相交叉(cross-cut)的树。比如说,在 "explicit" 这个树中所有 DOM 和 layout 测量数据会被分解到每个窗口当中,而在 "Other Measurements" 区段中,这些测量数据又会被汇总成整个浏览器,如下例所示。</p>
+<pre>26.77 MB (100.0%) -- window-objects
+├──14.59 MB (54.52%) -- layout
+│ ├───6.22 MB (23.24%) ── style-sets
+│ ├───4.00 MB (14.95%) ── pres-shell
+│ ├───1.79 MB (06.68%) ── frames
+│ ├───0.89 MB (03.33%) ── style-contexts
+│ ├───0.62 MB (02.33%) ── rule-nodes
+│ ├───0.56 MB (02.10%) ── pres-contexts
+│ ├───0.47 MB (01.75%) ── line-boxes
+│ └───0.04 MB (00.14%) ── text-runs
+├───6.53 MB (24.39%) ── style-sheets
+├───5.59 MB (20.89%) -- dom
+│ ├──3.39 MB (12.66%) ── element-nodes
+│ ├──1.56 MB (05.84%) ── text-nodes
+│ ├──0.54 MB (02.03%) ── other
+│ └──0.10 MB (00.36%) ++ (4 tiny)
+└───0.06 MB (00.21%) ── property-tables</pre>
+<p>但是这个区段部分树的测量数据又不会与 "explicit" 树的相交叉,比如上面提到的 "preference-service" 这个例子当中的树。</p>
+<p>最后,在这个区段结尾处是其他单独的测量数据,如下例所示。</p>
+<pre> 0.00 MB ── canvas-2d-pixels
+ 5.38 MB ── gfx-surface-xlib
+ 0.00 MB ── gfx-textures
+ 0.00 MB ── gfx-tiles-waste
+ 0 ── ghost-windows
+ 109.22 MB ── heap-allocated
+ 164 ── heap-chunks
+ 1.00 MB ── heap-chunksize
+ 114.51 MB ── heap-committed
+ 164.00 MB ── heap-mapped
+ 4.84% ── heap-overhead-ratio
+ 1 ── host-object-urls
+ 0.00 MB ── imagelib-surface-cache
+ 5.27 MB ── js-main-runtime-temporary-peak
+ 0 ── page-faults-hard
+ 203,349 ── page-faults-soft
+ 274.99 MB ── resident
+ 251.47 MB ── resident-unique
+1,103.64 MB ── vsize</pre>
+<p>这里有一些值得注意的测量数据:</p>
+<ul>
+ <li>"resident" 是物理内存占用。如果你想看到一个单独统计内存占用的测量数据,这应该是最符合的数据。</li>
+ <li>"vsize" 是虚拟内存占用。这个值往往会大大高于其他任何测量数据值(尤其在 Mac 平台),并且只在 Win32 这样的 32 位平台才显得很重要。还有一个 "vsize-max-contiguous"(有些平台没有测量,这里的例子也没有出现),它是指最大一个可用的虚拟地址空间数据块。如果这个数字过低,则意味着很快会因缺少虚拟地址空间而导致内存分配失败。</li>
+ <li>各种与图形有关的测量数据 ("gfx-*")。这个测量数据会因平台不同而有所变化。图形经常是引起高内存占用的一个原因,所以这些测量数据会有助于我们判断出这种情况。</li>
+</ul>
+<h4 id="System">System</h4>
+<p>这个区段只会在 Firefox OS 当中出现,它包含取自操作系统的对整个设备测量的数据。除此以外,该区段还有助于详细了解整个设备的内存是如何被使用的。</p>
diff --git a/files/zh-cn/mozilla/performance/index.html b/files/zh-cn/mozilla/performance/index.html
new file mode 100644
index 0000000000..dac76d9a75
--- /dev/null
+++ b/files/zh-cn/mozilla/performance/index.html
@@ -0,0 +1,138 @@
+---
+title: Performance
+slug: Mozilla/Performance
+tags:
+ - NeedsTranslation
+ - Performance
+ - TopicStub
+translation_of: Mozilla/Performance
+---
+<p>The articles linked to from here will help you improve performance, whether you're developing core Mozilla code or an add-on.</p>
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h3 id="Documentation">Documentation</h3>
+ <dl>
+ <dt>
+ <a href="/en/Performance/Reporting_a_Performance_Problem" title="en/Performance/Reporting_a_Performance_Problem">Reporting a Performance Problem</a></dt>
+ <dd>
+ A user friendly guide to reporting a performance problem. A development environment is not required.</dd>
+ <dt>
+ <a href="/en/Extensions/Performance_best_practices_in_extensions" title="en/Extensions/Performance best practices in extensions">Performance best practices in extensions</a></dt>
+ <dd>
+ A performance "best practices" guide for extension developers.</dd>
+ <dt>
+ <a href="/en/Performance/Measuring_add-on_startup_performance" title="en/Measuring Add-on Startup Performance">Measuring Add-on Startup Performance</a></dt>
+ <dd>
+ A guide for add-on developers on how to set up a performance testing environment.</dd>
+ <dt>
+ <a href="/en/XUL_School/Appendix_A:_Add-on_Performance" title="en/XUL School/Appendix A: Add-on Performance">XUL School: Add-on Performance</a></dt>
+ <dd>
+ Tips for add-on developers to help them avoid impairing application performance.</dd>
+ <dt>
+ <a href="/en/Performance/GPU_performance" title="en/GPU performance">GPU performance</a></dt>
+ <dd>
+ Tips for profiling and improving performance when using a GPU.</dd>
+ </dl>
+ <p><span class="alllinks"><a class="internal" href="/Special:Tags?tag=Performance" title="Special:Tags?tag=Performance">View all pages tagged with "Performance"...</a></span></p>
+ <h3 id="Memory_profiling_and_leak_detection_tools">Memory profiling and leak detection tools</h3>
+ <dl>
+ <dt>
+ <a href="/en-US/docs/Mozilla/Performance/about:memory">about:memory</a></dt>
+ <dd>
+ about:memory is the easiest-to-use tool for measuring memory usage in Mozilla code, and is the best place to start. It also lets you do other memory-related operations like trigger GC and CC, dump GC &amp; CC logs, and dump DMD reports. about:memory is built on top of Firefox's <a href="/en-US/docs/Mozilla/Performance/Memory_reporting">memory reporting</a> infrastructure.</dd>
+ <dt>
+ <a href="/en-US/docs/Mozilla/Performance/DMD">DMD</a></dt>
+ <dd>
+ DMD is a tool that identifies shortcomings in about:memory's measurements, and can also do multiple kinds of general heap profiling.</dd>
+ <dt>
+ <a href="https://areweslimyet.com/">areweslimyet.com</a></dt>
+ <dd>
+ areweslimyet.com (a.k.a. AWSY) is a memory usage and regression tracker.</dd>
+ <dt>
+ <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Performance/BloatView">BloatView</a></dt>
+ <dd>
+ BloatView prints per-class statistics on allocations and refcounts, and provides gross numbers on the amount of memory being leaked broken down by class. It is used as part of Mozilla's continuous integration testing.</dd>
+ <dt>
+ <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Performance/Refcount_tracing_and_balancing">Refcount tracing and balancing</a></dt>
+ <dd>
+ Refcount tracing and balancing are ways to track down leaks caused by incorrect uses of reference counting. They are slow and not particular easy to use, and thus most suitable for use by expert developers.</dd>
+ <dt>
+ <a href="/en-US/docs/Mozilla/Performance/GC_and_CC_logs">GC and CC logs</a></dt>
+ <dd>
+ GC and CC logs can be generated and analyzed to in various ways. In particular, they can help you understand why a particular object is being kept alive.</dd>
+ <dt>
+ <a href="/en-US/docs/Mozilla/Testing/Valgrind">Valgrind</a></dt>
+ <dd>
+ <a class="external text" href="http://valgrind.org/" rel="nofollow">Valgrind</a> is a tool that detects various memory-related problems at runtime, including leaks. Valgrind is used as <a class="external text" href="/en-US/docs/Valgrind_test_job" rel="nofollow">part</a> of Mozilla's continuous integration testing, though the coverage is limited because Valgrind is slow.</dd>
+ <dt>
+ <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Testing/Firefox_and_Address_Sanitizer#LeakSanitizer">LeakSanitizer</a></dt>
+ <dd>
+ <span class="external text">LeakSanitizer</span> (a.k.a. LSAN) is similar to Valgrind, but it runs faster because it uses static source code instrumentation. LSAN is part of Mozilla's continuous integration testing, with most tests running through it as part of the AddressSanitizer (a.k.a. ASAN) test jobs.</dd>
+ <dt>
+ <a href="http://developer.apple.com/documentation/Performance/Conceptual/ManagingMemory/Articles/FindingLeaks.html">Apple tools</a></dt>
+ <dd>
+ Apple provides <span class="external text">some tools</span> for Mac OS X that report similar problems to those reported by LSAN and Valgrind. The "leaks" tool is not recommended for use with SpiderMonkey or Firefox, because it gets confused by tagged pointers and thinks objects have leaked when they have not (see <a class="external text" href="https://bugzilla.mozilla.org/show_bug.cgi?id=390944" rel="nofollow">bug 390944</a>).</dd>
+ <dt>
+ <a href="/en-US/docs/Mozilla/Performance/TraceMalloc">TraceMalloc</a></dt>
+ <dd>
+ TraceMalloc is a tool that does various kinds of heap profiling.</dd>
+ <dt>
+ <a href="/en-US/docs/Mozilla/Performance/Leak_Gauge">Leak Gauge</a></dt>
+ <dd>
+ Leak Gauge is a tool that can be used to detect certain kinds of leaks in Gecko, including those involving documents, window objects, and docshells.</dd>
+ <dt>
+ <a href="http://dxr.mozilla.org/mozilla-central/source/memory/replace/logalloc/README">LogAlloc</a></dt>
+ <dd>
+ LogAlloc is a tool that dumps a log of memory allocations in Gecko. That log can then be replayed against Firefox's default memory allocator independently or through another replace-malloc library, allowing the testing of other allocators under the exact same workload.</dd>
+ </dl>
+ <p>See also the documentation on <a href="/en-US/docs/Mozilla/Performance/Leak-hunting_strategies_and_tips">Leak-hunting strategies and tips.</a></p>
+ </td>
+ <td>
+ <h3 id="Profiling_and_performance_tools">Profiling and performance tools</h3>
+ <dl>
+ <dt>
+ <a href="/en/Performance/Profiling_with_the_Built-in_Profiler" title="en/Performance/Profiling with the Built-in Profiler">Profiling with the Built-in Profiler</a> {{ gecko_minversion_inline("16.0") }}</dt>
+ <dd>
+ The built-in profiler is a good tool to start with.</dd>
+ <dt>
+ <a href="/en/Performance/Profiling_with_Instruments" title="en/Performance/Profiling with Instruments">Profiling with Instruments</a></dt>
+ <dd>
+ How to use Apple's Instruments tool to profile Mozilla code.</dd>
+ <dt>
+ <a href="/en/Performance/Profiling_with_Xperf" title="en/Performance/Profiling with Xperf">Profiling with Xperf</a></dt>
+ <dd>
+ How to use Microsoft's Xperf tool to profile Mozilla code.</dd>
+ <dt>
+ <a href="/en/Performance/Profiling_with_Zoom" title="en/Performance/Profiling with Zoom">Profiling with Zoom</a></dt>
+ <dd>
+ Zoom is a profiler for Linux done by the people who made Shark</dd>
+ <dt>
+ <a href="/en/Performance/Measuring_performance_using_the_PerfMeasurement.jsm_code_module" title="en/Performance/Measuring performance using the PerfMeasurement.jsm code module">Measuring performance using the PerfMeasurement.jsm code module</a> {{ gecko_minversion_inline("2.0") }}</dt>
+ <dd>
+ Using <a href="/en/JavaScript_code_modules/PerfMeasurement.jsm" title="en/JavaScript code modules/PerfMeasurement.jsm"><code>PerfMeasurement.jsm</code></a> to measure performance data in your JavaScript code.</dd>
+ <dt>
+ <a href="/en-US/docs/Performance/Adding_a_new_Telemetry_probe" title="https://developer.mozilla.org/en-US/docs/Performance/Adding_a_new_Telemetry_probe">Adding a new Telemetry probe</a></dt>
+ <dd>
+ Information on how to add a new measurement to the Telemetry performance-reporting system</dd>
+ <dt>
+ <a href="/en/Performance/Profiling_JavaScript_with_Shark" title="en/Performance/Profiling JavaScript with Shark">Profiling JavaScript with Shark</a> {{ gecko_minversion_inline("1.9") }}</dt>
+ <dd>
+ How to use the Mac OS X Shark profiler to profile JavaScript code in Firefox 3.5 or later.</dd>
+ <dt>
+ <a href="/en/Performance/Profiling_with_Shark" title="en/Performance/Profiling with Shark">Profiling with Shark</a></dt>
+ <dd>
+ How to use Apple's Shark tool to profile Mozilla code.</dd>
+ <br>
+ </dl>
+ <h3 id="Related_Topics">Related Topics</h3>
+ <dl>
+ <dd>
+ <a href="/en/JavaScript" title="en/JavaScript">JavaScript</a>, <a href="/en/XPCOM" title="en/XPCOM">XPCOM</a>, <a href="/En/Developer_Guide" title="en/Developing_Mozilla">Developing Mozilla</a>, <a href="/en/Extensions" title="en/Extensions">Extensions</a>, <a href="/en/Addons" title="en/Addons">Addons</a></dd>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
diff --git a/files/zh-cn/mozilla/performance/scroll-linked_effects/index.html b/files/zh-cn/mozilla/performance/scroll-linked_effects/index.html
new file mode 100644
index 0000000000..5d3c1a7bf0
--- /dev/null
+++ b/files/zh-cn/mozilla/performance/scroll-linked_effects/index.html
@@ -0,0 +1,121 @@
+---
+title: Scroll-linked effects
+slug: Mozilla/Performance/Scroll-linked_effects
+tags:
+ - CSS
+ - JavaScript
+ - Web动画
+ - 性能
+ - 滚动
+translation_of: Mozilla/Performance/Scroll-linked_effects
+---
+<p class="summary">scroll-linked<span lang="zh-CN"><span> 效果指的是某种因滚动条位置变化的而产生的效果,例如,为了产生视差滚动效果而更新 position 属性。</span> <span>本文讨论 </span></span>scroll-linked<span lang="zh-CN"><span> 效果、这些效果对性能的影响、相关工具以及可以缓解问题的技术。</span></span></p>
+
+<h2 id="滚动效果解释">滚动效果解释</h2>
+
+<p>滚动效果一般是指通过监听 {{event("scroll")}} 事件,并以某种方式修改页面上的元素(通常是 CSS 的 {{cssxref("position")}} 或 {{cssxref("transform")}} 属性)你可以在 <a href="https://github.com/RByers/css-houdini-drafts/blob/master/css-scroll-api/UseCases.md">CSS Scroll API: Use Cases</a> 找到这样的效果。</p>
+
+<p><span id="result_box" lang="zh-CN"><span>当滚动在浏览器主线程上完成时,这些效果运行良好。但是,大多数浏览器现在支持一种异步滚动,以便为用户提供恒定每秒60帧的体验。在异步滚动模型中,视觉滚动位置(译者注:即用户看到的滚动位置)在合成器线程中更新,并在 DOM 更新</span></span> {{event("scroll")}}<span lang="zh-CN"><span> 事件、主线程触发</span></span> {{event("scroll")}}<span lang="zh-CN"><span> 事件之前对用户可见。</span></span><span id="result_box" lang="zh-CN"><span>这意味着实际显示的效果将会落后于用户看到的滚动位置一点点。</span> <span>这可能会导致效果变得迟缓,总之,我们想要避免这种情况。</span></span></p>
+
+<p><span class="short_text" id="result_box" lang="zh-CN"><span>下面是一些在异步滚动中不能良好运行的例子,以及可以很好地运行的等效版本:</span></span></p>
+
+<div class="sy_shorturl_main" id="sy_shorturl_main"></div>
+
+<div class="sy_shorturl_main" id="sy_shorturl_main"></div>
+
+<h3 id="示例1:粘性定位"><span class="short_text" id="result_box" lang="zh-CN"><span>示例</span></span>1:粘性定位</h3>
+
+<p><span class="short_text" id="result_box" lang="zh-CN"><span>这是一个粘性定位效果的实现,其中“</span></span>toolbar<span class="short_text" lang="zh-CN"><span>”的 div 将在您向下滚动时“粘”在屏幕顶部</span></span></p>
+
+<div class="sy_shorturl_main" id="sy_shorturl_main"></div>
+
+<pre class="brush: html">&lt;body style="height: 5000px" onscroll="document.getElementById('toolbar').style.top = Math.max(100, window.scrollY) + 'px'"&gt;
+ &lt;div id="toolbar" style="position: absolute; top: 100px; width: 100px; height: 20px; background-color: green"&gt;&lt;/div&gt;
+&lt;/body&gt;</pre>
+
+<p><span id="result_box" lang="zh-CN"><span>这种粘性定位的实现依赖于监听</span></span><span lang="zh-CN"><span>滚动事件,来重新定位</span></span><span class="short_text" id="result_box" lang="zh-CN"><span>“</span></span>toolbar<span class="short_text" lang="zh-CN"><span>”的 div</span></span><span lang="zh-CN"><span>。由于滚动事件监听器运行于浏览器主线程的 JavaScript 中,它与用户可见的滚动是异步的。</span><span>所以,因为有异步滚动,事件处理程序将相对于用户可见的滚动来说是有延迟的,这个 div 不会像预期那样保持视觉上的固定。</span><span>相反,它将随用户的滚动移动,然后在滚动事件处理器运行时突然回到应有的位置。</span><span>这种恒定的移动和捕捉将会导致视觉效果的抖动。其中一种解决方法是使用为此设计的 CSS 属性,而不是用</span><span>滚动事件监听器:</span></span></p>
+
+<div class="sy_shorturl_main" id="sy_shorturl_main"></div>
+
+<pre class="brush: html">&lt;body style="height: 5000px"&gt;
+ &lt;div id="toolbar" style="position: sticky; top: 0px; margin-top: 100px; width: 100px; height: 20px; background-color: green"&gt;&lt;/div&gt;
+&lt;/body&gt;</pre>
+
+<p><span class="short_text" id="result_box" lang="zh-CN"><span>此版本适用于异步滚动,当用户滚动时,浏览器会更新“toolbar”的 div 的位置。</span></span></p>
+
+<h3 id="示例2:滚动捕捉"><span class="short_text" id="result_box" lang="zh-CN"><span>示例2:滚动捕捉</span></span></h3>
+
+<p class="summary"><span id="result_box" lang="zh-CN"><span>此特性已从 Web 标准中删除。</span> <span>虽然一些浏览器可能仍然支持它,但它正在被放弃。尽量不要</span><span>使用它,并尽可能更新现有代码。</span></span><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-coordinate#Browser_compatibility">https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-coordinate#Browser_compatibility</a></p>
+
+<div class="sy_shorturl_main" id="sy_shorturl_main"></div>
+
+<p><span class="short_text" lang="zh-CN"><span>以下是滚动捕捉的实现,当用户的滚动停止在 </span></span>snaptarget<span class="short_text" lang="zh-CN"><span> 附近时,滚动位置捕捉到特定目的地(</span></span>snaptarget<span class="short_text" lang="zh-CN"><span>)。</span></span></p>
+
+<div class="sy_shorturl_main" id="sy_shorturl_main"></div>
+
+<pre class="brush: html">&lt;body style="height: 5000px"&gt;
+ &lt;script&gt;
+    function snap(destination) {
+        if (Math.abs(destination - window.scrollY) &lt; 3) {
+            scrollTo(window.scrollX, destination);
+        } else if (Math.abs(destination - window.scrollY) &lt; 200) {
+            scrollTo(window.scrollX, window.scrollY + ((destination - window.scrollY) / 2));
+            setTimeout(snap, 20, destination);
+        }
+    }
+    var timeoutId = null;
+    addEventListener("scroll", function() {
+        if (timeoutId) clearTimeout(timeoutId);
+        timeoutId = setTimeout(snap, 200, parseInt(document.getElementById('snaptarget').style.top));
+    }, true);
+ &lt;/script&gt;
+ &lt;div id="snaptarget" style="position: relative; top: 200px; width: 100%; height: 200px; background-color: green"&gt;&lt;/div&gt;
+&lt;/body&gt;</pre>
+
+<p><span id="result_box" lang="zh-CN"><span>在该示例中,有滚动事件监听器,其检测滚动位置是否在“snaptarget”的 div 顶部的 200 像素内。</span> <span>如果是,则触发动画,将 div 的顶部</span></span><span lang="zh-CN"><span>“卡”到滚动位置。</span> <span>由于此动画由浏览器主线程上的 JavaScript 驱动,所以可以被其他选项卡或其他窗口中运行的 JavaScript 中断。</span> <span>因此,动画可能最终看起来很漂亮,但并不像预期那样平滑。</span> <span>相反,使用 CSS 的 snap-points 属性将允许浏览器异步运行动画,为用户提供平滑的视觉效果。</span></span></p>
+
+<div class="sy_shorturl_main" id="sy_shorturl_main"></div>
+
+<pre class="brush: html">&lt;body style="height: 5000px"&gt;
+ &lt;style&gt;
+    body {
+        scroll-snap-type: proximity;
+        scroll-snap-destination: 0 0;
+    }
+    #snaptarget {
+        scroll-snap-coordinate: 0 -8px;
+    }
+ &lt;/style&gt;
+ &lt;div id="snaptarget" style="position: relative; top: 200px; width: 100%; height: 200px; background-color: green"&gt;&lt;/div&gt;
+&lt;/body&gt;</pre>
+
+<p><span class="short_text" id="result_box" lang="zh-CN"><span>即使浏览器的主线程中运行的 JavaScript 速度较慢,该版本也能在浏览器中顺利运行。</span></span></p>
+
+<h3 id="其他效果">其他效果</h3>
+
+<p>在不少情况下,scroll-linked 效果能够通过 CSS 和在排序线程运行来重新实现。 然而, 有时浏览器提供的 API 不允许这么做。但是不管怎样, 如果 Firefox(从版本 46 之后)检测到页面上的 scroll-linked 效果, 将在控制台向开发人员显示警告 。 需要说明的是,使用滚动效果的页面如果在 JavaScript 中不监听滚动事件将无法获得此警告。你可以参考此博客文章( <a href="https://staktrace.com/spout/entry.php?id=834">Asynchronous scrolling in Firefox</a> )来了解更多通过 CSS 来实现避免页面延迟的例子。</p>
+
+<h2 id="未来改进">未来改进</h2>
+
+<p>未来我们将在 compositor 中支持更多的效果。为了完成这个目标,我们需要你(没错,就是你!)来告诉我们更多的你努力实现的 scroll-linked 效果,以便我们可以找到好的方式来支持它们。目前有几个对于 API 的提案可以实现这种效果,它们也都有各自的优缺点。目前正在审议的提案是:</p>
+
+<ul>
+ <li><a href="https://w3c.github.io/web-animations/">Web Animations</a>: A new API for precisely controlling web animations in JavaScript, with an <a href="https://wiki.mozilla.org/Platform/Layout/Extended_Timelines">additional proposal</a> to map scroll position to time and use that as a timeline for the animation.</li>
+ <li><a href="https://w3c.github.io/web-animations/">Web Animations</a>:在 JavaScript 中新增一个 API,用于精确控制 Web 动画,还有一个额外提议——将滚动位置映射到时间,并将其用作动画的时间轴。</li>
+ <li><a href="https://docs.google.com/document/d/18GGuTRGnafai17PDWjCHHAvFRsCfYUDYsi720sVPkws/edit?pli=1#heading=h.iy9r1phg1ux4">CompositorWorker</a>: Allows JavaScript to be run on the compositor thread in small chunks, provided it doesn't cause the framerate to drop.</li>
+ <li><a href="https://docs.google.com/document/d/18GGuTRGnafai17PDWjCHHAvFRsCfYUDYsi720sVPkws/edit?pli=1#heading=h.iy9r1phg1ux4">CompositorWorker</a>:允许 JavaScript 在小块中的合成器线程上运行,前提是不会导致帧率下降。</li>
+ <li><a href="https://docs.google.com/document/d/1VnvAqeWFG9JFZfgG5evBqrLGDZYRE5w6G5jEDORekPY/edit?pli=1">Scroll Customization</a>: Introduces a new API for content to dictate how a scroll delta is applied and consumed. As of this writing, Mozilla does not plan to support this proposal, but it is included for completeness.</li>
+ <li><a href="https://docs.google.com/document/d/1VnvAqeWFG9JFZfgG5evBqrLGDZYRE5w6G5jEDORekPY/edit?pli=1">Scroll Customization</a>:引入一个新的内容 API 来决定如何应用和消费滚动增量。在撰写本文时,Mozilla 并不打算支持这个提议,但是为了完整性,它被包括在内。</li>
+</ul>
+
+<h3 id="Call_to_action">Call to action</h3>
+
+<p>如果你对下列内容有想法或意见:</p>
+
+<ul>
+ <li>上面关于 scroll-linked 的内容中的任何提案</li>
+ <li>你想要实现的 scroll-linked 效果</li>
+ <li>任何相关的问题或想法</li>
+</ul>
+
+<p>请与我们联系,您可以通过 <a href="https://lists.w3.org/Archives/Public/public-houdini/">public-houdini</a> 邮件列表来加入讨论。</p>
diff --git a/files/zh-cn/mozilla/persona/bootstrapping_persona/index.html b/files/zh-cn/mozilla/persona/bootstrapping_persona/index.html
new file mode 100644
index 0000000000..4f1c519c0a
--- /dev/null
+++ b/files/zh-cn/mozilla/persona/bootstrapping_persona/index.html
@@ -0,0 +1,29 @@
+---
+title: Persona引导
+slug: Mozilla/Persona/Bootstrapping_Persona
+translation_of: Archive/Mozilla/Persona/Bootstrapping_Persona
+---
+<p>为了真正成功实现分权,Persona需要得到三方面的支持:</p>
+<ul>
+ <li><strong>站点</strong>必须允许用户使用Persona登录。</li>
+ <li><strong>Web 浏览器</strong>必须实现<a href="/en/DOM/navigator.id" title="navigator.id"><code>navigator.id</code></a> APIs.</li>
+ <li><b>邮件供应商</b>必须是身份提供者(IdPs).</li>
+</ul>
+<p>This creates a chicken-and-egg problem: none of these groups would significantly benefit unless there was a critical mass of users, but a distributed system can't get a critical mass of users without support from the above groups.</p>
+<p>To solve this problem, <a class="link-https" href="https://login.persona.org" rel="freelink">https://login.persona.org</a> hosts three resources:</p>
+<ol>
+ <li>A fallback Identity Provider, which vouches for users whose email providers don't support Persona.</li>
+ <li>A <a href="/en-US/docs/persona/Browser_compatibility" title="/en-US/docs/persona/Browser_compatibility">cross-browser</a>, JavaScript implementation of the <code><a href="/en/DOM/navigator.id" title="navigator.id">navigator.id</a></code> APIs for browsers without native support.</li>
+ <li>A hosted verification API to make it easy for sites to verify user credentials.</li>
+</ol>
+<p>Together, this allows web sites to offer Persona to users regardless of browser and without email providers needing to get involved.</p>
+<p>These services are temporary, and the Persona system is designed such that they transparently and automatically drop away as native support gets added to browsers and email providers. Thus, they will become less relevant as Persona matures, and may eventually be removed all together. At that point, <a href="https://login.persona.org" rel="freelink">https://login.persona.org</a> won't feature at all in the Persona system.</p>
+<h2 id="Fallback_Identity_Provider">Fallback Identity Provider</h2>
+<p>Any domain can become an Identity Provider as long as relying parties are willing to trust the certificates issued by that domain. We expect email providers to act as an IdPs for the addresses they administer, making the user experience of Persona seamless for those users.  It allows the user to leverage their existing relationship with the email provider when authenticating at other sites.</p>
+<p>However, email providers won't become IdPs until there is significant demand from their users. In the meantime, Mozilla operates a fallback IdP at <a href="https://login.persona.org" rel="freelink">https://login.persona.org</a>. This fallback allows users to sign into sites with their existing email address, regardless of whether or not the email provider supports Persona. The fallback IdP will certify email addresses from any domain using its own authentication flow and its own password, so long as the user is able to prove control of an address by clicking a link in a verification email.</p>
+<p>Once an email provider supports Persona natively, its users will transparently begin use it instead of the fallback IdP.</p>
+<h2 id="Cross-browser_API_Library">Cross-browser API Library</h2>
+<p>For Persona to work, the user's browser must support the <a href="/en/DOM/navigator.id" title="navigator.id">navigator.id</a> API. Eventually, browsers will add native support for these APIs, but until then a <a href="/en-US/docs/persona/Browser_compatibility" title="/en-US/docs/persona/Browser_compatibility">cross-browser </a>implementation is available at <a href="https://login.persona.org/include.js" title="https://login.persona.org/include.js">https://login.persona.org/include.js</a>. By including this file, web sites can already begin using Persona. Once native implementations of the API are available, the library will automatically defer to those.</p>
+<h2 id="Remote_verification_service">Remote verification service</h2>
+<p>At <a href="https://login.persona.org" rel="freelink">https://login.persona.org</a> Mozilla hosts a <a href="/en/Persona/Remote_Verification_API" title="en/BrowserID/Remote_Verification_API">remote verification service</a> that web sites can use to verify identity assertions sent from users. This makes it simpler for web sites to support Persona as it takes care of parsing the assertion and cryptographically verifying user identities.</p>
+<p>Once the Persona data formats stabilize, verification will most likely be done locally on each site's server. This transition is especially important for user privacy, since it will make it impossible for the fallback IdP to track its users. Even with remote verification, users of native IdPs can't be tracked by that IdP.</p>
diff --git a/files/zh-cn/mozilla/persona/branding/index.html b/files/zh-cn/mozilla/persona/branding/index.html
new file mode 100644
index 0000000000..3120f9a4c8
--- /dev/null
+++ b/files/zh-cn/mozilla/persona/branding/index.html
@@ -0,0 +1,79 @@
+---
+title: 品牌资源
+slug: Mozilla/Persona/branding
+tags:
+ - 图片
+ - 按钮
+translation_of: Archive/Mozilla/Persona/User_interface_guidelines
+---
+<h2 id="使用_Persona_样式的按钮登陆">使用 Persona 样式的按钮登陆</h2>
+<h3 id="图片样式">图片样式</h3>
+<p>Persona样式的登录按钮有三个版本,三种颜色:</p>
+<h4 id="英文按钮">英文按钮</h4>
+<table>
+ <thead>
+ <tr>
+ <th scope="row"> </th>
+ <th scope="col">Sign in with your Email</th>
+ <th scope="col">Sign in with Persona</th>
+ <th scope="col">Sign in</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th scope="row">Black</th>
+ <td><img alt="" src="/files/3955/email_sign_in_black.png" style="width: 202px; height: 25px;"></td>
+ <td><img alt="" src="/files/3961/persona_sign_in_black.png" style="width: 185px; height: 25px;"></td>
+ <td><img alt="" src="/files/3967/plain_sign_in_black.png" style="width: 95px; height: 25px;"></td>
+ </tr>
+ <tr>
+ <th scope="row">Blue</th>
+ <td><img alt="" src="/files/3957/email_sign_in_blue.png" style="width: 202px; height: 25px;"></td>
+ <td><img alt="" src="/files/3963/persona_sign_in_blue.png" style="width: 185px; height: 25px;"></td>
+ <td><img alt="" src="/files/3969/plain_sign_in_blue.png" style="width: 95px; height: 25px;"></td>
+ </tr>
+ <tr>
+ <th scope="row">Red</th>
+ <td><img alt="" src="/files/3959/email_sign_in_red.png" style="width: 202px; height: 25px;"></td>
+ <td><img alt="" src="/files/3965/persona_sign_in_red.png" style="width: 185px; height: 25px;"></td>
+ <td><img alt="" src="/files/3971/plain_sign_in_red.png" style="width: 95px; height: 25px;"></td>
+ </tr>
+ </tbody>
+</table>
+<h4 id="中文按钮">中文按钮</h4>
+<table>
+ <thead>
+ <tr>
+ <th scope="row"> </th>
+ <th scope="col">使用Email登录</th>
+ <th scope="col">使用Persona登录</th>
+ <th scope="col">登录</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th scope="row">黑色</th>
+ <td><img alt="" src="http://qidye.com/wp-content/uploads/2013/05/email_sign_in_black_zh_cn.png" style="width: 151px; height: 25px;"></td>
+ <td><img alt="" src="http://qidye.com/wp-content/uploads/2013/05/persona_sign_in_black_zh_cn.png" style="width: 167px; height: 25px;"></td>
+ <td><img alt="" src="http://qidye.com/wp-content/uploads/2013/05/plain_sign_in_black_zh_cn.png" style="width: 81px; height: 25px;"></td>
+ </tr>
+ <tr>
+ <th scope="row">蓝色</th>
+ <td><img alt="" src="http://qidye.com/wp-content/uploads/2013/05/email_sign_in_blue_zh_cn.png" style="width: 151px; height: 25px;"></td>
+ <td><img alt="" src="http://qidye.com/wp-content/uploads/2013/05/persona_sign_in_blue_zh_cn.png" style="width: 167px; height: 25px;"></td>
+ <td><img alt="" src="http://qidye.com/wp-content/uploads/2013/05/plain_sign_in_blue_zh_cn.png" style="width: 81px; height: 25px;"></td>
+ </tr>
+ <tr>
+ <th scope="row">红色</th>
+ <td><img alt="" src="http://qidye.com/wp-content/uploads/2013/05/email_sign_in_red_zh_cn.png" style="width: 151px; height: 25px;"></td>
+ <td><img alt="" src="http://qidye.com/wp-content/uploads/2013/05/persona_sign_in_red_zh_cn.png" style="width: 167px; height: 25px;"></td>
+ <td><img alt="" src="http://qidye.com/wp-content/uploads/2013/05/plain_sign_in_red_zh_cn.png" style="width: 81px; height: 25px;"></td>
+ </tr>
+ </tbody>
+</table>
+<h4 id="中文按钮打包下载">中文按钮打包下载</h4>
+<p>地址:<a href="http://qidye.com/wp-content/uploads/2013/05/persona_sign_in_zh_cn.20130513.001.by_.will_.chen_.7z">persona_sign_in_zh_cn.20130513.001.by.will.chen.7z</a></p>
+<h3 id="CSS-Based">CSS-Based</h3>
+<p><a href="http://sawyerhollenshead.com/" title="http://sawyerhollenshead.com/">Sawyer Hollenshead</a> 制作了一些非常优秀的 CSS-based 的按钮. <a href="/files/3973/persona-css-buttons.zip" title="/files/3973/persona-css-buttons.zip">Download (.zip)</a></p>
+<p><span style="font-size: 20px;"><b>更多信息</b></span></p>
+<p>你可以在 <a href="http://people.mozilla.org/~smartell/persona/" title="http://people.mozilla.org/~smartell/persona/">Sean Martell's style primer</a>找到更多关于Persona视觉效果设计的信息.</p>
diff --git a/files/zh-cn/mozilla/persona/browser_compatibility/index.html b/files/zh-cn/mozilla/persona/browser_compatibility/index.html
new file mode 100644
index 0000000000..e362b74b3a
--- /dev/null
+++ b/files/zh-cn/mozilla/persona/browser_compatibility/index.html
@@ -0,0 +1,89 @@
+---
+title: 浏览器兼容性
+slug: Mozilla/Persona/Browser_compatibility
+tags:
+ - Files
+translation_of: Archive/Mozilla/Persona/Browser_compatibility
+---
+<h2 id="支持的浏览器">支持的浏览器</h2>
+<p>Persona 支持下列浏览器。 Persona 包含一个跨平台的 JavaScript 库,因此用户使用时不需要安装任何插件。</p>
+<table>
+ <tbody>
+ <tr>
+ <th colspan="3" scope="row" style="text-align: center; background-color: #d3d7cf;"><strong>桌面浏览器</strong></th>
+ </tr>
+ <tr>
+ <th scope="row"><strong>Internet Explorer</strong></th>
+ <td colspan="2" rowspan="1" style="background-color: #8ae234;">8.0<sup>*</sup>, 9.0<sup>†</sup>, 10.0<sup>*</sup><sup>*</sup> (详见下方的 <a href="https://developer.mozilla.org/docs/persona/Browser_compatibility#Internet_Explorer_.22Compatibility_Mode.22">兼容模式</a> 说明)</td>
+ </tr>
+ <tr>
+ <th scope="row"><strong>Firefox</strong></th>
+ <td colspan="2" style="background-color: #8ae234;">现有稳定版本, 测试版本, Aurora, 夜间发布版本 和 扩展支持版本<br>
+ 以往稳定版本</td>
+ </tr>
+ <tr>
+ <th scope="row"><strong>Chrome</strong></th>
+ <td colspan="2" style="background-color: #8ae234;">最新稳定版本</td>
+ </tr>
+ <tr>
+ <th scope="row"><strong>Safari</strong></th>
+ <td colspan="2" style="background-color: #8ae234;">最新稳定版本</td>
+ </tr>
+ <tr>
+ <th scope="row"><strong>Opera</strong></th>
+ <td colspan="2" style="background-color: #8ae234;">最新稳定版本<sup>‡</sup></td>
+ </tr>
+ <tr>
+ <th colspan="3" scope="row" style="text-align: center; background-color: #d3d7cf;"><strong>iOS 浏览器</strong></th>
+ </tr>
+ <tr>
+ <th scope="row"><strong>Safari</strong></th>
+ <td colspan="2" rowspan="1" style="background-color: #8ae234;">iOS 5.x — 6.x</td>
+ </tr>
+ <tr>
+ <th colspan="3" scope="row" style="text-align: center; background-color: #d3d7cf;"><strong>Android 浏览器</strong></th>
+ </tr>
+ <tr>
+ <th scope="row"><b>默认浏览器</b></th>
+ <td colspan="2" rowspan="1" style="background-color: #8ae234;">2.2 — 4.x</td>
+ </tr>
+ <tr>
+ <th scope="row"><strong>Firefox</strong></th>
+ <td colspan="2" style="background-color: #8ae234;">现有稳定版本, 测试版本, Aurora 和 夜间发布版本<br>
+ 以往稳定版本</td>
+ </tr>
+ <tr>
+ <th scope="row"><strong>Chrome</strong></th>
+ <td colspan="2" style="background-color: #8ae234;">Latest Stable Release</td>
+ </tr>
+ </tbody>
+</table>
+<p><sup>*</sup>: Windows XP. <sup>†</sup>: Windows Vista 和 Windows 7. <sup>*</sup><sup>*</sup>Windows 8.<sup>  </sup><sup>‡</sup>: 如果时间允许.</p>
+<h2 id="不支持的浏览器">不支持的浏览器</h2>
+<ul>
+ <li>Internet Explorer 6.0 和 7.0 不被支持。 Persona 会提醒用户升级浏览器。 另见 <a href="https://developer.mozilla.org/docs/persona/Browser_compatibility#Internet_Explorer_.22Compatibility_Mode.22" title="IE 兼容模式">IE “兼容模式</a>”。</li>
+ <li>Google Chrome Frame 不被支持且无法使用。 以后可能会加入对其支持 (<a href="https://github.com/mozilla/browserid/issues/796" title="https://github.com/mozilla/browserid/issues/796">Issue #796</a>)。</li>
+ <li>iOS 上的第三方浏览器不被支持且无法使用。 以后可能会加入对其支持 (<a href="https://github.com/mozilla/browserid/issues/2034" title="https://github.com/mozilla/browserid/issues/2034">Issue #2034</a>)。</li>
+</ul>
+<h2 id="Internet_Explorer_的“兼容模式”">Internet Explorer 的“兼容模式”</h2>
+<p>从 8.0 版开始, Internet Explorer 提供了一项名为“兼容模式”的功能, 其在渲染页面时会模拟 8.0 以前版本的行为。 这个特性可以通过三种方法控制:</p>
+<ol>
+ <li>浏览器中的本地设置</li>
+ <li>页面中的 <a href="https://developer.mozilla.org/docs/Quirks_Mode_and_Standards_Mode" title="https://developer.mozilla.org/docs/Quirks_Mode_and_Standards_Mode">DOCTYPE</a> 声明</li>
+ <li>网站在 HTTP 头或页面 <a href="https://developer.mozilla.org/docs/HTML/Element/meta" style="text-decoration: underline; font-family: 'Courier New', 'Andale Mono', monospace;" title="https://developer.mozilla.org/docs/HTML/Element/meta">&lt;meta&gt;</a> 标签中使用 <a href="http://msdn.microsoft.com/library/cc288325%28v=vs.85%29.aspx" title="http://msdn.microsoft.com/library/cc288325%28v=vs.85%29.aspx">"X-UA-Compatible"</a>。 此方法会覆盖前两种</li>
+</ol>
+<p>由于 Persona 不支持 Internet Explorer 8.0 以前版本, 任何 Internet Explorer 如果模拟了8.0 以前版本也将不能支持 Persona 。 这通常是由于:</p>
+<ul>
+ <li>你的网站使用 "X-UA-Compatible" 显式指定浏览器模拟 8.0 以前版本</li>
+ <li>你的网站未设置 DOCTYPE ,未将 DOCTYPE 置于页面首行, 或者浏览器被设置为 quirks 模式而你的网站未将 "X-UA-Compatible" 设置为 IE 8.0 或更高版本</li>
+ <li>浏览器被用户设置为使用 模拟 8.0 以前版本的 “兼容模式”, 而你的网站没有使用 "X-UA-Compatible" 覆盖这个设置</li>
+ <li>译注:总之,为了让 IE 8.0 及以上能正常运行 Persona ,你应该加入 "X-UA-Compatible" 头部</li>
+</ul>
+<p>详情请见 <a href="https://blogs.msdn.com/b/askie/archive/2009/03/23/understanding-compatibility-modes-in-internet-explorer-8.aspx?Redirected=true" title="https://blogs.msdn.com/b/askie/archive/2009/03/23/understanding-compatibility-modes-in-internet-explorer-8.aspx?Redirected=true">"Understanding Compatibility Modes in Internet Explorer 8"</a> 和 <a href="http://hsivonen.iki.fi/doctype/index.html#ie8" title="http://hsivonen.iki.fi/doctype/index.html#ie8">"IE8 and IE9 Complications"</a>.</p>
+<h2 id="其他浏览器">其他浏览器</h2>
+<p>除非明显不被支持, 任何同时支持 {{ domxref("window.postMessage()") }} 和 {{ domxref("Storage", "localStorage") }} 的浏览器都应该能使 Persona 正常运行。 2010年3月后所有主流浏览器都支持这些 API 。</p>
+<h2 id="已知问题">已知问题</h2>
+<ul>
+ <li>浏览器需要允许第三方 Cookies 以保证功能完整 (<a href="https://github.com/mozilla/browserid/issues/1352" title="https://github.com/mozilla/browserid/issues/1352">Issue #1352</a>)。</li>
+ <li>Android 2.x 上,如果用户没有选择默认浏览器,他们将无法登录 (<a href="https://github.com/mozilla/browserid/issues/1854" title="https://github.com/mozilla/browserid/issues/1854">Issue #1854</a>)。</li>
+</ul>
diff --git a/files/zh-cn/mozilla/persona/glossary/index.html b/files/zh-cn/mozilla/persona/glossary/index.html
new file mode 100644
index 0000000000..430bacbabe
--- /dev/null
+++ b/files/zh-cn/mozilla/persona/glossary/index.html
@@ -0,0 +1,61 @@
+---
+title: 术语表
+slug: Mozilla/Persona/Glossary
+translation_of: Archive/Mozilla/Persona/Glossary
+---
+<h2 id="Persona_和_BrowserID">"Persona" 和 "BrowserID"</h2>
+<p>Persona 是 Mozilla 的全新分布式登录系统的完整实现。</p>
+<p>BrowserID 是 Persona 基于的开放协议。</p>
+<h2 id="常用_Persona_术语"><span style="font-size: 2.142857142857143rem;">常用 </span>Persona 术语</h2>
+<dl>
+ <dt>
+ BrowserID</dt>
+ <dd>
+ 一种基于电子邮件地址的,开放、去中心化的用户认证协议。</dd>
+ <dt>
+ 身份凭证提供者 ("IdP")</dt>
+ <dd>
+ 为其用户签发身份凭证的服务。</dd>
+ <dd>
+ 邮件服务提供商可以通过在其服务中增加 BrowserID 支持成为身份凭证提供者。 Mozilla 为不支持 Persona 的邮件<span style="line-height: 1.5;">服务</span><span style="line-height: 1.5;">提供商提供了身份凭证服务, 其位于 </span><a class="link-https" href="https://login.persona.org" style="line-height: 1.5;" title="https://login.persona.org">login.persona.org</a><span style="line-height: 1.5;">.</span></dd>
+ <dt>
+ login.persona.org</dt>
+ <dd>
+ 由 Mozilla Identity 团队运行的备用身份凭证服务。</dd>
+ <dt>
+ Persona</dt>
+ <dd>
+ Mozilla 对用户公布的整套认证服务的名称,这套服务包括由 Mozilla Identity 团队运行的备用身份凭证服务。 最终用户应该不需要知道 "BrowserID" 这个术语。</dd>
+ <dd>
+ Persona 可能逐渐包含 BrowserID 协议之外的功能,如 Firefox Sync 的部分功能,或者 Open Web Apps 的控制面板。</dd>
+ <dt>
+ Relying Party ("RP")</dt>
+ <dd>
+ 允许用户通过 Persona 登录的任何网站,应用或服务。</dd>
+</dl>
+<h2 id="项目代号">项目代号</h2>
+<dl>
+ <dt>
+ BigTent</dt>
+ <dd>
+ 三个身份凭证服务的集合,分别针对 Hotmail,Gmail 和 Yahoo Mail 的用户。 BigTent 通过OpenID 或 OAuth 等方式连接各个邮件<span style="line-height: 1.5;">服务</span><span style="line-height: 1.5;">提供商。 源码位于 </span><a href="https://github.com/mozilla/browserid-bigtent" style="line-height: 1.5;" title="https://github.com/mozilla/browserid-bigtent">https://github.com/mozilla/browserid-bigtent</a><span style="line-height: 1.5;"> 。</span></dd>
+ <dt>
+ Vinz Clortho</dt>
+ <dd>
+ <code>电子邮件后缀为 @mozilla.com</code> 和 <code>@mozilla.org</code> 的身份凭证服务。 通过 LDAP 运行。 源码位于 <a href="https://github.com/mozilla/vinz-clortho" title="https://github.com/mozilla/browserid-bigtent">https://github.com/mozilla/vinz-clortho</a> 。 项目名称向1984年的电影《捉鬼敢死队》致敬。</dd>
+</dl>
+<h2 id="不常用_Persona_术语">不常用 Persona 术语</h2>
+<dl>
+ <dt>
+ 一级认证机构 ("Primary")</dt>
+ <dd>
+ 弃用术语, 指能同时作为身份认证提供者的邮件服务提供商。</dd>
+ <dt>
+ 二级认证机构 ("Secondary)</dt>
+ <dd>
+ 弃用术语,指为其邮件服务提供商不支持 Persona 的用户提供备用身份认证服务的身份认证提供者。<span style="line-height: 1.5;">Mozilla 在 </span><a class="link-https" href="https://login.persona.org" style="line-height: 1.5;" title="https://login.persona.org">login.persona.org</a> 运行了一个备用身份认证服务。</dd>
+ <dt>
+ Verified Email Protocol</dt>
+ <dd>
+ BrowserID 协议的旧称。</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/persona/index.html b/files/zh-cn/mozilla/persona/index.html
new file mode 100644
index 0000000000..5c19bec83a
--- /dev/null
+++ b/files/zh-cn/mozilla/persona/index.html
@@ -0,0 +1,138 @@
+---
+title: Mozilla Persona
+slug: Mozilla/Persona
+tags:
+ - Mozilla
+ - Persona
+ - zh-CN
+translation_of: Archive/Mozilla/Persona
+---
+<div class="callout-box">
+<p><strong>保持联系或获取帮助!</strong></p>
+
+<p>关注 <a class="external" href="http://identity.mozilla.com/" title="http://identity.mozilla.com/">我们的 blog</a>,加入 <a class="link-https" href="https://lists.mozilla.org/listinfo/dev-identity" title="https://lists.mozilla.org/listinfo/dev-identity">我们的邮件列表</a>,或在 <a class="link-https" href="https://wiki.mozilla.org/IRC" title="https://wiki.mozilla.org/IRC">IRC</a> 中的 <a class="link-irc" href="irc://irc.mozilla.org/identity" title="irc://irc.mozilla.org/identity">#identity</a> 找到我们。</p>
+</div>
+
+<blockquote>
+<p>提示:Mozilla将在2016年11月关闭Persona.org</p>
+
+<p>邮件列表:<a href="https://mail.mozilla.org/pipermail/persona-notices/2016/000005.html">https://mail.mozilla.org/pipermail/persona-notices/2016/000005.html</a></p>
+</blockquote>
+
+<p><a class="link-https" href="https://www.mozilla.org/zh-CN/persona/" title="https://www.mozilla.org/zh-CN/persona/">Mozilla Persona</a> 是一个用于 web 的完全去中心化且安全的验证系统,基于开放 BrowserID 协议。Mozilla 当前管理一个 Persona 相关的一个<a href="/zh-CN/docs/Persona/Bootstrapping_Persona" title="/zh-CN/docs/Persona/Bootstrapping_Persona">可选的、中心化服务</a>的一小组套件。</p>
+
+<p>为什么你和你的站点应该使用 Persona?</p>
+
+<ol>
+ <li><strong>Persona 完全消除了站点特定的密码,</strong> 把用户和网站从创建、管理和安全存放密码的责任中解放出来。</li>
+ <li><strong>Persona 易于使用。</strong>只需点击两次,一个 Persona 用户可以登入到一个诸如 <a href="http://voo.st" title="http://voo.st">Voost</a> 或 <a href="http://crossword.thetimes.co.uk/" title="http://crossword.thetimes.co.uk/">The Times Crossword</a> 的新站点,绕开了账户创建相关的摩擦。</li>
+ <li><strong>Persona 易于实现。</strong>开发人员在一个下午就可以把 Persona 添加到站点上。</li>
+ <li>最好的是,<strong>不会被锁定</strong>。 开发人员获取所有他们用户的验证过的邮件地址,而用户可以在 Persona 上使用任何邮件地址。</li>
+ <li><strong>Persona 基于 BrowserID 协议构建。</strong>一旦流行的浏览器供应商实现了 BrowserID<strong>,它们不再需要依赖于 Mozilla 来登入。</strong></li>
+</ol>
+
+<p>继续阅读来开始!</p>
+
+<div class="note"><strong>注意:</strong>Persona 在活跃开发中。关注<a class="external" href="http://identity.mozilla.com/" title="http://identity.mozilla.com/">我们的 blog</a> 来了解新特性,或加入<a class="link-https" href="https://lists.mozilla.org/listinfo/dev-identity" title="https://lists.mozilla.org/listinfo/dev-identity">我们的邮件列表</a>来提供反馈!</div>
+
+<h2 id="在你的站点上使用_Persona">在你的站点上使用 Persona</h2>
+
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h3 id="准备开始">准备开始</h3>
+
+ <dl>
+ <dt><a href="/zh-CN/docs/Persona/Why_Persona" title="zh-CN/BrowserID/Why_BrowserID">为什么使用 Persona?</a></dt>
+ <dd>了解在你的站点上支持 Persona 的原因和它与其它身份验证系统的区别。</dd>
+ <dt><a href="/zh-CN/Persona/Quick_Setup" title="BrowserID/Quick setup">快速安装</a></dt>
+ <dd>一份快捷的攻略,展示了如何向你的网站中添加 Persona。</dd>
+ </dl>
+ </td>
+ <td>
+ <h3 id="Persona_API_参考">Persona API 参考</h3>
+
+ <dl>
+ <dt><a href="/zh-CN/DOM/navigator.id" title="navigator.id">navigator.id API 参考</a></dt>
+ <dd><code>navigator.id</code> 对象的参考,web 开发者可以用此来把 Persona 继承到站点中。</dd>
+ <dt><a href="/zh-CN/Persona/Remote_Verification_API" title="zh-CN/BrowserID/Remote_Verification_API">验证 API 参考</a></dt>
+ <dd>建立在 <code>https://verifier.login.persona.org/verify</code> 上的远程验证 API 的参考。</dd>
+ </dl>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <h3 id="指导">指导</h3>
+
+ <dl>
+ <dt><a href="/zh-CN/Persona/Security_Considerations" title="BrowserID/Security considerations">安全考虑</a></dt>
+ <dd>确保 Persona 部署安全的实践和技术。</dd>
+ <dt><a href="/zh-CN/Persona/Browser_compatibility" title="/Browser_compatibility">浏览器兼容性</a></dt>
+ <dd>准确获知哪些浏览器支持 Persona。</dd>
+ <dt><a href="/zh-CN/Persona/Internationalization" title="/Internationalization">国际化</a></dt>
+ <dd>了解 Persona 如何处理不同的语言。</dd>
+ </dl>
+ </td>
+ <td>
+ <h3 id="资源">资源</h3>
+
+ <dl>
+ <dt><a class="link-https" href="https://github.com/mozilla/browserid/wiki/Persona-Libraries" title="https://github.com/mozilla/browserid/wiki/BrowserID-Libraries">库和插件</a></dt>
+ <dd>寻找你偏好的编程语言、web 框架、博客或是内容管理系统(CMS)的即插库。</dd>
+ <dt><a class="link-https" href="https://github.com/mozilla/browserid-cookbook" title="https://github.com/mozilla/browserid-cookbook">Persona cookbook</a></dt>
+ <dd>Persona 站点的示例源代码。包括 PHP、Node.JS 等等的片段。</dd>
+ <dt><a href="/zh-CN/docs/persona/branding" title="/zh-CN/docs/persona/branding">品牌资源</a></dt>
+ <dd>登入按钮和其它向用户表现 Persona 的图形。</dd>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p> </p>
+
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h2 id="给身份提供者的信息">给身份提供者的信息</h2>
+
+ <p>如果你是一个电子邮件提供商或另一个身份提供服务,翻阅下面的链接来获知如何成为一个 Persona 身份提供者。</p>
+
+ <dl>
+ <dt><a href="/zh-CN/docs/Persona/Identity_Provider_Overview" title="IdP">IdP 概述</a></dt>
+ <dd>Persona 身份提供者的高层视角。</dd>
+ <dt><a href="/zh-CN/Persona/Implementing_a_Persona_IdP" title="Guide to Implementing a Persona IdP">实现一个 IdP</a></dt>
+ <dd>成为一个 IdP 的详细技术细节指导。</dd>
+ <dt><a href="/zh-CN/Persona/IdP_Development_tips" title="Developer tips">开发提示</a></dt>
+ <dd>开发一个新的身份提供者的一系列开发提示和技巧。</dd>
+ <dt><a href="/zh-CN/docs/Persona/.well-known-browserid" title="https://developer.mozilla.org/zh-CN/docs/Persona/.well-known-browserid">.well-known/browserid</a></dt>
+ <dd><code>.well-known/browserid</code> 文件的结构和用途概述,这个文件被 IdPs 用于通知它们支持这个协议。</dd>
+ </dl>
+ </td>
+ <td>
+ <h2 id="Persona_项目">Persona 项目</h2>
+
+ <dl>
+ <dt><a href="/zh-CN/Persona/Glossary" title="navigator.id">术语表</a></dt>
+ <dd>BrowserID 和 Persona 定义的术语。</dd>
+ <dt><a href="/zh-CN/Persona/FAQ" title="zh-CN/BrowserID/FAQ">FAQ</a></dt>
+ <dd>常见问题的回答。</dd>
+ <dt><a href="/zh-CN/Persona/Protocol_Overview" title="BrowserID/Protocol overview">协议概述</a></dt>
+ <dd>底层 BrowserID 协议的中等技术概述。</dd>
+ <dt><a href="/zh-CN/persona/Crypto" title="MDN">加密</a></dt>
+ <dd>一瞥 Persona 和 BrowserID 背后的密码学概念。</dd>
+ <dt><a class="link-https" href="https://github.com/mozilla/id-specs/blob/master/browserid/index.md" title="https://github.com/mozilla/id-specs/blob/master/browserid/index.md">协议规范</a></dt>
+ <dd>这里是深层技术细节。</dd>
+ <dt><a href="/Persona/Bootstrapping_Persona" title="zh-CN/BrowserID/Bootstrapping_BrowserID">Persona 网站</a></dt>
+ <dd>要让 Persona 运作, 我们在<a class="link-https" href="https://login.persona.org" rel="freelink">https://login.persona.org</a> 建立了三个服务:一个备用身份提供者、一个可迁移的 {{ domxref("navigator.id") }} API 实现以及一个身份断言验证服务。</dd>
+ <dt><a href="https://github.com/mozilla/browserid">Persona 源码</a></dt>
+ <dd>Persona 网站背后的源码托管在 GitHub 的一个仓库上。欢迎提交补丁!</dd>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/persona/protocol_overview/index.html b/files/zh-cn/mozilla/persona/protocol_overview/index.html
new file mode 100644
index 0000000000..9e61fb2b95
--- /dev/null
+++ b/files/zh-cn/mozilla/persona/protocol_overview/index.html
@@ -0,0 +1,96 @@
+---
+title: 协议概述
+slug: Mozilla/Persona/Protocol_Overview
+tags:
+ - Persona
+translation_of: Archive/Mozilla/Persona/Protocol_Overview
+---
+<p>Persona is built on the BrowserID protocol. This page describes the BrowserID protocol at a high level.</p>
+
+<h2 id="角色">角色</h2>
+
+<p>The protocol involves three actors:</p>
+
+<ul>
+ <li><strong>Users:</strong> The actual people that want to sign into websites using Persona.</li>
+ <li><strong>Relying Parties (RPs): </strong>Websites that want to let users sign in using Persona.</li>
+ <li><strong>Identity Providers (IdPs): </strong>Domains that can issue Persona-compatible identity certificates to their users.</li>
+</ul>
+
+<p>Persona and the BrowserID protocol use email addresses as identities, so it's natural for email providers to become IdPs.</p>
+
+<p>Mozilla operates a fallback IdP so that users can use any email address with Persona, even one with a specific domain that isn't an IdP itself.</p>
+
+<h2 id="协议步骤">协议步骤</h2>
+
+<p>There are three distinct steps in the protocol:</p>
+
+<ol>
+ <li>User Certificate Provisioning</li>
+ <li>Assertion Generation</li>
+ <li>Assertion Verification</li>
+</ol>
+
+<p>As a prerequisite, the user should have an active identity (email address) that they wish to use when logging in to websites. The protocol does not require that IdP-backed identities are SMTP-routable, but it does require that identities follow the <code>user@domain</code> format.</p>
+
+<h3 id="用户认证过程">用户认证过程</h3>
+
+<p>In order to sign into an RP, a user must be able to prove ownership of their preferred email address. The foundation of this proof is a cryptographically signed certificate from an IdP certifying the connection between a browser's user and a given identity within the IdP's domain.</p>
+
+<p>Because Persona uses standard <a href="http://en.wikipedia.org/wiki/Public-key_cryptography" title="http://en.wikipedia.org/wiki/Public-key_cryptography">public key cryptography</a> techniques, the user certificate is signed by the IdP's private key and contains:</p>
+
+<ul>
+ <li>The user's email address.</li>
+ <li>The user's public key for that address on that browser.</li>
+ <li>The time that the certificate was issued.</li>
+ <li>The time that the certificate expires.</li>
+ <li>The IdP's domain name.</li>
+</ul>
+
+<p>The user's browser generates a different keypair for each of the user's email addresses, and these keypairs are not shared across browsers. Thus, a user must obtain a fresh certificate whenever one expires, or whenever using a new browser or computer. Certificates must expire within 24 hours of being issued.</p>
+
+<p>When a user selects an identity to use when signing into an RP, the browser checks to see if it has a fresh user certificate for that address. If it does, this step is complete and the browser continues with the assertion generation step below. If the browser does not have a fresh certificate, it attempts to obtain one from the domain associated with the chosen identity.</p>
+
+<ol>
+ <li>The browser fetches the <a href="/en-US/docs/Persona/.well-known-browserid" title="/en-US/docs/Persona/.well-known-browserid">/.well-known/browserid</a> support document over SSL from the identity's domain.</li>
+ <li>Using information from the support document, the browser passes the user's email address and associated public key to the IdP and requests a signed certificate.</li>
+ <li>If necessary, the user is asked to sign into the IdP before provisioning proceeds.</li>
+ <li>The IdP creates, signs, and gives a user certificate to the user's browser.</li>
+</ol>
+
+<p>With the certificate in hand, the browser can continue with generating an identity assertion and signing into an RP.</p>
+
+<p><img alt="user-certificate-provisioning.png" class="internal default" src="/@api/deki/files/6043/=user-certificate-provisioning.png"></p>
+
+<h3 id="生成断言">生成断言</h3>
+
+<p>The user certificate establishes a verifiable link between an email address and a public key. However, this is alone not enough to log into a website: the user still has to show their connection to the certificate by proving ownership of the private key.</p>
+
+<p>In order to prove ownership of a private key, the user's browser creates and signs a new document called an "identity assertion." It contains:</p>
+
+<ul>
+ <li>The origin (scheme, domain, and port) of the RP that the user wants to sign into.</li>
+ <li>An expiration time for the assertion, generally less than five minutes after it was created.</li>
+</ul>
+
+<p>The browser then presents both the user certificate and the identity assertion to the RP for verification.</p>
+
+<h3 id="验证断言">验证断言</h3>
+
+<p>The combination of user certificate and identity assertion is sufficient to confirm a user's identity.</p>
+
+<p>First, the RP checks the domain and expiration time in the assertion. If the assertion is expired or intended for a different domain, it's rejected. This prevents malicious re-use of assertions.</p>
+
+<p>Second, the RP validates the signature on the assertion with the public key inside the user certificate. If the key and signature match, the RP is assured that the current user really does possess the key associated with the certificate.</p>
+
+<p>Last, the RP fetches the IdP's public key from its <a href="/en-US/docs/Persona/.well-known-browserid" title="/en-US/docs/Persona/.well-known-browserid">/.well-known/browserid</a> document and verifies that it matches the signature on the user certificate. If it does, then the RP can be certain that the certificate really was issued by the domain in question.</p>
+
+<p>Once verifying that this is a current login attempt for the proper RP, that the user certificate matches the current user, and that the user certificate is legitimate, the RP is done and can authenticate the user as the identity contained in the certificate.</p>
+
+<p><img alt="assertion-generation-and-verify.png" class="internal default" src="/@api/deki/files/6042/=assertion-generation-and-verify.png"></p>
+
+<h2 id="The_Persona_Fallback_IdP">The Persona Fallback IdP</h2>
+
+<p>What if a user's email provider doesn't support Persona? In that case, the provisioning step would fail. By convention, the user's browser handles this by asking a trusted third party, <a href="https://login.persona.org/" title="https://login.persona.org/">https://login.persona.org/</a>, to certify the user's identity on behalf of the unsupported domain. After demonstrating ownership of the address, the user would then receive a certificate issued by the fallback IdP, <code>login.persona.org</code>, rather than the identity's domain.</p>
+
+<p>RPs follow a similar process when validating the assertion: the RP would ultimately request the fallback IdP's public key in order to verify the certificate.</p>
diff --git a/files/zh-cn/mozilla/persona/quick_setup/index.html b/files/zh-cn/mozilla/persona/quick_setup/index.html
new file mode 100644
index 0000000000..e39958eb98
--- /dev/null
+++ b/files/zh-cn/mozilla/persona/quick_setup/index.html
@@ -0,0 +1,140 @@
+---
+title: 快速安装
+slug: Mozilla/Persona/Quick_Setup
+tags:
+ - Mozilla
+ - Persona
+translation_of: Archive/Mozilla/Persona/Quick_Setup
+---
+<p>要把 Persona 登录系统添加到你的站点只需要 5 步:</p>
+<ol>
+ <li>在你的页面中包含 Persona 的 JavaScript 库。</li>
+ <li>添加“登入”和“登出”按钮。</li>
+ <li>监视登入和登出行为。</li>
+ <li>验证用户证书。</li>
+ <li>回顾最佳实现。</li>
+</ol>
+<p>你应该能在一个下午就建立好并运行,但重要的是:如果你要在你的站点上使用 Persona,请花一点时间订阅 <a href="https://mail.mozilla.org/listinfo/persona-notices">Persona 通知</a> 邮件列表。它流量非常低,只用于通知那些对你站点有负面影响的变更或安全问题。</p>
+<h2 id="步骤1:包含_Persona_库">步骤1:包含 Persona 库</h2>
+<p>Persona 被设计为跨浏览器且可在<a href="https://developer.mozilla.org/docs/persona/Browser_compatibility">全部主要桌面和移动浏览器</a>中工作。</p>
+<p>在未来我们期望浏览器提供 Persona 的原生支持,但我们同时提供了一个 JavaScript 库完整地实现了用户界面和客户端部分的协议。通过包含这个库,你的用户会可以用 Persona 登入,无论他们的浏览器是否有原生支持。</p>
+<p>一 旦页面中的这个库加载完毕,你需要的 Persona 函数({{ domxref("navigator.id.watch()", "watch()") }}、{{ domxref("navigator.id.request()", "request()") }} 和 {{ domxref("navigator.id.logout()", "logout()") }})会在全局对象 <code>navigator.id</code> 中可用。</p>
+<p>要包含 Persona JavaScript 库,你可以把这个 <code>script</code> 标签放进你页面的首部:</p>
+<pre class="brush: html;">&lt;script src="https://login.persona.org/include.js"&gt;&lt;/script&gt;
+</pre>
+<p>你<strong>必须</strong>在每个使用 {{ domxref("navigator.id") }} 中函数的页面里包含这个标签。因为 Persona 始终在开发中,你不应该自行托管 <code>include.js</code> 文件。</p>
+<h2 id="步骤2:添加登入登出按钮">步骤2:添加登入/登出按钮</h2>
+<p>因 为 Persona 被设计为一个 DOM API,你必须在用户点击你站点上的登入或登出按钮时调用函数。要打开 Persona 对话框并提示用户登入,你应该调用 {{ domxref("navigator.id.request()") }} 。而登出要调用 {{ domxref("navigator.id.logout()") }} 。</p>
+<p>例如:</p>
+<pre class="brush: js;">var signinLink = document.getElementById('signin');
+if (signinLink) {
+ signinLink.onclick = function() { navigator.id.request(); };
+};
+
+var signoutLink = document.getElementById('signout');
+if (signoutLink) {
+ signoutLink.onclick = function() { navigator.id.logout(); };
+};
+</pre>
+<p>那些按钮的是什么样子的?查看我们的<a href="https://developer.mozilla.org/docs/persona/branding">品牌资源</a>页面中的预制图片和基于 CSS 的按钮!</p>
+<h2 id="步骤3:监视登入登出行为">步骤3:监视登入/登出行为</h2>
+<p>要把 Persona 封装成函数,你需要告诉它当用户登入/登出时做什么。调用 {{ domxref("navigator.id.watch()") }} 函数就可以实现,它支持三个参数:</p>
+<ol>
+ <li>
+ <p>你站点当前用户的 <code>loggedInEmail</code> ,如果没有则为 <code>null</code> 。你应该在渲染页面的时候动态生成它。</p>
+ </li>
+ <li>
+ <p>当触发 <code>onlogin</code> 行为的时候调用的函数。这个函数会被传递一个必须认证的“身份断言”参数。</p>
+ </li>
+ <li>
+ <p>当触发 <code>onlogout</code> 行为的时候调用的函数。这个函数不会被传递任何参数。</p>
+ </li>
+</ol>
+<div class="note style-wrap">
+ <p><strong>注意:</strong>你必须总是在调用 {{ domxref("navigator.id.watch()") }} 时同时包含 <code>onlogin</code> 和 <code>onlogout</code> 。</p>
+</div>
+<p>例如,如果你现在认为鲍勃已经登入到你的站点,你会这样做:</p>
+<pre class="brush: js;">var currentUser = 'bob@example.com';
+
+navigator.id.watch({
+ loggedInUser: currentUser,
+ onlogin: function(assertion) {
+ // 一个用户已经登入!这是你需要做的:
+ // 1. 把断言发送到后端验证并创建一个会话。
+ // 2. 更新你的 UI。
+ $.ajax({ /* &lt;-- 本例使用了 jQuery,但你也可以用你想用的 */
+ type: 'POST',
+ url: '/auth/login', // 这是你网站上的一个 URL
+ data: {assertion: assertion},
+ success: function(res, status, xhr) { window.location.reload(); },
+ error: function(res, status, xhr) { alert("登入失败" + res); }
+ });
+ },
+ onlogout: function() {
+ // 一个用户已经登出!这是你需要做的:
+ // 销毁用户的会话并重定向用户或做后端的调用。
+ // 同样,让 loggedInUser 在下个页面加载时变为 null。
+ // (这是一个字面的 JavaScript null。不是 false、 0 或 undefined。null。)
+ $.ajax({
+ type: 'POST',
+ url: '/auth/logout', // 这是你网站上的一个 URL
+ success: function(res, status, xhr) { window.location.reload(); },
+ error: function(res, status, xhr) { alert("登出失败" + res); }
+ });
+ }
+});
+</pre>
+<p>在本例中,<code>onlogin</code> 和 <code>onlogout</code> 都通过向你站点的后端发送异步 <code>POST</code> 请求来实现。后端随后通常用设定或删除会话 cookie 中的信息来登入或登出用户。之后,如果一切都核对无误,页面重加载来考虑账户的新登录状态。</p>
+<p>你当然可以用 AJAX 来不用重加载或重定向来实现,但这超出了本教程的范畴。</p>
+<p>你<strong>必须</strong>在每个有登入/登出按钮的页面上调用这个函数。要为用户支持 Persona 加强功能,诸如自动登录和全局登出,你<strong>应该</strong>在网站上的每个页面都调用这个函数。</p>
+<h2 id="步骤4:验证用户证书">步骤4:验证用户证书</h2>
+<p>Persona 用“身份断言”来代替密码,那是一种类似一次性、单站点的、用户邮件地址捆绑的密码。当用户想要登入时,你的 <code>onlogin</code> 回调会传入一个该用户的断言来调用。在你登入他们前,你必须验证断言的有效性。</p>
+<p>在你的服务器上而不是用户浏览器上运行的 JavaScript 中验证断言是<em>极度</em>重要的,因为那很容易伪造。上面的例子用 jQuery 的 <code>$.ajax()</code> 辅助函数来把断言通过 <code>POST</code> 到 <code>/auth/login</code> 来呈递给后端。</p>
+<p>一旦你的服务器获得了断言,你如何验证它?最简单的方法是用 Mozilla 提供的辅助服务。简单地把断言以两个参数 <code>POST</code> 给 <code>https://verifier.login.persona.org/verify</code>:</p>
+<ol>
+ <li><code>assertion</code>: 用户提供的身份断言。</li>
+ <li><code>audience</code>: 你网站的主机名和端口。你必须在后端硬编码这个值;不要从用户提供的任何数据中派生这个值。</li>
+</ol>
+<p>例如,如果你是 <code>example.com</code>,你可以用下面的命令行来测试断言:</p>
+<pre class="brush: bash;">$ curl -d "assertion=&lt;ASSERTION&gt;&amp;audience=https://example.com:443" "https://verifier.login.persona.org/verify"
+</pre>
+<p>如果它是有效的,你会得到像这样的一个 JSON 响应:</p>
+<pre class="brush: js;">{
+ "status": "okay",
+ "email": "bob@eyedee.me",
+ "audience": "https://example.com:443",
+ "expires": 1308859352261,
+ "issuer": "eyedee.me"
+}
+</pre>
+<p>你可以阅读<a href="https://developer.mozilla.org/en-US/docs/BrowserID/Remote_Verification_API">验证服务 API</a>来获知更多关于验证服务的内容。一个 <code>/api/login</code> 实现的使用了 <a href="http://python.org/">Python</a>、<a href="http://flask.pocoo.org/">Flask</a> web 框架和 <a href="http://python-requests.org">Requests</a> HTTP 库的例子看起来是这样:</p>
+<pre class="brush: python;">@app.route('/auth/login', methods=['POST'])
+def login():
+ # 请求必须包含我们要验证的断言
+ if 'assertion' not in request.form:
+ abort(400)
+
+ # 把断言发送给 Mozilla 的验证服务
+ data = {'assertion': request.form['assertion'], 'audience': 'https://example.com:443'}
+ resp = requests.post('https://verifier.login.persona.org/verify', data=data, verify=True)
+
+ # 验证器响应了吗?
+ if resp.ok:
+ # 处理响应
+ verification_data = json.loads(resp.content)
+
+ # 检查断言是否有效
+ if verification_data['status'] == 'okay':
+ # 设置一个安全会话 cookie 来登入用户
+ session.update({'email': verification_data['email']})
+ return resp.content
+
+ # 哎哟,有什么东西不对,放弃
+ abort(500)
+</pre>
+<p>会话管理可能很像你现有的登录系统。首先的大区别是在验证用户身份采用了检查断言而不是检查密码。另一个不同是确保用户的邮件地址有效来用于 {{ domxref("navigator.id.watch()") }} 的 <code>loggedInEmail</code> 参数</p>
+<p>登出很简单:你只需要移除用户的会话 cookie。</p>
+<h2 id="步骤5:回顾最佳实践">步骤5:回顾最佳实践</h2>
+<p>一旦所有的东西都工作正常并且你已经成功登入和登出你的站点,你应该花一会时间来回顾安全可靠地使用 Persona 的<a href="https://developer.mozilla.org/docs/BrowserID/Security_Considerations">最佳实践</a>。</p>
+<p>如果你在做一个要作为生产环境的站点,你会想要编写集成的测试来模拟用 Persona 登入或登出用户。要改善 Selenium 中的这个行为,请考虑使用 <a href="https://github.com/mozilla/bidpom" title="https://github.com/mozilla/bidpom">bidpom</a> 库。<a href="https://mockmyid.com/" title="https://mockmyid.com/">mockmyid.com</a> 和 <a href="http://personatestuser.org" title="http://personatestuser.org">personatestuser.org</a> 这两个网站也可能会有用。</p>
+<p>最后,不要忘记登记加入 <a href="https://mail.mozilla.org/listinfo/persona-notices">Persona 通知</a> 邮件列表,这样会通知你任何安全问题或 Persona API 的向后兼容变更。这个列表的流量非常低:它只用于通知会对你的站点造成负面影响的变更。</p>
diff --git a/files/zh-cn/mozilla/persona/remote_verification_api/index.html b/files/zh-cn/mozilla/persona/remote_verification_api/index.html
new file mode 100644
index 0000000000..55f37e793e
--- /dev/null
+++ b/files/zh-cn/mozilla/persona/remote_verification_api/index.html
@@ -0,0 +1,120 @@
+---
+title: 远程验证 API
+slug: Mozilla/Persona/Remote_Verification_API
+translation_of: Archive/Mozilla/Persona/Remote_Verification_API
+---
+<h3 id="Summary" name="Summary">概述</h3>
+<p>当用户试图登入一个网站,他们的浏览器会生成一个名为<em>断言</em>的数据结构,这实质上是一个加密签名的邮件地址。浏览器把这个断言发送给网站,网站必须在登入用户前检验断言是否有效。</p>
+<p>断言可以本地验证,或使用托管在 <span class="link-https"><code>https://verifier.login.persona.org/verify</code></span> 的 API。本页面描述如何使用这个 API。</p>
+<h3 id="Methods" name="Methods">方法</h3>
+<p>把 HTTP POST 请求发送至 <code>https://verifier.login.persona.org/verify</code>。</p>
+<h3 id="参数">参数</h3>
+<p><code>assertion</code>: 断言由用户提供。作为传给  {{ domxref("navigator.id.watch()") }} 中 <code>onlogin</code>  函数的第一个参数。<br>
+ <code>audience</code>: 你的站点的协议、域名和端口。 例如, "<code>https://example.com:443</code>"。</p>
+<h3 id="返回值">返回值</h3>
+<p>调用会返回一个包含 <code>status</code> 元素的 JSON 结构,这个元素值会是 "okay" 或是" failure" 。取决于 <code>status</code> 的值,这个结构包含下面列出的额外元素。</p>
+<h4 id="okay">"okay"</h4>
+<p>断言是有效的。</p>
+<p>在这种情况下 JSON 结构包含下面的额外元素:</p>
+<table style="width: 80%;">
+ <tbody>
+ <tr>
+ <td><code>"email"</code></td>
+ <td>断言中包含欲登录人的邮件地址。</td>
+ </tr>
+ <tr>
+ <td><code>"audience"</code></td>
+ <td>断言中包含 audience 值。 期望值为你的网站 URL。</td>
+ </tr>
+ <tr>
+ <td>"<code>expires"</code></td>
+ <td>断言过期的日期,表示为<a href="/en/JavaScript/Reference/Global_Objects/Date/valueOf" title="en/JavaScript/Reference/Global_Objects/Date/valueOf">Date 对象的原始值</a>: 即从 UTC 1970 年 1 月 1 日午夜至今的毫秒数。</td>
+ </tr>
+ <tr>
+ <td><code>"issuer"</code></td>
+ <td>发出断言的身份提供者的主机名。</td>
+ </tr>
+ </tbody>
+</table>
+<h4 id="failure">"failure"</h4>
+<p>断言是无效的。这种情况下,JSON 结构包含一个额外元素:</p>
+<table>
+ <tbody>
+ <tr>
+ <td><code>"reason"</code></td>
+ <td>一个解释验证失败原因的字符串。</td>
+ </tr>
+ </tbody>
+</table>
+<h3 id="示例">示例</h3>
+<h4 id="node.js">node.js</h4>
+<p>例中使用了一个采用 express.js 的 node.js 服务器</p>
+<pre class="brush: js">var express = require("express"),
+ app = express.createServer(),
+ https = require("https"),
+ querystring = require("querystring");
+/* ... */
+
+// audience 值必须匹配你浏览器地址栏显示的值,
+// 包括协议、主机名、端口
+var audience = "http://localhost:8888";
+
+app.post("/authenticate", function(req, res) {
+ var vreq = https.request({
+ host: "verifier.login.persona.org",
+ path: "/verify",
+ method: "POST"
+ }, function(vres) {
+ var body = "";
+ vres.on('data', function(chunk) { body+=chunk; } )
+ .on('end', function() {
+ try {
+ var verifierResp = JSON.parse(body);
+ var valid = verifierResp &amp;&amp; verifierResp.status === "okay";
+ var email = valid ? verifierResp.email : null;
+ req.session.email = email;
+ if (valid) {
+ console.log("assertion verified successfully for email:", email);
+ } else {
+ console.log("failed to verify assertion:", verifierResp.reason);
+ }
+ res.json(email);
+ } catch(e) {
+ console.log("non-JSON response from verifier");
+ // bogus response from verifier! return null
+ res.json(null);
+ }
+ });
+ });
+ vreq.setHeader('Content-Type', 'application/x-www-form-urlencoded');
+
+ var data = querystring.stringify({
+ assertion: req.body.assertion,
+ audience: audience
+ });
+ vreq.setHeader('Content-Length', data.length);
+ vreq.write(data);
+ vreq.end();
+ console.log("verifying assertion!");
+});
+
+</pre>
+<p>via <a class="link-https" href="https://github.com/lloyd/myfavoritebeer.org/blob/06255b960e1f9078bc935c1c7af0662f33c88818/server/main.js#L112" title="https://github.com/lloyd/myfavoritebeer.org/blob/06255b960e1f9078bc935c1c7af0662f33c88818/server/main.js#L112">Lloyd Hilaiel</a></p>
+<h4 id="PHP">PHP</h4>
+<pre class="brush: php">$url = 'https://verifier.login.persona.org/verify';
+$assert = $_POST['assert'];
+$params = 'assertion='.$assert.'&amp;audience=' .
+ urlencode('http://example.com:80');
+$ch = curl_init();
+$options = array(
+ CURLOPT_URL =&gt; $url,
+ CURLOPT_RETURNTRANSFER =&gt; TRUE,
+ CURLOPT_POST =&gt; 2,
+ CURLOPT_POSTFIELDS =&gt; $params
+);
+curl_setopt_array($ch, $options);
+$result = curl_exec($ch);
+curl_close($ch);
+echo $result;
+</pre>
+<p>Via <a class="link-https" href="https://github.com/codepo8/BrowserID-login-with-PHP/blob/184fdb74c8a554461c262875859968154d09288e/verify.php">Christian Heilmann</a></p>
diff --git a/files/zh-cn/mozilla/persona/security_considerations/index.html b/files/zh-cn/mozilla/persona/security_considerations/index.html
new file mode 100644
index 0000000000..d955e82d13
--- /dev/null
+++ b/files/zh-cn/mozilla/persona/security_considerations/index.html
@@ -0,0 +1,55 @@
+---
+title: 安全考虑
+slug: Mozilla/Persona/Security_Considerations
+translation_of: Archive/Mozilla/Persona/Security_Considerations
+---
+<p>When you add Persona support to your website, Persona takes on as much of the security burden as it can. However, some aspects of security can only be handled by your website. They're listed below.</p>
+<h2 id="Essential_practices" name="Essential_practices">Essential practices</h2>
+<h3 id="Verify_assertions_on_your_server" name="Verify_assertions_on_your_server">Verify assertions on your server</h3>
+<p>When using Persona, identity assertions are passed into the <code>onlogin</code> function passed to {{ domxref("navigator.id.watch()") }}. You should <em>always</em> pass the assertion to your server for verification, and only your server should decide to grant the user additional permissions based on the verification result:</p>
+<pre class="brush:js;">// Inside navigator.id.watch({ ...
+onlogin: function(assertion) {
+ // A user wants to log in! Here you need to:
+ // 1. Send the assertion to your backend for verification and to create a session.
+ // 2. Update your UI.
+},
+</pre>
+<p>If you try to verify the assertion using the JavaScript executing in the user's browser, then a malicious user will be able to impersonate a legitimate user of your site by locally injecting code and subverting your JavaScript. This is possible because you're not fully in control of the user's browser, where the code executes.</p>
+<p>Again, you should <em>always</em> pass the assertion to your server for verification. Even if you're using the remote verification API.</p>
+<h3 id="Explicitly_specify_the_audience_parameter" name="Explicitly_specify_the_audience_parameter">Explicitly specify the audience parameter</h3>
+<p>To verify an assertion, you may issue a POST request to<code> https://verifier.login.persona.org/verify</code>. The request includes a parameter called <code>audience</code>:</p>
+<pre><code>assertion=&lt;ASSERTION&gt;&amp;audience=https://mysite.com:443"</code></pre>
+<p>The <code>audience</code> parameter is required. You should always specify the audience explicitly in your code, or in your code's configuration. Specifically:</p>
+<ul>
+ <li>Do not trust the Host header sent by the user's browser.</li>
+ <li>Do not trust an explicit parameter sent by the user's browser, but generated by your JavaScript using, e.g. <code>document.location</code>.</li>
+</ul>
+<p>If you trust the user's browser to tell you the audience, then it becomes possible for a malicious web site to reuse assertions for <em>its</em> web site to log into <em>your</em> web site.</p>
+<h3 id="Verify_SSL_certificates" name="Verify_SSL_certificates">Verify SSL certificates</h3>
+<p>To verify an assertion, you may issue a POST request to <code>https://verifier.login.persona.org/verify</code>. You must ensure that your HTTPS request verifies the certificate sent from the server against a trusted root certificate. If you don't, then an attacker could pose as <code>verifier.login.persona.org</code> and issue false verifications.</p>
+<p>Check that the library you are using to make the request verifies certificates correctly, and that you are initializing it with the appropriate root certificate(s).</p>
+<p>For example, Python 2.7's standard <a class="external" href="http://docs.python.org/release/2.7.3/library/urllib2.html#urllib2.urlopen" title="http://docs.python.org/release/2.7.3/library/urllib2.html#urllib2.urlopen">urllib2 module</a> does not validate server certificates. Instead, we recommend using the "<a class="external" href="http://pypi.python.org/pypi/requests">requests</a>" or "<a class="external" href="http://pypi.python.org/pypi/urllib3" title="http://pypi.python.org/pypi/urllib3">urllib3</a>" modules in Python 2.x, or the standard <code>http.client.HTTPSConnection</code> class in Python 3.x. For Perl, ensure that you are using at least version 6.0 of <code>libwww-perl</code>. Depending on the language, library, and operating system that you're using, you may need to supply either a list of trusted CA roots or the single CA used by <code>verifier.login.persona.org</code>.</p>
+<h3 id="Implement_CSRF_protection" name="Implement_CSRF_protection">Implement CSRF protection</h3>
+<p>In a CSRF (Cross-Site Request Forgery) login attack, an attacker uses a cross-site request forgery to log the user into a web site using the attacker's credentials.</p>
+<p>For example: a user visits a malicious web site containing a <code>form</code> element. The form's <code>action</code> attribute is set to an HTTP POST request to <a class="external" href="http://www.google.com/login" title="http://www.google.com/login">http://www.google.com/login</a>, supplying the attacker's username and password. When the user submits the form, the request is sent to Google, the login succeeds and the Google server sets a cookie in the user's browser. Now the user's unknowingly logged into the attacker's Google account.</p>
+<p>The attack can be used to gather sensitive information about the user. For example, Google's <a class="link-https" href="https://www.google.com/history/">Web History</a> feature logs all the user's Google search terms. If a user is logged into the attacker's Google account and the attacker has Web History enabled, then the user is giving the attacker all this information.</p>
+<p>CSRF login attacks, and potential defenses against them, are documented more fully in <a class="external" href="http://www.adambarth.com/papers/2008/barth-jackson-mitchell-b.pdf">Robust Defenses for Cross-Site Request Forgery</a> (PDF). They're not specific to Persona: most login mechanisms are potentially vulnerable to them.</p>
+<p>There are a variety of techniques which can be used to protect a site from CSRF login attacks, which are documented more fully in the study above.</p>
+<p>One approach is to create a secret identifier in the server, shared with the browser, and require the browser to supply it when making login requests. For example:</p>
+<ol>
+ <li>As soon as the user lands on your site, before they try to log in, create a session for them on the server. Store the session ID in a browser cookie.</li>
+ <li>On the server, generate a random string of at least 10 alphanumeric characters. A randomly generated UUID is a good option. This is the CSRF token. Store it in the session.</li>
+ <li>Deliver the CSRF token to the browser by either embedding it in JavaScript or HTML as a hidden form variable.</li>
+ <li>Ensure that the AJAX submission or form POST includes the CSRF token.</li>
+ <li>On the server side, before accepting an assertion, check that the submitted CSRF token matches the session-stored CSRF token.</li>
+</ol>
+<h2 id="Enhancements" name="Enhancements">Enhancements</h2>
+<h3 id="Content_Security_Policy_(CSP)" name="Content_Security_Policy_(CSP)">Content Security Policy (CSP)</h3>
+<p><a href="/en-US/docs/Security/CSP" title="Security/CSP">Content Security Policy</a> (CSP) is an added layer of security that helps to detect and mitigate certain types of attacks, including Cross Site Scripting (XSS) and data injection attacks. These attacks are used for everything from data theft to site defacement or distribution of malware.</p>
+<p>If you use CSP on your site, you may need to tweak your policy to enable Persona. Depending on your policy, you may need to:</p>
+<ul>
+ <li>Remove inline <code>javascript:</code> URIs and replace them with code loaded from an additional script file. The file can look up elements based on their ID, and then attach to the element by setting {{ domxref("element.onclick", "onclick") }} or calling {{ domxref("element.addEventListener()", "addEventListener()") }}.</li>
+ <li>Allow <code>https://login.persona.org</code> as both a <code>script-src</code> and <code>frame-src</code> so that your site can load the remote <code>include.js</code> file and that file can communicate with the fallback Persona implementation.</li>
+</ul>
+<p>An example Apache configuration might include:</p>
+<pre><span class="diff-content"><span class="idiff">Header set X-Content-Security-Policy: "default-src 'self'; frame-src 'self' https://login.persona.org ; script-src 'self' https://login.persona.org"</span></span></pre>
diff --git a/files/zh-cn/mozilla/persona/why_persona/index.html b/files/zh-cn/mozilla/persona/why_persona/index.html
new file mode 100644
index 0000000000..d7d96a46fc
--- /dev/null
+++ b/files/zh-cn/mozilla/persona/why_persona/index.html
@@ -0,0 +1,30 @@
+---
+title: 为什么使用 Persona?
+slug: Mozilla/Persona/Why_Persona
+translation_of: Archive/Mozilla/Persona/Why_Persona
+---
+<p style="">流行的用户名和密码系统并非长久之计:用户需要为每个他们使用的站点和服务创建并记住一个新的、复杂的密码,并且每个站点都要安全地存储密码。尽管如此,最近的事故证明了即使是巨头级的大公司也在密码安全上失误,这让他们的用户信息暴露在风险中。</p>
+<p style="">Persona 是一个开放的、分布式、web 规模的身份识别系统,它取代了每个网站一个密码的局面。它解决了像 OpenID 这样系统的可用性和隐私相关的缺点而不诉诸于 Facebook Connect 这样的中心化基础架构。</p>
+<h2 id="Persona_摆脱了每站一密码">Persona 摆脱了每站一密码</h2>
+<p>Persona 让用户在完成一个用于身份识别的简单一次性过程后只需点击两次即可登入网站,而不是每站一密码。这是在公钥密码学上构建的,安全可靠。用户的浏览器生成一个加密的“身份断言”来代替密码,它在几分钟后会过期并只在单个站点上有效。因为没有站点特定的密码,使用 Persona 的网站不需要关心密码数据库如何妥善存储或是丢失隐患。</p>
+<p>这个快捷的登入过程也减少了用户访问新站点的摩擦。</p>
+<h2 id="Persona_身份是电子邮件地址">Persona 身份是电子邮件地址</h2>
+<p>Persona 使用邮件地址作为身份,而不是任意形式的用户名。这让用户和开发者有所裨益:</p>
+<h3 id="用户使用邮件地址的优势">用户使用邮件地址的优势</h3>
+<ul>
+ <li>用户已经知道他们的邮件地址,相反,用 OpenID 要学习新的且可能令人困惑的 URL。</li>
+ <li>电子邮件地址灵巧地捕捉了 <code>someone@some-context</code> 的概念,易于用户区分 <code>@work</code>、 <code>@home</code> 或 <code>@school</code> 的身份。这与像 Facebook 和 Google+ 社交网络上的通过实名、单账号策略的身份合并趋势不同。</li>
+ <li>电子邮件可以自托管或委托给其它服务商,用户可以控制他们的身份。</li>
+</ul>
+<h3 id="开发者使用邮件地址的优势">开发者使用邮件地址的优势</h3>
+<ul>
+ <li>邮件地址让开发者可以直接联系他们的用户。</li>
+ <li>大多数站点需要他们用户提供邮件地址,Persona 会在用户登入时自动提供,消除了额外的注册表单。</li>
+ <li>许多登录系统已经把邮件作为唯一键。这意味着不仅会被 Person 束缚,而且它可以与现有的登录系统并列部署。</li>
+</ul>
+<p>更不必说电子邮件已经是一个横跨无数服务提供者的有数以亿计账户的分布式系统。</p>
+<h2 id="Persona_与其它单点登录服务提供商有何区别?" style="">Persona 与其它单点登录服务提供商有何区别?</h2>
+<p>Persona 安全、可靠,并且简单。它用其它提供商保护不用或不能的方法来用户隐私、用户控制和用户选择:</p>
+<p>许多社交网络,诸如 Facebook 和 Google+,需要用户使用真名,并限制用户到单个账户。通过构建在邮件地址上,Persona 允许用户区分它们的工作、家庭、学校以及其它身份。</p>
+<p>Persona 是开放的,也是分布式的:任何有电子邮件地址的人都可以登入使用 Persona 的站点。除此之外,任何人可以建立他们自己的身份提供者或委托给其它的权威机构,就像用电子邮件。这与需要一个单一中心化服务账号的社交登录服务相反。</p>
+<p>Persona 也通过把用户浏览器放进认证过程中来提供保护用户隐私的新颖手段:浏览器从用户的邮件提供商获取证书,然后转向并把那些证书呈递给网站。电子邮件供应商不可能追踪用户,但网站仍然可以通过密码学验证证书来继续信任用户。大多数其它系统,即使是如 OpenID 这样的分布式系统,需要站点“背景连接通信(phone home)”才允许用户登入。</p>
diff --git a/files/zh-cn/mozilla/preferences/index.html b/files/zh-cn/mozilla/preferences/index.html
new file mode 100644
index 0000000000..442d12a5db
--- /dev/null
+++ b/files/zh-cn/mozilla/preferences/index.html
@@ -0,0 +1,6 @@
+---
+title: Preferences
+slug: Mozilla/Preferences
+translation_of: Mozilla/Preferences
+---
+This page was auto-generated because a user created a sub-page to this page.
diff --git a/files/zh-cn/mozilla/preferences/mozilla_networking_preferences/index.html b/files/zh-cn/mozilla/preferences/mozilla_networking_preferences/index.html
new file mode 100644
index 0000000000..117fa5d6af
--- /dev/null
+++ b/files/zh-cn/mozilla/preferences/mozilla_networking_preferences/index.html
@@ -0,0 +1,536 @@
+---
+title: Mozilla 网络相关首选项
+slug: Mozilla/Preferences/Mozilla_networking_preferences
+translation_of: Mozilla/Preferences/Mozilla_networking_preferences
+---
+<h3 id="Abstract" name="Abstract">摘要</h3>
+<p>本文列出了影响网络行为的首选项,并描述了可接受的值和行为。</p>
+<h3 id="Audience" name="Audience">受众</h3>
+<p>质量保证测试员、开发者以及熟知网络内部原理的骨灰级用户。<br>
+ 要想获取关于首选项(包括如何编辑)的通用技术文档,请参阅“有关 Mozilla 首选项的简要指南”一文。</p>
+<p>本文的目标是准确地记录有关 Core-Necko 的行为及是否在 Firefox 中默认存在的信息。</p>
+<h3 id="Feedback" name="Feedback">概观</h3>
+<p>The sections are in roughly alphabetical + functional order. The preferences are in order of usage by the UI (which is not often alphabetical order). Relevant bugs are provided only when absolutely necessary.</p>
+<div class="note">
+ <p>Note: Do not change any of these via <code>about:config</code> unless <strong>you know what you are doing</strong>. If you are uncertain what that phrase means, you probably do not.</p>
+</div>
+<p>If you qualify, you are probably one or more of the following:</p>
+<ul>
+ <li>You have a feature-spec or code-level understanding of the preference.</li>
+ <li>You are doing testing and have a clear performance metric.</li>
+ <li>You are doing this in conjunction with a packet trace to monitor Necko's changed behavior.</li>
+</ul>
+<h3 id="Preferences" name="Preferences">首选项</h3>
+<h4 id="HTTP_.28this_section_under_construction.29" name="HTTP_.28this_section_under_construction.29">HTTP(本部分仍在建设中)</h4>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>首选项名称</th>
+ <th>可接受的值</th>
+ <th>首选项是否默认存在及其他说明</th>
+ </tr>
+ <tr>
+ <td><code>general.useragent.contentlocale</code></td>
+ <td>string</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>general.useragent.misc</code></td>
+ <td>(major version number) string</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>general.useragent.security</code></td>
+ <td>string</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>network.http.accept-encoding</code></td>
+ <td><code>gzip,deflate</code> (default string)</td>
+ <td>no UI</td>
+ </tr>
+ <tr>
+ <td><code>network.http.accept.default</code></td>
+ <td><code>text/xml,application/xml,<br>
+ application/xhtml+xml,text/html;</code><br>
+ <code>q=0.9,text/plain;</code><br>
+ <code>q=0.8,video/x-mng,image/png,<br>
+ image/jpeg,image/gif;</code><br>
+ <code>q=0.2,*/*;q=0.1</code></td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>network.http.default-socket-type</code></td>
+ <td>(empty) default</td>
+ <td>?</td>
+ </tr>
+ <tr>
+ <td><code>network.http.keep-alive</code></td>
+ <td><code>true</code> (default)</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>network.http.keep-alive.timeout</code></td>
+ <td><code>30</code></td>
+ <td>no UI</td>
+ </tr>
+ <tr>
+ <td><code>network.http.max-connections</code></td>
+ <td><code>96</code></td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>network.http.max-connections-per-server</code></td>
+ <td><code>32</code></td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>network.http.max-persistent-connections-per-proxy</code></td>
+ <td><code>4</code></td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>network.http.max-persistent-connections-per-server</code></td>
+ <td><code>8</code></td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><a class="external" href="http://kb.mozillazine.org/Network.http.pipelining" title="http://kb.mozillazine.org/Network.http.pipelining"><code>network.http.pipelining</code></a></td>
+ <td><code>True</code></td>
+ <td>? (on in mozilla, greyed)</td>
+ </tr>
+ <tr>
+ <td><code>network.http.pipelining.firstrequest</code></td>
+ <td><code>True</code></td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>network.http.pipelining.maxrequests</code></td>
+ <td><code>8</code></td>
+ <td> Hard-coded to 8 max so 30 will have no greater affect</td>
+ </tr>
+ <tr>
+ <td><code>network.http.proxy.keep-alive</code></td>
+ <td><code>true</code> (default)</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>network.http.proxy.pipelining</code></td>
+ <td><code>True</code></td>
+ <td>? (on in mozilla, greyed)</td>
+ </tr>
+ <tr>
+ <td><code>network.http.proxy.version</code></td>
+ <td><code>1.1</code> (default)<br>
+ <code>1.0</code></td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>network.http.redirection-limit</code></td>
+ <td><code>20</code></td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>network.http.request.max-start-delay</code></td>
+ <td><code>10</code></td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>network.http.sendRefererHeader</code></td>
+ <td><code>2</code></td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>network.http.sendSecureXSiteReferrer</code></td>
+ <td><code>true</code></td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>network.http.use-cache</code></td>
+ <td><code>true</code></td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>network.http.version</code></td>
+ <td><code>1.1</code> (default)<br>
+ <code>1.0</code></td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+<h4 id="File" name="File">文件</h4>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>首选项名称</th>
+ <th>Acceptable Values</th>
+ <th>Preferences UI and comments</th>
+ </tr>
+ <tr>
+ <td><code>security.checkloaduri</code></td>
+ <td><strong><code>true</code> (default)</strong><br>
+ <code>false</code></td>
+ <td>No UI<br>
+ <code>checkloaduri</code> will disable file:// URLs on pages from a network (http: https: ftp:) source, for security reasons.<br>
+ Errors are sent to the javascript console, not to the user via dialog box. This preference only works in Gecko versions before 1.8 (so Firefox 1.0 and Mozilla Suite builds). In Firefox 1.5 and Seamonkey 1.0 this preference no longer has an effect.</td>
+ </tr>
+ </tbody>
+</table>
+<h4 id="FTP_.28see_also_Proxy.29" name="FTP_.28see_also_Proxy.29">FTP(另请参见“代理”部分)</h4>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>首选项名称</th>
+ <th>Acceptable Values</th>
+ <th>Preferences UI (in bold) and comments</th>
+ </tr>
+ <tr>
+ <td><code>advanced.mailftp</code></td>
+ <td><strong><code>false</code> (default)</strong><br>
+ <code>true</code></td>
+ <td>Preferences | Advanced |<br>
+ "<strong>{{ mediawiki.external('x') }} Set this email address as anonymous FTP password:</strong>"<br>
+ <br>
+ If false, FTP uses "<code><a class="link-mailto" href="mailto:mozilla@example.com" rel="freelink">mozilla@example.com</a></code>" as anonymous FTP password ({{ Bug("101027") }})<br>
+ If true, FTP uses contents of <code>network.ftp.anonymous_password</code> for anonymous FTP password ({{ Bug("57763") }} comment 28)</td>
+ </tr>
+ <tr>
+ <td><code>network.ftp.anonymous_password</code></td>
+ <td><strong><code>empty</code> (default)<br>
+ any text string</strong></td>
+ <td>Preferences | Advanced |<br>
+ (under "{{ mediawiki.external(' ') }} Set this email address as anonymous FTP password:")<br>
+ <strong>{{ mediawiki.external('text field') }}</strong><br>
+ <br>
+ If empty, FTP uses "<code><a class="link-mailto" href="mailto:mozilla@example.com" rel="freelink">mozilla@example.com</a></code>" as anonymous FTP password.</td>
+ </tr>
+ <tr>
+ <td><code>network.ftp.idleConnectionTimeout</code></td>
+ <td><strong><code>300</code> (default)</strong><br>
+ any integer</td>
+ <td>No UI<br>
+ Measured in seconds<br>
+ The open connection can prevent other FTP clients on your system from connecting to sites that allow only one control connection ({{ Bug("117875") }})</td>
+ </tr>
+ <tr>
+ <td><code>network.dir.format</code></td>
+ <td><code>0</code> = HTML view<br>
+ <code>1</code> = raw view<br>
+ <code>2</code> = HTML view<br>
+ <code>3</code> = XUL view</td>
+ <td>Preferences | Debug | Networking<br>
+ Networking<br>
+ Directory Listing Format<br>
+ <strong>( ) HTML</strong><br>
+ <strong>( ) XUL (tree-based)</strong></td>
+ </tr>
+ </tbody>
+</table>
+<h4 id="Cache" name="Cache">缓存</h4>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>首选项名称</th>
+ <th>Acceptable Values</th>
+ <th>Preferences UI (in bold) and comments</th>
+ </tr>
+ <tr>
+ <td><code>browser.cache.disk.capacity</code></td>
+ <td>
+ <p><strong><code>256000</code> (default)</strong></p>
+ <p>any integer (in KB)</p>
+ </td>
+ <td>
+ <p>Preferences | Advanced | Cache<br>
+ <strong>Cache: {{ mediawiki.external('MB') }} MB</strong></p>
+ <div class="note">
+ <strong>Note:</strong> The default was 51200 prior to Gecko 9.0 {{ geckoRelease("9.0") }}.</div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>browser.cache.disk.parent_directory</code></td>
+ <td><strong>path to Cache folder in profile (default)</strong></td>
+ <td>
+ <p><strong>Cache Folder: {{ mediawiki.external('text box') }}</strong></p>
+ <div class="note">
+ <strong>Note:</strong> The contents of the disk and memory caches are different (a very large memory cache is not the same as pointing disk cache to memory mapped disk space (RAM disk).</div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>browser.cache.disk.max_entry_size</code></td>
+ <td>
+ <p><strong><code>51200</code> (default)</strong></p>
+ <p>-1 = no limit</p>
+ </td>
+ <td>
+ <p>The maximum size of an entry in the disk cache.</p>
+ <div class="note">
+ <strong>Note:</strong> Items larger than 1/8 of <code>browser.cache.disk.capacity</code> are never cached.</div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>browser.cache.check_doc_frequency</code></td>
+ <td><code>1</code> = Every time I view the page<br>
+ <code>0</code> = Once per session<br>
+ <code>3</code> = When the page is out of date (default)<br>
+ <code>2</code> = Never</td>
+ <td><strong>Compare the page in cache to the page on the network:</strong></td>
+ </tr>
+ <tr>
+ <td><code>browser.cache.disk.enable</code></td>
+ <td><strong><code>true</code> (default)</strong></td>
+ <td colspan="1" rowspan="2">Preferences | Debug | Cache<br>
+ <strong>{{ mediawiki.external('x') }} Enable Disk Cache</strong><br>
+ <strong>{{ mediawiki.external('x') }} Enable Memory Cache</strong><br>
+ <br>
+ Disabling disk cache has the effect of setting it to zero.</td>
+ </tr>
+ <tr>
+ <td><code>browser.cache.memory.enable</code></td>
+ <td><strong><code>true</code> (default)</strong></td>
+ </tr>
+ <tr>
+ <td><code>browser.cache.memory.capacity</code></td>
+ <td>any integer (in KB)</td>
+ <td>Replaced by automatic sizing in Mozilla 1.4b ({{ Bug("105344") }}).<br>
+ This value overrides the application.<br>
+ 0 disables feature<br>
+ (<strong>before, <code>4096</code> = default</strong>)</td>
+ </tr>
+ <tr>
+ <td><code>browser.cache.memory.max_entry_size</code></td>
+ <td>
+ <p><strong><code>5120</code> (default)</strong></p>
+ <p>-1 = no limit</p>
+ </td>
+ <td>
+ <p>The maximum size of an entry in the memory cache (in KB).</p>
+ <div class="note">
+ <strong>Note:</strong> Items larger than 90% of <code>browser.cache.memory.capacity</code> are never cached.</div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>network.http.use-cache</code></td>
+ <td><strong><code>true</code> (default)</strong></td>
+ <td>no UI</td>
+ </tr>
+ <tr>
+ <td><code>browser.cache.disk_cache_ssl</code></td>
+ <td><strong><code>false</code> (default)</strong></td>
+ <td>no UI, added in 1.6a (see {{ Bug("205921") }})</td>
+ </tr>
+ <tr>
+ <td><code>network.prefetch-next</code></td>
+ <td><strong><code>False</code></strong></td>
+ <td>Preferences | Advanced | Cache: Link Prefetching<br>
+ <strong>{{ mediawiki.external('x') }} Prefetch web pages when idle, so that links in web page designed for prefetching can load faster.</strong></td>
+ </tr>
+ <tr>
+ <td><code>browser.cache.disk.smart_size.first_run</code></td>
+ <td><strong><code>true</code> (default)</strong></td>
+ <td>Indicates whether or not this is the first time smart sizing has been used.</td>
+ </tr>
+ <tr>
+ <td><code>browser.cache.disk.smart_size.enabled</code></td>
+ <td><strong><code>true</code> (default)</strong></td>
+ <td>Indicates whether or not smart sizing of the disk cache is enabled.</td>
+ </tr>
+ </tbody>
+</table>
+<h4 id="DNS" name="DNS">DNS</h4>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>首选项名称</th>
+ <th>Acceptable Values</th>
+ <th>Preferences UI (in bold) and comments</th>
+ </tr>
+ <tr>
+ <td><code>network.dnsCacheExpiration</code></td>
+ <td><strong><code>60</code> (seconds)</strong></td>
+ <td colspan="1" rowspan="2">default pref-less, not visible in about:config.<br>
+ Create and set both values to "0" to disable.</td>
+ </tr>
+ <tr>
+ <td><code>network.dnsCacheEntries</code></td>
+ <td><strong><code>20</code> (entries)</strong></td>
+ </tr>
+ </tbody>
+</table>
+<h4 id="Cookies" name="Cookies">Cookie</h4>
+<p>The old section in this document was removed because of dwitte's cookies re-write. Please see: <a href="/en/Cookies_Preferences_in_Mozilla" title="en/Cookies_Preferences_in_Mozilla">Cookies Preferences in Mozilla</a></p>
+<h4 id="Proxy" name="Proxy">代理</h4>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>首选项名称</th>
+ <th>Acceptable Values</th>
+ <th>Preferences UI (in bold) and comments</th>
+ </tr>
+ <tr>
+ <td><code>network.proxy.type</code></td>
+ <td><code>0</code> = direct<br>
+ <code>1</code> = manual<br>
+ <code>2</code> = PAC<br>
+ <code>3</code> = mapped to 0<br>
+ <code>4</code> = WPAD</td>
+ <td>Preferences | Advanced | Proxies<br>
+ Configure Proxies to Access the Internet<br>
+ <strong>( ) Direct connection to the internet</strong><br>
+ <strong>( ) Auto-detect proxy settings</strong> (new in 1.8)<br>
+ <strong>( ) Manual proxy configuration</strong><br>
+ <strong>( ) Automatic proxy configuration URL</strong><br>
+ <br>
+ 3 was old Communicator value for DIRECT.</td>
+ </tr>
+ <tr>
+ <td><code>network.proxy.http</code></td>
+ <td colspan="1" rowspan="10">&lt;Protocol&gt; Proxy: hostname or IPv4 is acceptable. IPv6 needs to be tested.<br>
+ <br>
+ Port: 0 will cause server:port preference for that manual proxy type to be ignored. 1-65xxx is valid range</td>
+ <td colspan="1" rowspan="2">Affects <code>http:</code> URLs</td>
+ </tr>
+ <tr>
+ <td><code>network.proxy.http_port</code></td>
+ </tr>
+ <tr>
+ <td><code>network.proxy.ssl</code></td>
+ <td colspan="1" rowspan="2">Affects <code>https:</code> URLs<br>
+ Possibly affects SIMAP and SNEWS</td>
+ </tr>
+ <tr>
+ <td><code>network.proxy.ssl_port</code></td>
+ </tr>
+ <tr>
+ <td><code>network.proxy.ftp</code></td>
+ <td colspan="1" rowspan="2">Affects <code>ftp:</code> URLs</td>
+ </tr>
+ <tr>
+ <td><code>network.proxy.ftp_port</code></td>
+ </tr>
+ <tr>
+ <td><code>network.proxy.gopher</code> {{ obsolete_inline("2.0") }}</td>
+ <td colspan="1" rowspan="2">Affects <code>gopher:</code> URLs</td>
+ </tr>
+ <tr>
+ <td><code>network.proxy.gopher_port</code> {{ obsolete_inline("2.0") }}</td>
+ </tr>
+ <tr>
+ <td><code>network.proxy.socks</code></td>
+ <td colspan="1" rowspan="2">Used when application-specific proxy is not configured. Possibly affects other protocols</td>
+ </tr>
+ <tr>
+ <td><code>network.proxy.socks_port</code></td>
+ </tr>
+ <tr>
+ <td><code>network.proxy.socks_version</code></td>
+ <td><strong><code>5</code> (default)</strong><br>
+ <code>4</code></td>
+ <td>Communicator supported only SOCKS V4.</td>
+ </tr>
+ <tr>
+ <td><code>network.proxy.no_proxies_on</code></td>
+ <td><strong><code>localhost, 127.0.0.1</code> (default)</strong><br>
+ string of comma delimited fqdn's, hostnames, IPv4 addresses and CDIR blocks. See <a href="/en/No_Proxy_For_configuration" title="en/No_Proxy_For_configuration">No Proxy For configuration</a>.</td>
+ <td>Localhost is not proxied by default, {{ Bug("31510") }}.</td>
+ </tr>
+ <tr>
+ <td><code>network.proxy.autoconfig_url</code></td>
+ <td><strong>empty (default)</strong><br>
+ URL string</td>
+ <td>must be absolute URl, no hostname</td>
+ </tr>
+ </tbody>
+</table>
+<h4 id="Online" name="Online">在线</h4>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>Preference Name</th>
+ <th>Acceptable Values</th>
+ <th>Preferences UI (in bold) and comments</th>
+ </tr>
+ <tr>
+ <td><code>network.online</code></td>
+ <td><strong><code>true</code> = Mozilla is online (default)<br>
+ <code>false</code> = Mozilla is offline</strong></td>
+ <td>Necko updates the offline|online status to this value.<br>
+ Changing this value does not change the actual networking status.<br>
+ Value is not updated if "Ask me for online state at startup" was selected<br>
+ for the current profile ({{ Bug("229677") }}).</td>
+ </tr>
+ <tr>
+ <td><code>offline.startup_state</code></td>
+ <td><strong><code>0</code> = use network.online (default)</strong><br>
+ <code>1 = prompt user</code></td>
+ <td>Preferences: Mail &amp; Newsgroups | Offline | When starting up:<br>
+ (Pref affects all modules, but was moved from Pref root, {{ Bug("202529") }})<br>
+ {{ mediawiki.external('x') }} Remember previous online state<br>
+ (Uses network.online to set online|offline status at startup)<br>
+ {{ mediawiki.external(' ') }} Ask me for online state at startup<br>
+ (Unlike Communicator, prompt always appears, {{ Bug("239564") }})</td>
+ </tr>
+ </tbody>
+</table>
+<h4 id="Gopher_.28see_also_Proxy.29" name="Gopher_.28see_also_Proxy.29">Gopher(另请参见“代理”部分)</h4>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>Preference Name</th>
+ <th>Acceptable Values</th>
+ <th>Comments (bold for areas that user configures)</th>
+ </tr>
+ <tr>
+ <td><code>network.dir.format</code></td>
+ <td colspan="2" rowspan="1">see FTP {{ obsolete_inline("2.0") }}</td>
+ </tr>
+ </tbody>
+</table>
+<h4 id="Unsupported" name="Unsupported">不推荐修改(Unsupported)</h4>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>Preference Name</th>
+ <th>Acceptable Values</th>
+ <th>Comments (bold for areas that user configures)</th>
+ </tr>
+ <tr>
+ <td><code>browser.xul.error.pages.enabled</code></td>
+ <td><code>false</code> (default)<br>
+ <code>true</code></td>
+ <td>Does not appear in about.config unless added explicitly. See {{ Bug("28586") }})</td>
+ </tr>
+ <tr>
+ <td><code>network.protocol-handler.external.SCHEME</code></td>
+ <td><code>false</code> (default)<br>
+ <code>true</code></td>
+ <td>Mac+Windows: sends URLs of &lt;SCHEME&gt; to the default OS handler<br>
+ Linux/UNIX: sends URLs to application<br>
+ For example: <code>network.protocol-handler.external.mailto==true</code> is used by Phoenix/Firebird/Firefox to access default mailers.<br>
+ Handlers loaded before prefs are read cannot be redirected (e.g. file:)</td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
+<h4 id="Obsolete.2FRemoved_.28this_is_list_is_incomplete.29" name="Obsolete.2FRemoved_.28this_is_list_is_incomplete.29">已过时/已移除(此列表不全)</h4>
+<ul>
+ <li><code>browser.cache.enable</code></li>
+ <li><code>browser.cache.disk.directory</code></li>
+ <li><code>networking.proxy.wais</code></li>
+ <li><code>networking.proxy.wais_port</code></li>
+ <li><code>network.http.connect.timeout</code></li>
+ <li><code>network.http.proxy.ssl.connect</code></li>
+</ul>
+<h4 id="Under_Investigation" name="Under_Investigation">Under Investigation</h4>
+<ul>
+ <li><code>offline.startup_state</code></li>
+</ul>
+<div class="originaldocinfo">
+ <h2 id="Original_Document_Information" name="Original_Document_Information"><span class="short_text" id="result_box" lang="zh-CN"><span>原始文档信息</span></span></h2>
+ <ul>
+ <li>Author(s): Benjamin Chuang</li>
+ <li>Last Updated Date: July 26, 2007</li>
+ <li>Copyright Information: Portions of this content are © 1998–2007 by individual mozilla.org contributors; content available under a Creative Commons license | <a class="external" href="http://www.mozilla.org/foundation/licensing/website-content.html">Details</a>.</li>
+ </ul>
+</div>
+<p>{{ languages( { "ja": "ja/Mozilla_Networking_Preferences" } ) }}</p>
diff --git a/files/zh-cn/mozilla/preferences/preference_reference/browser.altclicksave/index.html b/files/zh-cn/mozilla/preferences/preference_reference/browser.altclicksave/index.html
new file mode 100644
index 0000000000..e00172c42c
--- /dev/null
+++ b/files/zh-cn/mozilla/preferences/preference_reference/browser.altclicksave/index.html
@@ -0,0 +1,12 @@
+---
+title: browser.altClickSave
+slug: Mozilla/Preferences/Preference_reference/browser.altClickSave
+translation_of: Mozilla/Preferences/Preference_reference/browser.altClickSave
+---
+<p> <code>browser.altClickSave</code> 控制是否在按住alt键的同时点击链接执行下载动作.</p>
+<ul style="display: table; padding: 0; border-left: 2px solid; margin-left: 0.5em;"> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>类型:</dfn><code>boolean</code></li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认值: </dfn> <code>false</code></li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认已存在:</dfn> yes</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>支持版本:</dfn> Gecko 13.0 {{ geckoRelease("13.0") }}</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>状态:</dfn> Active; last updated 2012-03-19</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>介绍:</dfn> Pushed to Nightly on 2012-03-02</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>Bugs:</dfn> {{ bug("713052") }}</li>
+</ul>
+<h2 id="值">值</h2>
+<dl> <dt><code>true</code></dt> <dd>在按住alt键的同时点击链接执行下载该链接的动作.</dd> <dt><code>false</code> (默认)</dt> <dd>无下载动作 (查看{{ bug("736985") }}).</dd>
+</dl>
+<p>{{ languages( { "en": "en/Mozilla/Preferences/Preference_reference/browser.altClickSave" } ) }}</p>
diff --git a/files/zh-cn/mozilla/preferences/preference_reference/browser.download.lastdir.savepersite/index.html b/files/zh-cn/mozilla/preferences/preference_reference/browser.download.lastdir.savepersite/index.html
new file mode 100644
index 0000000000..e758aedb86
--- /dev/null
+++ b/files/zh-cn/mozilla/preferences/preference_reference/browser.download.lastdir.savepersite/index.html
@@ -0,0 +1,31 @@
+---
+title: browser.download.lastDir.savePerSite
+slug: Mozilla/Preferences/Preference_reference/browser.download.lastDir.savePerSite
+translation_of: Mozilla/Preferences/Preference_reference/browser.download.lastDir.savePerSite
+---
+<p><code>browser.download.lastDir.savePerSite</code> 控制是否为每个网站记忆上次下载文件时所选的保存目录. 如果设置为 <code>true</code>, 则数据将保存在 <a href="/zh-cn/Using_content_preferences" title="Using content preferences">content preference</a>.</p>
+<ul style="display: table; padding: 0; border-left: 2px solid; margin-left: 0.5em;">
+ <li style="display: table-row; padding: 3px; margin: 0;"><dfn>类型:</dfn><code>boolean</code></li>
+ <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认值:</dfn><code>true</code></li>
+ <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认已存在:</dfn> no</li>
+ <li style="display: table-row; padding: 3px; margin: 0;"><dfn>支持版本:</dfn>Firefox 11.0</li>
+ <li style="display: table-row; padding: 3px; margin: 0;"><dfn>状态:</dfn> Active; last updated 2012-02-15</li>
+ <li style="display: table-row; padding: 3px; margin: 0;"><dfn>介绍:</dfn> Pushed to Nightly on 2011-12-11</li>
+ <li style="display: table-row; padding: 3px; margin: 0;"><dfn>Bugs:</dfn> {{ bug("702748") }}</li>
+</ul>
+<h2 id="值">值</h2>
+<dl>
+ <dt>
+ <code>true</code> (默认)</dt>
+ <dd>
+ 该网站上次下载文件时用户所选的目录会被默认选择,如果是第一次在该网站下载文件,则会使用通用的 <a href="/zh-cn/Preferences/browser.download.lastDir" title="zh-cn/Preferences/browser.download.lastDir"><code>browser.download.lastDir</code></a> 目录.</dd>
+ <dt>
+ <code>false</code></dt>
+ <dd>
+ 下载文件时默认选择的目录会是通用的上次下载目录 ( <a href="/zh-cn/Preferences/browser.download.lastDir" title="zh-cn/Preferences/browser.download.lastDir"><code>browser.download.lastDir</code></a>)</dd>
+</dl>
+<h2 id="相关链接">相关链接</h2>
+<ul>
+ <li><a href="/zh-cn/Preferences/browser.download.lastDir" title="zh-cn/Preferences/browser.download.lastDir"><code>browser.download.lastDir</code></a></li>
+</ul>
+<p>{{ languages( { "en": "en/Mozilla/Preferences/Preferences_reference/browser.download.lastDir.savePerSite" } ) }}</p>
diff --git a/files/zh-cn/mozilla/preferences/preference_reference/browser.search.context.loadinbackground/index.html b/files/zh-cn/mozilla/preferences/preference_reference/browser.search.context.loadinbackground/index.html
new file mode 100644
index 0000000000..c80e03a840
--- /dev/null
+++ b/files/zh-cn/mozilla/preferences/preference_reference/browser.search.context.loadinbackground/index.html
@@ -0,0 +1,14 @@
+---
+title: browser.search.context.loadInBackground
+slug: >-
+ Mozilla/Preferences/Preference_reference/browser.search.context.loadInBackground
+translation_of: >-
+ Mozilla/Preferences/Preference_reference/browser.search.context.loadInBackground
+---
+<p><code>browser.search.context.loadInBackground</code> 控制右键菜单中的"通过&lt;搜索引擎&gt;搜索&lt;选中文字&gt;"打开新标签页后,立即激活该标签页,还是保持当前标签页状态不变.</p>
+<ul style="display: table; padding: 0; border-left: 2px solid; margin-left: 0.5em;"> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>类型:</dfn><code>boolean</code></li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认值:</dfn><code>false</code></li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认已存在:</dfn> yes</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>支持版本:</dfn> Firefox 13.0</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>状态:</dfn> Active; last updated 2012-02-17</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>介绍:</dfn> Pushed to Nightly on 2012-02-15</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>Bugs:</dfn> {{ bug("727131") }}</li>
+</ul>
+<h2 id="值">值</h2>
+<dl> <dt><code>true</code></dt> <dd>搜索页面在后台打开,保持当前标签页不变</dd> <dt><code>false</code> (默认)</dt> <dd>搜索页面在前台打开(打开并激活).</dd>
+</dl>
+<p>{{ languages( { "en": "en/Mozilla/Preferences/Preference_reference/browser.search.context.loadInBackground" } ) }}</p>
diff --git a/files/zh-cn/mozilla/preferences/preference_reference/browser.urlbar.trimurls/index.html b/files/zh-cn/mozilla/preferences/preference_reference/browser.urlbar.trimurls/index.html
new file mode 100644
index 0000000000..2f57e03212
--- /dev/null
+++ b/files/zh-cn/mozilla/preferences/preference_reference/browser.urlbar.trimurls/index.html
@@ -0,0 +1,12 @@
+---
+title: browser.urlbar.trimURLs
+slug: Mozilla/Preferences/Preference_reference/browser.urlbar.trimURLs
+translation_of: Mozilla/Preferences/Preference_reference/browser.urlbar.trimURLs
+---
+<p><code>browser.urlbar.trimURLs</code> 控制是否隐藏地址栏中域名<code>前面的http</code>协议字段和域名后面紧跟的斜杠 (前提是地址栏中的域名必须是当前网页的域名) .</p>
+<ul style="display: table; padding: 0; border-left: 2px solid; margin-left: 0.5em;"> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>类型:</dfn><code>boolean</code></li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认值: </dfn> <code>true</code></li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认已存在:</dfn> yes</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>支持版本:</dfn>Firefox 7.0</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>状态:</dfn> Active; last updated 2012-04-03</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>介绍:</dfn> Pushed to Nightly on 2011-06-23</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>Bugs:</dfn> {{ bug("665580") }}</li>
+</ul>
+<h2 id="值">值</h2>
+<dl> <dt><code>true</code> (默认值)</dt> <dd>如果地址栏中的域名确实是当前网页的域名,那么顶级域名后面紧跟的斜杠会被隐藏.如果地址栏中的网址是以 <code>http://</code> 协议开头且域名不以<code>ftp.</code> subdomain开头,也不包含<code>@</code> (通常是ftp登陆信息)符号, 则这个<code>http://</code> 前缀会被隐藏.<br> <br> 例如: <code><a class=" link-https" href="https://www.example.org/" rel="freelink">https://www.example.org/</a></code> 会显示为 <code><a class=" link-https" href="https://www.example.org" rel="freelink">https://www.example.org</a></code>, <code><a class=" external" href="http://www.example.org/foobar" rel="freelink">http://www.example.org/foobar</a></code> 会显示为 <code>www.example.org/foobar</code>  <code><a class=" external" href="http://ftp.example.org/foobar" rel="freelink">http://ftp.example.org/foobar</a></code> 保持不变.</dd> <dt><code>false</code></dt> <dd>显示完整的URL.</dd>
+</dl>
+<p>{{ languages( { "en": "en/Mozilla/Preferences/Preference_reference/browser.urlbar.trimURLs" } ) }}</p>
diff --git a/files/zh-cn/mozilla/preferences/preference_reference/dom.event.clipboardevents.enabled/index.html b/files/zh-cn/mozilla/preferences/preference_reference/dom.event.clipboardevents.enabled/index.html
new file mode 100644
index 0000000000..cdff9ccd1a
--- /dev/null
+++ b/files/zh-cn/mozilla/preferences/preference_reference/dom.event.clipboardevents.enabled/index.html
@@ -0,0 +1,12 @@
+---
+title: dom.event.clipboardevents.enabled
+slug: Mozilla/Preferences/Preference_reference/dom.event.clipboardevents.enabled
+translation_of: Mozilla/Preferences/Preference_reference/dom.event.clipboardevents.enabled
+---
+<p><code>dom.event.clipboardevents.enabled</code> 控制,当用户在网页上执行复制,粘贴或者剪切动作时,是否触发 <code><a href="/zh-cn/DOM/element.oncopy" title="element.oncopy">oncopy</a></code>, <code><a href="/zh-cn/DOM/element.oncut" title="element.oncut">oncut</a></code> 和 <code><a href="/zh-cn/DOM/element.onpaste" title="element.onpaste">onpaste</a></code> 事件.</p>
+<ul style="display: table; padding: 0; border-left: 2px solid; margin-left: 0.5em;"> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>类型:</dfn><code>boolean</code></li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认值:</dfn><code>true</code></li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认已存在:</dfn> no</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>支持版本:</dfn> Gecko 13.0 {{ geckoRelease("13.0") }}</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>状态:</dfn> Active; last updated 2012-02-15</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>介绍:</dfn> Pushed to Nightly on 2012-02-14</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>Bugs:</dfn> {{ bug("542938") }}</li>
+</ul>
+<h2 id="值">值</h2>
+<dl> <dt><code>true</code> (默认)</dt> <dd>可以触发 <code><a href="/zh-cn/DOM/element.oncopy" title="element.oncopy">oncopy</a></code>, <code><a href="/zh-cn/DOM/element.oncut" title="element.oncut">oncut</a></code> 和 <code><a href="/zh-cn/DOM/element.onpaste" title="element.onpaste">onpaste</a></code> 事件</dd> <dt><code>false</code></dt> <dd>不会触发 <code><a href="/zh-cn/DOM/element.oncopy" title="element.oncopy">oncopy</a></code>, <code><a href="/zh-cn/DOM/element.oncut" title="element.oncut">oncut</a></code> 和 <code><a href="/zh-cn/DOM/element.onpaste" title="element.onpaste">onpaste</a></code> 事件</dd>
+</dl>
+<p>{{ languages( { "en": "en/Mozilla/Preferences/Preference_reference/dom.event.clipboardevents.enabled" } ) }}</p>
diff --git a/files/zh-cn/mozilla/preferences/preference_reference/index.html b/files/zh-cn/mozilla/preferences/preference_reference/index.html
new file mode 100644
index 0000000000..f87f26f3cb
--- /dev/null
+++ b/files/zh-cn/mozilla/preferences/preference_reference/index.html
@@ -0,0 +1,8 @@
+---
+title: Preference reference
+slug: Mozilla/Preferences/Preference_reference
+translation_of: Mozilla/Preferences/Preference_reference
+---
+<p>{{ draft() }}</p>
+<p>This is an automatically-generated list of subpages.</p>
+<p>{{ListSubpages()}}</p>
diff --git a/files/zh-cn/mozilla/preferences/preference_reference/javascript.options.strict/index.html b/files/zh-cn/mozilla/preferences/preference_reference/javascript.options.strict/index.html
new file mode 100644
index 0000000000..0719935e05
--- /dev/null
+++ b/files/zh-cn/mozilla/preferences/preference_reference/javascript.options.strict/index.html
@@ -0,0 +1,13 @@
+---
+title: javascript.options.strict
+slug: Mozilla/Preferences/Preference_reference/javascript.options.strict
+translation_of: Mozilla/Preferences/Preference_reference/javascript.options.strict
+---
+<p><span style="font-size: 14px; line-height: 1.572;">当代码执行时,如果这条语句没有发生运行时错误,但却是用了非标准的特性,写法有问题,可能导致隐含的逻辑错误,则会生成JavaScript警告信息.该选项就控制着这些警告信息是否要打印到JavaScript控制台上.</span></p>
+<p> </p>
+<p>可用的值和对应的效果</p>
+<p><strong>True</strong>: 在错误控制台上显示JavaScript错误和警告.<br>
+ <br>
+ <strong>False</strong>: 在错误控制台上只显示JavaScript错误.(默认值)</p>
+<p> </p>
+<p>相关链接: <a href="http://kb.mozillazine.org/Javascript.options.strict" title="http://kb.mozillazine.org/Javascript.options.strict">http://kb.mozillazine.org/Javascript.options.strict</a></p>
diff --git a/files/zh-cn/mozilla/preferences/preference_reference/ui.alertnotificationorigin/index.html b/files/zh-cn/mozilla/preferences/preference_reference/ui.alertnotificationorigin/index.html
new file mode 100644
index 0000000000..7221433f99
--- /dev/null
+++ b/files/zh-cn/mozilla/preferences/preference_reference/ui.alertnotificationorigin/index.html
@@ -0,0 +1,12 @@
+---
+title: ui.alertNotificationOrigin
+slug: Mozilla/Preferences/Preference_reference/ui.alertNotificationOrigin
+translation_of: Mozilla/Preferences/Preference_reference/ui.alertNotificationOrigin
+---
+<p><code>ui.alertNotificationOrigin</code> 控制由 <a href="/zh-cn/XPCOM_Interface_Reference/nsIAlertsService" title="nsIAlertsService">nsIAlertsService</a> 生成的弹出提示窗口向外滚动时的位置和方向.</p>
+<ul style="display: table; padding: 0; border-left: 2px solid; margin-left: 0.5em;"> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>值:</dfn><code>integer</code></li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认值:</dfn>依据任务栏的位置而定</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认已存在:</dfn> no</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>支持版本:</dfn> Gecko 1.8.1.2 (Firefox 2.0.0.2 / Thunderbird 2.0.0.4 / SeaMonkey 1.1)</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>状态:</dfn> Active; last updated 2012-02-22</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>介绍:</dfn> Pushed to Nightly on 2007-01-04</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>Bugs:</dfn> {{ bug("133527") }}</li>
+</ul>
+<h2 id="值">值</h2>
+<dl> <dt><code>0</code></dt> <dd>右下角,由下向上滑出</dd> <dt><code>1</code></dt> <dd>右下角, 由右向左滑出</dd> <dt><code>2</code></dt> <dd>左下角, 由下向上滑出</dd> <dt><code>3</code></dt> <dd>左下角, 由左向右滑出</dd> <dt><code>4</code></dt> <dd>右上角, 由上向下滑出</dd> <dt><code>5</code></dt> <dd>右上角, 由右向左滑出</dd> <dt><code>6</code></dt> <dd>左上角, 由上向下滑出</dd> <dt><code>7</code></dt> <dd>左上角, 由左向右滑出</dd>
+</dl>
+<p>{{ languages( { "en": "en/Mozilla/Preferences/Preference_reference/ui.alertNotificationOrigin" } ) }}</p>
diff --git a/files/zh-cn/mozilla/preferences/preference_reference/ui.spellcheckerunderline/index.html b/files/zh-cn/mozilla/preferences/preference_reference/ui.spellcheckerunderline/index.html
new file mode 100644
index 0000000000..cbbb0e3961
--- /dev/null
+++ b/files/zh-cn/mozilla/preferences/preference_reference/ui.spellcheckerunderline/index.html
@@ -0,0 +1,12 @@
+---
+title: ui.SpellCheckerUnderline
+slug: Mozilla/Preferences/Preference_reference/ui.SpellCheckerUnderline
+translation_of: Mozilla/Preferences/Preference_reference/ui.SpellCheckerUnderline
+---
+<p><code>ui.SpellCheckerUnderline</code> 控制拼写检查器给不认识的单词所加的下划线的颜色.</p>
+<ul style="display: table; padding: 0; border-left: 2px solid; margin-left: 0.5em;"> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>类型:</dfn><code>string</code></li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认值:</dfn><code>#ff0000</code></li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认已存在:</dfn> no</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>支持版本:</dfn> Gecko 1.9.2 {{ geckoRelease("1.9.2") }}</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>状态:</dfn> Active; last updated 2012-02-21</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>介绍:</dfn> Pushed to Nightly on 2009-04-03</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>Bugs:</dfn> {{ bug("338209") }}</li>
+</ul>
+<h2 id="值">值</h2>
+<dl> <dd> <a href="/zh-cn/CSS/Getting_Started/Color" title="Color">颜色RGB值</a> 例如 #ff0000 是红色.</dd>
+</dl>
+<p>{{ languages( { "en": "en/Mozilla/Preferences/Preference_reference/ui.SpellCheckerUnderline" } ) }}</p>
diff --git a/files/zh-cn/mozilla/preferences/preference_reference/ui.spellcheckerunderlinestyle/index.html b/files/zh-cn/mozilla/preferences/preference_reference/ui.spellcheckerunderlinestyle/index.html
new file mode 100644
index 0000000000..573e8ec36f
--- /dev/null
+++ b/files/zh-cn/mozilla/preferences/preference_reference/ui.spellcheckerunderlinestyle/index.html
@@ -0,0 +1,13 @@
+---
+title: ui.SpellCheckerUnderlineStyle
+slug: Mozilla/Preferences/Preference_reference/ui.SpellCheckerUnderlineStyle
+translation_of: Mozilla/Preferences/Preference_reference/ui.SpellCheckerUnderlineStyle
+---
+<p><code>ui.SpellCheckerUnderlineStyle</code> 控制拼写检查器给不认识的单词所加的下划线的样式.</p>
+<ul style="display: table; padding: 0; border-left: 2px solid; margin-left: 0.5em;"> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>类型:</dfn><code>integer</code></li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认值:</dfn><code>5</code></li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认已存在:</dfn> no</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>支持版本:</dfn> Gecko 1.9.2 {{ geckoRelease("1.9.2") }}</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>状态:</dfn> Active; last updated 2012-02-22</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>介绍:</dfn> Pushed to Nightly on 2009-04-03</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>Bugs:</dfn> {{ bug("338209") }}</li>
+</ul>
+<h2 id="值">值</h2>
+<p><span id="cke_bm_94S" style="display: none;"> </span>下面的值被定义在源代码 <a class="external" href="http://mxr.mozilla.org/mozilla-central/source/layout/base/nsStyleConsts.h" title="http://mxr.mozilla.org/mozilla-central/source/layout/base/nsStyleConsts.h">nsStyleConsts.h</a> 中.</p>
+<dl> <dt><code>0</code></dt> <dd>无下划线</dd> <dt><code>1</code></dt> <dd>点状线</dd> <dt><code>2</code></dt> <dd>虚线</dd> <dt><code>3</code></dt> <dd>单实线</dd> <dt><code>4</code></dt> <dd>双实线</dd> <dt><code>5</code> (默认值)</dt> <dd>波浪线</dd>
+</dl>
+<p>{{ languages( { "en": "en/Mozilla/Preferences/Preference_reference/ui.SpellCheckerUnderlineStyle" } ) }}</p>
diff --git a/files/zh-cn/mozilla/preferences/preference_reference/ui.tooltipdelay/index.html b/files/zh-cn/mozilla/preferences/preference_reference/ui.tooltipdelay/index.html
new file mode 100644
index 0000000000..c92dd03248
--- /dev/null
+++ b/files/zh-cn/mozilla/preferences/preference_reference/ui.tooltipdelay/index.html
@@ -0,0 +1,13 @@
+---
+title: ui.tooltipDelay
+slug: Mozilla/Preferences/Preference_reference/ui.tooltipDelay
+translation_of: Mozilla/Preferences/Preference_reference/ui.tooltipDelay
+---
+<p>{{ gecko_minversion_header("11.0") }}</p>
+<p><code>ui.tooltipDelay</code> 存储着一个单位为毫秒的时间数值,该数值表示鼠标停留在某个元素上多长时间后显示出提示信息.</p>
+<ul style="display: table; padding: 0; border-left: 2px solid; margin-left: 0.5em;"> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>类型:</dfn><code>integer</code></li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认值:</dfn><code>500</code></li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>默认已存在:</dfn> no</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>支持版本:</dfn> Gecko 11.0 {{ geckoRelease("11.0") }}</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>状态:</dfn> Active; last updated 2012-02-21</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>介绍:</dfn> Pushed to Nightly on 2011-12-15</li> <li style="display: table-row; padding: 3px; margin: 0;"><dfn>Bugs:</dfn> {{ bug("204786") }}</li>
+</ul>
+<h2 id="值">值</h2>
+<dl> <dt><code>整数</code>(单位为毫秒, 默认值: 500)</dt> <dd>该数值表示鼠标停留在某个元素上多长时间后显示出提示信息,单位为毫秒,默认值为500ms.</dd>
+</dl>
+<p>{{ languages( { "zh-cn": "zh-cn/Mozilla/Preferences/Preference_reference/ui.tooltipDelay" } ) }}</p>
diff --git a/files/zh-cn/mozilla/preferences/preference_reference/view_source.syntax_highlight/index.html b/files/zh-cn/mozilla/preferences/preference_reference/view_source.syntax_highlight/index.html
new file mode 100644
index 0000000000..c09889f0be
--- /dev/null
+++ b/files/zh-cn/mozilla/preferences/preference_reference/view_source.syntax_highlight/index.html
@@ -0,0 +1,6 @@
+---
+title: view_source.syntax_highlight
+slug: Mozilla/Preferences/Preference_reference/view_source.syntax_highlight
+translation_of: Mozilla/Preferences/Preference_reference/view_source.syntax_highlight
+---
+<p>This page was auto-generated because a user created a sub-page to this page.</p>
diff --git a/files/zh-cn/mozilla/projects/crash_reporting/index.html b/files/zh-cn/mozilla/projects/crash_reporting/index.html
new file mode 100644
index 0000000000..bb8fd91519
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/crash_reporting/index.html
@@ -0,0 +1,47 @@
+---
+title: Crash reporting
+slug: Mozilla/Projects/Crash_reporting
+tags:
+ - Crashes
+ - Developer Guide
+ - Developing Mozilla
+ - Firefox
+ - Mozilla
+ - NeedsTranslation
+ - QA
+ - TopicStub
+ - crash reports
+translation_of: Mozilla/Projects/Crash_reporting
+---
+<p>Firefox ships with an open-source crash reporting system. This system is combination of projects:</p>
+
+<ul>
+ <li><a href="http://code.google.com/p/google-breakpad/">Google Breakpad</a> client and server libraries</li>
+ <li>Mozilla-specific crash reporting user interface and bootstrap code</li>
+ <li><a href="https://github.com/mozilla/socorro">Socorro</a> Collection and reporting server</li>
+</ul>
+
+<h2 id="Where_did_my_crash_get_submitted.3F" name="Where_did_my_crash_get_submitted.3F">Where did my crash get submitted?</h2>
+
+<p>Crash data submitted using the Mozilla Crash Reporter is located on <a href="http://crash-stats.mozilla.com/">crash-stats</a>. If you want to find a specific crash that you submitted, you first need to find the Crash ID that the server has assigned your crash. Type <code>about:crashes</code> into your location bar to get a page listing both submitted and unsubmitted crash reports. For more information, see <a href="/en-US/docs/How_to_get_a_stacktrace_for_a_bug_report" title="How to get a stacktrace for a bug report">How to get a stacktrace for a bug report</a>.</p>
+
+<h2 id="Reports_and_queries">Reports and queries</h2>
+
+<p>crash-stats has built-in reports of "topcrashes" for each release grouped by signature. There is also a custom query tool which allows users to limit searches on more precise information.</p>
+
+<p>For more automated usage, a summary of each day's crash reports is published as a CSV file, as well as batch analysis jobs. These can be found at <a href="https://crash-analysis.mozilla.com/crash_analysis/">https://crash-analysis.mozilla.com/crash_analysis/</a></p>
+
+<p>Finally, a set of Mozilla employees have access to directly query the underlying data in either SQL summary or using mapreduce on the storage cluster. If you are interested in obtaining this advanced access, contact <a href="mailto:benjamin@smedbergs.us?subject=crash-stats%20access%20query" title="mailto:benjamin@smedbergs.us?subject=crash-stats%20access%20query">Benjamin Smedberg</a>.</p>
+
+<h2 id="Additional_information" name="Additional_information">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/Projects/Crash_reporting/Understanding_crash_reports">Understanding crash reports</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/Crash_reporting/Searching_crash_reports">A guide to searching crash reports</a></li>
+ <li><a href="http://crash-stats.mozilla.com/">crash-stats</a></li>
+ <li><a href="/en-US/docs/Building_Firefox_with_Debug_Symbols">Building Firefox with Debug Symbols</a></li>
+ <li><a href="/en-US/docs/Environment_variables_affecting_crash_reporting">Environment variables affecting crash reporting</a></li>
+ <li><a href="/en-US/docs/Crash_Reporting_Guide_for_Firefox_OS_Partners" title="/en-US/docs/Crash_Reporting_Guide_for_Firefox_OS_Partners">Crash Reporting Guide for Firefox OS Partners</a></li>
+ <li><a href="/en-US/docs/Uploading_symbols_to_Mozillas_symbol_server" title="/en-US/docs/Uploading_symbols_to_Mozillas_symbol_server">Uploading Symbols to Mozilla's Symbol Server</a> (guide for partners)</li>
+ <li><a href="/en-US/docs/Using_Crash_Reporting_in_a_XULRunner_Application">Using Crash Reporting in a XULRunner Application</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/projects/emscripten/index.html b/files/zh-cn/mozilla/projects/emscripten/index.html
new file mode 100644
index 0000000000..9d488c2d8e
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/emscripten/index.html
@@ -0,0 +1,37 @@
+---
+title: Emscripten
+slug: Mozilla/Projects/Emscripten
+translation_of: Mozilla/Projects/Emscripten
+---
+<p><span class="seoSummary">Emscripten 是一个 LLVM (底层虚拟机)生成 JavaScript 的编译器. 它采用 LLVM 的字节码 (例如,使用 Clang 从 C/C++ 或者从其他语言生成的字节码) 并将其编译成可在 Web 上面运行的 </span>JavaScript<span class="seoSummary">。</span></p>
+
+<div class="warning">
+<p><strong>重要提示:</strong><font>本页简要介绍了 Emscripten 是什么。</font><font>要开始使用 Emscripten</font>,<a href="http://kripken.github.io/emscripten-site/index.html">请访问官方的Emscripten Wiki</a>。</p>
+</div>
+
+<p>使用 Emscripten,你可以</p>
+
+<ul>
+ <li>将 C 和 C++ 代码编译成 JavaScript</li>
+ <li>将可以翻译为 LLVM 字节码的任何其他代码编译为 JavaScript</li>
+ <li>将其他语言的 C / C ++ 运行时编译为 JavaScript,然后间接使用其他语言运行代码(已在Python和Lua中运行成功)!</li>
+</ul>
+
+<p>Emscripten 使原生代码可立即使用在 Web 上:是一个具有众多独立兼容的实现,可在从 PC 到 iPad 的任何地方运行的标准平台。</p>
+
+<p>借助 Emscripten,C / C ++ 开发人员无需手动将代码移植到 JavaScript 上,也无需学习 JavaScript。Web 开发人员也可以从中受益,因为他们可以在自己的站点中使用成千上万的已存在的原生实用程序和库。</p>
+
+<p>实际上,任何可移植的 C 或 C++ 代码库都可以通过 Emscripten 编译成 JavaScript,从需要渲染图形,播放声音,加载和处理文件的高性能游戏到诸如 Qt 的应用程序框架。</p>
+
+<p>Emscripten 生成的代码(其默认输出格式为 <a href="/en-US/docs/Games/Tools/asm.js">asm.js</a> ,这是 JavaScript 的高度优化子集)在许多情况下可以以接近原生的速度执行。</p>
+
+<div class="note">
+<p><strong>注意:</strong>听起来有趣吗? <a href="http://kripken.github.io/emscripten-site/docs/introducing_emscripten/about_emscripten.html">阅读有关 Emscripten 的更多信息并尝试一些 demo</a>,然后<a href="http://kripken.github.io/emscripten-site/docs/getting_started/index.html">开始使用它</a>。</p>
+</div>
+
+<h2 id="MDN上其他有趣的文章">MDN上其他有趣的文章</h2>
+
+<ul>
+ <li>我们的 <a href="/en-US/docs/Games">游戏专区</a> 包含了一些游戏开发相关的有用内容,这是一个 Emscripten 被广泛应用的领域</li>
+ <li>我们的 <a href="/en-US/docs/Mozilla/Projects/Emscripten/Techniques">Emscripten 技巧</a> 页面保存了许多未公开在 Emscripten Wiki 上的有关 Emscripten 的实用想法</li>
+</ul>
diff --git a/files/zh-cn/mozilla/projects/index.html b/files/zh-cn/mozilla/projects/index.html
new file mode 100644
index 0000000000..c1e43934a2
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/index.html
@@ -0,0 +1,14 @@
+---
+title: Projects
+slug: Mozilla/Projects
+tags:
+ - Mozilla
+ - NeedsContent
+ - NeedsTranslation
+ - Projects
+ - TopicStub
+translation_of: Mozilla/Projects
+---
+<p>{{ draft() }}</p>
+<p>Below you'll find links to documentation about various Mozilla projects; these are often parts of Firefox or other products, but may also be used in other projects as well.</p>
+<p>{{ LandingPageListSubpages() }}</p>
diff --git a/files/zh-cn/mozilla/projects/l20n/index.html b/files/zh-cn/mozilla/projects/l20n/index.html
new file mode 100644
index 0000000000..ce256b741f
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/l20n/index.html
@@ -0,0 +1,127 @@
+---
+title: L20n
+slug: Mozilla/Projects/L20n
+translation_of: Mozilla/Projects/L20n
+---
+<p>当这个文档还是草案的时候, 请上 <a href="https://github.com/l20n/l20n.js/tree/master/docs">GitHub</a>.</p>
+<div class="summary">
+ 一个JavaScript本地化框架, 释放你的本地语言的魅力, 仅使用简单的代码.</div>
+<div class="column-container">
+ <div class="column-half">
+ <h2 id="Introducing_L20n">Introducing L20n</h2>
+ <p>L20n reinvents software localization. Users should be able to benefit from the entire expressive power of the natural language. L20n keeps simple things simple, and at the same time makes complex things possible.</p>
+ <p>Through L20n, Mozilla is creating a new generation of technology that places more power in localizers' hands. <span class="seoSummary">L20n lets localizers reach higher levels of free linguistic expression by sharpening the divide between localization and application logic.</span> It allows to adapt your web application not only to languages and cultures, but also contextual data, user gender and screen dimensions.</p>
+ </div>
+ <div class="column-half">
+ <h2 id="What_L20n_looks_like">What L20n looks like</h2>
+ <p>Here is a simple, straightforward example showing an English string being provided:</p>
+ <pre class="brush: html">&lt;brandName "Firefox"&gt;
+&lt;about "About \{{ brandName }}"&gt;</pre>
+ <p>Here is the same string being provided in Slovenian:</p>
+ <pre class="brush: html">&lt;brandName {
+ nominative: "Firefox",
+ genitive: "Firefoxa",
+ dative: "Firefoxu",
+ accusative: "Firefox",
+ locative: "Firefoxu",
+ instrumental: "Firefoxom"
+}&gt;
+&lt;about "O \{{ brandName.locative }}"&gt;</pre>
+ </div>
+</div>
+<p> </p>
+<div class="column-container">
+ <div class="column-third">
+ <h2 class="Documentation" id="For_Developers">For Developers</h2>
+ <p><strong>Documentation for developers wanting to implement localization functionality on their web apps using L20n.</strong></p>
+ <dl>
+ <dt>
+ Internationalization for your web app</dt>
+ <dd>
+ First read for developers looking to use the L20n infrastructure.</dd>
+ <dt>
+ <a href="https://developer.mozilla.org/en-US/docs/L20n/HTML_Bindings">L20n's HTML bindings</a></dt>
+ <dd>
+ Tutorial on implementing L20n in your HTML code.</dd>
+ <dt>
+ <a href="/en-US/docs/L20n/Javascript_API">L20n JavaScript API</a></dt>
+ <dd>
+ An API for l20n.js.</dd>
+ <dt>
+ L20n syntax cheatsheet for developers</dt>
+ <dd>
+ A simple cheatsheet to help developers as they add L20n to their localization infrastructure.</dd>
+ </dl>
+ </div>
+ <div class="column-third">
+ <h2 class="Documentation" id="For_Localizers">For Localizers</h2>
+ <p><strong>Documentation for Localizers creating localized content for a project that uses L20n.</strong></p>
+ <dl>
+ <dt>
+ <a href="http://l20n.org/learn/">Learn the L20n syntax</a></dt>
+ <dd>
+ How to naturally localize applications using L20n. Complete with use cases and examples of L20n in action.</dd>
+ <dt>
+ <a href="https://developer.mozilla.org/en-US/docs/L20n/Localization_Use_Cases">Localization use-cases</a></dt>
+ <dd>
+ How to naturally localize applications using L20n. Complete with use cases and examples of L20n in action.</dd>
+ <dt>
+ L20n and Translation Memory eXchange (TMX)</dt>
+ <dd>
+ How L20n impacts the Translation Memory eXchange standard for translation memory data.</dd>
+ <dt>
+ L20n syntax cheatsheet for localizers</dt>
+ <dd>
+ A simple cheatsheet to help localizers as they localize projects with L20n.</dd>
+ </dl>
+ </div>
+ <div class="column-third">
+ <h2 class="Related_Topics" id="Related_Topics" name="Related_Topics">Additional resources</h2>
+ <p><strong>Some additional resources for developers and localizers involved with L20n.</strong></p>
+ <dl>
+ <dt>
+ <a href="http://www.l20n.org" title="http://www.l20n.org">L20n.org</a></dt>
+ <dd>
+ You can try L20n live in your browser on the project page.</dd>
+ <dt>
+ <a href="http://l20n.github.io/tinker/" title="http://l20n.github.io/tinker/">L20n Tinker</a></dt>
+ <dd>
+ Test out your own L20n code in L20n Tinker.</dd>
+ <dt>
+ <a href="https://github.com/l20n" title="https://github.com/l20n/l20n.js">GitHub</a></dt>
+ <dd>
+ Where the main code for the L20n infrastructure and design spec lives.</dd>
+ <dt>
+ <a href="https://wiki.mozilla.org/L20n" title="https://wiki.mozilla.org/L20n">Wiki page</a></dt>
+ <dd>
+ Info about the project to develop L20n.</dd>
+ </dl>
+ </div>
+</div>
+<h2 id="Subnav">Subnav</h2>
+<ol>
+ <li><a href="#" title="Documentation for developers wanting to implement localization functionality on their web apps using L20n">For Developers</a>
+ <ol>
+ <li><a href="#" title="First read for developers looking to use the L20n infrastructure">Internationalization for your web app</a></li>
+ <li><a href="#" title="Tutorial on implementing L20n in your HTML code">L20n's HTML bindings</a></li>
+ <li><a href="#" title="A complete description of the use, function, and role of L20n's .lol format.">.lol file format</a></li>
+ <li><a href="#" title="A simple cheatsheet to help developers as they add L20n to their localization infrastructure.">L20n syntax cheatsheet for developers</a></li>
+ </ol>
+ </li>
+ <li><a href="#" title="Documentation for Localizers creating localized content for a project that uses L20n.">For Localizers</a>
+ <ol>
+ <li><a href="#" title="How to naturally localize applications using L20n. Complete with use cases and examples of L20n in action.">Learn the L20n syntax</a></li>
+ <li><a href="/en-US/docs/L20n/Localization_Use_Cases">Localization use cases</a></li>
+ <li><a href="#" title="How L20n impacts the Translation Memory eXchange standard for translation memory data.">L20n and Translation Memory eXchange (TMX)</a></li>
+ <li><a href="#" title="A simple cheatsheet to help localizers as they localize projects with L20n.">L20n syntax cheatsheet for localizers</a></li>
+ </ol>
+ </li>
+ <li><a href="#" title="Some additional resources for developers and localizers involved with L20n.">Additional resources</a>
+ <ol>
+ <li><a href="http://www.l20n.org" title="You can try L20n live in your browser on the project page">L20n.org</a></li>
+ <li><a href="http://l20n.github.io/tinker/" title="Test out your own L20n code in L20n Tinker">L20n Tinker</a></li>
+ <li><a href="https://github.com/l20n/l20n.js" title="Where the main code for the L20n infrastructure and language lives">L20n GitHub repo</a></li>
+ <li><a href="https://wiki.mozilla.org/L20n" title="Info about the project to develop L20n">Mozilla Wiki</a></li>
+ </ol>
+ </li>
+</ol>
diff --git a/files/zh-cn/mozilla/projects/nspr/index.html b/files/zh-cn/mozilla/projects/nspr/index.html
new file mode 100644
index 0000000000..2ae2b7b9d5
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/nspr/index.html
@@ -0,0 +1,60 @@
+---
+title: NSPR
+slug: Mozilla/Projects/NSPR
+translation_of: Mozilla/Projects/NSPR
+---
+<h2 id="Netscape_Portable_Runtime_(NSPR)_提供一套面向系统级的与平台无关的_API_和类似于libc的函数._这些API被用在Mozilla客户端_Red_Hat公司、Sun公司的服务应用程序以及其他公司的一些软件中。"><strong>Netscape Portable Runtime</strong> (<strong>NSPR</strong>)  提供一套面向系统级的与平台无关的 API  和类似于libc的函数. 这些API被用在Mozilla客户端, Red Hat公司、Sun公司的服务应用程序以及其他公司的一些软件中。</h2>
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h2 id="Documentation" name="Documentation"><a href="/Special:Tags?tag=NSPR&amp;language=en" title="Special:Tags?tag=NSPR&amp;language=en">文档</a></h2>
+ <dl>
+ <dt>
+ <a class="external" href="http://www.mozilla.org/projects/nspr/">NSPR工程页面</a></dt>
+ <dd>
+ <small>Contains some older technical notes and training materials. (at mozilla.org)</small></dd>
+ </dl>
+ <dl>
+ <dt>
+ <a href="/en/About_NSPR" title="en/About_NSPR">关于 NSPR</a></dt>
+ <dd>
+ <small>This topic describes, in general terms, the goals of NSPR and a bit about how it does it.</small></dd>
+ </dl>
+ <dl>
+ <dt>
+ <a href="/en/NSPR_API_Reference" title="en/NSPR_API_Reference">NSPR API Reference</a></dt>
+ <dd>
+ <small>The reference describes each API public macro, structure and function in the NSPR API.</small></dd>
+ </dl>
+ <dl>
+ <dt>
+ <a href="/en/NSPR_build_instructions" title="en/NSPR_build_instructions">NSPR build instructions</a></dt>
+ <dd>
+ <small>How to checkout and build from source.</small></dd>
+ </dl>
+ <dl>
+ <dt>
+ <a href="/en/NSPR_release_process" title="en/NSPR_release_process">NSPR release process</a></dt>
+ <dd>
+ <small>How to prepare an NSPR release.</small></dd>
+ </dl>
+ <p><span class="alllinks"><a href="/Special:Tags?tag=NSPR&amp;language=en" title="Special:Tags?tag=NSPR&amp;language=en">View All...</a></span></p>
+ </td>
+ <td>
+ <h2 id="Community" name="Community">Community</h2>
+ <ul>
+ <li>View Mozilla forums...</li>
+ </ul>
+ <p>{{ DiscussionList("dev-tech-nspr", "mozilla.dev.tech.nspr") }}</p>
+ <h2 id="Related_Topics" name="Related_Topics">Related Topics</h2>
+ <dl>
+ <dd>
+ <a href="/en/Necko" title="en/Necko">Necko</a>, <a href="/en/NSS" title="en/NSS">NSS</a></dd>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
+<p>{{ languages( { "ja": "ja/NSPR", "it": "it/NSPR" } ) }}</p>
diff --git a/files/zh-cn/mozilla/projects/nspr/reference/index.html b/files/zh-cn/mozilla/projects/nspr/reference/index.html
new file mode 100644
index 0000000000..fe690af267
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/nspr/reference/index.html
@@ -0,0 +1,770 @@
+---
+title: NSPR API Reference
+slug: Mozilla/Projects/NSPR/Reference
+tags:
+ - NSPR
+ - NSPR_API_Reference
+ - NeedsTranslation
+ - TopicStub
+translation_of: Mozilla/Projects/NSPR/Reference
+---
+<section id="Quick_Links">
+<ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR">NSPR</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/About_NSPR">About NSPR</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference">NSPR API Reference</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/NSPR_build_instructions">NSPR Build Instruction</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Release_process">NSPR Release Process</a></li>
+ <li class="toggle">
+ <details>
+ <summary>Introduction to NSPR</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#NSPR_Naming_Conventions">NSPR Naming Conventions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#NSPR_Threads">NSPR Threads</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Thread_Schedoling">Thread Scheduling</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Setting_Thread_Priorities">Setting Thread Priorities</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Preempting_Threads">Preempting Threads</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Interrupting_Threads">Interrupting Threads</a></li>
+ </ol>
+ </li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#NSPR_Thread_Synchronization">NSPR Thread Synchronization</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Locks_and_Monitors">Locks and Monitors</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Condition_Variables">Condition Variables</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#NSPR_Sample_Code">NSPR Sample Code</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>NSPR Types</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Calling_Convention_Types">Calling Convention Types</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Algebraic_Types">Algebraic Types</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#8-.2C_16-.2C_and_32-bit_Integer_Types">8-, 16-, and 32-bit Integer Types</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Signed_Integers">Signed Integers</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Unsigned_Integers">Unsigned Integers</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#64-bit_Integer_Types">64-bit Integer Types</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Floating-Point_Number_Type">Floating-Point Integer Type</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Native_OS_Integer_Types">Native OS Integer Types</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Miscellaneous_Types">Miscellaneous Types</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Size_Type">Size Type</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Pointer_Difference_Types">Pointer Difference Types</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Boolean_Types">Boolean Types</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Status_Type_for_Return_Values">Status Type for Return Values</a></li>
+ </ol>
+ </li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Threads</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Threads#Threading_Types_and_Constants">Threading Types and Constants</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Threads#Threading_Functions">Threading Functions</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Threads#Creating.2C_Joining.2C_and_Identifying_Threads">Creating, Joining, and Identifying Threads</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Threads#Controlling_Thread_Priorities">Controlling Thread Priorities</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Threads#Controlling_Per-Thread_Private_Data">Controlling Per-Thread Private Data</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Threads#Interrupting_and_Yielding">Interrupting and Yielding</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Threads#Setting_Global_Thread_Concurrency">Setting Global Thread Concurrency</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Threads#Getting_a_Thread.27s_Scope">Getting a Thread's Scope</a></li>
+ </ol>
+ </li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Process Initialization</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Process_Initialization#Identity_and_Versioning">Identity and Versioning</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Process_Initialization#Name_and_Version_Constants">Name and Version Constants</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Process_Initialization#Initialization_and_Cleanup">Initialization and Cleanup</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Process_Initialization#Module_Initialization">Module Initialization</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Locks</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Locks#Lock_Type">Lock Type</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Locks#Lock_Functions">Lock Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Condition Variables</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Condition_Variables#Condition_Variable_Type">Condition Variable Type</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Condition_Variables#Condition_Variable_Functions">Condition Variable Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Monitors</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Monitors#Monitor_Type">Monitor Type</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Monitors#Monitor_Functions">Monitor Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Cached Monitors</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Cached_Monitors#Cached_Monitor_Functions">Cached Monitor Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>I/O Types</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Types#Directory_Type">Directory Type</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Types#File_Descriptor_Types">File Descriptor Types</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Types#File_Info_Types">File Info Types</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Types#Network_Address_Types">Network Address Types</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Types#Types_Used_with_Socket_Options_Functions">Types Used with Socket Options Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Types#Type_Used_with_Memory-Mapped_I.2FO">Type Used with Memory-Mapped I/O</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Types#Offset_Interpretation_for_Seek_Functions">Offset Interpretation for Seek Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>I/O Functions</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Functions_that_Operate_on_Pathnames">Functions that Operate on Pathnames</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Functions_that_Act_on_File_Descriptors">Functions that Act on File Descriptors</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Directory_I.2FO_Functions">Directory I/O Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Socket_Manipolation_Functions">Socket Manipolation Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Converting_Between_Host_and_Network_Addresses">Converting Between Host and Network Addresses</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Memory-Mapped_I.2FO_Functions">Memory-Mapped I/O Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Anonymous_Pipe_Function">Anonymous Pipe Function</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Polling_Functions">Polling Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Pollable_Events">Pollable Events</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Manipulating_Layers">Manipulating Layers</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Network Addresses</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Network_Addresses#Network_Address_Types_and_Constants">Network Address Types and Constants</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Network_Addresses#Network_Address_Functions">Network Address Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Atomic Operations</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_AtomicIncrement">PR_AtomicIncrement</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_AtomicDecrement">PR_AtomicDecrement</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_AtomicSet">PR_AtomicSet</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Interval Timing</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Interval_Timing#Interval_Time_Type_and_Constants">Interval Time Type and Constants</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Interval_Timing#Interval_Functions">Interval Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Date and Time</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Date_and_Time#Types_and_Constants">Types and Constants</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Date_and_Time#Time_Parameter_Callback_Functions">Time Parameter Callback Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Date_and_Time#Functions">Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Memory Management Operations</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Memory_Management_Operations#Memory_Allocation_Functions">Memory Allocation Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Memory_Management_Operations#Memory_Allocation_Macros">Memory Allocation Macros</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>String Operations</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PL_strlen">PL_strlen</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PL_strcpy">PL_strcpy</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PL_strdup">PL_strdup</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PL_strfree">PL_strfree</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Floating Point Number to String Conversion</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_strtod">PR_strtod</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_dtoa">PR_dtoa</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_cnvtf">PR_cnvtf</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Linked Lists</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Linked_Lists#Linked_List_Types">Linked List Types</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PRCList">PRCList</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Linked_Lists#Linked_List_Macros">Linked List Macros</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_INIT_CLIST">PR_INIT_CLIST</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_INIT_STATIC_CLIST">PR_INIT_STATIC_CLIST</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_APPEND_LINK">PR_APPEND_LINK</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_INSERT_LINK">PR_INSERT_LINK</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_NEXT_LINK">PR_NEXT_LINK</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_PREV_LINK">PR_PREV_LINK</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_REMOVE_LINK">PR_REMOVE_LINK</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_REMOVE_AND_INIT_LINK">PR_REMOVE_AND_INIT_LINK</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_INSERT_BEFORE">PR_INSERT_BEFORE</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_INSERT_AFTER">PR_INSERT_AFTER</a></li>
+ </ol>
+ </li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Dynamic Library Linking</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Library_Linking_Types">Library Linking Types</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PRLibrary">PRLibrary</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PRStaticLinkTable">PRStaticLinkTable</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Library_Linking_Functions">Library Linking Functions</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_SetLibraryPath">PR_SetLibraryPath</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_GetLibraryPath">PR_GetLibraryPath</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_GetLibraryName">PR_GetLibraryName</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_FreeLibraryName">PR_FreeLibraryName</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_LoadLibrary">PR_LoadLibrary</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_UnloadLibrary">PR_UnloadLibrary</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_FindSymbol">PR_FindSymbol</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_FindSymbolAndLibrary">PR_FindSymbolAndLibrary</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Finding_Symbols_Defined_in_the_Main_Executable_Program">Finding Symbols Defined in the Main Executable Program</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Platform_Notes">Platform Notes</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Dynamic_Library_Search_Path">Dynamic Library Search Path</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Exporting_Symbols_from_the_Main_Executable_Program">Exporting Symbols from the Main Executable Program</a></li>
+ </ol>
+ </li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Process Management and Interprocess Communication</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Process_Management_and_Interprocess_Communication#Process_Management_Types_and_Constants">Process Management Types and Constants</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PRProcess">PRProcess</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PRProcessAttr">PRProcessAttr</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/en-US/docs/Mozilla/Projects/NSPR/Reference/Process_Management_and_Interprocess_Communication#Process_Management_Functions">Process Management Functions</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Process_Management_and_Interprocess_Communication#Setting_the_Attributes_of_a_New_Process">Setting the Attributes of a New Process</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Process_Management_and_Interprocess_Communication#Creating_and_Managing_Processes">Creating and Managing Processes</a></li>
+ </ol>
+ </li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Logging</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Logging#Conditional_Compilation_and_Execution">Conditional Compilation and Execution</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Logging#Log_Types_and_Variables">Log Types and Variables</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PRLogModoleInfo">PRLogModoleInfo</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PRLogModoleLevel">PRLogModoleLevel</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_LOG_MODULES">NSPR_LOG_MODULES</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_LOG_FILE">NSPR_LOG_FILE</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Logging#Logging_Functions_and_Macros">Logging Functions and Macros</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_NewLogModole">PR_NewLogModole</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_SetLogFile">PR_SetLogFile</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_SetLogBuffering">PR_SetLogBuffering</a>/li&gt;
+ </li><li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_LogPrint">PR_LogPrint</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_LogFlush">PR_LogFlush</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_LOG_TEST">PR_LOG_TEST</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_LOG">PR_LOG</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_Assert_">PR_Assert</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_ASSERT">PR_ASSERT</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_NOT_REACHED">PR_NOT_REACHED</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Logging#Use_Example">Use Example</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Named Shared Memory</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Named_Shared_Memory#Shared_Memory_Protocol">Shared Memory Protocol</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Named_Shared_Memory#Named_Shared_Memory_Functions">Named Shared Memory Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Anonymous Shared Memory</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Anonymous_Shared_Memory#Anonymous_Memory_Protocol">Anonymous Memory Protocol</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Anonymous_Shared_Memory#Anonymous_Shared_Memory_Functions">Anonymous Shared Memory Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>IPC Semaphores</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/IPC_Semaphores#IPC_Semaphore_Functions">IPC Semaphore Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Thread Pools</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Thread_Pools#Thread_Pool_Types">Thread Pool Types</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Thread_Pools#Thread_Pool_Functions">Thread Pool Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Random Number Generator</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Random_Number_Generator#Random_Number_Generator_Function">Random Number Generator Function</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Hash Tables</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Hash_Tables#Hash_Tables_and_Type_Constants">Hash Tables and Type Constants</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Hash_Tables#Hash_Table_Functions">Hash Table Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>NSPR Error Handling</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Error_Handling#Error_Type">Error Type</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Error_Handling#Error_Functions">Error Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Error_Handling#Error_Codes">Error Codes</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Contribute</summary>
+ <ol>
+ <li><a href="/en-US/docs/MDN/Doc_status/NSPR"></a></li>
+ <li><a href="/en-US/docs/MDN">The MDN Project</a></li>
+ </ol>
+ </details>
+ </li>
+ </ol>
+</section>
+
+<h2 id="Introduction_to_NSPR" name="Introduction_to_NSPR"><a href="/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR">Introduction to NSPR</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#NSPR_Naming_Conventions">NSPR Naming Conventions</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#NSPR_Threads">NSPR Threads</a>
+ <ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Thread_Scheduling">Thread Scheduling</a>
+ <ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Setting_Thread_Priorities">Setting Thread Priorities</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Preempting_Threads">Preempting Threads</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Interrupting_Threads">Interrupting Threads</a></li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#NSPR_Thread_Synchronization">NSPR Thread Synchronization</a>
+ <ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Locks_and_Monitors">Locks and Monitors</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Condition_Variables">Condition Variables</a></li>
+ </ul>
+ </li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#NSPR_Sample_Code">NSPR Sample Code</a></li>
+</ul>
+
+<h2 id="NSPR_Types" name="NSPR_Types"><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Types">NSPR Types</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Types#Calling_Convention_Types">Calling Convention Types</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Types#Algebraic_Types">Algebraic Types</a>
+ <ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Types#8-.2C_16-.2C_and_32-bit_Integer_Types">8-, 16-, and 32-bit Integer Types</a>
+ <ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Types#Signed_Integers">Signed Integers</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Types#Unsigned_Integers">Unsigned Integers</a></li>
+ </ul>
+ </li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Types#64-bit_Integer_Types">64-bit Integer Types</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Types#Floating-Point_Number_Type">Floating-Point Integer Type</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Types#Native_OS_Integer_Types">Native OS Integer Types</a></li>
+ </ul>
+ </li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Types#Miscellaneous_Types">Miscellaneous Types</a>
+ <ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Types#Size_Type">Size Type</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Types#Pointer_Difference_Types">Pointer Difference Types</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Types#Boolean_Types">Boolean Types</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Types#Status_Type_for_Return_Values">Status Type for Return Values</a></li>
+ </ul>
+ </li>
+</ul>
+
+<h2 id="Threads" name="Threads"><a href="/Mozilla/Projects/NSPR/Reference/Threads">Threads</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Threads#Threading_Types_and_Constants">Threading Types and Constants</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Threads#Threading_Functions">Threading Functions</a>
+ <ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Threads#Creating.2C_Joining.2C_and_Identifying_Threads">Creating, Joining, and Identifying Threads</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Threads#Controlling_Thread_Priorities">Controlling Thread Priorities</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Threads#Controlling_Per-Thread_Private_Data">Controlling Per-Thread Private Data</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Threads#Interrupting_and_Yielding">Interrupting and Yielding</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Threads#Setting_Global_Thread_Concurrency">Setting Global Thread Concurrency</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Threads#Getting_a_Thread.27s_Scope">Getting a Thread's Scope</a></li>
+ </ul>
+ </li>
+</ul>
+
+<h2 id="Process_Initialization" name="Process_Initialization"><a href="/Mozilla/Projects/NSPR/Reference/Process_Initialization">Process Initialization</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Process_Initialization#Identity_and_Versioning">Identity and Versioning</a>
+
+ <ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Process_Initialization#Name_and_Version_Constants">Name and Version Constants</a></li>
+ </ul>
+ </li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Process_Initialization#Initialization_and_Cleanup">Initialization and Cleanup</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Process_Initialization#Module_Initialization">Module Initialization</a></li>
+</ul>
+
+<h2 id="Locks" name="Locks"><a href="/Mozilla/Projects/NSPR/Reference/Locks">Locks</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Locks#Lock_Type">Lock Type</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Locks#Lock_Functions">Lock Functions</a></li>
+</ul>
+
+<h2 id="Condition_Variables" name="Condition_Variables"><a href="/Mozilla/Projects/NSPR/Reference/Condition_Variables">Condition Variables</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Condition_Variables#Condition_Variable_Type">Condition Variable Type</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Condition_Variables#Condition_Variable_Functions">Condition Variable Functions</a></li>
+</ul>
+
+<h2 id="Monitors" name="Monitors"><a href="/Mozilla/Projects/NSPR/Reference/Monitors">Monitors</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Monitors#Monitor_Type">Monitor Type</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Monitors#Monitor_Functions">Monitor Functions</a></li>
+</ul>
+
+<h2 id="Cached_Monitors" name="Cached_Monitors"><a href="/Mozilla/Projects/NSPR/Reference/Cached_Monitors">Cached Monitors</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Cached_Monitors#Cached_Monitor_Functions">Cached Monitor Functions</a></li>
+</ul>
+
+<h2 id="I.2FO_Types" name="I.2FO_Types"><a href="/Mozilla/Projects/NSPR/Reference/I_O_Types">I/O Types</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Types#Directory_Type">Directory Type</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Types#File_Descriptor_Types">File Descriptor Types</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Types#File_Info_Types">File Info Types</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Types#Network_Address_Types">Network Address Types</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Types#Types_Used_with_Socket_Options_Functions">Types Used with Socket Options Functions</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Types#Type_Used_with_Memory-Mapped_I.2FO">Type Used with Memory-Mapped I/O</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Types#Offset_Interpretation_for_Seek_Functions">Offset Interpretation for Seek Functions</a></li>
+</ul>
+
+<h2 id="I.2FO_Functions" name="I.2FO_Functions"><a href="/Mozilla/Projects/NSPR/Reference/I_O_Functions">I/O Functions</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Functions#Functions_that_Operate_on_Pathnames">Functions that Operate on Pathnames</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Functions#Functions_that_Act_on_File_Descriptors">Functions that Act on File Descriptors</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Functions#Directory_I.2FO_Functions">Directory I/O Functions</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Functions#Socket_Manipulation_Functions">Socket Manipulation Functions</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Functions#Converting_Between_Host_and_Network_Addresses">Converting Between Host and Network Addresses</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Functions#Memory-Mapped_I.2FO_Functions">Memory-Mapped I/O Functions</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Functions#Anonymous_Pipe_Function">Anonymous Pipe Function</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Functions#Polling_Functions">Polling Functions</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Functions#Pollable_Events">Pollable Events</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/I_O_Functions#Manipulating_Layers">Manipulating Layers</a></li>
+</ul>
+
+<h2 id="Network_Addresses" name="Network_Addresses"><a href="/Mozilla/Projects/NSPR/Reference/Network_Addresses">Network Addresses</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Network_Addresses#Network_Address_Types_and_Constants">Network Address Types and Constants</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Network_Addresses#Network_Address_Functions">Network Address Functions</a></li>
+</ul>
+
+<h2 id="Atomic_Operations" name="Atomic_Operations"><a href="/Mozilla/Projects/NSPR/Reference/Atomic_Operations">Atomic Operations</a></h2>
+
+<ul>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_AtomicIncrement">PR_AtomicIncrement</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_AtomicDecrement">PR_AtomicDecrement</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_AtomicSet">PR_AtomicSet</a></code></li>
+</ul>
+
+<h2 id="Interval_Timing" name="Interval_Timing"><a href="/Mozilla/Projects/NSPR/Reference/Interval_Timing">Interval Timing</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Interval_Timing#Interval_Time_Type_and_Constants">Interval Time Type and Constants</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Interval_Timing#Interval_Functions">Interval Functions</a></li>
+</ul>
+
+<h2 id="Date_and_Time" name="Date_and_Time"><a href="/Mozilla/Projects/NSPR/Reference/Date_and_Time">Date and Time</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Date_and_Time#Types_and_Constants">Types and Constants</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Date_and_Time#Time_Parameter_Callback_Functions">Time Parameter Callback Functions</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Date_and_Time#Functions">Functions</a></li>
+</ul>
+
+<h2 id="Memory_Management_Operations" name="Memory_Management_Operations"><a href="/Mozilla/Projects/NSPR/Reference/Memory_Management_Operations">Memory Management Operations</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Memory_Management_Operations#Memory_Allocation_Functions">Memory Allocation Functions</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Memory_Management_Operations#Memory_Allocation_Macros">Memory Allocation Macros</a></li>
+</ul>
+
+<h2 id="String_Operations" name="String_Operations"><a href="/Mozilla/Projects/NSPR/Reference/String_Operations">String Operations</a></h2>
+
+<ul>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PL_strlen">PL_strlen</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PL_strcpy">PL_strcpy</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PL_strdup">PL_strdup</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PL_strfree">PL_strfree</a></code></li>
+</ul>
+
+<h2 id="Floating_Point_Number_to_String_Conversion" name="Floating_Point_Number_to_String_Conversion"><a href="/Mozilla/Projects/NSPR/Reference/Floating_Point_Number_to_String_Conversion">Floating Point Number to String Conversion</a></h2>
+
+<ul>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_strtod">PR_strtod</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_dtoa">PR_dtoa</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_cnvtf">PR_cnvtf</a></code></li>
+</ul>
+
+<h2 id="Long_Long_.2864-bit.29_Integers" name="Long_Long_.2864-bit.29_Integers">Long Long (64-bit) Integers</h2>
+
+<h2 id="BitMaps" name="BitMaps">BitMaps</h2>
+
+<h2 id="Formatted_Printing" name="Formatted_Printing">Formatted Printing</h2>
+
+<h2 id="Linked_Lists" name="Linked_Lists"><a href="/Mozilla/Projects/NSPR/Reference/Linked_Lists">Linked Lists</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Linked_Lists#Linked_List_Types">Linked List Types</a>
+
+ <ul>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PRCList">PRCList</a></code></li>
+ </ul>
+ </li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Linked_Lists#Linked_List_Macros">Linked List Macros</a>
+ <ul>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_INIT_CLIST">PR_INIT_CLIST</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_INIT_STATIC_CLIST">PR_INIT_STATIC_CLIST</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_APPEND_LINK">PR_APPEND_LINK</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_INSERT_LINK">PR_INSERT_LINK</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_NEXT_LINK">PR_NEXT_LINK</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_PREV_LINK">PR_PREV_LINK</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_REMOVE_LINK">PR_REMOVE_LINK</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_REMOVE_AND_INIT_LINK">PR_REMOVE_AND_INIT_LINK</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_INSERT_BEFORE">PR_INSERT_BEFORE</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_INSERT_AFTER">PR_INSERT_AFTER</a></code></li>
+ </ul>
+ </li>
+</ul>
+
+<h2 id="Dynamic_Library_Linking" name="Dynamic_Library_Linking"><a href="/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking">Dynamic Library Linking</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Library_Linking_Types">Library Linking Types</a>
+
+ <ul>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PRLibrary">PRLibrary</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PRStaticLinkTable">PRStaticLinkTable</a></code></li>
+ </ul>
+ </li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Library_Linking_Functions">Library Linking Functions</a>
+ <ul>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_SetLibraryPath">PR_SetLibraryPath</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_GetLibraryPath">PR_GetLibraryPath</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_GetLibraryName">PR_GetLibraryName</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_FreeLibraryName">PR_FreeLibraryName</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_LoadLibrary">PR_LoadLibrary</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_UnloadLibrary">PR_UnloadLibrary</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_FindSymbol">PR_FindSymbol</a></code></li>
+ <li><code><a href="/Mozilla/Projects/NSPR/Reference/PR_FindSymbolAndLibrary">PR_FindSymbolAndLibrary</a></code></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Finding_Symbols_Defined_in_the_Main_Executable_Program">Finding Symbols Defined in the Main Executable Program</a></li>
+ </ul>
+ </li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Platform_Notes">Platform Notes</a>
+ <ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Dynamic_Library_Search_Path">Dynamic Library Search Path</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Exporting_Symbols_from_the_Main_Executable_Program">Exporting Symbols from the Main Executable Program </a></li>
+ </ul>
+ </li>
+</ul>
+
+<h2 id="Process_Management_and_Interprocess_Communication" name="Process_Management_and_Interprocess_Communication"><a href="/En/NSPR_API_Reference/Process_Management_and_Interprocess_Communication">Process Management and Interprocess Communication</a></h2>
+
+<ul>
+ <li><a class="internal" href="/En/NSPR_API_Reference/Process_Management_and_Interprocess_Communication#Process_Management_Types_and_Constants">Process Management Types and Constants</a>
+
+ <ul>
+ <li><code><a class="internal" href="/En/PRProcess">PRProcess</a></code></li>
+ <li><code><a class="internal" href="/En/PRProcessAttr">PRProcessAttr</a></code></li>
+ </ul>
+ </li>
+ <li><a class="internal" href="/En/NSPR_API_Reference/Process_Management_and_Interprocess_Communication#Process_Management_Functions">Process Management Functions</a>
+ <ul>
+ <li><a class="internal" href="/En/NSPR_API_Reference/Process_Management_and_Interprocess_Communication#Setting_the_Attributes_of_a_New_Process">Setting the Attributes of a New Process</a></li>
+ <li><a class="internal" href="/En/NSPR_API_Reference/Process_Management_and_Interprocess_Communication#Creating_and_Managing_Processes">Creating and Managing Processes</a></li>
+ </ul>
+ </li>
+</ul>
+
+<h2 id="Multiwait_Receive" name="Multiwait_Receive">Multiwait Receive</h2>
+
+<h2 id="System_Information_and_Environment_Variables" name="System_Information_and_Environment_Variables">System Information and Environment Variables</h2>
+
+<h2 id="Logging" name="Logging"><a href="/NSPR_API_Reference/Logging">Logging</a></h2>
+
+<ul>
+ <li><a href="/NSPR_API_Reference/Logging#Conditional_Compilation_and_Execution">Conditional Compilation and Execution</a></li>
+ <li><a href="/NSPR_API_Reference/Logging#Log_Types_and_Variables">Log Types and Variables</a>
+ <ul>
+ <li><code><a href="/docs/Mozilla/Projects/NSPR/Reference/Logging/PRLogModuleInfo">PRLogModuleInfo</a></code></li>
+ <li><code><a href="/docs/Mozilla/Projects/NSPR/Reference/Logging/PRLogModuleLevel">PRLogModuleLevel</a></code></li>
+ <li><code><a href="/docs/Mozilla/Projects/NSPR/Reference/Logging/NSPR_LOG_MODULES">NSPR_LOG_MODULES</a></code></li>
+ <li><code><a href="/docs/Mozilla/Projects/NSPR/Reference/Logging/NSPR_LOG_FILE">NSPR_LOG_FILE</a></code></li>
+ </ul>
+ </li>
+ <li><a href="/NSPR_API_Reference/Logging#Logging_Functions_and_Macros">Logging Functions and Macros</a>
+ <ul>
+ <li><code><a href="PR_NewLogModule">PR_NewLogModule</a></code></li>
+ <li><code><a href="PR_SetLogFile">PR_SetLogFile</a></code></li>
+ <li><code><a href="PR_SetLogBuffering">PR_SetLogBuffering</a></code></li>
+ <li><code><a href="PR_LogPrint">PR_LogPrint</a></code></li>
+ <li><code><a href="PR_LogFlush">PR_LogFlush</a></code></li>
+ <li><code><a href="PR_LOG_TEST">PR_LOG_TEST</a></code></li>
+ <li><code><a href="PR_LOG">PR_LOG</a></code></li>
+ <li><code><a href="PR_Assert_">PR_Assert</a></code></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_ASSERT">PR_ASSERT</a></li>
+ <li><code><a href="PR_NOT_REACHED">PR_NOT_REACHED</a></code></li>
+ </ul>
+ </li>
+ <li><a href="/NSPR_API_Reference/Logging#Use_Example">Use Example</a></li>
+</ul>
+
+<h2 id="Instrumentation_Counters" name="Instrumentation_Counters">Instrumentation Counters</h2>
+
+<h2 id="Named_Shared_Memory" name="Named_Shared_Memory"><a href="/Mozilla/Projects/NSPR/Reference/Named_Shared_Memory">Named Shared Memory</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Named_Shared_Memory#Shared_Memory_Protocol">Shared Memory Protocol</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Named_Shared_Memory#Named_Shared_Memory_Functions">Named Shared Memory Functions</a></li>
+</ul>
+
+<h2 id="Anonymous_Shared_Memory" name="Anonymous_Shared_Memory"><a href="/Mozilla/Projects/NSPR/Reference/Anonymous_Shared_Memory">Anonymous Shared Memory</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Anonymous_Shared_Memory#Anonymous_Memory_Protocol">Anonymous Memory Protocol</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Anonymous_Shared_Memory#Anonymous_Shared_Memory_Functions">Anonymous Shared Memory Functions</a></li>
+</ul>
+
+<h2 id="IPC_Semaphores" name="IPC_Semaphores"><a href="/Mozilla/Projects/NSPR/Reference/IPC_Semaphores">IPC Semaphores</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/IPC_Semaphores#IPC_Semaphore_Functions">IPC Semaphore Functions</a></li>
+</ul>
+
+<h2 id="Thread_Pools" name="Thread_Pools"><a href="/Mozilla/Projects/NSPR/Reference/Thread_Pools">Thread Pools</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Thread_Pools#Thread_Pool_Types">Thread Pool Types</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Thread_Pools#Thread_Pool_Functions">Thread Pool Functions</a></li>
+</ul>
+
+<h2 id="Random_Number_Generator" name="Random_Number_Generator"><a href="/Mozilla/Projects/NSPR/Reference/Random_Number_Generator">Random Number Generator</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Random_Number_Generator#Random_Number_Generator_Function">Random Number Generator Function</a></li>
+</ul>
+
+<h2 id="Hash_Tables" name="Hash_Tables"><a href="/Mozilla/Projects/NSPR/Reference/Hash_Tables">Hash Tables</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Hash_Tables#Hash_Tables_and_Type_Constants">Hash Tables and Type Constants</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/Hash_Tables#Hash_Table_Functions">Hash Table Functions</a></li>
+</ul>
+
+<h2 id="NSPR_Error_Handling" name="NSPR_Error_Handling"><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Error_Handling">NSPR Error Handling</a></h2>
+
+<ul>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Error_Handling#Error_Type">Error Type</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Error_Handling#Error_Functions">Error Functions</a></li>
+ <li><a href="/Mozilla/Projects/NSPR/Reference/NSPR_Error_Handling#Error_Codes">Error Codes</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/projects/nspr/reference/memory_management_operations/index.html b/files/zh-cn/mozilla/projects/nspr/reference/memory_management_operations/index.html
new file mode 100644
index 0000000000..9fbb05ae70
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/nspr/reference/memory_management_operations/index.html
@@ -0,0 +1,424 @@
+---
+title: 内存管理操作
+slug: Mozilla/Projects/NSPR/Reference/Memory_Management_Operations
+tags:
+ - GC
+ - NSPR
+translation_of: Mozilla/Projects/NSPR/Reference/Memory_Management_Operations
+---
+<section id="Quick_Links">
+<ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR">NSPR</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/About_NSPR">About NSPR</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference">NSPR API Reference</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/NSPR_build_instructions">NSPR Build Instruction</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Release_process">NSPR Release Process</a></li>
+ <li class="toggle">
+ <details><summary>Introduction to NSPR</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#NSPR_Naming_Conventions">NSPR Naming Conventions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#NSPR_Threads">NSPR Threads</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Thread_Schedoling">Thread Scheduling</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Setting_Thread_Priorities">Setting Thread Priorities</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Preempting_Threads">Preempting Threads</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Interrupting_Threads">Interrupting Threads</a></li>
+ </ol>
+ </li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#NSPR_Thread_Synchronization">NSPR Thread Synchronization</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Locks_and_Monitors">Locks and Monitors</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Condition_Variables">Condition Variables</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#NSPR_Sample_Code">NSPR Sample Code</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>NSPR Types</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Calling_Convention_Types">Calling Convention Types</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Algebraic_Types">Algebraic Types</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#8-.2C_16-.2C_and_32-bit_Integer_Types">8-, 16-, and 32-bit Integer Types</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Signed_Integers">Signed Integers</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Unsigned_Integers">Unsigned Integers</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#64-bit_Integer_Types">64-bit Integer Types</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Floating-Point_Number_Type">Floating-Point Integer Type</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Native_OS_Integer_Types">Native OS Integer Types</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Miscellaneous_Types">Miscellaneous Types</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Size_Type">Size Type</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Pointer_Difference_Types">Pointer Difference Types</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Boolean_Types">Boolean Types</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types#Status_Type_for_Return_Values">Status Type for Return Values</a></li>
+ </ol>
+ </li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Threads</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Threads#Threading_Types_and_Constants">Threading Types and Constants</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Threads#Threading_Functions">Threading Functions</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Threads#Creating.2C_Joining.2C_and_Identifying_Threads">Creating, Joining, and Identifying Threads</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Threads#Controlling_Thread_Priorities">Controlling Thread Priorities</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Threads#Controlling_Per-Thread_Private_Data">Controlling Per-Thread Private Data</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Threads#Interrupting_and_Yielding">Interrupting and Yielding</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Threads#Setting_Global_Thread_Concurrency">Setting Global Thread Concurrency</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Threads#Getting_a_Thread.27s_Scope">Getting a Thread's Scope</a></li>
+ </ol>
+ </li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Process Initialization</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Process_Initialization#Identity_and_Versioning">Identity and Versioning</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Process_Initialization#Name_and_Version_Constants">Name and Version Constants</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Process_Initialization#Initialization_and_Cleanup">Initialization and Cleanup</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Process_Initialization#Module_Initialization">Module Initialization</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Locks</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Locks#Lock_Type">Lock Type</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Locks#Lock_Functions">Lock Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Condition Variables</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Condition_Variables#Condition_Variable_Type">Condition Variable Type</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Condition_Variables#Condition_Variable_Functions">Condition Variable Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Monitors</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Monitors#Monitor_Type">Monitor Type</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Monitors#Monitor_Functions">Monitor Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Cached Monitors</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Cached_Monitors#Cached_Monitor_Functions">Cached Monitor Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>I/O Types</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Types#Directory_Type">Directory Type</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Types#File_Descriptor_Types">File Descriptor Types</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Types#File_Info_Types">File Info Types</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Types#Network_Address_Types">Network Address Types</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Types#Types_Used_with_Socket_Options_Functions">Types Used with Socket Options Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Types#Type_Used_with_Memory-Mapped_I.2FO">Type Used with Memory-Mapped I/O</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Types#Offset_Interpretation_for_Seek_Functions">Offset Interpretation for Seek Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>I/O Functions</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Functions_that_Operate_on_Pathnames">Functions that Operate on Pathnames</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Functions_that_Act_on_File_Descriptors">Functions that Act on File Descriptors</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Directory_I.2FO_Functions">Directory I/O Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Socket_Manipolation_Functions">Socket Manipolation Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Converting_Between_Host_and_Network_Addresses">Converting Between Host and Network Addresses</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Memory-Mapped_I.2FO_Functions">Memory-Mapped I/O Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Anonymous_Pipe_Function">Anonymous Pipe Function</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Polling_Functions">Polling Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Pollable_Events">Pollable Events</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/I_O_Functions#Manipulating_Layers">Manipulating Layers</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Network Addresses</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Network_Addresses#Network_Address_Types_and_Constants">Network Address Types and Constants</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Network_Addresses#Network_Address_Functions">Network Address Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Atomic Operations</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_AtomicIncrement">PR_AtomicIncrement</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_AtomicDecrement">PR_AtomicDecrement</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_AtomicSet">PR_AtomicSet</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Interval Timing</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Interval_Timing#Interval_Time_Type_and_Constants">Interval Time Type and Constants</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Interval_Timing#Interval_Functions">Interval Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Date and Time</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Date_and_Time#Types_and_Constants">Types and Constants</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Date_and_Time#Time_Parameter_Callback_Functions">Time Parameter Callback Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Date_and_Time#Functions">Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details open><summary>Memory Management Operations</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Memory_Management_Operations#Memory_Allocation_Functions">Memory Allocation Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Memory_Management_Operations#Memory_Allocation_Macros">Memory Allocation Macros</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>String Operations</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PL_strlen">PL_strlen</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PL_strcpy">PL_strcpy</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PL_strdup">PL_strdup</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PL_strfree">PL_strfree</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Floating Point Number to String Conversion</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_strtod">PR_strtod</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_dtoa">PR_dtoa</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_cnvtf">PR_cnvtf</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Linked Lists</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Linked_Lists#Linked_List_Types">Linked List Types</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PRCList">PRCList</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Linked_Lists#Linked_List_Macros">Linked List Macros</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_INIT_CLIST">PR_INIT_CLIST</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_INIT_STATIC_CLIST">PR_INIT_STATIC_CLIST</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_APPEND_LINK">PR_APPEND_LINK</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_INSERT_LINK">PR_INSERT_LINK</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_NEXT_LINK">PR_NEXT_LINK</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_PREV_LINK">PR_PREV_LINK</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_REMOVE_LINK">PR_REMOVE_LINK</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_REMOVE_AND_INIT_LINK">PR_REMOVE_AND_INIT_LINK</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_INSERT_BEFORE">PR_INSERT_BEFORE</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_INSERT_AFTER">PR_INSERT_AFTER</a></li>
+ </ol>
+ </li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Dynamic Library Linking</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Library_Linking_Types">Library Linking Types</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PRLibrary">PRLibrary</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PRStaticLinkTable">PRStaticLinkTable</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Library_Linking_Functions">Library Linking Functions</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_SetLibraryPath">PR_SetLibraryPath</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_GetLibraryPath">PR_GetLibraryPath</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_GetLibraryName">PR_GetLibraryName</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_FreeLibraryName">PR_FreeLibraryName</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_LoadLibrary">PR_LoadLibrary</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_UnloadLibrary">PR_UnloadLibrary</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_FindSymbol">PR_FindSymbol</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_FindSymbolAndLibrary">PR_FindSymbolAndLibrary</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Finding_Symbols_Defined_in_the_Main_Executable_Program">Finding Symbols Defined in the Main Executable Program</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Platform_Notes">Platform Notes</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Dynamic_Library_Search_Path">Dynamic Library Search Path</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Dynamic_Library_Linking#Exporting_Symbols_from_the_Main_Executable_Program">Exporting Symbols from the Main Executable Program</a></li>
+ </ol>
+ </li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Process Management and Interprocess Communication</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Process_Management_and_Interprocess_Communication#Process_Management_Types_and_Constants">Process Management Types and Constants</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PRProcess">PRProcess</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PRProcessAttr">PRProcessAttr</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/en-US/docs/Mozilla/Projects/NSPR/Reference/Process_Management_and_Interprocess_Communication#Process_Management_Functions">Process Management Functions</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Process_Management_and_Interprocess_Communication#Setting_the_Attributes_of_a_New_Process">Setting the Attributes of a New Process</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Process_Management_and_Interprocess_Communication#Creating_and_Managing_Processes">Creating and Managing Processes</a></li>
+ </ol>
+ </li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Logging</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Logging#Conditional_Compilation_and_Execution">Conditional Compilation and Execution</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Logging#Log_Types_and_Variables">Log Types and Variables</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PRLogModoleInfo">PRLogModoleInfo</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PRLogModoleLevel">PRLogModoleLevel</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_LOG_MODULES">NSPR_LOG_MODULES</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_LOG_FILE">NSPR_LOG_FILE</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Logging#Logging_Functions_and_Macros">Logging Functions and Macros</a>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_NewLogModole">PR_NewLogModole</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_SetLogFile">PR_SetLogFile</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_SetLogBuffering">PR_SetLogBuffering</a>/li&gt;</li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_LogPrint">PR_LogPrint</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_LogFlush">PR_LogFlush</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_LOG_TEST">PR_LOG_TEST</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_LOG">PR_LOG</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_Assert_">PR_Assert</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_ASSERT">PR_ASSERT</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_NOT_REACHED">PR_NOT_REACHED</a></li>
+ </ol>
+ </li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Logging#Use_Example">Use Example</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Named Shared Memory</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Named_Shared_Memory#Shared_Memory_Protocol">Shared Memory Protocol</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Named_Shared_Memory#Named_Shared_Memory_Functions">Named Shared Memory Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Anonymous Shared Memory</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Anonymous_Shared_Memory#Anonymous_Memory_Protocol">Anonymous Memory Protocol</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Anonymous_Shared_Memory#Anonymous_Shared_Memory_Functions">Anonymous Shared Memory Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>IPC Semaphores</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/IPC_Semaphores#IPC_Semaphore_Functions">IPC Semaphore Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Thread Pools</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Thread_Pools#Thread_Pool_Types">Thread Pool Types</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Thread_Pools#Thread_Pool_Functions">Thread Pool Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Random Number Generator</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Random_Number_Generator#Random_Number_Generator_Function">Random Number Generator Function</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Hash Tables</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Hash_Tables#Hash_Tables_and_Type_Constants">Hash Tables and Type Constants</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/Hash_Tables#Hash_Table_Functions">Hash Table Functions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>NSPR Error Handling</summary>
+ <ol>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Error_Handling#Error_Type">Error Type</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Error_Handling#Error_Functions">Error Functions</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Error_Handling#Error_Codes">Error Codes</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details><summary>Contribute</summary>
+ <ol>
+ <li></li>
+ <li><a href="/en-US/docs/MDN">The MDN Project</a></li>
+ </ol>
+ </details>
+ </li>
+</ol>
+</section>
+
+<p>本章介绍用于执行内存管理的全局函数和宏。NSPR 提供基于堆内存管理的函数,映射到熟悉的<code>malloc()</code>, <code>calloc()</code>, <code>realloc()</code>, 和 <code>free()</code>.</p>
+
+<ul>
+ <li><a href="#Memory_Allocation_Functions">Memory Allocation Functions</a></li>
+ <li><a href="#Memory_Allocation_Macros">Memory Allocation Macros</a></li>
+</ul>
+
+<h2 id="Memory_Allocation_Functions" name="Memory_Allocation_Functions">内存分配函数</h2>
+
+<p>NSPR has its own heap, and these functions act on that heap. Libraries built on top of NSPR, such as the Netscape security libraries, use these functions to allocate and free memory. If you are allocating memory for use by such libraries or freeing memory that was allocated by such libraries, you must use these NSPR functions rather than the libc equivalents.</p>
+
+<p>Memory allocation functions are:</p>
+
+<ul>
+ <li><code><a href="PR_Malloc">PR_Malloc</a></code></li>
+ <li><code><a href="PR_Calloc">PR_Calloc</a></code></li>
+ <li><code><a href="PR_Realloc">PR_Realloc</a></code></li>
+ <li><code><a href="PR_Free">PR_Free</a></code></li>
+</ul>
+
+<p><code>PR_Malloc()</code>, <code>PR_Calloc()</code>, <code>PR_Realloc()</code>, and <code>PR_Free()</code> have the same signatures as their libc equivalents <code>malloc()</code>, <code>calloc()</code>, <code>realloc()</code>, and <code>free()</code>, and have the same semantics. (Note that the argument type <code>size_t</code> is replaced by <code>PRUint32</code>.) Memory allocated by <code>PR_Malloc()</code>, <code>PR_Calloc()</code>, or <code>PR_Realloc()</code> must be freed by <code>PR_Free()</code>.</p>
+
+<h2 id="Memory_Allocation_Macros" name="Memory_Allocation_Macros">内存分配 Macros</h2>
+
+<p>Macro versions of the memory allocation functions are available, as well as additional macros that provide programming convenience:</p>
+
+<ul>
+ <li><code><a href="PR_MALLOC">PR_MALLOC</a></code></li>
+ <li><code><a href="PR_NEW">PR_NEW</a></code></li>
+ <li><code><a href="PR_REALLOC">PR_REALLOC</a></code></li>
+ <li><code><a href="PR_CALLOC">PR_CALLOC</a></code></li>
+ <li><code><a href="PR_NEWZAP">PR_NEWZAP</a></code></li>
+ <li><code><a href="PR_DELETE">PR_DELETE</a></code></li>
+ <li><code><a href="PR_FREEIF">PR_FREEIF</a></code></li>
+</ul>
diff --git a/files/zh-cn/mozilla/projects/psm/index.html b/files/zh-cn/mozilla/projects/psm/index.html
new file mode 100644
index 0000000000..69fcd93234
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/psm/index.html
@@ -0,0 +1,15 @@
+---
+title: Personal Security Manager (PSM)
+slug: Mozilla/Projects/PSM
+translation_of: Mozilla/Projects/PSM
+---
+<p>PSM全称为Personal Security Manager,包含了一套在客户应用程序上执行密码操作的代码库。这些操作包括设置SSL连接,对象签名和签名认证,证书管理(包括发行和废弃),和其它通用PKI函数。</p>
+
+<p>注意:</p>
+
+<ul>
+ <li>PSM 现在总是随Firefox一起编译, 所以没有分离的编译命令.</li>
+ <li><a href="http://www-archive.mozilla.org/projects/security/pki/psm/">Archived Information about PSM</a></li>
+</ul>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/projects/rhino/bsf/index.html b/files/zh-cn/mozilla/projects/rhino/bsf/index.html
new file mode 100644
index 0000000000..8cf8b6c13e
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/rhino/bsf/index.html
@@ -0,0 +1,10 @@
+---
+title: BSF
+slug: Mozilla/Projects/Rhino/BSF
+translation_of: Mozilla/Projects/Rhino/BSF
+---
+<h2 id="BSF是什么">BSF是什么?</h2>
+<p><a class="ex-ref external" href="http://jakarta.apache.org/bsf/"><dfn>Bean Scripting Framework (BSF)</dfn></a>起初被IBM开发,后来作为Apache Software Foundation开源代码的一部分.它为Java上的大量的脚本语言提供了一个框架,Rhino是被支持的语言之一.</p>
+<p>这个框架已被大量的开源项目嵌入代码中, 包括 XSL 处理器 <a class="ex-ref external" href="http://xml.apache.org/xalan-j/">Xalan</a> 和  XML/Java 构建工具 <a class="ex-ref external" href="http://ant.apache.org/">Ant</a>. 查看 <a class="ex-ref external" href="http://xml.apache.org/xalan-j/extensions.html">Xalan-Java Extensions</a> 可以获取更多关于把JavaScript添加至XSL、在<a class="ex-ref external" href="http://ant.apache.org/manual/">Apache Ant Manual</a>中使用脚本构建项目时脚本任务的命令项的描述等信息.</p>
+<h2 id="Using_BSF_with_Rhino">Using BSF with Rhino</h2>
+<p>Now that the Apache Jakarta <dfn>Bean Scripting Framework (BSF)</dfn>, version 2.4.0, has been officially released, you can use Rhino easily with BSF. See <a class="ex-ref external" href="http://jakarta.apache.org/bsf/index.html">http://jakarta.apache.org/bsf/index.html</a>.</p>
diff --git a/files/zh-cn/mozilla/projects/rhino/community/index.html b/files/zh-cn/mozilla/projects/rhino/community/index.html
new file mode 100644
index 0000000000..8d5c3a446c
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/rhino/community/index.html
@@ -0,0 +1,24 @@
+---
+title: Rhino社区
+slug: Mozilla/Projects/Rhino/Community
+translation_of: Mozilla/Projects/Rhino/Community
+---
+<p>是否有在<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Documentation">Rhino文档</a>中找不到解答的问题?下面这些资源可以给你一些帮助:</p>
+
+<h4 id="Newsgroup_and_Mail_Gateway" name="Newsgroup_and_Mail_Gateway">邮件列表</h4>
+
+<p>在Google讨论组中有一个叫<a href="https://groups.google.com/group/mozilla-rhino">mozilla-rhino</a>的讨论组,可以讨论Rhino相关的话题.</p>
+
+<p>还有一个比较老的讨论组叫<a href="news://news.mozilla.org/mozilla.dev.tech.js-engine.rhino">mozilla.dev.tech.js-engine.rhino</a>,已经很久没有维护了,请使用新的讨论组,但是这个老的组可能也包含一些比较有历史意义的讨论,可以去参考浏览一下.</p>
+
+<p><a class="link-news" href="news://news.mozilla.org/mozilla.dev.tech.js-engine">mozilla.dev.tech.js-engine</a>这个讨论组讨论的是关于使用C语言实现的Javascript,也有在2007年9月27日之前关于Rhino的讨论.要看在2007年9月27日之前的讨论,请移步一个叫<a class="external" href="http://groups.google.com/group/mozilla.dev.tech.js-engine/topics">Google group for the earlier newsgroup</a>的Google讨论组.</p>
+
+<h4 id="Bug_System" name="Bug_System">Bug 系统</h4>
+
+<p>最好的提交Rhino bug的方式是在Rhino的<a href="https://github.com/mozilla/rhino/issues">Github</a>中提交.</p>
+
+<p>如果你愿意解决一些提交的Bug,我们非常欢迎您解决她,并提交一个<a href="https://github.com/mozilla/rhino/pulls">pull请求</a>.</p>
+
+<p>许多老的Rhino的问题都被记录在<a class="link-https" href="https://bugzilla.mozilla.org/enter_bug.cgi?product=Rhino">Bugzilla</a>中.也许有一些比较有历史意义的bug. 最后注意Rhino有自己的产品类目.</p>
+
+<p>{{ languages( { "ja": "ja/Rhino_help" } ) }}</p>
diff --git a/files/zh-cn/mozilla/projects/rhino/debugger/index.html b/files/zh-cn/mozilla/projects/rhino/debugger/index.html
new file mode 100644
index 0000000000..8b5ab147ca
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/rhino/debugger/index.html
@@ -0,0 +1,220 @@
+---
+title: Rhino Debugger
+slug: Mozilla/Projects/Rhino/Debugger
+translation_of: Mozilla/Projects/Rhino/Debugger
+---
+<p>The Rhino JavaScript debugger is a GUI that allows debugging of interpreted JavaScript scripts run in Rhino. Note that this debugger <strong>will not</strong> work with JavaScript scripts run in the mozilla browser since Rhino is not the engine used in such environments.</p>
+<p><img alt="" height="460" src="jsdebug.jpg" width="600"></p>
+<p>Current limitations:</p>
+<ul>
+ <li>No breakpoint menu</li>
+</ul>
+<h2 id="Using_the_Rhino_JavaScript_Debugger">Using the Rhino JavaScript Debugger</h2>
+<p>The Mozilla Rhino JavaScript engine includes a source-level debugger for debugging JavaScript scripts. The debugger is itself a Java program which you may run as</p>
+<pre class="code" style="white-space: -moz-pre-wrap; white-space: pre-wrap;">java org.mozilla.javascript.tools.debugger.Main [options] [filename.js] [script-arguments]
+
+</pre>
+<p>where the options are the same as the shell.</p>
+<p>The Rhino JavaScript Debugger can debug scripts running in multiple threads and provides facilities to set and clear breakpoints, control execution, view variables, and evaluate arbitrary JavaScript code in the current scope of an executing script.</p>
+<dl>
+ <dt>
+ <a id="console" name="console">Console Window</a></dt>
+ <dd>
+ The debugger redirects the System.out, System.in, and System.err streams to an internal JavaScript console window which provides an editable command line for you to enter JavaScript code and view system output. The console window maintains a history of the commands you have entered. You may move backward and forward through the history list by pressing the Up/Down arrow keys on the keyboard.</dd>
+ <dt>
+ <a id="opening" name="opening">Opening Scripts</a></dt>
+ <dd>
+ You may select the <b>
+ <i>
+ File-&gt;Open</i>
+ </b> menu item on the menu bar to load JavaScript scripts contained in files. This action will display a file-selection dialog box prompting you for the location of a script to load. The selected file will be compiled and displayed in a new window.</dd>
+ <dt>
+ <a id="running" name="running">Running Scripts</a></dt>
+ <dd>
+ You may select the <b>
+ <i>
+ File-&gt;Run</i>
+ </b> menu item on the menu bar to execute JavaScript scripts contained in files. This action will display a file-selection dialog box prompting you for the location of a script to execute. The loaded script will be run in a new thread and control will be given to the debugger on its first instruction.</dd>
+</dl>
+<h2 id="Controlling_Execution">Controlling Execution</h2>
+<p>The debugger provides the following facilities for you to control the execution of scripts you are debugging:</p>
+<dl>
+ <dt>
+ <a id="stepinto" name="stepinto">Step Into</a></dt>
+ <dd>
+ To single step entering any function calls, you may do any of the following:
+ <ul>
+ <li>Select the <b>
+ <i>
+ Debug-&gt;Step Into</i>
+ </b>menu item on the menu bar</li>
+ <li>Press the <b>
+ <i>
+ Step Into</i>
+ </b> button on the toolbar</li>
+ <li>Press the F11 key on the keyboard</li>
+ </ul>
+ <p>Execution will resume. If the current line in the script contains a function call control will return to the debugger upon entry into the function. Otherwise control will return to the debugger at the next line in the current function.</p>
+ </dd>
+ <dt>
+ <a id="stepover" name="stepover">Step Over</a></dt>
+ <dd>
+ To single step to the next line in the current function, you may do any of the following:
+ <ul>
+ <li>Select the <b>
+ <i>
+ Debug-&gt;Step Over</i>
+ </b> menu item on the menu bar</li>
+ <li>Press the <b>
+ <i>
+ Step Over</i>
+ </b> button on the toolbar</li>
+ <li>Press the F7 key on the keyboard</li>
+ </ul>
+ <p>Execution will resume but control will return to the debugger at the next line in the current function or top-level script.</p>
+ </dd>
+ <dt>
+ <a id="stepout" name="stepout">Step Out</a></dt>
+ <dd>
+ To continue execution until the current function returns you may do any of the following:
+ <ul>
+ <li>Select the <b>
+ <i>
+ Debug-&gt;Step Out</i>
+ </b> menu item on the menu bar</li>
+ <li>Press the <b>
+ <i>
+ Step Out</i>
+ </b> button on the toolbar</li>
+ <li>Press the F8 key on the keyboard</li>
+ </ul>
+ <p>Execution will resume until the current function returns or a breakpoint is hit.</p>
+ </dd>
+ <dt>
+ <a id="go" name="go">Go</a></dt>
+ <dd>
+ To resume execution of a script you may do any of the following:
+ <ul>
+ <li>Select the <b>
+ <i>
+ Debug-&gt;Go</i>
+ </b> menu item on the menu bar</li>
+ <li>Press the <b>
+ <i>
+ Go</i>
+ </b> button on the toolbar</li>
+ <li>Press the F5 key on the keyboard</li>
+ </ul>
+ <p>Execution will resume until a breakpoint is hit or the script completes.</p>
+ </dd>
+ <dt>
+ <a id="break" name="break">Break</a></dt>
+ <dd>
+ To stop all running scripts and give control to the debugger you may do any of the following:
+ <ul>
+ <li>Select the <b>
+ <i>
+ Debug-&gt;Break</i>
+ </b> menu item on the menu bar</li>
+ <li>Press the <b>
+ <i>
+ Break</i>
+ </b> button on the toolbar</li>
+ <li>Press the Pause/Break key on the keyboard</li>
+ </ul>
+ </dd>
+ <dt>
+ Break on Exceptions</dt>
+ <dd>
+ To give control to the debugger whenever a JavaScript is exception is thrown select the <b>
+ <i>
+ Debug-&gt;Break on Exceptions</i>
+ </b> checkbox from the menu bar. Whenever a JavaScript exception is thrown by a script a message dialog will be displayed and control will be given to the debugger at the location the exception is raised.</dd>
+ <dt>
+ Break on Function Enter</dt>
+ <dd>
+ Selecting <b>
+ <i>
+ Debug-&gt;Break on Function Enter</i>
+ </b> will give control to the debugger whenever the execution is entered into a function or script.</dd>
+ <dt>
+ Break on Function Exit</dt>
+ <dd>
+ Selecting <b>
+ <i>
+ Debug-&gt;Break on Function Return</i>
+ </b> will give control to the debugger whenever the execution is about to return from a function or script.</dd>
+ <dt>
+ Moving Up and Down the Stack</dt>
+ <dd>
+ The lower-left (dockable) pane in the debugger main window contains a combo-box labeled "Context:" which displays the current stack of the executing script. You may move up and down the stack by selecting an entry in the combo-box. When you select a stack frame the variables and watch windows are updated to reflect the names and values of the variables visible at that scope.</dd>
+ <dt>
+ <a id="setclearbkpts" name="setclearbkpts">Setting and Clearing Breakpoints</a></dt>
+ <dd>
+ The main desktop of the debugger contains file windows which display the contents of each script you are debugging. You may set a breakpoint in a script by doing one of the following:
+ <ul>
+ <li>Place the cursor on the line at which you want to set a breakpoint and right-click with the mouse. This action will display a pop-up menu. Select the <b>
+ <i>
+ Set Breakpoint</i>
+ </b> menu item.</li>
+ <li>Simply single-click on the line number of the line at which you want to set a breakpoint.</li>
+ </ul>
+ <p>If the selected line contains executable code a red dot will appear next to the line number and a breakpoint will be set at that location.</p>
+ <p>You may clear breakpoint in a script by doing one of the following:</p>
+ <ul>
+ <li>Place the cursor on the line at which you want to clear a breakpoint and right-click with the mouse. This action will display a pop-up menu. Select the <b>
+ <i>
+ Clear Breakpoint</i>
+ </b> menu item.</li>
+ <li>Simply single-click on the red dot or the line number of the line at which you want to clear a breakpoint.</li>
+ </ul>
+ <p>The red dot will disappear and the breakpoint at that location will be cleared.</p>
+ </dd>
+</dl>
+<h2 id="Viewing_Variables">Viewing Variables</h2>
+<p>The lower-left (dockable) pane in the debugger main window contains a tab-pane with two tabs, labeled "this" and "Locals". Each pane contains a tree-table which displays the properties of the current object and currently visible local variables, respectively.</p>
+<dl>
+ <dt>
+ <a id="this" name="this">This</a></dt>
+ <dd>
+ The properties of the current object are displayed in the <b>
+ <i>
+ this</i>
+ </b> table. If a property is itself a JavaScript object the property may be expanded to show its sub-properties. The <b>
+ <i>
+ this</i>
+ </b> table is updated each time control returns to the debugger or when you change the stack location in the <b>
+ <i>
+ Context:</i>
+ </b> window.</dd>
+ <dt>
+ <a id="locals" name="locals">Locals</a></dt>
+ <dd>
+ The local variables of the current function are displayed in the <b>
+ <i>
+ Locals</i>
+ </b> table. If a variable is itself a JavaScript object the variable may be expanded to show its sub-properties. The <b>
+ <i>
+ Locals</i>
+ </b> table is updated each time control returns to the debugger or when you change the stack location in the <b>
+ <i>
+ Context:</i>
+ </b> window</dd>
+ <dt>
+ Watch Window</dt>
+ <dd>
+ You may enter arbitrary JavaScript expressions in the <b>
+ <i>
+ Watch:</i>
+ </b> table located in the lower-right (dockable) pane in the debugger main window. The expressions you enter are re-evaluated in the current scope and their current values displayed each time control returns to the debugger or when you change the stack location in the <b>
+ <i>
+ Context:</i>
+ </b> window.</dd>
+ <dt>
+ Evaluation Window</dt>
+ <dd>
+ The <b>
+ <i>
+ Evaluate</i>
+ </b> pane located in the lower-right (dockable) pane in the debugger main window contains an editable command line where you may enter arbitrary JavaScript code. The code is evaluated in the context of the current stack frame. The window maintains a history of the commands you have entered. You may move backward or forward through the history by pressing the Up/Down arrow keys on the keyboard.</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/projects/rhino/documentation/index.html b/files/zh-cn/mozilla/projects/rhino/documentation/index.html
new file mode 100644
index 0000000000..74ae49d94e
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/rhino/documentation/index.html
@@ -0,0 +1,81 @@
+---
+title: Rhino 文档
+slug: Mozilla/Projects/Rhino/Documentation
+translation_of: Mozilla/Projects/Rhino/Documentation
+---
+<p>以下是面向 Rhino 脚本创作者和集成者的信息.</p>
+
+<h2 id="General" name="General">概述</h2>
+
+<dl>
+ <dt><a href="/zh-CN/docs/Rhino/Overview" title="Rhino_Overview">简介</a></dt>
+ <dd>Rhino 和 JavaScript 的简介.</dd>
+ <dt><a href="/zh-CN/docs/Rhino/License" title="Rhino_License">许可</a></dt>
+ <dd>Rhino 的许可信息.</dd>
+ <dt><a href="/zh-CN/docs/Rhino/Requirements_and_Limitations" title="Rhino_Requirements_and_Limitations">依赖和局限</a></dt>
+ <dd>运行 Rhino 所需要的要件; 以及 Rhino 不能做什么.</dd>
+ <dt><a href="/zh-CN/docs/Rhino/Downloads_archive" title="Rhino_downloads_archive">发布存档</a></dt>
+ <dd>Rhino 的历史版本以及发行说明.</dd>
+ <dt><a href="/zh-CN/docs/Rhino/Optimization" title="Rhino_Optimization">优化</a></dt>
+ <dd>优化级别的详细说明.</dd>
+ <dt><a href="/zh-CN/docs/Rhino/FAQ" title="Rhino_FAQ">FAQ</a></dt>
+ <dd>针对 Rhino 的 FAQ.</dd>
+ <dt><a href="/zh-CN/docs/Rhino/History">Rhino 的历史</a></dt>
+ <dd>关于这只野兽(Rhino)的历史.</dd>
+</dl>
+
+<h2 id="Writing_Scripts" name="Writing_Scripts">撰写脚本</h2>
+
+<dl>
+ <dt><a class="internal" href="/zh-CN/docs/Scripting_Java" title="Scripting Java">在 Java 中撰写脚本</a></dt>
+ <dd>使用 Rhino 编写 Java 类的方法.</dd>
+ <dt><a class="external" href="http://www.mozilla.org/rhino/scriptjava.html">在 Java 中撰写脚本</a></dt>
+ <dd>使用 Rhino 编写 Java 类的方法. (旧版).</dd>
+ <dt><a href="/en-US/docs/Rhino/Performance">性能</a></dt>
+ <dd>撰写更高效的 JavaScript 的窍门.</dd>
+</dl>
+
+<h2 id="JavaScript_Tools" name="JavaScript_Tools">JavaScript 工具</h2>
+
+<dl>
+ <dt><a href="/en-US/docs/Rhino/Shell" title="Rhino_Shell">Rhino Shell</a></dt>
+ <dd>交互式或批处理式执行脚本.</dd>
+ <dt><a href="/en-US/docs/Rhino/Debugger">JavaScript 调试器</a></dt>
+ <dd>调试执行于 Rhino 中的脚本.</dd>
+ <dt><a href="/en-US/docs/Rhino/JavaScript_Compiler" title="Rhino_JavaScript_Compiler">JavaScript 编译器</a></dt>
+ <dd>将脚本编译成类文件.</dd>
+ <dt><a href="/en-US/docs/Running_the_Rhino_tests" title="Running_the_Rhino_tests">运行Rhino测试</a></dt>
+ <dd>使用Rhino运行javascript单元测试.</dd>
+</dl>
+
+<h2 id="Embedding_Rhino" name="Embedding_Rhino">嵌入 Rhino</h2>
+
+<dl>
+ <dt><a href="/en-US/docs/Rhino/Embedding_tutorial">嵌入教程</a></dt>
+ <dd>一个介绍如何将Rhino嵌入到你的应用程序的简短教程.</dd>
+ <dt><a class="external" href="http://mozilla.github.io/rhino/javadoc/index.html">API Javadoc Reference</a> (无法访问?  <a href="http://www.jarvana.com/jarvana/view/org/mozilla/rhino/1.7R3/rhino-1.7R3-javadoc.jar!/index.html" title="http://www.jarvana.com/jarvana/view/org/mozilla/rhino/1.7R3/rhino-1.7R3-javadoc.jar!/index.html">Try this at Jarvana.</a>)</dt>
+ <dd>一个带有解释的Rhino编程api大纲(只有一些小提示).</dd>
+ <dt><a href="/en-US/docs/Rhino/Scopes_and_Contexts" title="https://developer.mozilla.org/editor/fckeditor/core/editor/en-US/docs/Rhino_documentation/Scopes_and_Contexts">Scopes and Contexts</a></dt>
+ <dd>描述如何在多线程环境中高效、灵活的使用scopes和contexts.</dd>
+ <dt><a href="/en-US/docs/Rhino/Serialization">序列化</a></dt>
+ <dd>如何在Rhino中序列化javascript对象和函数.</dd>
+ <dt><a href="/en-US/docs/Rhino/Runtime">运行时</a></dt>
+ <dd>一个对于javascrit运行时的简短介绍.</dd>
+ <dt><a href="/en-US/docs/Rhino/Footprint">Small Footprint</a></dt>
+ <dd>对于那些热衷于小面积脚本嵌入(small-footprint embeddings)的人的提示.</dd>
+ <dt><a href="/en-US/docs/Rhino/Examples">例子</a></dt>
+ <dd>一些展示如何控制javascript引擎以及创建javascript<span class="web-item">宿主对象的例子.</span></dd>
+ <dt><a href="/en-US/docs/Rhino/BSF">Using Rhino with Bean Scripting Framework (BSF)</a></dt>
+ <dd>如何在支持BSF(Bean 脚本框架)的app中通过Apache Jakarta project使用Rhino.</dd>
+</dl>
+
+<h2 id="External_references" name="External_references">外部链接</h2>
+
+<dl>
+ <dt><a class="external" href="http://www.ociweb.com/jnb/archive/jnbMar2001.html">在java中使用的脚本语言</a></dt>
+ <dd>一篇将Rhino和Jython进行对比的文章.</dd>
+</dl>
+
+<h2 id="Rhino_contributors" name="Rhino_contributors">Rhino 贡献者</h2>
+
+<p>有志于为 Rhino 贡献力量? 来看看 <a href="/en-US/docs/Rhino_Wish_List" title="Rhino_Wish_List">Rhino Wish List</a> 吧.</p>
diff --git a/files/zh-cn/mozilla/projects/rhino/download_rhino/index.html b/files/zh-cn/mozilla/projects/rhino/download_rhino/index.html
new file mode 100644
index 0000000000..54bf9966b8
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/rhino/download_rhino/index.html
@@ -0,0 +1,106 @@
+---
+title: 下载 Rhino
+slug: Mozilla/Projects/Rhino/Download_Rhino
+translation_of: Mozilla/Projects/Rhino/Download_Rhino
+---
+<p>Rhino 同时提供源代码和已编译形式的下载.</p>
+
+<h2 id="字节码文件">字节码文件</h2>
+
+<p>Rhino 1.7R5 是最新的稳定发行版.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">发行版本</th>
+ <th scope="col">发行时间</th>
+ <th scope="col">变更日志</th>
+ <th scope="col">下载链接</th>
+ </tr>
+ <tr>
+ <td>Rhino 1.7R4</td>
+ <td>2012-06-18</td>
+ <td><a href="/En/New_in_Rhino_1.7R4" title="En/New_in_Rhino_1.7R4">New in Rhino 1.7R4</a></td>
+ <td><a class="link-https" href="https://github.com/downloads/mozilla/rhino/rhino1_7R4.zip" title="https://github.com/downloads/mozilla/rhino/rhino1_7R4.zip">rhino1_7R4.zip</a></td>
+ </tr>
+ <tr>
+ <td>Rhino 1.7R5</td>
+ <td>2015-01-29</td>
+ <td><a href="https://github.com/mozilla/rhino/releases/tag/Rhino1_7R5_RELEASE">变更日志</a></td>
+ <td><a href="https://github.com/mozilla/rhino/releases/download/Rhino1_7R5_RELEASE/rhino1_7R5.zip">rhino1_7R5.zip</a></td>
+ </tr>
+ <tr>
+ <td>Rhino 1.7.6</td>
+ <td>2015-04-15</td>
+ <td><a href="https://github.com/mozilla/rhino/releases/tag/Rhino1_7_6_RELEASE">变更日志</a></td>
+ <td><a href="https://github.com/mozilla/rhino/releases/download/Rhino1_7_6_RELEASE/rhino1.7.6.zip">rhino1.7.6.zip</a></td>
+ </tr>
+ <tr>
+ <td>Rhino 1.7.7</td>
+ <td>2015-06-17</td>
+ <td><a href="https://github.com/mozilla/rhino/releases/tag/Rhino1_7_7_RELEASE">变更日志</a></td>
+ <td><a href="https://github.com/mozilla/rhino/releases/download/Rhino1_7_7_RELEASE/rhino1.7.7.zip">rhino1.7.7.zip</a></td>
+ </tr>
+ <tr>
+ <td>Rhino 1.7.7.1</td>
+ <td>2016-02-01</td>
+ <td><a href="https://github.com/mozilla/rhino/releases/tag/Rhino1_7_7_1_RELEASE">变更日志</a></td>
+ <td><a href="https://github.com/mozilla/rhino/releases/download/Rhino1_7_7_1_RELEASE/rhino-1.7.7.1.zip">rhino1.7.7.1.zip </a></td>
+ </tr>
+ <tr>
+ <td>Rhino 1.7.7.2</td>
+ <td>2017-08-24</td>
+ <td><a href="https://github.com/mozilla/rhino/releases/tag/Rhino1_7_7_2_Release">变更日志</a></td>
+ <td><a href="https://github.com/mozilla/rhino/releases/download/Rhino1_7_7_2_Release/rhino-1.7.7.2.zip">rhino1.7.7.2.zip </a></td>
+ </tr>
+ <tr>
+ <td>Rhino 1.7.8</td>
+ <td>2018-01-22</td>
+ <td><a href="https://github.com/mozilla/rhino/releases/tag/Rhino1_7_8_Release">变更日志</a></td>
+ <td><a href="https://github.com/mozilla/rhino/releases/download/Rhino1_7_8_Release/rhino-1.7.8.zip">rhino1.7.8.zip</a></td>
+ </tr>
+ <tr>
+ <td>Rhino 1.7.9</td>
+ <td>2018-03-15</td>
+ <td><a href="https://github.com/mozilla/rhino/releases/tag/Rhino1_7_9_Release">变更日志</a></td>
+ <td><a href="https://github.com/mozilla/rhino/releases/download/Rhino1_7_9_Release/rhino-1.7.9.zip">rhino1.7.9.zip</a></td>
+ </tr>
+ <tr>
+ <td>Rhino 1.7.10</td>
+ <td>2018-04-09</td>
+ <td><a href="https://github.com/mozilla/rhino/releases/tag/Rhino1_7_10_Release">变更日志</a></td>
+ <td><a href="https://github.com/mozilla/rhino/releases/download/Rhino1_7_10_Release/rhino-1.7.10.zip">rhino1.7.10.zip</a></td>
+ </tr>
+ <tr>
+ <td>Rhino 1.7.11</td>
+ <td>2019-05-30</td>
+ <td><a href="https://github.com/mozilla/rhino/releases/tag/Rhino1_7_11_Release">变更日志</a></td>
+ <td><a href="https://github.com/mozilla/rhino/releases/download/Rhino1_7_11_Release/rhino-1.7.11.zip">rhino1.7.11.zip</a></td>
+ </tr>
+ <tr>
+ <td>Rhino 1.7.12</td>
+ <td>2020-01-13</td>
+ <td><a href="https://github.com/mozilla/rhino/releases/tag/Rhino1_7_12_Release">变更日志</a></td>
+ <td><a href="https://github.com/mozilla/rhino/releases/download/Rhino1_7_12_Release/rhino-1.7.12.zip">rhino1.7.12.zip</a></td>
+ </tr>
+ </tbody>
+</table>
+
+<p>下载较旧版本的Rhino,可以参考 <a class="external" href="http://developer.mozilla.org/zh-cn/docs/Rhino_downloads_archive">Rhino 下载存档.</a></p>
+
+<h2 id="许可">许可</h2>
+
+<p>Rhino 是开源的, 从 1.7R4 开始以 MPL 2.0 许可.</p>
+
+<p>在此之前的版本遵循 <a class="external" href="http://www.mozilla.org/MPL/">MPL</a> 1.1/GPL 2.0 许可.</p>
+
+<p>参考更详细的 <a href="/zh-cn/Rhino/License" title="en/Rhino license">Rhino 许可证</a> 信息.</p>
+
+<h2 id="源代码">源代码</h2>
+
+<p>除了从上面zip文件获取源外,Rhino 的源代码可以在GitHub上的<a href="https://github.com/mozilla/rhino">https://github.com/mozilla/rhino</a>找到。 要获取源,使用命令</p>
+
+<pre class="brush: bash">$ git clone https://github.com/mozilla/rhino.git
+</pre>
+
+<p>Rhino 使用 <a class="ex-ref external" href="http://ant.apache.org/">Ant</a> 作为它的构建系统.。在Rhino分配的顶级目录运行 <code>ant</code> 命令将打印打印可构建目标的清单。</p>
diff --git a/files/zh-cn/mozilla/projects/rhino/embedding_tutorial/index.html b/files/zh-cn/mozilla/projects/rhino/embedding_tutorial/index.html
new file mode 100644
index 0000000000..b7cf0168f5
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/rhino/embedding_tutorial/index.html
@@ -0,0 +1,221 @@
+---
+title: 'Tutorial: Embedding Rhino'
+slug: Mozilla/Projects/Rhino/Embedding_tutorial
+translation_of: Mozilla/Projects/Rhino/Embedding_tutorial
+---
+<p>Embedding Rhino can be done simply with good results. With more effort on the part of the embedder, the objects exposed to scripts can be customized further.</p>
+<p>This tutorial leads you through the steps from a simple embedding to more customized, complex embeddings. Fully compilable examples are provided along the way.</p>
+<p>The examples live in the <code>rhino/examples</code> directory in the distribution and in <code>mozilla/js/rhino/examples</code> in cvs. This document will link to them using <a href="http://lxr.mozilla.org/">lxr</a>.</p>
+<p>In this document, JavaScript code will be in <span class="java_js_code">green</span>, Java code will be in <span class="java_js_code">green,</span> and shell logs will be in <span class="shell_logs_code">purple</span>.</p>
+<h2 id="In_this_document">In this document:</h2>
+<ul class="toc">
+ <li><a href="#runScript">RunScript: A simple embedding</a>
+ <ul>
+ <li><a href="#enteringContext">Entering a Context</a></li>
+ <li><a href="#initializing">Initializing standard objects</a></li>
+ <li><a href="#collecting">Collecting the arguments</a></li>
+ <li><a href="#evaluating">Evaluating a script</a></li>
+ <li><a href="#print">Printing the result</a></li>
+ <li><a href="#exit">Exiting the Context</a></li>
+ </ul>
+ </li>
+ <li><a href="#expose">Expose Java APIs</a>
+ <ul>
+ <li><a href="#useJava">Using Java APIs</a></li>
+ <li><a href="#implementingInterfaces">Implementing interfaces</a></li>
+ <li><a href="#addJava">Adding Java objects</a></li>
+ </ul>
+ </li>
+ <li><a href="#usingJSObjs">Using JavaScript objects from Java</a>
+ <ul>
+ <li><a href="#usingJSvars">Using JavaScript variables</a></li>
+ <li><a href="#callingJSfuns">Calling JavaScript functions</a></li>
+ </ul>
+ </li>
+ <li><a href="#javaScriptHostObjects">JavaScript host objects</a>
+ <ul>
+ <li><a href="#definingHostObjects">Defining Host Objects</a></li>
+ <li><a href="#counter">Counter example</a>
+ <ul>
+ <li><a href="#counterCtors">Counter's constructors</a></li>
+ <li><a href="#classname">Class name</a></li>
+ <li><a href="#dynamic">Dynamic properties</a></li>
+ <li><a href="#definingMethods">Defining JavaScript "methods"</a></li>
+ <li><a href="#addingCounter">Adding Counter to RunScript</a></li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+</ul>
+<h2 id="RunScript_A_simple_embedding"><a id="runScript" name="runScript">RunScript: A simple embedding</a></h2>
+<p>About the simplest embedding of Rhino possible is the <a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/RunScript.java">RunScript example</a>. All it does it read a script from the command line, execute it, and print a result.</p>
+<p>Here's an example use of RunScript from a shell command line:</p>
+<pre class="code shell_logs_code">$ java RunScript "Math.cos(Math.PI)"
+-1
+$ java RunScript "function f(x){return x+1} f(7)"
+8
+</pre>
+<p>Note that you'll have to have both the Rhino classes and the RunScript example class file in the classpath. Let's step through the body of <code>main</code> one line at time.</p>
+<h3 id="Entering_a_Context"><a id="enteringContext" name="enteringContext">Entering a Context</a></h3>
+<p>The code</p>
+<pre class="code java_js_code">Context cx = Context.enter();
+</pre>
+<p>Creates and enters a <code>Context</code>. A <code>Context</code> stores information about the execution environment of a script.</p>
+<h3 id="Initializing_standard_objects"><a name="initializing">Initializing standard objects</a></h3>
+<p>The code</p>
+<pre class="code java_js_code">Scriptable scope = cx.initStandardObjects();
+</pre>
+<p>Initializes the standard objects (<code>Object</code>, <code>Function</code>, etc.) This must be done before scripts can be executed. The <var>null</var> parameter tells <code>initStandardObjects</code> to create and return a scope object that we use in later calls.</p>
+<h3 id="Collecting_the_arguments"><a id="collecting" name="collecting">Collecting the arguments</a></h3>
+<p>This code is standard Java and not specific to Rhino. It just collects all the arguments and concatenates them together.</p>
+<pre class="code java_js_code">String s = "";
+for (int i=0; i &lt; args.length; i++) {
+ s += args[i];
+}
+</pre>
+<h3 id="Evaluating_a_script"><a id="evaluating" name="evaluating">Evaluating a script</a></h3>
+<p>The code</p>
+<pre class="code java_js_code">Object result = cx.evaluateString(scope, s, "&lt;cmd&gt;", 1, null);
+</pre>
+<p>uses the Context <code>cx</code> to evaluate a string. Evaluation of the script looks up variables in <var>scope</var>, and errors will be reported with the filename <code>&lt;cmd&gt;</code> and line number 1.</p>
+<h3 id="Printing_the_result"><a id="print" name="print">Printing the result</a></h3>
+<p>The code</p>
+<pre class="code java_js_code">System.out.println(cx.toString(result));
+</pre>
+<p>prints the result of evaluating the script (contained in the variable <var>result</var>). <var>result</var> could be a string, JavaScript object, or other values. The <code>toString</code> method converts any JavaScript value to a string.</p>
+<h3 id="Exiting_the_Context"><a id="exit" name="exit">Exiting the Context</a></h3>
+<p>The code</p>
+<pre class="code java_js_code">} finally {
+ Context.exit();
+}
+</pre>
+<p>exits the Context. This removes the association between the Context and the current thread and is an essential cleanup action. There should be a call to <code>exit</code> for every call to <code>enter</code>. To make sure that it is called even if an exception is thrown, it is put into the finally block corresponding to the try block starting after <code>Context.enter()</code>.</p>
+<h2 id="Expose_Java_APIs"><a id="expose" name="expose">Expose Java APIs</a></h2>
+<h3 id="Using_Java_APIs"><a id="useJava" name="useJava">Using Java APIs</a></h3>
+<p>No additional code in the embedding needed! The JavaScript feature called
+ <i>
+ LiveConnect</i>
+ allows JavaScript programs to interact with Java objects:</p>
+<pre class="code shell_logs_code">$ java RunScript "java.lang.System.out.println(3)"
+3.0
+undefined
+</pre>
+<h3 id="Implementing_interfaces"><a id="implementingInterfaces" name="implementingInterfaces">Implementing interfaces</a></h3>
+<p>Using Rhino, JavaScript objects can implement arbitrary Java interfaces. There's no Java code to write -- it's part of Rhino's LiveConnect implementation. For example, we can see how to implement java.lang.Runnable in a Rhino shell session:</p>
+<pre class="code shell_logs_code">js&gt; obj = { run: function() { print("hi"); } }
+[object Object]
+js&gt; obj.run()
+hi
+js&gt; r = new java.lang.Runnable(obj);
+[object Object]
+js&gt; t = new java.lang.Thread(r)
+Thread[Thread-0,5,main]
+js&gt; t.start()
+hi
+</pre>
+<h3 id="Adding_Java_objects"><a id="addJava" name="addJava">Adding Java objects</a></h3>
+<p>The next example is <a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/RunScript2.java">RunScript2</a>. This is the same as RunScript, but with the addition of two extra lines of code:</p>
+<pre class="code java_js_code">Object wrappedOut = Context.javaToJS(System.out, scope);
+ScriptableObject.putProperty(scope, "out", wrappedOut);
+</pre>
+<p>These lines add a global variable <code>out</code> that is a JavaScript reflection of the <code>System.out</code> variable:</p>
+<pre class="code shell_logs_code">$ java RunScript2 "out.println(42)"
+42.0
+undefined
+</pre>
+<h2 id="Using_JavaScript_objects_from_Java"><a id="usingJSObjs" name="usingJSObjs">Using JavaScript objects from Java</a></h2>
+<p>After evaluating a script it's possible to query the scope for variables and functions, extracting values and calling JavaScript functions. This is illustrated in the <a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/RunScript3.java">RunScript3</a> example. This example adds the ability to print the value of variable <var>x</var> and the result of calling function <code>f</code>. Both <var>x</var> and <var>f</var> are expected to be defined by the evaluated script. For example,</p>
+<pre class="code shell_logs_code">$ java RunScript3 "x = 7"
+x = 7
+f is undefined or not a function.
+$ java RunScript3 "function f(a) { return a; }"
+x is not defined.
+f("my args") = my arg
+</pre>
+<h3 id="Using_JavaScript_variables"><a id="usingJSvars" name="usingJSvars">Using JavaScript variables</a></h3>
+<p>To print out the value of <var>x</var>, we add the following code:</p>
+<pre class="code java_js_code">Object x = scope.get("x", scope);
+if (x == Scriptable.NOT_FOUND) {
+ System.out.println("x is not defined.");
+} else {
+ System.out.println("x = " + Context.toString(x));
+}
+</pre>
+<h3 id="Calling_JavaScript_functions"><a id="callingJSfuns" name="callingJSfuns">Calling JavaScript functions</a></h3>
+<p>To get the function <var>f</var>, call it, and print the result, we add this code:</p>
+<pre class="code java_js_code">Object fObj = scope.get("f", scope);
+if (!(fObj instanceof Function)) {
+ System.out.println("f is undefined or not a function.");
+} else {
+ Object functionArgs[] = { "my arg" };
+ Function f = (Function)fObj;
+ Object result = f.call(cx, scope, scope, functionArgs);
+ String report = "f('my args') = " + Context.toString(result);
+ System.out.println(report);
+}
+</pre>
+<h2 id="JavaScript_host_objects"><a id="javaScriptHostObjects" name="javaScriptHostObjects">JavaScript host objects</a></h2>
+<h3 id="Defining_Host_Objects"><a id="definingHostObjects" name="definingHostObjects">Defining Host Objects</a></h3>
+<p>Custom host objects can implement special JavaScript features like dynamic properties.</p>
+<h3 id="Counter_example"><a id="counter" name="counter">Counter example</a></h3>
+<p>The <a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/Counter.java">Counter example</a> is a simple host object. We'll go through it method by method below.</p>
+<p>It's easy to try out new host object classes in the shell using its built-in <code>defineClass</code> function. We'll see how to add it to RunScript later. (Note that because the <code>java -jar</code> option preempts the rest of the classpath, we can't use that and access the <code>Counter</code> class.)</p>
+<pre class="code shell_logs_code">$ java -cp "js.jar;examples" org.mozilla.javascript.tools.shell.Main
+js&gt; defineClass("Counter")
+js&gt; c = new Counter(7)
+[object Counter]
+js&gt; c.count
+7
+js&gt; c.count
+8
+js&gt; c.count
+9
+js&gt; c.resetCount()
+js&gt; c.count
+0
+</pre>
+<h3 id="Counter's_constructors"><a id="counterCtors" name="counterCtors">Counter's constructors</a></h3>
+<p>The zero-argument constructor is used by Rhino runtime to create instances. For the counter example, no initialization work is needed, so the implementation is empty.</p>
+<pre class="code java_js_code">public Counter () { }
+</pre>
+<p>The method <code>jsConstructor</code> defines the JavaScript constructor that was called with the expression <code>new Counter(7)</code> in the JavaScript code above.</p>
+<pre class="code java_js_code">public void jsConstructor(int a) { count
+= a; }
+</pre>
+<h3 id="Class_name"><a id="classname" name="classname">Class name</a></h3>
+<p>The class name is defined by the <code>getClassName</code> method. This is used to determine the name of the constructor.</p>
+<pre class="code java_js_code">public String getClassName() { return "Counter";
+}
+</pre>
+<h3 id="Dynamic_properties"><a id="dynamic" name="dynamic">Dynamic properties</a></h3>
+<p>Dynamic properties are defined by methods beginning with <code>jsGet_</code> or <code>jsSet_</code>. The method <code>jsGet_count</code> defines the
+ <i>
+ count</i>
+ property.</p>
+<pre class="code java_js_code">public int jsGet_count() { return count++;
+}
+</pre>
+<p>The expression <code>c.count</code> in the JavaScript code above results in a call to this method.</p>
+<h3 id="Defining_JavaScript_methods"><a id="definingMethods" name="definingMethods">Defining JavaScript "methods"</a></h3>
+<p>Methods can be defined using the <code>jsFunction_ prefix</code>. Here we define <code>resetCount</code> for JavaScript.</p>
+<pre class="code java_js_code">public void jsFunction_resetCount() { count
+= 0; }
+</pre>
+<p>The call <code>c.resetCount()</code> above calls this method.</p>
+<h3 id="Adding_Counter_to_RunScript"><a id="addingCounter" name="addingCounter">Adding Counter to RunScript</a></h3>
+<p>Now take a look at the <a href="http://lxr.mozilla.org/mozilla/source/js/rhino/examples/RunScript4.java">RunScript4 example</a>. It's the same as RunScript except for two additions. The method <code>ScriptableObject.defineClass</code> uses a Java class to define the Counter "class" in the top-level scope:</p>
+<pre class="code java_js_code">ScriptableObject.defineClass(scope, Counter.class);
+</pre>
+<p>Now we can reference the <code>Counter</code> object from our script:</p>
+<pre class="code shell_logs_code">$ java RunScript4 "c = new Counter(3); c.count;
+c.count;"
+</pre>
+<p>It also creates a new instance of the <code>Counter</code> object from within our Java code, constructing it with the value 7, and assigning it to the top-level variable <code>myCounter</code>:</p>
+<pre class="code java_js_code">Object[] arg = { new Integer(7) };
+Scriptable myCounter = cx.newObject(scope, "Counter", arg);
+scope.put("myCounter", scope, myCounter);
+</pre>
+<p>Now we can reference the <code>myCounter</code> object from our script:</p>
+<pre class="code shell_logs_code">$ java RunScript3 'RunScript4 'myCounter.count; myCounter.count'
+8
+</pre>
diff --git a/files/zh-cn/mozilla/projects/rhino/examples/index.html b/files/zh-cn/mozilla/projects/rhino/examples/index.html
new file mode 100644
index 0000000000..087697b94a
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/rhino/examples/index.html
@@ -0,0 +1,35 @@
+---
+title: Rhino Examples
+slug: Mozilla/Projects/Rhino/Examples
+translation_of: Mozilla/Projects/Rhino/Examples
+---
+<div>
+  </div>
+<p></p>
+<p>Examples have been provided that show how to control the JavaScript engine and how  to implement scriptable host objects. All the examples are in the git tree at <code><a href="https://github.com/mozilla/rhino/tree/master/examples/">mozilla/js/rhino/examples</a></code>.</p>
+<h2 id="Sample_Scripts"><a id="sample" name="sample">Sample Scripts</a></h2>
+<p>The <code><a href="https://github.com/mozilla/rhino/tree/master/examples/unique.js">unique.js</a></code> script allows printing unique lines from a file.</p>
+<p>The <code><a href="https://github.com/mozilla/rhino/tree/master/examples/liveConnect.js">liveConnect.js</a></code> script shows a sample usage of LiveConnect (Java-to-JavaScript connectivity).</p>
+<p>The <code><a href="https://github.com/mozilla/rhino/tree/master/examples/jsdoc.js">jsdoc.js</a></code> script is a JavaScript analog to Java's <code>javadoc</code>. It makes heavy use of regular expressions.</p>
+<p>The <code><a href="https://github.com/mozilla/rhino/tree/master/examples/checkParam.js">checkParam.js</a></code> script is a useful tool to check that <code>@param</code> tags in Java documentation comments match the parameters in the corresponding Java method.</p>
+<p>The <code><a href="https://github.com/mozilla/rhino/tree/master/examples/enum.js">enum.js</a></code> script is a good example of using a JavaAdapter to implement a Java interface using a JavaScript object.</p>
+<p>The <a href="https://github.com/mozilla/rhino/tree/master/examples/NervousText.js">NervousText.js</a> script is a JavaScript implementation of the famous NervousText applet using JavaScript compiled to Java classes using <a href="jsc.html">jsc</a>. It can be run in the HTML page <a href="https://github.com/mozilla/rhino/tree/master/examples/NervousText.html">NervousText.html</a>.</p>
+<h2 id="Controlling_the_JavaScript_Engine"><a id="controlling" name="controlling">Controlling the JavaScript Engine</a></h2>
+<h4 id="The_RunScript_class">The RunScript class</h4>
+<p><code><a href="https://github.com/mozilla/rhino/tree/master/examples/RunScript.java">RunScript.java</a></code> is a simple program that executes a script from the command line.</p>
+<h4 id="The_Control_class">The Control class</h4>
+<p><code><a href="https://github.com/mozilla/rhino/tree/master/examples/Control.java">Control.java</a></code> is a program that executes a simple script and then manipulates the result.</p>
+<h4 id="JavaScript_Shell">JavaScript Shell</h4>
+<p><code><a href="https://github.com/mozilla/rhino/tree/master/examples/Shell.java">Shell.java</a></code> is a program that executes JavaScript programs; it is a simplified version of the shell in the <code>tools</code> package. The programs may be specified as files on the command line or by typing interactively while the shell is running.</p>
+<h4 id="PrimitiveWrapFactory">PrimitiveWrapFactory</h4>
+<p><a href="https://github.com/mozilla/rhino/tree/master/examples/PrimitiveWrapFactory.java">PrimitiveWrapFactory.java</a> is an example of a WrapFactory that can be used to control the wrapping behavior of the Rhino engine on calls to Java methods.</p>
+<h4 id="Multithreaded_Script_Execution">Multithreaded Script Execution</h4>
+<p><code><a href="https://github.com/mozilla/rhino/tree/master/examples/DynamicScopes.java">DynamicScopes.java</a></code> is a program that creates a single global scope object and then shares it across multiple threads. Sharing the global scope allows both information to be shared across threads, and amortizes the cost of Context.initStandardObjects by only performing that expensive operation once.</p>
+<h2 id="Implementing_Host_Objects">Implementing Host Objects</h2>
+<p>First check out the <a href="/en/docs/Rhino/Embedding_tutorial">tutorial</a> if you haven't already.</p>
+<h4 id="The_Foo_class_-_Extending_ScriptableObject">The Foo class - Extending ScriptableObject</h4>
+<p><code><a href="https://github.com/mozilla/rhino/tree/master/examples/Foo.java">Foo.java</a></code> is a simple JavaScript host object that includes a property with an associated action and a variable argument method.</p>
+<h4 id="The_Matrix_class_-_Implementing_Scriptable">The Matrix class - Implementing Scriptable</h4>
+<p><code><a href="https://github.com/mozilla/rhino/tree/master/examples/Matrix.java">Matrix.java</a></code> provides a simple multidimensional array by implementing the Scriptable interface.</p>
+<h4 id="The_File_class_-_An_advanced_example">The File class - An advanced example</h4>
+<p><code><a href="https://github.com/mozilla/rhino/tree/master/examples/File.java">File.java</a></code> extends ScriptableObject to provide a means of reading and writing files from JavaScript. A more involved example of host object definition.</p>
diff --git a/files/zh-cn/mozilla/projects/rhino/index.html b/files/zh-cn/mozilla/projects/rhino/index.html
new file mode 100644
index 0000000000..86818aa172
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/rhino/index.html
@@ -0,0 +1,22 @@
+---
+title: Rhino
+slug: Mozilla/Projects/Rhino
+translation_of: Mozilla/Projects/Rhino
+---
+<p><img alt="Image:rhino.jpg" class="internal" src="/@api/deki/files/832/=Rhino.jpg"></p>
+
+<p><strong>Rhino </strong>是一个完全使用Java语言编写的开源<a href="/zh-CN/docs/Web/JavaScript">JavaScript</a>实现。Rhino通常用于在Java程序中,为最终用户提供脚本化能力。它被作为J2SE 6上的默认Java脚本化引擎。</p>
+
+<h4 id="Rhino_downloads" name="Rhino_downloads">Rhino 下载</h4>
+
+<p>如何 <a class="internal" href="/zh-cn/Rhino/Download_Rhino" title="zh-cn/Rhino/Download Rhino">获取源码和二进制文件</a><a id="fck_paste_padding"></a><a id="fck_paste_padding"></a>. </p>
+
+<h4 id="Rhino_documentation" name="Rhino_documentation">Rhino 文档</h4>
+
+<p>为脚本编写者和嵌入者提供的 <a href="/zh-CN/docs/Mozilla/Projects/Rhino/Documentation">一些Rhino信息</a>.</p>
+
+<h4 id="Rhino_help" name="Rhino_help">Rhino 帮助</h4>
+
+<p>如果你被卡住了,可以参考 <a href="/zh-CN/docs/Mozilla/Projects/Rhino/Community">这里的一些资源</a>.</p>
+
+<p>{{ languages( { "zh-cn": "zh-cn/Rhino" } ) }}</p>
diff --git a/files/zh-cn/mozilla/projects/rhino/license/index.html b/files/zh-cn/mozilla/projects/rhino/license/index.html
new file mode 100644
index 0000000000..035688ed65
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/rhino/license/index.html
@@ -0,0 +1,47 @@
+---
+title: Rhino license
+slug: Mozilla/Projects/Rhino/License
+translation_of: Mozilla/Projects/Rhino/License
+---
+<p>Rhino is available under open source licenses.</p>
+
+<h2 id="MPL.2FGPL_License" name="MPL.2FGPL_License">MPL/GPL License</h2>
+
+<p>The majority of the source code for Rhino is available under a <a class="external" href="http://www.mozilla.org/MPL/">MPL 1.1/GPL 2.0</a> license.</p>
+
+<h2 id="License_for_portions_of_the_Rhino_debugger" name="License_for_portions_of_the_Rhino_debugger">License for portions of the Rhino debugger</h2>
+
+<p>Additionally, some files (currently the contents of toolsrc/org/mozilla/javascript/tools/debugger/treetable/) are available under the following license:</p>
+
+<pre> * Copyright 1997, 1998 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Sun Microsystems nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+
+<hr>
+<p><a href="/User:Norrisboyd" title="User:Norrisboyd">Norrisboyd</a> 06:16, 14 April 2008 (PDT)</p>
diff --git a/files/zh-cn/mozilla/projects/rhino/overview/index.html b/files/zh-cn/mozilla/projects/rhino/overview/index.html
new file mode 100644
index 0000000000..ba6a9aaa18
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/rhino/overview/index.html
@@ -0,0 +1,78 @@
+---
+title: Rhino overview
+slug: Mozilla/Projects/Rhino/Overview
+translation_of: Mozilla/Projects/Rhino/Overview
+---
+<h3 id="Introduction" name="Introduction">简介</h3>
+
+<p>大多数用过 <a href="/en/JavaScript" title="en/JavaScript">JavaScript</a> 的人都是将js脚本放入<a href="/en/HTML" title="en/HTML">HTML</a>页面中使用。然而, Rhino 仅仅是对javascript核心部分的实现,并没有包含操作HTML的对象或方法。</p>
+
+<p>Rhino 包括</p>
+
+<ul>
+ <li> <a href="/en/New_in_JavaScript_1.7" title="en/New_in_JavaScript_1.7">JavaScript 1.7</a>的全部特性</li>
+ <li>可以用脚本方式调用Java</li>
+ <li>用一个<a href="/en/Rhino/Shell" title="en/Rhino/Shell">JavaScript Shell</a>来执行JavaScript脚本</li>
+ <li>用一个<a href="/en/Rhino/JavaScript_Compiler" title="en/Rhino/JavaScript_Compiler">JavaScript编译器</a> 来将JavaScript脚本文件转换成Java类文件</li>
+ <li>用一个<a class="external" href="http://www.mozilla.org/rhino/debugger.html">JavaScript调试器</a> 来调试Rhino执行的脚本</li>
+</ul>
+
+<h3 id="Language" name="Language">语言</h3>
+
+<p>JavaScript 的标准是 <a class="external" href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">Standard ECMA-262 ECMAScript: A general purpose, cross-platform programming language</a>. Rhino 1.3 及以上版本遵照上述标准的第3版。</p>
+
+<p>Rhino 1.6 及以上版本实现了 <a class="external" href="http://www.ecma-international.org/publications/standards/Ecma-357.htm">ECMA-357 ECMAScript for XML (E4X)</a> 标准. 查看详细的规格说明可以获得更多的信息,查看 <a class="external" href="http://www.mozilla.org/rhino/rhino16R1.html#E4X">Rhino version 1.6R1 release notes</a> 可以看到Rhino对标准实现的具体情况。</p>
+
+<p>此外,Rhino实现了JavaAdapters,这样我们可以用一个JavaScript对象来实现任何java的接口或者继承任何java的类。查看下载文件中example文件夹中的<code class="filename">enum.js获取更多的信息。</code>.</p>
+
+<p>有很多JavaScript的书和教程。 我们推荐<a class="external" href="http://www.oreilly.com/catalog/jscript5/">JavaScript: The Definitive Guide</a> 这本书,里面有一章是说Rhino的。</p>
+
+<h3 id="Deprecated_Language_Features" name="Deprecated_Language_Features">废弃的语言特性</h3>
+
+<p>很多在JavaScript 1.2中定义的特性已经被废弃了. 这些特性允许“计算反射”:可以决定和影响它被评价方法等方面的能力。 这些特性没有被广泛使用,他们对阻碍和防止优化的行为强加了重要的约束。 这些被废弃的特性是 <code>__proto__</code> 和 <code>__parent__</code> 属性, 还有构造函数 <code>With</code>,、<code>Closure<font face="Open Sans, sans-serif"><span style="line-height: 21px;">和</span></font></code><code>Call。</code>在JavaScript 1.4中使用这些特性会产生错误。在其他的版本中使用这些特性,会产生警告。</p>
+
+<h3 id="Internationalization" name="Internationalization">国际化</h3>
+
+<p>The messages reported by the JavaScript engine are by default retrieved from the property file <code class="filename">org/mozilla/javascript/resources/Messages.properties</code>. If other properties files with extensions corresponding to the current locale exist, they will be used instead.</p>
+
+<h3 id="JavaScript_Language_Versions" name="JavaScript_Language_Versions">JavaScript语言版本</h3>
+
+<p>JavaScript引擎的很多行为与语言的版本有关。在浏览器调用中,JavaScript版本的选择是通过script标签中的LANGUAGE属性定义的,比如"JavaScript1.2"。</p>
+
+<p>1.3 和更高版本是ECMA一致的。</p>
+
+<h4 id="Operators_.3D.3D_and_.21.3D" name="Operators_.3D.3D_and_.21.3D">操作符 <code>==</code>  和 <code>!=</code></h4>
+
+<p>1.2版本用 <code>==</code> 和 <code>!=</code> 来处理绝对相等的问题。 在1.3或更高的版本里, <code>==</code> 和 <code>!=</code> 和ECMA中所描述的一样。 操作符 <code>===</code> and <code>!==</code> 在所有版本中都表示绝对相等。</p>
+
+<h4 id="ToBoolean" name="ToBoolean">布尔转换</h4>
+
+<p><code>1.3之前的所有版本Boolean(new Boolean(false))</code> 值为<code>false</code> 。在1.3及1.3之后,它的值为<font face="Courier New, Andale Mono, monospace"><span style="line-height: normal;">true。</span></font></p>
+
+<h4 id="Array.prototype.toString_and_Object.prototype.toString" name="Array.prototype.toString_and_Object.prototype.toString"><code>Array.prototype.toString 和 Object.prototype.toString</code></h4>
+
+<p>1.2版本只是返回数组或对象的文字符号 (比如<code>"{{ mediawiki.external(1,2,3) }}"</code> or <code>"{a:1, b:2}"</code> )。 在1.3或更高版本中这些函数与ECMA标准一致。</p>
+
+<h4 id="Array_constructor" name="Array_constructor"><code>Array</code> 构造函数</h4>
+
+<p><code>只有在1.2版本中,Array(<var>i</var>)</code> 用一个参数i构造一个只有一个元素且元素的值为i的数组。 在其他版本中,使用和ECMA一致的标准 (一个没有元素的数组被构造,长度为i)。</p>
+
+<h4 id="String.prototype.substring" name="String.prototype.substring"><code>String.prototype.substring</code></h4>
+
+<p>只有在1.2版本中, 如果第一个参数小于第二个参数,两个参数不会互换。其他的版本都符合ECMA标准。</p>
+
+<h4 id="String.prototype.split" name="String.prototype.split"><code>String.prototype.split</code></h4>
+
+<p>只有对1.2版本,split按照Perl4的特例当用一个单独的空格字符作参数时, (跳过最先的空白,用空白分割). 其他的版本完全按照ECMA的标准分割。</p>
+
+<h3 id="Security" name="Security">安全</h3>
+
+<p>Rhino的安全特性提供了找到代码片段的来源的功能 (还有任何会轮流产生的代码片段)。这些特性考虑到了传统的基于URL的安全策略(在网景领航员中的JavaScript)的实现。执行信任的JavaScript代码时可以不考虑安全性特征。</p>
+
+<p>运行不被信任的JavaScript代码时,需要做两件事来保证安全性。第一,每一个被创建的Context必须被提供一个实现SecuritySupport接口的实例。 这样在功能上给Rhino提供了让它执行安全相关任务的支持。</p>
+
+<p>第二, <code>security.requireSecurityDomain属性的值应该被改为</code><code>true在资源束</code>bundle <code>org.mozilla.javascript.resources.Security中</code>. 这个属性的值可以在运行时通过调用<code style="font-size: 14px;">Context<font face="Open Sans, sans-serif"><span style="line-height: 21px;">的</span></font></code><code style="font-size: 14px;">isSecurityDomainRequired方法来决定。将这个属性设置为ture,要求任何编译或评估JavaScript的调用必须提供一个安全区域对象(任意类型),用来标识JavaScript代码。在一个典型的客户端嵌入中,这个对象可能是提供javascript的服务器的URL,或者是一个包含代码片段的签发人的代表(用于基于证书的安全策略)。</code></p>
+
+<p>当JavaScript代码想要执行一个受限制的行为时,安全区域会被后面的方法检索。类上下文会从安全管理(<code>java.lang.SecurityManager.getClassContext())中得到。执行限制行为的代码对应的类</code> 可以通过寻找一个在类上下文中合适的位置得到。如果调用者是JavaScript,得到的类可能是一种或两种类型。首先,它可能是解释器(如果解释器模式有效)。第二,它有可能是一个生成的类,如果类文件生成支持。一个植入可以区分两种情况,通过调用在Context Class中调用<code>isInterpreterClass()。</code> 如果是解释器类,调用Context的<code>getInterpreterSecurityDomain()</code> 方法来获取当前正在执行的被解释的脚本或方法的安全区域。否则,就是一个生成的类,一个嵌入可以调用在实现<span style="font-family: courier new,andale mono,monospace; line-height: normal;">SecuritySupport的类中调用</span><code style="font-size: 14px;">getSecurityDomain()。当类被定义而且被打开,恰当的安全区域和它建立关联,而且可以通过调用这个方法找回。一旦安全区域被决定,一个植入可以执行任何检查者适合去决定是否允许去做的操作。</code></p>
+
+<p>{{ languages( { "ja": "ja/Rhino_Overview" } ) }}</p>
diff --git a/files/zh-cn/mozilla/projects/rhino/requirements_and_limitations/index.html b/files/zh-cn/mozilla/projects/rhino/requirements_and_limitations/index.html
new file mode 100644
index 0000000000..8a159ae843
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/rhino/requirements_and_limitations/index.html
@@ -0,0 +1,24 @@
+---
+title: Rhino requirements and limitations
+slug: Mozilla/Projects/Rhino/Requirements_and_Limitations
+translation_of: Mozilla/Projects/Rhino/Requirements_and_Limitations
+---
+<h2 id="Requirements" name="Requirements">Requirements</h2>
+<p>Recent versions of Rhino have only been tested with JDK 1.4 and greater. Older versions support JDKs as early as 1.1.</p>
+<p>To use the JavaAdapter feature or an optimization level of 0 or greater, Rhino must be running under a security manager that allows the definition of class loaders.</p>
+<h2 id="Limitations" name="Limitations">Limitations</h2>
+<h3 id="LiveConnect" name="LiveConnect">LiveConnect</h3>
+<p>If a JavaObject's field's name collides with that of a method, the value of that field is retrieved lazily, and can be counter-intuitively affected by later assignments:</p>
+<pre>javaObj.fieldAndMethod = 5;
+var field = javaObj.fieldAndMethod;
+javaObj.fieldAndMethod = 7;
+// now, field == 7
+</pre>
+<p>You can work around this by forcing the field value to be converted to a JavaScript type when you take its value:</p>
+<pre>javaObj.fieldAndMethod = 5;
+var field = javaObj.fieldAndMethod + 0; // force conversion now
+javaObj.fieldAndMethod = 7;
+// now, field == 5
+</pre>
+<h3 id="JSObject" name="JSObject">JSObject</h3>
+<p>Rhino does <strong>NOT</strong> support the <code class="filename">netscape.javascript.JSObject</code> class.</p>
diff --git a/files/zh-cn/mozilla/projects/rhino/scripting_java/index.html b/files/zh-cn/mozilla/projects/rhino/scripting_java/index.html
new file mode 100644
index 0000000000..013ad3aa89
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/rhino/scripting_java/index.html
@@ -0,0 +1,397 @@
+---
+title: Scripting Java
+slug: Mozilla/Projects/Rhino/Scripting_Java
+translation_of: Mozilla/Projects/Rhino/Scripting_Java
+---
+<p>这篇文章描述了如何在rhino中使用java。使用脚本调用Java有很多用途,它使得我们可以利用Java中现有的库,来帮助我们构建强大的脚本。我们可以通过编写脚本,来对Java程序进行测试。可以通过脚本来进行探索式编程,辅助Java的开发,所谓探索式编程,就是通过快速地编程调用库或API来探索这些库或API可以做什么,显而易见,脚本语言很适合探索式编程。</p>
+
+<p>这里注意,ECMA标准并没有包含和Java(或者其他任何对象系统)交互的标准。本文所描述的所有内容,应该被认为是一个扩展。</p>
+
+
+
+<h3 id="访问_Java_Packages_和_Classes">访问 Java Packages 和 Classes</h3>
+
+<p>Java的每段代码都是类的一部分,每一个JAVA类都是包的一部分。在Javascript中,脚本不属于任何package。我们可以访问Java包中的类么?</p>
+
+<p>Rhino定义了一个顶层的变量Packages。Packages的所有属性都是Java中顶层的包,比如java和com。比如我们可以访问java包:</p>
+
+<pre class="code">js&gt; Packages.java
+[JavaPackage java]</pre>
+
+<p>还有一种更方便的方式,Rhino定义了一个顶层的变量java,等价于Packages.java。所以上面的例子可以更简介地写成:</p>
+
+<pre class="code">js&gt; java
+[JavaPackage java]
+</pre>
+
+<p>我们可以通过访问包的下层,来直接访问java类:</p>
+
+<pre class="code">js&gt; java.io.File
+[JavaClass java.io.File]
+</pre>
+
+<p>如果你的脚本需要访问很多的Java类,每次都附带完整的包名会使得编程很麻烦。Rhino提供了一个顶层的方法importPackage,它的功能和Java的import一样。比如,我们可以导入java.io包中的所有类,然后直接通过类名File来访问java.io.File:</p>
+
+<pre class="code">js&gt; importPackage(java.io)
+js&gt; File
+[JavaClass java.io.File]
+</pre>
+
+<p>这里importPackage(java.io)使得java.io包中的所有类(例如File)可以在顶层被访问。这和Java中的java.io.*;等价。</p>
+
+<p>要注意Java会暗中导入java.lang.*,但是Rhino不会。因为JavaScript的顶层对象Boolean、Math、Number、Object和String和java.lang包中同名的类并不相同。因为这种冲突,建议不要用importPackage来导入java.lang包。</p>
+
+<p>有一点要注意的,就是Rhino对于指定包名或类名时是如何处理错误的。如果java.Myclass是可访问的,Rhino会试图加载名为java.MyClass的类,如果加载失败,它会假设java.MyClass是一个包名,不会报错:</p>
+
+<pre class="code">js&gt; java.MyClass
+[JavaPackage java.MyClass]
+</pre>
+
+<p>只有在你试图将这个对象当作类使用时,才会报错。</p>
+
+<h4 id="额外的包和类">额外的包和类</h4>
+
+<p>额外的包和类也可以在Rhino中使用。确认你的.jar或.class文件在你的classpath里,你就可以在你的JavaScript应用中导入它们。这些包基本不会在java包中,所以你在使用时,需要在包前加上前缀"Packages"。 比如你想导入 <code>org.mozilla.javascript</code> 包,你应该像下面这样去使用importPackage():</p>
+
+<pre class="code">$ java org.mozilla.javascript.tools.shell.Main
+js&gt; importPackage(Packages.org.mozilla.javascript);
+js&gt; Context.currentContext;
+org.mozilla.javascript.Context@bb6ab6
+</pre>
+
+<p>偶尔,我们也会见到在一些例子中使用包的完整名称,而没有使用importPackage()。这也是可以的,只是会让你多打一些字。如果使用完整的名称,上面的例子就会变成下面这样:</p>
+
+<pre class="code">$ java org.mozilla.javascript.tools.shell.Main
+js&gt; jsPackage = Packages.org.mozilla.javascript;
+[JavaPackage org.mozilla.javascript]
+js&gt; jsPackage.Context.currentContext;
+org.mozilla.javascript.Context@bb6ab6
+</pre>
+
+<p>同样,你可以通过importClass()来导入一个类,上面的例子也可以像这样写:</p>
+
+<pre>$ java org.mozilla.javascript.tools.shell.Main
+js&gt; importClass(Packages.org.mozilla.javascript.Context);
+js&gt; Context.currentContext;
+org.mozilla.javascript.Context@bb6ab6</pre>
+
+<h3 id="和Java一起工作">和Java一起工作</h3>
+
+<p>现在我们可以访问Java类,下一步就是要创建一个对象。方法就和在Java中一样, 用new来创建对象:</p>
+
+<pre class="code">js&gt; new java.util.Date()
+Thu Jan 24 16:18:17 EST 2002
+</pre>
+
+<p>如果我们将创建的对象存放在JavaScript变量中,我们可以调用它的方法:</p>
+
+<pre class="code">js&gt; f = new java.io.File("test.txt")
+test.txt
+js&gt; f.exists()
+true
+js&gt; f.getName()
+test.txt
+</pre>
+
+<p>静态方法和属性可以直接通过类对象来访问:</p>
+
+<pre class="code">js&gt; java.lang.Math.PI
+3.141592653589793
+js&gt; java.lang.Math.cos(0)
+1
+</pre>
+
+<p>不像Java,在JavaScript里,方法就是一个对象。它可以被评估,也可以被调用。如果我们去查看这个方法,我们可以看到这个方法所有重载的形式:</p>
+
+<pre class="code">js&gt; f.listFiles
+function listFiles() {/*
+java.io.File[] listFiles()
+java.io.File[] listFiles(java.io.FilenameFilter)
+java.io.File[] listFiles(java.io.FileFilter)
+*/}
+</pre>
+
+<p>输出告诉我们,File类有listFiles方法的三种重载:一种不包含参数的,另一种包含一个FilenameFilter类型的参数,第三个包含一个FileFilter类型的参数。所有的方法都返回一个File对象数组。可以观察到Java方法的参数和返回类型在探索式编程中是非常有用的,尤其是在对一个方法的参数和返回对象不确定的时候。</p>
+
+<p>另一个有助于探索式编程的特性,是可以看到对象中定义的所有方法和属性。用JavaScript的<code>for..in</code> , 我们可以打印这些值:</p>
+
+<pre class="code">js&gt; for (i in f) { print(i) }
+exists
+parentFile
+mkdir
+toString
+wait
+<em>[44 others]</em>
+</pre>
+
+<p>注意这里不仅列出了File类中的所有方法,也列出了从基类java.lang.Object中继承的方法,例如wait。这使得我们可以更好地处理那些有复杂继承关系的对象,因为我们可以看到对象中所有可用的方法。</p>
+
+<p>Rhino可以通过属性名来方便地访问JavaBean的属性。一个JavaBean的属性foo被方法getFoo和setFoo定义,另外,一个也叫foo的boolean类型的属性,可以被isFoo来定义。比如, 下面的代码实际上调用了File对象的getName和isDirectory方法。</p>
+
+<pre class="code">js&gt; f.name
+test.txt
+js&gt; f.directory
+false
+</pre>
+
+<h3 id="调用重载方法"><font><font>调用重载方法</font></font></h3>
+
+<p> <span id="noHighlight_0.8335956993210636">根据参数类型选择调用方法的过程称为重载决议。在 Java 中, 重载决议在编译时执行, 而在rhino中则在运行时发生。这种差异是不可避免的, 因为 JavaScript 使用动态类型, 在2章中: 由于变量的类型直到运行时才知道, 才会发生重载决议。</span></p>
+
+<div class="textArea" id="destText" style="direction: ltr;">
+<div><span id="noHighlight_0.37802431709856343">例如, 请查看下面的 Java 类, 它定义了许多重载方法并调用它们。</span> </div>
+</div>
+
+
+
+<pre class="code">public class Overload {
+
+ public String f(Object o) { return "f(Object)"; }
+ public String f(String s) { return "f(String)"; }
+ public String f(int i) { return "f(int)"; }
+
+ public String g(String s, int i) { return "g(String,int)"; }
+ public String g(int i, String s) { return "g(int,String)"; }
+
+ public static void main(String[] args) {
+ Overload o = new Overload();
+ Object[] a = new Object[] { new Integer(3), "hi", Overload.class };
+ for (int i = 0; i != a.length; ++i)
+ System.out.println(o.f(a[i]));
+ }
+}
+</pre>
+
+<p><span id="noHighlight_0.42609135329922554">当我们编译和执行程序, 它产生输出</span></p>
+
+<pre class="code">f(Object)
+f(Object)
+f(Object)
+</pre>
+
+<p><span id="noHighlight_0.9335258512242988">但是, 如果我们编写一个类似的脚本</span></p>
+
+<pre class="code">var o = new Packages.Overload();
+var a = [ 3, "hi", Packages.Overload ];
+for (var i = 0; i != a.length; ++i)
+ print(o.f(a[i]));
+</pre>
+
+<p>并且运行它,将会输出</p>
+
+<pre class="code">f(int)
+f(String)
+f(Object)
+</pre>
+
+<p>因为Rhino在运行时选择重载方法, <span id="noHighlight_0.45030814581159195">所以它会调用与该参数匹配的更具体的类型。</span> <span id="noHighlight_0.45030814581159195">同时, 在编译时, Java 只在参数的类型上选择重载方法。</span></p>
+
+<p>尽管这有利于选择一种方法,这种方法可能是每个调用的更好匹配,但它确实对性能有影响,因为每次调用时都要做更多的工作。事实上,这种性能代价在实际应用中并不明显。</p>
+
+<p>因为重载决议发生在运行时,它可能在运行时失败。例如,如果我们用两个整数调用重载方法g,我们就会得到一个错误,因为方法的两个形式都比另一个更接近参数类型:</p>
+
+<pre class="code">js&gt; o.g(3,4)
+js:"&lt;stdin&gt;", line 2: The choice of Java method Overload.g
+matching JavaScript argument types (number,number) is ambiguous;
+candidate methods are:
+class java.lang.String g(java.lang.String,int)
+class java.lang.String g(int,java.lang.String)
+</pre>
+
+<p><a href="http://www.mozilla.org/js/liveconnect/lc3_method_overloading.html">http://www.mozilla.org/js/liveconnect/lc3_method_overloading.html</a> 提供了<font><font>一个更精确的重载语义定义</font><font>。</font></font></p>
+
+<h3 id="实现Java接口">  实现Java接口</h3>
+
+
+
+<p>现在我们可以访问Java类,创建Java对象,并访问这些对象的字段、方法和属性,我们就可以轻松掌握大量的功能。但是,在少数情况下是不够用的:Java中的很多API通过提供客户端必须实现的接口来工作。其中一个例子就是<font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.498039);">Thread</span></font>类:其构造函数Runnable包含一个<font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.498039);">run</span></font>方法,这个方法在新线程启动时被调用。</p>
+
+<p>为了满足这种需求,Rhino提供了创建新的Java对象实现的接口的能力。首先,我们必须定义一个JavaScript对象,其中的函数属性的名称与Java接口所需的方法名称相匹配。要实现一个<code>Runnable</code> ,我们只需要定义一个不带参数的<font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.498039);">run</span></font>单方法。如果你还记得第3章,可以用{ propertyName: value}符号定义一个JavaScript对象。我们可以在这里结合函数表达式使用这个语法来用一个 <font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.498039);">run</span></font>方法定义一个JavaScript对象:</p>
+
+<pre class="code">js&gt; obj = { run: function () { print("\nrunning"); } }
+[object Object]
+js&gt; obj.run()
+
+running
+</pre>
+
+
+
+<p>现在我们可以通过构建一个 <code>Runnable</code> 来实现 <code>Runnable</code> 接口的对象:</p>
+
+<pre><code>js&gt; r = new java.lang.Runnable(obj);</code></pre>
+
+
+
+<pre class="code">js&gt; r = new java.lang.Runnable(obj);
+[object JavaObject]
+</pre>
+
+<p><font><font>在Java中,不可能</font></font><font><font>在接口上</font><font>使用</font></font><code>new</code><font><font>运算符,因为没有可用的实现。</font><font>Rhino从JavaScript对象中获取实现</font></font><code>obj</code><font><font>。</font><font>现在我们有一个对象实现</font></font><code>Runnable</code><font><font>,我们可以创建</font></font><code>Thread</code><font><font>并运行它。</font><font>我们定义的函数</font></font><code>run </code><font><font>将在新线程上调用。</font></font></p>
+
+<pre class="code">js&gt; t = new java.lang.Thread(r)
+Thread[Thread-2,5,main]
+js&gt; t.start()
+js&gt;
+
+running
+</pre>
+
+
+
+<p><font><font>最终</font></font><code>js</code><font><font>提示和新线程的输出可能以任意顺序显示,具体取决于线程调度。</font></font></p>
+
+<p>在后台,Rhino为一个新的Java类生成字节码,该类实现 <code>Runnable</code> 并转发对其 <font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.498039);">run</span></font>方法的所有调用,并转发给关联的JavaScript对象。实现此类的对象称为Java适配器。因为转发到JavaScript是在运行时发生的,所以可能会延迟定义实现接口的方法直到它们被调用。虽然省略必要的方法对大编程来说是一种糟糕的做法,但它对小脚本和探索性编程很有用。</p>
+
+
+
+<h3 id="JavaAdapter构造函数"><font><font>JavaAdapter构造函数</font></font></h3>
+
+<p>在前面的章节中,我们使用 <code>new</code> 运算符与Java接口创建Java适配器。这种方法有其局限性:不可能实现多个接口,也不能扩展非抽象类。因为这些<font><font>原因,有一个</font></font> <code>JavaAdapter</code> 构造函数。</p>
+
+<p><code>JavaAdapter</code><font><font>构造函数</font><font>的语法</font><font>是:</font></font></p>
+
+<pre class="code">new JavaAdapter(javaIntfOrClass, [javaIntf, ..., javaIntf,] javascriptObject)
+</pre>
+
+<p><code><font face="Open Sans, arial, x-locale-body, sans-serif"><span style="background-color: #ffffff;">这里</span></font>javaIntfOrClass</code>是一个实现的接口或一个扩展的类,并且<code>javaIntf</code>是实现接口的接口。而<code>javascriptObject</code> 则包含从Java适配器调用的方法的JavaScript对象。</p>
+
+<p>在实践中,几乎不需要<code>JavaAdapter</code> 直接调用构造函数。大多数情况下,使用<code>new</code>运算符之前的语法就足够了。</p>
+
+<h3 id="作为Java接口的JavaScript函数"><font><font>作为Java接口的JavaScript函数</font></font></h3>
+
+<p>通常我们只需要使用一种方法实现一个接口,<font><font>就像前面的</font></font> <code>Runnable</code> <font><font>例子或者提供各种事件监听器实现一样。</font>为了方便这个,Rhino允许在这种接口传递JavaScript函数。</font><font>该函数被称为接口方法的实现。</font></p>
+
+<p>这里是简化的 <code>Runnable</code> 实例:</p>
+
+<pre class="code">js&gt; t = java.lang.Thread(function () { print("\nrunning"); });
+Thread[Thread-0,5,main]
+js&gt; t.start()
+js&gt;
+running
+</pre>
+
+<p><font>如果所有的方法都具有相同的签名,Rhino还允许使用JavaScript函数作为Java接口的实现方法。当调用函数时,Rhino将方法的名称作为附加参数传递。函数可以使用它</font>来代表被调用<font>的方法:</font></p>
+
+<pre class="code">js&gt; var frame = new Packages.javax.swing.JFrame();
+js&gt; frame.addWindowListener(function(event, methodName) {
+ if (methodName == "windowClosing") {
+ print("Calling System.exit()..."); java.lang.System.exit(0);
+ }
+ });
+js&gt; frame.setSize(100, 100);
+js&gt; frame.visible = true;
+true
+js&gt; Calling System.exit()...
+</pre>
+
+<h3 id="创建Java数组"><font><font>创建Java数组</font></font></h3>
+
+<p>Rhino不提供创建Java数组的特殊语法。你必须使用这个 <code>java.lang.reflect.Array</code> 类来达到这个目的。要创建一个由五个Java字符串组成的数组,可以进行以下调用:</p>
+
+<pre class="code">js&gt; a = java.lang.reflect.Array.newInstance(java.lang.String, 5);
+[Ljava.lang.String;@7ffe01
+</pre>
+
+<p>要创建一个基本类型数组,我们必须使用 <code>java.lang</code> 包中相关对象类中定义的特殊TYPE字段。例如,要创建一个字节数组,我们必须使用特殊字段 <code>java.lang.Byte.TYPE</code>:</p>
+
+<pre class="code">js&gt; a = java.lang.reflect.Array.newInstance(java.lang.Character.TYPE, 2);
+[C@7a84e4
+</pre>
+
+<p>而且结果值是允许被使用在该类型的Java数组的任何地方。</p>
+
+<pre class="code">js&gt; a[0] = 104
+104
+js&gt; a[1] = 105
+105
+js&gt; new java.lang.String(a)
+hi
+</pre>
+
+<h3 id="Java字符串和JavaScript字符串"><font><font>Java字符串和JavaScript字符串</font></font></h3>
+
+<p><font><font>请记住,Java字符串和JavaScript字符串是</font></font><strong><font><font>不</font></font></strong><font><font>一样的。</font><font>Java字符串类型的实例,</font></font><code>java.lang.String</code> ,<font><font>并具有由该类定义的所有方法。</font><font>JavaScript字符串具有由...定义的方法,</font></font><code>String.prototype</code>. <font><font>最常见的绊脚石是</font></font> <code>length</code>, <font><font><font face="consolas, Liberation Mono, courier, monospace">这是Java</font>字符串方法和JavaScript字符串的动态属性:</font></font></p>
+
+<pre class="code">js&gt; javaString = new java.lang.String("Java")
+Java
+js&gt; jsString = "JavaScript"
+JavaScript
+js&gt; javaString.length()
+4
+js&gt; jsString.length
+10
+</pre>
+
+<p>Rhino <font>在减少这两种类型之间的差异方面提供了一些帮助。</font><font>首先,您可以将JavaScript字符串传递给需要Java字符串的Java方法,Rhino将执行转换。</font><font>实际上,我们在前面</font><code>java.lang.String</code> <font>例子中</font><font>的</font><font>构造函数</font><font>调用中看到了这个特性</font><font>。</font></p>
+
+<p><font>如果</font><code>java.lang.String</code> <font>类尚未定义它们,Rhino还会使JavaScript方法可用于Java字符串。例如:</font></p>
+
+<pre class="code">js&gt; javaString.match(/a.*/)
+ava
+</pre>
+
+<h3 id="JavaImporter_构造函数">JavaImporter 构造函数</h3>
+
+<p><code>JavaImporter</code>是一个新的全局构造函数,它允许在脚本化Java时省略显式的包名称:</p>
+
+<pre>var SwingGui = JavaImporter(Packages.javax.swing,
+ Packages.javax.swing.event,
+ Packages.javax.swing.border,
+ java.awt.event,
+ java.awt.Point,
+ java.awt.Rectangle,
+ java.awt.Dimension);
+...
+
+with (SwingGui) {
+ var mybutton = new JButton(test);
+ var mypoint = new Point(10, 10);
+ var myframe = new JFrame();
+...
+}
+</pre>
+
+<p>以前,这样的功能仅适用于将 <code>org.mozilla.javascript.ImporterTopLevel</code> 用作顶级作用域的嵌入。这个类提供额外的 <code>importPackage()</code> 和<code>importClass()</code> 全局函数的脚本,但其广泛的使用有污染Java类名的全局命名空间的趋势,还有防止垃圾收集加载类。</p>
+
+<p>详情请参阅 <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=245882">Bugzilla 245882</a>.</p>
+
+<h3 id="Java_异常">Java 异常</h3>
+
+
+
+<p><font><font>JavaScript代码使用</font></font> <code>try ... catch</code> 语句<font><font>可以捕获Java方法抛出的异常</font><font>。</font><font>Rhino将Java异常封装到具有以下属性的错误对象中:</font></font></p>
+
+<ul>
+ <li><code>javaException</code><font><font>:Java方法抛出的原始异常</font></font></li>
+ <li><code>rhinoException</code><font><font>:由Rhino运行时包装的异常</font></font></li>
+</ul>
+
+<p><code>instanceof</code><font><font>运算符可用于查询异常的类型:</font></font></p>
+
+
+
+<pre>try {
+ java.lang.Class.forName("NonExistingClass");
+} catch (e) {
+ if (e.javaException instanceof java.lang.ClassNotFoundException) {
+ print("Class not found");
+ }
+}
+</pre>
+
+<p>Rhino 还支持对 <code>try... catch</code> 语句的扩展,允许定义条件捕获异常:</p>
+
+<pre>function classForName(name) {
+ try {
+ return java.lang.Class.forName(name);
+ } catch (e if e.javaException instanceof java.lang.ClassNotFoundException) {
+ print("Class " + name + " not found");
+ } catch (e if e.javaException instanceof java.lang.NullPointerException) {
+ print("Class name is null");
+ }
+}
+
+classForName("NonExistingClass");
+classForName(null);
+</pre>
diff --git a/files/zh-cn/mozilla/projects/rhino/shell/index.html b/files/zh-cn/mozilla/projects/rhino/shell/index.html
new file mode 100644
index 0000000000..d5a4b779a9
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/rhino/shell/index.html
@@ -0,0 +1,179 @@
+---
+title: Shell
+slug: Mozilla/Projects/Rhino/Shell
+translation_of: Mozilla/Projects/Rhino/Shell
+---
+<p>JavaScript的外壳提供了一个简单的方法来在批处理模式下或编程的一个探索性的互动环境运行脚本.</p>
+<h3 id="Invoking_the_Shell" name="Invoking_the_Shell">调用Shell</h3>
+<p>&lt;big&gt;<code>java org.mozilla.javascript.tools.shell.Main {{ mediawiki.external('<var>options</var>') }} <var>script-filename-or-url</var> {{ mediawiki.external('<var>script-arguments</var>') }} </code>&lt;/big&gt;</p>
+<p>这里是一些选项 <code><var>options</var></code></p>
+<h4 id="-e_script-source" name="-e_script-source"><code>-e <var>script-source</var></code></h4>
+<p>把 <var>script-source</var>  作为 JavaScript 执行.</p>
+<h4 id="-f_script-filename-or-url" name="-f_script-filename-or-url"><code>-f <var>script-filename-or-url</var></code></h4>
+<p>读取<var>script-filename-or-url</var> 的内容并作为JavaScript执行.</p>
+<h4 id="-opt_optLevel_.2F_-O_optLevel" name="-opt_optLevel_.2F_-O_optLevel"><code>-opt <var>optLevel</var></code> / <code>-O <var>optLevel</var></code></h4>
+<p>优化等级 <var>optLevel</var>, 必须是 <code>-1</code> 或 [0-9]之间的整数. 参考<a href="/en/Rhino/Optimization" title="en/Rhino_Optimization">Rhino Optimization</a> 或许详情.</p>
+<h4 id="-version_versionNumber" name="-version_versionNumber"><code>-version <var>versionNumber</var></code></h4>
+<p>制定语言编译版本. 字符串 <var>versionNumber</var> 必须是 <code>100</code>, <code>110</code>, <code>120</code>, <code>130</code>, <code>140</code>, <a class="external" href="/en/JavaScript/New_in_JavaScript/1.5" title="https://developer.mozilla.org/editor/fckeditor/core/editor/en/New_in_JavaScript_1.5"><code>150</code></a>, <code><a class="external" href="/en/JavaScript/New_in_JavaScript/1.6" title="https://developer.mozilla.org/editor/fckeditor/core/editor/en/New_in_JavaScript_1.6">160</a> 或 <a class="external" href="/en/JavaScript/New_in_JavaScript/1.7" title="https://developer.mozilla.org/editor/fckeditor/core/editor/en/New_in_JavaScript_1.7">170</a></code>. 参考<a href="/en/Rhino/Overview#JavaScript_Language_Versions" title="en/Rhino_Overview#JavaScript_Language_Versions">JavaScript Language Versions</a>获取更多的语言版本信息.</p>
+<h4 id="-strict" name="-strict"><code>-strict</code></h4>
+<p>开启strict 模式.</p>
+<h4 id="-continuations" name="-continuations"><code>-continuations</code></h4>
+<p>启用continuation的实验支持,建立优化级别为-1强制解释模式. 从Rhino 1.7 开始这个选项不再可用.</p>
+<h4 id="Note" name="Note">注意</h4>
+<p>如果shell被使用设置为<code>true</code>的系统属性<code>rhino.use_java_policy_security调用,一个安全管理将被安装</code>, shell限制脚本通过基于根据URL访问Java安全选项的权限.如果JVM实现Java2的安全模型才可以用.</p>
+<h3 id="Predefined_Properties" name="Predefined_Properties">预定义的属性</h3>
+<p>在shell中呗执行的脚本访问顶层定义的一些属性.</p>
+<h4 id="arguments" name="arguments"><code>arguments</code></h4>
+<p><code>当shell被调用时,arguments</code> 对象是一个包含所有通过命令行输入的字符串的数组</p>
+<h4 id="environment" name="environment"><code>environment</code></h4>
+<p>返回当前环境对象.</p>
+<h4 id="history" name="history"><code>history</code></h4>
+<p>显示命令行中执行命令的历史.</p>
+<h4 id="help.28.29" name="help.28.29"><code>help()</code></h4>
+<p>获取帮助信息.</p>
+<h4 id="defineClass.28className.29" name="defineClass.28className.29"><code>defineClass(<var>className</var>)</code></h4>
+<p>定义一个使用Java类命名的扩展,参数 <var>className</var>是个类名的字符串. 使用 <code>ScriptableObject.defineClass()</code> 定义扩展.</p>
+<h4 id="deserialize.28filename.29" name="deserialize.28filename.29"><code>deserialize(<var>filename</var>)</code></h4>
+<p>从指定的文件恢复以前通过调用一个被<code>serialize</code>的对象.</p>
+<h4 id="gc" name="gc"><code>gc()</code></h4>
+<p>运行垃圾回收器.</p>
+<h4 id="load.28.5Bfilename.2C_....5D.29" name="load.28.5Bfilename.2C_....5D.29"><code>load([<var>filename</var>, ...])</code></h4>
+<p>载入字符串命名的参数JavaScript源码文件. 如果有多个参数被传递,那么每一个参数都会被读取并执行.</p>
+<h4 id="loadClass.28className.29" name="loadClass.28className.29"><code>loadClass(<var>className</var>)</code></h4>
+<p>载入并执行字符串<var>className</var>.表示的类.这个类必须是已实现的脚本接口, 就像任何被编译的脚本 <a href="/en/Rhino/JavaScript_Compiler" title="en/Rhino_JavaScript_Compiler">Rhino JavaScript Compiler</a>.</p>
+<h4 id="print.28.5Bexpr_....5D.29" name="print.28.5Bexpr_....5D.29"><code>print([<var>expr</var> ...])</code></h4>
+<p>评估并打印表达式. 评估每一个表达式, 把结果转化为字符串并打印.</p>
+<h4 id="readFile.28path_.5B.2C_characterCoding.29" name="readFile.28path_.5B.2C_characterCoding.29"><code>readFile(<var>path</var> [, <var>characterCoding]</var>)</code></h4>
+<p>读取给定的文件并使用指定的编码把字节转换为字符串,如果没有制定编码就用默认编码.</p>
+<h4 id="readUrl.28url_.5B.2C_characterCoding.29" name="readUrl.28url_.5B.2C_characterCoding.29"><code>readUrl(<var>url</var> [, <var>characterCoding</var>])</code></h4>
+<p>打开指定的url,读取所有的字节并用指定的编码转化为数组,如果没有指定编码就是用默认的.</p>
+<h4 id="runCommand.28commandName.2C_.5Barg.2C_....5D_.5Boptions.5D.29" name="runCommand.28commandName.2C_.5Barg.2C_....5D_.5Boptions.5D.29"><code>runCommand(<var>commandName</var>, [<var>arg</var>, ...] [<var>options</var>])</code></h4>
+<p>执行参数中给定的命令,作为一个独立的进程选项并返回该进程的退出状态.</p>
+<p>Usage:</p>
+<pre>runCommand(command)
+runCommand(command, arg1, ..., argN)
+runCommand(command, arg1, ..., argN, options)
+</pre>
+<p>All except the last arguments to <code>runCommand</code> are converted to strings and denote command name and its arguments. If the last argument is a JavaScript object, it is an option object. Otherwise it is converted to string denoting the last argument and options objects assumed to be empty.</p>
+<p>The following properties of the option object are processed:</p>
+<ul>
+ <li><code>args</code> - provides an array of additional command arguments</li>
+ <li><code>env</code> - explicit environment object. All its enumeratable properties define the corresponding environment variable names.</li>
+ <li><code>input</code> - the process input. If it is not <code>java.io.InputStream</code>, it is converted to string and sent to the process as its input. If not specified, no input is provided to the process.</li>
+ <li><code>output</code> - the process output instead of <code>java.lang.System.out</code>. If it is not instance of <code>java.io.OutputStream</code>, the process output is read, converted to a string, appended to the output property value converted to string and put as the new value of the output property.</li>
+ <li><code>err</code> - the process error output instead of <code>java.lang.System.err</code>. If it is not instance of <code>java.io.OutputStream</code>, the process error output is read, converted to a string, appended to the err property value converted to string and put as the new value of the err property.</li>
+</ul>
+<h4 id="seal.28object.29" name="seal.28object.29"><code>seal(<var>object</var>)</code></h4>
+<p>Seal the specified object so any attempt to add, delete or modify its properties would throw an exception.</p>
+<h4 id="serialize.28object.2C_filename.29" name="serialize.28object.2C_filename.29"><code>serialize(<var>object</var>, <var>filename</var>)</code></h4>
+<p>Serialize the given object to the specified file.</p>
+<h4 id="spawn.28functionOrScript.29" name="spawn.28functionOrScript.29"><code>spawn(<var>functionOrScript</var>)</code></h4>
+<p>Run the given function or script in a different thread.</p>
+<h4 id="sync.28function.29" name="sync.28function.29"><code>sync(<var>function</var>)</code></h4>
+<p>creates a synchronized function (in the sense of a Java <code>synchronized</code> method) from an existing function. The new function synchronizes on the <code>this</code> object of its invocation.</p>
+<h4 id="quit.28.29" name="quit.28.29"><code>quit()</code></h4>
+<p>退出shell. 如果文件字符是在提示符下键入,shell将也退出在交互模式下.</p>
+<h4 id="version.28.5Bnumber.5D.29" name="version.28.5Bnumber.5D.29"><code>version([<var>number</var>])</code></h4>
+<p>设置或获取JavaScript的版本号. 如果没有参数,就返回当前的版本. 如果有参数,参数要在 <code>100</code>, <code>110</code>, <code>120</code>, <code>130</code>, <code>140</code>, <code>150</code>, <code>160 或 170范围内,它们分别对应</code> JavaScript1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 or 1.7.</p>
+<h3 id="Examples" name="Examples">例子</h3>
+<h4 id="Invocation" name="Invocation">调用</h4>
+<p>Here the shell is invoked three times from the command line. (The system command prompt is shown as <code>$</code>.) The first invocation executes a script specified on the command line itself. The next invocation has no arguments, so the shell goes into interactive mode, reading and evaluating each line as it is typed in. Finally, the last invocation executes a script from a file and accesses arguments to the script itself.</p>
+<pre>$ java org.mozilla.javascript.tools.shell.Main -e print('hi')
+hi
+$ java org.mozilla.javascript.tools.shell.Main
+js&gt; print('hi')
+hi
+js&gt; 6*7
+42
+js&gt; function f() {
+ return a;
+}
+js&gt; var a = 34;
+js&gt; f()
+34
+js&gt; quit()
+$ cat echo.js
+for (i in arguments) {
+ print(arguments[i])
+}
+$ java org.mozilla.javascript.tools.shell.Main echo.js foo bar
+foo
+bar
+$
+</pre>
+<h4 id="spawn_and_sync" name="spawn_and_sync"><code>spawn</code> 和 sync </h4>
+<p>下面的例子创建了2个线程 via <code>spawn</code> 和 uses <code>sync</code> 去创建同步的函数test <code>test版本.</code></p>
+<pre>js&gt; function test(x) {
+ print("entry");
+ java.lang.Thread.sleep(x*1000);
+ print("exit");
+}
+js&gt; var o = { f : sync(test) };
+js&gt; spawn(function() {o.f(5);});
+Thread[Thread-0,5,main]
+entry
+js&gt; spawn(function() {o.f(5);});
+Thread[Thread-1,5,main]
+js&gt;
+exit
+entry
+exit
+</pre>
+<h4 id="runCommand" name="runCommand"><code>运行命令</code></h4>
+<p>这是在Linux下调用 <code>runCommand</code> 的例子.</p>
+<pre>js&gt; runCommand('date')
+Thu Jan 23 16:49:36 CET 2003
+0
+// Using input option to provide process input
+js&gt; runCommand("sort", {input: "c\na\nb"})
+a
+b
+c
+0
+js&gt; // Demo of output and err options
+js&gt; var opt={input: "c\na\nb", output: 'Sort Output:\n'}
+js&gt; runCommand("sort", opt)
+0
+js&gt; print(opt.output)
+Sort Output:
+a
+b
+c
+js&gt; var opt={input: "c\na\nb", output: 'Sort Output:\n', err: ''}
+js&gt; runCommand("sort", "--bad-arg", opt)
+2
+js&gt; print(opt.err)
+/bin/sort: unrecognized option `--bad-arg'
+Try `/bin/sort --help' for more information.
+
+js&gt; runCommand("bad_command", "--bad-arg", opt)
+js: "&lt;stdin&gt;", line 18: uncaught JavaScript exception: java.io.IOException: bad_command: not found
+js&gt; // Passing explicit environment to the system shell
+js&gt; runCommand("sh", "-c", "echo $env1 $env2", { env: {env1: 100, env2: 200}})
+100 200
+0
+js&gt; // Use args option to provide additional command arguments
+js&gt; var arg_array = [1, 2, 3, 4];
+js&gt; runCommand("echo", { args: arg_array})
+1 2 3 4
+0
+</pre>
+<p>Windows下的例子也差不多:</p>
+<pre>js&gt; // Invoke shell command
+js&gt; runCommand("cmd", "/C", "date /T")
+27.08.2005
+0
+js&gt; // Run sort collectiong the output
+js&gt; var opt={input: "c\na\nb", output: 'Sort Output:\n'}
+js&gt; runCommand("sort", opt)
+0
+js&gt; print(opt.output)
+Sort Output:
+a
+b
+c
+js&gt; // Invoke notepad and wait until it exits
+js&gt; runCommand("notepad")
+0
+</pre>
+<p>{{ languages( { "zh-cn": "zh-cn/Shell" } ) }}</p>
diff --git a/files/zh-cn/mozilla/projects/social_api/index.html b/files/zh-cn/mozilla/projects/social_api/index.html
new file mode 100644
index 0000000000..55d8b5525e
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/social_api/index.html
@@ -0,0 +1,97 @@
+---
+title: Social API
+slug: Mozilla/Projects/Social_API
+tags:
+ - API
+ - Landing
+ - Mozilla
+ - NeedsTranslation
+ - Social
+ - TopicStub
+translation_of: Archive/Social_API
+---
+<p><span class="seoSummary">The Social API is an architecture that makes it easier for web browsers to integrate with social media services, using standard web technologies as the API. Once a social service provider is implemented for Firefox, it becomes possible for the browser to integrate web resources from a service, in-chrome user controls and information related to that service.</span> The following articles explain how to implement a social service provider.<br>
+ <br>
+ The Social API supports specific vertical use cases centered around social interactions, but does not tightly constrain those use cases, allowing flexibility and creativity for 3rd parties. Specific features supported are notifications, share, bookmarking (or save-for-later), sidebars and communications (e.g. chat and video).</p>
+
+<div class="row topic-page">
+<div class="section">
+<h2 class="Documentation" id="Social_API_documentation">Social API documentation</h2>
+
+<dl>
+ <dt><a href="/en-US/docs/Social_API/Glossary" title="/en-US/docs/Social_API/Glossary">Social API glossary</a></dt>
+ <dd>Provides definitions of key terms you'll need to understand when using the Social API.</dd>
+ <dt><a href="/en-US/docs/Social_API/Manifest" title="/en-US/docs/Social_API/Manifest">Social service manifest</a></dt>
+ <dd>A description of—(TBD: and guide to building)—the manifest required.</dd>
+ <dt><a href="/en-US/docs/Social_API/Service_worker_API_reference" title="/en-US/docs/Social_API/Service_worker_reference">Social service worker API reference</a> {{obsolete_inline(48)}}</dt>
+ <dd>A reference to the social service worker API.</dd>
+ <dt><a href="/en-US/docs/DOM/navigator.mozSocial" title="/en-US/docs/DOM/navigator.mozSocial">Social service content API: MozSocial</a> {{obsolete_inline(51)}}</dt>
+ <dd>A reference to the social service content API, which is provided by the {{domxref("navigator.MozSocial")}} object.</dd>
+ <dt><a href="/en-US/docs/Social_API/Share" title="/en-US/docs/Social_API/Share">Social share API</a></dt>
+ <dd>A reference to the Share API.</dd>
+ <dt><a href="/en-US/docs/Social_API/Bookmarks" title="/en-US/docs/Social_API/Share">Social bookmarks API</a> {{obsolete_inline(51)}}</dt>
+ <dd>A reference to the Social Bookmarks API.</dd>
+ <dt><a href="/en-US/docs/Social_API/Status" title="/en-US/docs/Social_API/Share">Social status API</a> {{obsolete_inline(51)}}</dt>
+ <dd>A reference to the Status API.</dd>
+ <dt><a href="/en-US/docs/Social_API/Widgets" title="/en-US/docs/Social_API/Widgets">Social service widgets</a></dt>
+ <dd>A guide to the widgets provided by the social service.</dd>
+</dl>
+
+<h2 id="How_to_create_a_SocialAPI_Provider">How to create a SocialAPI Provider</h2>
+
+<p>A step-by-step guide to create a simple Social API provider.</p>
+
+<dl>
+ <dt><a href="/en-US/docs/Social_API/Guide/FirstSteps" title="/en-US/docs/Social_API/FirstSteps">First Steps</a></dt>
+ <dd>The basics of getting an installable social provider running.</dd>
+ <dt><a href="/en-US/docs/Social_API/Guide/AmbientNotifications" title="/en-US/docs/Social_API/Implementing_chat_functionality">Adding ambient notifications</a> {{obsolete_inline(51)}}</dt>
+ <dd>A short guide to implementing ambient notifications using the Social API.</dd>
+ <dt><a href="/en-US/docs/Social_API/Guide/Status" title="/en-US/docs/Social_API/Implementing_chat_functionality">Implementing status and notifications</a> {{obsolete_inline(51)}}</dt>
+ <dd>A guide to implementing a status panel with notifications using the Social API.</dd>
+ <dt><a href="/en-US/docs/Social_API/Guide/Bookmarks" title="/en-US/docs/Social_API/Implementing_chat_functionality">Adding bookmark support</a> {{obsolete_inline(51)}}</dt>
+ <dd>A short guide to implementing social bookmarks using the Social API.</dd>
+ <dt><a href="/en-US/docs/Social_API/Guide/Share" title="/en-US/docs/Social_API/Implementing_chat_functionality">Implementing share</a></dt>
+ <dd>A guide to implementing a share panel using the Social API.</dd>
+ <dt><a href="/en-US/docs/Social_API/Guide/Chat" title="/en-US/docs/Social_API/Implementing_chat_functionality">Supporting chat</a> {{obsolete_inline(51)}}</dt>
+ <dd>A guide to implementing chat features using the Social API.</dd>
+</dl>
+
+<p><span class="alllinks"><a href="/en-US/docs/tag/Social" title="/en-US/docs/tag/CSS">View All...</a></span></p>
+</div>
+
+<div class="section">
+<h2 class="Community" id="Community" name="Community">Getting help from the community</h2>
+
+<p>Need help on a Social API related problem and can't find the solution in the documentation?</p>
+
+<ul>
+ <li>Ask your question on the Mozilla IRC channel: <a href="irc://irc.mozilla.org/socialdev" title="irc://irc.mozilla.org/socialdev">#socialdev</a></li>
+</ul>
+
+<p><span class="alllinks"><a class="external" href="http://www.catb.org/~esr/faqs/smart-questions.html" title="http://www.catb.org/~esr/faqs/smart-questions.html">Don't forget about the <em>netiquette</em>...</a></span></p>
+
+<h2 class="Tools" id="Tools" name="Tools">Tools and demos</h2>
+
+<ul>
+ <li><a href="https://github.com/mixedpuppy/socialapi-demo" title="https://github.com/mixedpuppy/socialapi-demo">A complete sample social service provider on github</a>.</li>
+ <li><a href="https://github.com/mixedpuppy/socialapi-toolbarbutton">A sample using only a toolbarbutton</a>.</li>
+ <li><a href="https://github.com/mixedpuppy/socialapi-sidebar">A sample sidebar project</a>. {{obsolete_inline(51)}}</li>
+ <li><a href="/en-US/docs/Social_API_Devtools" title="/en-US/docs/Social_API_Devtools">How to use the Firefox Developer Tools with the Social API</a>.</li>
+</ul>
+
+<p><span class="alllinks"><a href="/en-US/docs/tag/Social" title="/en-US/docs/tag/CSS:Tools">View All...</a></span></p>
+
+<h2 class="Related_Topics" id="Related_Topics" name="Related_Topics">Available Social Providers</h2>
+
+<p>Try out any of several providers on the <a href="https://activations.cdn.mozilla.net/">SocialAPI Directory</a> site (Firefox 29 or later required)</p>
+
+
+<h2 class="Related_Topics" id="Related_Topics" name="Related_Topics">Related Topics</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Apps" title="/en-US/docs/Apps">Open web apps</a></li>
+</ul>
+</div>
+</div>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/projects/social_api/share/index.html b/files/zh-cn/mozilla/projects/social_api/share/index.html
new file mode 100644
index 0000000000..844ac9d693
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/social_api/share/index.html
@@ -0,0 +1,86 @@
+---
+title: Share
+slug: Mozilla/Projects/Social_API/Share
+translation_of: Archive/Social_API/Share
+---
+<p id="Share">这一篇只是初步草案,可能会被改变。分享从 [TBD: Firefox 23] 开始可用。</p>
+
+<p>A service provider may choose to provide a Share panel that users can use to share content from the current browser tab with their friends.  The Share panel is slightly different from other Social UI in the browser.  The Share panel itself contains a list of providers that support the share functionality.  When a user shares a page, they can choose which provider they want to share with.  Each provider may have differing functionality, such as simply providing a comment box to extensive functionlality allowing for image selection and more.</p>
+
+<p>Share is initiated by the user either through the share button in the toolbar or a context menu.  The user can select an image or text in a page to be shared, or share the page itself.  Links within a page may also be shared without visiting the link.</p>
+
+<p>A provider implementing support for share may choose to use a URL template that is compatible with OExchange, however the browser also sends a DOM event to the page after load containing details of the share.  In some circumstances, such as sharing a link on the page, the browser will not have detailed information.  Using the DOM event allows the provider to display information about the page being shared without needing to fetch it themselves and parse the page for information.  The browser includes certain META tags, including OpenGraph tags in the event data.</p>
+
+<h2 id="A_User_Experience_Flow_for_Share">A User Experience Flow for Share</h2>
+
+<p>SocialAPI content works different than typical web pages.  The are presented as primary UI in the browser, and may be confined in size, live longer than a browser tab, and more.  How your user will interact with your share panel is unique and you will need to take into account how a user should experience your share panel.</p>
+
+<p>[TODO: describe the expected flow here]</p>
+
+<h2 id="OpenGraphData_DOM_Event">OpenGraphData DOM Event</h2>
+
+<p>The share page can listen for the <code>OpenGraphData</code> DOM Event.</p>
+
+<pre>addEventListener("OpenGraphData", function(e) {
+  var shareData = JSON.parse(e.detail);
+  $("#shared").text(shareData.url);
+})
+</pre>
+
+<h4 id="Attributes">Attributes</h4>
+
+<p>The event detail can contain the following attributes which are retreived from META tags and other tags within HEAD, such as the TITLE tag:</p>
+
+<ul>
+ <li>url: The URL to the page, link, image or video being shared</li>
+ <li>medium: The media type being shared</li>
+ <li>source: The media url being shared if a video is being shared</li>
+ <li>sitename: The site name</li>
+ <li>title: The title of the page</li>
+ <li>description: The description of the page</li>
+ <li>text: The selected text that the user is sharing</li>
+ <li>previews: A list of images available as page previews</li>
+</ul>
+
+<h2 id="Share_URL_Template">Share URL Template</h2>
+
+<p>While we prefer the use of the DOM event, many sites have existing endpoints that allow users to share to that site.  SocialAPI supports using a URL template to make implementation easy for sites that already have this functionality.  In your manifest, you can define your shareURL in this format:</p>
+
+<pre>"shareURL": "https://yoursite.com/share?u=%{url}&amp;t=%{title}</pre>
+
+<p>The %{name} values will be replaced with the following attributes if available.  Otherwise that parameter is removed from the final url used to load your share endpoint.</p>
+
+<ul>
+ <li>url: The URL to the page, link, image or video being shared</li>
+ <li>medium: The media type being shared</li>
+ <li>source: The media url being shared if a video is being shared</li>
+ <li>sitename: The site name</li>
+ <li>title: The title of the page</li>
+ <li>description: The description of the page</li>
+ <li>text: The selected text that the user is sharing</li>
+ <li>image: A URL to an image to use as a preview, or the image shared by the user.</li>
+</ul>
+
+<h2 id="How_to_properly_size_your_share_panel">How to properly size your share panel</h2>
+
+<p>Your share panel is presented in a door hanger from the browser toolbar.  While it can be flexible in size, there is a minimum and a maximum size that the panel will allow.  You also need to implement a couple items to help the browser identify the size you need for your panel.  There are a few ways you can define the proper size for your panel, here are some examples:</p>
+
+<h3 id="Styling_the_BODY_element">Styling the BODY element</h3>
+
+<p>By default the browser will look at the <code>body.style.width</code> and <code>body.style.height</code>, also taking into account the margin.  It will try to size the panel to show your full page.</p>
+
+<pre>&lt;html&gt;
+&lt;body style="width: 300px; height: 400px"&gt;
+&lt;/body&gt;
+&lt;/html&gt;
+</pre>
+
+<h3 id="Identifying_a_content_element">Identifying a content element</h3>
+
+<p>The browser will also look to see if you have defined a primary content element.  If you have, then it will use the width and height styles from that element to size the panel.  You will need to make sure that your content element is properly placed.</p>
+
+<pre>&lt;html&gt;
+&lt;body contentid="content"&gt;
+&lt;div id="content" style="width: 300px; height: 400px; top: 0; left: 0;"/&gt;
+&lt;/body&gt;
+&lt;/html&gt;</pre>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/build_documentation/index.html b/files/zh-cn/mozilla/projects/spidermonkey/build_documentation/index.html
new file mode 100644
index 0000000000..ecb793016e
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/build_documentation/index.html
@@ -0,0 +1,294 @@
+---
+title: SpiderMonkey Build Documentation
+slug: Mozilla/Projects/SpiderMonkey/Build_Documentation
+translation_of: Mozilla/Projects/SpiderMonkey/Build_Documentation
+---
+<div>{{SpiderMonkeySidebar("General")}}</div>
+
+<h2 id="构建_SpiderMonkey">构建 SpiderMonkey</h2>
+
+<p>使用本说明来构建最新的 SpiderMonkey 源码.</p>
+
+<p><strong>在构建前, 确保有适合你计算机的构建工具:</strong> <a href="/en-US/Developer_Guide/Build_Instructions/Linux_Prerequisites" title="en/Linux_Build_Prerequisites">Linux</a>, <a href="/en/Developer_Guide/Build_Instructions/Windows_Prerequisites" title="en/Windows_Build_Prerequisites">Windows</a>, <a href="/en/Developer_Guide/Build_Instructions/Mac_OS_X_Prerequisites" title="en/Mac_OS_X_Build_Prerequisites">Mac</a>, <a href="/en/Developer_Guide/Build_Instructions" title="en/Build_Documentation">others</a>. 当构建的版本低于28, 你还需要外加 <a href="/en/NSPR" title="en/NSPR">NSPR</a>.</p>
+
+<p style="margin: 0px 0px 1.7em; padding: 0px;">以及理所当然地, 你需要 <a class="internal" href="Getting_SpiderMonkey_source_code" title="En/SpiderMonkey/Getting SpiderMonkey source code#Getting the latest SpiderMonkey source code">获取 SpiderMonkey 源代码。</a></p>
+
+<h3 id="非开发者_(优化)_模式构建">非开发者 (优化) 模式构建</h3>
+
+<p>如果你想在生产环境中安装使用SpiderMonkey或运行标准性能测试,可以使用此步骤。 (如果你想在你的C++应用中把 SpiderMonkey 作为库使用, 或从事改进 SpiderMonkey 本身的工作, 按之后的描述,使用 开发者/调试 模式构建.)</p>
+
+<pre class="eval">cd js/src
+autoconf2.13
+
+# This name should end with "_OPT.OBJ" to make the version control system ignore it.
+mkdir build_OPT.OBJ
+cd build_OPT.OBJ
+../configure
+# Use "mozmake" on Windows
+make
+</pre>
+
+<p>一些注意事项:</p>
+
+<ul>
+ <li>
+ <p>The most common build problems are dependency problems. See the <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions#Getting_started">build prerequisites page for your platform</a>.</p>
+ </li>
+ <li>
+ <p>SpiderMonkey does not support building in your source directory. You must configure and build in a separate build directory, as shown above.</p>
+ </li>
+ <li>
+ <p>Yes, autoconf version 2.13 really is required. Later versions won't work. (However, don't install it as your system <code>autoconf</code>. That also won't work, and it's a bad idea because that version is so old.)</p>
+ </li>
+</ul>
+
+<div class="note">
+<p><strong>Note</strong>: If you are on Mac and getting an error similar to</p>
+
+<p>"<code>checking whether the C compiler (gcc-4.2  ) works... no<br>
+ configure: error: installation or configuration problem: C compiler cannot create executables.</code>"</p>
+
+<p>You can try configuring like so:</p>
+
+<pre><code>CC=clang CXX=clang++ ../configure</code></pre>
+
+<p>It is also possible that baldrdash  may fail to compile with</p>
+
+<pre>/usr/local/Cellar/llvm/7.0.1/lib/clang/7.0.1/include/inttypes.h:30:15: fatal error: 'inttypes.h' file not found
+
+/usr/local/Cellar/llvm/7.0.1/lib/clang/7.0.1/include/inttypes.h:30:15: fatal error: 'inttypes.h' file not found, err: true</pre>
+
+<p>This is because, starting from Mohave, headers are no longer installed in /usr/include. Refer the <a href="https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes">release notes</a>  under Command Line Tools -&gt; New Features</p>
+
+<p>The release notes also states that this compatibility package will no longer be provided in the near future, so the build system on macOS will have to be adapted to look for headers in the SDK<br>
+ <br>
+ Until then, the following should help,</p>
+
+<pre><code>open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pk
+</code></pre>
+</div>
+
+<p>This builds an executable named <code>js</code> in the directory <code>build-release/dist/bin</code>. You can test it with <code>dist/bin/js --help</code>, which displays a help page. At this point, you're ready to <a href="/en/SpiderMonkey/Introduction_to_the_JavaScript_shell" title="en/Introduction_to_the_JavaScript_shell">run and try out the shell</a>.</p>
+
+<p>On Mac, Linux, or UNIX, you can install SpiderMonkey on your system with the additional command <code>make install</code>. This installs the shared library to <code>/usr/local/lib</code>, the C header files to <code>/usr/local/include</code>, and the <code>js</code> executable to<code>/usr/local/bin</code>.</p>
+
+<h3 id="开发者_(调试)_模式构建">开发者 (调试) 模式构建</h3>
+
+<p>For developing and debugging SpiderMonkey itself, it is best to have both a debug build (for everyday debugging) and an optimized build (for performance testing), in separate build directories. Thus, in addition to following the steps above, you should also create a debug build using these steps:</p>
+
+<pre class="eval">cd js/src
+autoconf2.13
+
+# This name should end with "_DBG.OBJ" to make the version control system ignore it.
+mkdir build_DBG.OBJ
+cd build_DBG.OBJ
+../configure --enable-debug --disable-optimize
+# Use "mozmake" on Windows
+make
+</pre>
+
+<p>You can also build debug builds of SpiderMonkey with the <code>JS_GC_ZEAL</code> option, which adds a new built-in function to SpiderMonkey that lets you configure zealous garbage collection.  This can help debug memory leaks and other memory-related problems. See <a class="internal" href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCZeal" title="En/SpiderMonkey/JSAPI Reference/JS SetGCZeal"><code>JS_SetGCZeal()</code></a> for details.</p>
+
+<p>For a list of other available build options, type (assuming the current working directory is one of the above-created build directories):</p>
+
+<pre class="eval">../configure --help
+</pre>
+
+<h4 id="生成编译数据库">生成编译数据库</h4>
+
+<p>Some tools (like IDEs, static analyzers and refactoring tools) consume a file called <code><a href="https://clang.llvm.org/docs/JSONCompilationDatabase.html">compile_commands.json</a></code> which contains a description of all the pieces required to build a piece of software so that tools don't have to also understand a build system.</p>
+
+<p>To generate a <code>compile_commands.json</code> with the SpiderMonkey <code>configure</code> script, enable the CompileDB backend, like this:</p>
+
+<pre class="syntaxbox"> ../configure &lt;options&gt; --enable-build-backends=CompileDB,RecursiveMake
+</pre>
+
+<p>(RecursiveMake is there as you'd likely also want to be able to build!)</p>
+
+<h3 id="Building" name="Building">Windows Builds</h3>
+
+<div class="note">
+<p>Since version 28, <strong>threadsafe builds are the default</strong>, and should work out of the box on all POSIX platforms. Hence, the following instructions should only be relevant if you're on Windows or compiling an older version of SpiderMonkey.</p>
+</div>
+
+<p>The <a href="https://wiki.mozilla.org/MozillaBuild">MozillaBuild</a> batch file you used to open your shell (e.g. <code>start-shell-msvc2013.bat</code> or <code>start-shell-msvc2013-x64.bat</code>) determines whether the compiler toolchain will target 32-bit or 64-bit builds. To create a 64-bit build, note that you must configure with <code>--target=x86_64-pc-mingw32 --host=x86_64-pc-mingw32</code>.</p>
+
+<p>Since the POSIX NSPR emulation is not available for Windows, a working version of NSPR must be available to your build. <strong>The easiest option is to configure with <code>--enable-nspr-build.</code></strong><code> </code>This configure option builds the in-tree version of NSPR which is probably what you want; <span style="line-height: normal;"><span style="line-height: normal;">because SpiderMonkey uses newer NSPR symbols, the NSPR that ships with your operating system probably does not work.</span></span></p>
+
+<p>If <code>--enable-nspr-build</code> does not work, explicitly tell <code>configure</code> where to find NSPR using the <code>--with-nspr-cflags</code> and <code>--with-nspr-libs</code> configure options. For example, assuming your local NSPR has been installed to <code>C:/mozilla-build/msys/local</code>:</p>
+
+<pre><span style="line-height: normal;"><code><span style="line-height: normal;"><code><code>./configure<code> --with-nspr-cflags="-IC:/mozilla-build/msys/local/include" \
+     --with-nspr-libs="<span style="line-height: normal;"><code><span style="line-height: normal;"><code><code><code>C:/mozilla-build/msys/local</code></code></code></span></code></span>/lib/libnspr4.a \
+ <span style="line-height: normal;"><code><span style="line-height: normal;"><code><code><code>C:/mozilla-build/msys/local</code></code></code></span></code></span>/lib/libplds4.a \
+ <span style="line-height: normal;"><code><span style="line-height: normal;"><code><code><code>C:/mozilla-build/msys/local</code></code></code></span></code></span>/lib/libplc4.a"</code>
+</code></code></span></code></span></pre>
+
+<p>If you get symbol loading or dynamic library errors, you can force the correct NSPR to load with:</p>
+
+<pre><span style="line-height: normal;">PATH="$PATH;<span style="line-height: normal;">C:/mozilla-build/msys/local/lib/</span><span style="line-height: normal;">" ./js</span></span></pre>
+
+<h2 id="指定安装目录">指定安装目录</h2>
+
+<p><code>make install</code> puts files in the following directories by default. You can override this by passing options to the <code>configure</code> script:</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>What it is</th>
+ <th>Where it gets put</th>
+ <th><code>configure</code> option</th>
+ </tr>
+ <tr>
+ <td>executables, shell scripts</td>
+ <td><code>/usr/local/bin</code></td>
+ <td><code>--bindir</code></td>
+ </tr>
+ <tr>
+ <td>libraries, data</td>
+ <td><code>/usr/local/lib</code></td>
+ <td><code>--libdir</code></td>
+ </tr>
+ <tr>
+ <td>architecture-independent data</td>
+ <td><code>/usr/local/share</code></td>
+ <td><code>--sharedir</code></td>
+ </tr>
+ <tr>
+ <td>C header files</td>
+ <td><code>/usr/local/include</code></td>
+ <td><code>--includedir</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<p>For convenience, you can pass the <code>configure</code> script an option of the form <code>--prefix=&lt;PREFIXDIR&gt;</code>, which substitutes <code>&lt;PREFIXDIR&gt;</code> for <code>/usr/local</code> in all the settings above, in one step. This is usually the least troublesome thing to do, as it preserves the typical arrangement of <code>lib</code>, <code>bin</code>, and the rest.</p>
+
+<div class="note"><strong>Note:</strong> All directories you pass to <code>configure</code> are recorded in the generated makefile, so you don't need to specify them again until you re-run <code>configure</code>.</div>
+
+<h2 id="构建_SpiderMonkey_作为静态库">构建 SpiderMonkey 作为静态库</h2>
+
+<p>默认情况下, SpiderMonkey 会构建为共享库. However, you can build SpiderMonkey as a static library by specifying the <code>--disable-shared-js</code> flag when you run <code>configure</code>.</p>
+
+<h2 id="指定编译器及编译标签">指定编译器及编译标签</h2>
+
+<p>If you want to use a compiler other than the one the <code>configure</code> script chooses for you by default, you can set the <code>CXX</code> variable in the environment when you run <code>configure</code>. This will save the values you specify in the generated makefile, so once you've set it, you don't need to do so again until you re-run <code>configure</code>.</p>
+
+<p>If you'd like to pass certain flags to the compiler, you can set the <code>CXXFLAGS</code> environment variable when you run <code>configure</code>. For example, if you're using the GNU toolchain, the following will pass the <code>-g3</code> flag to the compiler, causing it to emit debug information about macros. Then you can use those macros in <code>gdb</code> commands:</p>
+
+<pre class="eval">$ <strong>CXXFLAGS=-g3 $SRC/configure</strong>
+<em>...</em>
+checking whether the C++ compiler (c++ -g3 ) works... yes
+<em>...</em>
+$
+</pre>
+
+<h2 id="交叉编译选项">交叉编译选项</h2>
+
+<p>For cross-compiling you will need a cross-compiling compiler. That tends to be easier with clang as clang has cross-compiling support built in. You may need other libraries though.  For example on debian linux you'll need the following to cross compile from x86_64 to x86.</p>
+
+<pre class="syntaxbox">apt install clang libstdc++-8-dev-i386-cross binutils-i686-gnu zlib1g-dev:i386</pre>
+
+<p>You'll also need rust, in addition to having normal rust set up you'll need to add another target to your existing rust toolchain (don't add a new toolchain spidermonkey will use only one toolchain and use it for both host and target code:</p>
+
+<pre class="syntaxbox">rustup target add i686-unknown-linux-gnu</pre>
+
+<p>To build a 32-bit version on a 64-bit Linux system, you can use the following:</p>
+
+<pre class="eval">PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig CC="gcc -m32 -mfpmath=sse -msse -msse2" CXX="g++ -m32 -mfpmath=sse -msse -msse2" AR=ar \
+$SRC/configure --target=i686-pc-linux
+</pre>
+
+<p>Or for clang.</p>
+
+<pre class="syntaxbox">$SRC/configure --target=i686-pc-linux-gnu</pre>
+
+<p>To build a 32-bit arm version on a 64-bit Linux system, that runs in the arm simulator, you can use the following:</p>
+
+<pre>   AR=ar CC="gcc -m32 -mfpmath=sse -msse -msse2" CXX="g++ -m32 -mfpmath=sse -msse -msse2" \
+    $SRC/configure --target=i686-pc-linux --enable-simulator=arm
+</pre>
+
+<p>To build a 32-bit version on a 64-bit Mac system (the target version is specific to your OS/X SDK), you can use the following:</p>
+
+<pre class="syntaxbox">$SRC/configure --target=i386-apple-darwin16.7.0 # Choose the appropriate SDK version for your version of OS/X</pre>
+
+<p>To build a 64-bit version on a 32-bit Mac system (e.g. Mac OS X 10.5), you can use the following:</p>
+
+<pre class="eval">AR=ar CC="gcc -m64" CXX="g++ -m64" ../configure --target=x86_64-apple-darwin10.0.0
+</pre>
+
+<p>To build a 64-bit Windows version, you can use the following:</p>
+
+<pre class="eval">$SRC/configure --host=x86_64-pc-mingw32 --target=x86_64-pc-mingw32
+</pre>
+
+<div class="note"><strong>Note:</strong> You must have started your MozillaBuild shell with the proper -x64.bat script in order for the 64-bit compilers to be in your PATH.</div>
+
+<p>Whatever compiler and flags you pass to <code>configure</code> are recorded in the generated makefile, so you don't need to specify them again until you re-run <code>configure</code>.</p>
+
+<h2 id="Building_your_application">Building your application</h2>
+
+<p>While "How to build your complete application" is clearly out of scope for this document, here are some tips that will help get you on your way:</p>
+
+<ul>
+ <li>The SpiderMonkey developers frequently and deliberately change the JSAPI ABI. You cannot use headers built for one version/configuration of JSAPI to create object files which will be linked against another.</li>
+ <li>Support for JS_THREADSAFE was recently removed, and threadsafe builds are now enabled by default.</li>
+ <li>The <code>js-config</code> script, described below, is the recommended way to determine correct include paths, required libraries, etc. for your embedding to use during compilation. We highly recommend calling the <code>js-config</code> script from your embedding's makefile to set your CFLAGS, LDFLAGS, and so forth.</li>
+ <li>To install SpiderMonkey somewhere other than the default, you must use the <code>configure</code> <code>--prefix</code> option, as described above. Failure to do so may break your <code>js-config.h</code> header or <code>js-config</code> script.</li>
+ <li>Some features detected by the <code>configure</code> script do not work for cross-compilation.</li>
+</ul>
+
+<h3 id="Using_the_js-config_script">Using the js-config script</h3>
+
+<p>In addition to the SpiderMonkey libraries, header files, and shell, the SpiderMonkey build also produces a shell script named <code>js-config</code> which other build systems can use to find out how to compile code using the SpiderMonkey APIs, and how to link with the SpiderMonkey libraries.</p>
+
+<div class="note"><strong>Note:</strong> In SpiderMonkey 1.8.5, the js-config script is not generated properly on many platforms. If the instructions below do not work, you can try this <a href="/en/SpiderMonkey/1.8.5#js-config" title="https://developer.mozilla.org/en/SpiderMonkey/1.8.5#js-config">workaround</a>.</div>
+
+<p>When invoked with the <code>--cflags</code> option, <code>js-config</code> prints the flags that you should pass to the C compiler when compiling files that use the SpiderMonkey API. These flags ensure the compiler will find the SpiderMonkey header files.</p>
+
+<pre class="eval">$ ./js-config --cflags # Example output: -I/usr/local/include/js -I/usr/include/nspr
+</pre>
+
+<p>When invoked with the <code>--libs</code> option, <code>js-config</code> prints the flags that you should pass to the C compiler when linking an executable or shared library that uses SpiderMonkey. These flags ensure the compiler will find the SpiderMonkey libraries, along with any libraries that SpiderMonkey itself depends upon (like NSPR).</p>
+
+<pre class="eval">$ ./js-config --libs # Example output: -L/usr/local/lib -lmozjs -L/usr/lib -lplds4 -lplc4 -lnspr4 -lpthread -ldl -ldl -lm -lm -ldl</pre>
+
+<h2 id="Test" name="Test">Testing SpiderMonkey</h2>
+
+<ul>
+ <li>
+ <p>Run <code>${BUILDDIR}/dist/bin/js </code><code>Y.js</code> and check if appropriate output is printed. (It should say: <code>5! is 120</code>.)</p>
+ </li>
+ <li>
+ <p>Run the main test suite by running <code>./tests/jstests.py ${BUILDDIR}/dist/bin/js</code></p>
+ </li>
+ <li>
+ <p>Run JIT-specific tests by running: <code>./jit-test/jit_test.py ${BUILDDIR}/dist/bin/js</code></p>
+ </li>
+</ul>
+
+<h2 id="Building_SpiderMonkey_1.8_or_earlier">Building SpiderMonkey 1.8 or earlier</h2>
+
+<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.286em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;">Use these instructions to build SpiderMonkey from an official source release or from the old CVS repository. To build the latest SpiderMonkey sources from Mercurial, see <a href="#Building_SpiderMonkey_tip" style="text-decoration: none; color: rgb(51, 102, 153) !important; cursor: default;">Building SpiderMonkey </a>above.</p>
+
+<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.286em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"><a href="/en/SpiderMonkey" style="text-decoration: none; color: rgb(51, 102, 153) !important; cursor: default;" title="en/SpiderMonkey">SpiderMonkey</a> is easy to build from source if you have the usual Mozilla build prerequisites installed. Before you begin, make sure you have right build tools for your computer: <a href="/en/Developer_Guide/Build_Instructions/Linux_Prerequisites" style="text-decoration: none; color: rgb(51, 102, 153) !important; cursor: default;" title="en/Linux_Build_Prerequisites">Linux</a>, <a href="/en/Developer_Guide/Build_Instructions/Windows_Prerequisites" style="text-decoration: none; color: rgb(51, 102, 153) !important; cursor: default;" title="en/Windows_Build_Prerequisites">Windows</a>, <a href="/en/Developer_Guide/Build_Instructions/Mac_OS_X_Prerequisites" style="text-decoration: none; color: rgb(51, 102, 153) !important; cursor: default;" title="en/Mac_OS_X_Build_Prerequisites">Mac</a>, <a href="/en/Developer_Guide/Build_Instructions" style="text-decoration: none; color: rgb(51, 102, 153) !important; cursor: default;" title="en/Build_Documentation">others</a>.</p>
+
+<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.286em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;">First, download a SpiderMonkey source distribution, such as <a class="external" href="http://ftp.mozilla.org/pub/mozilla.org/js/js-1.8.0-rc1.tar.gz" style="text-decoration: none; color: rgb(51, 102, 153) !important; cursor: default;">SpiderMonkey 1.8 Release Candidate 1</a>.</p>
+
+<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.286em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;">To build, use these commands:</p>
+
+<pre class="eval" style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.286em; margin-left: 0px; padding-top: 15px; padding-right: 15px; padding-bottom: 15px; padding-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: dotted; background-clip: initial; background-color: rgb(246, 246, 242); font: normal normal normal 100%/normal 'Courier New', 'Andale Mono', monospace;">tar xvzf js-1.8.0-rc1.tar.gz
+cd js/src
+make -f Makefile.ref
+</pre>
+
+<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.286em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;">This builds a debug version of SpiderMonkey. All build files are created in a subdirectory named depending on your system (for example,<code style="font: normal normal normal 100%/normal 'Courier New', 'Andale Mono', monospace; color: inherit; font-weight: inherit;">Linux_All_DBG.OBJ</code> if you are on Linux). To install this build on your system, see <a class="external" href="http://ebixio.com/blog/2010/07/31/how-to-install-libjs-spidermonkey/" style="text-decoration: none; color: rgb(51, 102, 153) !important; cursor: default;" title="http://ebixio.com/blog/2010/07/31/how-to-install-libjs-spidermonkey/">SpiderMonkey installation instructions</a>.</p>
+
+<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.286em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;">To build an optimized (non-debug) version of SpiderMonkey:</p>
+
+<pre class="eval" style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.286em; margin-left: 0px; padding-top: 15px; padding-right: 15px; padding-bottom: 15px; padding-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: dotted; background-clip: initial; background-color: rgb(246, 246, 242); font: normal normal normal 100%/normal 'Courier New', 'Andale Mono', monospace;">make BUILD_OPT=1 -f Makefile.ref</pre>
+
+<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.286em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;">To build a <a href="/en/SpiderMonkey/JSAPI_Reference/JS_THREADSAFE" style="text-decoration: none; color: rgb(51, 102, 153) !important; cursor: default;" title="JS_THREADSAFE">thread-safe</a> version of SpiderMonkey:</p>
+
+<pre class="eval" style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.286em; margin-left: 0px; padding-top: 15px; padding-right: 15px; padding-bottom: 15px; padding-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: dotted; background-clip: initial; background-color: rgb(246, 246, 242); font: normal normal normal 100%/normal 'Courier New', 'Andale Mono', monospace;">make JS_DIST=/full/path/to/directory/containing/nspr JS_THREADSAFE=1 -f Makefile.ref
+</pre>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/comparision_of_js_engines/index.html b/files/zh-cn/mozilla/projects/spidermonkey/comparision_of_js_engines/index.html
new file mode 100644
index 0000000000..934e38ad7a
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/comparision_of_js_engines/index.html
@@ -0,0 +1,105 @@
+---
+title: JS 引擎比较
+slug: Mozilla/Projects/SpiderMonkey/Comparision_of_JS_engines
+---
+<h2 id="概述">概述</h2>
+<p>本页用来纪录各个开源 JS 引擎(SpiderMonkey、V8、JavaScriptCore)在算法、未来趋势上的比较。除非额外说明,内存相关的数据<strong>假设系统为 32 位</strong>。</p>
+<h2 id="类、函数、词汇比较表">类、函数、词汇比较表</h2>
+<p>为了让懂得其中一个 JS 引擎的程序员迅速了解另外一个引擎,以下整理这些引擎共同概念的实现比较(把鼠标放在类/函数上面可以找到定义该类/函数的文件):</p>
+<h3 id="常见">常见</h3>
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">SpiderMonkey</th>
+ <th scope="col">V8</th>
+ <th scope="col">备注</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a href="http://hg.mozilla.org/mozilla-central/file/73eefb421e2a/js/public/Value.h#l872" title="public/Value.h:JS::Value"><code>Value</code></a></td>
+ <td><a href="http://code.google.com/p/v8/source/browse/branches/bleeding_edge/src/objects.h?r=19048#930" title="src/objects.h:v8::internal::MaybeObject *"><code style="white-space: nowrap;">MaybeObject *</code></a></td>
+ <td>代表一个 JS 值(数值、字符串、对象……)的类。SpiderMonkey 是用 <a href="http://wingolog.org/archives/2011/05/18/value-representation-in-javascript-implementations">nun-boxing</a>,总是一个 <code>double</code> 的大小(因此在 32 位的系统下,传值需要<a href="http://hg.mozilla.org/mozilla-central/file/73eefb421e2a/js/src/jit/RegisterSets.h#l88">两个 cycle</a>)。V8 是用 <a href="https://github.com/oupengsoftware/v8/wiki/Memory-Layout#wiki-tagged-pointer">tagged pointer</a>,总是一个指针的大小,浮点数存在堆上。<code>MaybeObject</code> 还是很多非 JS 语言对象(代码块等等)的<a href="http://sphinx.oupeng.com/wp-content/uploads/2013/07/v8-class-hierarchy.html">父类</a>。</td>
+ </tr>
+ <tr>
+ <td> <a href="http://hg.mozilla.org/mozilla-central/file/f550b112a19b/js/src/vm/ObjectImpl.h#l685" title="src/vm/ObjectImpl.h:js::ObjectImpl"><code>ObjectImpl</code></a></td>
+ <td><a href="http://code.google.com/p/v8/source/browse/branches/bleeding_edge/src/objects.h?r=19048#2089" title="src/objects.h:v8::internal::JSObject"><code>JSObject</code></a></td>
+ <td>JS 对象(<code>obj instanceof Object</code>)的实现类。SpiderMonkey 与 V8 皆是把部分属性存放在对象行内,部分用外链的一个数组储存的模式。SpiderMonkey 也将小数组的数据存在行内(但是<a href="http://hg.mozilla.org/mozilla-central/file/f550b112a19b/js/src/jsgc.h#l258">不会分两半</a>),而 V8 的 JS 数组对象(貌似)都是将数据存在外链的数组上。在 SpiderMonkey 中,只有在 new space 的 JS 对象的外链数组的空间由虚拟机分配,其他情况的外链数组的空间<a href="http://hg.mozilla.org/mozilla-central/file/f550b112a19b/js/src/gc/Nursery.cpp#l582">由 <code>malloc</code> 分配</a>(因此内存会比较分裂?)。<code>ObjectImpl</code> 除了有连接到 <code>Shape</code> 的指针之外,还有一个链到 <code>TypeObject</code> 的指针:16 B(<code>ObjectImpl</code>)vs. 12 B(<code>JSObject</code>)。在 SpiderMonkey 中,数据用 <code>Value</code> 存,也就是说,对于一个有 <em>k</em> 个行内属性的 JS 对象来说,内存占用是:16 B + <em>k</em> * 8 B(<code>ObjectImpl</code>)vs. 12 B + <em>k</em> * 4 B(<code>JSObject</code>),行外的情形 V8 则会再多用 8 B(<code>FixedArray</code> 的标头)。</td>
+ </tr>
+ <tr>
+ <td><span style="white-space: nowrap;"><a href="http://hg.mozilla.org/mozilla-central/file/f550b112a19b/js/src/vm/Shape.h#l37" title="src/vm/Shape.h:js::Shape"><code>Shape</code></a>、<code><a href="http://hg.mozilla.org/mozilla-central/file/f550b112a19b/js/src/jsinfer.h#l868" title="src/jsinfer.h:js::types::TypeObject">TypeObject</a>、</code><a href="http://hg.mozilla.org/mozilla-central/file/73eefb421e2a/js/public/Class.h#l590" title="public/Class.h::js::Class"><code>Class</code></a></span></td>
+ <td><a href="http://code.google.com/p/v8/source/browse/branches/bleeding_edge/src/objects.h?r=19048#5769" title="src/objects.h:v8::internal::Map"><code>Map</code></a></td>
+ <td>隐藏类的实现类。在 SpiderMonkey 中,属性名存在 <code>Shape</code> 上(因此带有 V8 的 <code>DescriptorArray</code> 的作用),JS 对象的原型存在 <code>TypeObject</code> 上,特殊属性的处理方法存在 <code>Class</code> 上(<code>Class</code> 对象不是 JS 堆里的对象,大部分都共用:<code>JSObject::class_</code>、<code>JSFunction::class_……</code>)。由于 V8 的 <code>Map</code> 有 SM 三个类的作用,因此占用内存也比较多:24 B(<code>Shape</code>)vs. 40 B(<code>Map</code>)。</td>
+ </tr>
+ </tbody>
+</table>
+<h3 id="内存布局与对象创建">内存布局与对象创建</h3>
+<h3 id="运行时">运行时</h3>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">SpiderMonkey</th>
+ <th scope="col">V8</th>
+ <th scope="col">备注</th>
+ </tr>
+ <tr>
+ <td><code>Interpret</code></td>
+ <td><code style="white-space: nowrap;">(无)</code></td>
+ <td>解释器的主回圈。V8 没有字节码与解释器。</td>
+ </tr>
+ </tbody>
+</table>
+<h3 id="堆与_GC">堆与 GC</h3>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">SpiderMonkey</th>
+ <th scope="col">V8</th>
+ <th scope="col">备注</th>
+ </tr>
+ <tr>
+ <td><code>Nursery</code></td>
+ <td><code style="white-space: nowrap;">NewSpace</code></td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="调优">调优</h2>
+<p>一个容易调优的 JS 引擎应该具备有以下条件(从重要的到不重要的):</p>
+<ul>
+ <li>能透过 profiler 够找到应用的热点函数(当前内联过的函数是怎么处理的?)。</li>
+ <li>调整各个常量方便。</li>
+ <li>能(透过内置函数扩展等等)得到以下影响性能的数据:
+ <ul>
+ <li>内联缓存(inline cache)中缓存的隐藏类个数。</li>
+ <li>函数运行状态(哪个阶段的 JIT?)与机械码。</li>
+ <li>一个 JS 函数已内联的函数。</li>
+ <li>一个 JS 函数调用运行时 C++ 函数的个数。</li>
+ <li>一段时间中 CPU 运行的指令个数与种类(SpiderMonkey 里有个 <code>PerfMeasurement</code>,这个好用么?)。</li>
+ </ul>
+ </li>
+ <li>能得到 bailout 的原因。</li>
+ <li>代码易读,容易调试。</li>
+</ul>
+<h2 id="参见">参见</h2>
+<ul>
+ <li><a href="http://arewefastyet.com/">ARE WE FAST YET</a> — 每天更新的 JS 引擎性能比较(使用 kraken、sunspider、octane 三个 benchmark)。</li>
+ <li><a href="http://openaphid.github.io/blog/2013/01/17/part-i-how-to-choose-a-javascript-engine-for-ios-and-android-apps/">How to Choose a JavaScript Engine for iOS and Android Development</a> — 不太具有技术分析的文章,不过有一个各类似 Phonegap 的产品用什么 JS 引擎的列表。</li>
+ <li><a href="http://hllvm.group.iteye.com/group/topic/37596">各JavaScript引擎的简介,及相关资料/博客收集帖</a> — R 大经典的整理帖,下面有一个比较高层级的各引擎比较表。</li>
+</ul>
+<p>跟 “JS 引擎” 比较无关,但是中文的 JS 引擎相关的博文也比较少,这里搜集一下:</p>
+<ul>
+ <li><a href="http://hellocompiler.com/">编译路慢慢</a> — SpiderMonkey 相关的比较多。</li>
+</ul>
+<h2 id="代码美观">代码美观</h2>
+<p><em>这件事实在</em><em>不应该是决定使用哪个 JS 引擎的因素,不过……</em></p>
+<p>如果(不幸的)需要以 SpiderMonkey 作为基础调优则会碰到以下问题:</p>
+<ol>
+ <li>C 与 C++ 代码混用。SpiderMonkey 原先是 C 写成的,后来大规模的以 C++ 改进,但是留下了很多残骸:宏、不是宏但是名称是大写的函数。(参见 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_Reference/JS::Value"><code>JS::Value</code></a> 的说明。)</li>
+ <li>成员变量、方法命名缺乏规则<code>。ObjectImpl::slots</code> 与 <code>ObjectImpl::shape_</code> 同时存在(前面那个应该加底线)。这个或许是可以修复的 bug。</li>
+ <li>混入 JavaScriptCore、V8 代码。SpiderMonkey 的组译器是 JavaScriptCore 的,那些类的成员变量是 <code>m_buffer</code> 等等,又增加了成员变量命名的。另外还有 <code>WTF_*</code> 宏,真是 WTF。再批。妈的,<a href="http://hg.mozilla.org/mozilla-central/file/262e73a6b7cd/js/src/assembler/wtf/Platform.h#l344"><code>WTF_CPU_ARM_THUMB2</code> 跟本不可能为真</a>,这里有大量的死代码(所有代码完全没有用到 <code>JSC::</code><code>MacroAssembler</code>,用到的是 <code>js::jit::</code><code><code>MacroAssembler</code></code>)。另外,</li>
+ <li>混乱的名称空间。</li>
+ <li><code>struct</code>、<code>class</code> 混用。</li>
+ <li>文档命名缺少规则。C 时代的档名是 <code>jsobj.h</code>,C++ 时代的档名是 <code>Value.h</code> 。请自重。</li>
+ <li>过渡滥用宏。</li>
+</ol>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/index.html b/files/zh-cn/mozilla/projects/spidermonkey/index.html
new file mode 100644
index 0000000000..468fafa0cb
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/index.html
@@ -0,0 +1,132 @@
+---
+title: SpiderMonkey
+slug: Mozilla/Projects/SpiderMonkey
+tags:
+ - SpiderMonkey
+ - Update
+translation_of: Mozilla/Projects/SpiderMonkey
+---
+<p><strong>SpiderMonkey</strong> 是Mozilla使用C/C++编写的<a href="/zh-cn/JavaScript" title="zh-cn/JavaScript">JavaScript</a> 引擎。它被用于包括Firefox在内的多个Mozilla产品中,使用的<span class="st">是MPL 2授权协议.</span></p>
+
+<p>独立的源代码版本可以在<a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Projects/SpiderMonkey/Releases">发布页</a>上找到</p>
+
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h3 id="Documentation" name="Documentation">文档</h3>
+
+ <table>
+ <tbody>
+ <tr>
+ <td colspan="2">
+ <h4 id="General">General</h4>
+ </td>
+ </tr>
+ <tr>
+ <td><a href="/zh-CN/docs/Mozilla/Projects/SpiderMonkey/Build_Documentation" title="zh-CN/docs/Mozilla/Projects/SpiderMonkey/Build_Documentation">SpiderMonkey Build Documentation</a></td>
+ <td>如何获取到SpiderMonkey源代码,编译,并运行测试套.</td>
+ </tr>
+ <tr>
+ <td><a href="/zh-cn/SpiderMonkey/Introduction_to_the_JavaScript_shell" title="zh-cn/Introduction_to_the_JavaScript_shell">Introduction to the JavaScript shell</a></td>
+ <td>如何获取,构建,并使用JavaScript shell.</td>
+ </tr>
+ <tr>
+ <td><a href="/zh-cn/SpiderMonkey/Running_Automated_JavaScript_Tests" title="zh-cn/SpiderMonkey/Running Automated JavaScript Tests">Running Automated JavaScript Tests</a></td>
+ <td>如何运行JavaScript测试套件.</td>
+ </tr>
+ <tr>
+ <td><a href="/zh-cn/SpiderMonkey/Creating_JavaScript_tests" title="zh-cn/SpiderMonkey/Creating JavaScript tests">Creating JavaScript tests</a></td>
+ <td>如何为JavaScript测试套件添加测试.</td>
+ </tr>
+ <tr>
+ <td><a class="link-https" href="https://wiki.mozilla.org/JavaScript:New_to_SpiderMonkey" title="https://wiki.mozilla.org/JavaScript:New_to_SpiderMonkey">New to SpiderMonkey</a></td>
+ <td>SpiderMonkey的hacking指南.</td>
+ </tr>
+ <tr>
+ <td><a href="/zh-cn/SpiderMonkey/Setting_up_CDT_to_work_on_SpiderMonkey" title="zh-cn/SpiderMonkey/Setting up CDT to work on SpiderMonkey">Setting up CDT to work on SpiderMonkey</a></td>
+ <td>如何配置CDT,使之在SpiderMonkey代码上工作.</td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <h4 id="JSAPI">JSAPI</h4>
+ </td>
+ </tr>
+ <tr>
+ <td><a href="/zh-cn/SpiderMonkey/JSAPI_User_Guide" title="zh-cn/JSAPI_User_Guide">JSAPI User Guide</a></td>
+ <td>本指南简要介绍了SpiderMonkey,还介绍了如何可以将SpiderMonkey嵌入到你的应用程序中.</td>
+ </tr>
+ <tr>
+ <td><a href="/zh-cn/SpiderMonkey/JSAPI_Cookbook" title="zh-cn/SpiderMonkey/JSAPI_Phrasebook">JSAPI Phrasebook</a></td>
+ <td>一些常用的JavaScript表达式和语句的JSAPI翻译.</td>
+ </tr>
+ <tr>
+ <td><a href="/zh-cn/SpiderMonkey/JSAPI_Reference" title="zh-cn/SpiderMonkey/JSAPI_Reference">JSAPI Reference</a></td>
+ <td>SpiderMonkey API 参考.</td>
+ </tr>
+ <tr>
+ <td><a href="/zh-cn/SpiderMonkey/Bytecodes" title="zh-cn/SpiderMonkey/Bytecodes">Bytecode Reference</a></td>
+ <td>SpiderMonkey 字节码参考.</td>
+ </tr>
+ <tr>
+ <td><a href="/zh-cn/SpiderMonkey/JS_Debugger_API_Guide" title="zh-cn/SpiderMonkey/JS Debugger API Guide">JS Debugger API Guide</a></td>
+ <td>在Gecko 8.0中引入的新的JavaScript调试器API{{ geckoRelease("8.0") }}.</td>
+ </tr>
+ <tr>
+ <td><a href="/zh-cn/SpiderMonkey/JS_Debugger_API_Reference" title="zh-cn/SpiderMonkey/JS Debugger API Reference">JS Debugger API Reference</a></td>
+ <td>SpiderMonkey 1.8.6(Gecko 8.0 )中引入的<code>Debugger</code>对象的API参考, {{ geckoRelease("8.0") }}.</td>
+ </tr>
+ <tr>
+ <td><a href="/zh-cn/JSDBGAPI_Reference" title="zh-cn/JSDBGAPI_Reference">JSDBGAPI Reference</a></td>
+ <td>
+ <p>SpiderMonkey调试API参考;SpiderMonkey 1.8.5之前版本的调试API,<small> </small>虽然它并没有被删除.</p>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <h4 id="提示技巧和理念">提示,技巧和理念</h4>
+ </td>
+ </tr>
+ <tr>
+ <td><a href="/zh-cn/How_to_embed_the_JavaScript_engine" title="zh-cn/How_to_embed_the_JavaScript_engine">How to embed the JavaScript engine</a></td>
+ <td>如何嵌入SpiderMonkey的基础教程</td>
+ </tr>
+ <tr>
+ <td><a href="/zh-cn/SpiderMonkey_Garbage_Collection_Tips" title="zh-cn/SpiderMonkey_Garbage_Collection_Tips">SpiderMonkey Garbage Collection Tips</a></td>
+ <td>如何避免垃圾回收时出现的问题.</td>
+ </tr>
+ <tr>
+ <td><a href="/zh-cn/SpiderMonkey/Internals" title="zh-cn/SpiderMonkey_Internals">SpiderMonkey Internals</a></td>
+ <td><span class="short_text" id="result_box" lang="zh-CN"><span>设计</span><span>概况</span></span>和实现版本介绍</td>
+ </tr>
+ <tr>
+ <td><a href="/zh-cn/SpiderMonkey/Internals/Garbage_collection" title="zh-cn/SpiderMonkey/Internals/GC">SpiderMonkey Internals: GC</a></td>
+ <td>关于垃圾回收的独立的内部文章.</td>
+ </tr>
+ <tr>
+ <td><a href="/zh-cn/SpiderMonkey/Internals/Thread_Safety" title="zh-cn/SpiderMonkey_Internals/Thread_Safety">SpiderMonkey Internals: Thread Safety</a></td>
+ <td>SpiderMonkey的请求模型的内部工作原理.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td>
+ <h3 id="Related_Topics" name="Related_Topics">相关链接</h3>
+
+ <ul>
+ <li><a href="/zh-cn/JavaScript" title="zh-cn/JavaScript">JavaScript</a></li>
+ <li><a href="/zh-cn/SpiderMonkey/FOSS" title="zh-cn/SpiderMonkey/FOSS">FOSS projects using / based on Spidermonkey</a></li>
+ </ul>
+
+
+ <h3 id="Community" name="Community">社区</h3>
+
+ <p>有问题? <a class="link-irc" href="irc://irc.mozilla.org/jsapi">在IRC上提问!</a></p>
+
+ <p>查看 <a class="external" href="http://infomonkey.cdleary.com/" title="http://infomonkey.cdleary.com/">Infomonkey</a>.</p>
+
+ <p>有bug? <a class="link-https" href="https://bugzilla.mozilla.org/enter_bug.cgi?product=Core&amp;component=JavaScript%20Engine" title="https://bugzilla.mozilla.org/enter_bug.cgi?product=Core&amp;component=JavaScript Engine">提交bug</a> 到 <a class="link-https" href="https://bugzilla.mozilla.org/buglist.cgi?product=Core&amp;component=JavaScript%20Engine&amp;resolution=---&amp;list_id=92318" title="https://bugzilla.mozilla.org/buglist.cgi?product=Core&amp;component=JavaScript Engine&amp;resolution=---&amp;list_id=92318">Core -&gt; JavaScript Engine</a></p>
+ </td>
+ </tr>
+ </tbody>
+</table>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/internals/bytecodes/index.html b/files/zh-cn/mozilla/projects/spidermonkey/internals/bytecodes/index.html
new file mode 100644
index 0000000000..7c47ffb7ae
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/internals/bytecodes/index.html
@@ -0,0 +1,30 @@
+---
+title: 字节码
+slug: Mozilla/Projects/SpiderMonkey/Internals/Bytecodes
+tags:
+ - SpiderMonkey
+translation_of: Mozilla/Projects/SpiderMonkey/Internals/Bytecodes
+---
+<div>{{SpiderMonkeySidebar("Internals")}}</div>
+
+<h2 id="背景知识">背景知识</h2>
+
+<p>SpiderMonkey字节码是JavaScript引擎使用的标准代码表示形式。JavaScript前端根据源文本构建AST,然后根据JSScript数据结构的一部分从AST生成基于堆栈的字节码。字节码可以引用原子和对象(通常通过数组索引),这些原子和对象也包含在JSScript数据结构中。</p>
+
+<p>在引擎内,所有字节码都在堆栈帧内执行。堆栈帧与全局(顶级)代码和<code>eval</code>代码相关联。堆栈上的框架为几个不同类别的JavaScript值(标记值格式)留出空间。单个JavaScript值空间称为“插槽”,类别为:</p>
+
+<ul>
+ <li>参数槽:保存传递给当前框架的实际参数。</li>
+ <li>本地插槽:保存当前代码中使用的本地变量。</li>
+ <li>表达式槽:保存在堆栈上计算表达式所需的临时空间。例如,<code>(a + b) + c</code>会压入a,然后压入b,再压入+,然后压入c,再压入+,依此类推。这需要最多两个表达槽的深度。</li>
+</ul>
+
+<p>还有一些保留给专用功能的插槽,用于处理<code>this</code>和<code>callee</code>返回值。.</p>
+
+<p>总有一个“堆栈顶部”(TOS),它对应于推入表达式堆栈的最新值。所有字节码都根据该位置隐式运行。</p>
+
+<h2 id="字节码列表">字节码列表</h2>
+
+<p>所有操作码都用<code> [-popcount, +pushcount] </code>标注,以表示整个执行的堆栈效果。</p>
+
+<p>字节码列表已移至 <a href="/en-US/docs/Mozilla/Projects/SpiderMonkey/Internals/Bytecode" title="SpiderMonkey Internals: Bytecode Descriptions">SpiderMonkey Internals: Bytecode Descriptions</a> 页面。</p>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/internals/functions/index.html b/files/zh-cn/mozilla/projects/spidermonkey/internals/functions/index.html
new file mode 100644
index 0000000000..91d96b22eb
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/internals/functions/index.html
@@ -0,0 +1,73 @@
+---
+title: Functions
+slug: Mozilla/Projects/SpiderMonkey/Internals/Functions
+translation_of: Mozilla/Projects/SpiderMonkey/Internals/Functions
+---
+<div>{{SpiderMonkeySidebar("Internals")}}</div>
+
+<p>There are several flavors of JavaScript function. All are <code>JSObject</code>s of the same class, <code>js_FunctionClass</code>.</p>
+
+<p>这里有些Javscript函数,它们属于JSObjects</p>
+
+<p>(But note that objects of other classes can be callable and can even have <code>typeof obj == "function"</code>.)</p>
+
+<p>(也存在其他可被Call的对象)</p>
+
+<h2 id="Script_functions">Script functions</h2>
+
+<p>Functions written in JavaScript and compiled to bytecode. There are four variations that affect how NameExpressions are evaluated. (NameExpressions are basic expressions like <code>String</code> and <code>x</code> that would eat up a huge amount of run time if the engine weren't smart enough to avoid symbol table lookups.)</p>
+
+<p><strong>General closures</strong> are the base case. When the function object is created, its parent is set to the first object on the scope chain. When a name is evaluated that doesn't refer to a local variable, the interpreter consults the scope chain to find the variable. When <code>with</code> or <code>eval</code> are used, we have to do this for correctness.</p>
+
+<p>This is slow, not only because walking the scope chain is a drag, but also because we'd rather avoid actually creating the scope chain at all, if possible. General closures force the interpreter to verify the whole scope chain. So we optimize this when we can.</p>
+
+<p>These optimizations depend on being <em>sure</em> that we will never have to walk the scope chain, so <code>with</code> and <code>eval</code> inhibit them all.</p>
+
+<p><strong>Null closures.</strong> If we can prove at compile time that a function does not refer to any locals or arguments of enclosing functions, it is a null closure. Since it will never need to walk the scope chain, its parent is the global object. This is the best case. Barring <code>with</code> and <code>eval</code>, all outermost functions are null closures.</p>
+
+<p><strong>Null closures with upvars.</strong> A nested function is <em>algol-like</em> if it is only ever defined and called, and it isn't accessed in any other way (and it is not a generator-function). Such a function is guaranteed never to be called again after the enclosing function exits. An algol-like function may read the local variables and arguments of its immediate enclosing function from the stack, as if by magic. (<code>JSContext::display</code> caches the enclosing function's stack frame.) If that function is also algol-like, its child can read locals and variables from the next enclosing function, and so on. The compiler detects these cases and makes such functions null closures too.</p>
+
+<p><strong>Flat closures.</strong> Suppose a function reads some variables from enclosing functions but is not algol-like. If the function does not assign to any closed-on vars/args, and it only reads closed-on local variables and arguments that never change value after the function is created, then the function can be implemented as a flat closure. When a flat closure is created, all the closed-on values are copied from the stack into reserved slots of the function object. To evaluate a name, instead of walking the scope chain, we just take the value from the reserved slot. The function object's parent is the global object.</p>
+
+<p><strong>Flat closures </strong><strong>and Null closures have been <span id="summary_alias_container"><span id="short_desc_nonedit_display">removed</span></span></strong>:</p>
+
+<p><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=730497">https://bugzilla.mozilla.org/show_bug.cgi?id=730497</a></p>
+
+<p><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=739808">https://bugzilla.mozilla.org/show_bug.cgi?id=739808</a></p>
+
+<h2 id="Name_lookups">Name lookups</h2>
+
+<p>In order of speed, fastest to slowest.</p>
+
+<ol>
+ <li>
+ <p><code><strong>ARG</strong></code><strong> and <code>LOCAL</code> instructions.</strong> If a name definitely refers to an argument or local variable of the immediately enclosing function, it can be accessed using <code>JSOP_{GET,SET,CALL}</code><code>{ARG,LOCAL}</code> instructions. Some of these can even be fused with other operations into combo instructions like <code>JSOP_GETARGPROP</code>, <code>JSOP_FORLOCAL</code>, and <code>JSOP_INCLOCAL</code>. Because arguments and locals can't be deleted, this optimization is available to all functions, and <code>eval</code> does not interfere with it. But a <code>with</code> block can:</p>
+
+ <pre>function f(s) {
+ eval(s);
+ print(s); // s can be loaded with GETARG
+ with (obj) {
+ print(s); // no GETARG here; s might refer to obj.s
+ }
+}
+</pre>
+ </li>
+ <li>
+ <p><code><strong>UPVAR</strong></code><strong> instructions.</strong> JSOP_{GET,CALL}UPVAR (in algol-like functions only, I think?) TODO</p>
+ </li>
+ <li>
+ <p><code><strong>DSLOT</strong></code><strong> instructions.</strong> JSOP_{GET,CALL}DSLOT (in flat closures only) TODO</p>
+ </li>
+ <li>
+ <p><code><strong>GVAR</strong></code><strong> instructions.</strong> Outside all functions, if a name definitely refers to a global for which we have seen a var, <code>const</code>, or <code>function</code> declaration, then we emit a JS_DEFVAR instruction in the script prelude and access the global using <code>JSOP_{GET,SET,CALL}GVAR</code>. This is fast if the global either doesn't exist before the script runs (the script creates it) or it's a non-configurable data property (which amounts to the same thing). Otherwise the <code>GVAR</code> instructions are as slow as <code>NAME</code> instructions.</p>
+
+ <p>There are also combo instructions <code>JSOP_{INC,DEC}GVAR</code> and <code>JSOP_GVAR{INC,DEC}</code>.</p>
+ </li>
+ <li>
+ <p><code><strong>NAME</strong></code><strong> instructions.</strong> In the worst case we emit <code>JSOP_{,SET,CALL}NAME</code>. These are totally general. They can still be optimized via the property cache; in the worst case we walk the scope chain.</p>
+
+ <p>In some cases, the JIT can optimize a <code>JSOP_NAME</code> instruction that refers to a variable in an enclosing scope to pull the value directly out of the <code>Call</code> object's <code>dslots</code>.</p>
+
+ <p>For the expression <code>delete name</code> we always emit <code>JSOP_DELNAME</code>. It's not worth optimizing.</p>
+ </li>
+</ol>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/internals/index.html b/files/zh-cn/mozilla/projects/spidermonkey/internals/index.html
new file mode 100644
index 0000000000..03228c312f
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/internals/index.html
@@ -0,0 +1,292 @@
+---
+title: SpiderMonkey Internals
+slug: Mozilla/Projects/SpiderMonkey/Internals
+tags:
+ - Guide
+ - JavaScript
+ - NeedsMarkupWork
+ - NeedsTranslation
+ - SpiderMonkey
+ - TopicStub
+translation_of: Mozilla/Projects/SpiderMonkey/Internals
+---
+<h2 id="Design_walk-through" name="Design_walk-through">Design walk-through</h2>
+
+<p>At heart, SpiderMonkey is a fast interpreter that runs an untyped bytecode and operates on values of type <code><a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/Jsval" title="SpiderMonkey/JSAPI_Reference/Jsval">jsval</a></code>—type-tagged double-sized values that represent the full range of JavaScript values. In addition to the interpreter, SpiderMonkey contains a Just-In-Time (JIT) compiler, a garbage collector, code implementing the basic behavior of JavaScript values, a standard library implementing <span class="pl-s1"><span class="pl-s">ECMA 262-3 §</span></span>15 with various extensions, and a few public APIs.</p>
+
+<h3 id="Interpreter">Interpreter</h3>
+
+<p>Like many portable interpreters, SpiderMonkey's interpreter is mainly a single, tremendously long function that steps through the bytecode one instruction at a time, using a <code>switch</code> statement (or faster alternative, depending on the compiler) to jump to the appropriate chunk of code for the current instruction. A JS-to-JS function call pushes a JavaScript stack frame without growing the C stack. But since JS-to-C-to-JS call stacks are common, the interpreter is reentrant.</p>
+
+<p>Some SpiderMonkey bytecode operations have many special cases, depending on the type of their arguments. Common cases are inlined in the interpreter loop, breaking any abstractions that stand in the way. So optimizations such as dense arrays and the property cache are, alas, <em>not</em> transparently tucked away in the <code>jsarray.*</code> and <code>jsobj.*</code> files. Both guest-star in <code>jsinterp.cpp</code> (to thunderous applause from Firefox users).</p>
+
+<p>All state associated with an interpreter instance is passed through formal parameters to the interpreter entry point; most implicit state is collected in a type named <code><a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JSRuntime" title="SpiderMonkey/JSAPI_Reference/JSRuntime">JSContext</a></code>. Therefore, almost all functions in SpiderMonkey, API or not, take a <code>JSContext</code> pointer as their first argument.</p>
+
+<h3 id="Compiler">Compiler</h3>
+
+<p>The compiler consumes JavaScript source code and produces a <em>script</em> which contains bytecode, source annotations, and a pool of string, number, and identifier literals. The script also contains objects, including any functions defined in the source code, each of which has its own, nested script.</p>
+
+<p>The compiler consists of: a random-logic rather than table-driven lexical scanner, a recursive-descent parser that produces an AST, and a tree-walking code generator. Semantic and lexical feedback are used to disambiguate hard cases such as missing semicolons, assignable expressions ("lvalues" in C parlance), and whether <code>/</code> is the division symbol or the start of a regular expression. The compiler attempts no error recovery; it bails out on the first error. The emitter does some constant folding and a few codegen optimizations; about the fanciest thing it does is to attach source notes to the script for the decompiler's benefit.</p>
+
+<p>The decompiler implements <code>Function.toSource()</code>, which reconstructs a function's source code. It translates postfix bytecode into infix source by consulting a separate byte-sized code, called <em>source notes</em>, to disambiguate bytecodes that result from more than one grammatical production.</p>
+
+<h3 id="Garbage_collector">Garbage collector</h3>
+
+<p>The GC is a mark-and-sweep, non-conservative (exact) collector. It is used to hold JS objects and string descriptors (but not property lists or string bytes), and double-precision floating point numbers. It runs automatically only when maxbytes (as passed to <code><a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_NewRuntime" title="SpiderMonkey/JSAPI_Reference/JS_NewRuntime">JS_NewRuntime</a></code>) bytes of GC things have been allocated and another thing-allocation request is made. JS API users should call <code><a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_GC" title="SpiderMonkey/JSAPI_Reference/JS_GC">JS_GC</a></code> or <code><a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_MaybeGC" title="SpiderMonkey/JSAPI_Reference/JS_MaybeGC">JS_MaybeGC</a></code> between script executions or from the <a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_SetBranchCallback" title="SpiderMonkey/JSAPI_Reference/JS_SetBranchCallback">branch callback</a>, as often as necessary.</p>
+
+<p>Because the GC is exact, C/C++ applications must ensure that all live objects, strings, and numbers are GC-reachable. Many techniques are available; see <a href="/en-US/docs/SpiderMonkey_Garbage_Collection_Tips" title="SpiderMonkey_Garbage_Collection_Tips">SpiderMonkey Garbage Collection Tips</a>.</p>
+
+<h3 id="JavaScript_values">JavaScript values</h3>
+
+<p>The type <code><a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/Jsval" title="SpiderMonkey/JSAPI_Reference/Jsval">jsval</a></code> represents a JavaScript value.</p>
+
+<p>The representation is 64 bits and uses NaN-boxing on all platforms, although the exact NaN-boxing format depends on the platform. NaN-boxing is a technique based on the fact that in IEEE-754 there are 2**47 different bit patterns that all represent NaN. Hence, we can encode any floating-point value as a C++ <code>double </code>(noting that JavaScript NaN must be represented as one canonical NaN format). Other values are encoded as a value and a type tag:</p>
+
+<ul>
+ <li>On x86, ARM, and similar 32-bit platforms, we use what we call "nunboxing", in which non-<code>double </code>values are a 32-bit type tag and a 32-bit payload, which is normally either a pointer or a signed 32-bit integer. There are a few special values: <code><a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JSVAL_NULL" title="SpiderMonkey/JSAPI_Reference/JSVAL_NULL">JSVAL_NULL</a></code>, <code><a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JSVAL_VOID" title="SpiderMonkey/JSAPI_Reference/JSVAL_VOID">JSVAL_VOID</a></code> (<code>undefined</code>), <code><a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JSVAL_TRUE" title="SpiderMonkey/JSAPI_Reference/JSVAL_TRUE">JSVAL_TRUE</a></code>, and <code><a href="/en-US/docs/JSVAL_FALSE" title="JSVAL_FALSE">JSVAL_FALSE</a></code>. Another special value, <code><a href="/en-US/docs/JSVAL_HOLE" title="JSVAL_HOLE">JSVAL_HOLE</a></code>, is used internally only (to represent deleted <code>Array</code> elements, for example). This value is never exposed to scripts or even via the JSAPI.</li>
+ <li>On x64 and similar 64-bit platforms, pointers are longer than 32 bits, so we can't use the nunboxing format. Instead, we use "punboxing", which has 17 bits of tag and 47 bits of payload.</li>
+</ul>
+
+<p>Only JIT code really depends on the layout--everything else in the engine interacts with values through functions like <code>JSVAL_IS_INT</code>. Most parts of the JIT also avoid depending directly on the layout: the files <code>PunboxAssembler.h</code> and <code>NunboxAssembler.h</code> are used to generate native code that depends on the value layout.</p>
+
+<p>Objects consist of a possibly shared structural description, called the map or scope; and unshared property values in a vector, called the slots. Each property has an <a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/jsid" title="SpiderMonkey/JSAPI_Reference/jsid">id</a>, either a nonnegative integer or an atom (unique string), with the same tagged-pointer encoding as a <code>jsval</code>.</p>
+
+<p>The atom manager consists of a hash table associating strings uniquely with scanner/parser information such as keyword type, index in script or function literal pool, etc. Atoms play three roles: as literals referred to by unaligned 16-bit immediate bytecode operands, as unique string descriptors for efficient property name hashing, and as members of the root GC set for exact GC.</p>
+
+<h3 id="Standard_library">Standard library</h3>
+
+<p>The methods for arrays, booleans, dates, functions, numbers, and strings are implemented using the JS API. Most are <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSNative" title="SpiderMonkey/JSAPI_Reference/JSFastNative">JSNative</a></code>s. Most string methods are customized to accept a primitive string as the <code>this</code> argument. (Otherwise, SpiderMonkey converts primitive values to objects before invoking their methods, per <span class="pl-s1"><span class="pl-s">ECMA 262-3 §</span></span>11.2.1.)</p>
+
+<h3 id="Error_handling">Error handling</h3>
+
+<p>SpiderMonkey has two interdependent error-handling systems: JavaScript exceptions (which are <em>not</em> implemented with, or even compatible with, any kind of native C/C++ exception handling) and error reporting. In general, both functions inside SpiderMonkey and JSAPI callback functions signal errors by calling <code><a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_ReportError" title="SpiderMonkey/JSAPI_Reference/JS_ReportError">JS_ReportError</a></code> or one of its variants, or <code><a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_SetPendingException" title="SpiderMonkey/JSAPI_Reference/JS_SetPendingException">JS_SetPendingException</a></code>, and returning <code><a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/JSBool" title="SpiderMonkey/JSAPI_Reference/JSBool">JS_FALSE</a></code> or <code>NULL</code>.</p>
+
+<h3 id="Public_APIs">Public APIs</h3>
+
+<p>The public C/C++ interface, called the JSAPI, is in most places a thin (but source-compatible across versions) layer over the implementation. See the <a href="/en-US/docs/SpiderMonkey/JSAPI_User_Guide" title="JSAPI_User_Guide">JSAPI User Guide</a>. There is an additional public API for JavaScript debuggers, <a href="/en-US/docs/JSDBGAPI_Reference" title="JSDBGAPI_Reference">JSDBGAPI</a>, but {{Source("js/jsd/jsdebug.h")}} might be a better API for debuggers. Another API, <a href="/en-US/docs/JSXDRAPI" title="JSXDRAPI">JSXDRAPI</a>, provides serialization for JavaScript scripts. (XUL Fastload uses this.)</p>
+
+<h3 id="Just-In-Time_compiler">Just-In-Time compiler</h3>
+
+<p>{{jsapi_minversion_inline("1.8.5")}} SpiderMonkey contains a just-in-time compiler, code-named <em>JägerMonkey</em>, that converts bytecode to machine code for faster execution. The JIT works by detecting commonly executed functions or functions containing hot loops and then compiling these methods into machine code.</p>
+
+<p>A second JIT, code-named <em>IonMonkey</em> was enabled in <a href="https://blog.mozilla.org/javascript/2012/09/12/ionmonkey-in-firefox-18/" title="https://blog.mozilla.org/javascript/2012/09/12/ionmonkey-in-firefox-18/">Firefox 18</a>.</p>
+
+<h3 id="Self-hosting_of_builtin_functions_in_JS">Self-hosting of builtin functions in JS</h3>
+
+<p>Starting with Firefox 17, SpiderMonkey has the ability to implement builtin functions in self-hosted JS code. This code is compiled in a special compilation mode that gives it access to functionality that's not normally exposed to JS code, but that's required for safe and specification-conformant implementation of builtin functions.</p>
+
+<p>All self-hosted code lives in <code>.js</code> files under <code>builtin/</code>. For details on implementing self-hosted builtins, see <a href="/en-US/docs/SpiderMonkey/Internals/self-hosting" title="SpiderMonkey/self-hosting">self-hosting</a>.</p>
+
+<h2 id="File_walkthrough" name="File_walkthrough">File walkthrough</h2>
+
+<h4 id="jsapi.cpp.2C_jsapi.h" name="jsapi.cpp.2C_jsapi.h">jsapi.cpp, jsapi.h</h4>
+
+<p>The public API to be used by almost all client code.</p>
+
+<h4 id="jspubtd.h.2C_jsprvtd.h" name="jspubtd.h.2C_jsprvtd.h">jspubtd.h, jsprvtd.h</h4>
+
+<p>These files exist to group struct and scalar typedefs so they can be used everywhere without dragging in struct definitions from N different files. The <code>jspubtd.h</code> file contains public typedefs, and is included automatically when needed. The <code>jsprvtd.h</code> file contains private typedefs and is included by various .h files that need type names, but not type sizes or declarations.</p>
+
+<h4 id="jsdbgapi.cpp.2C_jsdbgapi.h" name="jsdbgapi.cpp.2C_jsdbgapi.h">jsdbgapi.cpp, jsdbgapi.h</h4>
+
+<p>The debugging API. Provided so far:</p>
+
+<p><strong>Traps</strong>, with which breakpoints, single-stepping, step over, step out, and so on can be implemented. The debugger will have to consult jsopcode.def on its own to figure out where to plant trap instructions to implement functions like step out, but a future jsdbgapi.h will provide convenience interfaces to do these things. At most one trap per bytecode can be set. When a script (<code><a href="/en-US/docs/JSScript" title="JSScript">JSScript</a></code>) is destroyed, all traps set in its bytecode are cleared.</p>
+
+<p><strong>Watchpoints</strong>, for intercepting set operations on properties and running a debugger-supplied function that receives the old value and a pointer to the new one, which it can use to modify the new value being set.</p>
+
+<p><strong>Line number</strong> to PC and back mapping functions. The line-to-PC direction "rounds" toward the next bytecode generated from a line greater than or equal to the input line, and may return the PC of a for-loop update part, if given the line number of the loop body's closing brace. Any line after the last one in a script or function maps to a PC one byte beyond the last bytecode in the script. An example, from perfect.js:</p>
+
+<pre class="brush:js;first-line:14">function perfect(n) {
+ print("The perfect numbers up to " + n + " are:");
+ // We build sumOfDivisors[i] to hold a string expression for
+ // the sum of the divisors of i, excluding i itself.
+ var sumOfDivisors = new ExprArray(n+1,1);
+ for (var divisor = 2; divisor &lt;= n; divisor++) {
+ for (var j = divisor + divisor; j &lt;= n; j += divisor) {
+ sumOfDivisors[j] += " + " + divisor;
+ }
+ // At this point everything up to 'divisor' has its sumOfDivisors
+ // expression calculated, so we can determine whether it's perfect
+ // already by evaluating.
+ if (eval(sumOfDivisors[divisor]) == divisor) {
+ print("" + divisor + " = " + sumOfDivisors[divisor]);
+ }
+ }
+ delete sumOfDivisors;
+ print("That's all.");
+}</pre>
+
+<p>The line number to PC and back mappings can be tested using the js program with the following script:</p>
+
+<pre class="brush:js">load("perfect.js");
+print(perfect);
+dis(perfect);
+print();
+for (var ln = 0; ln &lt;= 40; ln++) {
+ var pc = line2pc(perfect, ln);
+ var ln2 = pc2line(perfect, pc);
+ print("\tline " + ln + " =&gt; pc " + pc + " =&gt; line " + ln2);
+}
+</pre>
+
+<p>The result of the for loop over lines 0 to 40 inclusive is:</p>
+
+<pre>line 0 =&gt; pc 0 =&gt; line 16
+line 1 =&gt; pc 0 =&gt; line 16
+line 2 =&gt; pc 0 =&gt; line 16
+line 3 =&gt; pc 0 =&gt; line 16
+line 4 =&gt; pc 0 =&gt; line 16
+line 5 =&gt; pc 0 =&gt; line 16
+line 6 =&gt; pc 0 =&gt; line 16
+line 7 =&gt; pc 0 =&gt; line 16
+line 8 =&gt; pc 0 =&gt; line 16
+line 9 =&gt; pc 0 =&gt; line 16
+line 10 =&gt; pc 0 =&gt; line 16
+line 11 =&gt; pc 0 =&gt; line 16
+line 12 =&gt; pc 0 =&gt; line 16
+line 13 =&gt; pc 0 =&gt; line 16
+line 14 =&gt; pc 0 =&gt; line 16
+line 15 =&gt; pc 0 =&gt; line 16
+line 16 =&gt; pc 0 =&gt; line 16
+line 17 =&gt; pc 19 =&gt; line 20
+line 18 =&gt; pc 19 =&gt; line 20
+line 19 =&gt; pc 19 =&gt; line 20
+line 20 =&gt; pc 19 =&gt; line 20
+line 21 =&gt; pc 36 =&gt; line 21
+line 22 =&gt; pc 53 =&gt; line 22
+line 23 =&gt; pc 74 =&gt; line 23
+line 24 =&gt; pc 92 =&gt; line 22
+line 25 =&gt; pc 106 =&gt; line 28
+line 26 =&gt; pc 106 =&gt; line 28
+line 27 =&gt; pc 106 =&gt; line 28
+line 28 =&gt; pc 106 =&gt; line 28
+line 29 =&gt; pc 127 =&gt; line 29
+line 30 =&gt; pc 154 =&gt; line 21
+line 31 =&gt; pc 154 =&gt; line 21
+line 32 =&gt; pc 161 =&gt; line 32
+line 33 =&gt; pc 172 =&gt; line 33
+line 34 =&gt; pc 172 =&gt; line 33
+line 35 =&gt; pc 172 =&gt; line 33
+line 36 =&gt; pc 172 =&gt; line 33
+line 37 =&gt; pc 172 =&gt; line 33
+line 38 =&gt; pc 172 =&gt; line 33
+line 39 =&gt; pc 172 =&gt; line 33
+line 40 =&gt; pc 172 =&gt; line 33
+</pre>
+
+<h4 id="jsconfig.h" name="jsconfig.h">jsconfig.h</h4>
+
+<p>Various configuration macros defined as 0 or 1 depending on how <code><a href="/en-US/docs/JS_VERSION" title="JS_VERSION">JS_VERSION</a></code> is defined (as 10 for JavaScript 1.0, 11 for JavaScript 1.1, etc.). Not all macros are tested around related code yet. In particular, JS 1.0 support is missing from SpiderMonkey.</p>
+
+<h4 id="js.cpp.2C_jsshell.msg" name="js.cpp.2C_jsshell.msg">js.cpp, jsshell.msg</h4>
+
+<p>The "JS shell", a simple interpreter program that uses the JS API and more than a few internal interfaces (some of these internal interfaces could be replaced by <code>jsapi.h</code> calls). The js program built from this source provides a test vehicle for evaluating scripts and calling functions, trying out new debugger primitives, etc.</p>
+
+<p>A look at the places where <code>jsshell.msg</code> is used in <code>js.cpp</code> shows how error messages can be handled in JSAPI applications. These messages can be localized at compile time by replacing the <code>.msg</code> file; or, with a little modification to the source, at run time.</p>
+
+<p><a href="/en-US/docs/SpiderMonkey/Introduction_to_the_JavaScript_shell" title="https://developer.mozilla.org/en/introduction_to_the_javascript_shell">More information on the JavaScript shell</a>.</p>
+
+<h4 id="js.msg" name="js.msg">js.msg</h4>
+
+<p>SpiderMonkey error messages.</p>
+
+<h4 id="jsarray..2A.2C_jsbool..2A.2C_jdsdate..2A.2C_jsfun..2A.2C_jsmath..2A.2C_jsnum..2A.2C_jsstr..2A" name="jsarray..2A.2C_jsbool..2A.2C_jdsdate..2A.2C_jsfun..2A.2C_jsmath..2A.2C_jsnum..2A.2C_jsstr..2A">jsarray.*, jsbool.*, jsdate.*, jsfun.*, jsmath.*, jsnum.*, jsstr.*</h4>
+
+<p>These file pairs implement the standard classes and (where they exist) their underlying primitive types. They have similar structure, generally starting with class definitions and continuing with internal constructors, finalizers, and helper functions.</p>
+
+<h4 id="jsobj..2A.2C_jsscope..2A" name="jsobj..2A.2C_jsscope..2A">jsobj.*, jsscope.*</h4>
+
+<p>These two pairs declare and implement the JS object system. All of the following happen here:</p>
+
+<ul>
+ <li>creating objects by class and prototype, and finalizing objects;</li>
+ <li>defining, looking up, getting, setting, and deleting properties;</li>
+ <li>creating and destroying properties and binding names to them.</li>
+</ul>
+
+<p>The details of a native object's map (scope) are mostly hidden in <code>jsscope.{{mediawiki.external('ch')}}</code>.</p>
+
+<h4 id="jsatom.cpp.2C_jsatom.h" name="jsatom.cpp.2C_jsatom.h">jsatom.cpp, jsatom.h</h4>
+
+<p>The atom manager. Contains well-known string constants, their atoms, the global atom hash table and related state, the js_Atomize() function that turns a counted string of bytes into an atom, and literal pool (<code>JSAtomMap</code>) methods.</p>
+
+<h4 id="jsarena.cpp.2C_jsarena.h" name="jsarena.cpp.2C_jsarena.h">jsarena.cpp, jsarena.h</h4>
+
+<p>Last-In-First-Out allocation macros that amortize malloc costs and allow for en-masse freeing. See the paper mentioned in <code>jsarena.h</code>'s major comment.</p>
+
+<h4 id="jsgc.cpp.2C_jsgc.h" name="jsgc.cpp.2C_jsgc.h">jsgc.cpp, jsgc.h</h4>
+
+<p>The garbage collector and tracing routines.</p>
+
+<h4 id="jsinterp..2A.2C_jscntxt..2A.2C_jsinvoke.cpp" name="jsinterp..2A.2C_jscntxt..2A.2C_jsinvoke.cpp">jsinterp.*, jscntxt.*, jsinvoke.cpp</h4>
+
+<p>The bytecode interpreter, and related functions such as Call and AllocStack, live in <em>jsinterp.cpp</em>. The JSContext constructor and destructor are factored out into <em>jscntxt.cpp</em> for minimal linking when the compiler part of JS is split from the interpreter part into a separate program.</p>
+
+<p><code>jsinvoke.cpp</code> is a build hack used on some platforms to build <code>js_Interpret</code> under different compiler options from the rest of <code>jsinterp.cpp</code>.</p>
+
+<h4 id="jstracer.*_nanojit*">jstracer.*, nanojit/*</h4>
+
+<p><a href="/en-US/docs/SpiderMonkey/Internals/Tracing_JIT" title="SpiderMonkey/Internals/Tracing JIT">The tracing JIT</a>. The interface between the JIT and the rest of SpiderMonkey is conceptually small—the interpreter calls into the trace recorder—but as with everything else, there are tendrils everywhere.</p>
+
+<h4 id="jsemit..2A.2C_jsopcode.tbl.2C_jsopcode..2A.2C_jsparse..2A.2C_jsscan..2A.2C_jsscript..2A" name="jsemit..2A.2C_jsopcode.tbl.2C_jsopcode..2A.2C_jsparse..2A.2C_jsscan..2A.2C_jsscript..2A">jsemit.*, jsopcode.tbl, jsopcode.*, jsparse.*, jsscan.*, jsscript.*</h4>
+
+<p>Compiler and decompiler modules. The <em>jsopcode.tbl</em> file is a C preprocessor source that defines almost everything there is to know about JS bytecodes. See its major comment for how to use it. For now, a debugger will use it and its dependents such as <em>jsopcode.h</em> directly, but over time we intend to extend <em>jsdbgapi.h</em> to hide uninteresting details and provide conveniences. The code generator is split across paragraphs of code in <em>jsparse.cpp</em>, and the utility methods called on <code>JSCodeGenerator</code> appear in <em>jsemit.cpp</em>. Source notes generated by <em>jsparse.cpp</em> and <em>jsemit.cpp</em> are used in <em>jsscript.cpp</em> to map line number to program counter and back.</p>
+
+<h4 id="jstypes.h" name="jstypes.h">jstypes.h</h4>
+
+<p>Fundamental representation types and utility macros. This file alone among all .h files in SpiderMonkey must be included first by .cpp files. It is not nested in .h files, as other prerequisite .h files generally are, since it is also a direct dependency of most .cpp files and would be over-included if nested in addition to being directly included.</p>
+
+<h4 id="jsbit.h.2C_jslog2.cpp" name="jsbit.h.2C_jslog2.cpp">jsbit.h, jslog2.cpp</h4>
+
+<p>Bit-twiddling routines. Most of the work here is selectively enabling compiler-specific intrinsics such as GCC's <code>__builtin_ctz</code>, which is useful in calculating base-2 logarithms of integers.</p>
+
+<h4 id="jsutil.cpp.2C_jsutil.h" name="jsutil.cpp.2C_jsutil.h">jsutil.cpp, jsutil.h</h4>
+
+<p>The <code>JS_ASSERT</code> macro is used throughout the source as a proof device to make invariants and preconditions clear to the reader, and to hold the line during maintenance and evolution against regressions or violations of assumptions that it would be too expensive to test unconditionally at run-time. Certain assertions are followed by run-time tests that cope with assertion failure, but only where I'm too smart or paranoid to believe the assertion will never fail...</p>
+
+<h4 id="jsclist.h" name="jsclist.h">jsclist.h</h4>
+
+<p>Doubly-linked circular list struct and macros.</p>
+
+<h4 id="jscpucfg.cpp" name="jscpucfg.cpp">jscpucfg.cpp</h4>
+
+<p>This standalone program generates <em>jscpucfg.h</em>, a header file containing bytes per word and other constants that depend on CPU architecture and C compiler type model. It tries to discover most of these constants by running its own experiments on the build host, so if you are cross-compiling, beware.</p>
+
+<h4 id="jsdtoa.cpp.2C_jsdtoa.h.2C_dtoa.c" name="jsdtoa.cpp.2C_jsdtoa.h.2C_dtoa.c">jsdtoa.cpp, jsdtoa.h, dtoa.c</h4>
+
+<p>dtoa.c contains David Gay's portable double-precision floating point to string conversion code, with Permission To Use notice included. jsdtoa.cpp <code>#include</code>s this file.</p>
+
+<h4 id="jshash.cpp.2C_jshash.h.2C_jsdhash.cpp.2C_jsdhash.h" name="jshash.cpp.2C_jshash.h.2C_jsdhash.cpp.2C_jsdhash.h">jshash.cpp, jshash.h, jsdhash.cpp, jsdhash.h</h4>
+
+<p>Portable, extensible hash tables. These use multiplicative hash for strength reduction over division hash, yet with very good key distribution over power of two table sizes. jshash resolves collisions via chaining, so each entry burns a malloc and can fragment the heap. jsdhash uses open addressing.</p>
+
+<h4 id="jslong.cpp.2C_jslong.h" name="jslong.cpp.2C_jslong.h">jslong.cpp, jslong.h</h4>
+
+<p>64-bit integer emulation, and compatible macros that use intrinsic C types, like <code>long long</code>, on platforms where they exist (most everywhere, these days).</p>
+
+<h4 id="jsprf..2A" name="jsprf..2A">jsprf.*</h4>
+
+<p>Portable, buffer-overrun-resistant sprintf and friends. For no good reason save lack of time, the %e, %f, and %g formats cause your system's native sprintf, rather than <code>JS_dtoa()</code>, to be used. This bug doesn't affect SpiderMonkey, because it uses its own <code>JS_dtoa()</code> call in <code>jsnum.cpp</code> to convert from double to string, but it's a bug that we'll fix later, and one you should be aware of if you intend to use a <code>JS_*printf()</code> function with your own floating type arguments - various vendor sprintf's mishandle NaN, +/-Inf, and some even print normal floating values inaccurately.</p>
+
+<h4 id="prmjtime.c.2C_prmjtime.h" name="prmjtime.c.2C_prmjtime.h">prmjtime.c, prmjtime.h</h4>
+
+<p>Time functions. These interfaces are named in a way that makes local vs. universal time confusion likely. Caveat emptor, and we're working on it. To make matters worse, Java (and therefore JavaScript) uses "local" time numbers (offsets from the epoch) in its Date class.</p>
+
+<h4 id="jsfile.cpp.2C_jsfile.h.2C_jsfile.msg" name="jsfile.cpp.2C_jsfile.h.2C_jsfile.msg">jsfile.cpp, jsfile.h, jsfile.msg</h4>
+
+<p>Obsolete. Do not use these files.</p>
+
+<h4 id="Makefile.in.2C_build.mk" name="Makefile.in.2C_build.mk">Makefile.in, build.mk</h4>
+
+<p>Mozilla makefiles. If you're building Gecko or Firefox, the larger build system will use these files. They are also used for current standalone builds.</p>
+
+<h4 id="Makefile.ref.2C_rules.mk.2C_config.mk.2C_config.2F.2A" name="Makefile.ref.2C_rules.mk.2C_config.mk.2C_config.2F.2A">Makefile.ref, rules.mk, config.mk, config/*</h4>
+
+<p>Obsolete SpiderMonkey standalone makefiles from 1.8 and earlier. See <a href="/en-US/docs/SpiderMonkey/Build_Documentation#Building_SpiderMonkey_1.8_or_earlier" title="SpiderMonkey/Build Documentation#Building SpiderMonkey 1.8 or earlier">SpiderMonkey Build Documentation</a>.</p>
+
+<h3 id="See_also">See also</h3>
+
+<ul>
+ <li><a href="/jsd" title="jsd">jsd</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/introduction_to_the_javascript_shell/index.html b/files/zh-cn/mozilla/projects/spidermonkey/introduction_to_the_javascript_shell/index.html
new file mode 100644
index 0000000000..b570b78d56
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/introduction_to_the_javascript_shell/index.html
@@ -0,0 +1,382 @@
+---
+title: JavaScript shell 介绍
+slug: Mozilla/Projects/SpiderMonkey/Introduction_to_the_JavaScript_shell
+tags:
+ - SpiderMonkey
+ - 蜘蛛猴
+translation_of: Mozilla/Projects/SpiderMonkey/Introduction_to_the_JavaScript_shell
+---
+<div>{{SpiderMonkeySidebar("General")}}</div>
+
+<div class="summary">
+<p>JavaScript shell 是一个命令行程序,它被包含在<a href="/en-US/docs/Mozilla/Projects/SpiderMonkey" title="en/SpiderMonkey">SpiderMonkey</a>源代码中。它在 JavaScript 中类似于 Python 命令行、Lisp 读取执行循环和 Ruby 中的 <code>irb</code> 。这篇文章解释如何使用 shell 去测试 JavaScript 代码和执行 JavaScript 程序。</p>
+</div>
+
+<p>要获取 SpiderMonkey JavaScript shell, 请参见 <a href="/en-US/docs/Mozilla/Projects/SpiderMonkey/Build_Documentation">SpiderMonkey 构建文档</a> 或根据你的平台从 <a class="external" href="https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/" title="http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/">Nightly Builds</a> 下载二进制文件。</p>
+
+<p>对于其他的 JavaScript shells, 参考 <a class="internal" href="/en-US/docs/Web/JavaScript/Shells" title="En/JavaScript shells">JavaScript shells</a>.</p>
+
+<div class="note">
+<p>注意: <span class="tlid-translation translation" lang="zh-CN"><span title="">从 SpiderMonkey 44 开始,默认情况下使用标准的、与 Web 兼容的 JavaScript 版本(不再使用JS1.7 +)。</span> <span title="">内置的</span></span> <code>version()</code> <span class="tlid-translation translation" lang="zh-CN"><span title=""> 内置函数仍然可以用来测试遗留功能。</span></span></p>
+</div>
+
+<h2 id="Using_the_JavaScript_shell" name="Using_the_JavaScript_shell">执行JavaScript shell</h2>
+
+<p>jsshell 提供两种操作模式。你既可以交互式操作 shell, 在此模式你可以输入JavaScript 代码并执行。便于实验和测试新特性。你也可以在命令行参数指定一个 JavaScript 代码文件,此文件会自动运行。</p>
+
+<p>在安装 jsshell 之后,你可以执行以下命令打开交互式终端:</p>
+
+<pre class="eval notranslate">js
+</pre>
+
+<div class="blockIndicator note">
+<p><strong>注意</strong>:如果你在预编译程序执行中遇到<br>
+ <code>"symbol lookup error: ./js: undefined symbol: PR_SetCurrentThreadName"</code><br>
+ 这样的错误, 请尝试用 run-mozilla.sh 文件执行它:<br>
+ <code>run-mozilla.sh ./js</code>  <br>
+ ——我测试过有效</p>
+</div>
+
+<p>如果运行 <code>foo.js</code> file中的JavaScript代码,你可以使用以下命令:</p>
+
+<pre class="eval notranslate">js foo.js
+</pre>
+
+<p>如果想运行 <code>foo.js</code> 然后进入交互模式:</p>
+
+<pre class="eval notranslate">js -f foo.js -i
+</pre>
+
+<h2 id="说明">说明</h2>
+
+<div class="note"><strong>注意:</strong> 因为JavaScript shell 用来给 JavaScript 引擎做测试环境, 可用的选项和内置函数可能改变。</div>
+
+<h3 id="Command_line_options" name="Command_line_options">命令行选项</h3>
+
+<p>有许多命令行选项可以控制shell,以下为总结。使用<strong>-h</strong>选项显示帮助</p>
+
+<dl>
+ <dt><code>-c, --compileonly</code></dt>
+ <dd>仅编译不执行代码,这是一种方便的检查语法错误的方式。</dd>
+ <dt><code>-e <em>script</em></code></dt>
+ <dd>运行指定脚本,<code><em>script</em></code> 是将要执行的代码字符串。</dd>
+ <dt><code>-f <em>filename</em></code></dt>
+ <dd>执行指定的代码文件。</dd>
+ <dt><code>-i</code></dt>
+ <dd>启用交互模式。(如果参数中没有文件名这个选项默认打开)</dd>
+ <dt><code>--no-ion</code></dt>
+ <dd>禁用优化的 JIT 编译器。</dd>
+ <dt><code>--no-baseline</code></dt>
+ <dd>禁用基准的 JIT 编译器。</dd>
+ <dt><code>-P</code></dt>
+ <dd>如果文件的第一行是 "/usr/bin/env js -P",文件内容将通过 JavaScript 引擎解释执行。</dd>
+ <dd>这将允许你在 unix 和 OS X 系统上执行 JavaScript 文件。</dd>
+ <dt><code>-s</code></dt>
+ <dd>启用严格警告模式.</dd>
+ <dt><code>-w, --warnings</code></dt>
+ <dd>显示警告消息.</dd>
+ <dt><code>-W</code>, --nowarnings</dt>
+ <dd>隐藏警告消息.</dd>
+</dl>
+
+<h3 id="Environment_options" name="Environment_options">环境选项</h3>
+
+<p>如果设置了这些环境变量,它们将会影响 js shell 的行为。</p>
+
+<dl>
+ <dt><code>JS_STDOUT=<em>file</em></code></dt>
+ <dd>将标准输出重定向到文件<code><em>file</em></code>。</dd>
+ <dt><code>JS_STDERR=<em>file</em></code></dt>
+ <dd>将标准输入重定向到文件<code><em>file</em></code>。</dd>
+</dl>
+
+<h3 id="Built-in_functions" name="Built-in_functions">内置函数</h3>
+
+<p>为了使 JavaScript shell 更加实用, 我们提供了一些内置的函数供 JavaScript 程序(包括交互模式下)使用。</p>
+
+<div class="warning">
+<p><strong>注意</strong>:这个列表是不完整的而且与 <a href="/en-US/docs/SpiderMonkey/Shell_global_objects">Shell 全局对象</a> 重复。请参见{{Source("js/src/shell/js.cpp")}} (在 <code>shell_functions</code> 附近) 以获取详细信息。</p>
+</div>
+
+<h4 id="build.28.29" name="build.28.29"><code>build()</code></h4>
+
+<p>返回 JavaScript shell 构建的日期和时间.</p>
+
+<div class="note"><strong>Note:</strong> <code>clear()</code> 函数如果不带任何参数,将清除包括所有内置方法在内的所有东西。</div>
+
+<h4 id="clone.28function.2C_.5Bscope.5D.29" name="clone.28function.2C_.5Bscope.5D.29"><code>clone(<em>function, [scope]</em>)</code></h4>
+
+<p>克隆指定函数对象。如果未指定具体域,新对象的父本和原始对象的相同。否则,新对象被放置于指定域。</p>
+
+<h4 id="countHeap" name="countHeap"><code>countHeap(<em>[start[, kind]]</em>)</code></h4>
+
+<p>{{ jsapi_minversion_inline("1.8") }}   <span class="tlid-translation translation" lang="zh-CN"><span title="">计算堆中活动的回收垃圾数量,或计算给定且不为 null 的可从 </span></span><code><em>start</em></code><span class="tlid-translation translation" lang="zh-CN"><span title=""> 到达的对象的数量。</span></span><code><em>kind</em></code><span class="tlid-translation translation" lang="zh-CN"><span title=""> 是“all”(默认)以计算所有事物,或者是“ object”,“ double”,“ string”,“ function”,“ qname”,“ namespace”,“ xml”之一以仅计算此类事物</span> <span title="">。</span></span></p>
+
+<h4 id="evalcx.28string.5B.2C_object.5D.29" name="evalcx.28string.5B.2C_object.5D.29"><code>dumpHeap(<em>[fileName[, start[, toFind[, maxDepth[, toIgnore]]]]]</em>)</code></h4>
+
+<p>{{ jsapi_minversion_inline("1.8") }} 转储所有现存对象的数据 (或有关联的子数据) 到文件。详情参见本函数的C/C++版本: <code>JS_DumpHeap</code>.</p>
+
+<h4 id="evalcx.28string.5B.2C_object.5D.29" name="evalcx.28string.5B.2C_object.5D.29"><code>evalcx(<em>string[, object]</em>)</code></h4>
+
+<p>执行 <code><em>string</em></code> 中的 JavaScript 代码。如果设置了参数 <code><em>object</em></code>,代码将在这个对象中执行,将其视为一个沙盒。</p>
+
+<p><code><em>string</em></code> 为空且没有设置 <code><em>object</em></code> 时,<code>evalcx()</code> 将会<span class="tlid-translation translation" lang="zh-CN"><span title="">返回一个具有“</span></span>eager”<span class="tlid-translation translation" lang="zh-CN"><span title=""> 标准类的新对象</span></span>。</p>
+
+<p><code><em>string</em></code> 为 "lazy" 且没有设置 <code><em>object</em></code> 时,<code>evalcx()</code> 将会<span class="tlid-translation translation" lang="zh-CN"><span title="">返回一个具有“</span></span>lazy”<span class="tlid-translation translation" lang="zh-CN"><span title=""> 标准类的新对象</span></span>。</p>
+
+<div class="note"><strong>注意:</strong> <code>evalcx()</code> 仅对进行 JavaScript 引擎极低层工作的开发者有用,用于在 shell 中测试类<code>evalInSandbox</code> 环境</div>
+
+<h4 id="gc.28.29" name="gc.28.29"><code>gc()</code></h4>
+
+<p>运行垃圾收集器释放内存。</p>
+
+<h4 id="gcparam.28.29" name="gcparam.28.29"><code>gcparam(<em>name[, value]</em>)</code></h4>
+
+<p>{{ jsapi_minversion_inline("1.8") }} 读取或配置垃圾收集器参数。</p>
+
+<p>名称必须是参数key之一 (例如 <code>'maxBytes'</code>, <code>'maxMallocBytes'</code> 或<code>'gcNumber</code>').</p>
+
+<p>如果value未指定,<code>gcparam()</code>返回与GC参数名name相关联的当前值</p>
+
+<p>如果value被指定,其必须可转换为uint32,<code>gcparam()</code>将GC参数名设置为value。</p>
+
+<p>For more information, see the C/C++ functions  <a class="internal" href="/En/SpiderMonkey/JSAPI_Reference/JS_GetGCParameter" title="en/SpiderMonkey/JSAPI Reference/JS GetGCParameter"><code>JS_SetGCParameter</code></a> and <a class="internal" href="/En/SpiderMonkey/JSAPI_Reference/JS_SetGCParameter" title="en/SpiderMonkey/JSAPI Reference/JS SetGCParameter"><code>JS_SetGCParameter</code></a>.</p>
+
+<h4 id="gczeal.28.29" name="gczeal.28.29"><code>gczeal(level)</code></h4>
+
+<p>{{ jsapi_minversion_inline("1.8") }} <code>DEBUG</code> only. 设置GC zeal级别, 这是一个调试特性。0 是正常的周期性垃圾收集,1是频繁的GC, 2是及其频繁的GC. 除了0以外的都将使JavaScript运行极其缓慢但是可能有助于发现GC相关的 bug. For more information, see the C/C++ version of this function, <a class="internal" href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCZeal" title="en/SpiderMonkey/JSAPI Reference/JS SetGCZeal"><code>JS_SetGCZeal</code></a>.</p>
+
+<h4 id="getpda.28object.29" name="getpda.28object.29"><code>getpda(<em>object</em>)</code></h4>
+
+<p>返回指定对象的属性描述</p>
+
+<h4 id="getslx.28object.29" name="getslx.28object.29"><code>getslx(<em>object</em>)</code></h4>
+
+<p>返回脚本行范围,这是包含指定对象的代码行数</p>
+
+<h4 id="help.28.5Bcommand_....5D.29" name="help.28.5Bcommand_....5D.29"><code>help(<em>[command ...]</em>)</code></h4>
+
+<p><span class="tlid-translation translation" lang="zh-CN"><span title="">显示有关指定命令或所有可用功能的简要帮助信息(如果未指定命令将显示所有帮助信息)。</span></span></p>
+
+<h4 id="intern.28string.29" name="intern.28string.29"><code>intern(<em>string</em>)</code></h4>
+
+<p>将指定的字符串 内化到atom表中。每个字符串都有一个唯一的标识符,称为atom。这个系统使得对字符串进行比较变得更加容易。</p>
+
+<div class="note"><strong>Note:</strong> This function is intended only for use when testing the JavaScript engine.</div>
+
+<h4 id="line2pc.28.5Bfunction.2C_.5D_line.29" name="line2pc.28.5Bfunction.2C_.5D_line.29"><code>line2pc(<em>[function, ] line</em>)</code></h4>
+
+<p>返回对应于指定行的代码行的程序计数器值。如果指定了函数,那么行就是指定函数的偏移量.</p>
+
+<h4 id="load.28filename1_.5Bfilename.5D.29" name="load.28filename1_.5Bfilename.5D.29"><code>load(<em>filename1</em> <em>[filename]</em>)</code></h4>
+
+<p>加载带有指定名称的JavaScript文件.</p>
+
+<div class="note"><strong>Note:</strong> For loading non-JavaScript files, use <code>read()</code>.</div>
+
+<h4 id="options.28.5Boption_....5D.29" name="options.28.5Boption_....5D.29"><code>options(<em>[option ...]</em>)</code></h4>
+
+<p>让你设置或获取选项。如果您在命令行上指定选项,那么调用<code>options的</code>结果将指示您所请求的选项。您还可以传递新的选项来设置.</p>
+
+<p>The available options are:</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Option Name</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>strict</code></td>
+ <td>严格模式 is enabled.</td>
+ </tr>
+ <tr>
+ <td><code>werror</code></td>
+ <td>Warnings should be treated as errors.</td>
+ </tr>
+ <tr>
+ <td><code>atline</code></td>
+ <td>When <code>atline</code> is enabled, 表单的注释 <code>//@line <em>num</em></code> set the number of the following line to <code><em>num</em></code>.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h4 id="pc2line.28function.2C_.5Bpc.5D.29" name="pc2line.28function.2C_.5Bpc.5D.29"><code>pc2line(<em>function, [pc]</em>)</code></h4>
+
+<p>返回对应于指定函数的第一行的JavaScript代码的行号. If you specify a program counter offset into the function, the line number of the line of code containing that offset is returned.</p>
+
+<h4 id="print.28.5Bexpression_....5D.29" name="print.28.5Bexpression_....5D.29"><code>print(<em>[expression ...]</em>)</code></h4>
+
+<p>Evaluates the <em>expression(s)</em> and displays the result(s) on <code>stdout</code>, 分隔 by spaces (" ") and 终止 by a newline ("\n").</p>
+
+<h4 id="print.28.5Bexpression_....5D.29" name="print.28.5Bexpression_....5D.29"><code>putstr(<em>expression</em>)</code></h4>
+
+<p>Evaluates the <em>expression</em> and displays the result on <code>stdout</code>.</p>
+
+<h4 id="quit.28.29" name="quit.28.29"><code>quit(<em>[status]</em>)</code></h4>
+
+<p>Exits the shell. 如果省略,状态默认为0。</p>
+
+<h4 id="load.28filename1_.5Bfilename.5D.29" name="load.28filename1_.5Bfilename.5D.29"><code>read(<em>filename[, type]</em>)</code></h4>
+
+<p>Reads and returns the contents of file. If type is "binary" returns an <code>Uint8Array</code>, otherwise returns an UTF-8 decoded string.</p>
+
+<h4 id="readline.28.29" name="readline.28.29"><code>readline()</code></h4>
+
+<p>Reads a single line of input from <code>stdin</code>, returning it to the caller. You can use this to create interactive shell programs in JavaScript.</p>
+
+<h4 id="scatter.28fnArray.29" name="scatter.28fnArray.29">Reflect.parse()</h4>
+
+<p>See <a href="/en/SpiderMonkey/Parser_API" title="en/SpiderMonkey/Parser_API">Parser API</a>.</p>
+
+<div class="note"><strong>Note:</strong> This function is intended only for use when testing the JavaScript engine.</div>
+
+<h4 id="seal.28object.5B.2C_deep.5D.29" name="seal.28object.5B.2C_deep.5D.29"><code>seal(<em>object[, deep]</em>)</code></h4>
+
+<p>密封指定的对象, or an object graph if <em>deep</em> is <code>true</code>. 通过封住对象或对象图,可以禁用这些对象的修改.</p>
+
+<h4 id="sleep.28dt.29" name="sleep.28dt.29"><code>sleep(dt)</code></h4>
+
+<p>{{ jsapi_minversion_inline("1.8") }} Only in <code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_THREADSAFE" title="en/SpiderMonkey/JSAPI_Reference/JS_THREADSAFE">JS_THREADSAFE</a></code> builds. Sleep for <em>dt</em> seconds. Fractions of a second are supported. Returns <code>true</code> on success, <code>false</code> if the sleep was interrupted.</p>
+
+<h4 id="stackQuota" name="stackQuota"><code>stackQuota(<em>[number]</em>)</code> {{obsolete_inline}}</h4>
+
+<p>{{ jsapi_minversion_inline("1.8") }} 获取或设置脚本堆栈配额.</p>
+
+<h4 id="throwError.28.29" name="throwError.28.29"><code>throwError()</code></h4>
+
+<p>Throws an error from the <code>JS_ReportError()</code> function.</p>
+
+<div class="note"><strong>Note:</strong> This function is intended only for use when testing the JavaScript engine.</div>
+
+<h4 id="trap.28.5Bfunction.2C_.5Bpc.2C.5D.5D_expression.29" name="trap.28.5Bfunction.2C_.5Bpc.2C.5D.5D_expression.29"><code>trap(<em>[function, [pc,]] expression</em>)</code></h4>
+
+<p>在JavaScript代码的特定点设置trap. 当由pc在函数函数中指定的偏移量即将被执行时,表达式将被求值。</p>
+
+<p>这是一种强大的调试机制,与<code>line2pc()</code>一起使用. 例如, 如果你想在函数的第6行中显示一条消息, <code>doSomething()</code> 被执行, you can enter the following:</p>
+
+<pre class="notranslate">trap(doSomething, line2pc(doSomething, 6), "print('line 6!\n')");
+</pre>
+
+<div class="note"><strong>Note:</strong> 当设置陷阱时,程序中的相应字节码将被<code>trap</code>字节码替换,直到您使用<code>untrap()</code> 来移除陷阱。</div>
+
+<h4 id="untrap.28function_.5B.2C_pc.5D.29" name="untrap.28function_.5B.2C_pc.5D.29"><code>untrap(<em>function [, pc]</em>)</code></h4>
+
+<p>Removes a trap from the specified <em>function</em> at the offset <em>pc</em>. If <em>pc</em> isn't specified, the trap is removed from the function's entry point.</p>
+
+<p>This function has no effect if there is no trap at the specified location.</p>
+
+<h4 id="version.28.5Bnumber.5D.29" name="version.28.5Bnumber.5D.29"><code>version(<em>[number]</em>)</code></h4>
+
+<p>The <code>version()</code> function lets you get or set the JavaScript version number. This may be useful for gaining access to syntax only available in certain versions of JavaScript (for example, see <a href="/en/JavaScript/New_in_JavaScript/1.7#Using_JavaScript_1.7" title="en/New_in_JavaScript_1.7#Using_JavaScript_1.7">Using JavaScript 1.7</a>).</p>
+
+<h3 id="Debug_functions" name="Debug_functions">调试方法</h3>
+
+<p>These built-in functions are only available in <code>DEBUG</code> builds.</p>
+
+<h4 id="dis.28.5Bfunction.5D.29" name="dis.28.5Bfunction.5D.29"><code>dis(<em>[function]</em>)</code></h4>
+
+<p>为整个程序或指定的函数分解JavaScript字节码</p>
+
+<p>For example, if you enter the JavaScript function below:</p>
+
+<pre class="eval notranslate">function test() {
+ var i = 3;
+ print(i+2);
+}
+</pre>
+
+<p>Then run the command <code>dis(test);</code>, you get this output:</p>
+
+<pre class="notranslate">main:
+00000: uint16 3
+00003: setvar 0
+00006: pop
+00007: name "print"
+00010: pushobj
+00011: getvar 0
+00014: uint16 2
+00017: add
+00018: call 1
+00021: pop
+00022: stop
+
+Source notes:
+ 0: 0 [ 0] newline
+ 1: 3 [ 3] decl offset 0
+ 2: 7 [ 4] newline
+ 3: 18 [ 11] xdelta
+ 4: 18 [ 0] pcbase offset 11
+</pre>
+
+<h4 id="dissrc.28.5Bfunction.5D.29" name="dissrc.28.5Bfunction.5D.29"><code>dissrc(<em>[function]</em>)</code></h4>
+
+<p>Disassembles the JavaScript bytecode for the entire program, or for the specified <em>function</em>, showing the source lines. This function only works with programs loaded from files, either using the <code>-f</code> flag on launching the shell, or by using the <code>load()</code> function.</p>
+
+<p>If your program includes a function, <code>doStuff()</code>, like this:</p>
+
+<pre class="notranslate">function doStuff(input) {
+ print("Enter a number: ");
+ var n1 = readline();
+ print("Enter another one: ");
+ var n2 = readline();
+
+ print("You entered " + n1 + " and " + n2 + "\n");
+}
+</pre>
+
+<p>Calling <code>dissrc(doStuff)</code> function would give this output:</p>
+
+<pre class="notranslate">;------------------------- 10: print("Enter a number: ");
+00000: 10 name "print"
+00003: 10 pushobj
+00004: 10 string "Enter a number: "
+00007: 10 call 1
+00010: 10 pop
+;------------------------- 11: var n1 = readline();
+00011: 11 name "readline"
+00014: 11 pushobj
+00015: 11 call 0
+00018: 11 setvar 0
+00021: 11 pop
+;------------------------- 12: print("Enter another one: ");
+00022: 12 name "print"
+00025: 12 pushobj
+00026: 12 string "Enter another one: "
+00029: 12 call 1
+00032: 12 pop
+;------------------------- 13: var n2 = readline();
+00033: 13 name "readline"
+00036: 13 pushobj
+00037: 13 call 0
+00040: 13 setvar 1
+00043: 13 pop
+;------------------------- 14:
+;------------------------- 15: print("You entered " + n1 + " and " + n2 + "\n");
+00044: 15 name "print"
+00047: 15 pushobj
+00048: 15 string "You entered "
+00051: 15 getvar 0
+00054: 15 add
+00055: 15 string " and "
+00058: 15 add
+00059: 15 getvar 1
+00062: 15 add
+00063: 15 string "\\n"
+00066: 15 add
+00067: 15 call 1
+00070: 15 pop
+00071: 15 stop
+</pre>
+
+<h4 id="dumpheap.28.28.5BfileName.5B.2C_start.5B.2C_toFind.5B.2C_maxDepth.5B.2C_toIgnore.5D.5D.5D.5D.5D.29" name="dumpheap.28.28.5BfileName.5B.2C_start.5B.2C_toFind.5B.2C_maxDepth.5B.2C_toIgnore.5D.5D.5D.5D.5D.29"><code>dumpheap((<em>[fileName[, start[, toFind[, maxDepth[, toIgnore]]]]]</em>)</code></h4>
+
+<p>Dump GC information. This is a thin wrapper for <code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DumpHeap" title="en/SpiderMonkey/JSAPI_Reference/JS_DumpHeap">JS_DumpHeap</a></code>.</p>
+
+<h4 id="gczeal.28zeal.29" name="gczeal.28zeal.29"><code>gczeal(<em>zeal</em>)</code></h4>
+
+<p>Enable extra-frequent GC, to help find GC hazards. <em>zeal</em> is an integer. The meaning is the same as for the parameter to <code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCZeal" title="en/SpiderMonkey/JSAPI_Reference/JS_SetGCZeal">JS_SetGCZeal</a></code>.</p>
+
+<h4 id="notes.28.5Bfunction.5D.29" name="notes.28.5Bfunction.5D.29"><code>notes(<em>[function]</em>)</code></h4>
+
+<p>Shows the source notes for the specified function. Source notes contain information that map the bytecode to the source code, which is used when decompiling the code, such as when using the <code>dissrc()</code> function.</p>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/javascript-c引擎嵌入开发指南/index.html b/files/zh-cn/mozilla/projects/spidermonkey/javascript-c引擎嵌入开发指南/index.html
new file mode 100644
index 0000000000..4752df82f3
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/javascript-c引擎嵌入开发指南/index.html
@@ -0,0 +1,11 @@
+---
+title: JavaScript-C引擎嵌入开发指南
+slug: Mozilla/Projects/SpiderMonkey/JavaScript-C引擎嵌入开发指南
+translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_User_Guide
+---
+<p><a class="external" href="http://www.nirvanastudio.org/javascript/javascript-c-engine-embedders-guide.html">查看Nirvana Studio上的翻译</a>
+</p><p><br>
+</p>
+<div class="noinclude">
+</div>
+{{ languages( { "en": "en/JSAPI_User_Guide", "ja": "ja/Embedding_SpiderMonkey" } ) }}
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/boolean_to_jsval/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/boolean_to_jsval/index.html
new file mode 100644
index 0000000000..80747881fd
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/boolean_to_jsval/index.html
@@ -0,0 +1,53 @@
+---
+title: BOOLEAN_TO_JSVAL
+slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/BOOLEAN_TO_JSVAL
+translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/BOOLEAN_TO_JSVAL
+---
+<div>{{SpiderMonkeySidebar("JSAPI")}}</div>
+
+<div>{{ obsolete_header("jsapi42") }}</div>
+
+<div class="summary">
+<p>Cast a C integer to a boolean {{jsapixref("JS::Value")}} without any type checking or error handling.</p>
+</div>
+
+<div class="note">
+<p>Please use {{jsapixref("JS::BooleanValue")}}/{{jsapixref("JS::TrueValue")}}/{{jsapixref("JS::FalseValue")}} instead in SpiderMonkey 45 or later.</p>
+</div>
+
+<h2 id="Syntax" name="Syntax">Syntax</h2>
+
+<pre class="brush: cpp">jsval
+BOOLEAN_TO_JSVAL(bool b);
+</pre>
+
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>Name</th>
+ <th>Type</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td><code>b</code></td>
+ <td><code>bool</code></td>
+ <td>C integer value to be converted to a boolean <code>jsval</code>.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Description" name="Description">Description</h2>
+
+<p><strong><code>BOOLEAN_TO_JSVAL</code></strong> converts a <code>bool</code> argument, <code>b</code>, to a boolean <code>jsval</code>.</p>
+
+<p>If <code>b</code> is <code>false</code>, the result is <code>JSVAL_FALSE</code>.</p>
+
+<p>If <code>b</code> is <code>true</code>, the result is <code>JSVAL_TRUE</code>.</p>
+
+<h2 id="See_Also" name="See_Also">See Also</h2>
+
+<ul>
+ <li>{{ LXRSearch("ident", "i", "BOOLEAN_TO_JSVAL") }}</li>
+ <li>{{jsapixref("JS::BooleanValue")}}</li>
+ <li>{{bug(1177892)}} -- removed</li>
+</ul>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/index.html
new file mode 100644
index 0000000000..d076928fba
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/index.html
@@ -0,0 +1,646 @@
+---
+title: JSAPI 参考
+slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference
+translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference
+---
+<p><strong>JSAPI</strong>是<strong> </strong><a href="/en/SpiderMonkey" title="en/SpiderMonkey">SpiderMonkey</a> JavaScript 引擎的C 语言应用程序接口(API)。要了解如何使用JSAPI ,请看 <a href="/En/SpiderMonkey/JSAPI_User_Guide" title="en/JSAPI_User_Guide">JSAPI User Guide</a> and the <a href="/En/SpiderMonkey/JSAPI_Phrasebook" title="en/JSAPI_Phrasebook">JSAPI Phrasebook</a>。</p>
+<p><br>
+ <a href="/En/SpiderMonkey/JSAPI_Reference/Alphabetical_List" title="en/JSAPI_Reference/Alphabetical_List">Alphabetical List</a></p>
+<h3 id="Runtimes_and_contexts" name="Runtimes_and_contexts">运行时和上下文</h3>
+<ul>
+ <li>typedef <a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSRuntime</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewRuntime" title="en/JS_NewRuntime">JS_NewRuntime</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DestroyRuntime" title="en/JS_DestroyRuntime">JS_DestroyRuntime</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ShutDown" title="en/JS_ShutDown">JS_ShutDown</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetRuntimePrivate" title="en/JS_GetRuntimePrivate">JS_GetRuntimePrivate</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetRuntimePrivate" title="en/JS_GetRuntimePrivate">JS_SetRuntimePrivate</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_Init" title="en/JS_Init">JS_Init</a> {{ Deprecated_inline() }}</li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_Finish" title="en/JS_Finish">JS_Finish</a> {{ Deprecated_inline() }}</li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ContextIterator" title="en/JS_ContextIterator">JS_ContextIterator</a></li>
+</ul>
+<ul>
+ <li>typedef <a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSContext</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewContext" title="en/JS_NewContext">JS_NewContext</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DestroyContext" title="en/JS_DestroyContext">JS_DestroyContext</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DestroyContext" title="en/JS_DestroyContext">JS_DestroyContextMaybeGC</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DestroyContext" title="en/JS_DestroyContext">JS_DestroyContextNoGC</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetRuntime" title="en/JS_GetRuntime">JS_GetRuntime</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetContextPrivate" title="en/JS_GetContextPrivate">JS_GetContextPrivate</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetContextPrivate" title="en/JS_GetContextPrivate">JS_SetContextPrivate</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetOptions" title="en/JS_GetOptions">JS_GetOptions</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOptions" title="en/JS_SetOptions">JS_SetOptions</a> – <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOptions" title="en/JS_SetOptions">JSOPTION_ATLINE</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOptions" title="en/JS_SetOptions">JSOPTION_COMPILE_N_GO</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOptions" title="en/JS_SetOptions">JSOPTION_DONT_REPORT_UNCAUGHT</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOptions" title="en/JS_SetOptions">JSOPTION_NATIVE_BRANCH_CALLBACK</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOptions" title="en/JSOPTION_RELIMIT">JSOPTION_RELIMIT</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOptions" title="en/JS_SetOptions">JSOPTION_STRICT</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOptions" title="en/JS_SetOptions">JSOPTION_VAROBJFIX</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOptions" title="en/JS_SetOptions">JSOPTION_WERROR</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOptions" title="en/JS_SetOptions">JSOPTION_XML</a></li>
+ <li><a href="/En/SpiderMonkey/JSAPI_Reference/JS_ToggleOptions" title="en/JS_ToggleOptions">JS_ToggleOptions</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetBranchCallback" title="en/JS_SetBranchCallback">JS_SetBranchCallback</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOperationCallback" title="en/JS_SetOperationCallback">JS_SetOperationCallback</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOperationCallback" title="en/JS_SetOperationCallback">JS_ClearOperationCallback</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOperationCallback" title="en/JS_SetOperationCallback">JS_GetOperationCallback</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOperationCallback" title="en/JS_SetOperationCallback">JS_GetOperationLimit</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOperationCallback" title="en/JS_SetOperationCallback">JS_SetOperationLimit</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOperationCallback" title="en/JS_SetOperationCallback">JS_MAX_OPERATION_LIMIT</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetOperationCallback" title="en/JS_SetOperationCallback">JS_OPERATION_WEIGHT_BASE</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetThreadStackLimit" title="en/JS_SetThreadStackLimit">JS_SetThreadStackLimit</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetScriptStackQuota" title="en/JS_SetScriptStackQuota">JS_SetScriptStackQuota</a></li>
+</ul>
+<ul>
+ <li>enum <a href="/en/SpiderMonkey/JSAPI_Reference/JSVersion" title="en/JSVersion">JSVersion</a>, <a href="/en/JSVERSION_ECMA_3" title="en/JSVERSION_ECMA_3">JSVERSION_ECMA_3</a>, <a href="/en/JSVERSION_DEFAULT" title="en/JSVERSION_DEFAULT">JSVERSION_DEFAULT</a>, <a href="/en/JSVERSION_LATEST" title="en/JSVERSION_LATEST">JSVERSION_LATEST</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetImplementationVersion" title="en/JS_GetImplementationVersion">JS_GetImplementationVersion</a></li>
+ <li><a class="internal" href="/cn/SpiderMonkey/JSAPI%20%E5%8F%82%E8%80%83/JS%20GetVersion" title="cn/SpiderMonkey/JSAPI 参考/JS GetVersion">JS_GetVersion</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetVersion" title="en/JS_SetVersion">JS_SetVersion</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_StringToVersion" title="en/JS_StringToVersion">JS_StringToVersion</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_VersionToString" title="en/JS_VersionToString">JS_VersionToString</a></li>
+</ul>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetGlobalObject" title="en/JS_GetGlobalObject">JS_GetGlobalObject</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGlobalObject" title="en/JS_SetGlobalObject">JS_SetGlobalObject</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_InitClass" title="en/JS_InitClass">JS_InitClass</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_InitStandardClasses" title="en/JS_InitStandardClasses">JS_InitStandardClasses</a></li>
+ <li><a href="/en/JS_ResolveStandardClass" title="en/JS_ResolveStandardClass">JS_ResolveStandardClass</a></li>
+ <li><a href="/en/JS_EnumerateStandardClasses" title="en/JS_EnumerateStandardClasses">JS_EnumerateStandardClasses</a></li>
+ <li><a href="/en/JS_EnumerateResolvedStandardClasses" title="en/JS_EnumerateResolvedStandardClasses">JS_EnumerateResolvedStandardClasses</a></li>
+</ul>
+<ul>
+ <li><a href="/en/JS_IsAssigning" title="en/JS_IsAssigning">JS_IsAssigning</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_IsConstructing" title="en/JS_IsConstructing">JS_IsConstructing</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_IsRunning" title="en/JS_IsRunning">JS_IsRunning</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetScopeChain" title="en/JS_GetScopeChain">JS_GetScopeChain</a></li>
+ <li><a href="/en/JS_SaveFrameChain" title="en/JS_SaveFrameChain">JS_SaveFrameChain</a>, <a href="/en/JS_RestoreFrameChain" title="en/JS_RestoreFrameChain">JS_RestoreFrameChain</a></li>
+</ul>
+<p>Locale callbacks:</p>
+<ul>
+ <li>struct <a href="/en/JSLocaleCallbacks" title="en/JSLocaleCallbacks">JSLocaleCallbacks</a></li>
+ <li><a href="/en/JS_GetLocaleCallbacks" title="en/JS_GetLocaleCallbacks">JS_GetLocaleCallbacks</a></li>
+ <li><a href="/en/JS_SetLocaleCallbacks" title="en/JS_SetLocaleCallbacks">JS_SetLocaleCallbacks</a></li>
+</ul>
+<p>Locale callback types:</p>
+<ul>
+ <li><a href="/en/JSLocaleToUpperCase" title="en/JSLocaleToUpperCase">JSLocaleToUpperCase</a></li>
+ <li><a href="/en/JSLocaleToLowerCase" title="en/JSLocaleToLowerCase">JSLocaleToLowerCase</a></li>
+ <li><a href="/en/JSLocaleCompare" title="en/JSLocaleCompare">JSLocaleCompare</a></li>
+ <li><a href="/en/JSLocaleToUnicode" title="en/JSLocaleToUnicode">JSLocaleToUnicode</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ReportErrorNumber" title="en/JS_ReportErrorNumber">JSErrorCallback</a></li>
+</ul>
+<h3 id="Scripts" name="Scripts">脚本</h3>
+<p>Just running some JavaScript code is straightforward:</p>
+<p>只是运行一些JavaScript代码很简单:</p>
+<ul>
+ <li><a class="internal" href="/Cn/SpiderMonkey/JSAPI_%E5%8F%82%E8%80%83/JS_EvaluateScript" title="cn/SpiderMonkey/JSAPI 参考/JS EvaluateScript">JS_EvaluateScript</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_EvaluateScript" title="en/JS_EvaluateScript">JS_EvaluateUCScript</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_EvaluateScriptForPrincipals" title="en/JS_EvaluateScriptForPrincipals">JS_EvaluateScriptForPrincipals</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_EvaluateScriptForPrincipals" title="en/JS_EvaluateScriptForPrincipals">JS_EvaluateUCScriptForPrincipals</a></li>
+</ul>
+<p>You can instead compile JavaScript code into a <code>JSScript</code> which you can then execute multiple times.</p>
+<p>你可以将JavaScript代码编译后保存在<code>JSScript类型的变量中,这样就可以多次执行。</code></p>
+<p>typedef <a href="/en/JSScript" title="en/JSScript">JSScript</a></p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CompileFile" title="en/JS_CompileFile">JS_CompileFile</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CompileFileHandle" title="en/JS_CompileFileHandle">JS_CompileFileHandle</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CompileFileHandle" title="en/JS_CompileFileHandle">JS_CompileFileHandleForPrincipals</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CompileScript" title="en/JS_CompileScript">JS_CompileScript</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CompileScript" title="en/JS_CompileScript">JS_CompileUCScript</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CompileScriptForPrincipals" title="en/JS_CompileScriptForPrincipals">JS_CompileScriptForPrincipals</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CompileScriptForPrincipals" title="en/JS_CompileScriptForPrincipals">JS_CompileUCScriptForPrincipals</a></li>
+ <li><a href="/en/JS_BufferIsCompilableUnit" title="en/JS_BufferIsCompilableUnit">JS_BufferIsCompilableUnit</a></li>
+ <li><a href="/en/JS_GetScriptObject" title="en/JS_GetScriptObject">JS_GetScriptObject</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewScriptObject" title="en/JS_NewScriptObject">JS_NewScriptObject</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ExecuteScript" title="en/JS_ExecuteScript">JS_ExecuteScript</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ExecuteScriptPart" title="en/JS_ExecuteScriptPart">JS_ExecuteScriptPart</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DecompileScript" title="en/JS_DecompileScript">JS_DecompileScript</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DestroyScript" title="en/JS_DestroyScript">JS_DestroyScript</a></li>
+</ul>
+<p>You can also compile JavaScript code into a function:</p>
+<ul>
+ <li>typedef <a href="/en/JSFunction" title="en/JSFunction">JSFunction</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CompileFunction" title="en/JS_CompileFunction">JS_CompileFunction</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CompileFunctionForPrincipals" title="en/JS_CompileFunctionForPrincipals">JS_CompileFunctionForPrincipals</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CompileFunction" title="en/JS_CompileFunction">JS_CompileUCFunction</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CompileFunctionForPrincipals" title="en/JS_CompileFunctionForPrincipals">JS_CompileUCFunctionForPrincipals</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DecompileFunction" title="en/JS_DecompileFunction">JS_DecompileFunction</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DecompileFunctionBody" title="en/JS_DecompileFunctionBody">JS_DecompileFunctionBody</a></li>
+</ul>
+<p> </p>
+<h3 id="Error_handling" name="Error_handling">错误处理</h3>
+<ul>
+ <li>struct <a href="/en/SpiderMonkey/JSAPI_Reference/JSErrorReport" title="en/JSErrorReport">JSErrorReport</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ReportError" title="en/JS_ReportError">JS_ReportError</a></li>
+ <li><a href="/en/JS_ReportWarning" title="en/JS_ReportWarning">JS_ReportWarning</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ReportErrorNumber" title="en/JS_ReportErrorNumber">JS_ReportErrorNumber</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_ReportErrorNumber" title="en/JS_ReportErrorNumber">JS_ReportErrorNumberUC</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_ReportErrorNumber" title="en/JS_ReportErrorNumber">JS_ReportErrorFlagsAndNumber</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_ReportErrorNumber" title="en/JS_ReportErrorNumber">JS_ReportErrorFlagsAndNumberUC</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ReportOutOfMemory" title="en/JS_ReportOutOfMemory">JS_ReportOutOfMemory</a></li>
+ <li><a class="internal" href="/cn/SpiderMonkey/JSAPI%20%E5%8F%82%E8%80%83/JS_%20SetErrorReporter" title="cn/SpiderMonkey/JSAPI 参考/JS SetErrorReporter">JS_SetErrorReporter</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSREPORT_IS_EXCEPTION" title="en/JSREPORT_IS_EXCEPTION">JSREPORT_IS_EXCEPTION</a></li>
+ <li><a href="/en/JSREPORT_IS_STRICT" title="en/JSREPORT_IS_STRICT">JSREPORT_IS_STRICT</a></li>
+ <li><a href="/en/JSREPORT_IS_WARNING" title="en/JSREPORT_IS_WARNING">JSREPORT_IS_WARNING</a></li>
+</ul>
+<p>The following functions allow C/C++ functions to throw and catch JavaScript exceptions:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_IsExceptionPending" title="en/JS_IsExceptionPending">JS_IsExceptionPending</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPendingException" title="en/JS_GetPendingException">JS_GetPendingException</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetPendingException" title="en/JS_SetPendingException">JS_SetPendingException</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ClearPendingException" title="en/JS_ClearPendingException">JS_ClearPendingException</a></li>
+ <li><a href="/en/JS_ThrowStopIteration" title="en/JS_ThrowStopIteration">JS_ThrowStopIteration</a></li>
+</ul>
+<ul>
+ <li>typedef <a href="/en/SpiderMonkey/JSAPI_Reference/JSExceptionState" title="en/JSExceptionState">JSExceptionState</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SaveExceptionState" title="en/JS_SaveExceptionState">JS_SaveExceptionState</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_RestoreExceptionState" title="en/JS_RestoreExceptionState">JS_RestoreExceptionState</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DropExceptionState" title="en/JS_DropExceptionState">JS_DropExceptionState</a></li>
+</ul>
+<p>These functions translate errors into exceptions and vice versa:</p>
+<ul>
+ <li><a href="/en/JS_ReportPendingException" title="en/JS_ReportPendingException">JS_ReportPendingException</a></li>
+ <li><a href="/en/JS_ErrorFromException" title="en/JS_ErrorFromException">JS_ErrorFromException</a></li>
+ <li><a href="/en/JS_ThrowReportedError" title="en/JS_ThrowReportedError">JS_ThrowReportedError</a></li>
+</ul>
+<h3 id="Values_and_types" name="Values_and_types">值和类型</h3>
+<ul>
+ <li>typedef <a href="/En/SpiderMonkey/JSAPI_Reference/Jsval" title="en/jsval">jsval</a></li>
+</ul>
+<p><code>jsval</code> constants:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_NULL" title="en/JSVAL_NULL">JSVAL_NULL</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_VOID" title="en/JSVAL_VOID">JSVAL_VOID</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_TRUE" title="en/JSVAL_TRUE">JSVAL_TRUE</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_TRUE" title="en/JSVAL_TRUE">JSVAL_FALSE</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_ZERO" title="en/JSVAL_ZERO">JSVAL_ZERO</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_ONE" title="en/JSVAL_ONE">JSVAL_ONE</a></li>
+</ul>
+<p>Function and macros for checking the type of a <code>jsval</code>:</p>
+<ul>
+ <li>enum <a href="/en/SpiderMonkey/JSAPI_Reference/JSType" title="en/JSType">JSType</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_TypeOfValue" title="en/JS_TypeOfValue">JS_TypeOfValue</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_IS_NULL" title="en/JSVAL_IS_NULL">JSVAL_IS_NULL</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_IS_VOID" title="en/JSVAL_IS_VOID">JSVAL_IS_VOID</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_IS_BOOLEAN" title="en/JSVAL_IS_BOOLEAN">JSVAL_IS_BOOLEAN</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_IS_NUMBER" title="en/JSVAL_IS_NUMBER">JSVAL_IS_NUMBER</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_IS_INT" title="en/JSVAL_IS_INT">JSVAL_IS_INT</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_IS_DOUBLE" title="en/JSVAL_IS_DOUBLE">JSVAL_IS_DOUBLE</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_IS_STRING" title="en/JSVAL_IS_STRING">JSVAL_IS_STRING</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_IS_OBJECT" title="en/JSVAL_IS_OBJECT">JSVAL_IS_OBJECT</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_IS_PRIMITIVE" title="en/JSVAL_IS_PRIMITIVE">JSVAL_IS_PRIMITIVE</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_IS_GCTHING" title="en/JSVAL_IS_GCTHING">JSVAL_IS_GCTHING</a></li>
+</ul>
+<p>High-level type-conversion routines for packing and unpacking function arguments.</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_PushArguments" title="en/JS_PushArguments">JS_PushArguments</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_PushArguments" title="en/JS_PushArguments">JS_PushArgumentsVA</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_PopArguments" title="en/JS_PopArguments">JS_PopArguments</a></li>
+</ul>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ConvertArguments" title="en/JS_ConvertArguments">JS_ConvertArguments</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ConvertArgumentsVA" title="en/JS_ConvertArgumentsVA">JS_ConvertArgumentsVA</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_AddArgumentFormatter" title="en/JS_AddArgumentFormatter">JS_AddArgumentFormatter</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_AddArgumentFormatter" title="en/JS_AddArgumentFormatter">JS_RemoveArgumentFormatter</a></li>
+</ul>
+<p>The following functions convert JS values to various types. They can be safely applied to <code>jsval</code>s of any type. They may return new objects. For example, <code>JS_ValueToObject(cx, s)</code> where <code>s</code> is a string creates a new <code>String</code> wrapper object. These functions may call JavaScript methods. For example, <code>JS_ValueToString(cx, obj)</code> may call <code>obj.toString()</code>.</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToBoolean" title="en/JS_ValueToBoolean">JS_ValueToBoolean</a></li>
+ <li><a href="/en/JS_ValueToConstructor" title="en/JS_ValueToConstructor">JS_ValueToConstructor</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToECMAInt32" title="en/JS_ValueToECMAInt32">JS_ValueToECMAInt32</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToECMAInt32" title="en/JS_ValueToECMAInt32">JS_ValueToECMAUint32</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToFunction" title="en/JS_ValueToFunction">JS_ValueToFunction</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToInt32" title="en/JS_ValueToInt32">JS_ValueToInt32</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToNumber" title="en/JS_ValueToNumber">JS_ValueToNumber</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToObject" title="en/JS_ValueToObject">JS_ValueToObject</a></li>
+ <li><a class="internal" href="/cn/SpiderMonkey/JSAPI%20%E5%8F%82%E8%80%83/JS%20ValueToString" title="cn/SpiderMonkey/JSAPI 参考/JS ValueToString">JS_ValueToString</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToECMAInt32" title="en/JS_ValueToECMAInt32">JS_ValueToUint16</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ConvertValue" title="en/JS_ConvertValue">JS_ConvertValue</a></li>
+</ul>
+<p>Fast, unchecked type-casting macros. These macros must not be applied to values that are not known to be the right type. Like C casts, they may cause crashes if applied to incorrect values. They never create new objects or call into JavaScript code.</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_TO_BOOLEAN" title="en/JSVAL_TO_BOOLEAN">JSVAL_TO_BOOLEAN</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/BOOLEAN_TO_JSVAL" title="en/BOOLEAN_TO_JSVAL">BOOLEAN_TO_JSVAL</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_TO_INT" title="en/JSVAL_TO_INT">JSVAL_TO_INT</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/INT_TO_JSVAL" title="en/INT_TO_JSVAL">INT_TO_JSVAL</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/INT_FITS_IN_JSVAL" title="en/INT_FITS_IN_JSVAL">INT_FITS_IN_JSVAL</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_TO_DOUBLE" title="en/JSVAL_TO_DOUBLE">JSVAL_TO_DOUBLE</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/DOUBLE_TO_JSVAL" title="en/DOUBLE_TO_JSVAL">DOUBLE_TO_JSVAL</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_TO_OBJECT" title="en/JSVAL_TO_OBJECT">JSVAL_TO_OBJECT</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/OBJECT_TO_JSVAL" title="en/OBJECT_TO_JSVAL">OBJECT_TO_JSVAL</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_TO_STRING" title="en/JSVAL_TO_STRING">JSVAL_TO_STRING</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/STRING_TO_JSVAL" title="en/STRING_TO_JSVAL">STRING_TO_JSVAL</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_TO_GCTHING" title="en/JSVAL_TO_GCTHING">JSVAL_TO_GCTHING</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/PRIVATE_TO_JSVAL" title="en/PRIVATE_TO_JSVAL">JSVAL_TO_PRIVATE</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/PRIVATE_TO_JSVAL" title="en/PRIVATE_TO_JSVAL">PRIVATE_TO_JSVAL</a></li>
+</ul>
+<p>And:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetTypeName" title="en/JS_GetTypeName">JS_GetTypeName</a></li>
+</ul>
+<h3 id="Memory_management" name="Memory_management">Memory management</h3>
+<p>These functions act like the Standard C <code>malloc</code> family of functions, except that errors are reported using the SpiderMonkey error APIs rather than <code>errno</code>. These functions also allow SpiderMonkey to account the number of bytes allocated:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_malloc" title="en/JS_malloc">JS_malloc</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_free" title="en/JS_free">JS_free</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_realloc" title="en/JS_realloc">JS_realloc</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_strdup" title="en/JS_strdup">JS_strdup</a></li>
+</ul>
+<p>JavaScript objects, strings, and floating-point numbers are garbage collected. These functions provide access to the garbage collector:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GC" title="en/JS_GC">JS_GC</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_MaybeGC" title="en/JS_MaybeGC">JS_MaybeGC</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCParameter" title="en/JS_SetGCParameter">JS_SetGCParameter</a>, enum <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCParameter" title="en/JS_SetGCParameter">JSGCParamKey</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCParameter" title="en/JS_SetGCParameter">JSGC_MAX_BYTES</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCParameter" title="en/JS_SetGCParameter">JSGC_MAX_MALLOC_BYTES</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCParameter" title="en/JS_SetGCParameter">JSGC_STACKPOOL_LIFESPAN</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCCallback" title="en/JS_SetGCCallback">JS_SetGCCallback</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCCallback" title="en/JS_SetGCCallback">JS_SetGCCallbackRT</a>, enum <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCCallback" title="en/JS_SetGCCallback">JSGCStatus</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCCallback" title="en/JS_SetGCCallback">JSGC_BEGIN</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCCallback" title="en/JS_SetGCCallback">JSGC_MARK_END</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCCallback" title="en/JS_SetGCCallback">JSGC_FINALIZE_END</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCCallback" title="en/JS_SetGCCallback">JSGC_END</a></li>
+ <li><a href="/en/JS_MarkGCThing" title="en/JS_MarkGCThing">JS_MarkGCThing</a></li>
+ <li><a href="/en/JS_IsAboutToBeFinalized" title="en/JS_IsAboutToBeFinalized">JS_IsAboutToBeFinalized</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ClearNewbornRoots" title="en/JS_ClearNewbornRoots">JS_ClearNewbornRoots</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCZeal" title="en/JS_SetGCZeal">JS_SetGCZeal</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DumpHeap" title="en/JS_DumpHeap">JS_DumpHeap</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+</ul>
+<p>The rest of these APIs help protect objects from being destroyed by the garbage collector before the application is done using them.</p>
+<p>If a variable is a <em>root</em>, then anything it points to will not be freed by the garbage collector. Failure to root objects is a very common cause of mysterious crashes.</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_AddRoot" title="en/JS_AddRoot">JS_AddRoot</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_AddRoot" title="en/JS_AddRoot">JS_AddNamedRoot</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_AddRoot" title="en/JS_AddRoot">JS_AddNamedRootRT</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_RemoveRoot" title="en/JS_RemoveRoot">JS_RemoveRoot</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_RemoveRootRT" title="en/JS_RemoveRootRT">JS_RemoveRootRT</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_MapGCRoots" title="en/JS_MapGCRoots">JS_MapGCRoots</a>, <a href="/en/JSGCMapRootFun" title="en/JSGCMapRootFun">JSGCMapRootFun</a> – <a href="/en/JS_MAP_GCROOT_NEXT" title="en/JS_MAP_GCROOT_NEXT">JS_MAP_GCROOT_NEXT</a>, <a href="/en/JS_MAP_GCROOT_REMOVE" title="en/JS_MAP_GCROOT_REMOVE">JS_MAP_GCROOT_REMOVE</a>, <a href="/en/JS_MAP_GCROOT_STOP" title="en/JS_MAP_GCROOT_STOP">JS_MAP_GCROOT_STOP</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DumpNamedRoots" title="en/JS_DumpNamedRoots">JS_DumpNamedRoots</a></li>
+</ul>
+<p>Local root scopes are another way of protecting objects from the garbage collector.</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_EnterLocalRootScope" title="en/JS_EnterLocalRootScope">JS_EnterLocalRootScope</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_LeaveLocalRootScope" title="en/JS_LeaveLocalRootScope">JS_LeaveLocalRootScope</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_LeaveLocalRootScopeWithResult" title="en/JS_LeaveLocalRootScopeWithResult">JS_LeaveLocalRootScopeWithResult</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ForgetLocalRoot" title="en/JS_ForgetLocalRoot">JS_ForgetLocalRoot</a></li>
+</ul>
+<p>{{ Jsapi_minversion_inline("1.8 (not yet released)") }} If an object contains references to other GC things that are not stored in SpiderMonkey data structures ("slots"), it must implement the <code><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.mark" title="en/JSClass.mark">JSTraceOp</a></code> hook to enable the garbage collector to traverse those references. Otherwise the garbage collector will not find all reachable objects and may collect objects that are still reachable, leading to a crash. (In SpiderMonkey 1.7 and earlier, the <code>JSMarkOp</code> hook is used instead. This will be deprecated when SpiderMonkey 1.8 is released.)</p>
+<p>The tracing APIs are used by the garbage collector and <code>JSTraceOp</code> hooks. JSAPI applications may also use them to examine the object graph. (For example, these APIs support very smooth integration between the JS garbage collector and other garbage collectors.)</p>
+<ul>
+ <li><a href="/en/JSVAL_IS_TRACEABLE" title="en/JSVAL_IS_TRACEABLE">JSVAL_IS_TRACEABLE</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/JSVAL_TO_TRACEABLE" title="en/JSVAL_TO_TRACEABLE">JSVAL_TO_TRACEABLE</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/JSVAL_TRACE_KIND" title="en/JSVAL_TRACE_KIND">JSVAL_TRACE_KIND</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li>struct <a href="/en/JSTracer" title="en/JSTracer">JSTracer</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_TRACER_INIT" title="en/JS_TRACER_INIT">JS_TRACER_INIT</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/JS_CallTracer" title="en/JS_CallTracer">JS_CallTracer</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SET_TRACING_DETAILS" title="en/JS_SET_TRACING_DETAILS">JS_SET_TRACING_DETAILS</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/JS_SET_TRACING_INDEX" title="en/JS_SET_TRACING_INDEX">JS_SET_TRACING_INDEX</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/JS_SET_TRACING_NAME" title="en/JS_SET_TRACING_NAME">JS_SET_TRACING_NAME</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/JS_CALL_TRACER" title="en/JS_CALL_TRACER">JS_CALL_TRACER</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/JS_CALL_VALUE_TRACER" title="en/JS_CALL_VALUE_TRACER">JS_CALL_VALUE_TRACER</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/JS_CALL_OBJECT_TRACER" title="en/JS_CALL_OBJECT_TRACER">JS_CALL_OBJECT_TRACER</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/JS_CALL_STRING_TRACER" title="en/JS_CALL_STRING_TRACER">JS_CALL_STRING_TRACER</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/JS_CALL_DOUBLE_TRACER" title="en/JS_CALL_DOUBLE_TRACER">JS_CALL_DOUBLE_TRACER</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/JS_TraceChildren" title="en/JS_TraceChildren">JS_TraceChildren</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/JS_TraceRuntime" title="en/JS_TraceRuntime">JS_TraceRuntime</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/JS_PrintTraceThingInfo" title="en/JS_PrintTraceThingInfo">JS_PrintTraceThingInfo</a> (DEBUG-only) {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+</ul>
+<p>Miscellaneous GC APIs:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_LOCK" title="en/JSVAL_LOCK">JSVAL_LOCK</a> {{ Deprecated_inline() }}</li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSVAL_UNLOCK" title="en/JSVAL_UNLOCK">JSVAL_UNLOCK</a> {{ Deprecated_inline() }}</li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_LockGCThing" title="en/JS_LockGCThing">JS_LockGCThing</a> {{ Deprecated_inline() }}</li>
+ <li><a href="/en/JS_LockGCThingRT" title="en/JS_LockGCThingRT">JS_LockGCThingRT</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_LockGCThing" title="en/JS_LockGCThing">JS_UnlockGCThing</a> {{ Deprecated_inline() }}</li>
+ <li><a href="/en/JS_UnlockGCThingRT" title="en/JS_UnlockGCThingRT">JS_UnlockGCThingRT</a></li>
+</ul>
+<h3 id="Numbers" name="Numbers">Numbers</h3>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewNumberValue" title="en/JS_NewNumberValue">JS_NewNumberValue</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewDoubleValue" title="en/JS_NewDoubleValue">JS_NewDoubleValue</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewDouble" title="en/JS_NewDouble">JS_NewDouble</a></li>
+ <li>struct <a href="/en/SpiderMonkey/JSAPI_Reference/JSConstDoubleSpec" title="en/JSConstDoubleSpec">JSConstDoubleSpec</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DefineConstDoubles" title="en/JS_DefineConstDoubles">JS_DefineConstDoubles</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetNaNValue" title="en/JS_GetNaNValue">JS_GetNaNValue</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPositiveInfinityValue" title="en/JS_GetPositiveInfinityValue">JS_GetNegativeInfinityValue</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPositiveInfinityValue" title="en/JS_GetPositiveInfinityValue">JS_GetPositiveInfinityValue</a></li>
+</ul>
+<h3 id="Strings" name="Strings">字符串</h3>
+<ul>
+ <li>typedef <a href="/en/SpiderMonkey/JSAPI_Reference/JSString" title="en/JSString">JSString</a></li>
+ <li>typedef <a href="/en/SpiderMonkey/JSAPI_Reference/jschar" title="en/jschar">jschar</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewString" title="en/JS_NewString">JS_NewString</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewStringCopyN" title="en/JS_NewStringCopyN">JS_NewStringCopyN</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewStringCopyZ" title="en/JS_NewStringCopyZ">JS_NewStringCopyZ</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewString" title="en/JS_NewString">JS_NewUCString</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewStringCopyN" title="en/JS_NewStringCopyN">JS_NewUCStringCopyN</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewStringCopyZ" title="en/JS_NewStringCopyZ">JS_NewUCStringCopyZ</a></li>
+ <li><a href="/en/JS_NewGrowableString" title="en/JS_NewGrowableString">JS_NewGrowableString</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewDependentString" title="en/JS_NewDependentString">JS_NewDependentString</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetEmptyStringValue" title="en/JS_GetEmptyStringValue">JS_GetEmptyStringValue</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CompareStrings" title="en/JS_CompareStrings">JS_CompareStrings</a></li>
+ <li><a href="/en/JS_ConcatStrings" title="en/JS_ConcatStrings">JS_ConcatStrings</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetStringBytes" title="en/JS_GetStringBytes">JS_GetStringBytes</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetStringChars" title="en/JS_GetStringChars">JS_GetStringChars</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetStringLength" title="en/JS_GetStringLength">JS_GetStringLength</a></li>
+ <li><a href="/en/JS_MakeStringImmutable" title="en/JS_MakeStringImmutable">JS_MakeStringImmutable</a></li>
+ <li><a href="/en/JS_UndependString" title="en/JS_UndependString">JS_UndependString</a></li>
+</ul>
+<ul>
+ <li><a href="/en/JS_CStringsAreUTF8" title="en/JS_CStringsAreUTF8">JS_CStringsAreUTF8</a></li>
+ <li><a href="/en/JS_SetCStringsAreUTF8" title="en/JS_SetCStringsAreUTF8">JS_SetCStringsAreUTF8</a></li>
+ <li><a href="/en/JS_DecodeBytes" title="en/JS_DecodeBytes">JS_DecodeBytes</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_EncodeCharacters" title="en/JS_EncodeCharacters">JS_EncodeCharacters</a></li>
+ <li><a href="/en/JS_EncodeString" title="en/JS_EncodeString">JS_EncodeString</a></li>
+</ul>
+<p><em>Interning</em> strings tells the SpiderMonkey engine to reuse existing string objects when possible.</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_InternString" title="en/JS_InternString">JS_InternString</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_InternString" title="en/JS_InternString">JS_InternUCString</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_InternString" title="en/JS_InternString">JS_InternUCStringN</a></li>
+</ul>
+<p>The character data for <em>external strings</em> is stored in memory provided by the application. Applications can use this to avoid copying data back and forth between SpiderMonkey's heap and application memory.</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_AddExternalStringFinalizer" title="en/JS_AddExternalStringFinalizer">JS_AddExternalStringFinalizer</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_RemoveExternalStringFinalizer" title="en/JS_RemoveExternalStringFinalizer">JS_RemoveExternalStringFinalizer</a></li>
+ <li><a href="/en/JS_GetExternalStringGCType" title="en/JS_GetExternalStringGCType">JS_GetExternalStringGCType</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewExternalString" title="en/JS_NewExternalString">JS_NewExternalString</a></li>
+</ul>
+<h3 id="Objects" name="Objects">对象</h3>
+<ul>
+ <li>typedef <a href="/en/SpiderMonkey/JSAPI_Reference/JSObject" title="en/JSObject">JSObject</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ConstructObject" title="en/JS_ConstructObject">JS_ConstructObject</a></li>
+ <li><a href="/en/JS_ConstructObjectWithArguments" title="en/JS_ConstructObjectWithArguments">JS_ConstructObjectWithArguments</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DefineObject" title="en/JS_DefineObject">JS_DefineObject</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewObject" title="en/JS_NewObject">JS_NewObject</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewObject" title="en/JS_NewObject">JS_NewObjectWithGivenProto</a></li>
+</ul>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GET_CLASS" title="en/JS_GET_CLASS">JS_GET_CLASS</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GET_CLASS" title="en/JS_GET_CLASS">JS_GetClass</a></li>
+ <li><a href="/en/JS_GetClassObject" title="en/JS_GetClassObject">JS_GetClassObject</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetConstructor" title="en/JS_GetConstructor">JS_GetConstructor</a></li>
+ <li><a href="/en/JS_GetGlobalForObject" title="en/JS_GetGlobalForObject">JS_GetGlobalForObject</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetInstancePrivate" title="en/JS_GetInstancePrivate">JS_GetInstancePrivate</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetParent" title="en/JS_GetParent">JS_GetParent</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetParent" title="en/JS_SetParent">JS_SetParent</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPrivate" title="en/JS_GetPrivate">JS_GetPrivate</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetPrivate" title="en/JS_SetPrivate">JS_SetPrivate</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPrototype" title="en/JS_GetPrototype">JS_GetPrototype</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetPrototype" title="en/JS_SetPrototype">JS_SetPrototype</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetReservedSlot" title="en/JS_GetReservedSlot">JS_GetReservedSlot</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetReservedSlot" title="en/JS_GetReservedSlot">JS_SetReservedSlot</a></li>
+ <li><a href="/en/JS_HasInstance" title="en/JS_HasInstance">JS_HasInstance</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_InstanceOf" title="en/JS_InstanceOf">JS_InstanceOf</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SealObject" title="en/JS_SealObject">JS_SealObject</a></li>
+</ul>
+<h3 id="Properties" name="Properties">属性</h3>
+<p>These functions correspond directly to the ways scripts access object properties:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetProperty" title="en/JS_GetProperty">JS_GetProperty</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetProperty" title="en/JS_GetProperty">JS_GetUCProperty</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetProperty" title="en/JS_SetProperty">JS_SetProperty</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetProperty" title="en/JS_SetProperty">JS_SetUCProperty</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_HasProperty" title="en/JS_HasProperty">JS_HasProperty</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_HasProperty" title="en/JS_HasProperty">JS_HasUCProperty</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DeleteProperty" title="en/JS_DeleteProperty">JS_DeleteProperty</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_DeleteProperty2" title="en/JS_DeleteProperty2">JS_DeleteProperty2</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_DeleteProperty2" title="en/JS_DeleteProperty2">JS_DeleteUCProperty2</a></li>
+</ul>
+<p>The following functions are lower-level, allowing the JSAPI application more access to details of how properties are implemented. "Define" is a lower-level version of "set" that provides access to extra settings and does not call setters. Similarly, "lookup" is a lower-level version of "get" that offers extra options and does not call getters.</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_AlreadyHasOwnProperty" title="en/JS_AlreadyHasOwnElement">JS_AlreadyHasOwnElement</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_AlreadyHasOwnProperty" title="en/JS_AlreadyHasOwnProperty">JS_AlreadyHasOwnProperty</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_AlreadyHasOwnProperty" title="en/JS_AlreadyHasOwnProperty">JS_AlreadyHasOwnUCProperty</a> {{ Jsapi_minversion_inline("1.8 (not yet released)") }}</li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ClearScope" title="en/JS_ClearScope">JS_ClearScope</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DefineProperties" title="en/JS_DefineProperties">JS_DefineProperties</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DefineProperty" title="en/JS_DefineProperty">JS_DefineProperty</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_DefineProperty" title="en/JS_DefineProperty">JS_DefineUCProperty</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DefinePropertyWithTinyId" title="en/JS_DefinePropertyWithTinyId">JS_DefinePropertyWithTinyId</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_DefinePropertyWithTinyId" title="en/JS_DefinePropertyWithTinyId">JS_DefineUCPropertyWithTinyId</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_Enumerate" title="en/JS_Enumerate">JS_Enumerate</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPropertyAttributes" title="en/JS_GetPropertyAttributes">JS_GetPropertyAttributes</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPropertyAttributes" title="en/JS_GetPropertyAttributes">JS_GetUCPropertyAttributes</a> – <a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPropertyAttributes" title="en/JS_GetPropertyAttributes">JSPROP_ENUMERATE</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPropertyAttributes" title="en/JS_GetPropertyAttributes">JSPROP_EXPORTED</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPropertyAttributes" title="en/JS_GetPropertyAttributes">JSPROP_GETTER</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPropertyAttributes" title="en/JS_GetPropertyAttributes">JSPROP_INDEX</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPropertyAttributes" title="en/JS_GetPropertyAttributes">JSPROP_PERMANENT</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPropertyAttributes" title="en/JS_GetPropertyAttributes">JSPROP_READONLY</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPropertyAttributes" title="en/JS_GetPropertyAttributes">JSPROP_SETTER</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPropertyAttributes" title="en/JS_GetPropertyAttributes">JSPROP_SHARED</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPropertyAttrsGetterAndSetter" title="en/JS_GetPropertyAttrsGetterAndSetter">JS_GetPropertyAttrsGetterAndSetter</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPropertyAttrsGetterAndSetter" title="en/JS_GetPropertyAttrsGetterAndSetter">JS_GetUCPropertyAttrsGetterAndSetter</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_LookupProperty" title="en/JS_LookupProperty">JS_LookupProperty</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_LookupProperty" title="en/JS_LookupProperty">JS_LookupUCProperty</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_LookupProperty" title="en/JS_LookupProperty">JS_LookupPropertyWithFlags</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewPropertyIterator" title="en/JS_NewPropertyIterator">JS_NewPropertyIterator</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NextProperty" title="en/JS_NextProperty">JS_NextProperty</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetPropertyAttributes" title="en/JS_SetPropertyAttributes">JS_SetPropertyAttributes</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetPropertyAttributes" title="en/JS_SetPropertyAttributes">JS_SetUCPropertyAttributes</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_AliasProperty" title="en/JS_AliasProperty">JS_AliasProperty</a> {{ Deprecated_inline() }}</li>
+</ul>
+<p>The following functions behave like <code>JS_GetProperty</code> except when operating on E4X XML objects.</p>
+<ul>
+ <li><a href="/en/JS_GetMethod" title="en/JS_GetMethod">JS_GetMethod</a>, <a href="/en/JS_GetMethodById" title="en/JS_GetMethodById">JS_GetMethodById</a></li>
+</ul>
+<p>A SpiderMonkey extension allows a native function to return an lvalue—that is, a reference to a property of an object:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetCallReturnValue2" title="en/JS_SetCallReturnValue2">JS_SetCallReturnValue2</a></li>
+</ul>
+<p>A <code><a href="/en/SpiderMonkey/JSAPI_Reference/jsid" title="en/jsid">jsid</a></code> is kind of like a <code>jsval</code>, only different. A handful of APIs use <code>jsid</code>s instead of <code>jsval</code>s for property names: <code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CheckAccess" title="en/JS_CheckAccess">JS_CheckAccess</a></code>, <code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_Enumerate" title="en/JS_Enumerate">JS_Enumerate</a></code>, <code><a href="/en/JS_GetMethodById" title="en/JS_GetMethodById">JS_GetMethodById</a></code>, and <code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NextProperty" title="en/JS_NextProperty">JS_NextProperty</a></code>.</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_IdToValue" title="en/JS_IdToValue">JS_IdToValue</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToId" title="en/JS_ValueToId">JS_ValueToId</a></li>
+ <li><a href="/en/JS_GetObjectId" title="en/JS_GetObjectId">JS_GetObjectId</a></li>
+ <li>struct <a href="/en/SpiderMonkey/JSAPI_Reference/JSIdArray" title="en/JSIdArray">JSIdArray</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DestroyIdArray" title="en/JS_DestroyIdArray">JS_DestroyIdArray</a></li>
+</ul>
+<h3 id="Classes" name="Classes">Classes</h3>
+<p>These API features are used to define custom classes—object types that are implemented in C/C++ code but accessible from JavaScript.</p>
+<ul>
+ <li>struct <a href="/en/SpiderMonkey/JSAPI_Reference/JSClass" title="en/JSClass">JSClass</a></li>
+ <li>struct <a href="/en/SpiderMonkey/JSAPI_Reference/JSExtendedClass" title="en/JSExtendedClass">JSExtendedClass</a></li>
+ <li>struct <a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps" title="en/JSObjectOps">JSObjectOps</a></li>
+ <li>struct <a href="/en/SpiderMonkey/JSAPI_Reference/JSXMLObjectOps" title="en/JSXMLObjectOps">JSXMLObjectOps</a></li>
+ <li>struct <a href="/en/JSFunctionSpec" title="en/JSFunctionSpec">JSFunctionSpec</a></li>
+ <li>struct <a href="/en/SpiderMonkey/JSAPI_Reference/JSProperty" title="en/JSProperty">JSProperty</a></li>
+ <li>struct <a href="/en/SpiderMonkey/JSAPI_Reference/JSPropertySpec" title="en/JSPropertySpec">JSPropertySpec</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_InitClass" title="en/JS_InitClass">JS_InitClass</a></li>
+</ul>
+<p>Adding native properties and methods to classes:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSNative" title="en/JSNative">JSNative</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSFastNative" title="en/JSFastNative">JSFastNative</a></li>
+ <li>struct <a href="/en/JSFunctionSpec" title="en/JSFunctionSpec">JSFunctionSpec</a></li>
+ <li><a href="/en/JS_FS" title="en/JS_FS">JS_FS</a></li>
+ <li><a href="/en/JS_FN" title="en/JS_FN">JS_FN</a></li>
+ <li><a href="/en/JS_FS_END" title="en/JS_FS_END">JS_FS_END</a></li>
+ <li>struct <a href="/en/SpiderMonkey/JSAPI_Reference/JSPropertySpec" title="en/JSPropertySpec">JSPropertySpec</a></li>
+</ul>
+<p><code>JSFastNative</code> methods use these macros:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSFastNative" title="en/JSFastNative">JS_CALLEE</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSFastNative" title="en/JSFastNative">JS_THIS</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSFastNative" title="en/JSFastNative">JS_THIS_OBJECT</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSFastNative" title="en/JSFastNative">JS_ARGV</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSFastNative" title="en/JSFastNative">JS_RVAL</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSFastNative" title="en/JSFastNative">JS_SET_RVAL</a></li>
+</ul>
+<p>The behavior of a <code>JSClass</code> and its instances can be customized in many ways using callback functions.</p>
+<p><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass" title="en/JSClass">JSClass</a> method types:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.addProperty" title="en/JSClass.addProperty">JSPropertyOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSEnumerateOp" title="en/JSEnumerateOp">JSEnumerateOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.enumerate" title="en/JSClass.enumerate">JSNewEnumerateOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.resolve" title="en/JSClass.resolve">JSResolveOp</a></li>
+ <li><a href="/En/SpiderMonkey/JSAPI_Reference/JSNewResolveOp" title="en/JSNewResolveOp">JSNewResolveOp</a> – <a href="/En/SpiderMonkey/JSAPI_Reference/JSNewResolveOp" title="en/JSNewResolveOp">JSRESOLVE_ASSIGNING</a>, <a href="/En/SpiderMonkey/JSAPI_Reference/JSNewResolveOp" title="en/JSNewResolveOp">JSRESOLVE_CLASSNAME</a>, <a href="/En/SpiderMonkey/JSAPI_Reference/JSNewResolveOp" title="en/JSNewResolveOp">JSRESOLVE_DECLARING</a>, <a href="/En/SpiderMonkey/JSAPI_Reference/JSNewResolveOp" title="en/JSNewResolveOp">JSRESOLVE_DETECTING</a>, <a href="/En/SpiderMonkey/JSAPI_Reference/JSNewResolveOp" title="en/JSNewResolveOp">JSRESOLVE_QUALIFIED</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps.defaultValue" title="en/JSObjectOps.defaultValue">JSConvertOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.finalize" title="en/JSClass.finalize">JSFinalizeOp</a></li>
+ <li><a href="/en/JSClass.getObjectOps" title="en/JSClass.getObjectOps">JSGetObjectOps</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.checkAccess" title="en/JSClass.checkAccess">JSCheckAccessOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.xdrObject" title="en/JSClass.xdrObject">JSXDRObjectOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.hasInstance" title="en/JSClass.hasInstance">JSHasInstanceOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.mark" title="en/JSClass.mark">JSMarkOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSTraceOp" title="en/JSTraceOp">JSTraceOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.reserveSlots" title="en/JSClass.reserveSlots">JSReserveSlotsOp</a></li>
+</ul>
+<p><a href="/en/SpiderMonkey/JSAPI_Reference/JSExtendedClass" title="en/JSExtendedClass">JSExtendedClass</a> method types:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSExtendedClass.iteratorObject" title="en/JSExtendedClass.iteratorObject">JSIteratorOp</a></li>
+ <li><a href="/en/JSEqualityOp" title="en/JSEqualityOp">JSEqualityOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOp" title="en/JSObjectOp">JSObjectOp</a></li>
+</ul>
+<p><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps" title="en/JSObjectOps">JSObjectOps</a> method types:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps.newObjectMap" title="en/JSObjectOps.newObjectMap">JSNewObjectMapOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps.destroyObjectMap" title="en/JSObjectOps.destroyObjectMap">JSObjectMapOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps.lookupProperty" title="en/JSObjectOps.lookupProperty">JSLookupPropOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps.defineProperty" title="en/JSObjectOps.defineProperty">JSDefinePropOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps.getProperty" title="en/JSObjectOps.getProperty">JSPropertyIdOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps.getAttributes" title="en/JSObjectOps.getAttributes">JSAttributesOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps.defaultValue" title="en/JSObjectOps.defaultValue">JSConvertOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.enumerate" title="en/JSClass.enumerate">JSNewEnumerateOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps.checkAccess" title="en/JSObjectOps.checkAccess">JSCheckAccessIdOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOp" title="en/JSObjectOp">JSObjectOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps.dropProperty" title="en/JSObjectOps.dropProperty">JSPropertyRefOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.xdrObject" title="en/JSClass.xdrObject">JSXDRObjectOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.hasInstance" title="en/JSClass.hasInstance">JSHasInstanceOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps.setProto" title="en/JSObjectOps.setProto">JSSetObjectSlotOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSTraceOp" title="en/JSTraceOp">JSTraceOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.finalize" title="en/JSClass.finalize">JSFinalizeOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps.getRequiredSlot" title="en/JSObjectOps.getRequiredSlot">JSGetRequiredSlotOp</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps.getRequiredSlot" title="en/JSObjectOps.getRequiredSlot">JSSetRequiredSlotOp</a></li>
+</ul>
+<p><a href="/en/SpiderMonkey/JSAPI_Reference/JSXMLObjectOps" title="en/JSXMLObjectOps">JSXMLObjectOps</a> method types:</p>
+<ul>
+ <li><a href="/en/JSGetMethodOp" title="en/JSGetMethodOp">JSGetMethodOp</a></li>
+ <li><a href="/en/JSSetMethodOp" title="en/JSSetMethodOp">JSSetMethodOp</a></li>
+ <li><a href="/en/JSEnumerateValuesOp" title="en/JSEnumerateValuesOp">JSEnumerateValuesOp</a></li>
+ <li><a href="/en/JSEqualityOp" title="en/JSEqualityOp">JSEqualityOp</a></li>
+ <li><a href="/en/JSConcatenateOp" title="en/JSConcatenateOp">JSConcatenateOp</a></li>
+</ul>
+<p>These stub functions can be used when creating a custom <code>JSClass</code>:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_PropertyStub" title="en/JS_PropertyStub">JS_ConvertStub</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_PropertyStub" title="en/JS_PropertyStub">JS_EnumerateStub</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_PropertyStub" title="en/JS_PropertyStub">JS_FinalizeStub</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_PropertyStub" title="en/JS_PropertyStub">JS_PropertyStub</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_PropertyStub" title="en/JS_PropertyStub">JS_ResolveStub</a></li>
+</ul>
+<p>The behavior of a <code>JSClass</code> can be customized using these flags:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.flags" title="en/JSClass.flags">JSClass.flags</a> – <a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.flags" title="en/JSClass.flags">JSCLASS_CONSTUCT_PROTOTYPE</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.flags" title="en/JSClass.flags">JSCLASS_GLOBAL_FLAGS</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.flags" title="en/JSClass.flags">JSCLASS_HAS_PRIVATE</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.flags" title="en/JSClass.flags">JSCLASS_HAS_RESERVED_SLOTS</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.flags" title="en/JSClass.flags">JSCLASS_IS_EXTENDED</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.flags" title="en/JSClass.flags">JSCLASS_MARK_IS_TRACE</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.flags" title="en/JSClass.flags">JSCLASS_NEW_ENUMERATE</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.flags" title="en/JSClass.flags">JSCLASS_NEW_RESOLVE</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.flags" title="en/JSClass.flags">JSCLASS_NEW_RESOLVE_GETS_START</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.flags" title="en/JSClass.flags">JSCLASS_PRIVATE_IS_NSISUPPORTS</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.flags" title="en/JSClass.flags">JSCLASS_SHARE_ALL_PROPERTIES</a></li>
+</ul>
+<h3 id="Arrays" name="Arrays">Arrays</h3>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewArrayObject" title="en/JS_NewArrayObject">JS_NewArrayObject</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_IsArrayObject" title="en/JS_IsArrayObject">JS_IsArrayObject</a></li>
+</ul>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_HasArrayLength" title="en/JS_HasArrayLength">JS_HasArrayLength</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetArrayLength" title="en/JS_GetArrayLength">JS_GetArrayLength</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetArrayLength" title="en/JS_SetArrayLength">JS_SetArrayLength</a></li>
+</ul>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_AliasElement" title="en/JS_AliasElement">JS_AliasElement</a> {{ Deprecated_inline() }}</li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DefineElement" title="en/JS_DefineElement">JS_DefineElement</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DeleteElement" title="en/JS_DeleteElement">JS_DeleteElement</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DeleteElement2" title="en/JS_DeleteElement2">JS_DeleteElement2</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetElement" title="en/JS_GetElement">JS_GetElement</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_LookupElement" title="en/JS_LookupElement">JS_LookupElement</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetElement" title="en/JS_SetElement">JS_SetElement</a></li>
+</ul>
+<h3 id="Functions" name="Functions">Functions</h3>
+<p>Calling a function or a method of an object:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CallFunction" title="en/JS_CallFunction">JS_CallFunction</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CallFunctionName" title="en/JS_CallFunctionName">JS_CallFunctionName</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CallFunctionValue" title="en/JS_CallFunctionValue">JS_CallFunctionValue</a></li>
+</ul>
+<p>Function accessors:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ObjectIsFunction" title="en/JS_ObjectIsFunction">JS_ObjectIsFunction</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetFunctionArity" title="en/JS_GetFunctionArity">JS_GetFunctionArity</a></li>
+ <li><a href="/en/JS_GetFunctionFlags" title="en/JS_GetFunctionFlags">JS_GetFunctionFlags</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetFunctionId" title="en/JS_GetFunctionId">JS_GetFunctionId</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetFunctionName" title="en/JS_GetFunctionName">JS_GetFunctionName</a> {{ Deprecated_inline() }}</li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetFunctionObject" title="en/JS_GetFunctionObject">JS_GetFunctionObject</a></li>
+</ul>
+<p>Creating functions:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CloneFunctionObject" title="en/JS_CloneFunctionObject">JS_CloneFunctionObject</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DefineFunction" title="en/JS_DefineFunction">JS_DefineFunction</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_DefineFunction" title="en/JS_DefineFunction">JS_DefineUCFunction</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DefineFunctions" title="en/JS_DefineFunctions">JS_DefineFunctions</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewFunction" title="en/JS_NewFunction">JS_NewFunction</a></li>
+</ul>
+<h3 id="RegExps" name="RegExps">RegExps</h3>
+<ul>
+ <li><a href="/En/SpiderMonkey/JSAPI_Reference/JS_NewRegExpObject" title="En/SpiderMonkey/JSAPI_Reference/JS_NewRegExpObject">JS_NewRegExpObject</a></li>
+ <li><a href="/En/SpiderMonkey/JSAPI_Reference/JS_NewRegExpObject" title="En/SpiderMonkey/JSAPI_Reference/JS_NewRegExpObject">JS_NewUCRegExpObject</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetRegExpInput" title="en/SpiderMonkey/JSAPI_Reference/JS_SetRegExpInput">JS_SetRegExpInput</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ClearRegExpRoots" title="en/SpiderMonkey/JSAPI_Reference/JS_ClearRegExpRoots">JS_ClearRegExpRoots</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ClearRegExpStatics" title="en/SpiderMonkey/JSAPI_Reference/JS_ClearRegExpStatics">JS_ClearRegExpStatics</a></li>
+</ul>
+<h3 id="Security" name="Security">Security</h3>
+<ul>
+ <li>struct <a href="/en/SpiderMonkey/JSAPI_Reference/JSPrincipals" title="en/JSPrincipals">JSPrincipals</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSPRINCIPALS_HOLD" title="en/JSPRINCIPALS_HOLD">JSPRINCIPALS_HOLD</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JSPRINCIPALS_HOLD" title="en/JSPRINCIPALS_HOLD">JSPRINCIPALS_DROP</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetObjectPrincipalsFinder" title="en/JS_SetObjectPrincipalsFinder">JS_SetObjectPrincipalsFinder</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetPrincipalsTranscoder" title="en/JS_SetPrincipalsTranscoder">JS_SetPrincipalsTranscoder</a></li>
+</ul>
+<ul>
+ <li>enum <a href="/en/SpiderMonkey/JSAPI_Reference/JS_CheckAccess" title="en/JS_CheckAccess">JSAccessMode</a> – <a href="/en/SpiderMonkey/JSAPI_Reference/JS_CheckAccess" title="en/JS_CheckAccess">JSACC_PROTO</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_CheckAccess" title="en/JS_CheckAccess">JSACC_PARENT</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_CheckAccess" title="en/JS_CheckAccess">JSACC_IMPORT</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_CheckAccess" title="en/JS_CheckAccess">JSACC_WATCH</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_CheckAccess" title="en/JS_CheckAccess">JSACC_READ</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_CheckAccess" title="en/JS_CheckAccess">JSACC_WRITE</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CheckAccess" title="en/JS_CheckAccess">JS_CheckAccess</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps.checkAccess" title="en/JSObjectOps.checkAccess">JSObjectOps.checkAccess</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass.checkAccess" title="en/JSClass.checkAccess">JSClass.checkAccess</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetCheckObjectAccessCallback" title="en/JS_SetCheckObjectAccessCallback">JS_SetCheckObjectAccessCallback</a></li>
+</ul>
+<h3 id="Threading" name="Threading">Threading</h3>
+<p>The following functions support the SpiderMonkey threading model. They are only available in <code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_THREADSAFE" title="en/JS_THREADSAFE">JS_THREADSAFE</a></code> builds.</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_BeginRequest" title="en/JS_BeginRequest">JS_BeginRequest</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_BeginRequest" title="en/JS_BeginRequest">JS_EndRequest</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_YieldRequest" title="en/JS_YieldRequest">JS_YieldRequest</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SuspendRequest" title="en/JS_SuspendRequest">JS_SuspendRequest</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SuspendRequest" title="en/JS_SuspendRequest">JS_ResumeRequest</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetContextThread" title="en/JS_GetContextThread">JS_GetContextThread</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ClearContextThread" title="en/JS_ClearContextThread">JS_SetContextThread</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ClearContextThread" title="en/JS_ClearContextThread">JS_ClearContextThread</a></li>
+</ul>
+<p>The following functions exist in all builds, but in non-<code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_THREADSAFE" title="en/JS_THREADSAFE">JS_THREADSAFE</a></code> builds, they do nothing:</p>
+<ul>
+ <li><a href="/en/JS_LockRuntime" title="en/JS_LockRuntime">JS_LockRuntime</a></li>
+ <li><a href="/en/JS_UnlockRuntime" title="en/JS_UnlockRuntime">JS_UnlockRuntime</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_Lock" title="en/JS_Lock">JS_Lock</a> {{ Deprecated_inline() }}</li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_Unlock" title="en/JS_Unlock">JS_Unlock</a> {{ Deprecated_inline() }}</li>
+</ul>
+<h3 id="Time" name="Time">Time</h3>
+<ul>
+ <li><a href="/en/JS_Now" title="en/JS_Now">JS_Now</a></li>
+</ul>
+<h3 id="Callback_Types" name="Callback_Types">Callback Types</h3>
+<p>Native function types:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSNative" title="en/JSNative">JSNative</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSFastNative" title="en/JSFastNative">JSFastNative</a></li>
+</ul>
+<p>Other callback types:</p>
+<ul>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_AddExternalStringFinalizer" title="en/JS_AddExternalStringFinalizer">JSStringFinalizeOp</a> - used by <a href="/en/SpiderMonkey/JSAPI_Reference/JS_AddExternalStringFinalizer" title="en/JS_AddExternalStringFinalizer">JS_AddExternalStringFinalizer</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_TRACER_INIT" title="en/JS_TRACER_INIT">JSTraceCallback</a> - used by <a href="/en/SpiderMonkey/JSAPI_Reference/JS_TRACER_INIT" title="en/JS_TRACER_INIT">JS_TRACER_INIT</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SET_TRACING_DETAILS" title="en/JS_SET_TRACING_DETAILS">JSTraceNamePrinter</a> - used by <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SET_TRACING_DETAILS" title="en/JS_SET_TRACING_DETAILS">JS_SET_TRACING_DETAILS</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetContextCallback" title="en/JS_SetContextCallback">JSContextCallback</a> - used by <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetContextCallback" title="en/JS_SetContextCallback">JS_SetContextCallback</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCCallback" title="en/JS_SetGCCallback">JSGCCallback</a> - used by <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetGCCallback" title="en/JS_SetGCCallback">JS_SetGCCallback</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetExtraGCRoots" title="en/JS_SetExtraGCRoots">JSTraceDataOp</a> - used by <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetExtraGCRoots" title="en/JS_SetExtraGCRoots">JS_SetExtraGCRoots</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetBranchCallback" title="en/JS_SetBranchCallback">JSBranchCallback</a> - used by <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetBranchCallback" title="en/JS_SetBranchCallback">JS_SetBranchCallback</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetErrorReporter" title="en/JS_SetErrorReporter">JSErrorReporter</a> - used by <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetErrorReporter" title="en/JS_SetErrorReporter">JS_SetErrorReporter</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ReportErrorNumber" title="en/JS_ReportErrorNumber">JSErrorCallback</a> - used by <a href="/en/SpiderMonkey/JSAPI_Reference/JS_ReportErrorNumber" title="en/JS_ReportErrorNumber">JS_ReportErrorNumber</a> and friends</li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_AddArgumentFormatter" title="en/JS_AddArgumentFormatter">JSArgumentFormatter</a> - used by <a href="/en/SpiderMonkey/JSAPI_Reference/JS_AddArgumentFormatter" title="en/JS_AddArgumentFormatter">JS_AddArgumentFormatter</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetPrincipalsTranscoder" title="en/JS_SetPrincipalsTranscoder">JSPrincipalsTranscoder</a> - used by <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetPrincipalsTranscoder" title="en/JS_SetPrincipalsTranscoder">JS_SetPrincipalsTranscoder</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetObjectPrincipalsFinder" title="en/JS_SetObjectPrincipalsFinder">JSObjectPrincipalsFinder</a> - used by <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetObjectPrincipalsFinder" title="en/JS_SetObjectPrincipalsFinder">JS_SetObjectPrincipalsFinder</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_MapGCRoots" title="en/JS_MapGCRoots">JSGCRootMapFun</a> - used by <a href="/en/SpiderMonkey/JSAPI_Reference/JS_MapGCRoots" title="en/JS_MapGCRoots">JS_MapGCRoots</a></li>
+</ul>
+<p>See also <a href="#Classes">Classes</a>, above.</p>
+<h3 id="Macros" name="Macros">Macros</h3>
+<ul>
+ <li><a href="/en/JS_DEFAULT_XML_NAMESPACE_ID" title="en/JS_DEFAULT_XML_NAMESPACE_ID">JS_DEFAULT_XML_NAMESPACE_ID</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSFUN_BOUND_METHOD" title="en/JSFUN_BOUND_METHOD">JSFUN_BOUND_METHOD</a> {{ Deprecated_inline() }}</li>
+ <li><a href="/en/JSFUN_GETTER" title="en/JSFUN_GETTER">JSFUN_GETTER</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JSFUN_GLOBAL_PARENT" title="en/JSFUN_GLOBAL_PARENT">JSFUN_GLOBAL_PARENT</a> {{ Deprecated_inline() }}</li>
+ <li><a href="/en/JSFUN_HEAVYWEIGHT" title="en/JSFUN_HEAVYWEIGHT">JSFUN_HEAVYWEIGHT</a></li>
+ <li><a href="/en/JSFUN_LAMBDA" title="en/JSFUN_LAMBDA">JSFUN_LAMBDA</a></li>
+ <li><a href="/en/JSFUN_SETTER" title="en/JSFUN_SETTER">JSFUN_SETTER</a></li>
+ <li><a href="/en/JSREG_GLOB" title="en/JSREG_GLOB">JSREG_GLOB</a></li>
+ <li><a href="/en/JSREG_FOLD" title="en/JSREG_FOLD">JSREG_FOLD</a></li>
+ <li><a href="/en/JSREG_MULTILINE" title="en/JSREG_MULTILINE">JSREG_MULTILINE</a></li>
+</ul>
+<h3 id="Preprocessor_conditionals" name="Preprocessor_conditionals">Preprocessor conditionals</h3>
+<ul>
+ <li><a href="/en/BUILD_OPT" title="en/BUILD_OPT">BUILD_OPT</a></li>
+ <li><a href="/en/GC_MARK_DEBUG" title="en/GC_MARK_DEBUG">GC_MARK_DEBUG</a></li>
+ <li><a href="/en/SpiderMonkey/JSAPI_Reference/JS_THREADSAFE" title="en/JS_THREADSAFE">JS_THREADSAFE</a></li>
+</ul>
+<p>These defines are useful for tuning SpiderMonkey performance:</p>
+<ul>
+ <li><a href="/en/JS_ARENAMETER" title="en/JS_ARENAMETER">JS_ARENAMETER</a> - Arena package instrumentation.</li>
+ <li><a href="/en/JS_GCMETER" title="en/JS_GCMETER">JS_GCMETER</a> - GC instrumentation.</li>
+ <li><a href="/en/JS_HASHMETER" title="en/JS_HASHMETER">JS_HASHMETER</a> - Hash table package instrumentation.</li>
+</ul>
+<h3 id="C.2B.2B_features" name="C.2B.2B_features">C++ features</h3>
+<ul>
+ <li>class <a href="/en/JSAutoRequest" title="en/JSAutoRequest">JSAutoRequest</a></li>
+ <li>class <a href="/en/JSAutoLocalRootScope" title="en/JSAutoLocalRootScope">JSAutoLocalRootScope</a></li>
+</ul>
+<p>{{ languages( { "ja": "ja/JSAPI_Reference", "pl": "pl/Dokumentacja_JSAPI" } ) }}</p>
+<h1 id="JSAPI_参考">JSAPI 参考</h1>
+<p> </p>
+<h3 id=".E6.95.B0.E6.8D.AE.E7.BB.93.E6.9E.84" name=".E6.95.B0.E6.8D.AE.E7.BB.93.E6.9E.84">数据结构</h3>
+<ul>
+ <li><a href="/cn/JSClass" title="cn/JSClass">JS类</a></li>
+ <li><a href="/cn/JSConstDoubleSpec" title="cn/JSConstDoubleSpec">JSConstDoubleSpec</a></li>
+ <li><a href="/cn/JSErrorReport" title="cn/JSErrorReport">JS错误报告</a></li>
+ <li><a href="/cn/JSFunctionSpec" title="cn/JSFunctionSpec">JS函数规范</a></li>
+ <li><a href="/cn/JSIdArray" title="cn/JSIdArray">JSIdArray</a></li>
+ <li><a href="/cn/JSObjectOps" title="cn/JSObjectOps">JS对象操作</a></li>
+ <li><a href="/cn/JSPrincipals" title="cn/JSPrincipals">JSPrincipals</a></li>
+ <li><a href="/cn/JSProperty" title="cn/JSProperty">JS属性</a></li>
+ <li><a href="/cn/JSPropertySpec" title="cn/JSPropertySpec">JS属性规范</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_defineconstdoubles/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_defineconstdoubles/index.html
new file mode 100644
index 0000000000..82835b714d
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_defineconstdoubles/index.html
@@ -0,0 +1,59 @@
+---
+title: JS DefineConstDoubles
+slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_DefineConstDoubles
+translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_DefineConstDoubles
+---
+<h3 id=".E6.91.98.E8.A6.81" name=".E6.91.98.E8.A6.81">摘要</h3>
+<p>为对象创建一个或多个包含双浮点值的属性。</p>
+<h3 id=".E8.AF.AD.E6.B3.95" name=".E8.AF.AD.E6.B3.95">语法</h3>
+<pre> JSBool JS_DefineConstDoubles(JSContext *cx, JSObject *obj,
+ JSConstDoubleSpec *cds);
+</pre>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>名称</th>
+ <th>类型</th>
+ <th>描述</th>
+ </tr>
+ <tr>
+ <td>cx</td>
+ <td>JSContext *</td>
+ <td>指向JS运行时信息内容的指针。</td>
+ </tr>
+ <tr>
+ <td>obj</td>
+ <td>JSObject *</td>
+ <td>指向新建的属性的对象指针。</td>
+ </tr>
+ <tr>
+ <td>cds</td>
+ <td>JSConstDoubleSpec *</td>
+ <td>指向创建的包含双浮点属性值和属性名的结构化数组的指针。最后一个数组元素必须包含一个为零值的成员。</td>
+ </tr>
+ </tbody>
+</table>
+<h3 id=".E6.8F.8F.E8.BF.B0" name=".E6.8F.8F.E8.BF.B0">描述</h3>
+<p><code>JS_DefineConstDoubles</code>为特定的对象创建一个或多个成员变量,<code>obj</code>, 每个成员变量包含一个双浮点类型的值。每个成员变量在<code>JSConstDoubleSpec</code>结构中的<code>flags</code>字段被自动声名并由<code>cds</code>传递指针。 如果<code>flags</code>被设为<code>0</code>值, 成员变量的属性会自动被设为<code>JSPROP_PERMANENT 或 JSPROP_READONLY</code>。</p>
+<p><code>cds</code> 是一个指向具有<code>JSConstDoubleSpec</code>结构的数组的第一个元素的指针。每个数组元素定义独立的变量名和变量值。数组的最后一个元素的<code>name</code>字段必须是0。<code>JS_DefineConstDoubles</code>为数组中的每一个名称字段不为零的元素建立一个成员变量。</p>
+<p>通常情况下, <code>JS_DefineConstDoubles</code> 返回 <code>JS_TRUE</code>, 表明它在数组中已经建立了所有的属性列表。除此之外的情况下它返回<code>JS_FALSE</code>。</p>
+<h2 id=".E6.9B.B4.E5.A4.9A.E5.8F.82.E8.80.83" name=".E6.9B.B4.E5.A4.9A.E5.8F.82.E8.80.83">更多参考</h2>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <td>新闻组</td>
+ <td><a href="cn/JSAPI_%e5%8f%82%e8%80%83#Functions">Functions</a></td>
+ </tr>
+ <tr>
+ <td>文档</td>
+ <td><a class="external" href="http://lxr.mozilla.org/mozilla/ident?i=JS_DefineConstDoubles">LXRSearch</a></td>
+ </tr>
+ <tr>
+ <td>章节</td>
+ <td>
+ <p><a href="cn/JSConstDoubleSpec">JSConstDoubleSpec</a>, <a href="cn/JS_DefineElement">JS_DefineElement</a>, <a href="cn/JS_DefineFunction">JS_DefineFunction</a>, <a href="cn/JS_DefineFunctions">JS_DefineFunctions</a>, <a href="cn/JS_DefineObject">JS_DefineObject</a>, <a href="cn/JS_DefineProperties">JS_DefineProperties</a>, <a href="cn/JS_DefineProperty">JS_DefineProperty</a>, <a href="cn/JS_DefinePropertyWithTinyId">JS_DefinePropertyWithTinyId</a></p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_doublecolon_call/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_doublecolon_call/index.html
new file mode 100644
index 0000000000..a0c3d1239a
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_doublecolon_call/index.html
@@ -0,0 +1,92 @@
+---
+title: 'JS::Call'
+slug: 'Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS::Call'
+translation_of: 'Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS::Call'
+---
+<div>{{SpiderMonkeySidebar("JSAPI")}}</div>
+
+<div>{{ jsapi_minversion_header("17") }}</div>
+
+
+<div class="summary">
+<p><font><font>调用指定的JS函数。</font></font></p>
+</div>
+
+<h2 id="Syntax" name="Syntax"><font><font>句法</font></font></h2>
+
+<pre class="brush: cpp notranslate">bool
+JS::Call(JSContext *cx, JS::HandleObject thisObj, JS::HandleFunction fun,
+ const JS::HandleValueArray &amp;args, JS::MutableHandleValue rval);
+
+bool
+JS::Call(JSContext *cx, JS::HandleObject thisObj, const char *name,
+ const JS::HandleValueArray&amp; args, JS::MutableHandleValue rval);
+
+bool
+JS::Call(JSContext *cx, JS::HandleObject thisObj, JS::HandleValue fun,
+ const JS::HandleValueArray&amp; args, JS::MutableHandleValue rval);
+
+bool
+JS::Call(JSContext *cx, JS::HandleValue thisv, JS::HandleValue fun,
+ const JS::HandleValueArray&amp; args, JS::MutableHandleValue rval);
+
+bool
+JS::Call(JSContext *cx, JS::HandleValue thisv, JS::HandleObject funObj,
+ const JS::HandleValueArray&amp; args, JS::MutableHandleValue rval);
+</pre>
+
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th><font><font>名称</font></font></th>
+ <th><font><font>类型</font></font></th>
+ <th><font><font>描述</font></font></th>
+ </tr>
+ <tr>
+ <td><code>cx</code></td>
+ <td>{{jsapixref("JSRuntime", "JSContext *")}}</td>
+ <td><font><font>指向JS上下文的指针,从中可以派生运行时信息。</font><font>{{Jsapi-requires-request()}}</font></font></td>
+ </tr>
+ <tr>
+ <td><code>thisObj</code></td>
+ <td>{{jsapixref("JSObject", "JS::HandleObject")}} / {{jsapixref("JS::Value", "JS::HandleValue")}}</td>
+ <td>The "current" object on which the function operates; the object specified here is "this" when the function executes.</td>
+ </tr>
+ <tr>
+ <td><code>fun</code> / <code>funObj</code></td>
+ <td>{{jsapixref("JSFunction", "JS::HandleFunction")}} / {{jsapixref("JS::Value", "JS::HandleValue")}} / {{jsapixref("JSObject", "JS::HandleObject")}}</td>
+ <td>Pointer to the function to call. <strong>Should be a native function or JSAPI-compiled function.</strong></td>
+ </tr>
+ <tr>
+ <td><code>name</code></td>
+ <td><code>const char *</code></td>
+ <td>Pointer to the function name to call.</td>
+ </tr>
+ <tr>
+ <td><code>args</code></td>
+ <td>{{jsapixref("JS::HandleValueArray", "JS::HandleValueArray &amp;")}}</td>
+ <td>Arguments to pass to the function.</td>
+ </tr>
+ <tr>
+ <td><code>rval</code></td>
+ <td>{{jsapixref("JS::Value", "JS::MutableHandleValue")}}</td>
+ <td>Out parameter. On success, <code>*rval</code> receives the return value from the function call.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Description" name="Description">Description</h2>
+
+<p><code>JS::Call</code><code>fun</code><font><font>在对象上</font><font>调用指定的函数</font></font><code>thisObj</code><font><font>。</font><font>在函数执行方面,该对象被视为</font></font><code>this</code><font><font>。</font></font></p>
+
+<p><font><font>有关更多详细信息,请参阅{{jsapixref("JS_CallFunction")}},{{jsapixref("JS_CallFunctionName")}}和{{jsapixref("JS_CallFunctionValue")}}。</font></font></p>
+
+<h2 id="See_Also" name="See_Also"><font><font>也可以看看</font></font></h2>
+
+<ul>
+ <li>{{ LXRSearch("ident", "i", "JS::Call") }}</li>
+ <li>{{jsapixref("JS_CallFunction")}}</li>
+ <li>{{jsapixref("JS_CallFunctionName")}}</li>
+ <li>{{jsapixref("JS_CallFunctionValue")}}</li>
+ <li>{{bug(601168)}}</li>
+</ul>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_doublecolon_ordinarytoprimitive/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_doublecolon_ordinarytoprimitive/index.html
new file mode 100644
index 0000000000..b09164ee56
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_doublecolon_ordinarytoprimitive/index.html
@@ -0,0 +1,66 @@
+---
+title: 'JS::OrdinaryToPrimitive'
+slug: 'Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS::OrdinaryToPrimitive'
+translation_of: 'Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS::OrdinaryToPrimitive'
+---
+<div>{{SpiderMonkeySidebar("JSAPI")}}</div>
+
+<p>{{ jsapi_minversion_header("38") }}</p>
+
+<div class="summary">
+<p>将普通对象转换为原始值</p>
+</div>
+
+<h2 id="语法说明">语法说明</h2>
+
+<pre class="brush: cpp">bool
+JS::OrdinaryToPrimitive(JSContext *cx, JS::HandleObject obj, JSType type,
+ JS::MutableHandleValue vp);</pre>
+
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>名称</th>
+ <th>类型</th>
+ <th>描述</th>
+ </tr>
+ <tr>
+ <td><code>cx</code></td>
+ <td>{{jsapixref("JSRuntime", "JSContext *")}}</td>
+ <td>执行转换的上下文. {{ Jsapi-requires-request() }}</td>
+ </tr>
+ <tr>
+ <td><code>obj</code></td>
+ <td>{{jsapixref("JSObject", "JS::HandleObject")}}</td>
+ <td>要转换的对象。</td>
+ </tr>
+ <tr>
+ <td><code>type</code></td>
+ <td>{{jsapixref("JSType")}}</td>
+ <td>转换后值的类型。</td>
+ </tr>
+ <tr>
+ <td><code>vp</code></td>
+ <td>{{jsapixref("JS::Value", "JS::MutableHandleValue")}}</td>
+ <td>输出参数. 成功, <code>*vp 收到转换后的值</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="描述">描述</h2>
+
+<p><code>JS::OrdinaryToPrimitive</code> 通过ES6 draft rev 28(2014年10月14日)7.1.1第二算法中指定的算法将JavaScript对象转换为指定的类型值。</p>
+
+<p>Most users should not call this -- use {{jsapixref("JS::ToNumber")}}, {{jsapixref("JS::ToBoolean")}}, or {{jsapixref("JS::ToString")}} instead. This should only be called from custom convert hooks. It implements the default conversion behavior shared by most objects in JS, so it's useful as a fallback.</p>
+
+<p>On success, <code>JS::OrdinaryToPrimitive</code> stores the converted value in <code>*vp</code> and returns <code>true</code>. On error or exception, it returns <code>false</code>, and the value left in <code>*vp</code> is undefined.</p>
+
+<h2 id="See_Also" name="See_Also">了解其他</h2>
+
+<ul>
+ <li>{{ LXRSearch("ident", "i", "JS::OrdinaryToPrimitive") }}</li>
+ <li>{{jsapixref("JS::ToNumber")}}</li>
+ <li>{{jsapixref("JS::ToBoolean")}}</li>
+ <li>{{jsapixref("JS::ToString")}}</li>
+ <li>{{bug(1103152)}}</li>
+</ul>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_evaluatescript/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_evaluatescript/index.html
new file mode 100644
index 0000000000..94454ee794
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_evaluatescript/index.html
@@ -0,0 +1,69 @@
+---
+title: SpiderMonkey/JSAPI_参考/JS_EvaluateScript
+slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_EvaluateScript
+translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_EvaluateScript
+---
+<p>编译并执行一个脚本。</p>
+<h2 id="Syntax" name="Syntax">语法</h2>
+<pre class="eval"><a href="/En/SpiderMonkey/JSAPI_Reference/JSBool" title="en/JSBool">JSBool</a> <strong>JS_EvaluateScript</strong>(<a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSContext</a> *cx, <a href="/en/SpiderMonkey/JSAPI_Reference/JSObject" title="en/JSObject">JSObject</a> *obj,
+ const char *src, <a href="/en/SpiderMonkey/JSAPI_Reference/jsint" title="en/jsint">uintN</a> length, const char *filename,
+ <a href="/en/SpiderMonkey/JSAPI_Reference/jsint" title="en/jsint">uintN</a> lineno, <a href="/En/SpiderMonkey/JSAPI_Reference/Jsval" title="en/jsval">jsval</a> *rval);
+
+<a href="/En/SpiderMonkey/JSAPI_Reference/JSBool" title="en/JSBool">JSBool</a> <strong>JS_EvaluateUCScript</strong>(<a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSContext</a> *cx, <a href="/en/SpiderMonkey/JSAPI_Reference/JSObject" title="en/JSObject">JSObject</a> *obj,
+ const <a href="/en/SpiderMonkey/JSAPI_Reference/jschar" title="en/jschar">jschar</a> *src, <a href="/en/SpiderMonkey/JSAPI_Reference/jsint" title="en/jsint">uintN</a> length, const char *filename,
+ <a href="/en/SpiderMonkey/JSAPI_Reference/jsint" title="en/jsint">uintN</a> lineno, <a href="/En/SpiderMonkey/JSAPI_Reference/Jsval" title="en/jsval">jsval</a> *rval);
+</pre>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>名称</th>
+ <th>数据类型</th>
+ <th>描述</th>
+ </tr>
+ <tr>
+ <td><code>cx</code></td>
+ <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSContext</a> *</code></td>
+ <td>脚本运行的上下文. {{ Jsapi-requires-request() }}</td>
+ </tr>
+ <tr>
+ <td><code>obj</code></td>
+ <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/JSObject" title="en/JSObject">JSObject</a> *</code></td>
+ <td>The scope in which to execute the script. This parameter is documented in detail at <code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ExecuteScript" title="en/JS_ExecuteScript">JS_ExecuteScript</a></code>.</td>
+ </tr>
+ <tr>
+ <td><code>src</code></td>
+ <td><code>const char *</code> <em>or</em> <code>const <a href="/en/SpiderMonkey/JSAPI_Reference/jschar" title="en/jschar">jschar</a> *</code></td>
+ <td>包含要编译和执行的脚本的字符串.</td>
+ </tr>
+ <tr>
+ <td><code>length</code></td>
+ <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/jsint" title="en/jsint">uintN</a></code></td>
+ <td><code>src的长度</code>, in characters.</td>
+ </tr>
+ <tr>
+ <td><code>filename</code></td>
+ <td><code>const char *</code></td>
+ <td>Name of file or URL containing the script. Used to report filename or URL in error messages.</td>
+ </tr>
+ <tr>
+ <td><code>lineno</code></td>
+ <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/jsint" title="en/jsint">uintN</a></code></td>
+ <td>Line number. Used to report the offending line in the file or URL if an error occurs.</td>
+ </tr>
+ <tr>
+ <td><code>rval</code></td>
+ <td><code><a href="/En/SpiderMonkey/JSAPI_Reference/Jsval" title="en/jsval">jsval</a> *</code></td>
+ <td>Out parameter. On success, <code>*rval</code> receives the value of the last-executed expression statement processed in the script.</td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Description" name="Description">描述</h2>
+<p><code>JS_EvaluateScript</code> compiles and executes a script in the specified scope, <code>obj</code>. On successful completion, <code>rval</code> is a pointer to a variable that holds the value from the last executed expression statement processed in the script. <code>JS_EvaluateUCScript</code> is the Unicode version of the function.</p>
+<p><code>src</code> is the string containing the text of the script. <code>length</code> indicates the size of the text version of the script in characters.</p>
+<p><code>filename</code> is the name of the file (or URL) containing the script. This information is used in messages if an error occurs during compilation. Similarly, <code>lineno</code> is used to report the line number of the script or file where an error occurred during compilation.</p>
+<p>If a script compiles and executes successfully, <code>*rval</code> receives the value from the last-executed expression statement in the script, and <code>JS_EvaluateScript</code> or <code>JS_EvaluateUCScript</code> returns <code>JS_TRUE</code>. Otherwise it returns <code>JS_FALSE</code> and the value left in <code>*rval</code> is undefined.</p>
+<h2 id="See_Also" name="See_Also">See Also</h2>
+<p>{{ LXRSearch("ident", "i", "JS_EvaluateScript") }}<br>
+ {{ LXRSearch("ident", "i", "JS_EvaluateUCScript") }}</p>
+<p><a href="/en/SpiderMonkey/JSAPI_Reference/JS_CompileFile" title="en/JS_CompileFile">JS_CompileFile</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_CompileScript" title="en/JS_CompileScript">JS_CompileScript</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_DecompileScript" title="en/JS_DecompileScript">JS_DecompileScript</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_DestroyScript" title="en/JS_DestroyScript">JS_DestroyScript</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_EvaluateScriptForPrincipals" title="en/JS_EvaluateScriptForPrincipals">JS_EvaluateScriptForPrincipals</a></p>
+<p>{{ languages( { "ja": "ja/JS_EvaluateScript" } ) }}</p>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_getversion/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_getversion/index.html
new file mode 100644
index 0000000000..a2b2888958
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_getversion/index.html
@@ -0,0 +1,29 @@
+---
+title: SpiderMonkey/JSAPI_参考/JS_GetVersion
+slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_GetVersion
+translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_GetVersion
+---
+<p>Retrieves the JavaScript version number used within a specified executable script context.</p>
+<h2 id="Syntax" name="Syntax">语法</h2>
+<pre class="eval"><a href="/en/SpiderMonkey/JSAPI_Reference/JSVersion" title="en/JSVersion">JSVersion</a> <strong>JS_GetVersion</strong>(<a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSContext</a> *cx);
+</pre>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>参数名称</th>
+ <th>类型</th>
+ <th>描述</th>
+ </tr>
+ <tr>
+ <td><code>cx</code></td>
+ <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSContext</a> *</code></td>
+ <td>要查询的上下文.</td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Description" name="Description">描述</h2>
+<p><code>JS_GetVersion</code> returns the JavaScript version currently used by the given <code>JSContext</code>, <code>cx</code>. The result is one of the <code><a href="/en/SpiderMonkey/JSAPI_Reference/JSVersion" title="en/JSVersion">JSVersion</a></code> constants.</p>
+<p>When a context is created, its version is initially <code>JSVERSION_DEFAULT</code>. Scripts are compiled using the latest version of the JavaScript language. To configure a context to run scripts using a specific version of JavaScript, use <code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetVersion" title="en/JS_SetVersion">JS_SetVersion</a></code>.</p>
+<h2 id="See_Also" name="See_Also">请参阅</h2>
+<p>{{ LXRSearch("ident", "i", "JS_GetVersion") }}</p>
+<p><a href="/en/SpiderMonkey/JSAPI_Reference/JS_VersionToString" title="en/JS_VersionToString">JS_VersionToString</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_StringToVersion" title="en/JS_StringToVersion">JS_StringToVersion</a></p>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_hasownproperty/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_hasownproperty/index.html
new file mode 100644
index 0000000000..ed6e760796
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_hasownproperty/index.html
@@ -0,0 +1,73 @@
+---
+title: JS_HasOwnProperty
+slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_HasOwnProperty
+tags:
+ - 中文
+translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_HasOwnProperty
+---
+<div>{{SpiderMonkeySidebar("JSAPI")}}</div>
+
+<p>{{ jsapi_minversion_header("45") }}</p>
+
+<div class="summary">
+<p>Determine whether a JavaScript object has a specified own property.</p>
+</div>
+
+<h2 id="Syntax" name="Syntax">Syntax</h2>
+
+<pre class="brush: cpp notranslate">bool
+JS_HasOwnProperty(JSContext* cx, HandleObject obj, const char* name,
+ bool* foundp)
+
+bool
+JS_HasOwnPropertyById(JSContext* cx, HandleObject obj, HandleId id,
+ bool* foundp)
+</pre>
+
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>Name</th>
+ <th>Type</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td><code>cx</code></td>
+ <td>{{jsapixref("JSRuntime", "JSContext *")}}</td>
+ <td>A context. {{ Jsapi-requires-request() }}</td>
+ </tr>
+ <tr>
+ <td><code>obj</code></td>
+ <td>{{jsapixref("JSObject", "JS::HandleObject")}}</td>
+ <td>Object to search on for the property.</td>
+ </tr>
+ <tr>
+ <td><code>name</code> <em>or<em> <code>id</code></em></em></td>
+ <td><code>const char *</code> <em>or</em> {{jsapixref("jsid", "JS::HandleId")}}</td>
+ <td>Name of the property to look up.</td>
+ </tr>
+ <tr>
+ <td><code>foundp</code></td>
+ <td><code>bool *</code></td>
+ <td>Non-null pointer to a variable of type <code>bool</code>. On success, <code>JS_HasOwnProperty</code> stores <code>true</code> in this variable if <code>obj</code> has an own property with the given <code>name</code>, and <code>false</code> if not.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Description" name="Description">Description</h2>
+
+<p><strong><code>JS_HasOwnProperty</code></strong> searches an object, <code>obj</code>, for an own property with the specified <code>name</code>. It behaves like the JavaScript expression <code>Object.hasOwnProperty(obj, name)</code>. <strong><code>JS_HasOwnPropertyById</code></strong> is the same but takes a {{jsapixref("jsid", "JS::HandleId")}} for the property name.</p>
+
+<p>If the property exists, this function sets <code>*foundp</code> to <code>true</code> and returns <code>true</code>.</p>
+
+<p>If the object <code>obj</code> has no such property, the function sets <code>*foundp</code> to <code>false</code> and returns <code>true</code> (to indicate that no error occurred).</p>
+
+<p>If an error occurs during the search, the function returns <code>false</code>, and the value of <code>*foundp</code> is undefined.</p>
+
+<h2 id="See_Also" name="See_Also">See Also</h2>
+
+<ul>
+ <li>{{ LXRSearch("ident", "i", "JS_HasOwnProperty") }}</li>
+ <li>{{ LXRSearch("ident", "i", "JS_HasOwnPropertyById") }}</li>
+ <li>{{bug(1163423)}}</li>
+</ul>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_newruntime/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_newruntime/index.html
new file mode 100644
index 0000000000..885bb3dd6e
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_newruntime/index.html
@@ -0,0 +1,33 @@
+---
+title: JS_NewRuntime
+slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_NewRuntime
+tags:
+ - JSAPI_Reference
+ - SpiderMonkey
+translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_NewRuntime
+---
+<p>Initializes the JavaScript runtime.</p>
+<h2 id="Syntax" name="Syntax">Syntax</h2>
+<pre class="eval"><a href="/zh-CN/SpiderMonkey/JSAPI_Reference/JSRuntime" title="zh-CN/JSRuntime">JSRuntime</a> * <strong>JS_NewRuntime</strong>(uint32 maxbytes);
+</pre>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>Name</th>
+ <th>Type</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td><code>maxbytes</code></td>
+ <td><code>uint32</code></td>
+ <td>Maximum number of allocated bytes after which garbage collection is run.</td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Description" name="Description">Description</h2>
+<p><code>JS_NewRuntime</code> initializes the JavaScript runtime environment. Call <code>JS_NewRuntime</code> before making any other API calls. <code>JS_NewRuntime</code> allocates memory for the <code>JSRuntime</code> and initializes certain internal runtime structures. <code>maxbytes</code> specifies the number of allocated bytes after which garbage collection is run.</p>
+<p>Generally speaking, most applications need only one <code><a href="/zh-CN/SpiderMonkey/JSAPI_Reference/JSRuntime" title="zh-CN/JSRuntime">JSRuntime</a></code>. In a <code><a href="/zh-CN/SpiderMonkey/JSAPI_Reference/JS_THREADSAFE" title="zh-CN/JS_THREADSAFE">JS_THREADSAFE</a></code> build, each runtime is capable of handling multiple execution threads, using one <code><a href="/zh-CN/SpiderMonkey/JSAPI_Reference/JSRuntime" title="zh-CN/JSRuntime">JSContext</a></code> per thread, sharing the same <code>JSRuntime</code>. You only need multiple runtimes if your application requires completely separate JS engines that cannot share values, objects, and functions.</p>
+<p>On success, <code>JS_NewRuntime</code> returns a pointer to the newly created runtime, which the caller must later destroy using <code><a href="/zh-CN/SpiderMonkey/JSAPI_Reference/JS_DestroyRuntime" title="zh-CN/JS_DestroyRuntime">JS_DestroyRuntime</a></code>. Otherwise it returns <code>NULL</code>.</p>
+<h3 id="Notes" name="Notes">Notes</h3>
+<p>Ordinarily, <code>JS_NewRuntime</code> should be the first JSAPI call in an application, and <code><a href="/zh-CN/SpiderMonkey/JSAPI_Reference/JS_DestroyRuntime" title="zh-CN/JS_DestroyRuntime">JS_DestroyRuntime</a></code> and <code><a href="/zh-CN/SpiderMonkey/JSAPI_Reference/JS_ShutDown" title="zh-CN/JS_ShutDown">JS_ShutDown</a></code> should be the last ones.</p>
+<p>{{ LXRSearch("ident", "i", "JS_NewRuntime") }}</p>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_seterrorreporter/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_seterrorreporter/index.html
new file mode 100644
index 0000000000..e04127a541
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_seterrorreporter/index.html
@@ -0,0 +1,61 @@
+---
+title: SpiderMonkey/JSAPI_参考/JS_SetErrorReporter
+slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_SetErrorReporter
+translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_SetErrorReporter
+---
+<p>指定一个程序的错误报告途径.</p>
+<h2 id="Syntax" name="Syntax">语法</h2>
+<pre class="eval"><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetErrorReporter" title="en/JS_SetErrorReporter">JSErrorReporter</a> <strong>JS_SetErrorReporter</strong>(<a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSContext</a> *cx, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetErrorReporter" title="en/JS_SetErrorReporter">JSErrorReporter</a> er);
+</pre>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>形式参数</th>
+ <th>类型</th>
+ <th>描述</th>
+ </tr>
+ <tr>
+ <td><code>cx</code></td>
+ <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSContext</a> *</code></td>
+ <td>Pointer to a JS context from which to derive runtime information.</td>
+ </tr>
+ <tr>
+ <td><code>er</code></td>
+ <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetErrorReporter" title="en/JS_SetErrorReporter">JSErrorReporter</a></code></td>
+ <td>在你的程序中用于报告错误的自定义函数, 见下面的描述.</td>
+ </tr>
+ </tbody>
+</table>
+<h3 id="Callback_Syntax" name="Callback_Syntax">  回调函数语法</h3>
+<pre class="eval">typedef void (*<strong>JSErrorReporter</strong>)(
+ <a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSContext</a> *cx, const char *message, <a href="/en/SpiderMonkey/JSAPI_Reference/JSErrorReport" title="en/JSErrorReport">JSErrorReport</a> *report);
+</pre>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>形式参数</th>
+ <th>类型</th>
+ <th>描述</th>
+ </tr>
+ <tr>
+ <td><code>cx</code></td>
+ <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSContext</a> *</code></td>
+ <td>错误发生的上下文。</td>
+ </tr>
+ <tr>
+ <td><code>message</code></td>
+ <td><code>const char *</code></td>
+ <td>一个错误信息。</td>
+ </tr>
+ <tr>
+ <td><code>report</code></td>
+ <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/JSErrorReport" title="en/JSErrorReport">JSErrorReport</a> *</code></td>
+ <td>一个包含错误额外的详细资料报告记录。</td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Description" name="Description">描述</h2>
+<p><code>JS_SetErrorReporter</code> enables you to define and use your own error reporting mechanism in your applications. The reporter you define is automatically passed a <code><a href="/en/SpiderMonkey/JSAPI_Reference/JSErrorReport" title="en/JSErrorReport">JSErrorReport</a></code> structure when an error occurs and has been parsed by <code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ReportError" title="en/JS_ReportError">JS_ReportError</a></code>.</p>
+<p>Typically, the error reporting mechanism you define should log the error where appropriate (such as to a log file), and display an error to the user of your application. The error you log and display can make use of the information passed about the error condition in the <code>JSErrorReport</code> structure.</p>
+<p>Like all other SpiderMonkey callbacks, the error reporter callback must not throw a C++ exception.</p>
+<p>{{ LXRSearch("ident", "i", "JS_SetErrorReporter") }}</p>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_valuetostring/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_valuetostring/index.html
new file mode 100644
index 0000000000..ab0e6654a4
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/js_valuetostring/index.html
@@ -0,0 +1,45 @@
+---
+title: SpiderMonkey/JSAPI_参考/JS_ValueToString
+slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_ValueToString
+translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_ValueToString
+---
+<p>把一个<code>jsval值</code> 转换成一个 <code>JSString</code>.</p>
+
+<p> </p>
+
+<h2 id="Syntax" name="Syntax">语法</h2>
+
+<pre class="eval"><a href="/en/SpiderMonkey/JSAPI_Reference/JSString" title="en/JSString">JSString</a> * <strong>JS_ValueToString</strong>(<a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSContext</a> *cx, <a href="/En/SpiderMonkey/JSAPI_Reference/Jsval" title="en/jsval">jsval</a> v);
+</pre>
+
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>Name</th>
+ <th>Type</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td><code>cx</code></td>
+ <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSContext</a> *</code></td>
+ <td>The context in which to perform the conversion. {{ Jsapi-requires-request() }}</td>
+ </tr>
+ <tr>
+ <td><code>v</code></td>
+ <td><code><a href="/En/SpiderMonkey/JSAPI_Reference/Jsval" title="en/jsval">jsval</a></code></td>
+ <td>转换的jsval值.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Description" name="Description">描述</h2>
+
+<p><code>JS_ValueToString</code> converts a specified JS value, <code>v</code>, to a JS string. It implements the ToString operator specified in <span class="pl-s1"><span class="pl-s">ECMA 262-3 §</span></span>9. If <code>v</code> is an object, the actual conversion is performed by its <code><a href="/en/SpiderMonkey/JSAPI_Reference/JSObjectOps.defaultValue" title="en/JSObjectOps.defaultValue">JSClass.convert</a></code> callback, which may call the JavaScript methods <code>v.toString()</code> and/or <code>v.valueOf()</code>. On success, <code>JS_ValueToString</code> returns a pointer to a string. On error or exception, it returns <code>NULL</code>. This happens, for example, if <code>v</code> is an object and <code>v.toString()</code> throws an exception.</p>
+
+<p>The resulting <code>JSString</code> is subject to garbage collection unless you protect it using a local root, an object property, or the <code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_AddRoot" title="en/JS_AddRoot">JS_AddRoot</a></code> function.</p>
+
+<h2 id="See_Also" name="See_Also">See Also</h2>
+
+<p>{{ LXRSearch("ident", "i", "JS_ValueToString") }}</p>
+
+<p><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ConvertArguments" title="en/JS_ConvertArguments">JS_ConvertArguments</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_ConvertValue" title="en/JS_ConvertValue">JS_ConvertValue</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetTypeName" title="en/JS_GetTypeName">JS_GetTypeName</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_TypeOfValue" title="en/JS_TypeOfValue">JS_TypeOfValue</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToBoolean" title="en/JS_ValueToBoolean">JS_ValueToBoolean</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToFunction" title="en/JS_ValueToFunction">JS_ValueToFunction</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToInt32" title="en/JS_ValueToInt32">JS_ValueToInt32</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToNumber" title="en/JS_ValueToNumber">JS_ValueToNumber</a>, <a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToObject" title="en/JS_ValueToObject">JS_ValueToObject</a></p>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jsclass/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jsclass/index.html
new file mode 100644
index 0000000000..dd119aba3f
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jsclass/index.html
@@ -0,0 +1,137 @@
+---
+title: JSClass
+slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSClass
+translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSClass
+---
+<h3 id=".E6.91.98.E8.A6.81" name=".E6.91.98.E8.A6.81">摘要</h3>
+<p><b>数据结构</b> 定义一个基本类用于建立和维护JS对象。</p>
+<h3 id=".E8.AF.AD.E6.B3.95" name=".E8.AF.AD.E6.B3.95">语法</h3>
+<pre>struct JSClass {
+ char *name;
+ uint32 flags;
+ /* Mandatory non-null function pointer members. */
+ JSPropertyOp addProperty;
+ JSPropertyOp delProperty;
+ JSPropertyOp getProperty;
+ JSPropertyOp setProperty;
+ JSEnumerateOp enumerate;
+ JSResolveOp resolve;
+ JSConvertOp convert;
+ JSFinalizeOp finalize;
+ /* Optionally non-null members start here. */
+ JSGetObjectOps getObjectOps;
+ JSCheckAccessOp checkAccess;
+ JSNative call;
+ JSNative construct;
+ JSXDRObjectOp xdrObject;
+ JSHasInstanceOp hasInstance;
+ JSMarkOp mark;
+ JSReserveSlotsOp reserveSlots;
+};
+</pre>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>名称</th>
+ <th>类型</th>
+ <th>描述</th>
+ </tr>
+ <tr>
+ <td><code>name</code></td>
+ <td><code>char *</code></td>
+ <td>类名</td>
+ </tr>
+ <tr>
+ <td><code>flags</code></td>
+ <td><code>uint32</code></td>
+ <td>类的属性(成员变量)。0表明属性不是一个集合. 属性值可以是下面这些值中的一个或多个:
+ <ul>
+ <li><code><a href="cn/JSAPI_Reference/JSCLASS_HAS_PRIVATE">JSCLASS_HAS_PRIVATE</a></code>: 类可以使用私有数据。</li>
+ <li><code><a href="cn/JSAPI_Reference/JSCLASS_NEW_ENUMERATE">JSCLASS_NEW_ENUMERATE</a></code>: 返回由类定义的<code>getObjectOps</code>方法获取所有属性的一个新方法。</li>
+ <li><code><a href="cn/JSAPI_Reference/JSCLASS_NEW_RESOLVE">JSCLASS_NEW_RESOLVE</a></code>: 返回由类定义的<code>getObjectOps</code>方法获取属性值的一个新方法。</li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td><code>addProperty</code></td>
+ <td><code>JSPropertyOp</code></td>
+ <td>为类增加属性的函数。</td>
+ </tr>
+ <tr>
+ <td><code>delProperty</code></td>
+ <td><code>JSPropertyOp</code></td>
+ <td>从类中删除属性的函数。</td>
+ </tr>
+ <tr>
+ <td><code>getProperty</code></td>
+ <td><code>JSPropertyOp</code></td>
+ <td>获取属性值的函数。</td>
+ </tr>
+ <tr>
+ <td><code>setProperty</code></td>
+ <td><code>JSPropertyOp</code></td>
+ <td>设置属性值的函数</td>
+ </tr>
+ <tr>
+ <td><code>enumerate</code></td>
+ <td><code>JSEnumerateOp</code></td>
+ <td>枚举类所有属性的函数。</td>
+ </tr>
+ <tr>
+ <td><code>resolve</code></td>
+ <td><code>JSResolveOp</code></td>
+ <td>Method for resolving property ambiguities.</td>
+ </tr>
+ <tr>
+ <td><code>convert</code></td>
+ <td><code>JSConvertOp</code></td>
+ <td>进行属性值转换的函数。</td>
+ </tr>
+ <tr>
+ <td><code>finalize</code></td>
+ <td><code>JSFinalizeOp</code></td>
+ <td>将类设为不可修改(finalizing)的函数。</td>
+ </tr>
+ <tr>
+ <td><code>getObjectOps</code></td>
+ <td><code>JSGetObjectOps</code></td>
+ <td>为类定义重载方法指向一个可选的结构。如果你不想重载类的默认方法,可以将<code>getObjectOps</code> 设为 <code>NULL</code>。</td>
+ </tr>
+ <tr>
+ <td><code>checkAccess</code></td>
+ <td><code>JSCheckAccessOp</code></td>
+ <td>为类或对象操作结构指定可选的自定义请求控制方法。如果你不想提供自定义的请求控制,设置此值为<code>NULL</code>。</td>
+ </tr>
+ <tr>
+ <td><code>call</code></td>
+ <td><code>JSNative</code></td>
+ <td>为对象提供替换这个类的方法。</td>
+ </tr>
+ <tr>
+ <td><code>construct</code></td>
+ <td><code>JSNative</code></td>
+ <td>为对象提供方法去替换这个类的构造器。</td>
+ </tr>
+ <tr>
+ <td><code>xdrObject</code></td>
+ <td><code>JSXDRObjectOp</code></td>
+ <td>指向一个可选的XDR对象和它的方法。如果你不想使用XDR, 设置这个值为 <code>NULL</code>。</td>
+ </tr>
+ <tr>
+ <td><code>hasInstance</code></td>
+ <td><code>JSHasInstanceOp</code></td>
+ <td>Pointer to an optional <code>hasInstance</code> method for this object. If you do not provide a method for <code>hasInstance</code>, set this pointer to <code>NULL</code>.</td>
+ </tr>
+ <tr>
+ <td><code>mark</code></td>
+ <td><code>JSMarkOp</code></td>
+ <td>Pointer to an optional <code>mark</code> method for this object. If you do not provide a method for <code>mark</code>, set this pointer to <code>NULL</code>.</td>
+ </tr>
+ <tr>
+ <td><code>reserveSlots</code></td>
+ <td><code>JSReserveSlotsOp</code></td>
+ <td>Pointer to an optional <code>reserveSlots</code> method for this object. If you do not provide a method for <code>reserveSlots</code>, set this pointer to <code>NULL</code>.</td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jsconstdoublespec/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jsconstdoublespec/index.html
new file mode 100644
index 0000000000..509d3b12ed
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jsconstdoublespec/index.html
@@ -0,0 +1,56 @@
+---
+title: JSConstDoubleSpec
+slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSConstDoubleSpec
+translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSConstDoubleSpec
+---
+<h3 id=".E6.91.98.E8.A6.81" name=".E6.91.98.E8.A6.81">摘要</h3>
+<p><b>数据结构</b></p>
+<p>定义一个双浮点类型的变量并进行赋值。</p>
+<h3 id=".E8.AF.AD.E6.B3.95" name=".E8.AF.AD.E6.B3.95">语法</h3>
+<pre>struct JSConstDoubleSpec {
+ jsdouble dval;
+ const char *name;
+ uint8 flags;
+ uint8 spare[3];
+};
+</pre>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>名称</th>
+ <th>类型</th>
+ <th>描述</th>
+ </tr>
+ <tr>
+ <td><code>dval</code></td>
+ <td><code>jsdouble</code></td>
+ <td>双浮点类型的值。</td>
+ </tr>
+ <tr>
+ <td><code>name</code></td>
+ <td><code>const char *</code></td>
+ <td>给双浮点类型定义的名称。</td>
+ </tr>
+ <tr>
+ <td><code>flags</code></td>
+ <td><code>uint8</code></td>
+ <td>双浮点类型的属性。这里可以是0或者是下面这些值之中的一个:
+ <ul>
+ <li><code><a href="cn/JSPROP_ENUMERATE">JSPROP_ENUMERATE</a></code>: 在for循环中的可用性。</li>
+ <li><code><a href="cn/JSPROP_READONLY">JSPROP_READONLY</a></code>: 只读性。</li>
+ <li><code><a href="cn/JSPROP_PERMANENT">JSPROP_PERMANENT</a></code>: 非删除性。</li>
+ <li><code><a href="cn/JSPROP_EXPORTED">JSPROP_EXPORTED</a></code>: 可导出性。(property can be exported outside its object.)</li>
+ <li><code><a href="cn/JSPROP_INDEX">JSPROP_INDEX</a></code>: 数组(array)元素的当前索引。</li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td><code>spare</code></td>
+ <td><code>uint8{{ mediawiki.external(3) }}</code></td>
+ <td>为以后的扩展保留的属性。</td>
+ </tr>
+ </tbody>
+</table>
+<h3 id=".E6.8F.8F.E8.BF.B0" name=".E6.8F.8F.E8.BF.B0">描述</h3>
+<p><code>JS双浮点型的构造规范</code> 典型应用于定义一个双浮点值集合,并使用<code><a href="cn/JS_DefineConstDoubles">JS_DefineConstDoubles</a></code>对生成的对象进行赋值。使用<code>JS_DefineConstDouble</code>为指定的对象创建一个或多个双浮点类型属性。</p>
+<p><code>JS_DefineConstDoubles</code>为一类由<code>JSConstDoubleSpecs</code>定义的数组提供证明。为每个数据元素定义独立的属性名和设置独立的属性值。数组的最后一个元素必须包括0值(zero-valued)的属性。<code>JS_DefineConstDoubles</code> 为数组中每个非0值(non-zero)元素创建一个属性值。</p>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jserrorreport/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jserrorreport/index.html
new file mode 100644
index 0000000000..7246c3c416
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jserrorreport/index.html
@@ -0,0 +1,6 @@
+---
+title: JSErrorReport
+slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSErrorReport
+translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSErrorReport
+---
+<p><a>Media:Example.ogg</a></p>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jsproperty/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jsproperty/index.html
new file mode 100644
index 0000000000..16f0cca090
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jsproperty/index.html
@@ -0,0 +1,29 @@
+---
+title: JSProperty
+slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSProperty
+translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSProperty
+---
+<div>{{SpiderMonkeySidebar("JSAPI")}}</div>
+
+<p>{{deprecated_header("jsapi16")}}</p>
+
+<div class="summary">
+<p>限内部使用。{{jsapixref("JSObjectOps")}}层使用的JavaScript对象属性的类型。</p>
+</div>
+
+<h3 id="Syntax" name="Syntax">语法</h3>
+
+<pre class="eval">struct JSProperty {
+ jsid id;
+};
+</pre>
+
+<h3 id="Description" name="Description">Description</h3>
+
+<p><code>JSProperty</code> 是所有对象属性的抽象基类。 它在 {{jsapixref("JSObjectOps.lookupProperty")}}, {{jsapixref("JSObjectOps.getAttributes", "getAttributes")}}, {{jsapixref("JSObjectOps.getAttributes", "setAttributes")}}, 和 {{jsapixref("JSObjectOps.dropProperty", "dropProperty")}}中内部使用。</p>
+
+<h2 id="See_Also" name="See_Also">See Also</h2>
+
+<ul>
+ <li>{{bug(483473)}}</li>
+</ul>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jspropertydescriptor/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jspropertydescriptor/index.html
new file mode 100644
index 0000000000..9f35d49fdb
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jspropertydescriptor/index.html
@@ -0,0 +1,69 @@
+---
+title: JSPropertyDescriptor
+slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSPropertyDescriptor
+translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSPropertyDescriptor
+---
+<div>{{SpiderMonkeySidebar("JSAPI")}}</div>
+
+<div class="summary">描述符是一个用于声明一个属性是否可以被修改,是否可以被删除,是否可以被枚举的一个对象</div>
+
+<h2 id="内容">内容</h2>
+
+<p>每一个属性只拥有一个描述符对象,但是这个对象中拥有多个键值,用来描述这个属性,下表说明了描述符中可以拥有的键值.</p>
+
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <td class="header">Field Name</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>getter</code></td>
+ <td><code>get</code> 语法为属性绑定一个函数,每当查询该属性时便调用对应的函数,查询的结构为该函数的返回值</td>
+ </tr>
+ <tr>
+ <td><code>setter</code></td>
+ <td>如果试着改变一个属性的值,那么对应的 <em>setter</em> 函数将被执行</td>
+ </tr>
+ <tr>
+ <td><code>value</code></td>
+ <td>描述指定属性的值 , 可以是任何有效的 <em>Javascript</em> 值(函数 , 对象 , 字符串 ...).</td>
+ </tr>
+ <tr>
+ <td><code>configurable</code></td>
+ <td>当且仅当该属性的 <em>configurable</em> 为 true 时,该属性 <code>描述符</code> 才能够被改变, 同时该属性也能从对应的对象上被删除.</td>
+ </tr>
+ <tr>
+ <td><code>enumerable</code></td>
+ <td>描述指定的属性是否是 <a href="https://www.yuque.com/hardtoname/ur9xy2/rwbt5g#o93qms">可枚举</a> 的.</td>
+ </tr>
+ <tr>
+ <td><code>writable</code></td>
+ <td>当且仅当该属性的 <em>writable</em> 为 <code>true</code> 时, <em>value</em> 才能被赋值运算符改变。</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Description" name="Description">描述</h2>
+
+<p><em>描述符</em> 是描述对象属性的属性 , 对象里目前存在的属性描述符有两种主要形式:<strong>数据描述符 </strong>和 <strong>存取描述符</strong>. 可以通过 <em>Object.getOwnPropertyDescriptor()</em> 函数来获取某个对象下指定属性的对应的 <em>描述符</em> .</p>
+
+<h2 id="示例">示例</h2>
+
+<p>下面将演示通过 <em>Object.defineProperty()</em> 函数定义一个对象的属性.</p>
+
+<pre class="brush: js">var language = {}; // 定义一个空对象 language
+
+Object.defineProperty(language, 'log', { // 定义 language 对象下的 log 属性
+ value : ['CN','EN'],
+ writable : true,
+ enumerable : true,
+ configurable : true
+})</pre>
+
+<p>此时这是一个可读可写可枚举的属性 此时我们将这三个值都设为了 true 此时上面这段代码等价于:</p>
+
+<pre class="brush: js">var language = {}; // 定义一个空对象 language
+
+languange.log = ['CN','EN']; // 定义 language 对象下的 log 属性
+</pre>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jsruntime/index.html b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jsruntime/index.html
new file mode 100644
index 0000000000..daabc3f876
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/jsapi_reference/jsruntime/index.html
@@ -0,0 +1,29 @@
+---
+title: JSRuntime
+slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSRuntime
+translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JSRuntime
+---
+<div>{{SpiderMonkeySidebar("JSAPI")}}</div>
+
+<div>
+<p><font><font>在JSAPI中,</font></font><code><strong>JSRuntime</strong></code><font><font>是代表JavaScript引擎实例的顶级对象。</font><font>一个程序通常只有一个</font></font><code>JSRuntime</code><font><font>,即使它有很多线程。</font><font>这</font></font><code>JSRuntime</code><font><font>是JavaScript对象所居住的世界;</font><font>他们不能去其他人</font></font><code>JSRuntime</code><font><font>。</font></font></p>
+
+<p><font><font>所有JavaScript代码和大多数JSAPI调用都在内运行</font></font><code><strong>JSContext</strong></code><font><font>。</font><font>该</font></font><code>JSContext</code><font><font>是对一个孩子</font></font><code>JSRuntime</code><font><font>。</font><font>上下文可以运行脚本。</font><font>它包含</font></font><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_GetGlobalObject" title="该函数已过时:请改用JS_GetGlobalForObject或JS_GetGlobalForScopeChain。 属于上下文的全局对象的概念可能会在以后的SpiderMonkey版本中逐步淘汰。"><font><font>全局对象</font></font></a><font><font>和执行堆栈。</font></font><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_SetPendingException" title="JS_SetPendingException设置在上下文中引发的当前异常。 如果已经引发异常,则将其替换为给定的新异常。"><font><font>异常处理</font></font></a><font><font>,</font></font><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_SetErrorReporter" title="JS_SetErrorReporter使您可以在应用程序中定义和使用自己的错误报告机制。 发生错误并由JS_ReportError解析后,您定义的报告程序会自动传递JSErrorReport结构。 JS_SetErrorReporter"><font><font>错误报告</font></font></a><font><font>和某些</font></font><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_SetOptions" title="JS_SetOptions设置给定JS上下文cx的选项标志。 此函数返回包含标志的先前值的uint32值。"><font><font>语言选项</font></font></a><font><font>是基于Per-的</font></font><code>JSContext</code><font><font>。</font><font>创建上下文后,可以将上下文多次用于不同的脚本或JSAPI查询。</font><font>例如,浏览器可能会为每个HTML页面创建一个单独的上下文。</font><font>页面中的每个脚本都可以使用相同的上下文。</font></font></p>
+
+<p><font><font>对象</font></font><code>在同一个</code><font><font> </font></font><code>JSRuntime</code><font><font>内</font></font><code>JSContext</code><font><font>之间可以共享。对象与创建对象的上下文之间没有固定的关联。</font></font></p>
+
+<p><font><font>设置和拆卸a </font></font><code>JSRuntime</code><font><font>和a的</font><font>示例代码</font></font><code>JSContext</code><font><font>在</font></font><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_User_Guide" title="JSAPI用户指南"><font><font>JSAPI用户指南中</font></font></a><font><font>。</font></font></p>
+</div>
+
+<h3 id="Threads" name="Threads">线程</h3>
+
+<p><font><font>只有一个线程可以使用</font></font><code>JSContext </code><font><font>或</font></font><code>JSRuntime</code><font><font>。</font><font>较早的版本允许使用  </font></font><code>JS_ClearContextThread</code><font><font> 和其他功能将a </font></font><code>JSContext</code><font><font> 从一个线程</font><font>移动  </font><font>到另一个线程。</font><font>此功能已被删除。</font></font></p>
+
+<h2 id="相关文档"><font><font>相关文档</font></font></h2>
+
+<ul>
+ <li>{{jsapixref("JS_NewRuntime")}}</li>
+ <li>{{jsapixref("JS_DestroyRuntime")}}</li>
+ <li>{{jsapixref("JS_NewContext")}}</li>
+ <li>{{jsapixref("JS_DestroyContext")}}</li>
+</ul>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/parser_api/index.html b/files/zh-cn/mozilla/projects/spidermonkey/parser_api/index.html
new file mode 100644
index 0000000000..03b00c9b00
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/parser_api/index.html
@@ -0,0 +1,1625 @@
+---
+title: Parser API
+slug: Mozilla/Projects/SpiderMonkey/Parser_API
+translation_of: Mozilla/Projects/SpiderMonkey/Parser_API
+---
+<p>{{ jsapi_minversion_header("1.8.5") }}</p>
+
+<p>最近构建的<a href="/En/SpiderMonkey/Build_Documentation" title="https://developer.mozilla.org/en/SpiderMonkey/Build_Documentation">独立的SpiderMonkey shell</a>包含了SpiderMonkey解析器的反射,可以通过JavaScript API来访问. 这使得我们更容易的用JavaScript写出处理JavaScript源代码的工具, 比如语法高亮工具,静态分析工具, 翻译器,编译器,混淆器等等.</p>
+
+<p>例子:</p>
+
+<pre>&gt; var expr = Reflect.parse("obj.foo + 42").body[0].expression
+&gt; expr.left.property
+({loc:null, type:"Identifier", name:"foo"})
+&gt; expr.right
+({loc:{source:null, start:{line:1, column:10}, end:{line:1, column:12}}, type:"Literal", value:42})
+</pre>
+
+<p>Reflect也可以使用在Firefox 7及以上版本中,但必须要导入一个模块:</p>
+
+<pre>Components.utils.import("resource://gre/modules/reflect.jsm")
+</pre>
+
+<p>如果不想用<code>Reflect</code>全局对象,也可以指定一个对象名称:</p>
+
+<pre>Components.utils.import("resource://gre/modules/reflect.jsm", obj)
+</pre>
+
+<h2 id="内置对象">内置对象</h2>
+
+<p>无论是SpiderMonkey shell还是Firefox (导入模块之后),全局对象<code>Reflect</code>目前都只有一个<code>parse</code>方法.</p>
+
+<h2 id="Reflect对象的属性"><code>Reflect</code>对象的属性</h2>
+
+<p><code>Reflect</code>对象目前只有一个方法.</p>
+
+<h4 id="Reflect.parse(src_options)"><code>Reflect.parse(src[, options])</code></h4>
+
+<p>将SRC强制转为字符串,并将结果作为javascript程序进行分析。默认情况下,解析返回一个表示被解析的抽象语法树(AST)的程序对象(见下文)</p>
+
+<p>可通过<strong>options</strong>对象提供其他选项, 可以使用的属性如下:</p>
+
+<table style="border: 1px solid #edf2f7; width: 67%;">
+ <tbody>
+ <tr style="background-color: rgb(241, 246, 251);">
+ <td><strong><span style="font-family: Courier New;">loc</span></strong></td>
+ <td>Boolean</td>
+ <td>Default: <span style="font-family: Courier New;">true</span></td>
+ </tr>
+ <tr>
+ <td colspan="3">如果<strong><span style="font-family: Courier New;">loc</span></strong>为<span style="font-family: Courier New;">true</span>,则解析器会在返回的AST节点中包含上源码的位置信息.</td>
+ </tr>
+ <tr style="background-color: rgb(241, 246, 251);">
+ <td><strong><span style="font-family: Courier New;">source</span></strong></td>
+ <td>String</td>
+ <td>Default: <span style="font-family: Courier New;">null</span></td>
+ </tr>
+ <tr>
+ <td colspan="3">A description of the input source; typically a filename, path, or URL. This string is not meaningful to the parsing process, but is produced as part of the source location information in the returned AST nodes.</td>
+ </tr>
+ <tr style="background-color: rgb(241, 246, 251);">
+ <td><strong><span style="font-family: Courier New;">line</span></strong></td>
+ <td>Number</td>
+ <td>Default: <span style="font-family: Courier New;">1</span></td>
+ </tr>
+ <tr>
+ <td colspan="3">初始行号,用在源码位置信息上.</td>
+ </tr>
+ <tr style="background-color: rgb(241, 246, 251);">
+ <td><strong><span style="font-family: Courier New;">builder</span></strong></td>
+ <td>Builder</td>
+ <td>Default: <span style="font-family: Courier New;">null</span></td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <p>A builder object, which can be used to produce AST nodes in custom data formats. The expected callback methods are described under <a href="/en/SpiderMonkey/Parser_API#Builder_objects" title="en/SpiderMonkey/Parser API#Builder objects">Builder Objects</a>.</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>If parsing fails due to a syntax error, an instance of <code>SyntaxError</code> is thrown. The syntax error object thrown by <code>Reflect.parse()</code> has the same <code>message</code> property as the syntax error that would be thrown by <code>eval(src)</code>. The <code>lineNumber</code> and <code>fileName</code> properties of the syntax error object indicate the source location of the syntax error.</p>
+
+<h2 id="节点对象">节点对象</h2>
+
+<p>默认情况下, <code>Reflect.parse()</code> 生成Node对象, 即普通的JavaScript对象 (i.e., 它们的原型来自标准的<code>Object原型</code>). 所有的节点类型都实现了以下的接口:</p>
+
+<pre>interface Node {
+ type: string;
+ loc: SourceLocation | null;
+}
+</pre>
+
+<p><code>type</code> 字段是一个字符串,代表AST变量类型.节点的每个子类型在下面的文档中都用其  <code>type</code> 字段特定的字符串标注出来了. 你可以使用这个字段去决定一个节点要实现的接口.</p>
+
+<p><code>loc</code> 字段代表节点的源位置信息. 如果解析器未生成有关节点的源位置信息,  <code>null</code> 字段为空;否则它是一个对象, 包括一个起始位置 (the position of the first character of the parsed source region) 和一个结束位置 (the position of the first character <em>after</em> the parsed source region):ss</p>
+
+<pre>interface SourceLocation {
+ source: string | null;
+ start: Position;
+ end: Position;
+}
+</pre>
+
+<p>每个 <code>Position</code> 包括一个 <code>line</code> 数字 (1-indexed) 和 <code>column</code> 数字 (0-indexed):</p>
+
+<pre>interface Position {
+ line: uint32 &gt;= 1;
+ column: uint32 &gt;= 0;
+}</pre>
+
+<h3 id="Programs">Programs</h3>
+
+<pre>interface Program &lt;: Node {
+ type: "Program";
+ body: [ Statement ];
+}
+</pre>
+
+<p>A complete program source tree.</p>
+
+<h3 id="函数">函数</h3>
+
+<pre>interface Function &lt;: Node {
+ id: Identifier | null;
+ params: [ Pattern ];
+ defaults: [ Expression ];
+ rest: Identifier | null;
+ body: BlockStatement | Expression;
+ generator: boolean;
+ expression: boolean;
+}
+</pre>
+
+<p>A function declaration or expression. The <code>body</code> of the function may be a block statement, or in the case of an <a href="/en/JavaScript/New_in_JavaScript/1.8#Expression_closures_%28Merge_into_own_page.2fsection%29" title="https://developer.mozilla.org/en/new_in_javascript_1.8#Expression_closures_(Merge_into_own_page.2fsection)">expression closure</a>, an expression.</p>
+
+<div class="note"><strong>注:</strong> Expression closures 是SpiderMonkey特有的.</div>
+
+<p>If the <code>generator</code> flag is <code>true</code>, the function is a <a href="/en/JavaScript/Guide/Iterators_and_Generators" title="https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Iterators_and_Generators">generator function</a>, i.e., contains a <code>yield</code> expression in its body (other than in a nested function).</p>
+
+<div class="note"><strong>注:</strong> Generators 是SpiderMonkey特有的.</div>
+
+<p>If the <code>expression</code> flag is <code>true</code>, the function is an expression closure and the <code>body</code> field is an expression.</p>
+
+<h3 id="语句">语句</h3>
+
+<pre>interface Statement &lt;: Node { }
+</pre>
+
+<p>任意语句.</p>
+
+<pre>interface EmptyStatement &lt;: Statement {
+ type: "EmptyStatement";
+}
+</pre>
+
+<p>一个空语句,也就是,一个孤立的分号.</p>
+
+<pre>interface BlockStatement &lt;: Statement {
+ type: "BlockStatement";
+ body: [ Statement ];
+}
+</pre>
+
+<p>一个语句块,也就是由大括号包围的语句序列.</p>
+
+<pre>interface ExpressionStatement &lt;: Statement {
+ type: "ExpressionStatement";
+ expression: Expression;
+}
+</pre>
+
+<p>一个表达式语句,也就是,仅有一个表达式组成的语句.</p>
+
+<pre>interface IfStatement &lt;: Statement {
+ type: "IfStatement";
+ test: Expression;
+ consequent: Statement;
+ alternate: Statement | null;
+}
+</pre>
+
+<p>一个<code>if</code>语句.</p>
+
+<pre>interface LabeledStatement &lt;: Statement {
+ type: "LabeledStatement";
+ label: Identifier;
+ body: Statement;
+}
+</pre>
+
+<p>一个标签语句,也就是, a statement prefixed by a <code>break</code>/<code>continue</code> label.</p>
+
+<pre>interface BreakStatement &lt;: Statement {
+ type: "BreakStatement";
+ label: Identifier | null;
+}
+</pre>
+
+<p>一个<code>break</code>语句.</p>
+
+<pre>interface ContinueStatement &lt;: Statement {
+ type: "ContinueStatement";
+ label: Identifier | null;
+}
+</pre>
+
+<p>一个<code>continue语句</code>.</p>
+
+<pre>interface WithStatement &lt;: Statement {
+ type: "WithStatement";
+ object: Expression;
+ body: Statement;
+}
+</pre>
+
+<p>A <code>with</code> statement.</p>
+
+<pre>interface SwitchStatement &lt;: Statement {
+ type: "SwitchStatement";
+ discriminant: Expression;
+ cases: [ SwitchCase ];
+ lexical: boolean;
+}
+</pre>
+
+<p>一个<code>switch</code>语句. The lexical flag is metadata indicating whether the <code>switch</code> statement contains any unnested <code>let</code> declarations (and therefore introduces a new lexical scope).</p>
+
+<pre>interface ReturnStatement &lt;: Statement {
+ type: "ReturnStatement";
+ argument: Expression | null;
+}
+</pre>
+
+<p>一个<code>return</code>语句.</p>
+
+<pre>interface ThrowStatement &lt;: Statement {
+ type: "ThrowStatement";
+ argument: Expression;
+}
+</pre>
+
+<p>一个<code>throw</code>语句.</p>
+
+<pre>interface TryStatement &lt;: Statement {
+ type: "TryStatement";
+ block: BlockStatement;
+ handlers: [ CatchClause ];
+ finalizer: BlockStatement | null;
+}
+</pre>
+
+<p>一个<code>try</code>语句.</p>
+
+<div class="note"><strong>注:</strong> 多个<code>catch</code>子句是SpiderMonkey特有的.</div>
+
+<pre>interface WhileStatement &lt;: Statement {
+ type: "WhileStatement";
+ test: Expression;
+ body: Statement;
+}
+</pre>
+
+<p>一个<code>while</code>语句.</p>
+
+<pre>interface DoWhileStatement &lt;: Statement {
+ type: "DoWhileStatement";
+ body: Statement;
+ test: Expression;
+}
+</pre>
+
+<p>一个<code>do</code>/<code>while</code>语句.</p>
+
+<pre>interface ForStatement &lt;: Statement {
+ type: "ForStatement";
+ init: VariableDeclaration | Expression | null;
+ test: Expression | null;
+ update: Expression | null;
+ body: Statement;
+}
+</pre>
+
+<p>一个<code>for</code>语句.</p>
+
+<pre>interface ForInStatement &lt;: Statement {
+ type: "ForInStatement";
+ left: VariableDeclaration | Expression;
+ right: Expression;
+ body: Statement;
+ each: boolean;
+}
+</pre>
+
+<p>一个<code>for</code>/<code>in</code>语句, or, if <code>each</code> is <code>true</code>, a <code>for each</code>/<code>in</code> statement.</p>
+
+<div class="note"><strong>注:</strong> <code>for each</code>语法是SpiderMonkey特有的.</div>
+
+<pre>interface LetStatement &lt;: Statement {
+ type: "LetStatement";
+ head: [ { id: Pattern, init: Expression | null } ];
+ body: Statement;
+}
+</pre>
+
+<p>一个<code>let语句</code>.</p>
+
+<div class="note"><strong>注:</strong> <code>let</code>语句形式是SpiderMonkey特有的.</div>
+
+<pre>interface DebuggerStatement &lt;: Statement {
+ type: "DebuggerStatement";
+}
+</pre>
+
+<p>一个<code>debugger</code>语句.</p>
+
+<div class="note"><strong>注:</strong> <code>debugger</code>语句是ECMAScript 5中的新语法,尽管SpiderMonkey已经支持它很多年了.</div>
+
+<h3 id="声明">声明</h3>
+
+<pre>interface Declaration &lt;: Statement { }
+</pre>
+
+<p>Any declaration node. Note that declarations are considered statements; this is because declarations can appear in any statement context in the language recognized by the SpiderMonkey parser.</p>
+
+<div class="note"><strong>注:</strong> 任意嵌套作用域下的声明是SpiderMonkey特有的.</div>
+
+<pre>interface FunctionDeclaration &lt;: Function, Declaration {
+ type: "FunctionDeclaration";
+ id: Identifier;
+ params: [ Pattern ];
+ defaults: [ Expression ];
+ rest: Identifier | null;
+ body: BlockStatement | Expression;
+ generator: boolean;
+ expression: boolean;
+}
+</pre>
+
+<p>一个函数声明.</p>
+
+<div class="note"><strong>注:</strong> <code>id</code>字段不能为<code>null</code>.</div>
+
+<pre>interface VariableDeclaration &lt;: Declaration {
+ type: "VariableDeclaration";
+ declarations: [ VariableDeclarator ];
+ kind: "var" | "let" | "const";
+}
+</pre>
+
+<p>一个变量声明,可以通过<code>var</code>, <code>let</code>, 或<code>const</code>.</p>
+
+<pre>interface VariableDeclarator &lt;: Node {
+ type: "VariableDeclarator";
+ id: Pattern;
+ init: Expression | null;
+}
+</pre>
+
+<p>一个变量<span class="st">声明符</span>.</p>
+
+<div class="note"><strong>注:</strong> <code>id</code>字段不能为<code>null</code>.</div>
+
+<div class="note"><strong>注:</strong> <code>let</code>和<code>const是</code>SpiderMonkey特有的.</div>
+
+<h3 id="表达式">表达式</h3>
+
+<pre>interface Expression &lt;: Node, Pattern { }</pre>
+
+<p>任意表达式节点. Since the left-hand side of an assignment may be any expression in general, an expression can also be a pattern.</p>
+
+<pre>interface ThisExpression &lt;: Expression {
+ type: "ThisExpression";
+}
+</pre>
+
+<p>一个<code>this</code>表达式.</p>
+
+<pre>interface ArrayExpression &lt;: Expression {
+ type: "ArrayExpression";
+ elements: [ Expression | null ];
+}</pre>
+
+<p>一个数组表达式.</p>
+
+<pre>interface ObjectExpression &lt;: Expression {
+ type: "ObjectExpression";
+ properties: [ { key: Literal | Identifier,
+  value: Expression,
+ kind: "init" | "get" | "set" } ];
+}</pre>
+
+<p>一个对象表达式. A literal property in an object expression can have either a string or number as its <code>value</code>. Ordinary property initializers have a <code>kind</code> value <code>"init"</code>; getters and setters have the <code>kind</code> values <code>"get"</code> and <code>"set"</code>, respectively.</p>
+
+<pre>interface FunctionExpression &lt;: Function, Expression {
+ type: "FunctionExpression";
+ id: Identifier | null;
+ params: [ Pattern ];
+ defaults: [ Expression ];
+ rest: Identifier | null;
+ body: BlockStatement | Expression;
+ generator: boolean;
+ expression: boolean;
+}
+</pre>
+
+<p>一个函数表达式.</p>
+
+<pre>interface SequenceExpression &lt;: Expression {
+ type: "SequenceExpression";
+ expressions: [ Expression ];
+}</pre>
+
+<p>一个序列表达式,也就是一个由逗号分割的表达式序列.</p>
+
+<pre>interface UnaryExpression &lt;: Expression {
+ type: "UnaryExpression";
+ operator: UnaryOperator;
+ prefix: boolean;
+ argument: Expression;
+}</pre>
+
+<p>A unary operator expression.</p>
+
+<pre>interface BinaryExpression &lt;: Expression {
+ type: "BinaryExpression";
+ operator: BinaryOperator;
+ left: Expression;
+ right: Expression;
+}</pre>
+
+<p>一个二元运算符表达式.</p>
+
+<pre>interface AssignmentExpression &lt;: Expression {
+ type: "AssignmentExpression";
+ operator: AssignmentOperator;
+ left: Expression;
+ right: Expression;
+}</pre>
+
+<p>An assignment operator expression.</p>
+
+<pre>interface UpdateExpression &lt;: Expression {
+ type: "UpdateExpression";
+ operator: UpdateOperator;
+ argument: Expression;
+ prefix: boolean;
+}</pre>
+
+<p>An update (increment or decrement) operator expression.</p>
+
+<pre>interface LogicalExpression &lt;: Expression {
+ type: "LogicalExpression";
+ operator: LogicalOperator;
+ left: Expression;
+ right: Expression;
+}</pre>
+
+<p>一个逻辑运算符表达式.</p>
+
+<pre>interface ConditionalExpression &lt;: Expression {
+ type: "ConditionalExpression";
+ test: Expression;
+ alternate: Expression;
+ consequent: Expression;
+}</pre>
+
+<p>一个条件运算符表达式, i.e., a ternary <code>?</code>/<code>:</code> expression.</p>
+
+<pre>interface NewExpression &lt;: Expression {
+ type: "NewExpression";
+ callee: Expression;
+ arguments: [ Expression ] | null;
+}</pre>
+
+<p>A <code>new</code> expression.</p>
+
+<pre>interface CallExpression &lt;: Expression {
+ type: "CallExpression";
+ callee: Expression;
+ arguments: [ Expression ];
+}</pre>
+
+<p>A function or method call expression.</p>
+
+<pre>interface MemberExpression &lt;: Expression {
+ type: "MemberExpression";
+ object: Expression;
+ property: Identifier | Expression;
+ computed : boolean;
+}</pre>
+
+<p>一个member表达式. If <code>computed === true</code>, the node corresponds to a computed <code>e1[e2]</code> expression and property is an <code>Expression</code>. If <code>computed === false</code>, the node corresponds to a static <code>e1.x</code> expression and property is an <code>Identifier</code>.</p>
+
+<pre>interface YieldExpression &lt;: Expression {
+ argument: Expression | null;
+}
+</pre>
+
+<p>A <code>yield</code> expression.</p>
+
+<div class="note"><strong>注:</strong> <code>yield</code> expressions 是SpiderMonkey特有的.</div>
+
+<pre>interface ComprehensionExpression &lt;: Expression {
+ body: Expression;
+ blocks: [ ComprehensionBlock ];
+ filter: Expression | null;
+}
+</pre>
+
+<p>An <a href="/en/JavaScript/Guide/Obsolete_Pages/Working_with_Arrays#Array_comprehensions" title="https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Working_with_Arrays#Array_comprehensions">array comprehension</a>. The <code>blocks</code> array corresponds to the sequence of <code>for</code> and <code>for each</code> blocks. The optional <code>filter</code> expression corresponds to the final <code>if</code> clause, if present.</p>
+
+<div class="note"><strong>注:</strong> Array comprehensions 是SpiderMonkey特有的.</div>
+
+<pre>interface GeneratorExpression &lt;: Expression {
+ body: Expression;
+ blocks: [ ComprehensionBlock ];
+ filter: Expression | null;
+}
+</pre>
+
+<p>A <a href="/en/JavaScript/Guide/Iterators_and_Generators#Generator_expressions" title="https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Iterators_and_Generators#Generator_expressions">generator expression</a>. As with array comprehensions, the <code>blocks</code> array corresponds to the sequence of <code>for</code> and <code>for each</code> blocks, and the optional <code>filter</code> expression corresponds to the final <code>if</code> clause, if present.</p>
+
+<div class="note"><strong>注:</strong> Generator expressions 是SpiderMonkey特有的.</div>
+
+<pre>interface GraphExpression &lt;: Expression {
+ index: uint32;
+ expression: Literal;
+}
+</pre>
+
+<p>A <a href="/en/JavaScript/Sharp_variables_in_JavaScript" title="https://developer.mozilla.org/en/Sharp_variables_in_JavaScript">graph expression</a>, aka "sharp literal," such as <code>#1={ self: #1# }</code>.</p>
+
+<div class="note"><strong>注:</strong> Graph expressions 是SpiderMonkey特有的.</div>
+
+<pre>interface GraphIndexExpression &lt;: Expression {
+ index: uint32;
+}
+</pre>
+
+<p>一个<a href="/en/JavaScript/Sharp_variables_in_JavaScript" title="https://developer.mozilla.org/en/Sharp_variables_in_JavaScript">graph索引表达式</a>,又称为"井号变量",比如<code>#1#</code>.</p>
+
+<div class="note"><strong>注:</strong> Graph索引表达式</div>
+
+<div class="note">Graph索引表达式是SpiderMonkey特有的.</div>
+
+<pre>interface LetExpression &lt;: Expression {
+ type: "LetExpression";
+ head: [ { id: Pattern, init: Expression | null } ];
+ body: Expression;
+}
+</pre>
+
+<p>一个<code>let表达式</code>.</p>
+
+<div class="note"><strong>注:</strong> <code>let</code>表达式是SpiderMonkey特有的.</div>
+
+<h3 id="模式">模式</h3>
+
+<pre>interface Pattern &lt;: Node { }
+</pre>
+
+<p>JavaScript 1.7 introduced <a href="/en/JavaScript/New_in_JavaScript/1.7#Destructuring_assignment_%28Merge_into_own_page.2fsection%29" title="https://developer.mozilla.org/en/new_in_javascript_1.7#Destructuring_assignment_(Merge_into_own_page.2fsection)">destructuring assignment and binding</a> forms. All binding forms (such as function parameters, variable declarations, and <code>catch</code> block headers), accept array and object destructuring patterns in addition to plain identifiers. The left-hand sides of assignment expressions can be arbitrary expressions, but in the case where the expression is an object or array literal, it is interpreted by SpiderMonkey as a destructuring pattern.</p>
+
+<p>Since the left-hand side of an assignment can in general be any expression, in an assignment context, a pattern can be any expression. In binding positions (such as function parameters, variable declarations, and <code>catch</code> headers), patterns can only be identifiers in the base case, not arbitrary expressions.</p>
+
+<pre>interface ObjectPattern &lt;: Pattern {
+ type: "ObjectPattern";
+ properties: [ { key: Literal | Identifier, value: Pattern } ];
+}
+</pre>
+
+<p>An object-destructuring pattern. A literal property in an object pattern can have either a string or number as its <code>value</code>.</p>
+
+<pre>interface ArrayPattern &lt;: Pattern {
+ type: "ArrayPattern";
+ elements: [ Pattern | null ];
+}
+</pre>
+
+<p>An array-destructuring pattern.</p>
+
+<h3 id="子句">子句</h3>
+
+<pre>interface SwitchCase &lt;: Node {
+ type: "SwitchCase";
+ test: Expression | null;
+ consequent: [ Statement ];
+}
+</pre>
+
+<p>一个<code>case</code> (if <code>test</code> is an <code>Expression</code>) or <code>default</code> (if <code>test === null</code>) clause in the body of a <code>switch</code>语句.</p>
+
+<pre>interface CatchClause &lt;: Node {
+ type: "CatchClause";
+ param: Pattern;
+ guard: Expression | null;
+ body: BlockStatement;
+}
+</pre>
+
+<p>A <code>catch</code> clause following a <code>try</code> block. The optional <code>guard</code> property corresponds to the optional expression guard on the bound variable.</p>
+
+<div class="note"><strong>注:</strong> The guard expression is SpiderMonkey-specific.</div>
+
+<pre>interface ComprehensionBlock &lt;: Node {
+ left: Pattern;
+ right: Expression;
+ each: boolean;
+}
+</pre>
+
+<p>A <code>for</code> or <code>for each</code> block in an array comprehension or generator expression.</p>
+
+<div class="note"><strong>注:</strong> Array comprehensions and generator expressions 是SpiderMonkey特有的.</div>
+
+<h3 class="r" id="杂项"><nobr>杂项</nobr></h3>
+
+<pre>interface Identifier &lt;: Node, Expression, Pattern {
+ type: "Identifier";
+ name: string;
+}
+</pre>
+
+<p>An identifier. Note that an identifier may be an expression or a destructuring pattern.</p>
+
+<pre>interface Literal &lt;: Node, Expression {
+ type: "Literal";
+ value: string | boolean | null | number | RegExp;
+}
+</pre>
+
+<p>A literal token. Note that a literal can be an expression.</p>
+
+<pre>enum UnaryOperator {
+ "-" | "+" | "!" | "~" | "typeof" | "void" | "delete"
+}
+</pre>
+
+<p>A unary operator token.</p>
+
+<pre>enum BinaryOperator {
+ "==" | "!=" | "===" | "!=="
+ | "&lt;" | "&lt;=" | "&gt;" | "&gt;="
+ | "&lt;&lt;" | "&gt;&gt;" | "&gt;&gt;&gt;"
+ | "+" | "-" | "*" | "/" | "%"
+ | "|" | "^" | "in"
+ | "instanceof" | ".."
+}
+</pre>
+
+<p>A binary operator token.</p>
+
+<div class="note"><strong>注:</strong> The <code>..</code> operator is E4X-specific.</div>
+
+<pre>enum LogicalOperator {
+ "||" | "&amp;&amp;"
+}
+</pre>
+
+<p>A logical operator token.</p>
+
+<pre>enum AssignmentOperator {
+ "=" | "+=" | "-=" | "*=" | "/=" | "%="
+ | "&lt;&lt;=" | "&gt;&gt;=" | "&gt;&gt;&gt;="
+ | "|=" | "^=" | "&amp;="
+}
+</pre>
+
+<p>An assignment operator token.</p>
+
+<pre>enum UpdateOperator {
+ "++" | "--"
+}
+</pre>
+
+<p>An update (increment or decrement) operator token.</p>
+
+<h3 id="E4X">E4X</h3>
+
+<p>下面介绍一下为E4X提供支持的节点类型.</p>
+
+<div class="note"><strong>注:</strong> E4X不是ECMAScript规范(<a class="external" href="http://www.ecma-international.org/publications/standards/Ecma-262.htm" title="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMA-262</a>)的一部分,它是一个单独的标准(<a class="external" href="http://www.ecma-international.org/publications/standards/Ecma-357.htm" title="http://www.ecma-international.org/publications/standards/Ecma-357.htm">ECMA-357</a>).</div>
+
+<h4 id="声明_2">声明</h4>
+
+<pre>interface XMLDefaultDeclaration &lt;: Declaration {
+ type: "XMLDefaultDeclaration";
+ namespace: Expression;
+}
+</pre>
+
+<p>一个默认<code>xml命名空间</code>声明</p>
+
+<h4 id="表达式_2">表达式</h4>
+
+<pre>interface XMLAnyName &lt;: Expression {
+ type: "XMLAnyName";
+}
+</pre>
+
+<p>The special E4X wildcard pseudo-identifier <code>*</code>.</p>
+
+<pre>interface XMLQualifiedIdentifier &lt;: Expression {
+ type: "XMLQualifiedIdentifier";
+ left: Identifier | XMLAnyName;
+ right: Identifier | Expression;
+ computed: boolean;
+}
+</pre>
+
+<p>An E4X qualified identifier, i.e., a pseudo-identifier using the namespace separator <code>::</code>. If the qualified identifier has a computed name (i.e., the <code>id::[expr]</code> form), then <code>computed</code> is <code>true</code> and the <code>right</code> property is an expression.</p>
+
+<pre>interface XMLFunctionQualifiedIdentifier &lt;: Expression {
+ type: "XMLFunctionQualifiedIdentifier";
+ right: Identifier | Expression;
+ computed: boolean;
+}
+</pre>
+
+<p>An E4X identifier qualified by the <code>function</code> keyword, e.g. <code>function::id</code>.</p>
+
+<div class="note"><strong>注:</strong> <code>function</code>-qualified identifiers 是SpiderMonkey特有的.</div>
+
+<pre>interface XMLAttributeSelector &lt;: Expression {
+ type: "XMLAttributeSelector";
+ attribute: Expression;
+}
+</pre>
+
+<p>An E4X attribute selector expression, i.e., an <code>@</code> expression.</p>
+
+<pre>interface XMLFilterExpression &lt;: Expression {
+ type: "XMLFilterExpression";
+ left: Expression;
+ right: Expression;
+}
+</pre>
+
+<p>An E4X list filter expression, i.e., an expression of the form <code>expr.(expr)</code>.</p>
+
+<pre>interface XMLElement &lt;: XML, Expression {
+ type: "XMLElement";
+ contents: [ XML ];
+}
+</pre>
+
+<p>An E4X literal representing a single XML element.</p>
+
+<pre>interface XMLList &lt;: XML, Expression {
+ type: "XMLList";
+ contents: [ XML ];
+}
+</pre>
+
+<p>An E4X literal representing a list of XML elements.</p>
+
+<h4 id="XML">XML</h4>
+
+<pre>interface XML &lt;: Node { }
+</pre>
+
+<p>XML data.</p>
+
+<pre>interface XMLEscape &lt;: XML {
+ type "XMLEscape";
+ expression: Expression;
+}
+</pre>
+
+<p>XML data with an escaped JavaScript expression.</p>
+
+<pre>interface XMLText &lt;: XML {
+ type: "XMLText";
+ text: string;
+}
+</pre>
+
+<p>Literal XML text.</p>
+
+<pre>interface XMLStartTag &lt;: XML {
+ type: "XMLStartTag";
+ contents: [ XML ];
+}
+</pre>
+
+<p>An XML start tag.</p>
+
+<pre>interface XMLEndTag &lt;: XML {
+ type: "XMLEndTag";
+ contents: [ XML ];
+}
+</pre>
+
+<p>An XML end tag.</p>
+
+<pre>interface XMLPointTag &lt;: XML {
+ type: "XMLPointTag";
+ contents: [ XML ];
+}
+</pre>
+
+<p>An XML point tag.</p>
+
+<pre>interface XMLName &lt;: XML {
+ type: "XMLName";
+ contents: string | [ XML ];
+}
+</pre>
+
+<p>An XML name.</p>
+
+<pre>interface XMLAttribute &lt;: XML {
+ type: "XMLAttribute";
+ value: string;
+}
+</pre>
+
+<p>An XML attribute value.</p>
+
+<pre>interface XMLCdata &lt;: XML {
+ type: "XMLCdata";
+ contents: string;
+}
+</pre>
+
+<p>An XML CDATA node.</p>
+
+<pre>interface XMLComment &lt;: XML {
+ type: "XMLComment";
+ contents: string;
+}
+</pre>
+
+<p>An XML comment.</p>
+
+<pre>interface XMLProcessingInstruction &lt;: XML {
+ type: "XMLProcessingInstruction";
+ target: string;
+ contents: string | null;
+}
+</pre>
+
+<p>An XML processing instruction.</p>
+
+<h2 id="Builder_objects">Builder objects</h2>
+
+<p>The optional <strong><code>builder</code></strong> parameter to <code>Reflect.parse()</code> makes it possible to construct user-specified data from the parser, rather than the default <code>Node</code> objects. Builder objects may contain any of the callback methods described in this section.</p>
+
+<p>Each callback can produce any custom, user-defined datatype; these are referred to below as <code>CustomExpression</code>, <code>CustomStatement</code>, etc.</p>
+
+<div class="note"><strong>注:</strong> Because this library uses <code>null</code> for optional nodes, it is recommended that user-defined datatypes <strong>not</strong> use <code>null</code> as a representation of an AST node.</div>
+
+<p>If the <strong><code>loc</code></strong> option is enabled (see the <a href="/en/SpiderMonkey/Parser_API#Reflect.parse(src.5b.2c_options.5d)" title="en/SpiderMonkey/Parser API#Reflect.parse(src.5b.2c options.5d)">Reflect.parse() options</a> above), then each callback is provided with the source location information of the parsed node as an extra parameter.</p>
+
+<p>All builder callbacks are optional. When a callback is missing, the default format is used, but the provided builder methods are still used recursively for sub-nodes.</p>
+
+<h3 id="Programs_2">Programs</h3>
+
+<h5 id="program(body_loc)"><code>program(body[, loc])</code></h5>
+
+<pre>body: [ CustomStatement ]
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomProgram</p>
+
+<p>Callback to produce a custom program node.</p>
+
+<h3 id="Statements">Statements</h3>
+
+<h5 id="emptyStatement(loc)"><code>emptyStatement([loc])</code></h5>
+
+<pre>loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom empty statement node.</p>
+
+<h5 id="blockStatement(body_loc)"><code>blockStatement(body[, loc])</code></h5>
+
+<pre>body: CustomStatement
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom block statement node.</p>
+
+<h5 id="expressionStatement(expr_loc)"><code>expressionStatement(expr[, loc])</code></h5>
+
+<pre>expr: CustomExpression
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom expression statement node.</p>
+
+<h5 id="labeledStatement(label_body_loc)"><code>labeledStatement(label, body[, loc])</code></h5>
+
+<pre>label: CustomIdentifier
+body: CustomStatement
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom labeled statement node.</p>
+
+<h5 id="ifStatement(test_cons_alt_loc)"><code>ifStatement(test, cons, alt[, loc])</code></h5>
+
+<pre>test: CustomExpression
+cons: CustomStatement
+alt: CustomStatement | null
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom <code>if</code> statement node.</p>
+
+<h5 id="switchStatement(disc_cases_isLexical_loc)"><code>switchStatement(disc, cases, isLexical[, loc])</code></h5>
+
+<pre>disc: CustomExpression
+cases: [ CustomSwitchCase ]
+isLexical: boolean
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom <code>switch</code> statement node. The <strong><code>isLexical</code></strong> flag is metadata indicating whether the <code>switch</code> statement contains any unnested <code>let</code> declarations (and therefore introduces a new lexical scope).</p>
+
+<h5 id="whileStatement(test_body_loc)"><code>whileStatement(test, body[, loc])</code></h5>
+
+<pre>test: CustomExpression
+body: CustomStatement
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom <code>while</code> statement node.</p>
+
+<h5 id="doWhileStatement(body_test_loc)"><code>doWhileStatement(body, test[, loc])</code></h5>
+
+<pre>body: CustomStatement
+test: CustomExpression
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom <code>do</code>-<code>while</code> statement node.</p>
+
+<h5 id="forStatement(init_test_update_body_loc)"><code>forStatement(init, test, update, body[, loc])</code></h5>
+
+<pre>init: CustomVariableDeclaration | CustomExpression | null
+test: CustomExpression | null
+update: CustomExpression | null
+body: CustomStatement
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom <code>for</code> statement node.</p>
+
+<h5 id="forInStatement(left_right_body_isForEach_loc)"><code>forInStatement(left, right, body, isForEach[, loc])</code></h5>
+
+<pre>left: CustomVariableDeclaration | CustomExpression
+right: CustomExpression
+body: CustomStatement
+isForEach: boolean
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom <code>for</code>-<code>in</code> statement node. The <strong><code>isForEach</code></strong> flag indicates whether the node is a <code>for each</code> statement.</p>
+
+<h5 id="breakStatement(label_loc)"><code>breakStatement(label[, loc])</code></h5>
+
+<pre>label: CustomIdentifier | null
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom <code>break</code> statement node.</p>
+
+<h5 id="continueStatement(label_loc)"><code>continueStatement(label[, loc])</code></h5>
+
+<pre>label: CustomIdentifier | null
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom <code>continue</code> statement node.</p>
+
+<h5 id="withStatement(obj_body_loc)"><code>withStatement(obj, body[, loc])</code></h5>
+
+<pre>obj: CustomExpression
+body: CustomStatement
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom <code>with</code> statement node.</p>
+
+<h5 id="returnStatement(arg_loc)"><code>returnStatement(arg[, loc])</code></h5>
+
+<pre>arg: CustomExpression | null
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom <code>return</code> statement node.</p>
+
+<h5 id="tryStatement(body_handlers_fin_loc)"><code>tryStatement(body, handlers, fin[, loc])</code></h5>
+
+<pre>body: CustomStatement
+handlers: [ CustomCatchClause ]
+fin: CustomStatement | null
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom <code>try</code> statement node.</p>
+
+<h5 id="throwStatement(arg_loc)"><code>throwStatement(arg[, loc])</code></h5>
+
+<pre>arg: CustomExpression
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom <code>throw</code> statement node.</p>
+
+<h5 id="debuggerStatement(loc)"><code>debuggerStatement([loc])</code></h5>
+
+<pre>loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom <code>debugger</code> statement node.</p>
+
+<h5 id="letStatement(head_body_loc)"><code>letStatement(head, body[, loc])</code></h5>
+
+<pre>head: [ CustomDeclarator ]
+body: CustomStatement
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomStatement</p>
+
+<p>Callback to produce a custom <code>let</code> statement node.</p>
+
+<h3 id="声明_3">声明</h3>
+
+<h5 id="functionDeclaration(name_args_body_isGenerator_isExpression_loc)"><code>functionDeclaration(name, args, body, isGenerator, isExpression[, loc])</code></h5>
+
+<pre>name: string
+args: [ CustomPattern ]
+body: CustomStatement | CustomExpression
+isGenerator: boolean
+isExpression: boolean
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomDeclaration</p>
+
+<p>Callback to produce a custom function declaration node.</p>
+
+<h5 id="variableDeclaration(kind_dtors_loc)"><code>variableDeclaration(kind, dtors[, loc])</code></h5>
+
+<pre>kind: "const" | "let" | "var"
+dtors: [ CustomDeclarator ]
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomDeclaration</p>
+
+<p>Callback to produce a custom variable declaration node.</p>
+
+<h5 id="variableDeclarator(patt_init_loc)"><code>variableDeclarator(patt, init[, loc])</code></h5>
+
+<pre>patt: CustomPattern
+init: CustomExpression | null
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomDeclarator</p>
+
+<p>Callback to produce a custom variable declarator node.</p>
+
+<h3 id="表达式_3">表达式</h3>
+
+<h5 id="sequenceExpression(exprs_loc)"><code>sequenceExpression(exprs[, loc])</code></h5>
+
+<pre>exprs: [ CustomExpression ]
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom sequence expression node.</p>
+
+<h5 id="conditionalExpression(test_cons_alt_loc)"><code>conditionalExpression(test, cons, alt[, loc])</code></h5>
+
+<pre>test: CustomExpression
+cons: CustomExpression
+alt: CustomExpression
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom conditional expression node.</p>
+
+<h5 id="unaryExpression(op_arg_isPrefix_loc)"><code>unaryExpression(op, arg, isPrefix[, loc])</code></h5>
+
+<pre>op: UnaryOperator
+arg: CustomExpression
+isPrefix: boolean
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom unary expression node.</p>
+
+<h5 id="binaryExpression(op_left_right_loc)"><code>binaryExpression(op, left, right[, loc])</code></h5>
+
+<pre>op: BinaryOperator
+left: CustomExpression
+right: CustomExpression
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom binary expression node.</p>
+
+<h5 id="assignmentExpression(op_left_right_loc)"><code>assignmentExpression(op, left, right[, loc])</code></h5>
+
+<pre>op: AssignmentOperator
+left: CustomExpression
+right: CustomExpression
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom assignment expression node.</p>
+
+<h5 id="logicalExpression(op_left_right_loc)"><code>logicalExpression(op, left, right[, loc])</code></h5>
+
+<pre>op: LogicalOperator
+left: CustomExpression
+right: CustomExpression
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom logical expression node.</p>
+
+<h5 id="updateExpression(op_arg_isPrefix_loc)"><code>updateExpression(op, arg, isPrefix[, loc])</code></h5>
+
+<pre>op: UpdateOperator
+arg: CustomExpression
+isPrefix: boolean
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom update expression node.</p>
+
+<h5 id="newExpression(callee_args_loc)"><code>newExpression(callee, args[, loc])</code></h5>
+
+<pre>callee: CustomExpression
+args: [ CustomExpression ]
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom <code>new</code>-expression node.</p>
+
+<h5 id="callExpression(callee_args_loc)"><code>callExpression(callee, args[, loc])</code></h5>
+
+<pre>callee: CustomExpression
+args: [ CustomExpression ]
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom function call node.</p>
+
+<h5 id="memberExpression(obj_prop_isComputed_loc)"><code>memberExpression(obj, prop, isComputed[, loc])</code></h5>
+
+<pre>obj: CustomExpression
+prop: CustomIdentifier | CustomExpression
+isComputed: boolean
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom member expression node.</p>
+
+<h5 id="functionExpression(name_args_body_isGenerator_isExpression_loc)"><code>functionExpression(name, args, body, isGenerator, isExpression[, loc])</code></h5>
+
+<pre>name: CustomIdentifier | null
+args: [ CustomPattern ]
+body: CustomStatement | CustomExpression
+isGenerator: boolean
+isExpression: boolean
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom function expression node.</p>
+
+<h5 id="arrayExpression(elts_loc)"><code>arrayExpression(elts[, loc])</code></h5>
+
+<pre>elts: [ CustomExpression | null ]
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom array expression node.</p>
+
+<h5 id="objectExpression(props_loc)"><code>objectExpression(props[, loc])</code></h5>
+
+<pre>props: [ CustomObjectProperty ]
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom object expression node.</p>
+
+<h5 id="thisExpression(loc)"><code>thisExpression([loc])</code></h5>
+
+<pre>loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom <code>this</code> expression node.</p>
+
+<h5 id="graphExpression(index_expr_loc)"><code>graphExpression(index, expr[, loc])</code></h5>
+
+<pre>index: uint32 &gt;= 1
+expr: CustomExpression
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom <code>graph</code> expression node.</p>
+
+<h5 id="graphIndexExpression(index_loc)"><code>graphIndexExpression(index[, loc])</code></h5>
+
+<pre>index: uint32 &gt;= 1
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom <code>graph index</code> expression node.</p>
+
+<h5 id="comprehensionExpression(body_blocks_filter_loc)"><code>comprehensionExpression(body, blocks, filter[, loc])</code></h5>
+
+<pre>body: CustomExpression
+blocks: [ CustomComprehensionBlock ]
+filter: CustomExpression | null
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom <code>comprehension</code> expression node.</p>
+
+<h5 id="generatorExpression(body_blocks_filter_loc)"><code>generatorExpression(body, blocks, filter[, loc])</code></h5>
+
+<pre>body: CustomExpression
+blocks: [ CustomComprehensionBlock ]
+filter: CustomExpression | null
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom <code>generator</code> expression node.</p>
+
+<h5 id="yieldExpression(arg_loc)"><code>yieldExpression(arg[, loc])</code></h5>
+
+<pre>arg: CustomExpression
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom <code>yield</code> expression node.</p>
+
+<h5 id="letExpression(head_body_loc)"><code>letExpression(head, body[, loc])</code></h5>
+
+<pre>head: [ CustomDeclarator ]
+body: CustomExpression
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomExpression</p>
+
+<p>Callback to produce a custom <code>let</code> expression node.</p>
+
+<h3 id="Patterns">Patterns</h3>
+
+<h5 id="arrayPattern(elts_loc)"><code>arrayPattern(elts[, loc])</code></h5>
+
+<pre>elts: [ CustomPattern | null ]
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomPattern</p>
+
+<p>Callback to produce a custom array destructuring pattern node.</p>
+
+<h5 id="objectPattern(props_loc)"><code>objectPattern(props[, loc])</code></h5>
+
+<pre>props: [ CustomPropertyPattern ]
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomPattern</p>
+
+<p>Callback to produce a custom object destructuring pattern node.</p>
+
+<h5 id="propertyPattern(key_patt_loc)"><code>propertyPattern(key, patt[, loc])</code></h5>
+
+<pre>key: CustomLiteral | CustomIdentifier
+patt: CustomPattern
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomPropertyPattern</p>
+
+<p>Callback to produce a custom object property destructuring pattern node.</p>
+
+<h3 id="Clauses">Clauses</h3>
+
+<h5 id="switchCase(test_cons_loc)"><code>switchCase(test, cons[, loc])</code></h5>
+
+<pre>test: CustomExpression | null
+cons: [ CustomStatement ]
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomSwitchCase</p>
+
+<p>Callback to produce a custom <code>case</code> or <code>default</code> clause node. The <strong><code>test</code></strong> argument is <code>null</code> if and only if the node is a <code>default</code> clause.</p>
+
+<h5 id="catchClause(arg_guard_body_loc)"><code>catchClause(arg, guard, body[, loc])</code></h5>
+
+<pre>arg: CustomPattern
+guard: CustomExpression
+body: CustomStatement
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomCatchClause</p>
+
+<p>Callback to produce a custom <code>catch</code> clause node.</p>
+
+<h5 id="comprehensionBlock(left_right_isForEach_loc)"><code>comprehensionBlock(left, right, isForEach[, loc])</code></h5>
+
+<pre>left: CustomPattern
+right: CustomExpression
+isForEach: boolean
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomComprehensionBlock</p>
+
+<p>Callback to produce a custom comprehension block node. The <strong><code>isForEach</code></strong> flag indicates whether the node is a <code>for each</code> block.</p>
+
+<h3 id="Miscellaneous">Miscellaneous</h3>
+
+<h5 id="identifier(name_loc)"><code>identifier(name[, loc])</code></h5>
+
+<pre>name: string
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomIdentifier/CustomPattern/CustomExpression</p>
+
+<p>Callback to produce a custom identifier node.</p>
+
+<h5 id="literal(val_loc)"><code>literal(val[, loc])</code></h5>
+
+<pre>val: string | boolean | null | number | RegExp
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomLiteral / CustomExpression</p>
+
+<p>Callback to produce a custom literal node.</p>
+
+<h5 id="property(kind_key_val_loc)"><code>property(kind, key, val[, loc])</code></h5>
+
+<pre>kind: "init" | "get" | "set"
+key: CustomLiteral | CustomIdentifier
+val: CustomExpression
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomObjectProperty</p>
+
+<p>Callback to produce a custom object property initializer node.</p>
+
+<h3 id="E4X_2">E4X</h3>
+
+<h4 id="Declarations">Declarations</h4>
+
+<h5 id="xmlDefaultDeclaration(ns_loc)"><code>xmlDefaultDeclaration(ns[, loc])</code></h5>
+
+<pre>loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomDeclaration</p>
+
+<p>Callback to produce a custom XML default namespace declaration node.</p>
+
+<h4 id="Expressions">Expressions</h4>
+
+<h5 id="xmlAnyName(loc)"><code>xmlAnyName([loc])</code></h5>
+
+<pre>loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXMLAnyName/CustomXML/CustomExpression</p>
+
+<p>Callback to produce a custom XML node for the wildcard pseudo-identifier <code>*</code>.</p>
+
+<h5 id="xmlAttributeSelector(expr_loc)"><code>xmlAttributeSelector(expr[, loc])</code></h5>
+
+<pre>expr: CustomExpression
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXML/CustomExpression</p>
+
+<p>Callback to produce a custom XML attribute selector node.</p>
+
+<h5 id="xmlFilterExpression(left_right_loc)"><code>xmlFilterExpression(left, right[, loc])</code></h5>
+
+<pre>left: CustomExpression
+right: CustomExpression
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXML/CustomExpression</p>
+
+<p>Callback to produce a custom XML filter expression node.</p>
+
+<h5 id="xmlQualifiedIdentifier(left_right_isComputed_loc)"><code>xmlQualifiedIdentifier(left, right, isComputed[, loc])</code></h5>
+
+<pre>left: CustomIdentifier | CustomXMLAnyName
+right: CustomIdentifier | CustomExpression
+isComputed: boolean
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXML/CustomExpression</p>
+
+<p>Callback to produce a custom qualified identifier node.</p>
+
+<h5 id="xmlFunctionQualifiedIdentifier(right_isComputed_loc)"><code>xmlFunctionQualifiedIdentifier(right, isComputed[, loc])</code></h5>
+
+<pre>right: CustomIdentifier | CustomExpression
+isComputed: boolean
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXML/CustomExpression</p>
+
+<p>Callback to produce a custom XML <code>function</code>-qualified identifier node.</p>
+
+<h5 id="xmlElement(contents_loc)"><code>xmlElement(contents[, loc])</code></h5>
+
+<pre>contents: [ CustomXML ]
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXML / CustomExpression</p>
+
+<p>Callback to produce a custom XML element node.</p>
+
+<h5 id="xmlList(contents_loc)"><code>xmlList(contents[, loc])</code></h5>
+
+<pre>contents: [ CustomXML ]
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXML/CustomExpression</p>
+
+<p>Callback to produce a custom XML list node.</p>
+
+<h4 id="XML_2">XML</h4>
+
+<h5 id="xmlEscape(expr_loc)"><code>xmlEscape(expr[, loc])</code></h5>
+
+<pre>expr: CustomExpression
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXML</p>
+
+<p>Callback to produce a custom XML escape node.</p>
+
+<h5 id="xmlText(text_loc)"><code>xmlText(text[, loc])</code></h5>
+
+<pre>text: string
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXML</p>
+
+<p>Callback to produce a custom XML text node.</p>
+
+<h5 id="xmlStartTag(contents_loc)"><code>xmlStartTag(contents[, loc])</code></h5>
+
+<pre>contents: [ CustomXML ]
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXML</p>
+
+<p>Callback to produce a custom XML start-tag node.</p>
+
+<h5 id="xmlEndTag(contents_loc)"><code>xmlEndTag(contents[, loc])</code></h5>
+
+<pre>contents: [ CustomXML ]
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXML</p>
+
+<p>Callback to produce a custom XML end-tag node.</p>
+
+<h5 id="xmlPointTag(contents_loc)"><code>xmlPointTag(contents[, loc])</code></h5>
+
+<pre>contents: [ CustomXML ]
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXML</p>
+
+<p>Callback to produce a custom XML point tag node.</p>
+
+<h5 id="xmlName(contents_loc)"><code>xmlName(contents[, loc])</code></h5>
+
+<pre>contents: string | [ CustomXML ]
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXML</p>
+
+<p>Callback to produce a custom XML name node.</p>
+
+<h5 id="xmlAttribute(value_loc)"><code>xmlAttribute(value[, loc])</code></h5>
+
+<pre>value: string
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXML</p>
+
+<p>Callback to produce a custom XML attribute node.</p>
+
+<h5 id="xmlCdata(contents_loc)"><code>xmlCdata(contents[, loc])</code></h5>
+
+<pre>contents: string
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXML</p>
+
+<p>Callback to produce a custom XML <code>CDATA</code> node.</p>
+
+<h5 id="xmlComment(contents_loc)"><code>xmlComment(contents[, loc])</code></h5>
+
+<pre>contents: string
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXML</p>
+
+<p>Callback to produce a custom XML comment node.</p>
+
+<h5 id="xmlProcessingInstruction(target_contents_loc)"><code>xmlProcessingInstruction(target, contents[, loc])</code></h5>
+
+<pre>target: string
+contents: string | null
+loc: SourceLocation
+</pre>
+
+<p><strong>返回:</strong> CustomXML</p>
+
+<p>Callback to produce a custom XML processing instruction node.</p>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/releases/index.html b/files/zh-cn/mozilla/projects/spidermonkey/releases/index.html
new file mode 100644
index 0000000000..fd88b37529
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/releases/index.html
@@ -0,0 +1,42 @@
+---
+title: SpiderMonkey releases
+slug: Mozilla/Projects/SpiderMonkey/Releases
+translation_of: Mozilla/Projects/SpiderMonkey/Releases
+---
+<div>{{SpiderMonkeySidebar("Releases")}}</div>
+
+<div class="summary">
+<p>本页开列了 <a href="/en-US/docs/Mozilla/Projects/SpiderMonkey">SpiderMonkey</a> 的版本记录.</p>
+</div>
+
+<div class="note">
+<p><strong>注意:</strong> 独立的 SpiderMonkey 并不是官方产品. Our continuous integration system does produce a tarball that is built into a binary that runs our smoke tests, but we do not maintain it nor actively test its suitability for general embedding. We have periodically created "releases", but they are best-effort and incomplete. We do happily accept patches, and make some effort to keep the tip of the Gecko tree minimally working as an embeddable source package. We are very limited in our ability to support older versions, including those labeled as "releases" on this page.</p>
+</div>
+
+<p>The easiest way to fetch the version corresponding to the current Firefox release is to visit the <a href="https://treeherder.mozilla.org/#/jobs?repo=mozilla-release&amp;filter-searchStr=spidermonkey-sm-package">treeherder page for the release repository</a> and click on the first SM(pkg) link you see. That will open a small window in the bottom left with a line like "<label>artifact uploaded:</label> <a href="https://queue.taskcluster.net/v1/task/e8X3tKITQTeSFhtdirD7Xg/runs/0/artifacts/public/build/mozjs-57.0.1.tar.bz2" title="artifact uploaded">mozjs-57.0.1.tar.bz2</a>".</p>
+
+<h2 id="当前版本">当前版本</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/52">SpiderMonkey 52</a></li>
+</ul>
+
+<h2 id="Future_release">Future release</h2>
+
+<ul>
+ <li>None</li>
+</ul>
+
+<h2 id="过往版本">过往版本</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/45">SpiderMonkey 45</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/38">SpiderMonkey 38</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/31">SpiderMonkey 31</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/24">SpiderMonkey 24</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/17">SpiderMonkey 17</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/1.8.8">SpiderMonkey 1.8.8</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/1.8.7">SpiderMonkey 1.8.7</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/1.8.5">SpiderMonkey 1.8.5</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/1.8">SpiderMonkey 1.8</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/projects/spidermonkey/split_object/index.html b/files/zh-cn/mozilla/projects/spidermonkey/split_object/index.html
new file mode 100644
index 0000000000..86d82e7d58
--- /dev/null
+++ b/files/zh-cn/mozilla/projects/spidermonkey/split_object/index.html
@@ -0,0 +1,72 @@
+---
+title: Split object
+slug: Mozilla/Projects/SpiderMonkey/Split_object
+translation_of: Mozilla/Projects/SpiderMonkey/Split_object
+---
+<p>In <a href="/en/SpiderMonkey" title="en/SpiderMonkey">SpiderMonkey</a>, a <strong>split object</strong> is made up of two <code><a href="/en/SpiderMonkey/JSAPI_Reference/JSObject" title="en/SpiderMonkey/JSAPI_Reference/JSObject">JSObject</a></code>s: an <strong>inner object</strong> and an <strong>outer object</strong>.</p>
+
+<p>Each half of a split object always has a pointer to the other half. Inner objects implement the <code><a href="/En/SpiderMonkey/JSAPI_Reference/JSExtendedClass.outerObject" title="En/SpiderMonkey/JSAPI_Reference/JSExtendedClass.outerObject">JSExtendedClass.outerObject</a></code> hook, which returns a pointer to the corresponding outer object. Outer objects implement the <code><a href="/En/SpiderMonkey/JSAPI_Reference/JSExtendedClass.outerObject" title="En/SpiderMonkey/JSAPI_Reference/JSExtendedClass.outerObject">JSExtendedClass.innerObject</a></code> hook. But the association is not fixed. An outer object may be associated with different inner objects at different times.</p>
+
+<p>This feature is complicated. Programs other than Mozilla that embed SpiderMonkey should avoid using split objects.</p>
+
+<h2 id="The_window_object" name="The_window_object">The <code>window</code> object</h2>
+
+<p>Split objects were introduced to resolve a problem posed by the <code><a href="/en/DOM/window" title="en/DOM/window">window</a></code> object. Three interrelated requirements on the <code>window</code> object seemed to conflict.</p>
+
+<ul>
+ <li>
+ <p>The <code>window</code> object is the global object for scripts in Web pages. Firefox has to maintain this for Web compatibility. For performance, access to global properties must be fast.</p>
+ </li>
+</ul>
+
+<ul>
+ <li>
+ <p>There is a glaring difference in the lifetime of the <code>window</code> object as seen from two different angles. Suppose a script in page A, in tab TA, has a reference to the <code>window</code> object of page B in another tab TB. The <code>window</code> object for tab TB must persist as the user navigates from page to page in that tab. To the script in page A, the <code>window</code> must appear to be a single object that moves from page to page. But each web page must load with fresh globals.</p>
+
+ <p>(The problem is even a bit subtler than this, since the reference may be direct or indirect. The script in A might have opened TB by calling <code><a href="/en/DOM/window.open" title="en/DOM/window.open">window.open</a></code>, which returns a direct reference to TB's <code>window</code>. More indirectly, suppose there's a JavaScript function defined in page B that refers to global variables in page B. If page A gets a reference to that function, then by calling it, it is indirectly accessing tab TB's <code>window</code>. The <code>Function</code> object carries a reference to the <code>window</code>, via the scope chain. To further complicate matters, A and B are in the same security domain, so security checks between them automatically succeed. This makes the problem resistant to a wrapper-based approach.)</p>
+
+ <p>Older versions of Firefox accomplished this by blowing away all <code>window</code> properties every time a user navigated to another page, then reusing the <code>window</code>. Each page, even on Back, had to load from scratch. This was slow. Circa Firefox 1.5, the decision was made to cache layout information and JavaScript state across navigation. A new approach for <code>window</code> was needed.</p>
+ </li>
+</ul>
+
+<ul>
+ <li>
+ <p>Security privileges are granted to JS code on the basis of the scope chain of the executing code. SpiderMonkey walks up the scope chain to the nearest object that has <code><a href="/en/SpiderMonkey/JSAPI_Reference/JSPrincipals" title="en/SpiderMonkey/JSAPI_Reference/JSPrincipals">JSPrincipals</a></code> attached. The end of the scope chain is the global object for the script. But what <code>JSPrincipals</code> should be attached to a <code>window</code> object? The principals of the page the window is <em>currently</em> displaying? But then the page that called <code>window.open</code> could use a <code>with</code> statement to inject that <code>window</code> into its scope chain, gaining access to that window's privileges. <em>(Note: <code>with</code> does add an object to the scope chain, but it's a special <code>With</code> wrapper object that is skipped, or something, during the search described here. This security feature is not peculiar to split objects. ...And yet, there is special code in jsobj.h with a comment about fixing some kind of interaction between <code>with</code> an split objects. Write that down, it'll be on the test.)</em></p>
+ </li>
+</ul>
+
+<p>Split objects were the solution. The inner <code>window</code> object is different for each page a browser window visits. It serves as the "globals" object and provides the <code>JSPrincipals</code> for scripts on that page. Access to inner <code>window</code> properties is fast. The outer <code>window</code> object is the object returned by <code>window.open</code>. It represents the window or tab itself and survives as the user navigates in that window or tab. The <code>window</code> object's <code><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass" title="en/SpiderMonkey/JSAPI_Reference/JSClass">JSClass</a>.resolve</code> hook ensures that properties of the inner object are visible via the outer object, if the running code has the right principals to access them. This privilege check may be slow.</p>
+
+<p>See {{ interwiki('wikimo', 'Gecko:SplitWindow', 'wikimo:Gecko:SplitWindow') }} and {{ Bug(296639) }} for more discussion.</p>
+
+<p>See also <a class="external" href="http://groups.google.com/group/mozilla.dev.tech.js-engine/msg/df81825b338fb84f" rel="freelink">http://groups.google.com/group/mozil...81825b338fb84f</a></p>
+
+<h2 id="Details" name="Details">Details</h2>
+
+<p>This section describes split objects as a feature of the JSAPI. It catalogues (and tries to explain) the subtle ways in which split objects affect SpiderMonkey's behavior.</p>
+
+<p>Split objects are only useful for implementing objects that will be on the scope chain of functions. SpiderMonkey assumes that inner and outer objects are dangerous in two different and complementary ways.</p>
+
+<p>Inner objects are dangerous because they have fast property accessors that do not perform security checks. Therefore, no function may be allowed to see an inner object that has different <code>JSPrincipals</code>. Apart from the security issue, if one page directly or indirectly gets a reference to another page's <code>window</code> object, that <code>window</code> object must appear to behave like the outer window and navigate from page to page. SpiderMonkey arranges this by not allowing JS code to see inner objects at all. To enforce this rule:</p>
+
+<ul>
+ <li>If <code>this</code> would evaluate to an inner object, it evaluates to the corresponding outer object instead.</li>
+</ul>
+
+<p>Outer objects are dangerous because their <code>JSPrincipals</code> may change over time. Because a <code>Function</code> inherits the <code>JSPrincipals</code> of its lexical scope (specifically, the nearest principals-aware object in its scope chain), untrusted code must <em>never</em> be able to make an outer object appear in a <code>Function</code>'s scope chain. Again, SpiderMonkey enforces a slightly stronger rule: outer objects may never appear in a scope chain at all, except when put there by an explicit C-level JSAPI call (to <code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_SetParent" title="en/SpiderMonkey/JSAPI_Reference/JS_SetParent">JS_SetParent</a></code> or equivalent). (Several objects, such as <code><a href="/en/DOM/window.location" title="en/DOM/window.location">window.location</a></code> and <code><a href="/en/DOM/window.navigator" title="en/DOM/window.navigator">window.navigator</a></code>, are intentionally parented to the outer window object using such APIs.) To enforce this rule:</p>
+
+<ul>
+ <li>APIs that allow the caller to pass a scope object always check that object first and fail if any outer objects are on its scope chain.</li>
+</ul>
+
+<ul>
+ <li>In the spirit of this rule, <code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetScopeChain" title="en/SpiderMonkey/JSAPI_Reference/JS_GetScopeChain">JS_GetScopeChain</a></code> should always return an inner object. But there is a special case when <code>JS_GetScopeChain</code> is called on a <code>JSContext</code> in which no code is currently running. By convention, the context's global object is returned in this case. For consistency with the rule, if that global object is an outer object, SpiderMonkey returns the inner object instead.</li>
+</ul>
+
+<p>Inner and outer objects are in certain other respects the same object:</p>
+
+<ul>
+ <li>If <code><a href="/en/JavaScript/Reference/Global_Objects/Object/hasOwnProperty" title="en/Core_JavaScript_1.5_Reference/Global_Objects/Object/hasOwnProperty">Object.hasOwnProperty</a></code> is called on an inner object, and the named property is found on an outer object, that's considered close enough and <code>hasOwnProperty</code> returns <code>true</code>.</li>
+</ul>
+
+<p>Note that none of the rules listed here affects ordinary property accesses. SpiderMonkey's split object support, by itself, does not cause inner object properties to appear on the outer object or vice versa. Split objects that need this behavior must implement it in custom <code><a href="/en/SpiderMonkey/JSAPI_Reference/JSClass" title="en/SpiderMonkey/JSAPI_Reference/JSClass">JSClass</a></code> hooks. In the case of <code>window</code>, each half has custom hooks.</p>
diff --git a/files/zh-cn/mozilla/rust/index.html b/files/zh-cn/mozilla/rust/index.html
new file mode 100644
index 0000000000..f2964058fb
--- /dev/null
+++ b/files/zh-cn/mozilla/rust/index.html
@@ -0,0 +1,40 @@
+---
+title: Rust编程语言
+slug: Mozilla/Rust
+translation_of: Mozilla/Rust
+---
+<p><img alt="Rust logo" src="https://www.rust-lang.org/logos/rust-logo-blk.svg" style="float: left; height: 150px; width: 150;"><a href="https://www.rust-lang.org/">Rust</a> 是一个全新的开源系统编程语言,由Mozilla和社区的义务劳动者创造,它帮助开发者创造高速与安全的应用,同时能享受到现代多核处理器的强大特性。Rust使用易懂的语法避免了段错误(segmentation faults)并保证了线程安全。</p>
+
+<p>不仅如此,Rust提供了零成本抽象,更多语义,内存安全保证,不会发生竞争的线程,基于特性(trait)的泛型,模式匹配,类型推导,高效的C绑定,和最小运行时大小。</p>
+
+<p>想了解更多Rust,你可以:</p>
+
+<ul>
+ <li>看下面的视频,进一步了解Rust的强大和优势。</li>
+ <li>在线阅读教程<em><a href="https://doc.rust-lang.org/book/">The Rust Programming Language</a></em>。</li>
+ <li>下载Rust编译器,看看例子,并在<a href="https://www.rust-lang.org/">Rust official web site</a>寻找你可能想知道的一切</li>
+</ul>
+
+<h2 id="Rust_与系统编程的未来">Rust 与系统编程的未来</h2>
+
+<p>{{EmbedYouTube("8EPsnf_ZYU0")}}</p>
+
+<h2 id="用Rust解锁并行的力量">用Rust解锁并行的力量</h2>
+
+<p>{{EmbedYouTube("cNeIOt8ZdAY")}}</p>
+
+<h2 id="给Web开发者的Rust">给Web开发者的Rust</h2>
+
+<p>{{EmbedYouTube("FfoXFnzZbBM")}}</p>
+
+<h2 id="用Rust实现安全系统编程">用Rust实现安全系统编程</h2>
+
+<p>{{EmbedYouTube("P3sfNGtpuxc")}}</p>
+
+<h2 id="成长中的Rust社区">成长中的Rust社区</h2>
+
+<p>{{EmbedYouTube("duv0tuPAnO0")}}</p>
+
+<h2 id="Mozilla将Rust用于生产">Mozilla将Rust用于生产</h2>
+
+<p>{{EmbedYouTube("2RhbYpgVpg0")}}</p>
diff --git a/files/zh-cn/mozilla/tech/index.html b/files/zh-cn/mozilla/tech/index.html
new file mode 100644
index 0000000000..2e4f7a5d64
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/index.html
@@ -0,0 +1,7 @@
+---
+title: Mozilla 私有技术
+slug: Mozilla/Tech
+translation_of: Mozilla/Tech
+---
+<p>Mozilla has several technologies used as components of its projects. These are documented here. (flesh out this text).</p>
+<p>{{LandingPageListSubpages}}</p>
diff --git a/files/zh-cn/mozilla/tech/toolkit_api/extisessionstorage/index.html b/files/zh-cn/mozilla/tech/toolkit_api/extisessionstorage/index.html
new file mode 100644
index 0000000000..7d49c345e7
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/toolkit_api/extisessionstorage/index.html
@@ -0,0 +1,48 @@
+---
+title: extISessionStorage
+slug: Mozilla/Tech/Toolkit_API/extISessionStorage
+translation_of: Mozilla/Tech/Toolkit_API/extISessionStorage
+---
+<p></p>
+<p></p><div class="blockIndicator standardNote">
+<p>该条目记录了 <a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Thunderbird/Releases/3">Thunderbird 3</a> 引入的新特性</p>
+</div><p></p>
+<p><br> <code>extISessionStorage</code> 允许一个扩展程序存储数据,该数据会在应用程序的整个生命周期内可用(比如浏览器). <code>extISessionStorage</code> 被定义在 <code><a href="https://dxr.mozilla.org/mozilla-central/source/toolkit/components/exthelper/extIApplication.idl" rel="custom">toolkit/components/exthelper/extIApplication.idl</a></code>.</p>
+<p>通过XPCOM服务实现的 <a class="internal" href="/zh-cn/Toolkit_API/extIApplication" title="zh-cn/Toolkit API/extIApplication"><code>extIApplication</code></a>: 查看相关指南在 <a class="internal" href="/zh-cn/Toolkit_API/FUEL" title="zh-cn/FUEL">FUEL</a> (Firefox), <a class="internal" href="/zh-cn/Thunderbird/STEEL" title="zh-cn/Thunderbird/STEEL">STEEL</a> (Thunderbird) 和 <a class="internal" href="/zh-cn/Toolkit_API/SMILE" title="zh-cn/SeaMonkey/SMILE">SMILE</a> (SeaMonkey) 页面.</p>
+<h2 id="Method_overview" name="Method_overview">方法概述</h2>
+<p>这些方法通常是通过Application.storage来访问的.</p>
+<table class="standard-table"> <tbody> <tr> <th>返回值类型</th> <th>方法</th> </tr> <tr> <td><code>boolean</code></td> <td><code><a href="#has.28.29">has</a>(in AString aName)</code></td> </tr> <tr> <td><code>void</code></td> <td><code><a href="#set.28.29">set</a>(in AString aName, in nsIVariant aValue)</code></td> </tr> <tr> <td><code>nsIVariant</code></td> <td><code><a href="#get.28.29">get</a>(in AString aName, in nsIVariant aDefaultValue)</code></td> </tr> </tbody>
+</table>
+<h2 id="Attributes" name="Attributes">属性</h2>
+<table class="standard-table"> <tbody> <tr> <td class="header">属性名</td> <td class="header">类型</td> <td class="header">描述</td> </tr> <tr> <td><code>events</code></td> <td><code>readonly attribute extIEvents</code></td> <td>The events object for the storage supports: "change"</td> </tr> </tbody>
+</table>
+<h2 id="Methods" name="Methods">方法</h2>
+<h3 id="has.28.29" name="has.28.29">has()</h3>
+<p>判断一个指定名称的存储项是否已经存在.</p>
+<pre class="eval">boolean has(in AString aName)
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl> <dt><code>aName</code></dt> <dd>存储项名称</dd>
+</dl>
+<h6 id="Return_value" name="Return_value">返回值</h6>
+<p>如果这个存储项已经存在,则返回true,否则返回false.</p>
+<h3 id="set.28.29" name="set.28.29">set()</h3>
+<p>为一个指定名称的存储项赋值.</p>
+<pre class="eval">void set(in AString aName, in nsIVariant aValue)
+</pre>
+<h6 id="Parameters_2" name="Parameters_2">参数</h6>
+<dl> <dt><code>aName</code></dt> <dd>存储项名称</dd> <dt><code>aValue</code></dt> <dd>任意类型的值</dd>
+</dl>
+<h6 id="Return_value_2" name="Return_value_2">返回值</h6>
+<p>无</p>
+<h3 id="get.28.29" name="get.28.29">get()</h3>
+<p>获取一个指定名称的存储项的值.如果该存储项不存在,则返回一个默认值.</p>
+<pre class="eval">nsIVariant get(in AString aName, in nsIVariant aDefaultValue)
+</pre>
+<h6 id="Parameters_3" name="Parameters_3">参数</h6>
+<dl> <dt><code>aName</code></dt> <dd>存储项名称</dd>
+</dl>
+<h6 id="Return_value_3" name="Return_value_3">返回值</h6>
+<p>指定存储项的值或者一个默认的返回值.</p><h2 id="See_also" name="See_also">相关链接</h2>
+<p> <a class="internal" href="/zh-cn/Toolkit_API/FUEL" title="zh-cn/FUEL">FUEL</a> (Firefox), <a class="internal" href="/zh-cn/Thunderbird/STEEL" title="zh-cn/Thunderbird/STEEL">STEEL</a> (Thunderbird) and <a class="internal" href="/zh-cn/Toolkit_API/SMILE" title="zh-cn/SeaMonkey/SMILE">SMILE</a> (SeaMonkey)</p>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/toolkit_api/index.html b/files/zh-cn/mozilla/tech/toolkit_api/index.html
new file mode 100644
index 0000000000..7ba5906994
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/toolkit_api/index.html
@@ -0,0 +1,18 @@
+---
+title: Toolkit API
+slug: Mozilla/Tech/Toolkit_API
+translation_of: Mozilla/Tech/Toolkit_API
+---
+<p> </p>
+<p><b>Mozilla Toolkit</b> 是建立在<a href="cn/Gecko">Gecko</a>上的应用程序接口集(APIs),用来提供对XUL应用的高级服务. 这些服务包含:</p>
+<ul>
+ <li>Profile 管理</li>
+ <li>Chrome 注册</li>
+ <li>浏览历史</li>
+ <li>扩展和主题管理</li>
+ <li>应用更新服务</li>
+ <li>安全模式</li>
+</ul>
+<h3 id=".E6.9B.B4.E5.A4.9A.E4.BF.A1.E6.81.AF" name=".E6.9B.B4.E5.A4.9A.E4.BF.A1.E6.81.AF">更多信息</h3>
+<p>下面的开发者页面包含特别主题的例子和讨论:</p>
+<p><a href="cn/XUL">XUL</a>; <a href="cn/XUL_Overlays">XUL Overlays</a>; <a href="cn/Extensions">Developing Extensions</a>; <a href="cn/XULRunner">XULRunner</a>; <a href="cn/Themes">Developing Themes</a>; <a href="cn/DOM">DOM</a>; <a href="cn/RDF">RDF</a>; <a href="cn/Storage">Storage</a>; <a href="cn/Help_Viewer">Creating Help Documentation</a></p>
diff --git a/files/zh-cn/mozilla/tech/viewing_and_searching_mozilla_source_code_online/index.html b/files/zh-cn/mozilla/tech/viewing_and_searching_mozilla_source_code_online/index.html
new file mode 100644
index 0000000000..80965735d2
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/viewing_and_searching_mozilla_source_code_online/index.html
@@ -0,0 +1,26 @@
+---
+title: 在线搜索并浏览Mozilla源代码
+slug: Mozilla/Tech/Viewing_and_searching_Mozilla_source_code_online
+tags:
+ - 开发Mozilla
+ - 需要更新
+translation_of: Mozilla/Tech/Viewing_and_searching_Mozilla_source_code_online
+---
+<p>托管在Mercurial资源库中的所有Mozilla项目的源代码都可以使用<a href="https://searchfox.org/">Searchfox</a>在线搜索和查看,Searchfox是一个运行在AWS上的快速索引搜索引擎。</p>
+
+<p>请勿通过Searchfox下载源码;你可以通过下载<a href="https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Source_Code/Downloading_Source_Archives#Download">tarball</a>或使用<a href="https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Source_Code/Mercurial">Mercurial。</a></p>
+
+<p>Searchfox索引多个分支和模块。</p>
+
+<p>值得注意的几个Searchfox 有:</p>
+
+<ul>
+ <li><a class="link-https" href="https://hg.mozilla.org/mozilla-central/">"mozilla-central"</a> 包含当前的 Firefox 和 Gecko 开发。发行版本是从这个版本库分支出来的。也称为 "Trunk "或 "nightly"。</li>
+ <li><a class="external" href="https://searchfox.org/comm-central/source">"comm-central"</a> 包含当前Thunderbird、SeaMonkey和Calendar的开发。也包含mozilla-central的镜像。从这个版本库中发布分支。</li>
+</ul>
+
+<p><a href="/en/Mozilla_Source_Code_Directory_Structure" title="en/Mozilla_Source_Code_Directory_Structure">Mozilla 源代码目录结构</a> 在每个源码目录树中拥有一段简短的描述。</p>
+
+<div class="note">
+<p>你既可以浏览每个特定版本的源码,也可以下载他们. 每个版本连着源码,都<a href="https://archive.mozilla.org/pub/">在这</a>归档</p>
+</div>
diff --git a/files/zh-cn/mozilla/tech/xpcom/glue/index.html b/files/zh-cn/mozilla/tech/xpcom/glue/index.html
new file mode 100644
index 0000000000..58bfdc731e
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/glue/index.html
@@ -0,0 +1,71 @@
+---
+title: XPCOM Glue
+slug: Mozilla/Tech/XPCOM/Glue
+tags:
+ - XPCOM
+ - 所有分类
+translation_of: Mozilla/Tech/XPCOM/Glue
+---
+<p>The XPCOM Glue is a static library which component developers and embedders can link against. It allows developers to link only against the frozen XPCOM method symbols and maintain compatibility with multiple versions of XPCOM.</p>
+<h3 id="Compiling_or_linking_against_XPCOM_headers" name="Compiling_or_linking_against_XPCOM_headers">Compiling or linking against XPCOM headers</h3>
+<p>There are three ways to compile/link against XPCOM headers/libraries:</p>
+<h4 id="Frozen_linkage:_dependent_glue_.28dependent_on_xpcom.dll.29" name="Frozen_linkage:_dependent_glue_.28dependent_on_xpcom.dll.29">Frozen linkage: dependent glue (dependent on xpcom.dll)</h4>
+<p>Code which wishes to use only frozen symbols but can tolerate a load-time dependency on xpcom.dll should link against xpcom.lib and xpcomglue_s.lib. This is the case for XPCOM components.</p>
+<h4 id="Frozen_linkage:_standalone_glue_.28no_DLL_dependencies.29" name="Frozen_linkage:_standalone_glue_.28no_DLL_dependencies.29">Frozen linkage: standalone glue (no DLL dependencies)</h4>
+<p>Embedding code which wishes to use only frozen symbols and cannot tolerate a load-time dependency on &lt;tt&gt;xpcom.dll&lt;/tt&gt; should &lt;tt&gt;#define XPCOM_GLUE 1&lt;/tt&gt; while compiling, and link against &lt;tt&gt;xpcomglue.lib&lt;/tt&gt;. It should
+ <i>
+ not</i>
+ link against &lt;tt&gt;xpcomglue_s.lib&lt;/tt&gt; or &lt;tt&gt;xpcom.lib&lt;/tt&gt;.</p>
+<p>In order to use XPCOM, the embedding application first needs to find where the XPCOM runtime is located. This is typically done using <a href="cn/GRE_GetGREPathWithProperties">GRE_GetGREPathWithProperties</a>. Then, the code must call <a href="cn/XPCOMGlueStartup">XPCOMGlueStartup</a>, which will dynamically link against the XPCOM runtime. Only then can the embedding application initialize and use XPCOM.</p>
+<p>This linkage strategy is used when an embedder needs to bootstrap an embedding app by finding a compatible <a href="cn/GRE">GRE</a>. Extension or XULRunner application components should use the dependent glue.</p>
+<p>Embedders using the standalone glue typically also need to avoid linking against NSPR as well.</p>
+<p>Emlak ilanlar</p>
+<h4 id="Using_Mozilla_internal_linkage" name="Using_Mozilla_internal_linkage">Using Mozilla internal linkage</h4>
+<p>Mozilla internal code defines MOZILLA_INTERNAL_API while compiling and links against xpcom.lib and xpcom_core.lib. In almost all cases embedders should *not* use internal linkage. Components using internal linkage will have shared-library dependencies against non-frozen symbols in the XPCOM libraries, and will not work with any other versions of XPCOM other than the one it was compiled against.</p>
+<p>Internal linkage will be unavailable to extension authors in XULRunner 1.9 (Firefox 3) because the nonfrozen symbols will not be exported from libxul. Extension and application authors currently using internal linkage should read the guide on <a href="cn/Migrating_from_Internal_Linkage_to_Frozen_Linkage">Migrating from Internal Linkage to Frozen Linkage</a>.</p>
+<h3 id="Threadsafe_nsISupports_implementations" name="Threadsafe_nsISupports_implementations">Threadsafe nsISupports implementations</h3>
+<p>When using glue libraries from Gecko 1.8 or later, a special step needs to be taken to use <code>NS_IMPL_THREADSAFE_ISUPPORTS
+ <i>
+ n</i>
+ </code>. This is because it forces a dependency on the NSPR library, which can otherwise be avoided. As described in <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=299664" title="FIXED: add support for MOZ_USE_NSPR w/ XPCOM_GLUE">bug 299664</a>, the preprocessor symbol <code>XPCOM_GLUE_USE_NSPR</code> needs to be defined.</p>
+<h3 id="Sample_Compiler.2FLinker_Flags" name="Sample_Compiler.2FLinker_Flags">Sample Compiler/Linker Flags</h3>
+<p>Code compiled using XPCOM headers should always &lt;tt&gt;#include "xpcom-config.h"&lt;/tt&gt; from the SDK, to ensure that XPCOM #defines are correct.</p>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th rowspan="2">Linking Strategy</th>
+ <th rowspan="2">Compiler Flags</th>
+ <th colspan="3">Linker Flags</th>
+ </tr>
+ <tr>
+ <th>Windows</th>
+ <th>Mac</th>
+ <th>Linux</th>
+ </tr>
+ <tr>
+ <td>Dependent Glue</td>
+ <td>&lt;tt style="white-space: pre"&gt;#include "xpcom-config.h"&lt;/tt&gt;</td>
+ <td>&lt;tt&gt;-LIBPATH:<var>c:/path/to/sdk/lib</var> xpcomglue_s.lib xpcom.lib nspr4.lib&lt;/tt&gt;</td>
+ <td>&lt;tt&gt;-L<var>/path/to/sdk/lib</var> -L<var>/path/to/sdk/bin</var> -Wl,-executable-path,<var>/path/to/sdk/bin</var> -lxpcomglue_s -lxpcom -lnspr4&lt;/tt&gt;</td>
+ <td>&lt;tt&gt;-L<var>/path/to/sdk/lib</var> -L<var>/path/to/sdk/bin</var> -Wl,-rpath-link,<var>/path/to/sdk/bin</var> -lxpcomglue_s -lxpcom -lnspr4&lt;/tt&gt;</td>
+ </tr>
+ <tr>
+ <td>Standalone Glue</td>
+ <td>&lt;tt style="white-space: pre"&gt;#include "xpcom-config.h"<br>
+ #define XPCOM_GLUE 1&lt;/tt&gt;</td>
+ <td>&lt;tt&gt;-LIBPATH:<var>c:/path/to/sdk/lib</var> xpcomglue.lib&lt;/tt&gt;</td>
+ <td>&lt;tt&gt;-L<var>/path/to/sdk/lib</var> -lxpcomglue&lt;/tt&gt;</td>
+ <td>&lt;tt&gt;-L<var>/path/to/sdk/lib</var> -lxpcomglue&lt;/tt&gt;</td>
+ </tr>
+ </tbody>
+</table>
+<h4 id="Notes" name="Notes">Notes</h4>
+<ul>
+ <li>Never link against xpcomglue.lib and xpcomglue_s.lib at the same time.</li>
+ <li>Never link against xpcomglue.lib and xpcom.lib at the same time.</li>
+ <li>These instructions are for Mozilla 1.8 and above. When using a SDK from Mozilla 1.7 or earlier, you must define MOZILLA_STRICT_API when using any form of the glue.</li>
+</ul>
+<h3 id="See_Also" name="See_Also">See Also</h3>
+<ul>
+ <li><a href="cn/Using_the_Gecko_SDK">Using the Gecko SDK</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/arrays/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/arrays/index.html
new file mode 100644
index 0000000000..53939ba6c0
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/arrays/index.html
@@ -0,0 +1,573 @@
+---
+title: Array
+slug: Mozilla/Tech/XPCOM/Guide/Arrays
+tags:
+ - XPCOM
+ - 所有分类
+translation_of: Mozilla/Tech/XPCOM/Guide/Arrays
+---
+<p> </p>
+<h2 id="Introduction" name="Introduction">Introduction</h2>
+<h4 id="Array_types" name="Array_types">Array types</h4>
+<p>Mozilla has many array classes because each array is optimized for a particular usage pattern. This guide describes the available arrays as well as the enumerator classes that can be used to get to them. In this document the term Array refers to a container for multiple objects with a numeric, zero-based index.</p>
+<p>The standard array classes are:</p>
+<ul>
+ <li><code><a href="#nsIArray_.2F_nsIMutableArray">nsIArray</a></code> - a scriptable container for scriptable XPCOM objects. This array is read-only, and the interface does not provide any methods that will allow adding and removing members.</li>
+ <li><code>nsIMutableArray</code> - a scriptable container for scriptable XPCOM objects, which allows addition and removal of member objects. This interface actually derives from nsIArray.</li>
+ <li><code>nsCOMArray<span class="nowiki">&lt;T&gt;</span></code> - a C++ class which provides a typesafe, reference-counted container for pointers to a single type of COM object. This class is more or less a wrapper around nsVoidArray and thus shares most of its semantics.</li>
+ <li><code>nsTArray<span class="nowiki">&lt;T&gt;</span></code> - a C++ class which provides a typesafe container for objects or primitive types (pointers, integers, etc). The objects must define a default constructor and a copy constructor. To use <code>IndexOf</code> without providing a comparator, they must also define an <code>operator==</code>. For sorting without providing a comparator they must define an <code><span class="nowiki">operator&lt;</span></code>. Note that this class differs from the other array types by using unsigned indices.</li>
+ <li><code>nsVoidArray</code> - a C++ class which provides a generic container for any objects using the generic void * type.</li>
+ <li><code>nsStringArray</code> / <code>nsCStringArray</code> - a set of C++ classes for holding lists of string objects. Derived from nsVoidArray</li>
+ <li><code>nsAutoVoidArray</code> - a version of nsVoidArray which includes 8 entries of internal storage for the array data.</li>
+ <li><code>nsSmallVoidArray</code> - a replacement for nsVoidArray which is optimized to hold zero or one element.</li>
+</ul>
+<p>This handy chart may make it easier to understand the different arrays:</p>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>Class</th>
+ <th>Data Type</th>
+ <th>Scriptable?</th>
+ <th>Typesafe?</th>
+ <th>Can be modified?</th>
+ <th>Built in buffer?</th>
+ <th>Ownership</th>
+ </tr>
+ <tr class="even">
+ <td><code><a href="#nsIArray_.2F_nsIMutableArray">nsIArray</a></code></td>
+ <td>XPCOM object</td>
+ <td>Yes</td>
+ <td>No</td>
+ <td>No</td>
+ <td>No</td>
+ <td>Reference Counted, Weak/Strong</td>
+ </tr>
+ <tr class="odd">
+ <td><code>nsIMutableArray</code></td>
+ <td>XPCOM object</td>
+ <td>Yes</td>
+ <td>No</td>
+ <td>Yes</td>
+ <td>No</td>
+ <td>Reference Counted, Weak/Strong</td>
+ </tr>
+ <tr class="even">
+ <td><code>nsCOMArray&lt;T&gt;</code></td>
+ <td>XPCOM object</td>
+ <td>No</td>
+ <td>Yes</td>
+ <td>Yes*</td>
+ <td>No</td>
+ <td>Reference Counted, Strong</td>
+ </tr>
+ <tr class="odd">
+ <td><code>nsTArray&lt;T&gt;</code></td>
+ <td>Any that has a default constructor and copy constructor</td>
+ <td>No</td>
+ <td>Yes</td>
+ <td>Yes*</td>
+ <td>No</td>
+ <td>Can hold objects directly, in which case it owns them. When holding pointers, doesn't own the pointer.</td>
+ </tr>
+ <tr class="even">
+ <td><code>nsVoidArray</code></td>
+ <td>Any</td>
+ <td>No</td>
+ <td>No</td>
+ <td>Yes*</td>
+ <td>No</td>
+ <td>Weak / None</td>
+ </tr>
+ <tr class="odd">
+ <td><code>nsStringArray</code><br>
+ <code>nsCStringArray</code></td>
+ <td><code>nsString</code><br>
+ <code>nsCString</code></td>
+ <td>No</td>
+ <td>Yes</td>
+ <td>Yes*</td>
+ <td>No</td>
+ <td>Private (copies strings)</td>
+ </tr>
+ <tr class="even">
+ <td><code>nsAutoVoidArray</code></td>
+ <td>Any</td>
+ <td>No</td>
+ <td>No</td>
+ <td>Yes*</td>
+ <td>Yes</td>
+ <td>Weak / None</td>
+ </tr>
+ <tr class="odd">
+ <td><code>nsSmallVoidArray</code></td>
+ <td>Any</td>
+ <td>No</td>
+ <td>No</td>
+ <td>Yes*</td>
+ <td>No</td>
+ <td>Weak / None</td>
+ </tr>
+ <tr class="even">
+ <td><code>nsISupportsArray</code></td>
+ <td>XPCOM Object</td>
+ <td>Yes</td>
+ <td>No</td>
+ <td>Yes*</td>
+ <td>No</td>
+ <td>Reference Counted, Strong</td>
+ </tr>
+ </tbody>
+</table>
+<p>(*) Note: Concrete C++ arrays can be made read-only by declaring them const. For example:</p>
+<pre class="eval">// HandleList cannot modify the array because of const
+void HandleList(const nsVoidArray&amp;);
+</pre>
+<h4 id="In-place_enumeration" name="In-place_enumeration">In-place enumeration</h4>
+<p>Most of the arrays presented here provide callback-style means to enumerate members of an array. Instead of incrementally accessing each element of the array by its index, the arrays provide a way to pass in a callback function that will be called for each element in the array.</p>
+<p>For most concrete C++ classes like <code>nsVoidArray</code> and <code>nsCOMArray&lt;T&gt;</code>, indexing should be faster than the callback-style enumeration, because accessing an indexed member of such an array is usually very fast, while enumeration has slight function call overhead. In the case of scriptable arrays like nsIArray however, the enumeration mechanism is often preferred because it avoids the AddRef / Release overhead that comes from accessing each object.</p>
+<p>The only functional drawback to in-place enumeration is that you cannot manipulate the array itself during the enumeration. For example, you should not delete elements of an array during the enumeration as this will often confuse the loop which is enumerating the array.</p>
+<h4 id="Enumerators" name="Enumerators">Enumerators</h4>
+<p>Most arrays provide access to an object which is used to enumerate members of the array. These Enumerators maintain state about the current position in the array. Enumerators are used to access the elements in an ordered way, without relying on the underlying array type. These enumerators include:</p>
+<ul>
+ <li><code>nsISimpleEnumerator</code> - an enumerator for COM objects.</li>
+ <li><code>nsIStringEnumerator</code> / <code>nsIUTF8StringEnumerator</code> - enumerators for strings</li>
+</ul>
+<h4 id="Obsolete_arrays_.2F_enumerators" name="Obsolete_arrays_.2F_enumerators">Obsolete arrays / enumerators</h4>
+<p>There are some deprecated classes which <b>should not be used by new code</b>.</p>
+<ul>
+ <li><code>nsISupportsArray</code> - obsoleted by <code><a href="#nsIArray_.2F_nsIMutableArray">nsIArray</a></code>, use that instead.</li>
+ <li><code>nsIEnumerator</code> - obsoleted by <code>nsISimpleEnumerator</code>, use that instead.</li>
+ <li><code>nsIBidirectionalEnumerator</code> - obsoleted by <code>nsISimpleEnumerator</code>, use that instead.</li>
+ <li><code>nsVoidArray</code> - <code>nsTArray<span class="nowiki">&lt;T&gt;</span></code> is preferred. Using <code>nsAutoVoidArray</code> is still ok, since that saves an allocation over using <code>nsTArray<span class="nowiki">&lt;T&gt;</span>(8)</code>.</li>
+</ul>
+<h2 id="Which_Array_should_I_use.3F" name="Which_Array_should_I_use.3F">Which Array should I use?</h2>
+<p>Do not use <code>nsISupportsArray</code>; it is deprecated.</p>
+<p>Does your array need to be scriptable? If so, use <code>nsIArray</code>.</p>
+<p>Example: an array attribute in an IDL file would be <code>nsIArray</code>.</p>
+<p>Will your array store non-refcounted objects and need automatic resizing? If so, use <code>nsTArray<span class="nowiki">&lt;T&gt;</span></code>.</p>
+<p>Example: an array of integers or an array of strings.</p>
+<p>Will your array store non-refcounted objects and be a fixed size? If so, just use a native C++ array unless you need the enumeration options on <code>nsTArray<span class="nowiki">&lt;T&gt;</span></code>.</p>
+<p>Example: an array of error message static const char* pointers.</p>
+<p>Are all the things you are storing interface pointers to instances of the same interface? If so, use <code>nsCOMArray</code>.</p>
+<p>Example: a content node's list of <code>nsIContent</code> children.</p>
+<p>Otherwise use <code>nsIArray</code> and make liberal use of <code>QueryElementAt()</code>.</p>
+<p>The point of <code>nsCOMArray</code> is that it's a template, and all the pointers in it must be pointers to the same type; it's nice to be able to use it because you get type-safety and don't have to spend time and code QIing (like you have to with <code>nsIArray</code>).</p>
+<h2 id="Array_Guidelines" name="Array_Guidelines">Array Guidelines</h2>
+<p>Here are a few simple rules which will keep your code clean and your developers happy:</p>
+<ul>
+ <li>Use typesafe arrays like <code>nsCOMArray<span class="nowiki">&lt;T&gt;</span></code> <code>nsTArray<span class="nowiki">&lt;T&gt;</span></code> wherever possible.</li>
+ <li>Avoid all obsolete arrays and enumerators.</li>
+ <li>Avoid creating temporary arrays.</li>
+</ul>
+<h2 id="Scriptable_Arrays" name="Scriptable_Arrays">Scriptable Arrays</h2>
+<h3 id="nsIArray_.2F_nsIMutableArray" name="nsIArray_.2F_nsIMutableArray">nsIArray / nsIMutableArray</h3>
+<h4 id="Usage" name="Usage">Usage</h4>
+<p><code>nsIArray</code> is useful if you need to pass arrays of COM objects through interfaces or require a scriptable array. It can hold strong or weak references to its container objects. This basic interface only allows querying of existing elements in the array. The methods that modify the array have been broken out into <code>nsIMutableArray</code>.</p>
+<p>An <code>nsIArray</code> implementation can be created from C++ with the function <code>NS_NewArray(nsIMutableArray**);</code>. The created array implements <code>nsIMutableArray</code> and <code>nsIArray</code>. Since <code>nsIArray</code> derives from <code>nsIMutableArray</code>, the resulting array can be cast to a read-only array.</p>
+<pre class="eval">void GetList(nsIArray** aResult) {
+ nsCOMPtr&lt;nsIMutableArray&gt; array;
+ NS_NewArray(getter_AddRefs(array));
+
+ // append some elements
+ ...
+
+ // return it to the caller
+ *aResult = array;
+ NS_ADDREF(*aResult);
+}
+</pre>
+<h4 id="Access_to_elements" name="Access_to_elements">Access to elements</h4>
+<p>Since <code>nsIArray</code> is a regular XPCOM object, its interfaces follows the standard conventions of ownership. Access to specific elements is through <code>QueryElementAt</code>, which is similar to <code>QueryInterface</code>, but it takes a specific index.</p>
+<pre class="eval">void NotifyObservers(nsIArray* aArray) {
+ PRUint32 length;
+ aArray-&gt;GetLength(&amp;length);
+ for (PRUint32 i=0; i&lt;length; ++i) {
+ nsCOMPtr&lt;nsIMyObserver&gt; element;
+ aArray-&gt;QueryElementAt(i, NS_GET_IID(nsIElement),
+ getter_AddRefs(element));
+ element-&gt;Observe();
+ }
+}
+</pre>
+<p>A simpler option is to use the helper <code>do_QueryElementAt</code> which is typesafe.</p>
+<pre class="eval">void NotifyObservers(nsIArray* aArray) {
+ PRUint32 length;
+ aArray-&gt;GetLength(&amp;length);
+ for (PRUint32 i=0; i&lt;length; ++i) {
+ nsCOMPtr&lt;nsIMyObserver&gt; element =
+ do_QueryElementAt(aArray, i);
+ element-&gt;Observe();
+ }
+}
+</pre>
+<h4 id="Passing_as_a_parameter" name="Passing_as_a_parameter">Passing as a parameter</h4>
+<p>Since <code>nsIArray</code> is an XPCOM object, it should be passed as a pointer. To distinguish between read-only arrays and writable arrays, you should make sure to pass a nsIArray or <code>nsIMutableArray</code> as appropriate.</p>
+<p>When the array can or should be modified, then use nsIMutableArray:</p>
+<pre class="eval">// array is read-only because it uses nsIArray
+void PrintSize(nsIArray* elements) {
+ PRUint32 count;
+ elements-&gt;GetLength(&amp;count);
+ printf("There are %d elements.\n", count);
+}
+
+// using nsIMutableArray, so callee may modify
+void TweakArray(nsIMutableArray* elements) {
+ elements-&gt;RemoveElementAt(0);
+ elements-&gt;AppendElement(newElement, PR_FALSE);
+}
+</pre>
+<p>While it is usually possible to call <code>QueryInterface</code> on an <code>nsIArray</code> to get access to the <code>nsIMutableArray</code> interface, this is against convention and it should be avoided.</p>
+<pre class="eval">// no need for the double-pointer, and this violates XPCOM rules
+// which expect acess to a new object
+void TweakArray(nsIMutableArray** elements) {
+ // ugh, extra indirection!
+ *elements-&gt;RemoveElementAt(0);
+ *elements-&gt;AppendElement(newElement, PR_FALSE);
+}
+</pre>
+<h4 id="In-place_enumeration_2" name="In-place_enumeration_2">In-place enumeration</h4>
+<p>When accessing all members of an <code>nsIArray</code>, in-place enumeration is preferred over indexed access. However, I seem to have forgotten to implement that. Good thing the interface is under review. Sorry!</p>
+<h4 id="Enumerators_2" name="Enumerators_2">Enumerators</h4>
+<p>Creating an enumerator from an <code>nsIArray</code> is easy. The method <code>Enumerate()</code> returns a <code>nsISimpleEnumerator</code> which accesses all the elements in the array. Often, simply accessing an array by index, using <code>QueryElementAt</code> is faster. See the section on Enumerators to learn when to properly use enumerators.</p>
+<p>For example, if you need to iterate an array returned from another object, you might use <code>Enumerate()</code>.</p>
+<pre class="eval">...
+// get the array
+nsCOMPtr&lt;nsIArray&gt; array;
+foo-&gt;GetElements(getter_AddRefs(array));
+
+// make an enumerator
+nsCOMPtr&lt;nsISimpleEnumerator&gt; enumerator;
+array-&gt;Enumerate(getter_AddRefs(enumerator));
+
+// now enumerate the elements
+...
+</pre>
+<h2 id="Typesafe_Arrays" name="Typesafe_Arrays">Typesafe Arrays</h2>
+<h3 id="nsCOMArray.3CT.3E" name="nsCOMArray.3CT.3E">nsCOMArray&lt;T&gt;</h3>
+<p><code>nsCOMArray&lt;T&gt;</code> is a typesafe wrapper around <code>nsVoidArray</code>, so it has a similar API. It enforces both typesafety and XPCOM reference counting by keeping an owning reference to each element in the array.</p>
+<h4 id="Usage_2" name="Usage_2">Usage</h4>
+<p>It is most often used as a member of a C++ class to store a list of well-typed XPCOM objects. It is also usually declared as an inline member rather than a pointer. As a class member, <code>nsCOMArray&lt;T&gt;</code> is preferred over <code>nsIArray</code> when access to the array is confined to the class itself.</p>
+<p>For example, here is its use in a class:</p>
+<pre class="eval">class NodeContainer {
+public:
+ void AddNode(nsINode* node);
+
+private:
+ nsCOMArray&lt;nsINode&gt; mNodes;
+};
+
+// typesafety of mNodes ensures that we only append an nsINode*
+void NodeContainer::AddNode(nsINode* node) {
+ mNodes.AppendObject(node);
+}
+
+</pre>
+<p><code>nsCOMArray&lt;T&gt;</code> can also be declared on the stack to collect a temporary list of objects and manipulate them. When the object goes out of scope, all its members are released.</p>
+<pre class="eval">void ProcessVisibleItems()
+{
+ // temporary stack-based nsCOMArray
+ nsCOMArray&lt;nsIFoo&gt; fooItems;
+ GetCompleteList(fooItems);
+
+ // now filter out non visible objects
+ // doing this backwards
+ PRUint32 i = fooItems.Count();
+ while (i &gt; 0) {
+ --i;
+ PRBool isVisible;
+ fooItems[i]-&gt;GetIsVisible(&amp;isVisible);
+ if (!isVisible) {
+ fooItems.RemoveObjectAt(i);
+ }
+ }
+
+ // now deal with the processed list
+ ProcessList(fooItems);
+
+ // fooItems will release all its members
+ // when it goes out of scope
+}
+</pre>
+<h4 id="Access_to_elements_2" name="Access_to_elements_2">Access to elements</h4>
+<p><code>nsCOMArray&lt;T&gt;</code> is a concrete C++ class, and so the [] operator is used to access its members. When using the [] operator, the reference count is unchanged. This allows direct processing of array elements without worrying about calling <code>Release()</code>.</p>
+<p>For example, this code calls the same method on each member:</p>
+<pre class="eval">void NotifyObservers(const nsCOMArray&lt;nsIMyObserver&gt;&amp; observers) {
+ // Using [] doesn't leak!
+ for (PRInt32 i = observers.Count() - 1; i &gt;= 0 ; i--)
+ observers[i]-&gt;Observe();
+}
+</pre>
+<p>Be careful with this though, you could end up with a weak pointer if you're converting from non-nsCOMArray code.</p>
+<pre class="eval">// old version, relied on automatic addref
+// mElements is an nsISupportsArray*
+void GetFirstObject(nsIElement** aResult) {
+ // no need to call NS_ADDREF - this does it for you
+ mElements-&gt;QueryElementAt(0, NS_GET_IID(nsIElement),
+ (void**)aResult);
+}
+
+// new version, make sure to call NS_ADDREF()
+// mElements is now a nsCOMArray&lt;nsIElement&gt;
+void GetFirstObject(nsIElement** aResult) {
+ *aResult = mElements[0];
+ NS_ADDREF(*aResult);
+}
+</pre>
+<h4 id="Passing_as_a_parameter_2" name="Passing_as_a_parameter_2">Passing as a parameter</h4>
+<p>When passing <code>nsCOMArray&lt;T&gt;</code> among functions, the convention is to pass by reference. Also be sure to use const if you want to enforce that the array is read-only.</p>
+<p>Here is an example with a read-only and a writable array:</p>
+<pre class="eval">// array is read-only because of const
+void PrintSize(const nsCOMArray&lt;nsIElements&gt;&amp; elements) {
+ printf("There are %d elements.\n", elements.Count());
+}
+
+// no const, so we can modify the array
+void TweakArray(nsCOMArray&lt;nsIElement&gt;&amp; elements, nsIElement* newElement) {
+ elements.RemoveObjectAt(0);
+ elements.AppendObject(newElement);
+}
+</pre>
+<h4 id="In-place_enumeration_3" name="In-place_enumeration_3">In-place enumeration</h4>
+<p>The callback-based enumeration in <code>nsCOMArray&lt;T&gt;</code> is about as fast as, if not faster than, standard loop-based iteration. The callback mechanism can be useful when integrating with existing callback-style code however.</p>
+<p>One particularly nice thing about the callback mechanism is that it is typesafe. For instance:</p>
+<pre class="eval">PR_CALLBACK PRBool getFirstVisible(nsIElement* element, void* closure) {
+ PRBool isVisible;
+ element-&gt;IsVisible(&amp;isVisible);
+
+ // stop at first object
+ if (isVisible) {
+ NS_STATIC_CAST(ClosureObject*,closure)-&gt;element = element;
+ return PR_FALSE;
+ }
+ return PR_TRUE;
+}
+
+...
+// enumerate to find the object
+ClosureObject closureObject = { 0 };
+if (!mElements.EnumerateForwards(getFirstVisible, closureObject))
+ processElement(closureObject-&gt;element);
+...
+</pre>
+<h4 id="Enumerators_3" name="Enumerators_3">Enumerators</h4>
+<p>A <code>nsISimpleEnumerator</code> can be created to provide access to a <code>nsCOMArray&lt;T&gt;</code>. When the enumerator is created, it takes a snapshot of the elements in the array, so that the enumerator can outlive the array.</p>
+<p>To create the enumerator, use <code>NS_NewArrayEnumerator(nsISimpleEnumerator**, const nsCOMArray&lt;T&gt;&amp;)</code>. For example:</p>
+<pre class="eval">// mElements is an nsCOMArray&lt;nsIElement&gt;
+nsFoo::GetElements(nsISimpleEnumerator** aResult) {
+ return NS_NewArrayEnumerator(aResult, mElements);
+}
+</pre>
+<h3 id="nsTArray.3CT.3E" name="nsTArray.3CT.3E">nsTArray&lt;T&gt;</h3>
+<p><code>nsTArray&lt;T&gt;</code> is a typesafe array for holding various objects. It can be used to hold objects directly, not just pointers to objects.</p>
+<h4 id="Usage_3" name="Usage_3">Usage</h4>
+<p>It is most often used as a member of a C++ class to store a list of well-typed objects. It is also usually declared as an inline member rather than a pointer. As a class member, <code>nsTArray&lt;T&gt;</code> is preferred over <code>nsVoidArray</code>.</p>
+<p>For example, here is its use in a class:</p>
+<pre class="eval">class MediaList {
+public:
+ void AddMedium(const nsString&amp; aMedium);
+
+private:
+ nsTArray&lt;nsString&gt; mMedia;
+};
+
+// typesafety of mMedia ensures that we only append an nsString
+void NodeContainer::AddMedium(const nsString&amp; aMedium) {
+ mMedia.AppendElement(aMedium);
+}
+
+</pre>
+<p><code>nsTArray&lt;T&gt;</code> can also be declared on the stack to collect a temporary list of objects and manipulate them. When the object goes out of scope, all its members have their destructors called. Note that if the <code>nsTArray&lt;T&gt;</code> holds pointers to objects, the objects will not be deleted (and hence not have their destructors called).</p>
+<pre class="eval">void ProcessVisibleItems()
+{
+ // temporary stack-based nsTArray
+ nsTArray&lt;FooStruct&gt; fooItems;
+ GetCompleteList(fooItems);
+
+ // now filter out non visible objects
+ // doing this backwards
+ PRUint32 i = fooItems.Length();
+ while (i &gt; 0) {
+ --i;
+ PRBool isVisible;
+ fooItems[i]-&gt;GetIsVisible(&amp;isVisible);
+ if (!isVisible) {
+ fooItems.RemoveElementAt(i);
+ }
+ }
+
+ // now deal with the processed list
+ ProcessList(fooItems);
+
+ // fooItems will call the destructors of all the FooStruct objects
+ // when it goes out of scope
+}
+</pre>
+<h4 id="Access_to_elements_3" name="Access_to_elements_3">Access to elements</h4>
+<p><code>nsTArray&lt;T&gt;</code> is a concrete C++ class, and so the [] operator is used to access its members.</p>
+<p>For example, this code calls the same method on each member:</p>
+<pre class="eval">void NotifyObservers(const nsTArray&lt;ObserverClass*&gt;&amp; observers) {
+ for (PRUint32 i = observers.Length(); i &gt; 0 ; ) {
+ --i;
+ observers[i]-&gt;Observe();
+ }
+}
+</pre>
+<h4 id="Passing_as_a_parameter_3" name="Passing_as_a_parameter_3">Passing as a parameter</h4>
+<p>When passing <code>nsTArray&lt;T&gt;</code> among functions, the convention is to pass by reference. Also be sure to use <code>const</code> if you want to enforce that the array is read-only.</p>
+<p>Here is an example with a read-only and a writable array:</p>
+<pre class="eval">// array is read-only because of const
+void PrintSize(const nsTArray&lt;nsElement&gt;&amp; elements) {
+ printf("There are %d elements.\n", elements.Length());
+}
+
+// no const, so we can modify the array
+void TweakArray(nsTArray&lt;nsElement&gt;&amp; elements,
+ const nsElement&amp; newElement) {
+ elements.RemoveElementAt(0);
+ elements.AppendElement(newElement);
+}
+</pre>
+<h4 id="In-place_enumeration_4" name="In-place_enumeration_4">In-place enumeration</h4>
+<p>There are no enumerator objects that work on an <code>nsTArray&lt;T&gt;</code>.</p>
+<h2 id="C.2B.2B_Arrays" name="C.2B.2B_Arrays">C++ Arrays</h2>
+<h3 id="nsVoidArray" name="nsVoidArray">nsVoidArray</h3>
+<p><code>nsVoidArray</code> is a concrete C++ class that allows for storage of any arbitrary object. The base type for all objects is void *. When converting to/from a void *, use <code>NS_STATIC_CAST</code> to ensure that no const-ness is lost.</p>
+<p>Note that <code>nsVoidArray</code> defines no semantics of ownership of its objects. Depending on its use, the array may either own the objects that it points to, or its member may be pointers to existing objects that are owned by another data structure. Because nsVoidArray itself does not define any ownership rules, it is up to the consumer to know when it is appropriate to free objects out of the array.</p>
+<p>This implies that when an <code>nsVoidArray</code> goes out of scope, seperate code must free any memory that is semantically owned by the array. This should always be documented in the declaration of the array instance.</p>
+<p><code>nsCOMArray&lt;T&gt;</code> was designed to eliminate some of the overhead of using nsVoidArray when using COM objects. If your code is using <code>nsVoidArray</code> to keep references to COM objects, consider converting it to <code>nsCOMArray&lt;T&gt;</code>.</p>
+<h4 id="Usage_4" name="Usage_4">Usage</h4>
+<p><code>nsVoidArray</code> is often used as a member variable in a class. Remember to document ownership!</p>
+<pre class="eval">struct FooElement {
+ ...
+};
+
+class nsFoo : nsIFoo {
+ ...
+ virtual ~nsFoo();
+ ...
+
+ private:
+ // mElements owns a list of FooElement structs,
+ // which must be deleted when this object goes away
+ nsVoidArray mElements;
+
+ // mVisibleElements contains weak (non-owning) references
+ // to elements in mElements, and does not need to be cleaned up
+ nsVoidArray mVisibleElements;
+};
+
+nsFoo::~nsFoo() {
+ // mVisibleElements is fine, but
+ // don't forget to clean up mElements!
+ PRUint32 i, count = mElements.Count();
+ for (i=0; i&lt;count; ++i)
+ delete NS_STATIC_CAST(FooElement*, mElements[i]);
+ }
+
+</pre>
+<p>As you can see, <code>nsVoidArray</code> has some context-specific overhead to make sure memory is cleaned up appropriately.</p>
+<h4 id="Access_to_elements_4" name="Access_to_elements_4">Access to elements</h4>
+<p>The [] operator is used to access member variables. Don't forget to use <code>NS_STATIC_CAST()</code>.</p>
+<pre class="eval">for (i=0; i&lt;count; ++i) {
+ FooElement* element = NS_STATIC_CAST(FooElement*,mElements[i]);
+ // now manipulate element
+}
+
+</pre>
+<h4 id="Passing_as_a_parameter_4" name="Passing_as_a_parameter_4">Passing as a parameter</h4>
+<p>Like other concrete C++ classes, passing by reference using the &amp; syntax is preferred.</p>
+<h4 id="In-place_enumeration_5" name="In-place_enumeration_5">In-place enumeration</h4>
+<h4 id="Enumerators_4" name="Enumerators_4">Enumerators</h4>
+<h3 id="nsStringArray_.2F_nsCStringArray" name="nsStringArray_.2F_nsCStringArray">nsStringArray / nsCStringArray</h3>
+<h4 id="Usage_5" name="Usage_5">Usage</h4>
+<h4 id="Access_to_elements_5" name="Access_to_elements_5">Access to elements</h4>
+<h4 id="Passing_as_a_parameter_5" name="Passing_as_a_parameter_5">Passing as a parameter</h4>
+<h4 id="In-place_enumeration_6" name="In-place_enumeration_6">In-place enumeration</h4>
+<h4 id="Enumerators_5" name="Enumerators_5">Enumerators</h4>
+<h3 id="nsAutoVoidArray" name="nsAutoVoidArray">nsAutoVoidArray</h3>
+<h4 id="Usage_6" name="Usage_6">Usage</h4>
+<h4 id="Access_to_elements_6" name="Access_to_elements_6">Access to elements</h4>
+<h4 id="Passing_as_a_parameter_6" name="Passing_as_a_parameter_6">Passing as a parameter</h4>
+<h4 id="In-place_enumeration_7" name="In-place_enumeration_7">In-place enumeration</h4>
+<h4 id="Enumerators_6" name="Enumerators_6">Enumerators</h4>
+<h3 id="nsSmallVoidArray" name="nsSmallVoidArray">nsSmallVoidArray</h3>
+<h4 id="Usage_7" name="Usage_7">Usage</h4>
+<h4 id="Access_to_elements_7" name="Access_to_elements_7">Access to elements</h4>
+<h4 id="Passing_as_a_parameter_7" name="Passing_as_a_parameter_7">Passing as a parameter</h4>
+<h4 id="In-place_enumeration_8" name="In-place_enumeration_8">In-place enumeration</h4>
+<h4 id="Enumerators_7" name="Enumerators_7">Enumerators</h4>
+<h2 id="Enumerators_8" name="Enumerators_8">Enumerators</h2>
+<p>Enumerators are very simple, structure-free objects for visiting each member of a set of objects. The enumerators are used as a generic interface for arrays, hashtables, and other constructs which contain one or more objects. When designing public interfaces, enumerators are the preferred mechanism for accessing these structures because they hide the details of the implementation behind the interface.</p>
+<h3 id="nsISimpleEnumerator" name="nsISimpleEnumerator">nsISimpleEnumerator</h3>
+<p><code>nsISimpleEnumerator</code> is a generic enumerator for enumerating a list of any XPCOM object. There are many implementations of <code>nsISimpleEnumerator</code>, including one that enumerates <code>nsIArray</code> objects, and another one for <code>nsCOMArray</code>. It is very common for other interfaces which support <code>nsISimpleEnumerator</code> to make their own implementations.</p>
+<h3 id="nsIStringEnumerator" name="nsIStringEnumerator">nsIStringEnumerator</h3>
+<p>String enumerators provide an easy way to pass a list of strings around with minimal copying. Both unicode strings and UTF8-encoded strings are supported. For more information about the different types of strings, see the String Guide.</p>
+<p>String enumerators can be created from <code>nsStringArray</code> or <code>nsCStringArray</code> objects. The implementation of the string enumerator interfaces for <code>nsStringArray</code> and <code>nsCStringArray</code> supports conversion between UTF8 and Unicode, and can be QueryInterface'd back and forth between <code>nsIStringEnumerator</code> and <code>nsIUTF8StringEnumerator</code>.</p>
+<p>To create an nsIStringEnumerator for an <code>nsStringArray</code>, you can use one of the variations of <code>NS_NewStringEnumerator</code>. There are also corresponding enumerators and helpers for UTF8 strings. In the examples below, <code>NS_NewUTF8StringEnumerator</code> can be used along with <code>nsIUTF8StringEnumerator</code> and <code>nsCStringArray</code>.</p>
+<p>This first example demonstrates the case where a class which owns an <code>nsStringArray</code>, and are returns an <code>nsIStringEnumerator</code> to a caller. You can use the variation of <code>NS_NewStringEnumerator</code> that ensures the owner of the array outlives the enumerator. This is necessary because nsStringArray is not reference counted. Without holding a reference to the owner, the enumerator could be left with a dangling pointer to a deleted <code>nsStringArray</code>.</p>
+<pre class="eval">class nsFoo : nsIFoo {
+...
+private:
+ nsStringArray mElementNames;
+};
+
+nsFoo::GetElementNames(nsIStringEnumerator** aResult)
+{
+ // pass in "this" to make sure the enumerator
+ // holds a reference to "this"
+ return NS_NewStringEnumerator(aResult, mElementNames, this);
+}
+</pre>
+<p>One variant of <code>NS_NewStringEnumerator</code> does not require an owner, but should only be used when the lifetime of the enumerator is known to be shorter than that of the array. Often this is used when a method must take a <code>nsIStringEnumerator</code> rather than an <code>nsStringArray</code>, due to some sort of interface constraint.</p>
+<pre class="eval">class nsFoo : nsIFoo {
+ ...
+ // when ProcessElements returns, the enumerator is at the
+ // end of the list, and can be released.
+ NS_IMETHODIMP ProcessNames(nsIStringEnumerator*);
+ private:
+
+ nsStringArray mElementNames;
+};
+
+...
+nsCOMPtr&lt;nsIStringEnumerator&gt; enumerator;
+NS_NewStringEnumerator(getter_AddRefs(enumerator), mElementNames);
+
+// now call a method on "this" that has a known behavior
+ProcessNames(enumerator);
+// now enumerator is used up, and can be released
+...
+</pre>
+<p>The last version of <code>nsIStringEnumerator</code> takes ownership of an <code>nsStringArray</code> and is responsible for freeing the array when the enumerator is used up.</p>
+<pre class="eval">void GetNames(nsIStringEnumerator** aResult)
+{
+ nsStringArray *resultArray = new nsStringArray;
+ resultArray-&gt;AppendString(str1);
+ resultArray-&gt;AppendString(str2);
+
+ // enumerator will free resultArray
+ return NS_NewAdoptingStringEnumerator(aResult, resultArray);
+}
+</pre>
+<p>As noted above, these implementations of <code>nsIStringEnumerator</code> can also be QueryInterface'd between nsIStringEnumerator and <code>nsIUTF8StringEnumerator</code>. The implementations will properly convert back and forth between UTF8 and Unicode. To ensure that you get the right implementation and the conversion is done in the right direction, make sure that you call the version of <code>NS_NewStringEnumerator</code> or <code>NS_NewUTF8StringEnumerator</code> that corresponds to the array type, not the enumerator type.</p>
+<p>For example, if a class has an internal <code>nsCStringArray</code> of UTF8 strings, but needs to implement an interface which returns an nsIStringEnumerator, it should use <code>NS_NewStringEnumerator</code>:</p>
+<pre class="eval">class nsFoo : nsIFoo {
+ ...
+ NS_IMETHOD GetStrings(nsIStringEnumerator** aResult);
+</pre>
+<pre class="eval"> private:
+ nsCStringArray mElementNames;
+};
+
+NS_IMETHODIMP
+nsFoo::GetStrings(nsIStringEnumerator** aResult) {
+ nsresult rv;
+ nsCOMPtr&lt;nsIUTF8StringEnumerator&gt; enumerator
+ rv = NS_NewUTF8StringEnumerator(getter_AddRefs(enumerator),
+ mElementNames, this);
+ return CallQueryInterface(enumerator, aResult);
+}
+</pre>
+<h2 id="Obsolete_Arrays_and_Enumerators" name="Obsolete_Arrays_and_Enumerators">Obsolete Arrays and Enumerators</h2>
+<h3 id="nsISupportsArray" name="nsISupportsArray">nsISupportsArray</h3>
+<h3 id="nsIEnumerator_.28includes_nsIBidirectionalEnumerator.29" name="nsIEnumerator_.28includes_nsIBidirectionalEnumerator.29">nsIEnumerator (includes nsIBidirectionalEnumerator)</h3>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/an_overview_of_xpcom/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/an_overview_of_xpcom/index.html
new file mode 100644
index 0000000000..64bf41704f
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/an_overview_of_xpcom/index.html
@@ -0,0 +1,535 @@
+---
+title: 创建_XPCOM_组件/XPCOM_简介
+slug: Mozilla/Tech/XPCOM/Guide/Creating_components/An_Overview_of_XPCOM
+tags:
+ - XPCOM
+ - 所有分类
+translation_of: Mozilla/Tech/XPCOM/Guide/Creating_components/An_Overview_of_XPCOM
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/创建_XPCOM_组件:前言" style="float: left;">« 上一页</a><a href="/zh-CN/docs/创建_XPCOM_组件:使用_XPCOM_组件">下一页 »</a></p>
+</div><p></p>
+
+<p>这是一本关于 XPCOM 的书. 这本书是以编写一个 XPCOM 组件的方式来组织的, 但是这个过程涵盖了 XPCOM 组件模型主要的出发点, 概念和术语.</p>
+
+<p>本章以 XPCOM 的快速导览开始, 简单介绍了 XPCOM 和组件开发的基本概念和技术. 本章的大部分内容从一个很高的角度介绍了这些概念, 这些概念将在创建一个称为 <strong>WebLock</strong> 的 Mozilla 组件过程中逐渐透彻的讲述.</p>
+
+<h3 id="XPCOM_.E8.A7.A3.E5.86.B3.E6.96.B9.E6.A1.88" name="XPCOM_.E8.A7.A3.E5.86.B3.E6.96.B9.E6.A1.88">XPCOM 解决方案</h3>
+
+<p>Cross Platform Component Object Module (XPCOM) 是一个允许开发人员把一个大的工程划分成小的模块的框架. 这些小模块称为<em>组件</em>, 它们在运行时刻组装在一起.</p>
+
+<p>XPCOM 的目标是使软件的不同部分分别开发, 相互独立. 为了是应用的不同组件之间能够互操作, XPCOM 把组件的<em>实现</em>与<em>接口</em>(后面讨论<a href="#接口">接口</a>)分开. 同时 XPCOM 还提供了加载和操纵这些组件的库和工具以及服务, 以帮助开发人员编写跨平台的代码和组件版本管理; 因此组件可以在不破坏应用或者重新生成应用的同时被替换被更新. 通过使用 XPCOM, 开发人员创建的组件可以在不同的应用中被重用, 或者替换当前应用中的组件以改变应用的功能.</p>
+
+<p>XPCOM 不只提供组件软件开发的支持, 它同时提供一个开发平台的大多数功能的支持:</p>
+
+<ul>
+ <li>组件管理</li>
+ <li>文件抽象</li>
+ <li>对象消息传递</li>
+ <li>内存管理</li>
+</ul>
+
+<p>我们将在后面的章节中详细讨论上面的条目, 但是现在, 仅仅把 XPCOM 想象成一个 <em>组件开发平台</em>, 它提供了上面的这些特性.</p>
+
+<h3 id="Gecko" name="Gecko">Gecko</h3>
+
+<p>XPCOM 尽管在许多方面类似于 Microsoft COM, 但 XPCOM 被设计成主要应用于应用层. XPCOM 的最重要的应用是 <em>Gecko</em>, 一个开源的, 遵循标准的, 嵌入式 web 浏览器和 工具包.</p>
+
+<p>XPCOM 是访问 Gecko 库和嵌入或扩展 Gecko 的方法. 本书着重于后者 - 扩展 Gecko - 但是本书中描述的基本思想对嵌入 Gecko 的开发人员也很重要.</p>
+
+<p>Gecko 应用在许多 internet 程序中, 主要是浏览器. 包括 Gateway/AOL Instant AOL device 和 Nokia Media Terminal. Gecko 最近还被应用于的 Compuserve 客户端, AOL for Mac OS X, Netscape 7, 当然还包括 Mozilla 客户端. Gecko 是目前而言主流的开源浏览器.</p>
+
+<h3 id=".E7.BB.84.E4.BB.B6" name=".E7.BB.84.E4.BB.B6">组件</h3>
+
+<p>XPCOM 允许把一个大的工程分解为一些小部分. 这些小部分称为组件, 通常是一些小的可重用的二进制库(在 Windows 下表现为一个 DLL (动态联接库), Unix 下为一个 DSO (分布式共享对象), 这些二进制库可以包含一个或多个组件. 当多个相关组件被封装到一个二进制库, 这个库也称为<em>模块</em>.</p>
+
+<p>把软件划分成不同的组件可以使开发和维护工作变得更容易. 除了这个好处, 模块化组件化的编程还有下面的优势:</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">优点</td>
+ <td class="header">描述</td>
+ </tr>
+ <tr>
+ <td>重用</td>
+ <td>模块化的代码可以在其他应用和环境中被重用.</td>
+ </tr>
+ <tr>
+ <td>更新</td>
+ <td>在不需要重新编译整个应用的情况下更新组件.</td>
+ </tr>
+ <tr>
+ <td>性能</td>
+ <td>代码按照模块化组织, 模块就不必要立刻被加载, 而是以 "lazy" 方式加载, 或者根本不需要加载. 这样就可以提升应用的整体性能.</td>
+ </tr>
+ <tr>
+ <td>维护</td>
+ <td>甚至在不更新组件的情况下, 按照模块化的方式设计应用也能够使你对感兴趣的部分的维护变得更容易.</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>Mozilla 有几百万行代码, 没有那个人能够彻底搞明白整个代码的细节. 面对这样的一个系统, 最好的方式是把它划分成一些小的, 更容易管理的部分; 同时使用组件模型来编程, 把相关组件组织到各个模块中去. 比如说, Mozilla 的网络库就包含了 HTTP, FTP, 及其他协议的组件, 这些组件被塞到一个单独的库里. 这个库就是网络模块, 也就是通常所说的 "necko."</p>
+
+<p>但是把事物划分开来并不一定就好, 有许多事物作为一个整体组织起来才是最好的方式, 或者根本就不能划分开来. 比如说, 一个小孩就可能不吃没有果酱的三明志, 对于他来说, 果酱和三明志是缺一不可的整体. 同样的情形也会存在于某些软件中, 某些需要紧耦合的仅仅在内部使用的部分就并不需要费力去把它拆开成为小的模块.</p>
+
+<p>Gecko 中的 HTTP (超文本传输协议)  组件并不会暴露它内部的类, 它是作为一个整体来使用. 组件内部的事物不应该暴露给 XPCOM. 在 Mozilla 早期的开发中, 有些组件的创建并不适当, 但是随着开发的深入, 这些部分会被逐渐移出 XPCOM.</p>
+
+<h3 id=".E6.8E.A5.E5.8F.A3" name=".E6.8E.A5.E5.8F.A3">接口</h3>
+
+<p>把软件划分成组件通常一个好的解决方法, 但是我们该怎么做呢? 基本的思路是按照功能进行划分, 理解这些功能块之间的如何进行通信. 这些组件之间的通信通道就构成了各个组件的边界, 这些边界形式的描述为<em>接口</em>.</p>
+
+<p>接口并不是编程中的一个新的概念. 从我们的第一个 "HelloWorld" 程序开始我们就一直在不知不觉的使用它, 这里的接口就存在于我们的应用程序和打印程序之间. 应用程序使用 <code>stdio</code> 库提供的接口来把 "hello world" 字符串打印到屏幕上. XPCOM 与 "HelloWorld" 程序的不同之处在于 XPCOM 会在运行时刻找到这个屏幕打印的功能, 而 XPCOM 事前根本就不需要在编译的时刻了解 <code>stdio</code> 库提供了什么东西.</p>
+
+<p>接口允许开发人员把功能的具体实现<em>封装</em>在组件内部, 而客户程序不需要了解这个功能是如何实现的, 它只需要使用它就行了.</p>
+
+<div class="side-note">
+<p><span id="%E6%8E%A5%E5%8F%A3%E4%B8%8E%E6%8C%89%E7%85%A7%E5%A5%91%E7%BA%A6(Contract)%E7%BC%96%E7%A8%8B"><a id="%E6%8E%A5%E5%8F%A3%E4%B8%8E%E6%8C%89%E7%85%A7%E5%A5%91%E7%BA%A6(Contract)%E7%BC%96%E7%A8%8B"></a><strong>接口与按照契约(Contract)编程</strong></span></p>
+
+<p>一个接口在组件与客户程序之间达成契约. 并没有任何强制措施保证认同这个契约, 但是忽略它会是致命的. 在基于组件的编程中, 组件保证它提供的接口是<em>不变的</em> - 不同版本的组件都要提供同样的访问方法 - 这就与使用它的客户程序达成了一种契约. 从这种角度来说, 基于组件的编程通常也称为<em>按照契约编程</em>.</p>
+</div>
+
+<h4 id=".E6.8E.A5.E5.8F.A3.E4.B8.8E.E5.B0.81.E8.A3.85" name=".E6.8E.A5.E5.8F.A3.E4.B8.8E.E5.B0.81.E8.A3.85">接口与封装</h4>
+
+<p>组件边界之间的抽象对软件的可维护性与可重用性是致关重要的. 举个例子来说, 考虑下面一个没有很好封装的类. 在下面的例子中, 使用可自由访问的 public 的初始化方法可能会出问题.</p>
+
+<p><span id="SomeClass%E7%B1%BB%E5%88%9D%E5%A7%8B%E5%8C%96"><a id="SomeClass%E7%B1%BB%E5%88%9D%E5%A7%8B%E5%8C%96"></a><strong>SomeClass类初始化</strong></span></p>
+
+<pre>class SomeClass
+{
+ public:
+ // Constructor
+ SomeClass();
+
+ // Virtual Destructor
+ virtual ~SomeClass();
+
+ // init method
+ void Init();
+
+ void DoSomethingUseful();
+};
+</pre>
+
+<p>系统要工作正常, 客户程序员必须注意到组件程序员建立的潜规则. 这就是这个未很好封装的类的契约: 这是一套关于何时该调用一个方法, 调用这个方法之前应该做什么的规则. 这个规则可能指出 <code>DoSomethingUseful</code> 方法只能在调用 <code>Init()</code> 之后被使用. <code>DoSomethingUseful</code> 方法可能会做某些检查工作以保证条件满足 - <code>Init</code> 已经被调用.</p>
+
+<p>除了在代码中给出注释告诉客户程序员关于 <code>Init()</code> 规则之外, 程序员可以使他的契约更明晰. 首先对象的构造函数可以封装起来, 然后向客户程序员提供一个声明 <code>DoSomethingUseful</code> 方法的<em>虚基类</em>. 通过这种方式, 构造函数和初始化函数被隐藏起来. 在这种<em>半封装</em>条件下, 这个类只向客户程序暴露一些良好定义的可调用方法(或者称为接口). 一旦按照这种方式封装一个类, 客户程序只能看到的是下面的接口:</p>
+
+<p><span id="SomeInterface%E5%B0%81%E8%A3%85"><a id="SomeInterface%E5%B0%81%E8%A3%85"></a><strong>SomeInterface封装</strong></span></p>
+
+<pre>class SomeInterface
+{
+ public:
+ virtual void DoSomethingUseful() = 0;
+};
+</pre>
+
+<p>实现类就可以从这个虚基类派生, 实现接口的功能. 客户程序使用类厂(factory pattern)模式来创建对象(参看<a href="#类厂">类厂</a>), 而封装类的内部实现. XPCOM 以这种方式把客户程序屏蔽在组件的内部工作之外, 而客户程序也只依赖于提供所需要功能的接口.</p>
+
+<h4 id="nsISupports_.E5.9F.BA.E6.8E.A5.E5.8F.A3" name="nsISupports_.E5.9F.BA.E6.8E.A5.E5.8F.A3"><code>nsISupports</code> 基接口</h4>
+
+<p>组件与基于接口的编程的两个最基本的问题是: 一个是<em>组件生存期</em>, 也称为<em>对象所属关系</em>; 另一个是<em>接口查询</em>, 它是在运行时刻确定接口能够提供哪些接口. 这一节介绍基接口 <code>nsISupports</code> - 它是 XPCOM 中所有接口的父接口, 它提供了上面两个问题的解决方案.</p>
+
+<h5 id=".E5.AF.B9.E8.B1.A1.E6.89.80.E5.B1.9E.E5.85.B3.E7.B3.BB" name=".E5.AF.B9.E8.B1.A1.E6.89.80.E5.B1.9E.E5.85.B3.E7.B3.BB">对象所属关系</h5>
+
+<p>在 XPCOM 中, 由于组件可以实现任意多的不同接口, 接口必须是<em>引用计数的</em>. 组件在内部跟踪客户程序对它的接口引用了多少次, 当接口计数为零的时候组件就会卸载它自己.</p>
+
+<p>当一个组件创建后, 组件内部有一个整数在跟踪这个引用计数值. 客户程序实例化组件就会自动对这个引用计数加一; 在组件的整个生存期内, 引用计数或加或减, 总是大于零的. 如果在某个时刻, 所有的客户程序对该组件都失去了兴趣, 引用计数减到零, 组件就会卸载自己.</p>
+
+<p>客户程序使用相关接口是一个非常直接的过程. XPCOM 有一些工具让我们更方便的使用接口, 我们会在后面讲述. 如果客户程序在使用接口的时候忘记对接口的引用计数进行相关操作, 就会对组件的维护工作带来某些问题. 此时, 由于组件的引用计数始终不为零, 它就永远不会释放, 从而导致内存泄漏. 引用计数系统就象 XPCOM 的许多其他事物一样, 是客户与组件之间的契约. 如果遵守这些契约, 就会工作得很正常, 反之不然. 由创建接口指针的函数负责对初始化的接口引用加1, 这个引用也称为<em>所属引用</em>.</p>
+
+<div class="side-note">
+<p><span id="XPCOM%E4%B8%AD%E7%9A%84%E6%8C%87%E9%92%88"><a id="XPCOM%E4%B8%AD%E7%9A%84%E6%8C%87%E9%92%88"></a><strong>XPCOM中的指针</strong></span></p>
+
+<p>XPCOM 中的<em>指针</em>术语指的是接口指针. 它与常规指针相比有细微的差别, 毕竟它们都指向的是某个内存区域. 但是 XPCOM 指针指向的都是从 nsISupports 基接口派生而来的接口实现, 这个基接口包括三个基本的方法: <code>AddRef</code>, <code>Release</code>, 和 <code>QueryInterface</code>.</p>
+</div>
+
+<p><code>nsISupports</code> 接口提供了对接口查询与引用计数基本的支持. 这个接口的成员方法包括: <code>QueryInterface</code>, <code>AddRef</code>, 和 <code>Release</code>. 这些方法提供了从一个对象获取正确接口的基本方法, 加引用计数, 释放不再使用的对象. <code>nsISupports</code> 接口的声明如下:</p>
+
+<p><span id="%3Ccode%3EnsISupports%3C/code%3E_%E6%8E%A5%E5%8F%A3"><a id="%3Ccode%3EnsISupports%3C/code%3E_%E6%8E%A5%E5%8F%A3"></a><strong><code>nsISupports</code> 接口</strong></span></p>
+
+<pre>class Sample: public nsISupports
+{
+ private:
+ nsrefcnt mRefCnt;
+ public:
+ Sample();
+ virtual ~Sample();
+
+ NS_IMETHOD QueryInterface(const nsIID &amp;aIID, void **aResult);
+ NS_IMETHOD_(nsrefcnt) AddRef(void);
+ NS_IMETHOD_(nsrefcnt) Release(void);
+};
+</pre>
+
+<p>接口中使用的各种数据类型见<a href="#XPCOM_类型">XPCOM 类型</a>一节. <code>nsISupports</code> 接口的实现代码如下:</p>
+
+<p><span id="%3Ccode%3EnsISupports%3C/code%3E_%E6%8E%A5%E5%8F%A3%E5%AE%9E%E7%8E%B0"><a id="%3Ccode%3EnsISupports%3C/code%3E_%E6%8E%A5%E5%8F%A3%E5%AE%9E%E7%8E%B0"></a><strong><code>nsISupports</code> 接口实现</strong></span></p>
+
+<pre>Sample::Sample()
+{
+ // initialize the reference count to 0
+ mRefCnt = 0;
+}
+Sample::~Sample()
+{
+}
+
+// typical, generic implementation of QI
+NS_IMETHODIMP Sample::QueryInterface(const nsIID &amp;aIID,
+ void **aResult)
+{
+ if (aResult == NULL) {
+ return NS_ERROR_NULL_POINTER;
+ }
+ *aResult = NULL;
+ if (aIID.Equals(kISupportsIID)) {
+ *aResult = (void *) this;
+ }
+ if (*aResult == NULL) {
+ return NS_ERROR_NO_INTERFACE;
+ }
+ // add a reference
+ AddRef();
+ return NS_OK;
+}
+
+NS_IMETHODIMP_(nsrefcnt) Sample::AddRef()
+{
+ return ++mRefCnt;
+}
+
+NS_IMETHODIMP_(nsrefcnt) Sample::Release()
+{
+ if (--mRefCnt == 0) {
+ delete this;
+ return 0;
+ }
+ // optional: return the reference count
+ return mRefCnt;
+}
+</pre>
+
+<h5 id=".E5.AF.B9.E8.B1.A1.E6.8E.A5.E5.8F.A3.E7.9A.84.E5.8F.91.E7.8E.B0" name=".E5.AF.B9.E8.B1.A1.E6.8E.A5.E5.8F.A3.E7.9A.84.E5.8F.91.E7.8E.B0">对象接口的发现</h5>
+
+<p><em>继承</em>是面向对象编程中另一个非常重要的话题. 继承是通过一个类派生另一个类的方法. 当一个类继承另一个类, 继承类可以<em>重载</em>基类的缺省动作, 而不需要拷贝基类的代码, 从而创建更加专有的类. 如下所示:</p>
+
+<p><span id="%E7%AE%80%E5%8D%95%E7%B1%BB%E7%BB%A7%E6%89%BF"><a id="%E7%AE%80%E5%8D%95%E7%B1%BB%E7%BB%A7%E6%89%BF"></a><strong>简单类继承</strong></span></p>
+
+<pre>class Shape
+{
+ private:
+ int m_x;
+ int m_y;
+
+ public:
+ virtual void Draw() = 0;
+ Shape();
+ virtual ~Shape();
+};
+
+class Circle : public Shape
+{
+ private:
+ int m_radius;
+ public:
+ virtual Draw();
+ Circle(int x, int y, int radius);
+ virtual ~Circle();
+};
+</pre>
+
+<p><code>Circle</code> 从 <code>Shape</code> 类派生. <code>Circle</code> 本身也是一个 <code>Shape</code>, 但是 <code>Shape</code> 并不一定是 <code>Circle</code>. 在这种情况下, <code>Shape</code> 是<em>基类</em>, <code>Circle</code> 是 <code>Shape</code> 的子类.</p>
+
+<p>在 XPCOM 中, 所有的类都派生自 <code>nsISupports</code> 接口, 这样所有的对象都提供 <code>nsISupports</code>接口, 但是这些对象是更专有的类, 在运行时刻必须能找到它. 比如说在<a href="#简单类继承">简单类继承</a>例子中, 如果对象是一个 <code>Circle</code>, 你就可以调用 <code>Shape</code> 类的方法. 就是为什么在 XPCOM 中, 所有的对象都派生自 <code>nsISupports</code> 接口: 它允许客户程序根据需要发现和访问不同的接口.</p>
+
+<p>在 C++ 中, 我们可以使用 <code>dynamic_cast&lt;&gt;</code> 来把一个 <code>Shape</code> 对象的指针强制转化成一个 <code>Circle</code> 指针, 如果不能转化就抛出异常. 但是在 XPCOM 中, 由于性能开销和平台兼容性问题, 采用 RTTI (运行时刻类型信息) 的方法是不行的.</p>
+
+<div class="side-note">
+<p><span id="XPCOM_%E4%B8%AD%E7%9A%84%E5%BC%82%E5%B8%B8"><a id="XPCOM_%E4%B8%AD%E7%9A%84%E5%BC%82%E5%B8%B8"></a><strong>XPCOM 中的异常</strong></span></p>
+
+<p>XPCOM 并不直接支持 C++ 的异常处理. 在 XPCOM 中, 所有的异常必须在组件内部处理, 而不能跨越接口的边界. 然后接口方法返回一个 <code>nsresult</code> 错误值(这些错误码请参考 <a href="/cn/XPCOM_API_Reference" title="cn/XPCOM_API_Reference">XPCOM API Reference</a>). 客户程序根据这些错误码进行"异常"处理.</p>
+</div>
+
+<p>XPCOM 没有采用 C++ RTTI 机制来实现对象指针的动态转化, 它使用 <code>QueryInterface</code> 方法来把一个对象指针 cast 成正确的接口指针.</p>
+
+<p>每个接口使用称为 "uuidgen" 的工具来生成专有ID. 这个 ID 是一个全局唯一的 128-bit 值. 在接口的语境中, 这个 ID 又称为 <em>IID</em>. (组件语境中, 这个 ID 代表的是一个契约)</p>
+
+<p>当客户程序想查询一个对象是否支持某个接口, 它把接口的 IID 值传递给这个对象的 <code>QueryInterface</code> 方法. 如果对象支持这个接口, 它就会对自己的引用计数加1, 然后返回指向那个专有接口的指针. 反之, 如果不支持这个接口, 它会返回一个错误码.</p>
+
+<pre>class nsISupports {
+ public:
+ long QueryInterface(const nsIID &amp; uuid,
+ void **result) = 0;
+ long AddRef(void) = 0;
+ long Release(void) = 0;
+};
+</pre>
+
+<p><code>QueryInterface</code> 的第一个参数是一个 <code>nsIID</code> 类型的引用, 它封装了 IID. <code>nsIID</code> 类有三种方法: <code>Equals</code>, <code>Parse</code>, 和 <code>ToString</code>. <code>Equals</code> 在接口查询中是最重要的, 它用来比较两个 <code>nsIID</code> 对象是否相同.</p>
+
+<p>在客户以 IID 调用 <code>nsISupports</code> 接口的 <code>QueryInterface</code> 方法时, 我们必须保证返回一个有效的 result 参数(在<a href="/cn/Creating_XPCOM_Components/Using_XPCOM_Utilities_to_Make_Things_Easier" title="cn/Creating_XPCOM_Components/Using_XPCOM_Utilities_to_Make_Things_Easier">Using XPCOM Utilities to Make Things Easier</a> 一章中, 我们将看到怎样更方便的实现一个 <code>nsIID</code> 类). <code>QueryInterface</code> 方法应该支持该组件所有接口的查询.</p>
+
+<p>在 <code>QueryInterface</code> 方法的实现中, IID 参数与组件支持 <code>nsIID</code> 类进行比较. 如果匹配, 对象的 <code>this</code> 指针转化为 <code>void</code> 指针, 引用计数加1, 把 <code>void</code> 指针返回给客户程序.</p>
+
+<p>在上面的例子中, 仅仅使用 C 方式的类型转化就足够了. 但是在把 <code>void</code> 指针 cast 成接口指针的时候, 还有更多的问题, 因为返回的接口指针必须与 vtable (virtual table) 相对应. 当出现菱形多重继承的时候, 可能这种接口转化就会有问题.</p>
+
+<h3 id="XPCOM_.E7.9A.84ID" name="XPCOM_.E7.9A.84ID">XPCOM 的ID</h3>
+
+<p>除了上一节中的接口 IID, XPCOM 还使用两种 ID 来区分类与组件.</p>
+
+<div class="side-note">
+<p><span id="XPCOM_ID%E7%B1%BB"><a id="XPCOM_ID%E7%B1%BB"></a><strong>XPCOM ID类</strong></span></p>
+
+<p><code>nsIID</code> 类实际上是一种 <code>nsID</code> 类. 其他的 <code>nsID</code>, CID 和 IID, 分别指的是一个实体类和一个专有的接口.</p>
+
+<p><code>nsID</code> 类提供 <code>Equals</code> 类似的方法, 来比较 ID. 请参考 <a href="/cn/Creating_XPCOM_Components/Creating_the_Component_Code#Identifiers_in_XPCOM" title="cn/Creating_XPCOM_Components/Creating_the_Component_Code#Identifiers_in_XPCOM">Identifiers in XPCOM</a> 一节, 其中对 <code>nsID</code> 类有更多的讨论.</p>
+</div>
+
+<h4 id="CID" name="CID">CID</h4>
+
+<p>CID 是一个唯一的 128-bit 值, 类似于 IID, 它用于全局标识唯一的类或者组件. <code>nsISupports</code> 的 CID 就象:</p>
+
+<p><code>00000000-0000-0000-c000-000000000046</code></p>
+
+<p>由于 CID 比较长, 通常我们都使用#define来定义它:</p>
+
+<pre>#define SAMPLE_CID \
+{ 0x777f7150, 0x4a2b, 0x4301, \
+{ 0xad, 0x10, 0x5e, 0xab, 0x25, 0xb3, 0x22, 0xaa}}
+</pre>
+
+<p>我们将会看到许多 <code>NS_DEFINE_CID</code> 的定义. 下面的宏用 CID 定义了一个静态变量:</p>
+
+<pre>static NS_DEFINE_CID(kWebShellCID, NS_WEB_SHELL_CID);
+</pre>
+
+<p>CID 有时也称为<em>类 ID</em>. 如果一个类实现了多个接口, 当CID 在该类发布后, 就与该类的 IID 一起被冻结了.</p>
+
+<h4 id=".E5.A5.91.E7.BA.A6_ID" name=".E5.A5.91.E7.BA.A6_ID">契约 ID</h4>
+
+<p>契约 ID 是一个用于访问组件的可读(to humen)的字符串. 一个 CID 或者一个契约 ID 可以用于从一个组件管理器获取组件. 下面是一个用于 LDAP 操作组件的契约 ID:</p>
+
+<pre>"@mozilla.org/network/ldap-operation;1"
+</pre>
+
+<p>契约 ID 的格式是: 用斜杠分开的组件的<em>域</em>, <em>模块</em>, <em>组件名</em>, <em>版本号</em>.</p>
+
+<p>与 CID 类似, 契约 ID 指的是组件实现而不是接口. 但是契约 ID 并不像CID那样,被限定为某个专有实现, 它更通用. 一个契约 ID 只是指明需要实现的一组接口,可以通过任意数量的CID满足这个需要. 契约 ID 与 CID 的这种不同, 使得组件重写成为可能.</p>
+
+<h3 id=".E7.B1.BB.E5.8E.82" name=".E7.B1.BB.E5.8E.82">类厂</h3>
+
+<p>把代码划分成组件, 客户代码通常使用 <code>new</code> 操作符来构造实例对象:</p>
+
+<pre>SomeClass* component = new SomeClass();
+</pre>
+
+<p>这种模式或多或少地需要客户对组件有一定的了解,至少要知道组件的大小. <em>类厂设计模式</em>此时可以用来封装对象的构造过程. 类厂模式的目的是在不暴露对象的实现和初始化的前提下创建对象. 在 <code>SomeClass</code> 例子中, 可以按照类厂模式把 <code>SomeClass</code> 对象的构造和初始化封装在 <code>New_SomeInterface</code> 函数中:</p>
+
+<p><span id="%E5%B0%81%E8%A3%85%E6%9E%84%E9%80%A0%E5%87%BD%E6%95%B0"><a id="%E5%B0%81%E8%A3%85%E6%9E%84%E9%80%A0%E5%87%BD%E6%95%B0"></a><strong>封装构造函数</strong></span></p>
+
+<pre>int New_SomeInterface(SomeInterface** ret)
+{
+ // create the object
+ SomeClass* out = new SomeClass();
+ if (!out) return -1;
+
+ // init the object
+ if (out-&gt;Init() == FALSE)
+ {
+ delete out;
+ return -1;
+ }
+
+ // cast to the interface
+ *ret = static_cast&lt;SomeInterface*&gt;(out);
+ return 0;
+}
+</pre>
+
+<p>类厂本身是一个管理组件实例化的类. 在 XPCOM 中, 类厂要实现 <code>nsIFactory</code> 接口, 它们就象上面的代码一样要使用类厂设计模式来封装对象的构造和初始化.</p>
+
+<p><a href="#封装构造函数">封装构造函数</a> 的例子是一个简单的无状态的类厂版本, 实际的编程要复杂一些, 一般的类厂都需要保存状态. 类厂至少应该保存那些对象已经被创建了的信息. 如果类厂管理的实例被存放在一个动态联接库中, 还需要知道什么时候可以卸载这个动态联接库. 当类厂保存了这样的信息, 就可以向类厂查询一个对象是否已经被创建.</p>
+
+<p>另一个需要保存的信息是关于<em>单件(singleton)</em>. 如果一个类厂已经创建了一个单件类型的类, 后续的创建该单件的函数调用将返回已经创建的对象. 尽管有更好的工具和方式来管理单件(在讨论 <code>nsIServiceManager</code> 会看到), 开发人员可能仍然需要通过这种方式来保证只有一个单件对象被创建.</p>
+
+<p>厂模式可以完全利用函数来做, 状态可以保存在全局变量中; 但是使用类的方式来实现厂模式还有更多的好处. 其一是: 我们可以管理从 <code>nsISupports</code> 接口派生而来的类厂本身的生存期. 当我们试图把多个类厂划分成一组, 然后确定是否能卸载这一组类厂的时候, 这一点非常重要. 另一个好处是: 类厂可以引入其他需要支持的接口. 在我们后面讨论 <code>nsIClassInfo</code> 接口的时候, 我们会看到某些类厂使用这个接口支持信息查询, 诸如这个对象是用什么语言写的, 对象支持的接口等等. 这种派生自 <code>nsISupports</code> 的 "future-proofing" 特性非常关键.</p>
+
+<h4 id="XPIDL_.E4.B8.8E.E7.B1.BB.E5.9E.8B.E5.BA.93" name="XPIDL_.E4.B8.8E.E7.B1.BB.E5.9E.8B.E5.BA.93">XPIDL 与类型库</h4>
+
+<p>定义接口的简单而强劲的方法是使用<em>接口定义语言</em>(IDL) - 这实际上是在一个跨平台而语言无关开发环境下定义接口的需求. XPCOM 使用的是源自于 CORBA OMG 接口定义语言(IDL)的变体, 称为 XPIDL, 来定义接口, XPIDL 可以定义接口的方法, 属性, 常量, 以及接口继承.</p>
+
+<p>采用 XPIDL 定义接口还存在一些缺陷. 它不支持多继承, 同时 XPIDL 定义的方法名不能相同,你不能有两个相同名字但是所接受的参数不同的函数. - 不能像 C++ 语言的成员函数一样通过参数不同重载, 毕竟接口同时要支持类似于 C 这样的语言.</p>
+
+<pre>void FooWithInt(in int x);
+void FooWithString(in string x);
+void FooWithURI(in nsIURI x);
+</pre>
+
+<p>然而尽管有这些问题, XPIDL 的功能仍然是非常强大的. XPIDL 能自动生成以 <em>.xpt</em> 为后缀的<em>类型库</em>, 或者说 typelibs. 类型库是接口的二进制表示, 它向非 C++ 语言提供接口的访问与控制. 非 C++ 语言通过类型库来了解接口支持哪些方法, 如何调用这些方法, 这称为 <em>XPConnect</em>. XPConnect 是 XPCOM 向类似于 JavaScript 这样的语言提供组件访问的 Wrapper. 参看<a href="/cn/Creating_XPCOM_Components/Using_XPCOM_Components#Connecting_to_Components_from_the_Interface" title="cn/Creating_XPCOM_Components/Using_XPCOM_Components#Connecting_to_Components_from_the_Interface">Connecting to Components from the Interface</a>获取更多关于 XPConnect 的信息.</p>
+
+<p>从其他类型的语言访问接口, 常常说成是接口被<em>反射(reflected)</em>到这种语言. 每一个被反射的接口必须提供相应的类型库. 当前可以使用 C, C++, 和 JavaScript 来编写组件.</p>
+
+<div class="side-note">
+<p><span id="%E4%BD%BF%E7%94%A8%E5%85%B6%E4%BB%96%E8%AF%AD%E8%A8%80%E7%BC%96%E5%86%99%E7%BB%84%E4%BB%B6"><a id="%E4%BD%BF%E7%94%A8%E5%85%B6%E4%BB%96%E8%AF%AD%E8%A8%80%E7%BC%96%E5%86%99%E7%BB%84%E4%BB%B6"></a><strong>使用其他语言编写组件</strong></span></p>
+
+<p>在使用其他语言创建组件的时候, 不需要利用 XPCOM 提供给 C++ 程序员的工具(诸如一些宏, 智能指针等等, 我们可以方便的利用到这种语言本身来创建组件. 比如说, 基于 Python 的 XPCOM 组件可以从 JavaScript 来调用.</p>
+
+<p>参看 <a href="/cn/Creating_XPCOM_Components/Resources" title="cn/Creating_XPCOM_Components/Resources">Resources</a> 获取更多使用其他语言来创建组件的信息.</p>
+</div>
+
+<p>所有的 XPCOM 接口都用 XPIDL 语法来定义. <em>xpidl 编译器</em>会从这个 IDL 文件产生类型库和 C++ 头文件. 在<a href="/cn/Creating_XPCOM_Components/Starting_WebLock#Defining_the_WebLock_Interface_in_XPIDL" title="cn/Creating_XPCOM_Components/Starting_WebLock#Defining_the_WebLock_Interface_in_XPIDL">Defining the WebLock Interface in XPIDL</a> 一节详细描述了 XPIDL 语法.</p>
+
+<h3 id="XPCOM_.E6.9C.8D.E5.8A.A1" name="XPCOM_.E6.9C.8D.E5.8A.A1">XPCOM 服务</h3>
+
+<p>当客户需要某个组件提供的功能的时候, 通常都是<em>实例化</em>一个新的组件对象. 比如说, 客户程序需要某些处理文件, 这里每个组件就代表一个文件, 客户可能会同时处理多个这样的组件.</p>
+
+<p>但是在某些情况下对象表示的是一种<em>服务</em>, 这种服务只能有一个拷贝(尽管会有多个服务同时运行). 每次客户程序访问服务提供的功能时, 客户程序都是与同一个服务实例在打交道. 比如说, 一个用户查询公司的电话号码数据库, 数据库作为一个<em>对象</em>对用户来说都是同一的. 如若不然的话, 就需要维护两个数据库拷贝, 这种开销将非常大, 而且还存在数据内容不一致的问题. 单件设计模式就是提供系统中需要的这种单点访问功能.</p>
+
+<p>XPCOM 不仅提供了对组件的支持和管理服务, 它还包含了许多编写跨平台组件所需要的其他服务. 其中包括: 跨平台文件抽象, 向 XPCOM 开发人员提供同一而强大的文件访问功能. 目录服务, 提供应用和特定系统定位信息. 内存管理, 保证所有对象使用同样的内存分配器. 事件通知机制, 允许传递简单消息. 本教程将在后面展现如何使用这些服务, <a href="/cn/XPCOM_API_Reference" title="cn/XPCOM_API_Reference">XPCOM API Reference</a> 一节有完整的接口索引列表.</p>
+
+<h3 id="XPCOM_.E7.B1.BB.E5.9E.8B" name="XPCOM_.E7.B1.BB.E5.9E.8B">XPCOM 类型</h3>
+
+<p>XPCOM 声明了许多数据类型和简单宏, 这些东西将在我们后面的例子中看到. 大多数的宏都是简单的重定义, 下一节我们会描述一些最常用的数据类型.</p>
+
+<h4 id=".E6.96.B9.E6.B3.95.E7.B1.BB.E5.9E.8B" name=".E6.96.B9.E6.B3.95.E7.B1.BB.E5.9E.8B">方法类型</h4>
+
+<p>下面的类型用在 XPCOM 方法调用的参数和返回值定义中.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>NS_IMETHOD</code></td>
+ <td>声明方法返回值. XPCOM 的方法缺省的返回值声明.</td>
+ </tr>
+ <tr>
+ <td><code>NS_IMETHODIMP</code></td>
+ <td>方法实现返回值. XPCOM 方法函数返回的时候缺省采用这种类型的返回值.</td>
+ </tr>
+ <tr>
+ <td><code>NS_IMETHODIMP_(type)</code></td>
+ <td>特定类型的方法实现返回值. 诸如 <code>AddRef</code> 和 <code>Release</code> 的方法不返回缺省类型, 这种返回值的不一致虽然有点不舒服, 但是必需的.</td>
+ </tr>
+ <tr>
+ <td><code>NS_IMPORT</code></td>
+ <td>共享库内部使用的符号局部声明</td>
+ </tr>
+ <tr>
+ <td><code>NS_EXPORT</code></td>
+ <td>共享库导出的符号声明.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h4 id=".E5.BC.95.E7.94.A8.E8.AE.A1.E6.95.B0" name=".E5.BC.95.E7.94.A8.E8.AE.A1.E6.95.B0">引用计数</h4>
+
+<p>下面的宏提供对引用计数的基本操作.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>NS_ADDREF</code></td>
+ <td>调用 <code>nsISupports</code> 对象的 <code>AddRef</code> 方法.</td>
+ </tr>
+ <tr>
+ <td><code>NS_IF_ADDREF</code></td>
+ <td>与上一个方法类似, 不同之处在于这个宏在<code>AddRef之前</code>会检查对象指针是否为空(虚函数指针).</td>
+ </tr>
+ <tr>
+ <td><code>NS_RELEASE</code></td>
+ <td>调用 <code>nsISupports</code> 对象的 <code>Release</code> 方法.</td>
+ </tr>
+ <tr>
+ <td><code>NS_IF_RELEASE</code></td>
+ <td>与上一个方法类似, 不同之处在于这个宏<code>在调用Release</code>之前会检查空指针.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id=".E7.8A.B6.E6.80.81.E7.A0.81" name=".E7.8A.B6.E6.80.81.E7.A0.81">状态码</h3>
+
+<p>下面的宏测试状态码.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>NS_FAILED</code></td>
+ <td>如果传递的状态码为失败, 则返回真.</td>
+ </tr>
+ <tr>
+ <td><code>NS_SUCCEEDED</code></td>
+ <td>如果传递的状态码为成功, 则返回真.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id=".E5.8F.98.E9.87.8F.E6.98.A0.E5.B0.84" name=".E5.8F.98.E9.87.8F.E6.98.A0.E5.B0.84">变量映射</h3>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>nsrefcnt</code></td>
+ <td>缺省的引用计数类型, 是一个 32-bit 整数.</td>
+ </tr>
+ <tr>
+ <td><code>nsresult</code></td>
+ <td>缺省数据类型, 是一个 32-bit 整数.</td>
+ </tr>
+ <tr>
+ <td><code>nsnull</code></td>
+ <td>缺省 null 类型.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id=".E9.80.9A.E7.94.A8_XPCOM_.E9.94.99.E8.AF.AF.E7.A0.81" name=".E9.80.9A.E7.94.A8_XPCOM_.E9.94.99.E8.AF.AF.E7.A0.81">通用 XPCOM 错误码</h3>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>NS_ERROR_NOT_INITIALIZED</code></td>
+ <td>如果实例未初试化, 返回该值.</td>
+ </tr>
+ <tr>
+ <td><code>NS_ERROR_ALREADY_INITIALIZED</code></td>
+ <td>如果实例已初试化, 返回该值.</td>
+ </tr>
+ <tr>
+ <td><code>NS_ERROR_NOT_IMPLEMENTED</code></td>
+ <td>如果方法未实现, 返回该值.</td>
+ </tr>
+ <tr>
+ <td><code>NS_ERROR_NO_INTERFACE</code></td>
+ <td>如果组件不支持某种类型接口, 返回该值.</td>
+ </tr>
+ <tr>
+ <td><code>NS_ERROR_NULL_POINTER</code></td>
+ <td>如果指针指向 <code>nsnull</code>, 返回该值 .</td>
+ </tr>
+ <tr>
+ <td><code>NS_ERROR_FAILURE</code></td>
+ <td>如果某个方法失效, 返回该值, 这时一个通用的错误值.</td>
+ </tr>
+ <tr>
+ <td><code>NS_ERROR_UNEXPECTED</code></td>
+ <td>如果一个未预料的错误发生, 返回该值.</td>
+ </tr>
+ <tr>
+ <td><code>NS_ERROR_OUT_OF_MEMORY</code></td>
+ <td>如果无法进行内存分配, 返回该值.</td>
+ </tr>
+ <tr>
+ <td><code>NS_ERROR_FACTORY_NOT_REGISTERED</code></td>
+ <td>如果一个请求的类型未注册, 返回该值.</td>
+ </tr>
+ </tbody>
+</table>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/创建_XPCOM_组件:前言" style="float: left;">« 上一页</a><a href="/zh-CN/docs/创建_XPCOM_组件:使用_XPCOM_组件">下一页 »</a></p>
+</div> <p></p><div class="licenseblock">
+<p>Copyright (c) 2003 by Doug Turner and Ian Oeschger. This material may be distributed only subject to the terms and conditions set forth in the <a class="external" href="http://www.opencontent.org/openpub/" rel="noopener">Open Publication License</a>, v1.02 or later. Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.</p>
+</div><p></p>
+
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/building_the_weblock_ui/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/building_the_weblock_ui/index.html
new file mode 100644
index 0000000000..51f544fb16
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/building_the_weblock_ui/index.html
@@ -0,0 +1,297 @@
+---
+title: Building the WebLock UI
+slug: Mozilla/Tech/XPCOM/Guide/Creating_components/Building_the_WebLock_UI
+tags:
+ - XPCOM
+ - 所有分类
+translation_of: Mozilla/Tech/XPCOM/Guide/Creating_components/Building_the_WebLock_UI
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Creating_XPCOM_Components:Finishing_the_Component" style="float: left;">« 上一页</a><a href="/zh-CN/docs/Creating_XPCOM_Components:Packaging_WebLock">下一页 »</a></p>
+</div><p></p>
+
+<p>到目前为止我们建立了一个可以安装到Gecko应用中的组件。你所使用的XPCOM接口和工具是通用的跨平台的,可以被Gecko Runtime Environment或者任何Mozilla1.2以后任何基于Gecko的应用(这时GRE已经可用)。</p>
+
+<p>本章,我们将建立<strong>WebLock</strong>组件的用户接口,这就意味着添加到<em>现有的</em> Mozilla 浏览器<sup><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Guide/Creating_components/Building_the_WebLock_UI#endnote_other-mozlike-browsers">[other-mozlike-browsers]</a></sup>. 他使用 <abbr title="XML UI Language">XUL</abbr>, 这是一个Gecko知道如何呈现用户界面的XML语言, 同时它也跟特定的Mozilla用户界面交互, 为此它要把自己作为UI的扩展安装起来. Specifically, the user interface we create in this chapter will be<em>overlaid</em> into the statusbar of the browser component, where it will provide a small icon the user can click to access the web lock interface.</p>
+
+<p><span id="WebLock_Indicator_in_Browser"><a id="WebLock_Indicator_in_Browser"></a><strong>WebLock Indicator in Browser</strong></span></p>
+
+<p><img alt="Image:web-lock-ui.png"></p>
+
+<h3 id="User_Interface_Package_List" name="User_Interface_Package_List">User Interface Package List</h3>
+
+<p>本章所描述的用户界面包括4个文件:</p>
+
+<ul>
+ <li><code>webLockOverlay.xul</code> is the file that defines the little status icon in the browser.</li>
+ <li><code>weblock.xul</code> defines the web lock manager dialog.</li>
+ <li><code>weblock.css</code> provides style rules for both of the XUL files.</li>
+ <li><code>weblock.js</code> provides JavaScript functions for both of the XUL files.</li>
+</ul>
+
+<p>下面章节描述每个文件的功能。. In the following chapter we'll describe how you can take these files and create a<em>package</em> , an installable archive that includes the <strong>WebLock</strong> component and the new UI.</p>
+
+<p>因为这些步骤 (特别是 overlay section) 与Mozilla非常相关, the chapter is divided up into a couple of different sections. 第二部分, <a href="#XUL">XUL</a>, 描述XML-based 用户接口语言 (XUL) 以及他如何创建一个对话框访问<strong>WebLock</strong> 组件和它的服务. 第三部分, <a href="#Overlaying_New_User_Interface_Into_Mozilla">Overlaying New User Interface Into Mozilla</a>, 描述如何建立一个overlay到浏览器以便Mozilla build能访问这个对话框. 在overlay section, 我们讨论如何从Mozilla导入scripts, images, 和其他资源到你的 UI, 这会是比较复杂的部分.</p>
+
+<p>If the <strong>WebLock</strong> component is being installed in Mozilla or another Gecko-based browser, then this third section shows you how to create the entry point in the browser for controlling the web locking. If you are planning on deploying the <strong>WebLock</strong> component in some other application, you'll have to devise a different means of access (e.g., native widgetry that instantiates and controls the <strong>WebLock</strong> component).</p>
+
+<h3 id="Client_Code_Overview" name="Client_Code_Overview">Client Code Overview</h3>
+
+<p>在我们开始实际用户界面以前,我们应该首先建立访问<strong>WebLock</strong>组件和它的接口来控制browser的Web locking的客户代码.</p>
+
+<p>首先, it's important to be able to 表达Lock的基本状态as soon as it's loaded. 如同安全网页icon, weblock icon 在browser右下角,提示browser是否当前是锁定的. Since the <strong>WebLock</strong> component is always initialized as unlocked, we can have the 客户代码 - 接口中的JavaScript代码 - 表达并跟踪状态 as the user manipulates the <code>iWebLock</code> interface. A boolean <code>wLocked</code> variable can do this:</p>
+
+<pre>// initialize the wLocked variable as unlocked
+var wLocked = 0;
+</pre>
+
+<p>Then the functions that get called from the interface and call through to the <code>lock</code> and <code>unlock</code> methods of the <strong>WebLock</strong> component must also adjust this variable accordingly:</p>
+
+<pre>function wLock()
+{
+ // check to see if locking is on or off
+ weblock.lock();
+ wLocked = 1;
+}
+
+function wUnLock()
+{
+ // check to see if locking is on or off
+ weblock.unlock();
+ wLocked = 0;
+}
+</pre>
+
+<p>这些函数的前提是<strong>WebLock</strong> 组件对于 JavaScript可见,in the form of the <code>weblock</code> object being used in the snippets above. As you can see, <code>weblock</code> is initialized as a global JavaScript variable, available in the scope of these functions and others:</p>
+
+<pre>var weblock = Components.classes["@dougt/weblock"]
+ .getService()
+ .QueryInterface(Components.interfaces.iWebLock);
+</pre>
+
+<p>In addition to this basic setup, you must also write JavaScript that uses the <code>AddSite</code> method to add new sites to the white list. This is a bit more complicated, because it requires that you work with the currently loaded page or provide other UI (e.g., a textfield where you can enter an arbitrary URL) for specifying URLs. In the <a href="#XUL">XUL</a> section we'll go into how the user interface is defined. This section describes the functions that are called from the interface and how they interact with the <strong>WebLock</strong> component.</p>
+
+<p>The URL that the <code>AddSite</code> method expects is a string, so we can pass a string directly in from the user interface, or we can do a check on the string and verify that it's a valid URL. In this tutorial, focusing as it is on the <strong>WebLock</strong> functionality (rather than the UI), we'll assume the strings we get from the UI itself are URLs we actually want to write to the white list:</p>
+
+<pre>function addThisSite()
+{
+ var tf = document.getElementById("dialog.input");
+ // weblock is global and declared above
+ weblock.AddSite(tf.value);
+}
+</pre>
+
+<p>这段javascript可以直接被 XUL widget调用, where the input string is retrieved as the <code>value</code> property of the <code>textbox</code> element.</p>
+
+<p>你还需要建立一个函数当用户点击weblock icon的时候来显示<strong>WebLock</strong> 窗口. That function uses the <code>openDialog</code> method from the <code>window</code> object and takes the URL to the XUL file in which the dialog is defined:</p>
+
+<pre>function loadWebLock()
+{
+ window.openDialog("chrome://weblock/weblock.xul");
+}
+</pre>
+
+<h3 id="XUL" name="XUL">XUL</h3>
+
+<p>The entire user interface of the Mozilla browser and all of the applications that go with it, including the mail client, the IRC client, and others, have been defined in an XML language called XUL. Elements in the XUL markup map to widgets in the interface that Gecko renders in a fairly straightforward way - so, for instance, the root element of an application window is the element <code>&lt;window/&gt;</code>, the root element of the dialog we'll be creating here is <code>&lt;dialog/&gt;</code>, and so forth. Within a XUL application file, elements like <code>&lt;button/&gt;</code>, <code>menu/&gt;</code>, and <code>checkbox/&gt;</code> can be hooked up to an event model, to scripts, and to the XPCOM interfaces that carry out a lot of the browser functionality in Mozilla.</p>
+
+<p>In <a href="cn/Creating_XPCOM_Components/Using_XPCOM_Components">Using XPCOM Components</a> you saw how XPCOM objects are reflected into the interface layer as JavaScript objects. In this chapter, now that we've created the <strong>WebLock</strong> component and made it available to XPCOM, we create the UI that actually instantiates the <strong>WebLock</strong> component and uses its methods to control page loading in the browser.</p>
+
+<p>In the previous section, we outlined the JavaScript that interacts with the <strong>WebLock</strong> component. In this section, we are going to create the XUL interface that calls the JavaScript methods when the user interacts with it.</p>
+
+<h4 id="The_XUL_Document" name="The_XUL_Document">The XUL Document</h4>
+
+<p>The first thing to do is create the actual XUL document in which the user interface for the dialog and the events that initiate interaction with the web locking are defined. At the top of all XUL documents, an XML declaration is followed by the root element for the document, which is usually <code>&lt;window/&gt;</code> 对于对话框,也可以是<code>&lt;dialog/&gt;</code>. The "shell" for the XUL file, then, looks like this:</p>
+
+<pre>&lt;?xml version="1.0"?&gt;
+&lt;?xml-stylesheet href="chrome://global/skin/" type="text/css"?&gt;
+
+&lt;dialog id="weblock_ui"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ title="Web Lock Manager"
+ persist="screenX screenY"
+ screenX="24" screenY="24"&gt;
+
+&lt;/dialog&gt;
+</pre>
+
+<p>注意这部分XUL文件也包含了stylesheet declaration, which imports CSS rules and applies them to particular parts of the interface. In Gecko, CSS 被用来几乎控制所有的XUL界面表现 - its color, position, style, and to some extent its behavior as well. The web lock manager dialog does not deviate from the look of a standard dialog, so it can use a single declaration to import the "global" skin from the browser and make it available to the widgets you define in <code>weblock.xul</code>.</p>
+
+<p>You can save this first, 最外层的web lock dialog部分称为<code>weblock.xul</code>, 你要把它放在附录B所描述的安装包里.</p>
+
+<div class="side-note">
+<p>注意这个文件包含了当用户/管理员点击web locking icon的时候弹出的对话框. 这部分UI - 需要动态地装载到Mozilla runtime - 在<a href="#Overlaying_New_User_Interface_Into_Mozilla">Overlaying New User Interface Into Mozilla</a>.</p>
+</div>
+
+<p>描述</p>
+
+<p>最终的对话框看起来是.</p>
+
+<p><span id="Web_Lock_Manager_Dialog"><a id="Web_Lock_Manager_Dialog"></a><strong>Web Lock Manager Dialog</strong></span></p>
+
+<p><img alt="Image:Weblock-sitelist-ui.png"></p>
+
+<p>As you can see, it's a simple interface, providing just enough widgetry to lock and unlock the browser and to add new sites to the list. The entire XUL file for the web lock manager dialog is defined in <a href="#weblock.xul">weblock.xul</a> below.</p>
+
+<h4 id="The_Locking_UI" name="The_Locking_UI">The Locking UI</h4>
+
+<p>Once you have the basic XUL wrapper set up for your interface, the next step is to define that part of the interface that locks and unlocks the browser. One of the most efficient ways to expose this is to use radio buttons, which allow the user to toggle a particulart state, as the figure above illustrates.</p>
+
+<p>In XUL individual <code>&lt;radio/&gt;</code> elements are contained within a parent element called <code>&lt;radiogroup/&gt;</code>. Grouping radio elements together creates the toggling UI by requiring that one or another of the elements be selected, but not both.</p>
+
+<p>The XUL that defines the radiogroup in the web lock manager dialog is this:</p>
+
+<pre>&lt;radiogroup&gt;
+ &lt;radio label="lock"/&gt;
+ &lt;radio label="unlock" selected="true"/&gt;
+&lt;/radiogroup&gt;
+</pre>
+
+<p>Since the <strong>WebLock</strong> component always starts up in the unlocked position, you can add the <code>selected="true"</code> attribute and value on the unlock radio button and reset it dynamically as the user takes action.</p>
+
+<h4 id="Site_Adding_UI" name="Site_Adding_UI">Site Adding UI</h4>
+
+<p>The next step is to create that part of the user interface that lets you add a new site to the white list. There are other, more sophisticated ways to do this; you may also want to include some UI that lets you view the white list or edit it as a list. In this part of the tutorial, however, we only provide the means of adding an URL provided as a string (which is not checked for validity) and passing it through to the <code>AddSite</code> API we defined in the earlier part of the tutorial.</p>
+
+<pre>&lt;separator class="thin"/&gt;
+
+&lt;hbox align="center"&gt;
+ &lt;textbox id="url.input" flex="1"/&gt;
+ &lt;button label="Add this URL" oncommand="addThisSite();"/&gt;
+&lt;/hbox&gt;
+</pre>
+
+<p>This snippet introduces a couple of new general layout widgets in XUL. The separator that appears at the top of this snippet creates a little divider between widgets like the kind you see in menus that divide sets of functionality available there. The parent of the textbox that users enter an URL into is something called an <code>&lt;hbox/&gt;</code>, which is a layout widget - often invisible - that controls the way its child elements are rendered. In this case the <code>&lt;hbox/&gt;</code> centers the textbox and the button children, and it orients them horizontally (in contrast to the <code>&lt;vbox/&gt;</code>, which orients its children vertically).</p>
+
+<p>Notice also that when it's clicked, the button executes a JavaScript function called <code>addThisSite()</code>, which we've already defined in the <code>weblock.js</code> file in <a href="#Client_Code_Overview">Client Code Overview</a> above.</p>
+
+<h4 id="weblock.xul" name="weblock.xul"><code>weblock.xul</code></h4>
+
+<pre>&lt;?xml version="1.0"?&gt;
+&lt;?xml-stylesheet href="chrome://global/skin/" type="text/css"?&gt;
+
+&lt;dialog id="weblock_mgg"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ title="Web Lock Manager"
+ style="width: 30em;"
+ persist="screenX screenY"
+ screenX="24" screenY="24"&gt;
+
+ &lt;script src="chrome://weblock/content/weblock.js"/&gt;
+
+ &lt;hbox&gt;
+ &lt;separator orient="vertical" class="thin"/&gt;
+ &lt;vbox flex="1"&gt;
+ &lt;separator class="thin"/&gt;
+ &lt;hbox align="center"&gt;
+ &lt;textbox id="dialog.input" flex="1"/&gt;
+ &lt;button label="Add this URL"
+ oncommand="addThisSite();"/&gt;
+ &lt;/hbox&gt;
+ &lt;hbox align="center"&gt;
+ &lt;radiogroup onchange="toggleLock();"&gt;
+ &lt;radio label="lock"/&gt;
+ &lt;radio label="unlock"/&gt;
+ &lt;/radiogroup&gt;
+ &lt;spacer flex="1"/&gt;
+ &lt;/hbox&gt;
+ &lt;/vbox&gt;
+ &lt;/hbox&gt;
+
+&lt;/dialog&gt;
+</pre>
+
+<h3 id="Overlaying_New_User_Interface_Into_Mozilla" name="Overlaying_New_User_Interface_Into_Mozilla">Overlaying New User Interface Into Mozilla</h3>
+
+<p>你已经有了一个可以跟<strong>WebLock</strong>组件交互的对话框, 但是你怎么把它装到browser中? 然后你怎么访问它呢? 当安装和准备好以后,<strong>WebLock</strong> 组件已经可以用了: XPCOM finds it and adds it to the list of registered components, and then WebLock observes the XPCOM startup event and initializes itself.</p>
+
+<p>But you still have to add your new UI into the browser so it can call the component, and the Mozilla overlay mechanism is the way to do this. Overlays 是 XUL文件可以用来注册他们自己以便动态地嵌入到Browser UI合适的位置.</p>
+
+<h4 id="webLockOverlay.xul" name="webLockOverlay.xul"><code>webLockOverlay.xul</code></h4>
+
+<p>The XUL that defines the new icon is small: 这是一个调用JavaScript function来装载前面我们定义的<code>weblock.xul</code> 文件的小图表. The icon is actually a separate <code>&lt;statusbarpanel/&gt;</code> element that gets overlaid into the main browser, along with some JavaScript and some CSS to control the behavior and appearance of the element, respectively. Here is that XUL file in its entirety:</p>
+
+<p><span id="The_WebLock_Overlay"><a id="The_WebLock_Overlay"></a><strong>The WebLock Overlay</strong></span></p>
+
+<pre>&lt;?xml version="1.0"?&gt;
+&lt;?xml-stylesheet href="chrome://navigator/content/weblock.css" type="text/css"?&gt;
+
+&lt;overlay id="weblockOverlay"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;
+
+ &lt;script type="application/x-javascript"
+ src="chrome://weblock/content/weblock.js"/&gt;
+
+ &lt;statusbar id="status-bar"&gt;
+ &lt;statusbarpanel class="statusbarpanel-iconic"
+ id="weblock-status"
+ insertbefore="offline-status"
+ oncommand="loadWebLock();"
+ status="none"/&gt;
+ &lt;/statusbar&gt;
+
+&lt;/overlay&gt;
+</pre>
+
+<p>文件的根元素不是<code>&lt;window/&gt;</code> 而是<code>&lt;overlay/&gt;</code>. In overlays 被 XUL elements用来把他们和其他元素相区分的<code>id</code>属性被设置称为browser中他们要嵌入部分的值. In this case, the weblock <code>&lt;statusbarpanel/&gt;</code> appears as a child of the <code>&lt;statusbar/&gt;</code> element with <code>id</code> "status-bar". This <code>id</code> is the same one used by the <code>&lt;statusbar/&gt;</code> in <code>navigator.xul</code>, which means that the overlay mechanism will merge the new UI here (i.e., the weblock statusbarpanel) and the UI already defined within that browser <code>&lt;statusbar/&gt;</code> at runtime.</p>
+
+<h3 id="Other_Resources" name="Other_Resources">Other Resources</h3>
+
+<p>这部分描述剩下的需要添加和打包到<strong>WebLock</strong>组件来提供web locking用户界面的文件。</p>
+
+<div class="side-note">
+<p><span id="Other_Front_End_Resources"><a id="Other_Front_End_Resources"></a><strong>Other Front End Resources</strong></span></p>
+
+<p>在某些UI包中, 本地化 resources are also defined. These include DTDs in which the language in which the UI is labelled can be extracted into external files, which are swapped with DTDs for other languages. For example, user interface packages often include an English DTD that defines labels and strings for button and menus and other elements in the interface. When the user selects a different<em>language pack</em> , all of the English that's been externalized in these files is dynamically replaced with the new choice. In addition to DTDs, the localization parts of a user interface may also include string bundles in which strings that are used in the interface JavaScript can be similarly replaced. 有一些技术通过单独的文件来提供这种功能. 包含<em>bindings</em> in XML files,<em>metadata</em> in RDF files, whole collections of CSS files called<em>skins</em> , and others.</p>
+</div>
+
+<h4 id="weblock.css" name="weblock.css">weblock.css</h4>
+
+<p>The following style rules are defined in <code>weblock.css</code>, a CSS file that is loaded by the overlay and applied to the icon in the browser that reflects the current status of the web lock and provides access to the web lock manager dialog.</p>
+
+<pre>statusbarpanel#weblock-status
+{
+ list-style-image: url("chrome://weblock/wlock.gif");
+}
+
+statusbarpanel#weblock-status[status="locked"]
+{
+ list-style-image: url("chrome://weblock/wl-lock.gif");
+}
+
+statusbarpanel#weblock-status[status="unlocked"]
+{
+ list-style-image: url("chrome://weblock/wl-un.gif");
+}
+</pre>
+
+<p>The style rules are distinguished by the state of the <code>status</code> attribute on the element in the XUL with the <code>id</code> "weblock-status." As you can see above, when the status of the element is set to "locked", the image <code>wl-lock.gif</code> is used to show the state, and when the web locking is unlocked, it uses <code>wl-un.gif</code>. (Note: We include three images to represent the state of the weblock, but <code>wlock.gif</code> and <code>wl-lock.gif</code> are identical, since weblock is presumed to be unlocked when it's loaded. This tutorial makes use of only two different states, but you can further customize the look of the weblock using the three images if you wish.)</p>
+
+<p>Since the presentation of the weblock manager dialog itself doesn't require any special styles, these are all the rules you need in the <code>weblock.css</code>. Note that the <code>weblock.xul</code> file in which the manager is defined imports only the global skin:</p>
+
+<pre>&lt;?xml-stylesheet href="chrome://global/skin/" type="text/css"?&gt;
+</pre>
+
+<p>Save <code>weblock.css</code> in your working directory.</p>
+
+<p>You should now have the four files listed at the top of this chapter as the "packing list" for the <strong>WebLock</strong> package (see <a href="#User_Interface_Package_List">User Interface Package List</a>). Don't worry for now about where these files are. 下一章, <a href="cn/Creating_XPCOM_Components/Packaging_WebLock">Packaging WebLock</a>, 我们讨论如何打包这些文件以便 <strong>WebLock</strong> 组件或者别的资源利用它们.</p>
+
+<h4 id="Image_Resources" name="Image_Resources">Image Resources</h4>
+
+<p>如果你学习本教程并且希望使用<strong>WebLock</strong>组件在statusbar中的图片,你可以从 <a class="external" href="http://www.brownhen.com/weblock下载他们和其他" rel="freelink">http://www.brownhen.com/weblock下载他们和其他</a><strong>weblock</strong>相关资源. The GIF files that represent the various states are:</p>
+
+<ul>
+ <li><code>wlock.gif</code></li>
+ <li><code>wl-lock.gif</code></li>
+ <li><code>wl-un.gif</code></li>
+</ul>
+
+<ol>
+ <li><div class="blockIndicator note"><strong>Note:</strong> other-mozlike-browsers</div> 或者你可能会很喜欢这些东西. 还有一些基于 Gecko的browsers ,例如Beonex 和 IBM Web Browser 也会共享很多Mozilla用户界面成分, 你也可能装载 <strong>WebLock</strong> 组件和用户界面到其中. 不过请注意, <strong>WebLock</strong>有可能还不能保证完全安装到Mozilla Firefox,因为firefox有一些新的变化 (这本书是2003的版本).</li>
+</ol>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Creating_XPCOM_Components:Finishing_the_Component" style="float: left;">« 上一页</a><a href="/zh-CN/docs/Creating_XPCOM_Components:Packaging_WebLock">下一页 »</a></p>
+</div> <p></p><div class="licenseblock">
+<p>Copyright (c) 2003 by Doug Turner and Ian Oeschger. This material may be distributed only subject to the terms and conditions set forth in the <a class="external" href="http://www.opencontent.org/openpub/" rel="noopener">Open Publication License</a>, v1.02 or later. Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.</p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/component_internals/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/component_internals/index.html
new file mode 100644
index 0000000000..d29da9a71d
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/component_internals/index.html
@@ -0,0 +1,217 @@
+---
+title: Component Internals
+slug: Mozilla/Tech/XPCOM/Guide/Creating_components/Component_Internals
+translation_of: Mozilla/Tech/XPCOM/Guide/Creating_components/Component_Internals
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/创建_XPCOM组件/使用XPCOM组件" style="float: left;">« 上一页</a><a href="/zh-CN/docs/Creating_XPCOM_Components/Creating_the_Component_Code">下一页 »</a></p>
+</div> 前几章以组件使用者的角度介绍了XPCOM 组件, 本章将以软件开发者的角度讨论XPCOM.您可以继续阅读以明白XPCOM的一般实现方式, 或者您也可以跳到下一章, 在下一章,以WebLock为例向一步一步您介绍 组件的开发过程。 <span class="comment">XXX mediawiki...</span><span class="comment">XXX sucks</span><p></p>
+
+<h3 id="Creating_Components_in_C.2B.2B" name="Creating_Components_in_C.2B.2B">使用C++创建组件</h3>
+
+<p>让我们开始研究怎样用c++创建XPCOM组件. 最常见的组件是以C++编写并编译成共享库(如Windows平台的DLL或者Unix平台的DSO)。</p>
+
+<p>The illustration below shows the basic relationship between the shared library containing the component implementation code you write and the XPCOM framework itself. In this diagram, the outer boundary is that of the module, the shared library in which a component is defined.</p>
+
+<p><span id="A_Component_in_the_XPCOM_Framework"><a id="A_Component_in_the_XPCOM_Framework"></a><strong>A Component in the XPCOM Framework</strong></span></p>
+
+<p><img alt="Image:component-internals-framework.png" class="internal" src="/@api/deki/files/615/=Component-internals-framework.png"></p>
+
+<p>When you build a component or module and compile it into a library, it must export a single method named <code>NSGetModule</code>. This <code>NSGetModule</code> function is the entry point for accessing the library. It gets called during registration and unregistration of the component, and when XPCOM wants to discover what interfaces or classes the module/library implements. In this chapter we will outline this entire process.</p>
+
+<p>As <a href="#A_Component_in_the_XPCOM_Framework">A Component in the XPCOM Framework</a> illustrates, in addition to the <code>NSGetModule</code> entry point, there are <code>nsIModule</code> and <code>nsIFactory</code> interfaces that control the actual creation of the component, and also the string and XPCOM glue parts, which we'll discuss in some detail in the next section (see <a href="/en/Creating_XPCOM_Components/Component_Internals#XPCOM_Glue" title="en/Creating_XPCOM_Components/Component_Internals#XPCOM_Glue">XPCOM Glue</a>). These latter supply ease-of-development utilities like smart pointers, generic modules support, and simple string implementations. The largest and possibly most complex part of a component is the code specific to the component itself.</p>
+
+<div class="side-note">
+<p><span id="But_Where_Are_the_Components?"><a id="But_Where_Are_the_Components?"></a><strong>But Where Are the Components?</strong></span></p>
+
+<p>Components reside in modules, and those modules are defined in shared library files that typically sit in the <em>components</em> directory of an XPCOM application.</p>
+
+<p>A set of default libraries stored in this components directory makes up a typical Gecko installation, providing functionality that consists of networking, layout, composition, a cross-platform user interface, and others.</p>
+
+<p>Another, even more basic view of this relationship of components to the files and interfaces that define them is shown in <a href="/en/Creating_XPCOM_Components/Creating_the_Component_Code" title="en/Creating_XPCOM_Components/Creating_the_Component_Code">Onion Peel View of XPCOM Component Creation</a> in the next chapter. The component is an abstraction sitting between the actual module in which it is implemented and the objects that its factory code creates for use by clients.</p>
+</div>
+
+<h3 id="XPCOM_Initialization" name="XPCOM_Initialization">XPCOM Initialization</h3>
+
+<p>To understand why and when your component library gets called, it is important to understand the XPCOM initalization process. When an application starts up, that application may <em>initialize</em> XPCOM. The sequence of events that kicks off this XPCOM initialization may be triggered by user action or by the application startup itself. A web browser that embeds Gecko, for example, may initialize XPCOM at startup through the embedding APIs. Another application may delay this startup until XPCOM is needed for the first time. In either case, the initialization sequence within XPCOM is the same.</p>
+
+<p>XPCOM starts when the application makes a call to initialize it. Parameters passed to this startup call allow you to configure some aspects of XPCOM, including the customization of location of specific directories. The main purpose of the API at this point is to change which <em>components</em> directory XPCOM searches when it looks for XPCOM components. This is how the API is used, for example, in the <em>Gecko Runtime Environment</em> (GRE).</p>
+
+<div class="side-note">
+<p><span id="XPCOM_Startup"><a id="XPCOM_Startup"></a><strong>XPCOM Startup</strong></span></p>
+
+<p>The six basic steps to XPCOM startup are as follows:</p>
+
+<ol>
+ <li>Application starts XPCOM.</li>
+ <li>XPCOM sends a notification that it's beginning startup.</li>
+ <li>XPCOM finds and processes the <em>component manifest</em> (see <a href="#Component_Manifests">Component Manifests</a> below).</li>
+ <li>XPCOM finds and processes the <em>type library manifest</em> (see <a href="#Type_Library_Manifests">Type Library Manifests</a> below).</li>
+ <li>If there are new components, XPCOM registers them:
+ <ol>
+ <li>XPCOM calls autoregistration start.</li>
+ <li>XPCOM registers new components.</li>
+ <li>XPCOM calls autoregistration end.</li>
+ </ol>
+ </li>
+ <li>Complete XPCOM startup: XPCOM notifies that it's begun.</li>
+</ol>
+
+<p>Component manifests and type library manifests are described in the following section, <a href="#XPCOM_Registry_Manifests">XPCOM Registry Manifests</a>.</p>
+</div>
+
+<h4 id="XPCOM_Registry_Manifests" name="XPCOM_Registry_Manifests">XPCOM Registry Manifests</h4>
+
+<p>XPCOM uses special files called manifests to track and persist information about the components to the local system. There are two types of manifests that XPCOM uses to track components:</p>
+
+<h5 id="Component_Manifests" name="Component_Manifests">Component Manifests</h5>
+
+<p>When XPCOM first starts up, it looks for the <em>component manifest</em>, which is a file that lists all registered components, and stores details on exactly what each component can do. XPCOM uses the component manifest to determine which components have been overridden. Starting with Mozilla 1.2, this file is named <code>compreg.dat</code> and exists in the <em>components</em> directory, but there are efforts to move it out of this location to a less application-centric (and thus more user-centric) location. Any Gecko-based application may choose to locate it elsewhere. XPCOM reads this file into an in-memory database.</p>
+
+<div class="side-note">
+<p><span id="Component_Manifests"><a id="Component_Manifests"></a><strong>Component Manifests</strong></span></p>
+
+<p>The component manifest is a mapping of files to components and components to classes. It specifies the following information:</p>
+
+<ul>
+ <li>Location on disk of registered components with file size</li>
+ <li>Class ID to Location Mapping</li>
+ <li>Contract ID to Class ID Mapping</li>
+</ul>
+
+<p>The component manifest maps component files to unique identifiers for the specific implementations (class IDs), which in turn are mapped to more general component identifiers (contract IDs).</p>
+</div>
+
+<h5 id="Type_Library_Manifests" name="Type_Library_Manifests">Type Library Manifests</h5>
+
+<p>Another important file that XPCOM reads in is the <em>type library manifest</em> file. This file is also located in the <em>components</em> directory and is named <code>xpti.dat</code>. It includes the location and search paths of all type library files on the system. This file also lists all known interfaces and links to the type library files that define these interface structures. These type library files are at the core of XPCOM scriptablity and the binary component architecture of XPCOM.</p>
+
+<div class="side-note">
+<p><span id="Type_Library_Manifests"><a id="Type_Library_Manifests"></a><strong>Type Library Manifests</strong></span></p>
+
+<p>Type library manifests contain the following information:</p>
+
+<ul>
+ <li>location of all type library files</li>
+ <li>mapping of all known interfaces to type libraries where these structures are defined</li>
+</ul>
+</div>
+
+<p>Using the data in these two manifests, XPCOM knows exactly which component libraries have been installed and what implementations go with which interfaces. Additionally, it relates the components to the type libraries in which the binary representations of the interfaces they support are defined.</p>
+
+<p>The next section describes how to hook into the XPCOM startup and registration process and make the data about your component available in these manifests, so that your component will be found and registered at startup.</p>
+
+<h4 id="Registration_Methods_in_XPCOM" name="Registration_Methods_in_XPCOM">Registration Methods in XPCOM</h4>
+
+<div class="side-note">
+<p><span id="What_Is_XPCOM_Registration?"><a id="What_Is_XPCOM_Registration?"></a><strong>What Is XPCOM Registration?</strong></span></p>
+
+<p>In a nutshell, registration is the process that makes XPCOM aware of your component(s). As this section and the next describe, you can register your component explicitly during installation, or with the <code>regxpcom</code> program, or you can use the autoregistration methods in the Service Manager to find and register components in a specified components directory:</p>
+
+<ul>
+ <li>XPInstall APIs</li>
+ <li><code>regxpcom</code> command-line tool</li>
+ <li><code>nsIComponentRegistrar</code> APIs from Service Manager</li>
+</ul>
+
+<p>The registration process is fairly involved. This section introduces it in terms of XPCOM initialization, and the next chapter describes what you have to do in your component code to register your component with XPCOM.</p>
+</div>
+
+<p>Once the manifest files are read in, XPCOM checks to see if there are any components that need to be registered. There are two supported ways to go about registering your XPCOM component. The first is to use <em>XPInstall</em>, which is an installation technology that may or may not come with a Gecko application and provides interfaces for registering your component during installation. Another, more explicit way to register your component is to run the application <code>regxpcom</code>, which is built as part of Mozilla and is also available in the Gecko SDK. <code>regxpcom</code> registers your component in the default component registry.</p>
+
+<p>A Gecko embedding application may also provide its own way of registering XPCOM components using the interface that is in fact used by both XPInstall and <code>regxpcom</code>, <code>nsIComponentRegistrar</code>. An application, for example, could provide a "registration-less" component directory whose components are automatically registered at startup and unregistered at shutdown. Component discovery does not currently happen automatically in non-debug builds of Gecko, however.</p>
+
+<p>When the registration process begins, XPCOM broadcasts to all registered observers a notification that says XPCOM has begun the registration of new components. After all components are registered, another notification is fired saying that XPCOM is done with the registration step. The <code>nsIObserver</code> interface that handles this notification is discussed in <a href="/en/Creating_XPCOM_Components/Starting_WebLock" title="en/Creating_XPCOM_Components/Starting_WebLock">Starting WebLock</a>.</p>
+
+<p>Once registration is complete and the notifications have fired, XPCOM is ready to be used by the application. If XPCOM registered your component, then it will be available to other parts of the XPCOM system. The <a href="#XPCOM_Initialization">XPCOM Initialization</a> section in this chapter describes registration in more detail.</p>
+
+<h4 id="Autoregistration" name="Autoregistration">Autoregistration</h4>
+
+<p>The term <em>autoregistration</em> is sometimes used synonymously with registration in XPCOM. In the <a href="#What_Is_XPCOM_Registration?">What Is XPCOM Registration?</a> note, we describe the three ways you can register components with XPCOM. Sometimes, applications use the <code>nsIComponentRegistrar</code> interface and create their own code for watching a particular directory and registering new components that are added there, which is what's often referred to as <em>autoregistration</em>. You should always know what the installation and registration requirements are for the applications that will be using your component.</p>
+
+<h4 id="The_Shutdown_Process" name="The_Shutdown_Process">The Shutdown Process</h4>
+
+<p>When the application is ready to shutdown XPCOM, it calls <code>NS_ShutdownXPCOM</code>. When that method is called, the following sequence of events occurs:</p>
+
+<ol>
+ <li>XPCOM fires a shutdown notification to all registered observers.</li>
+ <li>XPCOM closes down the Component Manager, the Service Manager and associated services.</li>
+ <li>XPCOM frees all global services.</li>
+ <li>NS_ShutdownXPCOM returns and the application may exit normally.</li>
+</ol>
+
+<div class="side-note">
+<p><span id="The_Unstoppable_Shutdown"><a id="The_Unstoppable_Shutdown"></a><strong>The Unstoppable Shutdown</strong></span></p>
+
+<p>Note that shutdown observation is unstoppable. In other words, the event you observe cannot be used to implement something like a "Are you sure you want to Quit?" dialog. Rather, the shutdown event gives the component or embedding application a last chance to clean up any leftovers before they are released. In order to support something like an "Are you sure you want to quit" dialog, the application needs to provide a higher-level event (e.g., <code>startShutdown()</code>) which allows for cancellation.</p>
+
+<p>Note also that XPCOM services may deny you access once you have received the shutdown notification. It is possible that XPCOM will return an error if you access the <code>nsIServiceManager</code> at that point, for example, so you may have to keep a reference-counted pointer to the service you are interested in using during this notification.</p>
+</div>
+
+<h4 id="Component_Loaders" name="Component_Loaders">Component Loaders</h4>
+
+<p>Components can be written in many languages. So far this book has been focusing on "native components," shared libraries exporting a <code>NSGetModule</code> symbol. But if there is a <em>component loader</em> for Javascript installed, then you can also write a JavaScript component.</p>
+
+<p>To register, unregister, load and manage various component types, XPCOM abstracts the interface between the XPCOM component and XPCOM with the Component Loader. This loader is responsible for initialization, loading, unloading, and supporting the <code>nsIModule</code> interface on behalf of each component. It is the Component Loader's responsibility to provide scriptable component support.</p>
+
+<p>When building a "native" component, the component loader looks for an exported symbol from the components shared library. "Native" here includes any language that can generate a platform native dynamically loaded library. Scripting languages and other "non-native" languages usually have no way to build native libraries. In order to have "non-native" XPCOM components work, XPCOM must have a special component loader which knows how to deal with these type of components.</p>
+
+<p>XPConnect, for example, provides a component loader that makes the various types, including the interfaces and their parameters, available to JavaScript. Each language supported by XPCOM must have a component loader.</p>
+
+<h4 id="Three_parts_of_a_XPCOM_Component_Library" name="Three_parts_of_a_XPCOM_Component_Library">Three parts of a XPCOM Component Library</h4>
+
+<p>XPCOM is like an onion<span class="comment">or a parfait! Everybody likes parfaits</span>. XPCOM components have at least three layers. From the innermost and moving outward these layers include:</p>
+
+<ul>
+ <li>The core XPCOM object</li>
+ <li>The factory code</li>
+ <li>The module code</li>
+</ul>
+
+<p>The core XPCOM object is the object that will implement the functionality you need. For example, this is the object that may start a network download and implement interfaces that will listen to the progress. Or the object may provide a new content type handler. Whatever it does, this object is at the core of the XPCOM component, and the other layers are supporting it, plugging it into the XPCOM system. A single library may have many of these core objects.</p>
+
+<p>One layer above the core object is the factory code. The factory object provides a basic abstraction of the core XPCOM object. <a href="/en/Creating_XPCOM_Components/An_Overview_of_XPCOM" title="en/Creating_XPCOM_Components/An_Overview_of_XPCOM">An Overview of XPCOM</a> discussed the factory design pattern that's used in a factory object. At this layer of the XPCOM Component Library, the factory objects are factories for the core XPCOM objects of the layer below.</p>
+
+<p>One more layer outward is the module code. The module interface provides yet another abstraction - this time of the factories - and allows for multiple factory objects. From the outside of the component library, there is only the single entry point, <code>NSGetModule()</code>. This point of entry may fan out to any number of factories, and from there, to any number of XPCOM objects.</p>
+
+<p>The factory design pattern in XPCOM is represented by the <code>nsIFactory</code> interface. The module layer is represented by the <code>nsIModule</code> interface. Most component libraries only need these two interfaces, along with the <code>nsISupports</code> interface, to have XPCOM load, recognize, and use their core object code.</p>
+
+<p>In the next section, we'll be writing the code that actually compiles into a component library, and you will see how each layer is implemented and how each interface is used. Following this initial, verbose demonstration of the APIs, we will introduce a faster more generic way of implementing the module and factory code using macros, which can make components much easier to create.</p>
+
+<h3 id="XPCOM_Glue" name="XPCOM_Glue">XPCOM Glue</h3>
+
+<p>XPCOM contains a lot of stuff. Most XPCOM interfaces are not frozen and are only meant to be used by the Gecko internals and not by clients. XPCOM provides many data structures from linked lists to <a class="external" href="http://en.wikipedia.org/wiki/AVL_tree">AVL trees</a>. It's tempting to reuse <code>nsVoidArray</code> or another publicly available class instead of writing your own linked list, but this may prove to be a fatal mistake. The class can change at any time and give you unexpected behavior.</p>
+
+<p>XPCOM makes for a very open environment. At runtime you can acquire any service or component by merely knowing a CID or Contract ID along with an IID. At last count there were over 1300 interfaces defined in XPIDL. Of those 1300 interfaces, less than 100 were frozen, which means that a developer is likely to stumble upon useful interfaces that aren't frozen. Unless an interface is explicitly marked "FROZEN" in the IDL comments, your component may possibly break or crash along with a version change.</p>
+
+<h4 id="The_Glue_Library" name="The_Glue_Library">The Glue Library</h4>
+
+<p>In general, you should avoid any interfaces, symbols in XPCOM, or other part of Gecko libraries that aren't frozen. However, there are some unfrozen tools in XPCOM that are used so often they are practically required parts of component programming.</p>
+
+<p>The smart pointer class, <code>nsCOMPtr</code>, for example, which makes reference counting less tedious and error-prone, is not actually frozen, and neither is <code>nsDebug</code>, a class for aiding in tracking down bugs, nor is <code>nsMemory</code>, a class to ensure that everyone uses the same heap, generic factory, and module. Instead of asking every developer to find and copy these various files into their own application, XPCOM provides a single library of "not-ready-to-freeze-but-really-helpful" classes that you can link into your application, as the following figure demonstrates.</p>
+
+<p><span id="XPCOM_Glue_and_Tools"><a id="XPCOM_Glue_and_Tools"></a><strong>XPCOM Glue and Tools</strong></span></p>
+
+<p><img alt="Image:xpcom-glue-tools.png" class="internal" src="/@api/deki/files/978/=Xpcom-glue-tools.png"></p>
+
+<p>This is the glue library. It provides a bridge, or "glue" layer, between your component and XPCOM.</p>
+
+<p>A version of the glue library is built into XPCOM, and when your component uses it, it links a snapshot of this library: it includes a copy of these unfrozen classes directly, which allows the XPCOM library version to change without affecting the software. There is a slight footprint penalty to linking directly, but this gives your component freedom to work in any recent environment. If footprint is a big issue in your component or application, you can trim out the pieces you don't need.</p>
+
+<h4 id="XPCOM_String_Classes" name="XPCOM_String_Classes">XPCOM String Classes</h4>
+
+<p>The base string types that XPCOM uses are <code>nsAString</code> and <code>nsACString</code>. These classes are described in the Mozilla String Guide (see <a href="/en/Creating_XPCOM_Components/Resources#Gecko_Resources" title="en/Creating_XPCOM_Components/Resources#Gecko_Resources">Gecko Resources</a>).</p>
+
+<p>The string classes that implement these abstract classes are another set of helpful, unfrozen classes in XPCOM. Most components and embedding applications need to link to some string class or other in order to utilize certain Gecko APIs, but the string code that Mozilla uses is highly complex and even more expensive than the glue code in terms of footprint (~100k). <code>nsEmbedString</code> and <code>nsEmbedCString</code> are available as very lightweight string implementations for component development, especially in small embedded applications. This string implementation does the bare minimum to support the <code>nsAString</code>/<code>nsACString</code> functionality.</p>
+
+<p>In your own component, you can go "slim" and restrict yourself to the <code>nsEmbedString</code> or go "hog wild" and use any of the the other strings. WebLock restricts itself to using the simple <code>nsEmbedString</code> family of classes.</p>
+
+<p><span id="String_Classes_and_XPCOM"><a id="String_Classes_and_XPCOM"></a><strong>String Classes and XPCOM</strong></span></p>
+
+<p><img alt="Image:strings-in-xpcom.png" class="internal" src="/@api/deki/files/867/=Strings-in-xpcom.png"></p>
+
+<p>The glue library provides stub functions for the public functions that XPCOM provides (see <code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/build/nsXPCOM.h" rel="custom">xpcom/build/nsXPCOM.h</a></code>). When the glue library is initialized, it dynamically loads these symbols from the XPCOM library, which allows the component to avoid linking directly with the XPCOM library. You shouldn't have to link to the XPCOM library to create a XPCOM component - in fact, if your component has to, then something is wrong. </p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Creating_XPCOM_Components/Using_XPCOM_Components" style="float: left;">« 上一页</a><a href="/zh-CN/docs/Creating_XPCOM_Components/Creating_the_Component_Code">下一页 »</a></p>
+</div><p></p><div class="licenseblock">
+<p>Copyright (c) 2003 by Doug Turner and Ian Oeschger. This material may be distributed only subject to the terms and conditions set forth in the <a class="external" href="http://www.opencontent.org/openpub/" rel="noopener">Open Publication License</a>, v1.02 or later. Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.</p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/creating_the_component_code/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/creating_the_component_code/index.html
new file mode 100644
index 0000000000..a4aa535eca
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/creating_the_component_code/index.html
@@ -0,0 +1,727 @@
+---
+title: Creating the Component Code
+slug: Mozilla/Tech/XPCOM/Guide/Creating_components/Creating_the_Component_Code
+tags:
+ - XPCOM
+ - 所有分类
+translation_of: Mozilla/Tech/XPCOM/Guide/Creating_components/Creating_the_Component_Code
+---
+<p> </p>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Creating_XPCOM_Components:Component_Internals" style="float: left;">« 上一页</a><a href="/zh-CN/docs/Creating_XPCOM_Components:Using_XPCOM_Utilities_to_Make_Things_Easier">下一页 »</a></p>
+</div><p></p>
+
+<p>这一章叙述处理你的组件和XPCOM之间关联的基本代码。让组件被找到和注册是这个章节的目的。在后续章节中,我们开始建立<strong>WebLock</strong>组件本身的功能。</p>
+
+<p>注:有些部分采用英汉对照的方式。避免翻译的不准确!</p>
+
+<div class="side-note">
+<p><span id="Use_the_Calculator_(After_Learning_Long_Division)"><a id="Use_the_Calculator_(After_Learning_Long_Division)"></a><strong>Use the Calculator (After Learning Long Division)</strong></span></p>
+
+<p>You have to write a fair amount of code to create a component library that gets loaded into XPCOM. 一个XPCOM组件起码要实现三个XPCOM要求的接口, 通常还有其他一些. 这一章包含了可能你不会需要的更多代码,不过<a href="/cn/Creating_XPCOM_Components/Using_XPCOM_Utilities_to_Make_Things_Easier" title="cn/Creating_XPCOM_Components/Using_XPCOM_Utilities_to_Make_Things_Easier">Using XPCOM Utilities to Make Things Easier</a>会教你一些更简单和优雅的使用通用宏建立XPCOM组件的方式, 本章主要讲述基本的内容。 As in grade school when you learned long division, better tools like calculators come <em>after</em> you figure out what's actually happening. In this case, the long-hand implementation gives us an opportunity to talk about various features of XPCOM.</p>
+</div>
+
+<h3 id="What_We.27ll_Be_Working_On" name="What_We.27ll_Be_Working_On">What We'll Be Working On</h3>
+
+<p>The component we'll be working on in this book controls a special mode in your browser that prevents users from leaving the current domain or a set of safe domains. Once enabled, this weblock mode is password protected and persists until it is turned off by the password holder. It can be used to make the browser into a safe viewer for children, or for targeted "kiosk browsing," where the content is restricted to a particular server. <a href="#Web_Lock_User_Interface">Web Lock User Interface</a> shows the icon that is used to activate the web lock mode (leftmost in the status bar) once you have installed the <strong>WebLock</strong> component and the extra user interface.</p>
+
+<h3 id="接下来的内容"> 接下来的内容</h3>
+
+<p>文章后续的内容,将向读者描述一个使浏览器处在受控模式(web lock mode)的组件,该组件采用密码保护的方式防止用户从当前域或者一组安全的域中离开。这个组件可以使用在为未成年人提供受限内容或者是在一些小型电子浏览器中防止页面跳出特定服务内容。在用户安装了WebLock组件和额外的用户接口后,在状态栏的最左边,如图<a href="#Web_Lock_User_Interface">Web Lock User Interface</a>,可以用图标来激活受控模式(web lock mode)</p>
+
+<p><span id="Web_Lock_User_Interface"><a id="Web_Lock_User_Interface"></a><strong>Web Lock User Interface</strong></span></p>
+
+<p><img alt="Image:web-lock-ui.png" class="internal" src="/@api/deki/files/2727/=Web-lock-ui.png"></p>
+
+<p>实际上组件<strong>WebLock</strong>做的大多数事情是准备组件本身,找到需要的XPCOM接口, 并且挂接到现有的Gecko Browser功能.</p>
+
+<h3 id="Component_Registration" name="Component_Registration">Component Registration 组件注册</h3>
+
+<p>All XPCOM components - whether they're stored in shared libraries (DLLs, DSOs or dylibs), JavaScript files, or some other file - need to be <em>registered</em> before they can be used. Registration is a process that happens in all XPCOM applications, whether they're embedded Gecko clients, Mozilla, Netscape 7, Compuserve, or any other software that uses XPCOM. Registration provides the information that applications need in order to use components properly.</p>
+
+<p>所有的XPCOM 组件- 无论是存储在shared libraries (<abbr title="Dynamic Link Library (Windows)">DLLs</abbr>, <abbr title="Dynamic Shared Object (Linux)">DSOs</abbr> 还是 <abbr title="Dynamically linked library (OS X)">dylibs</abbr>), JavaScript文件,或者其他文件 - 使用前需要被<em>注册. </em>使用XPCOM的Gecko clients, Mozilla, Netscape 7, Compuserve, 或者其他程序,都需要注册,才能获得合适的组件信息。</p>
+
+<p>The <strong>WebLock</strong> component must do a number of things to register itself. Specifically, the component library has to contain implementations for the component-related interfaces described in this chapter: <code>nsIModule</code> and <code>nsIFactory</code>, which are entry points for your implementation code.</p>
+
+<p>想要注册 WebLock 组件必须做许多事情. 特别是, 组件库需要包含本章介绍的组件定义的接口: <code>nsIModule</code> and <code>nsIFactory</code>, 这是你的代码入口.</p>
+
+<p>Once your component implements these interfaces, the rest of the registration process itself is simple. Applications typically use <code>regxpcom</code>, described in the next section.</p>
+
+<p>如果你的组件实现了这些接口,注册将变的很容易. 应用中通常使用<code>regxpcom</code>注册, 在下一节描述.</p>
+
+<h4 id="regxpcom_.E7.A8.8B.E5.BA.8F" name="regxpcom_.E7.A8.8B.E5.BA.8F"><code>regxpcom</code> 程序</h4>
+
+<p>一个明确的注册组件方法是运行<code>regxpcom</code>. 不带任何参数启动<code>regxpcom</code>时, 程序把组件注册在缺省的组件注册表. 我们建议你如果是运行应用, 你可以拷贝你的组件到对应程序安装目录下的<code>components</code>目录. 拷贝好以后,运行<code>regxpcom</code>将注册包含你的组件在内的所有那个目录中的组件.</p>
+
+<p><code>regxpcom</code>在1.4 或更高版本有一些新的参数. 参看 <code>regxpcom 加&lt;code&gt;-h</code> 选项。</p>
+
+<h4 id=".E5.8F.A6.E5.A4.96.E7.9A.84.E6.B3.A8.E5.86.8C.E6.96.B9.E6.B3.95" name=".E5.8F.A6.E5.A4.96.E7.9A.84.E6.B3.A8.E5.86.8C.E6.96.B9.E6.B3.95">另外的注册方法</h4>
+
+<p>Gecko embedding 应用可能提供其他注册组件的方法. XPInstall, 是一个跨平台的安装技术,Mozilla用来安装浏览器和其他组件,这是一个选择。参看<a href="/cn/Creating_XPCOM_Components/Packaging_WebLock" title="cn/Creating_XPCOM_Components/Packaging_WebLock">Packaging WebLock</a>. 你可以询问你想要扩展的应用的作者看是否有其他扩展方法.</p>
+
+<h3 id="WebLock_Module_.E6.BA.90.E4.BB.A3.E7.A0.81.E6.A6.82.E8.A7.88" name="WebLock_Module_.E6.BA.90.E4.BB.A3.E7.A0.81.E6.A6.82.E8.A7.88">WebLock Module 源代码概览</h3>
+
+<p>As we mentioned in the previous section, components have layers. There are three main parts to every XPCOM component. From the innermost and moving outward, the first object is the XPCOM object. This is the object that contains the business logic, that implements functionality such as starting a network download, implementing interfaces that listen to the download progress, or providing a new content type handler. In <strong>Weblock</strong>, this is the part that brings together various Gecko services and prevents users from leaving the list of acceptable domains. In a way, the factory and module layers are glue to plug the XPCOM object into the larger XPCOM system.</p>
+
+<p>在前面的章节我们提到,组件是分层的.每一个XPCOM组件都有三部分.从内到外, 第一个对象是XPCOM对象. 这个对象包含了交互逻辑, 负责载入network, 执行一个监听载入过程或新content type的接口。. 在<strong>Weblock</strong>中, 这部分综合了各种Gecko服务并且防止用户离开允许的一些domain. In a way, the factory and module layers are glue to plug the XPCOM object into the larger XPCOM system.</p>
+
+<p>One layer above the object itself is the <code>nsIFactory</code> object. This object provides basic abstraction of the XPCOM object itself. As you can see in <span class="lang lang-en"><a href="/en/Creating_XPCOM_Components/Creating_the_Component_Code#Onion_Peel_View_of_XPCOM_Component_Creation" title="en/Creating_XPCOM_Components/Creating_the_Component_Code#Onion_Peel_View_of_XPCOM_Component_Creation"><font color="#638fa2">Onion Peel View of XPCOM Component Creation</font></a> </span>, the main accessor for the XPCOM object is <code>CreateInstance</code>, which is expected to return the object that matches a given CID and IID pair.</p>
+
+<p>XPCOM的上层是 <code>nsIFactory</code> 对象. nsIFactory是对XPCOM的基本抽象. 如同你在 <a href="#Onion_Peel_View_of_XPCOM_Component_Creation">Onion Peel View of XPCOM Component Creation</a>中看到的, 通过CreateInstance与XPCOM对象进行交互, 返回一个匹配给定的CID 和IID 的两个对象.</p>
+
+<p>Moving another layer outward is the <code>nsIModule</code>. This interface provides yet another abstraction of the <code>nsIFactory</code> object, and may allow for multiple <code>nsIFactory</code> objects. The key to this interface is that the return type of <code>getClassObject</code> does not have to be an <code>nsIFactory</code>. Instead, the <code>nsIModule</code> can ask for implementation details about the XPCOM object. This is very useful if the caller is required to know information about the component like its threading module, whether or not it's a singleton, its implementation language, and so forth. The interface used in this case is <code>nsIClassInfo</code>. Starting from the outside in, <span class="lang lang-en"><a href="/en/Creating_XPCOM_Components/Creating_the_Component_Code#Onion_Peel_View_of_XPCOM_Component_Creation" title="en/Creating_XPCOM_Components/Creating_the_Component_Code#Onion_Peel_View_of_XPCOM_Component_Creation"><font color="#638fa2">Onion Peel View of XPCOM Component Creation</font></a> </span>represents the sequence for constructing an XPCOM object.</p>
+
+<p>最外层是<code>nsIModule对象</code>. 他提供了对<code>nsIFactory</code> 的进一步抽象, 而且可能允许多个<code>nsIFactory</code>对象. 关键点是这个接口的方法<code>getClassObject</code>返回的不一定非要是<code>nsIFactory</code>. <code>nsIModule</code> 也可以用来询问 XPCOM 对象的细节. This is very useful if the caller is required to know information about the component like its threading module, whether or not it's a singleton, its implementation language, and so forth. 这是可以使用接口<code>nsIClassInfo</code>. 从外到内, <a href="#Onion_Peel_View_of_XPCOM_Component_Creation">Onion Peel View of XPCOM Component Creation</a> 表示了建立XPCOM对象的顺序.</p>
+
+<p><span id="Onion_Peel_View_of_XPCOM_Component_Creation"><a id="Onion_Peel_View_of_XPCOM_Component_Creation"></a><strong>Onion Peel View of XPCOM Component Creation</strong></span></p>
+
+<p><img alt="Image:xpcom-is-an-onion.png" class="internal" src="/@api/deki/files/2732/=Xpcom-is-an-onion.png"></p>
+
+<p>Before we begin looking at the various parts of the component and how they'll be implemented in the source, let's look at the module in <code>weblock.cpp</code> as a whole to see where we're going. The source we're referring to is listed in its entirety at the end of this chapter (see <a href="/cn/Creating_XPCOM_Components/Creating_the_Component_Code#webLock1.cpp" title="cn/Creating_XPCOM_Components/Creating_the_Component_Code#webLock1.cpp">webLock1.cpp</a>).</p>
+
+<p><strong>WebLock</strong> 组件的源代码包含三个类. 为了让<strong>WebLock</strong>组件工作在 Mozilla中, 你要为<strong>WebLock</strong>组件建立一个接口, <code>iWebLock</code>, where the actual work specific to the the web locking features happens. 建立 <code>WebLockModule</code> 实现<code>nsIModule</code>接口, 你也要建立 <code>WebLockFactory</code>实现 <code>nsIFactory</code>来建立一个为你的客户处理组件实例的工厂. These three interface implementations - of the component functionality, of the <code>nsIModule</code> interface, and of the <code>nsIFactory</code> interface that creates and manages instances for clients - are the basic sets of code you need to write to create an XPCOM component.</p>
+
+<div class="side-note">
+<p><span id="Basic_Structure_of_the_WebLock_Component_Source"><a id="Basic_Structure_of_the_WebLock_Component_Source"></a><strong>Basic Structure of the WebLock Component Source</strong></span></p>
+
+<p>The <code>weblock1.cpp</code> source file that defines these classes and the code you need to create a basic component has the following structure:</p>
+
+<pre class="eval"> * required includes and constants
+ * <strong>WebLock</strong>: public <code>iWebLock</code>
+ * <strong>WebLockFactory</strong>: public <code>nsIFactory</code>
+ * <strong>WebLockModule</strong>: public <code>nsIModule</code>
+</pre>
+
+<p>在XPCOM中, 所有这些类要实现 <code>nsISupports</code>.</p>
+</div>
+
+<h3 id=".E6.9B.B4.E8.BF.9B.E4.B8.80.E6.AD.A5:_.E9.9C.80.E8.A6.81.E7.9A.84_Includes_and_Constants" name=".E6.9B.B4.E8.BF.9B.E4.B8.80.E6.AD.A5:_.E9.9C.80.E8.A6.81.E7.9A.84_Includes_and_Constants">更进一步: 需要的 Includes and Constants</h3>
+
+<p>Let's take a look at the first several lines of code in the component and discuss what they mean in XPCOM. The includes and definitions at the top of an XPCOM source file can give you an idea about some of the data types and techniques we'll be discussing more in the upcoming chapters.</p>
+
+<p>介绍一下XPCOM的component代码里面前几行的意思。</p>
+
+<p>例如,<code>MOZILLA_STRICT_API</code>是一个变量,它用来遮蔽某些私有的、非XPCOM的头文件。 For example, <code>MOZILLA_STRICT_API</code> is a variable that shields you from certain private, non-XPCOM headers. For example, including <a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/components/nsIComponentManager.idl" rel="custom">nsIComponentManager.idl</a> without <code>MOZILLA_STRICT_API</code> defined will include the following headers, which are not supported across versions (unfrozen):</p>
+
+<ul>
+ <li><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/nsComponentManagerUtils.h" rel="custom">nsComponentManagerUtils.h</a></li>
+ <li><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/components/nsComponentManagerObsolete.h" rel="custom">nsComponentManagerObsolete.h</a></li>
+</ul>
+
+<p>These variables are picked up by files that do not specify themselves as <code>MOZILLA_STRICT_API</code>.</p>
+
+<p><span id="Includes_and_Constants_in_%3Ccode%3Eweblock1.cpp%3C/code%3E"><a id="Includes_and_Constants_in_%3Ccode%3Eweblock1.cpp%3C/code%3E"></a><strong>Includes and Constants in <code>weblock1.cpp</code></strong></span></p>
+
+<pre>#include &lt;stdio.h&gt;
+
+// may be defined at the project level
+// in the makefile
+#define MOZILLA_STRICT_API
+
+#include "nsIModule.h"
+#include "nsIFactory.h"
+
+#include "nsIComponentManager.h"
+#include "nsIComponentRegistrar.h"
+
+// use classes to handle IIDs
+// classes provide methods for comparison: Equals, etc.
+static const nsIID kIModuleIID = NS_IMODULE_IID;
+static const nsIID kIFactoryIID = NS_IFACTORY_IID;
+static const nsIID kISupportsIID = NS_ISUPPORTS_IID;
+static const nsIID kIComponentRegistrarIID = NS_ICOMPONENTREGISTRAR_IID;
+
+
+// generate unique ID here with uuidgen
+#define SAMPLE_CID \
+{ 0x777f7150, 0x4a2b, 0x4301, \
+{ 0xad, 0x10, 0x5e, 0xab, 0x25, 0xb3, 0x22, 0xaa}}
+
+static const nsCID kSampleCID = SAMPLE_CID;
+</pre>
+
+<p><code>nsIModule.h</code> and <code>nsIFactory.h</code> are required to build your module successfully. They define the module and factory interfaces, and they contain a couple of important macros as well (see the following chapter for information about using these macros). The two other includes, <code>nsIComponentManager.h</code> and <code>nsIComponentRegistrar.h</code>, provide functions such as <code>RegisterFactoryLocation</code> that are required to implement the module and factory classes in your code.</p>
+
+<h4 id=".E6.A0.87.E8.AF.86.E7.AC.A6_in_XPCOM" name=".E6.A0.87.E8.AF.86.E7.AC.A6_in_XPCOM">标识符 in XPCOM</h4>
+
+<p>一组 <code>nsIID</code> 变量实际上是一些处理XPCOM用来支持客户和组件之间关系的128-bit标识符. The variable <code>kIFactoryIID</code>, for example, provides methods like <code>Equals()</code> that can be used to facilitate comparisons in the code, as in the following example from the Mozilla source:</p>
+
+<p><span id="Using_Class_Methods_to_Handle_Identifiers"><a id="Using_Class_Methods_to_Handle_Identifiers"></a><strong>Using Class Methods to Handle Identifiers</strong></span></p>
+
+<pre>if (aIID.Equals(NS_GET_IID(nsISupports)))
+{
+ *aInstancePtr = (void*)(nsISupports*)this;
+ NS_ADDREF_THIS();
+ return NS_OK;
+}
+</pre>
+
+<p>最后, <code>SAMPLE_CID</code> 是一个唯一标示组件的 CID . 所有的XPCOM中使用的128-bit数字 - 类和接口 IDs - 都是 UUIDs的例子, or <em>universal unique identifiers</em>, which were discussed in <a href="/cn/Creating_XPCOM_Components/What_is_XPCOM%3f#Object_Interface_Discovery" title="cn/Creating_XPCOM_Components/What_is_XPCOM?#Object_Interface_Discovery">Object Interface Discovery</a>.</p>
+
+<div class="side-note">
+<p>Generating CIDs</p>
+
+<p>为组件建立一个CID,你可以使用大多数Unix版本以及Miscrosoft Visual C++都包含的<code>uuidgen</code> 工具. <code>uuidgen</code> is a command-line tool that returns a unique 128-bit number when you call it with no arguments:</p>
+
+<pre>$ uuidgen
+ce32e3ff-36f8-425f-94be-d85b26e634ee
+</pre>
+
+<p>On Windows, a program called <code>guidgen.exe</code> does the same thing and also provides a graphical user interface if you'd rather point and click. Or you can use one of the special "bots" on IRC in <a class="link-irc" href="irc://irc.mozilla.org/mozilla">#developers</a>, where you can also get help from human beings.</p>
+
+<pre>irc irc.mozilla.org
+/join #developers
+/msg mozbot uuid
+</pre>
+
+<p>This command makes the bot generate and return a UUID, which you can then copy into your component source code.</p>
+</div>
+
+<p>Now that we've looked at the preliminaries, it's time to discuss the classes that this module provides and the way that they define the relationships of the component in XPCOM.</p>
+
+<h4 id="Coding_for_the_Registration_Process" name="Coding_for_the_Registration_Process">Coding for the Registration Process</h4>
+
+<p>当 XPCOM 第一次发现你的组件(via XPInstall or <code>regxpcom</code>, both of which are discussed in <a href="#Component_Installation_Overview">Component Installation Overview</a>), 第一件事是装载你的库并找到符号<code>NSGetModule</code>. 当这个专用的入口被调用, 它被传送XPCOM's Component Manager和组件存在的共享库位置.</p>
+
+<p>Component Manager是一个是XPCOM实现的用来包含建立对象和提供一些所有组件的综合信息的接口。磁盘的位置是通过另外一个接口 <code>nsIFile</code>传送的. This interface is XPCOM's abstraction of files and directories. An <code>nsIFile</code> object is usually a file or directory on a local volume, but it may represent something on a network volume as well.</p>
+
+<pre>nsresult NSGetModule(nsIComponentManager *servMgr,
+ nsIFile* location,
+ nsIModule** result);
+</pre>
+
+<p>XPCOM 需要成功调用 <code>NSGetModule</code>并返回接口<code>nsIModule</code>. 当你写一个 XPCOM 组件, 你实现了 <code>nsIModule</code> to do all of the necessary registration, unregistration, and object creation. <code>nsIModule</code> 有4个方法必须实现.<code>nsIModule</code> has four methods that must be implemented.</p>
+
+<h4 id="The_Registration_Methods" name="The_Registration_Methods">The Registration Methods</h4>
+
+<p>Two closely related registration methods are declared below.</p>
+
+<pre>NS_IMETHOD RegisterSelf(nsIComponentManager *aCompMgr,
+ nsIFile *aLocation,
+ const char *aLoaderStr,
+ const char *aType) = 0;
+
+NS_IMETHOD UnregisterSelf(nsIComponentManager *aCompMgr,
+ nsIFile *aLocation,
+ const char *aLoaderStr) = 0;
+</pre>
+
+<p><code>RegisterSelf</code> 在组件第一次被XPCOM注册的时候调用. 他只执行一次, which gives you a chance to add any one time setup functionality. The <code>RegisterSelf</code> 允许你的组件告诉XPCOM 你将支持什么功能. 注意所有你在 <code>RegisterSelf</code> 中做的都应该在 <code>UnregisterSelf</code>中撤销.</p>
+
+<p>首先, <code>NSGetModule</code>入口从你的库中被调用, 返回一个指向<code>nsIModule</code>的实现. 然后XPCOM调用<code>RegisterSelf</code>, passing parameters that we'll examine here.</p>
+
+<h5 id="The_RegisterSelf_Method" name="The_RegisterSelf_Method">The RegisterSelf Method</h5>
+
+<p>The first parameter is the <code>nsIComponentManager</code>, which provides a kind of entry point into managing the registration process. 你可以调用<code>QueryInterface</code> 来查找访问下面所述的其他组件管理接口.</p>
+
+<div class="side-note">
+<p><span id="The_Many_Faces_of_the_XPCOM_Component_Manager"><a id="The_Many_Faces_of_the_XPCOM_Component_Manager"></a><strong>The Many Faces of the XPCOM Component Manager</strong></span></p>
+
+<p>三个主要的组件管理接口, <code>nsIComponentManager</code>, <code>nsIServiceManager</code>, and <code>nsIComponentRegistrar</code>, are described below:</p>
+
+<ul>
+ <li><code>nsIComponentManager</code> - 建立组件并且返回组件实现细节。</li>
+ <li><code>nsIServiceManager</code> - 提供访问单根组件并且返回单根状态信息。</li>
+ <li><code>nsIComponentRegistrar</code> - 注册和注销工厂和组件;处理自动注册和发现已经注册的组件列表。</li>
+</ul>
+</div>
+
+<p>Your <code>RegisterSelf</code> method may call <code>QueryInterface</code> on the <code>nsIComponentManager</code> interface parameter to obtain the <code>nsIComponentRegistrar</code> or <code>nsIServiceManager</code>. <code>nsIServiceManager</code> can be used to obtain a singleton service, which can be useful if you have to register with a service other than the <code>nsIComponentRegistrar</code> if necessary. For example, you may want to get the service that is responsible for an event you want to be notified about. See <a href="/cn/Creating_XPCOM_Components/Starting_WebLock#Getting_Called_at_Startup" title="cn/Creating_XPCOM_Components/Starting_WebLock#Getting_Called_at_Startup">Getting Called at Startup</a> for an example of this.</p>
+
+<p>第二个参数<code>RegisterSelf</code>是正在注册组件的位置. This parameter is useful when the component needs to know where it has been installed or registered - as, for example, when other files must be stored or accessed relative to the component. This method is only called once, so you have to persist the location if you are going to use it later.</p>
+
+<p>The next two parameters are usually passed into the <code>nsIComponentRegistrar</code> methods and used by XPCOM to determine how to handle the component's registration. The <code>aLoaderStr</code> parameter, which is opaque and should not be modified, distinguishes components that are loaded from the same location specified by the <code>nsIFile</code> parameter. A single ZIP archive may store several XPCOM components, where every component in the archive has the same <code>nsIFile</code> parameter but the <code>aLoaderStr</code> parameter can be used to refer to the location within the ZIP archive.</p>
+
+<p>The last parameter specifies what kind of loader to use on the component. This is reserved as an optimization, for the most part, but it can be a useful way to extend XPCOM. Since XPCOM already knows internally what kind of file it has just loaded and called <code>RegisterSelf</code> on, passing this value to the registration methods is a shortcut for determining what kind of component is being registered.</p>
+
+<h5 id="nsIComponentRegistrar_Methods" name="nsIComponentRegistrar_Methods">nsIComponentRegistrar Methods</h5>
+
+<p>为了告诉XPCOM这个组件库实现了什么,调用方法:</p>
+
+<pre>NS_IMETHOD RegisterFactoryLocation(const nsCID &amp; aClass,
+ const char *aClassName,
+ const char *aContractID,
+ nsIFile *aFile,
+ const char *aLoaderStr,
+ const char *aType) = 0;
+</pre>
+
+<p>The last three parameters are the same as the three passed into the <code>RegisterSelf</code> method of <code>nsIModule</code> objects. All you have to do is forward these parameters from your <code>RegisterSelf</code> call into this method, leaving just the first three parameters.</p>
+
+<p>For any class that implements an XPCOM interface, the implementation must have a class identifier if it is to be shared with other parts of code via XPCOM. This identifier, called a CID, uniquely specifies the implementation. This CID can be created via the tool <code>uuidgen</code> on most operating systems, as in <a href="#The_Many_Faces_of_the_XPCOM_Component_Manager">The Many Faces of the XPCOM Component Manager</a> above. Given a CID and an IID, you can refer to any class in XPCOM. Consider the following:</p>
+
+<p><span id="Referencing_Objects_by_ID"><a id="Referencing_Objects_by_ID"></a><strong>Referencing Objects by ID</strong></span></p>
+
+<p><img alt="Image:referencing-objects-by-id.png" class="internal" src="/@api/deki/files/2676/=Referencing-objects-by-id.png"></p>
+
+<p>In this case, you have two implementations of the <code>nsISupports</code> interface. Each implementation has a separate CID. The interface also as an IID which is the same for both implementations. When specifying implementation A, the two required pieces of information are the CID of A and the IID of the interface that A supports. The code to register such an object is simple:</p>
+
+<pre>NS_IMETHODIMP
+SampleModule::RegisterSelf(nsIComponentManager *aCompMgr,
+ nsIFile* aPath,
+ const char* registryLocation,
+ const char* componentType)
+{
+ printf("Hello Mozilla Registration!\n\n");
+ nsIComponentRegistrar* compReg = nsnull;
+ nsresult rv =
+ aCompMgr-&gt;QueryInterface(kIComponentRegistrarIID,(void**)&amp; compReg);
+ if (NS_FAILED(rv))
+ return rv;
+ rv = compReg-&gt;RegisterFactoryLocation(kSampleCID,
+ "Sample Class",
+ nsnull,
+ aPath,
+ registryLocation,
+ componentType);
+ compReg-&gt;Release();
+ return rv;
+}
+</pre>
+
+<p>Unregistration follows the same logic. To unregister, all you have to do is pass the CID and the file which is passed into <code>UnregisterSelf</code>.</p>
+
+<h4 id=".E5.BB.BA.E7.AB.8B.E4.BD.A0.E7.9A.84.E7.BB.84.E4.BB.B6.E7.9A.84.E4.B8.80.E4.B8.AA.E5.AE.9E.E4.BE.8B" name=".E5.BB.BA.E7.AB.8B.E4.BD.A0.E7.9A.84.E7.BB.84.E4.BB.B6.E7.9A.84.E4.B8.80.E4.B8.AA.E5.AE.9E.E4.BE.8B">建立你的组件的一个实例</h4>
+
+<p>上面的例子用了 CID, 一旦注册以后,任何使用 XPCOM 的客户都可以访问你的组件,通过contract ID or CID. (Note that <code>RegisterSelf</code> method above does not register a contract ID - it simply passes null. This prevents clients from ever accessing the component with a contract ID.)</p>
+
+<p>为了让其他人访问, 你要公开组件包括它支持的接口的 CID 和/或者 contract ID. 上面的例子中,某人可能通过下面的方法建立一个 <strong>Sample</strong>对象 :</p>
+
+<pre>nsIComponentManager* compManager; // assume initialized
+
+nsISupports* sample;
+compManager-&gt;CreateInstance(kSampleCID,
+ nsnull,
+ kISupportsIID,
+ (void**)&amp;sample);
+</pre>
+
+<p>In the above snippet, we assume that the component manager has been initialized. In many cases this value is passed in or easily accessible. 如果还没有建立组件管理者,你总可以调用<code>NS_GetComponentManager()</code>来建立它. <a href="/cn/XPCOM_API_Reference" title="cn/XPCOM_API_Reference">XPCOM API Reference</a>中列出了一些全局的XPCOM方法.</p>
+
+<p>The first parameter of the call to <code>CreateInstance</code> specifies the component the client code is looking for, which is the same value passed to <code>RegisterFactoryLocation</code>. The next parameter is for aggregation, which the <strong>WebLock</strong> component does not support. The third parameter is the interface used to talk to the component. The last parameter is the out variable which will contain a valid object if and only if the method succeeds<sup><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Guide/Creating_components/Creating_the_Component_Code#endnote_non-null-out">[non-null-out]</a></sup>. The implementation of <code>CreateInstance</code> will ensure that the result will support the passed IID, <code>kISupportsIID</code>. The type of the variable <code>sample</code> should match the IID passed in as <code>kISupportsIID</code>.</p>
+
+<p>当 <code>CreateInstance</code> 被调用, XPCOM 查询所有的注册组件来匹配CID. XPCOM然后会装载对应的匹配 CID的组件,如果他还没有被装载的话. XPCOM 然后调用库的 <code>NSGetModule</code>. 最后它调用模块上的 <code>GetClassObject</code>. 这个方法是你来实现的,返回匹配 CID/IID 对的<code>nsIFactory</code>. To prepare your component code, you need to create a factory object for each object that you have registered with XPCOM.</p>
+
+<p>The main function that must be implemented in the <code>nsIFactory</code> interface is <code>CreateInstance</code>. The implementation follows a simple algorithm:</p>
+
+<ol>
+ <li>Create the raw object.</li>
+ <li>If that fails, return an out of memory error code.</li>
+ <li>Call <code>QueryInterface</code> on the new object.</li>
+ <li>If that fails, null the out param and free the new object.</li>
+ <li>Return the <code>nsresult</code> value from <code>QueryInterface</code>.</li>
+</ol>
+
+<p>Often, you don't have to create the object first because the factory implicitly knows what IIDs are supported. When this is not the case, however, doing it this way further abstracts the factories from their concrete classes. If you have a factory that knows every IID supported by the concrete base class, for example, then when you go to add a new supported interface you add this IID comparison in both the factory and the <code>QueryInterface</code> implementation in the concrete class.</p>
+
+<pre>NS_IMETHODIMP
+SampleFactory::CreateInstance(nsISupports *aOuter,
+ const nsIID &amp; iid,
+ void * *result)
+{
+ if (!result)
+ return NS_ERROR_INVALID_ARG;
+
+ Sample* sample = new Sample();
+ if (!sample)
+ return NS_ERROR_OUT_OF_MEMORY;
+
+ nsresult rv = sample-&gt;QueryInterface(iid, result);
+
+ if (NS_FAILED(rv)) {
+ *result = nsnull;
+ delete sample;
+ }
+
+ return rv;
+}
+</pre>
+
+<h3 id="webLock1.cpp" name="webLock1.cpp"><code>webLock1.cpp</code></h3>
+
+<p>Before any of the improvements and XPCOM tools we describe in the following chapter are brought in, the source code for the <strong>WebLock</strong> component that implements all the necessary interfaces looks like this.</p>
+
+<pre>#include &lt;stdio.h&gt;
+
+#define MOZILLA_STRICT_API
+
+#include "nsIModule.h"
+#include "nsIFactory.h"
+
+#include "nsIComponentManager.h"
+#include "nsIComponentRegistrar.h"
+
+static const nsIID kIModuleIID = NS_IMODULE_IID;
+static const nsIID kIFactoryIID = NS_IFACTORY_IID;
+static const nsIID kISupportsIID = NS_ISUPPORTS_IID;
+static const nsIID kIComponentRegistrarIID = NS_ICOMPONENTREGISTRAR_IID;
+
+
+#define SAMPLE_CID \
+{ 0x777f7150, 0x4a2b, 0x4301, \
+{ 0xad, 0x10, 0x5e, 0xab, 0x25, 0xb3, 0x22, 0xaa}}
+
+static const nsCID kSampleCID = SAMPLE_CID;
+
+class Sample: public nsISupports {
+ private:
+ nsrefcnt mRefCnt;
+ public:
+ Sample();
+ virtual ~Sample();
+
+ NS_IMETHOD QueryInterface(const nsIID &amp;aIID, void **aResult);
+ NS_IMETHOD_(nsrefcnt) AddRef(void);
+ NS_IMETHOD_(nsrefcnt) Release(void);
+
+};
+
+Sample::Sample()
+{
+ mRefCnt = 0;
+}
+
+Sample::~Sample()
+{
+}
+
+NS_IMETHODIMP
+Sample::QueryInterface(const nsIID &amp;aIID,
+ void **aResult)
+{
+ if (aResult == NULL) {
+ return NS_ERROR_NULL_POINTER;
+ }
+ *aResult = NULL;
+ if (aIID.Equals(kISupportsIID)) {
+ *aResult = (void *) this;
+ }
+ if (*aResult == NULL) {
+ return NS_ERROR_NO_INTERFACE;
+ }
+ AddRef();
+ return NS_OK;
+}
+
+NS_IMETHODIMP_(nsrefcnt) Sample::AddRef()
+{
+ return ++mRefCnt;
+}
+
+NS_IMETHODIMP_(nsrefcnt) Sample::Release()
+{
+ if (--mRefCnt == 0) {
+ delete this;
+ return 0;
+ }
+ return mRefCnt;
+}
+
+
+
+// factory implementation class for component
+class SampleFactory: public nsIFactory{
+ private:
+ nsrefcnt mRefCnt;
+ public:
+ SampleFactory();
+ virtual ~SampleFactory();
+
+ NS_IMETHOD QueryInterface(const nsIID &amp;aIID, void **aResult);
+ NS_IMETHOD_(nsrefcnt) AddRef(void);
+ NS_IMETHOD_(nsrefcnt) Release(void);
+
+ NS_IMETHOD CreateInstance(nsISupports *aOuter, const nsIID &amp; iid, void * *result);
+ NS_IMETHOD LockFactory(PRBool lock);
+
+};
+
+SampleFactory::SampleFactory()
+{
+ mRefCnt = 0;
+}
+SampleFactory::~SampleFactory()
+{
+}
+
+NS_IMETHODIMP
+SampleFactory::QueryInterface(const nsIID &amp;aIID,
+ void **aResult)
+{
+ if (aResult == NULL) {
+ return NS_ERROR_NULL_POINTER;
+ }
+ *aResult = NULL;
+ if (aIID.Equals(kISupportsIID)) {
+ *aResult = (void *) this;
+ }
+ else if (aIID.Equals(kIFactoryIID)) {
+ *aResult = (void *) this;
+ }
+
+ if (*aResult == NULL) {
+ return NS_ERROR_NO_INTERFACE;
+ }
+ AddRef();
+ return NS_OK;
+}
+
+NS_IMETHODIMP_(nsrefcnt) SampleFactory::AddRef()
+{
+ return ++mRefCnt;
+}
+
+NS_IMETHODIMP_(nsrefcnt) SampleFactory::Release()
+{
+ if (--mRefCnt == 0) {
+ delete this;
+ return 0;
+ }
+ return mRefCnt;
+}
+
+
+NS_IMETHODIMP
+SampleFactory::CreateInstance(nsISupports *aOuter,
+ const nsIID &amp; iid,
+ void * *result)
+{
+ if (!result)
+ return NS_ERROR_INVALID_ARG;
+
+ Sample* sample = new Sample();
+ if (!sample)
+ return NS_ERROR_OUT_OF_MEMORY;
+
+ nsresult rv = sample-&gt;QueryInterface(iid, result);
+
+ if (NS_FAILED(rv)) {
+ *result = nsnull;
+ delete sample;
+ }
+
+ return rv;
+}
+
+
+NS_IMETHODIMP
+SampleFactory::LockFactory(PRBool lock)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+
+
+
+
+
+// Module implementation
+class SampleModule : public nsIModule
+{
+ public:
+ SampleModule();
+ virtual ~SampleModule();
+
+ // nsISupports methods:
+ NS_IMETHOD QueryInterface(const nsIID &amp; uuid, void * *result);
+ NS_IMETHOD_(nsrefcnt) AddRef(void);
+ NS_IMETHOD_(nsrefcnt) Release(void);
+
+ // nsIModule methods:
+ NS_IMETHOD GetClassObject(nsIComponentManager *aCompMgr,
+ const nsCID &amp; aClass,
+ const nsIID &amp; aIID,
+ void * *aResult);
+ NS_IMETHOD RegisterSelf(nsIComponentManager *aCompMgr,
+ nsIFile *aLocation,
+ const char *aLoaderStr,
+ const char *aType);
+ NS_IMETHOD UnregisterSelf(nsIComponentManager *aCompMgr,
+ nsIFile *aLocation,
+ const char *aLoaderStr);
+ NS_IMETHOD CanUnload(nsIComponentManager *aCompMgr,
+ PRBool *_retval);
+
+ private:
+ nsrefcnt mRefCnt;
+};
+
+
+//----------------------------------------------------------------------
+
+SampleModule::SampleModule()
+{
+ mRefCnt = 0;
+}
+
+SampleModule::~SampleModule()
+{
+}
+
+
+// nsISupports implemention
+NS_IMETHODIMP_(nsrefcnt)
+SampleModule::AddRef(void)
+{
+ return ++mRefCnt;
+}
+
+
+NS_IMETHODIMP_(nsrefcnt)
+SampleModule::Release(void)
+{
+ if (--mRefCnt == 0) {
+ mRefCnt = 1; /* stabilize */
+ delete this;
+ return 0;
+ }
+ return mRefCnt;
+}
+
+NS_IMETHODIMP
+SampleModule::QueryInterface(REFNSIID aIID,
+ void** aInstancePtr)
+{
+ if (!aInstancePtr)
+ return NS_ERROR_NULL_POINTER;
+
+ nsISupports* foundInterface;
+
+ if (aIID.Equals(kIModuleIID)) {
+ foundInterface = (nsIModule*) this;
+ }
+ else if ( aIID.Equals(kISupportsIID) ) {
+ foundInterface = (nsISupports*) this;
+ }
+ else {
+ foundInterface = 0;
+ }
+
+ if (foundInterface) {
+ foundInterface-&gt;AddRef();
+ *aInstancePtr = foundInterface;
+ return NS_OK;
+ }
+
+ *aInstancePtr = foundInterface;
+ return NS_NOINTERFACE;
+}
+
+
+// Create a factory object for creating instances of aClass.
+NS_IMETHODIMP
+SampleModule::GetClassObject(nsIComponentManager *aCompMgr,
+ const nsCID&amp; aClass,
+ const nsIID&amp; aIID,
+ void** result)
+{
+
+ if (!kSampleCID.Equals(aClass))
+ return NS_ERROR_FACTORY_NOT_REGISTERED;
+
+ if (!result)
+ return NS_ERROR_INVALID_ARG;
+
+ SampleFactory* factory = new SampleFactory();
+ if (!factory)
+ return NS_ERROR_OUT_OF_MEMORY;
+
+ nsresult rv = factory-&gt;QueryInterface(aIID, result);
+
+ if (NS_FAILED(rv)) {
+ *result = nsnull;
+ delete factory;
+ }
+
+ return rv;
+}
+
+
+//----------------------------------------
+
+
+NS_IMETHODIMP
+SampleModule::RegisterSelf(nsIComponentManager *aCompMgr,
+ nsIFile* aPath,
+ const char* registryLocation,
+ const char* componentType)
+{
+
+ nsIComponentRegistrar* compReg = nsnull;
+
+ nsresult rv =
+ aCompMgr-&gt;QueryInterface(kIComponentRegistrarIID, (void**)&amp;compReg);
+ if (NS_FAILED(rv))
+ return rv;
+
+ rv = compReg-&gt;RegisterFactoryLocation(kSampleCID,
+ "Sample Class",
+ nsnull,
+ aPath,
+ registryLocation,
+ componentType);
+
+ compReg-&gt;Release();
+
+ return rv;
+}
+
+NS_IMETHODIMP
+SampleModule::UnregisterSelf(nsIComponentManager* aCompMgr,
+ nsIFile* aPath,
+ const char* registryLocation)
+{
+
+ nsIComponentRegistrar* compReg = nsnull;
+
+ nsresult rv = aCompMgr-&gt;QueryInterface(kIComponentRegistrarIID, (void**)&amp;compReg);
+ if (NS_FAILED(rv))
+ return rv;
+
+ rv = compReg-&gt;UnregisterFactoryLocation(kSampleCID, aPath);
+
+ compReg-&gt;Release();
+
+ return rv;
+}
+
+NS_IMETHODIMP
+SampleModule::CanUnload(nsIComponentManager *aCompMgr, PRBool *okToUnload)
+{
+ *okToUnload = PR_FALSE; // we do not know how to unload.
+ return NS_OK;
+}
+
+//----------------------------------------------------------------------
+
+extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager *servMgr,
+ nsIFile* location,
+ nsIModule** return_cobj)
+{
+ nsresult rv = NS_OK;
+
+ // Create and initialize the module instance
+ SampleModule *m = new SampleModule();
+ if (!m) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+
+ // Increase refcnt and store away nsIModule interface to m in return_cobj
+ rv = m-&gt;QueryInterface(kIModuleIID, (void**)return_cobj);
+ if (NS_FAILED(rv)) {
+ delete m;
+ }
+ return rv;
+}
+</pre>
+
+<ol>
+ <li><div class="blockIndicator note"><strong>Note:</strong> non-null-out</div> The <code>CreateInstance</code> method guarantees that if the out variable is non-null, it is valid.</li>
+</ol>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Creating_XPCOM_Components:Component_Internals" style="float: left;">« 上一页</a><a href="/zh-CN/docs/Creating_XPCOM_Components:Using_XPCOM_Utilities_to_Make_Things_Easier">下一页 »</a></p>
+</div> <p></p><div class="licenseblock">
+<p>Copyright (c) 2003 by Doug Turner and Ian Oeschger. This material may be distributed only subject to the terms and conditions set forth in the <a class="external" href="http://www.opencontent.org/openpub/" rel="noopener">Open Publication License</a>, v1.02 or later. Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.</p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/finishing_the_component/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/finishing_the_component/index.html
new file mode 100644
index 0000000000..3be93d89f5
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/finishing_the_component/index.html
@@ -0,0 +1,337 @@
+---
+title: Finishing the Component
+slug: Mozilla/Tech/XPCOM/Guide/Creating_components/Finishing_the_Component
+tags:
+ - XPCOM
+ - 所有分类
+translation_of: Mozilla/Tech/XPCOM/Guide/Creating_components/Finishing_the_Component
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Creating_XPCOM_Components:Starting_WebLock" style="float: left;">« 上一页</a><a href="/zh-CN/docs/Creating_XPCOM_Components:Building_the_WebLock_UI">下一页 »</a></p>
+</div><p></p>
+
+<p>At this point you have created most of the infrastructure of the component. The component will be recognized by XPCOM and registered with the Category Manager so that it starts up when XPCOM initializes. When the component starts up, it populates a list of URLs read in from a file stored next to the Gecko binary on the local system.</p>
+
+<h3 id="Using_Frozen_Interfaces" name="Using_Frozen_Interfaces">Using Frozen Interfaces</h3>
+
+<p>The core functionality of blocking sites is still missing, however. The interfaces needed to block certain URLs from loading are not frozen, and there is still some debate about how exactly this functionality should be exposed to embedders and component developers, so the APIs are not ready to be published. This puts you in the same situation as many developers using Mozilla - you want to use some specific functionality, but the interfaces seem to change on a daily basis.</p>
+
+<p>All of the Mozilla source code is publicly available, and interfaces can be used easily enough. Grab the right headers, use the Component or Service Manager to access the interface you want, and the XPCOM object(s) that implement that interface will do your bidding. With this huge amount of flexibility, however, you lose compatibility. If you use "stuff" that isn't frozen, that stuff is subject to change in future versions of Gecko.</p>
+
+<p>If you want to be protected against changes in Gecko, you must only use interfaces and APIs that are clearly marked as FROZEN. The marking is made in the comments above the interface declaration. For example, take a look at the <code>nsIServiceManager</code>:</p>
+
+<pre>/**
+ * The nsIServiceManager manager interface provides a means to obtain
+ * global services in an application. The service manager depends
+ * on the repository to find and instantiate factories to obtain
+ * services.
+ *
+ * Users of the service manager must first obtain a pointer to the
+ * global service manager by calling NS_GetServiceManager. After that,
+ * they can request specific services by calling GetService.
+ * When they are finished they can NS_RELEASE() the service as usual.
+ *
+ * A user of a service may keep references to particular services
+ * indefinitely and only must call Release when it shuts down.
+ *
+ * @status FROZEN
+ */
+</pre>
+
+<p>These frozen interfaces and functions are part of the Gecko SDK. The rule of thumb is that interfaces outside of the SDK are considered "experimental" or unfrozen. See the following sidebar for information about how frozen and unfrozen interfaces can affect your component development, and for technical details about how interface changes beneath your code can cause havoc.</p>
+
+<div class="side-note">
+<p><span id="The_Danger_of_Using_Unfrozen_Interfaces"><a id="The_Danger_of_Using_Unfrozen_Interfaces"></a><strong>The Danger of Using Unfrozen Interfaces</strong></span></p>
+
+<p>Suppose that you need to use the interface <code>nsIFoo</code> that isn't frozen. You build your component using this interface, and it works great with the version of Gecko that you have tested against. However, some point in the future, the <code>nsIFoo</code> interface requires a major change, and methods are reordered, some are added, others are removed. Moreover, since this interface was never supposed to be used by clients other than Gecko or Mozilla, the maintainers of the interface don't know that it's being used, and don't change the IID of the interface. When your component runs in a version of Gecko in which this interface is updated, your method calls will be routed through a different v-table than the one the component expected, most likely resulting in a crash.</p>
+
+<p>Below, the component is compiled against a version of the <code>nsIFoo</code> interface that has three methods. The component calls the method <code>TestA</code> and passes an integer, 10. This works fine in any Gecko installation where a contract guarantees that the interface that was compiled against has the same signature. However, when this same component is used in a Gecko installation where this interface has changed, the method <code>TestA</code> does not exist in the <code>nsIFoo</code> interface; the first entry in the v-table is in fact <code>IsPrime()</code>. When this method call is made, the code execution treats the <code>IsPrime</code> method as <code>TestA</code>. Needless to say, this is a bad thing. Furthermore, there is no way easy way to realize this error at runtime.</p>
+
+<p><img alt="Image:vtable-of-altered-interface.png"></p>
+
+<p>Gecko developers could change the interface's IID, and some do. This can prevent many errors like this. But unfrozen interfaces are not supported in any formal way, and relying upon a different IID for any change in the interface is not a good idea either.</p>
+
+<p>When using frozen interfaces, you are guaranteed compatibility with future versions of Gecko. The only trouble occurs when the compiler itself changes its v-table layout, which can happen when the compiler changes its ABI. For example, in 2002 the GNU Compiler Collection (GCC), version 3.2 changed the C++ ABI, and this caused problems between libraries compiled with GCC 3.2 and applications compiled with an earlier version and vice versa. Similar problems occurred with GCC 4.0, which underwent similar ABI changes.</p>
+</div>
+
+<p>Before attempting to use unfrozen interfaces, you should contact the developers who are responsible for the code you're trying to use (i.e.,<em><a class="external" href="http://www.mozilla.org/owners.html">module owners</a></em> ) and ask them how best to do what you are trying to do. Be as precise you possibly can. They may be able to suggest a supported alternative, or they may be able to notify you about pending changes.</p>
+
+<p>The interface that we need for this project is something called <code>nsIContentPolicy</code>. At the time this book was written, this interface was under review. An interface reaches this state when a group of module owners and peers are actively engaged in discussion about how best to expose it. Usually there are only minor changes to interfaces marked with such a tag. Even with interfaces marked "under review," however, it's still a good idea to contact the module owners responsible for the interfaces you are interested in using.</p>
+
+<h4 id="Copying_Interfaces_into_Your_Build_Environment" name="Copying_Interfaces_into_Your_Build_Environment">Copying Interfaces into Your Build Environment</h4>
+
+<p>To get and implement interfaces that are not part of Gecko in your component, simply create a new directory in the Gecko SDK named <code>unfrozen</code>. Copy the headers and IDL files that you need from the <code><a href="https://dxr.mozilla.org/mozilla-central/source/content/base/public" rel="custom">content/base/public</a></code> source directory of the Gecko build into this new directory. (For <strong>WebLock</strong>, all you need are the headers for <code>nsIContentPolicy</code> and the <code>nsIContentPolicy.idl</code>.) Then, using the same steps you used to create the <code>Weblock.h</code>, create a header from this IDL file using the xpidl compiler. Once you have these interface and header files, you can modify the <code>WebLock</code> class to implement the <code>nsIContentPolicy</code> interface. The Weblock class will then support four interfaces: <code>nsISupports</code>, <code>nsIObserver</code>, <code>nsIContentPolicy</code>, and <code>iWeblock</code>.</p>
+
+<p><img alt="Image:weblock-implemented-ifaces.png"></p>
+
+<p><span id="%3Ccode%3EWebLock%3C/code%3E_Interfaces"><a id="%3Ccode%3EWebLock%3C/code%3E_Interfaces"></a><strong><code>WebLock</code> Interfaces</strong></span></p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Interface Name</td>
+ <td class="header">Defined by</td>
+ <td class="header">Status</td>
+ <td class="header">Summary</td>
+ </tr>
+ <tr>
+ <td><code>nsISupports</code></td>
+ <td>XPCOM</td>
+ <td>Frozen</td>
+ <td>Provides interface discovery, and object reference counting</td>
+ </tr>
+ <tr>
+ <td><code>nsIObserver</code></td>
+ <td>XPCOM</td>
+ <td>Frozen</td>
+ <td>Allows messaging passing between objects</td>
+ </tr>
+ <tr>
+ <td><code>nsIContentPolicy</code></td>
+ <td>Content</td>
+ <td>Not Frozen</td>
+ <td>Interface for policy control mechanism</td>
+ </tr>
+ <tr>
+ <td><code>iWeblock</code></td>
+ <td>Web Lock</td>
+ <td>Not Frozen</td>
+ <td>Enables and disables Weblock. Also, provides access to the URL that are whitelisted.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h4 id="Implementing_the_nsIContentPolicy_Interface" name="Implementing_the_nsIContentPolicy_Interface">Implementing the <code>nsIContentPolicy</code> Interface</h4>
+
+<p>To implement the new interface, you must <code>#include</code> the unfrozen <code><a class="internal" href="/en/nsIContentPolicy" title="en/nsIContentPolicy">nsIContentPolicy</a></code>, and you must also make sure the build system can find the file you've brought over. The location of the file and the steps for adding that location to the build system vary depending on how you build this component.</p>
+
+<p>Once you have made sure that your component builds with the new header file, you must derive the <code>Weblock</code> class from the interface <code>nsIContentPolicy</code>, which you can do by simply adding a public declaration when defining the class. At the same time, you can add the macro <code>NS_DECL_NSICONTENTPOLICY</code> to the class declaration that provides all of the methods defined in the interface nsIContentPolicy. The updated <code>WebLock</code> class looks as follows:</p>
+
+<pre>class WebLock: public nsIObserver, public iWeblock, public nsIContentPolicy
+{
+ public:
+ WebLock();
+ virtual ~WebLock();
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIOBSERVER
+ NS_DECL_IWEBLOCK
+ NS_DECL_NSICONTENTPOLICY
+
+ private:
+ urlNode* mRootURLNode;
+ PRBool mLocked;
+};
+</pre>
+
+<p>Remember to change the <code>nsISupports</code> implementation macro to include <code>nsIContentPolicy</code> so that other parts of Gecko will know <strong>WebLock</strong> supports the <code>nsIContentPolicy</code> interface without modifying this macro.</p>
+
+<pre>NS_IMPL_ISUPPORTS3(WebLock, nsIObserver, iWeblock, nsIContentPolicy);
+</pre>
+
+<h4 id="Receiving_Notifications" name="Receiving_Notifications">Receiving Notifications</h4>
+
+<p>To receive notifications, you must register as a new category. You have already registered as a category to receive startup notification. This time, the category name to use is "content-policy". To add the <strong>WebLock</strong> component to this category, modify the <code>WebLockRegistration</code> callback function so that it looks like this:</p>
+
+<pre>static NS_METHOD WebLockRegistration(nsIComponentManager *aCompMgr,
+ nsIFile *aPath,
+ const char *registryLocation,
+ const char *componentType,
+ const nsModuleComponentInfo *info)
+{
+ nsresult rv;
+ nsCOMPtr&lt;nsIServiceManager&gt; servman = do_QueryInterface((nsISupports*)aCompMgr, &amp;rv);
+ if (NS_FAILED(rv))
+ return rv;
+
+ nsCOMPtr&lt;nsICategoryManager&gt; catman;
+ servman-&gt;GetServiceByContractID(NS_CATEGORYMANAGER_CONTRACTID,
+ NS_GET_IID(nsICategoryManager),
+ getter_AddRefs(catman));
+ if (NS_FAILED(rv))
+ return rv;
+
+ char* previous = nsnull;
+ rv = catman-&gt;AddCategoryEntry("xpcom-startup",
+ "WebLock",
+ WebLock_ContractID,
+ PR_TRUE,
+ PR_TRUE,
+ &amp;previous);
+ if (previous)
+ nsMemory::Free(previous);
+
+ rv = catman-&gt;AddCategoryEntry("content-policy",
+ "WebLock",
+ WebLock_ContractID,
+ PR_TRUE,
+ PR_TRUE,
+ &amp;previous);
+ if (previous)
+ nsMemory::Free(previous);
+ return rv;
+}
+</pre>
+
+<p>This code adds a new category entry under the topic "content-policy," and it calls <code>AddCategoryEntry</code> in the same way we did in <a href="cn/Creating_XPCOM_Components/Starting_WebLock#Registering_for_Notifications">Registering for Notifications</a>. A similar step is required for unregistration.</p>
+
+<h3 id="Implementing_the_nsIContentPolicy" name="Implementing_the_nsIContentPolicy">Implementing the <code>nsIContentPolicy</code></h3>
+
+<p>At this point, you can take the <strong>WebLock</strong> component and install it into a Gecko installation. When the component is loaded, Gecko calls the <code>nsIContentPolicy</code> implementation in <strong>WebLock</strong> on every page load, and this prevents pages from displaying by returning the proper value when the load method is called.</p>
+
+<p>The web locking policy that we are going to put into place is quite simple: for every load request that comes through, we will ensure that the URI is in the list of "good" URLs on the white list.</p>
+
+<div class="side-note">
+<p>If you care to extend this implementation so that the list of URLs is held remotely on a server somewhere - as might be the case when the <strong>WebLock</strong> component is used in a corporate intranet, for example - there are Networking APIs in Gecko that will support this. Or you could implement the web lock so that instead of blocking any site, the component would simply log all URLs that are loaded. In any case, the process to make the XPCOM component is the same.</p>
+</div>
+
+<p>The method that handles the check before page loading and the only method we care about in our own implementation of <code>nsIContentPolicy</code> is <code>ShouldLoad()</code>. The other method on the <code>nsIContentPolicy</code> interface is for blocking processing of specific elements in a document, but our policy is more restrictive: if the URL isn't on the white list, the entire page should be blocked. In the <strong>WebLock</strong> component, the <code>ShouldLoad</code> method looks like this:</p>
+
+<pre>NS_IMETHODIMP WebLock::ShouldLoad(PRInt32 contentType,
+ nsIURI *contentLocation,
+ nsISupports *ctxt,
+ nsIDOMWindow *window,
+ PRBool *_retval)
+</pre>
+
+<h4 id="Uniform_Resource_Locators" name="Uniform_Resource_Locators">Uniform Resource Locators</h4>
+
+<p>The method passes in an interface pointer of type <code>nsIURI</code>, which is based on the Uniform Resource Identifier, or URI. This type is defined by the <a class="external" href="http://www.w3.org/">World Wide Web Consortium</a> as:</p>
+
+<ul>
+ <li>The naming scheme of the mechanism used to access the resource.</li>
+ <li>The name of the machine hosting the resource.</li>
+ <li>The name of the resource itself, given as a path.</li>
+</ul>
+
+<p>In this context, URIs are the strings used refer to places or things on the web. This specific form of URI is called a Uniform Resource Locator, or URL. See the <a class="external" href="http://www.w3.org/TR/REC-html40/intro/intro.html">intro to the HTML 4 specification</a> for more information about URIs and URLs.</p>
+
+<p>Gecko encapsulates these identifiers into two interfaces, <code>nsIURI</code> and <code>nsIURL</code>. You can <code>QueryInterface</code> between these two interfaces. The networking library, Necko, deals only with these interfaces when handling requests. When you want to download a file using Necko, for example, all you probably have is a string that represents the URI of the file. When you pass that string to Necko, it creates an object that implements at least the <code>nsIURI</code> interface (and perhaps other interfaces as well).</p>
+
+<p>Currently, the <strong>WebLock</strong> implementation of the <code>ShouldLoad</code> method compares the in parameter with each string in the white list. But it only should do this comparison for remote URLs, because we don't want to block the application from loading local content that it requires, like files it gets via the <code><a class="external" rel="freelink">resource://</a></code> protocol. If URIs of this kind are blocked, then Gecko will not be able to start up, so we'll restrict the content policy to the HTTP and FTP protocols.</p>
+
+<p>Instead of extracting the string <code>spec</code> out of the <code>nsIURI</code> to do a string comparison, which would require you to do the parsing yourself, you can compare the <code>nsIURI</code> objects with each other, as in the following section. This ensures that the URLs are canonical before they are compared.</p>
+
+<h4 id="Checking_the_White_List" name="Checking_the_White_List">Checking the White List</h4>
+
+<p>The <strong>WebLock</strong> implementation of the <code>ShouldLoad</code> method starts by extracting the scheme of the incoming <code>nsIURI</code>. If the scheme isn't "http", "https", or "ftp", it immediately returns true, which continues the loading process unblocked.</p>
+
+<p>These three are the only kinds of URI that <strong>Weblock</strong> will try to block. When it has one, it walks the linked list and creates a new <code>nsIURI</code> object for each string URL in the list. From each object, <code>ShouldLoad()</code> extracts the host and compares it to the URI. If they match, the component allows the load to continue by returning true. If these two strings do not match, then the component returns return false and blocks the load.</p>
+
+<div class="side-note">
+<p><span id="URI_Caching"><a id="URI_Caching"></a><strong>URI Caching</strong></span></p>
+
+<p>Caching the URI would make this method implementation much faster by avoiding the need to create and destroy so many objects. This points out an important drawback of XPCOM, which is that you cannot create an object on the stack.</p>
+
+<p>Creating this many objects is OK in a tight loop if the buffer of memory that holds the contents of the URLs is guaranteed to be valid for the lifetime of the object. But regardless of how optimized the implementation is with respect to is memory usage, a heap allocation will be made for every XPCOM object created.</p>
+</div>
+
+<p>The string comparison with the URL type "http", "https", and "ftp" looks like this:</p>
+
+<pre>nsEmbedCString scheme;
+contentLocation-&gt;GetScheme(scheme);
+
+if (strcmp("http", scheme.get())  != 0 &amp;&amp;
+ strcmp("https", scheme.get()) != 0 &amp;&amp;
+ strcmp("ftp", scheme.get())  != 0)
+{
+ // this isn't a type of URI that we deal with.
+ *_retval = PR_TRUE;
+ return NS_OK;
+}
+</pre>
+
+<h4 id="Creating_nsIURI_Objects" name="Creating_nsIURI_Objects">Creating <code>nsIURI</code> Objects</h4>
+
+<p>To create an <code>nsIURI</code>, use <code>nsIIOService</code>. <code>nsIIOService</code> is the part of the networking library ("necko") that's responsible for kicking off network requests, managing protocols such as http, ftp, or file, and creating <code>nsIURI</code>s. Necko offers tremendous network functionality, but all the <strong>WebLock</strong> component needs is to create the <code>nsIURI</code> object that can be compared with the URIs on the white list.</p>
+
+<p>Use the Service Manager to acquire the <code>nsIIOService</code>. Since this object is going to be used for the life of the component, it can also be cached. A good place to get an <code>nsIIOService</code> is in the component's <code>Observe()</code> method, which already has a pointer to the <code>Service Manager</code>. The code for getting the IO service from the Service Manager looks like this:</p>
+
+<pre>// Get a pointer to the IOService
+rv = servMan-&gt;GetServiceByContractID("@mozilla.org/network/io-service;1",
+ NS_GET_IID(nsIIOService),
+ getter_AddRefs(mIOService));
+</pre>
+
+<p>Once you have this interface pointer, you can easily create <code>nsIURI</code> objects from a string, as in the following snippet:</p>
+
+<pre>nsCOMPtr&lt;nsIURI&gt; uri;
+nsEmbedCString urlString(node-&gt;urlString);
+mIOService-&gt;NewURI(urlString,
+ nsnull,
+ nsnull,
+ getter_AddRefs(uri));
+</pre>
+
+<p>This code wraps a C-string with a <code>nsEmbedCString</code>, which you'll recall is a string class that many of the Gecko APIs require. See <a href="cn/Creating_XPCOM_Components/Using_XPCOM_Utilities_to_Make_Things_Easier#String_Classes_in_XPCOM">String Classes in XPCOM</a> for more information about strings.</p>
+
+<p>Once the URL string is wrapped in a <code>nsEmbedCString</code>, it can be passed to the method <code>NewURI</code>. This method expects to parse the incoming string and create an object which implements an <code>nsIURI</code> interface. The two <code>nsnull</code> parameters passed to <code>NewURI</code> are used to specify the charset of the string and any base URI to use, respectively. We are assuming here that the charset of the URL string is <a href="cn/UTF-8">UTF-8</a>, and also assuming that every URL string is absolute. See the <a class="external" href="http://www.w3.org/TR/REC-html40/intro/intro.html">intro to the HTML 4 specification</a> for more information about relative URLs.</p>
+
+<p>Here is the complete implementation of the <code>ShouldLoad()</code> method:</p>
+
+<pre>NS_IMETHODIMP
+WebLock::ShouldLoad(PRInt32 contentType,
+ nsIURI *contentLocation,
+ nsISupports *ctxt,
+ nsIDOMWindow *window,
+ PRBool *_retval)
+{
+ if (!contentLocation)
+ return NS_ERROR_FAILURE;
+
+
+ nsEmbedCString scheme;
+ contentLocation-&gt;GetScheme(scheme);
+
+ if (strcmp("http", scheme.get())  != 0 &amp;&amp;
+ strcmp("https", scheme.get()) != 0 &amp;&amp;
+ strcmp("ftp", scheme.get())  != 0)
+ {
+ // this isn't a type of URI that we deal with
+ *_retval = PR_TRUE;
+ return NS_OK;
+ }
+
+ nsEmbedCString hostToLoad;
+ contentLocation-&gt;GetHost(hostToLoad);
+
+ // Assume failure. Do not allow this nsIURI to load.
+ *_retval = PR_FALSE;
+
+ nsresult rv;
+
+ urlNode* node = mRootURLNode;
+ PRBool match = PR_FALSE;
+
+ while (node)
+ {
+ nsCOMPtr&lt;nsIURI&gt; uri;
+ nsEmbedCString urlString(node-&gt;urlString);
+ rv = mIOService-&gt;NewURI(urlString, nsnull, nsnull, getter_AddRefs(uri));
+
+ // if anything bad happens, just abort
+ if (NS_FAILED(rv))
+ return rv;
+
+ nsEmbedCString host;
+ uri-&gt;GetHost(host);
+
+ if (strcmp(hostToLoad.get(), host.get()) == 0)
+ {
+ // match found. Allow this nsIURI to load
+ *_retval = PR_TRUE;
+ return NS_OK;
+ }
+ node = node-&gt;next;
+ }
+ return NS_OK;
+}
+</pre>
+
+<p>At this point, all of the backend work is complete. You can of course improve this backend in many ways, but this example presents the basic creation of what is commonly referred to as a "browser helper object" like <strong>WebLock</strong>. The next chapter looks at how to tie this into the front end - specifically, how to use XPConnect to access and control this component from JavaScript in the user interface.</p>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Creating_XPCOM_Components:Starting_WebLock" style="float: left;">« 上一页</a><a href="/zh-CN/docs/Creating_XPCOM_Components:Building_the_WebLock_UI">下一页 »</a></p>
+</div> <p></p><div class="licenseblock">
+<p>Copyright (c) 2003 by Doug Turner and Ian Oeschger. This material may be distributed only subject to the terms and conditions set forth in the <a class="external" href="http://www.opencontent.org/openpub/" rel="noopener">Open Publication License</a>, v1.02 or later. Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.</p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/index.html
new file mode 100644
index 0000000000..13fd6aff60
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/index.html
@@ -0,0 +1,278 @@
+---
+title: 创建_XPCOM_组件
+slug: Mozilla/Tech/XPCOM/Guide/Creating_components
+tags:
+ - XPCOM
+ - 'XPCOM:索引'
+ - 所有分类
+translation_of: Mozilla/Tech/XPCOM/Guide/Creating_components
+---
+<p> </p>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/创建_XPCOM_组件:前言">下一页 »</a></p>
+</div><p></p>
+
+<h3 id=".E5.89.8D.E8.A8.80" name=".E5.89.8D.E8.A8.80"><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%89%8D%E8%A8%80" title="cn/创建_XPCOM_组件/前言">前言</a></h3>
+
+<dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%89%8D%E8%A8%80#.E8.B0.81.E8.AF.A5.E8.AF.BB.E8.BF.99.E6.9C.AC.E4.B9.A6" title="cn/创建_XPCOM_组件/前言#.E8.B0.81.E8.AF.A5.E8.AF.BB.E8.BF.99.E6.9C.AC.E4.B9.A6">谁该读这本书</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%89%8D%E8%A8%80#.E6.9C.AC.E6.95.99.E7.A8.8B.E7.9A.84.E7.BB.84.E7.BB.87" title="cn/创建_XPCOM_组件/前言#.E6.9C.AC.E6.95.99.E7.A8.8B.E7.9A.84.E7.BB.84.E7.BB.87">本教程的组织</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%89%8D%E8%A8%80#.E6.8C.89.E7.85.A7.E4.BE.8B.E5.AD.90.E6.9D.A5.E5.AD.A6.E4.B9.A0" title="cn/创建_XPCOM_组件/前言#.E6.8C.89.E7.85.A7.E4.BE.8B.E5.AD.90.E6.9D.A5.E5.AD.A6.E4.B9.A0">按照例子来学习</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%89%8D%E8%A8%80#.E6.9C.AC.E4.B9.A6.E7.9A.84.E4.BD.93.E4.BE.8B" title="cn/创建_XPCOM_组件/前言#.E6.9C.AC.E4.B9.A6.E7.9A.84.E4.BD.93.E4.BE.8B">本书的体例</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%89%8D%E8%A8%80#.E8.87.B4.E8.B0.A2" title="cn/创建_XPCOM_组件/前言#.E8.87.B4.E8.B0.A2">致谢</a></dd>
+</dl>
+
+<h3 id="XPCOM_.E7.AE.80.E4.BB.8B" name="XPCOM_.E7.AE.80.E4.BB.8B"><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B" title="cn/创建_XPCOM_组件/XPCOM_简介">XPCOM 简介</a></h3>
+
+<dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#XPCOM_.E8.A7.A3.E5.86.B3.E6.96.B9.E6.A1.88" title="cn/创建_XPCOM_组件/XPCOM_简介#XPCOM_.E8.A7.A3.E5.86.B3.E6.96.B9.E6.A1.88">XPCOM 解决方案</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#Gecko" title="cn/创建_XPCOM_组件/XPCOM_简介#Gecko">Gecko</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#.E7.BB.84.E4.BB.B6" title="cn/创建_XPCOM_组件/XPCOM_简介#.E7.BB.84.E4.BB.B6">组件</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#.E6.8E.A5.E5.8F.A3" title="cn/创建_XPCOM_组件/XPCOM_简介#.E6.8E.A5.E5.8F.A3">接口</a>
+ <dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#.E6.8E.A5.E5.8F.A3.E4.B8.8E.E5.B0.81.E8.A3.85" title="cn/创建_XPCOM_组件/XPCOM_简介#.E6.8E.A5.E5.8F.A3.E4.B8.8E.E5.B0.81.E8.A3.85">接口与封装</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#nsISupports_.E5.9F.BA.E6.8E.A5.E5.8F.A3" title="cn/创建_XPCOM_组件/XPCOM_简介#nsISupports_.E5.9F.BA.E6.8E.A5.E5.8F.A3"><code>nsISupports</code> 基接口</a></dd>
+ </dl>
+ </dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#XPCOM_.E7.9A.84ID" title="cn/创建_XPCOM_组件/XPCOM_简介#XPCOM_.E7.9A.84ID">XPCOM 的ID</a>
+ <dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#CID" title="cn/创建_XPCOM_组件/XPCOM_简介#CID">CID</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#.E5.A5.91.E7.BA.A6_ID" title="cn/创建_XPCOM_组件/XPCOM_简介#.E5.A5.91.E7.BA.A6_ID">契约 ID</a></dd>
+ </dl>
+ </dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#.E7.B1.BB.E5.8E.82" title="cn/创建_XPCOM_组件/XPCOM_简介#.E7.B1.BB.E5.8E.82">类厂</a>
+ <dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#XPIDL_.E4.B8.8E.E7.B1.BB.E5.9E.8B.E5.BA.93" title="cn/创建_XPCOM_组件/XPCOM_简介#XPIDL_.E4.B8.8E.E7.B1.BB.E5.9E.8B.E5.BA.93">XPIDL 与类型库</a></dd>
+ </dl>
+ </dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#XPCOM_.E6.9C.8D.E5.8A.A1" title="cn/创建_XPCOM_组件/XPCOM_简介#XPCOM_.E6.9C.8D.E5.8A.A1">XPCOM 服务</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#XPCOM_.E7.B1.BB.E5.9E.8B" title="cn/创建_XPCOM_组件/XPCOM_简介#XPCOM_.E7.B1.BB.E5.9E.8B">XPCOM 类型</a>
+ <dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#.E6.96.B9.E6.B3.95.E7.B1.BB.E5.9E.8B" title="cn/创建_XPCOM_组件/XPCOM_简介#.E6.96.B9.E6.B3.95.E7.B1.BB.E5.9E.8B">方法类型</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#.E5.BC.95.E7.94.A8.E8.AE.A1.E6.95.B0" title="cn/创建_XPCOM_组件/XPCOM_简介#.E5.BC.95.E7.94.A8.E8.AE.A1.E6.95.B0">引用计数</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#.E7.8A.B6.E6.80.81.E7.A0.81" title="cn/创建_XPCOM_组件/XPCOM_简介#.E7.8A.B6.E6.80.81.E7.A0.81">状态码</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#.E5.8F.98.E9.87.8F.E6.98.A0.E5.B0.84" title="cn/创建_XPCOM_组件/XPCOM_简介#.E5.8F.98.E9.87.8F.E6.98.A0.E5.B0.84">变量映射</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/XPCOM_%E7%AE%80%E4%BB%8B#.E9.80.9A.E7.94.A8_XPCOM_.E9.94.99.E8.AF.AF.E7.A0.81" title="cn/创建_XPCOM_组件/XPCOM_简介#.E9.80.9A.E7.94.A8_XPCOM_.E9.94.99.E8.AF.AF.E7.A0.81">通用 XPCOM 错误码</a></dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id=".E4.BD.BF.E7.94.A8_XPCOM_.E7.BB.84.E4.BB.B6" name=".E4.BD.BF.E7.94.A8_XPCOM_.E7.BB.84.E4.BB.B6"><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8_XPCOM_%E7%BB%84%E4%BB%B6" title="cn/创建_XPCOM_组件/使用_XPCOM_组件">使用 XPCOM 组件</a></h3>
+
+<dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8_XPCOM_%E7%BB%84%E4%BB%B6#.E7.BB.84.E4.BB.B6.E7.9A.84.E4.BE.8B.E5.AD.90" title="cn/创建_XPCOM_组件/使用_XPCOM_组件#.E7.BB.84.E4.BB.B6.E7.9A.84.E4.BE.8B.E5.AD.90">组件的例子</a>
+
+ <dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8_XPCOM_%E7%BB%84%E4%BB%B6#Cookie_.E7.AE.A1.E7.90.86.E5.99.A8" title="cn/创建_XPCOM_组件/使用_XPCOM_组件#Cookie_.E7.AE.A1.E7.90.86.E5.99.A8">Cookie 管理器</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8_XPCOM_%E7%BB%84%E4%BB%B6#WebBrowserFind_.E7.BB.84.E4.BB.B6" title="cn/创建_XPCOM_组件/使用_XPCOM_组件#WebBrowserFind_.E7.BB.84.E4.BB.B6"><strong>WebBrowserFind</strong> 组件</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8_XPCOM_%E7%BB%84%E4%BB%B6#WebLock_.E7.BB.84.E4.BB.B6" title="cn/创建_XPCOM_组件/使用_XPCOM_组件#WebLock_.E7.BB.84.E4.BB.B6"><strong>WebLock</strong> 组件</a></dd>
+ </dl>
+ </dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8_XPCOM_%E7%BB%84%E4%BB%B6#Mozilla_.E4.B8.AD.E4.BD.BF.E7.94.A8.E7.9A.84.E7.BB.84.E4.BB.B6" title="cn/创建_XPCOM_组件/使用_XPCOM_组件#Mozilla_.E4.B8.AD.E4.BD.BF.E7.94.A8.E7.9A.84.E7.BB.84.E4.BB.B6">Mozilla 中使用的组件</a>
+ <dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8_XPCOM_%E7%BB%84%E4%BB%B6#.E6.9F.A5.E6.89.BE_Mozilla_.E7.BB.84.E4.BB.B6" title="cn/创建_XPCOM_组件/使用_XPCOM_组件#.E6.9F.A5.E6.89.BE_Mozilla_.E7.BB.84.E4.BB.B6">查找 Mozilla 组件</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8_XPCOM_%E7%BB%84%E4%BB%B6#.E5.9C.A8_Cpp_.E4.BB.A3.E7.A0.81.E4.B8.AD.E4.BD.BF.E7.94.A8_XPCOM_.E7.BB.84.E4.BB.B6" title="cn/创建_XPCOM_组件/使用_XPCOM_组件#.E5.9C.A8_Cpp_.E4.BB.A3.E7.A0.81.E4.B8.AD.E4.BD.BF.E7.94.A8_XPCOM_.E7.BB.84.E4.BB.B6">在 Cpp 代码中使用 XPCOM 组件</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8_XPCOM_%E7%BB%84%E4%BB%B6#XPConnect:_.E5.9C.A8.E8.84.9A.E6.9C.AC.E4.B8.AD.E4.BD.BF.E7.94.A8_XPCOM_.E7.BB.84.E4.BB.B6" title="cn/创建_XPCOM_组件/使用_XPCOM_组件#XPConnect:_.E5.9C.A8.E8.84.9A.E6.9C.AC.E4.B8.AD.E4.BD.BF.E7.94.A8_XPCOM_.E7.BB.84.E4.BB.B6">XPConnect: 在脚本中使用 XPCOM 组件</a></dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id=".E7.BB.84.E4.BB.B6.E5.86.85.E5.B9.95" name=".E7.BB.84.E4.BB.B6.E5.86.85.E5.B9.95"><a href="/cn/Creating_XPCOM_Components/Component_Internals" title="cn/Creating_XPCOM_Components/Component_Internals">组件内幕</a></h3>
+
+<dl>
+ <dd><a href="/cn/Creating_XPCOM_Components/Component_Internals#.E7.94.A8Cpp.E4.B9.A6.E5.86.99.E7.BB.84.E4.BB.B6" title="cn/Creating_XPCOM_Components/Component_Internals#.E7.94.A8Cpp.E4.B9.A6.E5.86.99.E7.BB.84.E4.BB.B6">用Cpp书写组件</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Component_Internals#XPCOM.E5.88.9D.E5.A7.8B.E5.8C.96" title="cn/Creating_XPCOM_Components/Component_Internals#XPCOM.E5.88.9D.E5.A7.8B.E5.8C.96">XPCOM初始化</a>
+ <dl>
+ <dd><a href="/cn/Creating_XPCOM_Components/Component_Internals#XPCOM.E6.B3.A8.E5.86.8C.E6.8F.8F.E8.BF.B0" title="cn/Creating_XPCOM_Components/Component_Internals#XPCOM.E6.B3.A8.E5.86.8C.E6.8F.8F.E8.BF.B0">XPCOM注册描述</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Component_Internals#XPCOM.E6.B3.A8.E5.86.8C.E7.9A.84.E6.96.B9.E6.B3.95" title="cn/Creating_XPCOM_Components/Component_Internals#XPCOM.E6.B3.A8.E5.86.8C.E7.9A.84.E6.96.B9.E6.B3.95">XPCOM注册的方法</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Component_Internals#.E8.87.AA.E5.8A.A8.E6.B3.A8.E5.86.8C" title="cn/Creating_XPCOM_Components/Component_Internals#.E8.87.AA.E5.8A.A8.E6.B3.A8.E5.86.8C">自动注册</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Component_Internals#The_Shutdown_Process" title="cn/Creating_XPCOM_Components/Component_Internals#The_Shutdown_Process">The Shutdown Process</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Component_Internals#XPCOM.E7.BB.84.E4.BB.B6.E5.BA.93.E7.9A.84.E4.B8.89.E4.B8.AA.E9.83.A8.E5.88.86" title="cn/Creating_XPCOM_Components/Component_Internals#XPCOM.E7.BB.84.E4.BB.B6.E5.BA.93.E7.9A.84.E4.B8.89.E4.B8.AA.E9.83.A8.E5.88.86">XPCOM组件库的三个部分</a></dd>
+ </dl>
+ </dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Component_Internals#XPCOM_Glue" title="cn/Creating_XPCOM_Components/Component_Internals#XPCOM_Glue">XPCOM Glue</a>
+ <dl>
+ <dd><a href="/cn/Creating_XPCOM_Components/Component_Internals#The_Glue_Library" title="cn/Creating_XPCOM_Components/Component_Internals#The_Glue_Library">The Glue Library</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Component_Internals#XPCOM_String_Classes" title="cn/Creating_XPCOM_Components/Component_Internals#XPCOM_String_Classes">XPCOM String Classes</a></dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id=".E5.BB.BA.E7.AB.8B.E7.BB.84.E4.BB.B6.E4.BB.A3.E7.A0.81" name=".E5.BB.BA.E7.AB.8B.E7.BB.84.E4.BB.B6.E4.BB.A3.E7.A0.81"><a href="/cn/Creating_XPCOM_Components/Creating_the_Component_Code" title="cn/Creating_XPCOM_Components/Creating_the_Component_Code">建立组件代码</a></h3>
+
+<dl>
+ <dd><a href="/cn/Creating_XPCOM_Components/Creating_the_Component_Code#.E6.88.91.E4.BB.AC.E5.B0.86.E5.81.9A.E4.BB.80.E4.B9.88" title="cn/Creating_XPCOM_Components/Creating_the_Component_Code#.E6.88.91.E4.BB.AC.E5.B0.86.E5.81.9A.E4.BB.80.E4.B9.88">我们将做什么</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Creating_the_Component_Code#.E7.BB.84.E4.BB.B6.E6.B3.A8.E5.86.8C" title="cn/Creating_XPCOM_Components/Creating_the_Component_Code#.E7.BB.84.E4.BB.B6.E6.B3.A8.E5.86.8C">组件注册</a>
+ <dl>
+ <dd><a href="/cn/Creating_XPCOM_Components/Creating_the_Component_Code#The_regxpcom_Program" title="cn/Creating_XPCOM_Components/Creating_the_Component_Code#The_regxpcom_Program">The <code>regxpcom</code> Program</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Creating_the_Component_Code#.E5.85.B6.E4.BB.96.E7.9A.84.E6.B3.A8.E5.86.8C.E9.80.94.E5.BE.84" title="cn/Creating_XPCOM_Components/Creating_the_Component_Code#.E5.85.B6.E4.BB.96.E7.9A.84.E6.B3.A8.E5.86.8C.E9.80.94.E5.BE.84">其他的注册途径</a></dd>
+ </dl>
+ </dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Creating_the_Component_Code#.E6.A6.82.E8.A7.88WebLock_Module_Source" title="cn/Creating_XPCOM_Components/Creating_the_Component_Code#.E6.A6.82.E8.A7.88WebLock_Module_Source">概览<strong>WebLock</strong> Module Source</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Creating_the_Component_Code#.E6.B7.B1.E5.BA.A6.E6.8C.96.E6.8E.98:_.E9.9C.80.E8.A6.81.E7.9A.84Includes.E5.92.8C.E5.B8.B8.E9.87.8F" title="cn/Creating_XPCOM_Components/Creating_the_Component_Code#.E6.B7.B1.E5.BA.A6.E6.8C.96.E6.8E.98:_.E9.9C.80.E8.A6.81.E7.9A.84Includes.E5.92.8C.E5.B8.B8.E9.87.8F">深度挖掘: 需要的Includes和常量</a>
+ <dl>
+ <dd><a href="/cn/Creating_XPCOM_Components/Creating_the_Component_Code#XPCOM.E4.B8.AD.E7.9A.84.E6.A0.87.E8.AF.86.E7.AC.A6" title="cn/Creating_XPCOM_Components/Creating_the_Component_Code#XPCOM.E4.B8.AD.E7.9A.84.E6.A0.87.E8.AF.86.E7.AC.A6">XPCOM中的标识符</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Creating_the_Component_Code#.E6.B3.A8.E5.86.8C.E8.BF.87.E7.A8.8B.E7.9A.84.E4.BB.A3.E7.A0.81" title="cn/Creating_XPCOM_Components/Creating_the_Component_Code#.E6.B3.A8.E5.86.8C.E8.BF.87.E7.A8.8B.E7.9A.84.E4.BB.A3.E7.A0.81">注册过程的代码</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Creating_the_Component_Code#.E6.B3.A8.E5.86.8C.E7.94.A8.E7.9A.84.E6.96.B9.E6.B3.95" title="cn/Creating_XPCOM_Components/Creating_the_Component_Code#.E6.B3.A8.E5.86.8C.E7.94.A8.E7.9A.84.E6.96.B9.E6.B3.95">注册用的方法</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Creating_the_Component_Code#.E5.BB.BA.E7.AB.8B.E4.BD.A0.E7.9A.84.E7.BB.84.E4.BB.B6.E7.9A.84.E6.8E.A5.E5.8F.A3" title="cn/Creating_XPCOM_Components/Creating_the_Component_Code#.E5.BB.BA.E7.AB.8B.E4.BD.A0.E7.9A.84.E7.BB.84.E4.BB.B6.E7.9A.84.E6.8E.A5.E5.8F.A3">建立你的组件的接口</a></dd>
+ </dl>
+ </dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/%E5%BB%BA%E7%AB%8B%E7%BB%84%E4%BB%B6%E4%BB%A3%E7%A0%81#webLock1.cpp" title="cn/Creating_XPCOM_Components/建立组件代码#webLock1.cpp"><code>webLock1.cpp</code></a></dd>
+</dl>
+
+<h3 id=".E4.BD.BF.E7.94.A8XPCOM.E5.B7.A5.E5.85.B7.E7.B1.BB.E8.AE.A9.E4.BA.8B.E6.83.85.E5.8F.98.E5.BE.97.E7.AE.80.E5.8D.95" name=".E4.BD.BF.E7.94.A8XPCOM.E5.B7.A5.E5.85.B7.E7.B1.BB.E8.AE.A9.E4.BA.8B.E6.83.85.E5.8F.98.E5.BE.97.E7.AE.80.E5.8D.95"><a href="/cn/%E5%88%9B%E5%BB%BAXPCOM%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8XPCOM%E5%B7%A5%E5%85%B7%E7%B1%BB%E8%AE%A9%E4%BA%8B%E6%83%85%E5%8F%98%E5%BE%97%E7%AE%80%E5%8D%95" title="cn/创建XPCOM组件/使用XPCOM工具类让事情变得简单">使用XPCOM工具类让事情变得简单</a></h3>
+
+<dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BAXPCOM%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8XPCOM%E5%B7%A5%E5%85%B7%E7%B1%BB%E8%AE%A9%E4%BA%8B%E6%83%85%E5%8F%98%E5%BE%97%E7%AE%80%E5%8D%95#XPCOM_.E5.AE.8F" title="cn/创建XPCOM组件/使用XPCOM工具类让事情变得简单#XPCOM_.E5.AE.8F">XPCOM 宏</a>
+
+ <dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BAXPCOM%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8XPCOM%E5%B7%A5%E5%85%B7%E7%B1%BB%E8%AE%A9%E4%BA%8B%E6%83%85%E5%8F%98%E5%BE%97%E7%AE%80%E5%8D%95#.E9.80.9A.E7.94.A8XPCOM.E6.A8.A1.E5.9D.97.E5.AE.8F" title="cn/创建XPCOM组件/使用XPCOM工具类让事情变得简单#.E9.80.9A.E7.94.A8XPCOM.E6.A8.A1.E5.9D.97.E5.AE.8F">通用XPCOM模块宏</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BAXPCOM%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8XPCOM%E5%B7%A5%E5%85%B7%E7%B1%BB%E8%AE%A9%E4%BA%8B%E6%83%85%E5%8F%98%E5%BE%97%E7%AE%80%E5%8D%95#.E5.9F.BA.E6.9C.AC.E5.AE.9E.E7.8E.B0.E5.AE.8F" title="cn/创建XPCOM组件/使用XPCOM工具类让事情变得简单#.E5.9F.BA.E6.9C.AC.E5.AE.9E.E7.8E.B0.E5.AE.8F">基本实现宏</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BAXPCOM%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8XPCOM%E5%B7%A5%E5%85%B7%E7%B1%BB%E8%AE%A9%E4%BA%8B%E6%83%85%E5%8F%98%E5%BE%97%E7%AE%80%E5%8D%95#.E5.A3.B0.E6.98.8E.E5.AE.8F" title="cn/创建XPCOM组件/使用XPCOM工具类让事情变得简单#.E5.A3.B0.E6.98.8E.E5.AE.8F">声明宏</a></dd>
+ </dl>
+ </dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BAXPCOM%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8XPCOM%E5%B7%A5%E5%85%B7%E7%B1%BB%E8%AE%A9%E4%BA%8B%E6%83%85%E5%8F%98%E5%BE%97%E7%AE%80%E5%8D%95#webLock2.cpp" title="cn/创建XPCOM组件/使用XPCOM工具类让事情变得简单#webLock2.cpp"><code>webLock2.cpp</code></a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BAXPCOM%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8XPCOM%E5%B7%A5%E5%85%B7%E7%B1%BB%E8%AE%A9%E4%BA%8B%E6%83%85%E5%8F%98%E5%BE%97%E7%AE%80%E5%8D%95#XPCOM.E4.B8.AD.E7.9A.84.E5.AD.97.E7.AC.A6.E4.B8.B2.E7.B1.BB" title="cn/创建XPCOM组件/使用XPCOM工具类让事情变得简单#XPCOM.E4.B8.AD.E7.9A.84.E5.AD.97.E7.AC.A6.E4.B8.B2.E7.B1.BB">XPCOM中的字符串类</a>
+ <dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BAXPCOM%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8XPCOM%E5%B7%A5%E5%85%B7%E7%B1%BB%E8%AE%A9%E4%BA%8B%E6%83%85%E5%8F%98%E5%BE%97%E7%AE%80%E5%8D%95#.E4.BD.BF.E7.94.A8.E5.AD.97.E7.AC.A6.E4.B8.B2" title="cn/创建XPCOM组件/使用XPCOM工具类让事情变得简单#.E4.BD.BF.E7.94.A8.E5.AD.97.E7.AC.A6.E4.B8.B2">使用字符串</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BAXPCOM%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8XPCOM%E5%B7%A5%E5%85%B7%E7%B1%BB%E8%AE%A9%E4%BA%8B%E6%83%85%E5%8F%98%E5%BE%97%E7%AE%80%E5%8D%95#nsEmbedString_.E5.92.8C_nsEmbedCString" title="cn/创建XPCOM组件/使用XPCOM工具类让事情变得简单#nsEmbedString_.E5.92.8C_nsEmbedCString"><code>nsEmbedString</code> 和 <code>nsEmbedCString</code></a></dd>
+ </dl>
+ </dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BAXPCOM%E7%BB%84%E4%BB%B6/%E4%BD%BF%E7%94%A8XPCOM%E5%B7%A5%E5%85%B7%E7%B1%BB%E8%AE%A9%E4%BA%8B%E6%83%85%E5%8F%98%E5%BE%97%E7%AE%80%E5%8D%95#.E6.99.BA.E8.83.BD.E6.8C.87.E9.92.88" title="cn/创建XPCOM组件/使用XPCOM工具类让事情变得简单#.E6.99.BA.E8.83.BD.E6.8C.87.E9.92.88">智能指针</a></dd>
+</dl>
+
+<h3 id=".E5.BC.80.E5.A7.8BWebLock" name=".E5.BC.80.E5.A7.8BWebLock"><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock" title="cn/创建_XPCOM_组件/开始WebLock">开始<strong>WebLock</strong></a></h3>
+
+<dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E5.90.AF.E5.8A.A8.E6.97.B6.E8.A2.AB.E8.B0.83.E7.94.A8" title="cn/创建_XPCOM_组件/开始WebLock#.E5.90.AF.E5.8A.A8.E6.97.B6.E8.A2.AB.E8.B0.83.E7.94.A8">启动时被调用</a>
+
+ <dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E6.B3.A8.E5.86.8C.E5.88.B0.E6.B6.88.E6.81.AF" title="cn/创建_XPCOM_组件/开始WebLock#.E6.B3.A8.E5.86.8C.E5.88.B0.E6.B6.88.E6.81.AF">注册到消息</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E8.AE.BF.E9.97.AECategory_Manager" title="cn/创建_XPCOM_组件/开始WebLock#.E8.AE.BF.E9.97.AECategory_Manager">访问Category Manager</a></dd>
+ </dl>
+ </dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E6.8F.90.E4.BE.9BWebLock.E8.AE.BF.E9.97.AE" title="cn/创建_XPCOM_组件/开始WebLock#.E6.8F.90.E4.BE.9BWebLock.E8.AE.BF.E9.97.AE">提供<strong>WebLock</strong>访问</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E5.BB.BA.E7.AB.8BWebLock.E7.BC.96.E7.A8.8B.E6.8E.A5.E5.8F.A3" title="cn/创建_XPCOM_组件/开始WebLock#.E5.BB.BA.E7.AB.8BWebLock.E7.BC.96.E7.A8.8B.E6.8E.A5.E5.8F.A3">建立<strong>WebLock</strong>编程接口</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E5.9C.A8XPIDL.E4.B8.AD.E5.AE.9A.E4.B9.89WebLock.E6.8E.A5.E5.8F.A3" title="cn/创建_XPCOM_组件/开始WebLock#.E5.9C.A8XPIDL.E4.B8.AD.E5.AE.9A.E4.B9.89WebLock.E6.8E.A5.E5.8F.A3">在XPIDL中定义<strong>WebLock</strong>接口</a>
+ <dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#XPIDL.E4.B9.A6.E5.86.99.E6.A0.BC.E5.BC.8F" title="cn/创建_XPCOM_组件/开始WebLock#XPIDL.E4.B9.A6.E5.86.99.E6.A0.BC.E5.BC.8F">XPIDL书写格式</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E8.84.9A.E6.9C.AC.E5.8C.96.E6.8E.A5.E5.8F.A3" title="cn/创建_XPCOM_组件/开始WebLock#.E8.84.9A.E6.9C.AC.E5.8C.96.E6.8E.A5.E5.8F.A3">脚本化接口</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E5.AE.9E.E7.8E.B0nsISupports" title="cn/创建_XPCOM_组件/开始WebLock#.E5.AE.9E.E7.8E.B0nsISupports">实现<code>nsISupports</code></a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#Web_Locking_.E6.8E.A5.E5.8F.A3" title="cn/创建_XPCOM_组件/开始WebLock#Web_Locking_.E6.8E.A5.E5.8F.A3">Web Locking 接口</a></dd>
+ </dl>
+ </dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E5.AE.9E.E7.8E.B0WebLock" title="cn/创建_XPCOM_组件/开始WebLock#.E5.AE.9E.E7.8E.B0WebLock">实现<strong>WebLock</strong></a>
+ <dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E5.A3.B0.E6.98.8E.E5.AE.8F" title="cn/创建_XPCOM_组件/开始WebLock#.E5.A3.B0.E6.98.8E.E5.AE.8F">声明宏</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E5.9C.A8XPCOM.E4.B8.AD.E8.A1.A8.E8.BE.BE.E8.BF.94.E5.9B.9E.E5.80.BC" title="cn/创建_XPCOM_组件/开始WebLock#.E5.9C.A8XPCOM.E4.B8.AD.E8.A1.A8.E8.BE.BE.E8.BF.94.E5.9B.9E.E5.80.BC">在XPCOM中表达返回值</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#XPIDL.E4.BB.A3.E7.A0.81.E7.94.9F.E6.88.90" title="cn/创建_XPCOM_组件/开始WebLock#XPIDL.E4.BB.A3.E7.A0.81.E7.94.9F.E6.88.90">XPIDL代码生成</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E4.BB.8E.E5.AE.A2.E6.88.B7.E7.AB.AF.E8.8E.B7.E5.8F.96WebLock_Service" title="cn/创建_XPCOM_组件/开始WebLock#.E4.BB.8E.E5.AE.A2.E6.88.B7.E7.AB.AF.E8.8E.B7.E5.8F.96WebLock_Service">从客户端获取WebLock Service</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E5.AE.9E.E7.8E.B0iWebLock.E6.8E.A5.E5.8F.A3" title="cn/创建_XPCOM_组件/开始WebLock#.E5.AE.9E.E7.8E.B0iWebLock.E6.8E.A5.E5.8F.A3">实现<code>iWebLock</code>接口</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#The_Directory_Service" title="cn/创建_XPCOM_组件/开始WebLock#The_Directory_Service">The Directory Service</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E7.94.A8nsIFile.E6.94.B9.E5.8F.98.E8.B7.AF.E5.BE.84" title="cn/创建_XPCOM_组件/开始WebLock#.E7.94.A8nsIFile.E6.94.B9.E5.8F.98.E8.B7.AF.E5.BE.84">用<code>nsIFile</code>改变路径</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E7.94.A8nsIFile.E6.93.8D.E4.BD.9C.E6.96.87.E4.BB.B6" title="cn/创建_XPCOM_组件/开始WebLock#.E7.94.A8nsIFile.E6.93.8D.E4.BD.9C.E6.96.87.E4.BB.B6">用<code>nsIFile</code>操作文件</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E7.94.A8nsILocalFile.E8.AF.BB.E5.8F.96.E6.95.B0.E6.8D.AE" title="cn/创建_XPCOM_组件/开始WebLock#.E7.94.A8nsILocalFile.E8.AF.BB.E5.8F.96.E6.95.B0.E6.8D.AE">用<code>nsILocalFile</code>读取数据</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#.E5.A4.84.E7.90.86White_List_Data" title="cn/创建_XPCOM_组件/开始WebLock#.E5.A4.84.E7.90.86White_List_Data">处理White List Data</a></dd>
+ </dl>
+ </dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#iWebLock.E6.96.B9.E6.B3.95.E5.88.97.E4.B8.BE" title="cn/创建_XPCOM_组件/开始WebLock#iWebLock.E6.96.B9.E6.B3.95.E5.88.97.E4.B8.BE"><code>iWebLock</code>方法列举</a>
+ <dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#Lock_.E5.92.8C_Unlock" title="cn/创建_XPCOM_组件/开始WebLock#Lock_.E5.92.8C_Unlock"><code>Lock</code> and <code>Unlock</code></a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#AddSite" title="cn/创建_XPCOM_组件/开始WebLock#AddSite"><code>AddSite</code></a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#RemoveSite" title="cn/创建_XPCOM_组件/开始WebLock#RemoveSite"><code>RemoveSite</code></a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#SetSites" title="cn/创建_XPCOM_组件/开始WebLock#SetSites"><code>SetSites</code></a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#GetNext" title="cn/创建_XPCOM_组件/开始WebLock#GetNext"><code>GetNext</code></a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#GetSites" title="cn/创建_XPCOM_组件/开始WebLock#GetSites"><code>GetSites</code></a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BC%80%E5%A7%8BWebLock#HasMoreElements" title="cn/创建_XPCOM_组件/开始WebLock#HasMoreElements"><code>HasMoreElements</code></a></dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id="Finishing_the_Component" name="Finishing_the_Component"><a href="/cn/Creating_XPCOM_Components/Finishing_the_Component" title="cn/Creating_XPCOM_Components/Finishing_the_Component">Finishing the Component</a></h3>
+
+<dl>
+ <dd><a href="/cn/Creating_XPCOM_Components/Finishing_the_Component#Using_Frozen_Interfaces" title="cn/Creating_XPCOM_Components/Finishing_the_Component#Using_Frozen_Interfaces">Using Frozen Interfaces</a>
+
+ <dl>
+ <dd><a href="/cn/Creating_XPCOM_Components/Finishing_the_Component#Copying_Interfaces_Into_Your_Build_Environment" title="cn/Creating_XPCOM_Components/Finishing_the_Component#Copying_Interfaces_Into_Your_Build_Environment">Copying Interfaces Into Your Build Environment</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Finishing_the_Component#Implementing_the_nsIContentPolicy_Interface" title="cn/Creating_XPCOM_Components/Finishing_the_Component#Implementing_the_nsIContentPolicy_Interface">Implementing the <code>nsIContentPolicy</code> Interface</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Finishing_the_Component#Receiving_Notifications" title="cn/Creating_XPCOM_Components/Finishing_the_Component#Receiving_Notifications">Receiving Notifications</a></dd>
+ </dl>
+ </dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Finishing_the_Component#Implementing_the_nsIContentPolicy" title="cn/Creating_XPCOM_Components/Finishing_the_Component#Implementing_the_nsIContentPolicy">Implementing the <code>nsIContentPolicy</code></a>
+ <dl>
+ <dd><a href="/cn/Creating_XPCOM_Components/Finishing_the_Component#Uniform_Resource_Locators" title="cn/Creating_XPCOM_Components/Finishing_the_Component#Uniform_Resource_Locators">Uniform Resource Locators</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Finishing_the_Component#Checking_the_White_List" title="cn/Creating_XPCOM_Components/Finishing_the_Component#Checking_the_White_List">Checking the White List</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Finishing_the_Component#Creating_nsIURI_Objects" title="cn/Creating_XPCOM_Components/Finishing_the_Component#Creating_nsIURI_Objects">Creating <code>nsIURI</code> Objects</a></dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id="Building_the_WebLock_UI" name="Building_the_WebLock_UI"><a href="/cn/Creating_XPCOM_Components/Building_the_WebLock_UI" title="cn/Creating_XPCOM_Components/Building_the_WebLock_UI">Building the <strong>WebLock</strong> UI</a></h3>
+
+<dl>
+ <dd><a href="/cn/Creating_XPCOM_Components/Building_the_WebLock_UI#User_Interface_Package_List" title="cn/Creating_XPCOM_Components/Building_the_WebLock_UI#User_Interface_Package_List">User Interface Package List</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Building_the_WebLock_UI#Client_Code_Overview" title="cn/Creating_XPCOM_Components/Building_the_WebLock_UI#Client_Code_Overview">Client Code Overview</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Building_the_WebLock_UI#XUL" title="cn/Creating_XPCOM_Components/Building_the_WebLock_UI#XUL">XUL</a>
+ <dl>
+ <dd><a href="/cn/Creating_XPCOM_Components/Building_the_WebLock_UI#The_XUL_Document" title="cn/Creating_XPCOM_Components/Building_the_WebLock_UI#The_XUL_Document">The XUL Document</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Building_the_WebLock_UI#The_Locking_UI" title="cn/Creating_XPCOM_Components/Building_the_WebLock_UI#The_Locking_UI">The Locking UI</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Building_the_WebLock_UI#Site_Adding_UI" title="cn/Creating_XPCOM_Components/Building_the_WebLock_UI#Site_Adding_UI">Site Adding UI</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Building_the_WebLock_UI#weblock.xul" title="cn/Creating_XPCOM_Components/Building_the_WebLock_UI#weblock.xul"><code>weblock.xul</code></a></dd>
+ </dl>
+ </dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Building_the_WebLock_UI#Overlaying_New_User_Interface_Into_Mozilla" title="cn/Creating_XPCOM_Components/Building_the_WebLock_UI#Overlaying_New_User_Interface_Into_Mozilla">Overlaying New User Interface Into Mozilla</a>
+ <dl>
+ <dd><a href="/cn/Creating_XPCOM_Components/Building_the_WebLock_UI#webLockOverlay.xul" title="cn/Creating_XPCOM_Components/Building_the_WebLock_UI#webLockOverlay.xul"><code>webLockOverlay.xul</code></a></dd>
+ </dl>
+ </dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Building_the_WebLock_UI#Other_Resources" title="cn/Creating_XPCOM_Components/Building_the_WebLock_UI#Other_Resources">Other Resources</a>
+ <dl>
+ <dd><a href="/cn/Creating_XPCOM_Components/Building_the_WebLock_UI#weblock.css" title="cn/Creating_XPCOM_Components/Building_the_WebLock_UI#weblock.css"><code>weblock.css</code></a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Building_the_WebLock_UI#Image_Resources" title="cn/Creating_XPCOM_Components/Building_the_WebLock_UI#Image_Resources">Image Resources</a></dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id=".E6.89.93.E5.8C.85_WebLock" name=".E6.89.93.E5.8C.85_WebLock"><a href="/cn/Creating_XPCOM_Components/Packaging_WebLock" title="cn/Creating_XPCOM_Components/Packaging_WebLock">打包 WebLock</a></h3>
+
+<dl>
+ <dd><a href="/cn/Creating_XPCOM_Components/Packaging_WebLock#Component_Installation_Overview" title="cn/Creating_XPCOM_Components/Packaging_WebLock#Component_Installation_Overview">组件安装预览</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Packaging_WebLock#Archiving_Resources" title="cn/Creating_XPCOM_Components/Packaging_WebLock#Archiving_Resources">资源归档</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Packaging_WebLock#The_WebLock_Installation_Script" title="cn/Creating_XPCOM_Components/Packaging_WebLock#The_WebLock_Installation_Script"><strong>WebLock</strong> 安装脚本</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Packaging_WebLock#The_WebLock_Trigger_Script" title="cn/Creating_XPCOM_Components/Packaging_WebLock#The_WebLock_Trigger_Script"><strong>WebLock</strong> 跟踪脚本</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Packaging_WebLock#Distributing_Your_Component" title="cn/Creating_XPCOM_Components/Packaging_WebLock#Distributing_Your_Component">分发你的组件</a></dd>
+</dl>
+
+<h3 id=".E9.99.84.E5.BD.95_A_-_.E5.BB.BA.E7.AB.8B_Gecko_SDK" name=".E9.99.84.E5.BD.95_A_-_.E5.BB.BA.E7.AB.8B_Gecko_SDK"><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BB%BA%E7%AB%8B_Gecko_SDK" title="cn/创建_XPCOM_组件/建立_Gecko_SDK">附录 A - 建立 Gecko SDK</a></h3>
+
+<dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BB%BA%E7%AB%8B_Gecko_SDK#.E4.B8.8B.E8.BD.BD.E5.92.8C.E5.BB.BA.E7.AB.8B_SDK" title="cn/创建_XPCOM_组件/建立_Gecko_SDK#.E4.B8.8B.E8.BD.BD.E5.92.8C.E5.BB.BA.E7.AB.8B_SDK">下载和建立 SDK</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BB%BA%E7%AB%8B_Gecko_SDK#.E7.BC.96.E8.AF.91.E4.B8.80.E4.B8.AA_Microsoft_Visual_Cpp_.E5.B7.A5.E7.A8.8B" title="cn/创建_XPCOM_组件/建立_Gecko_SDK#.E7.BC.96.E8.AF.91.E4.B8.80.E4.B8.AA_Microsoft_Visual_Cpp_.E5.B7.A5.E7.A8.8B">编译一个 Microsoft Visual Cpp 工程</a>
+ <dl>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BB%BA%E7%AB%8B_Gecko_SDK#.E5.88.9B.E5.BB.BA.E4.B8.80.E4.B8.AA.E6.96.B0.E7.9A.84.E5.B7.A5.E7.A8.8B" title="cn/创建_XPCOM_组件/建立_Gecko_SDK#.E5.88.9B.E5.BB.BA.E4.B8.80.E4.B8.AA.E6.96.B0.E7.9A.84.E5.B7.A5.E7.A8.8B">创建一个新的工程</a></dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BB%BA%E7%AB%8B_Gecko_SDK#.E6.8A.8A_Gecko_SDK_.E6.B7.BB.E5.8A.A0.E5.88.B0.E5.B7.A5.E7.A8.8B.E8.AE.BE.E7.BD.AE" title="cn/创建_XPCOM_组件/建立_Gecko_SDK#.E6.8A.8A_Gecko_SDK_.E6.B7.BB.E5.8A.A0.E5.88.B0.E5.B7.A5.E7.A8.8B.E8.AE.BE.E7.BD.AE">把 Gecko SDK 添加到工程设置</a></dd>
+ </dl>
+ </dd>
+ <dd><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BB%BA%E7%AB%8B_Gecko_SDK#Unix_.E4.B8.8B.E7.9A.84.E4.B8.80.E4.B8.AA_Makefile" title="cn/创建_XPCOM_组件/建立_Gecko_SDK#Unix_.E4.B8.8B.E7.9A.84.E4.B8.80.E4.B8.AA_Makefile">Unix 下的一个 Makefile</a></dd>
+</dl>
+
+<h3 id=".E9.99.84.E5.BD.95B_-_.E8.B5.84.E6.BA.90" name=".E9.99.84.E5.BD.95B_-_.E8.B5.84.E6.BA.90"><a href="/cn/Creating_XPCOM_Components/Resources" title="cn/Creating_XPCOM_Components/Resources">附录B - 资源</a></h3>
+
+<dl>
+ <dd><a href="/cn/Creating_XPCOM_Components/Resources#WebLock_Resources" title="cn/Creating_XPCOM_Components/Resources#WebLock_Resources">WebLock 资源</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Resources#Gecko_Resources" title="cn/Creating_XPCOM_Components/Resources#Gecko_Resources">Gecko 资源</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Resources#XPCOM_Resources" title="cn/Creating_XPCOM_Components/Resources#XPCOM_Resources">XPCOM 资源</a></dd>
+ <dd><a href="/cn/Creating_XPCOM_Components/Resources#General_Development_Resources" title="cn/Creating_XPCOM_Components/Resources#General_Development_Resources">General Development 资源</a></dd>
+</dl>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/创建_XPCOM_组件:前言">下一页 »</a></p>
+</div> <p></p><div class="licenseblock">
+<p>Copyright (c) 2003 by Doug Turner and Ian Oeschger. This material may be distributed only subject to the terms and conditions set forth in the <a class="external" href="http://www.opencontent.org/openpub/" rel="noopener">Open Publication License</a>, v1.02 or later. Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.</p>
+</div><p></p>
+
+<p> </p>
+
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/packaging_weblock/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/packaging_weblock/index.html
new file mode 100644
index 0000000000..3a7744ec03
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/packaging_weblock/index.html
@@ -0,0 +1,136 @@
+---
+title: Packaging WebLock
+slug: Mozilla/Tech/XPCOM/Guide/Creating_components/Packaging_WebLock
+tags:
+ - XPCOM
+ - 所有分类
+translation_of: Mozilla/Tech/XPCOM/Guide/Creating_components/Packaging_WebLock
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Creating_XPCOM_Components:Building_the_WebLock_UI" style="float: left;">« 上一页</a><a href="/zh-CN/docs/创建_XPCOM_组件:建立_Gecko_SDK">下一页 »</a></p>
+</div><p></p>
+
+<p>这是教程最后一部分, 我们将把所有的web所有的组件成分打包成可安装到其他应用中的形式 - the library itself, the type library, the header file, and the user interface resources. The first section, <a href="#Component_Installation_Overview">Component Installation Overview</a>, describes the general installation process in Mozilla. The following sections describe the steps you can take to organize the <strong>WebLock</strong> component for distribution and installation.</p>
+
+<div class="side-note">
+<p>请注意: 这个教程主要是关注组件开发本身, 所以这部分描述有关打包和安装到Gecko的过程是很简单的. 如果你希望了解详细的打包和安装组件到基于Gecko应用的信息,应该参考http://www.mozilla.org/projects/xpinstall.</p>
+</div>
+
+<h3 id="Component_Installation_Overview" name="Component_Installation_Overview">Component Installation Overview</h3>
+
+<p>XPInstall是一组JavaScript APIs用来建立安装脚本. 使用XPInstall,你可以为装载到Gecko-based应用,Mozilla extensions,或者individual components的组件建立web-based安装脚本. <strong>WebLock</strong> component安装脚本也可以用来注册组件到browser(see <a href="cn/Creating_XPCOM_Components/Component_Internals#Registration_Methods_in_XPCOM">Registration Methods in XPCOM</a> for more information on registration).</p>
+
+<p>下面的例子安装脚本使用了Mozilla XPInstall技术来操作安装并且以高层次Javascript对象的方式来跟Mozilla's<em>chrome registry</em> 交互。</p>
+
+<div class="side-note">
+<p><span id="What_Is_the_Chrome_Registry?"><a id="What_Is_the_Chrome_Registry?"></a><strong>What Is the Chrome Registry?</strong></span></p>
+
+<p>Like the Windows registry, the chrome registry is a database of information about applications, skins, and other extensions that have been installed in a Gecko application. Since Mozilla and other Gecko-based applications are cross-platform, this database is abstracted above the operating system or any particular platform's registry.</p>
+
+<p>The chrome registry lives in a series of RDF/XML files in the application directory of Mozilla and other Gecko-based browsers, where new installs, user configurable data, skins, and other information are related to one another and the application itself.</p>
+</div>
+
+<p>XPInstall中的JavaScript APIs <code>Install</code> 对象下载包含了安装文件的JAR并且调用注册方法来告诉 Mozilla 新的组件和用来调用<strong>WebLock</strong>组件的UI. <a href="#WebLock_Installation_Script">WebLock Installation Script</a> 是完整的<em>trigger installation script</em> , 可以从网页触发. 文件被存储在JAR file <code>weblock.jar</code>, 这是一个简单的ZIP文件,以XPI结尾,有时候也可能包含一个内部的安装脚本<code>install.js</code>.</p>
+
+<p>一旦你把组件和<strong>Weblock</strong>相关资源正确打包(see the following section, <a href="#Archiving_Resources">Archiving Resources</a>), <strong>WebLock</strong>安装脚本是一个简单的事情(see <a href="#The_WebLock_Installation_Script">The WebLock Installation Script</a>).</p>
+
+<h3 id="Archiving_Resources" name="Archiving_Resources">Archiving Resources</h3>
+
+<p>Once you have compiled all the resources that make up the <strong>WebLock</strong> component and the files that make up the user interface that will be added to the browser, you can place these within a subdirectory called <code>weblock</code>.</p>
+
+<p>Place the entire subdirectory into a ZIP archive and name the archive <code>weblock.xpi</code>. The archive, its subdirectory structure, and its contents should look like this:</p>
+
+<p><span id="%3Ccode%3Eweblock.xpi%3C/code%3E_Archive_Viewed_in_WinZIP"><a id="%3Ccode%3Eweblock.xpi%3C/code%3E_Archive_Viewed_in_WinZIP"></a><strong><code>weblock.xpi</code> Archive Viewed in WinZIP</strong></span></p>
+
+<p><img alt="Image:weblock-zipped-package.png"></p>
+
+<p>Note that the top level of the archive holds the <code>install.js</code> installation file, an RDF manifest for the package as a whole, and the component files (<code>weblock.xpt</code> and <code>weblock4.dll</code>). The component files are copied to the components directory of the Gecko application, and the weblock subdirectory gets copied over into the chrome subdirectory, where its UI resources can be added dynamically to the XUL-based Gecko application.</p>
+
+<p>The next section shows how this process of downloading, copying and registering the necessary files from the XPI can be achieved with an XPInstall installation script.</p>
+
+<h3 id="The_WebLock_Installation_Script" name="The_WebLock_Installation_Script">The <strong>WebLock</strong> Installation Script</h3>
+
+<p>安装脚本是一个存储在XPI中的JavaScript文件. 他必须在包的根目录 (i.e., <code>weblock.xpi</code>) itself. 一旦触发 (see <a href="#The_WebLock_Trigger_Script">The WebLock Trigger Script</a>), 安章脚本将:</p>
+
+<ul>
+ <li>downloads the <strong>WebLock</strong> component and places it in the <code>components</code> directory</li>
+ <li>copies the <code>weblock</code> subdirectory in the Mozilla chrome application subdirectory</li>
+ <li>registers both the component and the UI</li>
+</ul>
+
+<p>The XPInstall API提供了一些核心方法<sup><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Guide/Creating_components/Packaging_WebLock#endnote_essential-methods">[essential-methods]</a></sup>例如 <code>initInstall</code>, <code>registerChrome</code>, <code>addFile</code>, and others.</p>
+
+<p><span id="WebLock_Installation_Script"><a id="WebLock_Installation_Script"></a><strong>WebLock Installation Script</strong></span></p>
+
+<pre>// initialize the installation
+var err = initInstall("WebLock", "weblock", 1.0);
+
+var componentsDir = getFolder("Components");
+var cf = getFolder("Chrome");
+
+// add the DLL and say where it'll go
+addFile("weblock.dll", 1.0, "weblock.dll", componentsDir, "");
+
+// add the typelib also
+addFile("weblock.xpt", "1.0", "weblock.xpt", componentsDir, "");
+
+// add the weblock subdirectory of the XPI and specify that
+// it be installed in the chrome application directory
+err = addDirectory("weblock", "1.0", "", chromeDir, "");
+
+// ? have to register component here or with regxpcom?
+
+// register the new UI with the mozilla chrome registry
+
+registerChrome(CONTENT, getFolder(cf,"weblock.xpi"),"weblock");
+registerChrome(SKIN, getFolder(cf, "weblock.xpi"),"weblock");
+
+// perform the installation if there are no errors
+if (err==SUCCESS)
+ performInstall();
+else
+ cancelInstall(err);
+</pre>
+
+<h3 id="The_WebLock_Trigger_Script" name="The_WebLock_Trigger_Script">The <strong>WebLock</strong> Trigger Script</h3>
+
+<p>The <code>trigger script</code> is the script placed on a web page that actually initiates an XPInstall installation and calls the installation script that appears in the XPI. The following HTML specifies a complete webpage in which the trigger script is defined as a JavaScript function, <code>installWebLock</code>, that gets called when the user clicks the hyperlink.</p>
+
+<pre>&lt;html&gt;
+&lt;title&gt;WebLock Installation&lt;/title&gt;
+&lt;script type="text/javascript"&gt;
+/*
+ * Trigger function that downloads the XPI so the
+ * install.js file inside can be read and executed
+ */
+function installWebLock()
+{
+ weblock_xpi = {'WebLock Extension': 'weblock.xpi'};
+ InstallTrigger.install(weblock_xpi);
+}
+&lt;/script&gt;
+
+&lt;h1&gt;Install WebLock&lt;/h1&gt;
+
+&lt;p&gt;&lt;a href="#" onclick="installWebLock();"&gt;install weblock&lt;/a&gt;&lt;/p&gt;
+
+&lt;/html&gt;
+</pre>
+
+<h3 id="Distributing_Your_Component" name="Distributing_Your_Component">Distributing Your Component</h3>
+
+<p>Once you have the component packaged properly and the necessary installation and trigger scripts, you are ready to distribute your component so others can install it in their Gecko applications.</p>
+
+<p>In Mozilla and Netscape browsers, XPInstall makes this process especially easy by providing the file format (XPI) and the necessary installation scripts for doing a web-based installation. As <a href="#WebLock_Installation_Script">WebLock Installation Script</a> demonstrates, XPInstall uses special keywords to refer to common installation directories such as <code>components</code> in a generalized, cross-platform way.</p>
+
+<p>If you are installing <strong>WebLock</strong> in an Gecko-based application for which XPInstall is not available, then you will have to devise a separate installation scheme. We leave this as an exercise for the reader.</p>
+
+<ol>
+ <li><div class="blockIndicator note"><strong>Note:</strong> install-object-methods</div> The methods are available on the main <code>Install</code> object, which is implied in the script below in the same way that the <code>window</code> object is implied in JavaScript manipulation of the DOM of a web page. In other words, the fragment <code>initInstall()</code> from the script is equivalent to <code>Install.initInstall()</code>.</li>
+</ol>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Creating_XPCOM_Components:Building_the_WebLock_UI" style="float: left;">« 上一页</a><a href="/zh-CN/docs/创建_XPCOM_组件:建立_Gecko_SDK">下一页 »</a></p>
+</div><p></p><div class="licenseblock">
+<p>Copyright (c) 2003 by Doug Turner and Ian Oeschger. This material may be distributed only subject to the terms and conditions set forth in the <a class="external" href="http://www.opencontent.org/openpub/" rel="noopener">Open Publication License</a>, v1.02 or later. Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.</p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/preface/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/preface/index.html
new file mode 100644
index 0000000000..0710f0a701
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/preface/index.html
@@ -0,0 +1,83 @@
+---
+title: 前言
+slug: Mozilla/Tech/XPCOM/Guide/Creating_components/Preface
+tags:
+ - XPCOM
+ - 所有分类
+translation_of: Mozilla/Tech/XPCOM/Guide/Creating_components/Preface
+---
+<p> </p>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/创建_XPCOM_组件:XPCOM_简介">下一页 »</a></p>
+</div>这本书是关于 Gecko, 以及如何创建基于 Gecko 的 <a href="/cn/XPCOM" title="cn/XPCOM">XPCOM</a> 组件. 尽管本书的重点是放在把你的 C++ 代码制作成一个使用 Gecko 的组件的步骤之上, 我们还希望这个过程能够讨论到所有构建 XPCOM 的相关工具, 技巧和技术. 因此本书的安排上是作为一个参考书, 使读者能够自己创建组件, 学习不同的 XPCOM 内容. 比如说, 导言中包含了什么是组件的讨论; 第一章中你可以编译基本的源码并注册到 Mozilla 中, 由此讨论了组件于模块之间的关系, 以及一般的注册过程.<p></p>
+
+<p>每章的开始会给出这一章的主要内容. Sidebar sections are included to highlight technical details. 在本书的结尾, 如果能够达到本书的目的的话, 读者应该学会如何创建一个组件, Gecko 中的 XPCOM 组件框架.</p>
+
+<h3 id=".E8.B0.81.E8.AF.A5.E8.AF.BB.E8.BF.99.E6.9C.AC.E4.B9.A6" name=".E8.B0.81.E8.AF.A5.E8.AF.BB.E8.BF.99.E6.9C.AC.E4.B9.A6">谁该读这本书</h3>
+
+<p><a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6" title="cn/创建_XPCOM_组件">创建 XPCOM 组件</a> 是为 C++ 开发人员而写. 尽管你可能会使用 <a href="/cn/JavaScript" title="cn/JavaScript">JavaScript</a>, <a href="/cn/C" title="cn/C">C</a> 或其他的语言来创建 XPCOM 组件, 组件管理的实现是采用 C++, 许多关于如何创建 XPCOM 组件的讨论也是从 C++ 语言开始的. 然而并不要求读者是一个 C++ 语言的专家, 你需要了解的是基本的 C++ 继承和封装的思想, 我们在书中将尽可能的解释这些 C++ 语言的特性的使用. 由于 Mozilla 使用 JavaScript 脚本语言来访问 XPCOM 组件, 所以熟悉 JavaScript 会很有帮助.</p>
+
+<p>XPCOM 是 Cross Platform Component Object Model (跨平台组件模型)的缩写. 就象它的名字暗示的, XPCOM 类似于 Microsoft 的 COM. 开发 MS COM 的经验大多都可以被应用到 XPCOM. 然而本书假设读者对 COM 一无所知, 本书将包含关于 COM 基本思想的介绍.</p>
+
+<p>本书将描述一个控制浏览动作的 XPCOM 组件的制作过程. 尽管 XPCOM 的多数应用环境与 web 浏览并没有关系, 但是 XPCOM 现在的主要客户应用是 Gecko, 一个开源的, 遵循标准的嵌入式 web 浏览器, 所以它是最简单的, 而且是最实用的展示 XPCOM 功能的例子. 本教程中关于组件的详细描述在这里 <a href="/cn/Creating_XPCOM_Components/Creating_the_Component_Code#What_We.27ll_Be_Working_On" title="cn/Creating_XPCOM_Components/Creating_the_Component_Code#What_We.27ll_Be_Working_On">What We'll Be Working On</a>.</p>
+
+<h3 id=".E6.9C.AC.E6.95.99.E7.A8.8B.E7.9A.84.E7.BB.84.E7.BB.87" name=".E6.9C.AC.E6.95.99.E7.A8.8B.E7.9A.84.E7.BB.84.E7.BB.87">本教程的组织</h3>
+
+<p>下面的列表给出了编制一个称为 <strong>WebLock</strong> 的 XPCOM 组件的整体步骤, 这个组件向基于 Gecko 的浏览器提供了阻止网站访问的功能. 每个步骤都有各自的章节, 在各个章节中会讨论相关的内容.</p>
+
+<ul>
+ <li>创建组件的通用模块.</li>
+ <li>使用 C++ 宏, 特殊的字符串类以及智能指针来优化代码.</li>
+ <li>为组件定义功能; 为这个功能创建一个 <a href="/cn/XPIDL" title="cn/XPIDL">XPIDL</a> 接口; 生成实现代码, 规格定制的 <strong>WebLock</strong> 接口.</li>
+ <li>完整实现 <strong>WebLock</strong> 组件: <code>nsIContentPolicy</code>, 文件 I/O, 加锁等.</li>
+ <li>创建 WebLock 组件用户接口.</li>
+ <li>为发布和安装 <strong>WebLock</strong> 打包.</li>
+</ul>
+
+<h3 id=".E6.8C.89.E7.85.A7.E4.BE.8B.E5.AD.90.E6.9D.A5.E5.AD.A6.E4.B9.A0" name=".E6.8C.89.E7.85.A7.E4.BE.8B.E5.AD.90.E6.9D.A5.E5.AD.A6.E4.B9.A0">按照例子来学习</h3>
+
+<p>安装 XPCOM 到本地机器上的方法有很多, 如果你已经编译了 Mozilla 1.2 或更高的版本源码, 你就已经有了 XPCOM 框架. 如果你还没有下载 Mozilla 源码, 更简单的方法是下载 Gecko SDK, 它包含了 XPCOM 组件框架的库和工具.</p>
+
+<p>如果有了上面的工具, 你就可以编译自己的组件, 并把这个组件添加到 Gecko 库中. 我们这里讨论的 <strong>WebLock</strong> 组件是一个实用的浏览器扩展, 编译它需要 1.2 或更高版本的 Gecko SDK / Mozilla 源码.</p>
+
+<p>本书假设你使用的是 SDK, 下载 SDK, 编译, 和获取可用于编成的 Gecko 组件的方法在本书的附录, <a href="/cn/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6/%E5%BB%BA%E7%AB%8B_Gecko_SDK" title="cn/创建_XPCOM_组件/建立_Gecko_SDK">建立 Gecko SDK</a>.</p>
+
+<h3 id=".E6.9C.AC.E4.B9.A6.E7.9A.84.E4.BD.93.E4.BE.8B" name=".E6.9C.AC.E4.B9.A6.E7.9A.84.E4.BD.93.E4.BE.8B">本书的体例</h3>
+
+<p>下面列出的是格式化文档的习惯,他们用于本书中特定的信息类型并且让信息检索变得简单。目标是使用尽量少的格式类型,同时能辨别不同的信息类型。</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Format</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><strong>bold</strong></td>
+ <td><strong>component names</strong> 显示为粗题文字</td>
+ </tr>
+ <tr>
+ <td><code>monospace</code></td>
+ <td><code>code listings</code>, <code>interface names</code> 和 <code>members</code> of interfaces (e.g., <code>createInstance()</code>) 用monospaced 字体表达. 代码行放在不同的box内. 此外, <code>filenames</code> 和 <code>directories</code> 也用 monospaced 字体.</td>
+ </tr>
+ <tr>
+ <td><em>italic</em></td>
+ <td><em>variables</em> appear in italic. 重要的条目和新的概念第一次在文本中出现的时候也应该是斜体字。这些条目通常会立刻有进一步的解释,或者读者可以在本书的某个地方找到详细的解释。</td>
+ </tr>
+ <tr>
+ <td>link</td>
+ <td>References to other sections and to figures and tables are links to those sections.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id=".E8.87.B4.E8.B0.A2" name=".E8.87.B4.E8.B0.A2">致谢</h3>
+
+<p>Thanks to Peter Lubczynski, John Gaunt, Ellen Evans, and Alec Flett for technical reviews. A special thanks goes to Darin Fisher for his very acute observations, close reading, and attention to detail. </p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/创建_XPCOM_组件:XPCOM_简介">下一页 »</a></p>
+</div><p></p><div class="licenseblock">
+<p>Copyright (c) 2003 by Doug Turner and Ian Oeschger. This material may be distributed only subject to the terms and conditions set forth in the <a class="external" href="http://www.opencontent.org/openpub/" rel="noopener">Open Publication License</a>, v1.02 or later. Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.</p>
+</div><p></p>
+
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/resources/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/resources/index.html
new file mode 100644
index 0000000000..b23e6eb4c2
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/resources/index.html
@@ -0,0 +1,10 @@
+---
+title: 资源
+slug: Mozilla/Tech/XPCOM/Guide/Creating_components/Resources
+translation_of: Mozilla/Tech/XPCOM/Guide/Creating_components/Resources
+---
+<p><a href="cn/Link_title">Link title</a>
+ <i>
+ Italic text</i>
+</p>
+<pre class="script">Insert formula here</pre>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/setting_up_the_gecko_sdk/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/setting_up_the_gecko_sdk/index.html
new file mode 100644
index 0000000000..3e8c8516e2
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/setting_up_the_gecko_sdk/index.html
@@ -0,0 +1,204 @@
+---
+title: 建立 Gecko SDK
+slug: Mozilla/Tech/XPCOM/Guide/Creating_components/Setting_up_the_Gecko_SDK
+tags:
+ - XPCOM
+ - 所有分类
+translation_of: Mozilla/Tech/XPCOM/Guide/Creating_components/Setting_up_the_Gecko_SDK
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Creating_XPCOM_Components:Packaging_WebLock" style="float: left;">« 上一页</a><a href="/zh-CN/docs/Creating_XPCOM_Components:Resources">下一页 »</a></p>
+</div><p></p>
+
+<p>这一章提供建立 Gecko SDK 的基本方法, 下面会告诉开发人员如何下载和组织 Gecko SDK, 如何象 <em>WebLock</em> 一样创建一个新的组件工程.</p>
+
+<h3 id=".E4.B8.8B.E8.BD.BD.E5.92.8C.E5.BB.BA.E7.AB.8B_SDK" name=".E4.B8.8B.E8.BD.BD.E5.92.8C.E5.BB.BA.E7.AB.8B_SDK">下载和建立 SDK</h3>
+
+<p>Gecko SDK 提供了编译 XPCOM 组件所需要的所有的工具, 头文件和库. SDK 现在有 Windows 和 Linux 两个版本, 其他操作系统上的 SDK 正在开发. SDK 在下面的地址下载:</p>
+
+<ul>
+ <li>Linux: <a class="external" href="http://ftp.mozilla.org/pub/mozilla/releases/mozilla1.4a/gecko-sdk-i686-pc-linux-gnu-1.4a.tar.gz" rel="freelink">http://ftp.mozilla.org/pub/mozilla/r...nu-1.4a.tar.gz</a></li>
+ <li>Windows: <a class="external" href="http://ftp.mozilla.org/pub/mozilla/releases/mozilla1.4a/gecko-sdk-win32-1.4a.zip" rel="freelink">http://ftp.mozilla.org/pub/mozilla/r...win32-1.4a.zip</a></li>
+</ul>
+
+<p>注意版号要大于1.4a. 可以在下面的地址获取更新的 SDK 版本 <a class="external" href="http://ftp.mozilla.org/pub/mozilla/releases/" rel="freelink">http://ftp.mozilla.org/pub/mozilla/releases/</a>.</p>
+
+<p>一旦你下载了SDK, 你可以解压缩到任何合适的目录. 在本附录中, 我们建立Windows Gecko SDK 到 <code>c:\gecko-sdk\</code>. 如果你选择其他的位置, 记得调整这里描述的设置指向这个位置(e.g., in the <a href="#建立一个Microsoft_visual_cpp工程">建立一个Microsoft visual cpp工程</a> 章节) .</p>
+
+<p>当你解压缩SDK,它的目录结构看起来应该是:</p>
+
+<p><span id="Layout_of_the_Extracted_SDK"><a id="Layout_of_the_Extracted_SDK"></a><strong>Layout of the Extracted SDK</strong></span></p>
+
+<p><img alt="Image:sdk-layout.png" class="internal" src="/@api/deki/files/2682/=Sdk-layout.png"></p>
+
+<p>目录分别代表SDK中的不同模块。例如网络通讯的所有头文件放在<code>necko</code>目录中,而所有XPCOM需要的头文件则放在 XPCOM 目录中。 这个目录结构使得编译脚本变得比较复杂(因为会产生很多include路径)但是他帮助把SKD的部分组织得更有条例。</p>
+
+<p>两组顶级头文件是比较特别的。<code>mozilla-config.h</code>列出了SDK中使用的所有define,在你的文件中包含着个头文件会保证你创建的组件和Gecko库使用的相同的define。注意<code>mozilla-config.h</code>可能需要在你的组件代码中第一个被include.</p>
+
+<p>每一个模块的目录都分成三个子目录:</p>
+
+<p><span id="Module_Subdirectories"><a id="Module_Subdirectories"></a><strong>Module Subdirectories</strong></span></p>
+
+<p><img alt="Image:module-directory-subdirs.png" class="internal" src="/@api/deki/files/2669/=Module-directory-subdirs.png"></p>
+
+<p><code>bin</code>目录包含了静态库,动态库, 和一些可能会在开发中使用的tools。<code>idl</code>目录包含了模块所公开的公共的IDL文件。<code>includes</code>目录包含了你的组件使用的C++头文件。</p>
+
+<p>现在我们应该提到XPCOM公开的一组二进制代码文件。下面的列表罗列了可执行的Windows文件名:</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Application Name</td>
+ <td class="header">Description of functionality</td>
+ </tr>
+ <tr>
+ <td><code>regxpcom.exe</code></td>
+ <td>Registers or Unregisters components with XPCOM</td>
+ </tr>
+ <tr>
+ <td><code>xpidl.exe</code></td>
+ <td>Generates typelib and C++ headers from XPIDL</td>
+ </tr>
+ <tr>
+ <td><code>xpt_dump.exe</code></td>
+ <td>Prints out information about a given typelib</td>
+ </tr>
+ <tr>
+ <td><code>xpt_link.exe</code></td>
+ <td>Combines multiple typelibs into a single typelib</td>
+ </tr>
+ </tbody>
+</table>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Library Name</td>
+ <td class="header">Description of functionality</td>
+ </tr>
+ <tr>
+ <td><code>xpcomglue.lib</code></td>
+ <td>XPCOM Glue library to be used by xpcom components.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id=".E7.BC.96.E8.AF.91.E4.B8.80.E4.B8.AA_Microsoft_Visual_Cpp_.E5.B7.A5.E7.A8.8B" name=".E7.BC.96.E8.AF.91.E4.B8.80.E4.B8.AA_Microsoft_Visual_Cpp_.E5.B7.A5.E7.A8.8B">编译一个 Microsoft Visual Cpp 工程</h3>
+
+<p>一担你建立了Gecko SDK,你可以创建一个Miscrosoft visual c++项目来处理你基于SDK的组件开发。</p>
+
+<h4 id=".E5.88.9B.E5.BB.BA.E4.B8.80.E4.B8.AA.E6.96.B0.E7.9A.84.E5.B7.A5.E7.A8.8B" name=".E5.88.9B.E5.BB.BA.E4.B8.80.E4.B8.AA.E6.96.B0.E7.9A.84.E5.B7.A5.E7.A8.8B">创建一个新的工程</h4>
+
+<p>启动Visual c++以后,从文件菜单重选择new。然后在新建对话框中选择"Win32 Dynamic-Link Library"。 使用对话框右边的栏目输入你的项目和位置。(这个例子使用了 "SampleGeckoProject"作为问兼并,位置是<code>C:\</code> ).</p>
+
+<p><span id="New_Dialog"><a id="New_Dialog"></a><strong>New Dialog</strong></span></p>
+
+<p><img alt="Image:new-vcpp-project.png" class="internal" src="/@api/deki/files/2671/=New-vcpp-project.png"></p>
+
+<p>选择OK. 在出现的Win32 Dynamic-Link Library 对话框里, 你可以选择缺省的 "An Empty DLL Project" 作为DLL的类型.</p>
+
+<p><img alt="Image:vcpp-dll-dialog.png" class="internal" src="/@api/deki/files/2690/=Vcpp-dll-dialog.png"></p>
+
+<p>选择Finish. Microsoft Studio 将根据你的设定建立一个新的项目并且展开项目开发视图。</p>
+
+<h4 id=".E6.8A.8A_Gecko_SDK_.E6.B7.BB.E5.8A.A0.E5.88.B0.E5.B7.A5.E7.A8.8B.E8.AE.BE.E7.BD.AE" name=".E6.8A.8A_Gecko_SDK_.E6.B7.BB.E5.8A.A0.E5.88.B0.E5.B7.A5.E7.A8.8B.E8.AE.BE.E7.BD.AE">把 Gecko SDK 添加到工程设置</h4>
+
+<p>为了build使用Gecko的所有信息,你还需要进一步修改项目使得它知道在哪里取得Gecko SDK。为了编辑项目设置, 从项目菜单种选择Settings (or press Alt-F7).</p>
+
+<p>大部分你在下面步骤中所做的修改方法都适用于所有项目设置的修改(包括Debug和Optimize)。选择从Setting菜单中选择"All Configurations",出现一个下拉菜单:</p>
+
+<p><img alt="Image:vcpp-project-settings.png" class="internal" src="/@api/deki/files/2692/=Vcpp-project-settings.png"></p>
+
+<p>在C/C++ tab,选择Preprocessor组。在这个窗口里你要添加到Gecko SDK的include路径,以及两个 preprocessor defines:</p>
+
+<ul>
+ <li><code>XPCOM_GLUE</code></li>
+ <li><code>MOZILLA_STRICT_API</code></li>
+</ul>
+
+<p>最起码你要加上include <code>nspr</code>, <code>embedstring</code> 和 <code>string</code> <code>include</code>目录, 和<code>xpcom</code> <code>include</code> 子目录. 如果你的组件适用其他SDK的部分(例如Necko), 你也要添加指向他们的路径.</p>
+
+<p>假定你使用例子项目的路径,这些路径看起来会是:</p>
+
+<ul>
+ <li><code>c:\gecko-sdk\embedstring\include</code></li>
+ <li><code>c:\gecko-sdk\xpcom\include</code></li>
+ <li><code>c:\gecko-sdk\nspr\include</code></li>
+ <li><code>c:\gecko-sdk\string\include</code></li>
+</ul>
+
+<p><img alt="Image:vcpp-project-settings-includes.png" class="internal" src="/@api/deki/files/2691/=Vcpp-project-settings-includes.png"></p>
+
+<p>在C++ language组, 禁止异常处理. 正如在 <a href="/cn/XPCOM%E6%A6%82%E8%A7%88/XPCOM%E4%B8%AD%E7%9A%84%E5%BC%82%E5%B8%B8" title="cn/XPCOM概览/XPCOM中的异常">XPCOM中的异常</a>章节所表明的, 异常处理不支持跨越Interface, 所以使用这个功能将可能在开发中引起问题。</p>
+
+<p><strong>WebLock</strong> 组件需要引用必要的库文件以使用XPCOM Glue. 为添加这些库文件,选择Link tab, 然后选择Input category. 在这个面板上不要连接到 <code>nspr</code>, <code>embedstring</code>和<code>xpcom</code>中的子目录<code>include</code> ,而改用<code>bin</code>子目录.</p>
+
+<p>我们也会连接到一些Object/library 模块中的库:</p>
+
+<ul>
+ <li><code>nspr4.lib</code></li>
+ <li><code>plds4.lib</code></li>
+ <li><code>plc4.lib</code></li>
+ <li><code>embedstring.lib</code></li>
+ <li><code>xpcomglue.lib</code></li>
+</ul>
+
+<p>这些设定看起来会是:</p>
+
+<p><img alt="Image:vcpp-project-settings.png" class="internal" src="/@api/deki/files/2692/=Vcpp-project-settings.png"></p>
+
+<p>最后一个你需要让Gecko SDK在你的项目中设定成功的修改是"Use run-time library" 设定为 "Multithreaded DLL." 因为这个设置是根据其他设定而确定的,你<strong>必须设定Release configuration run-time library 为 release multithreaded DLL runtime, 并且Debug configuration 设定为 the debug multithreaded dll runtime</strong> (这个需要澄清一下):</p>
+
+<p><img alt="Image:vcpp-runtime-settings.png" class="internal" src="/@api/deki/files/2693/=Vcpp-runtime-settings.png"></p>
+
+<p>完成所有这些设定后,选择OK. 这就完成了项目设定并且让你的项目能包含和编译XPCOM组件.</p>
+
+<h3 id="Unix_.E4.B8.8B.E7.9A.84.E4.B8.80.E4.B8.AA_Makefile" name="Unix_.E4.B8.8B.E7.9A.84.E4.B8.80.E4.B8.AA_Makefile">Unix 下的一个 Makefile</h3>
+
+<p>Linux 下不采用工程而采用 <code>Makefile</code> 来组织代码. <code>Makefile</code> 中放置编译环境中的编译选项, 包括使用 Gecko SDK 编译的路径和配置更新等.</p>
+
+<p>下面是一个使用 SDK 来编译的 <code>Makefile</code>, 这里对 <code>Makefile</code> 的详细用法不做解释. 它与 Visual C++ 的工程(<a href="#Building_a_Microsoft_Visual_Cpp_Project">Building a Microsoft Visual Cpp Project</a>)相类似, 关于 Makefile 的命令请参看 <a class="external" href="http://www.gnu.org/manual/make/">Make 手册</a>.</p>
+
+<p><span id="Gecko_SDK_%E4%B8%8B%E7%9A%84%E4%B8%80%E4%B8%AA_Makefile_%E4%BE%8B%E5%AD%90"><a id="Gecko_SDK_%E4%B8%8B%E7%9A%84%E4%B8%80%E4%B8%AA_Makefile_%E4%BE%8B%E5%AD%90"></a><strong>Gecko SDK 下的一个 Makefile 例子</strong></span></p>
+
+<pre>CXX = c++
+
+CPPFLAGS += -fno-rtti \
+ -fno-exceptions \
+ -shared
+
+# Change this to point at your Gecko SDK directory.
+GECKO_SDK_PATH = /home/dougt/gecko-sdk
+
+# GCC only define which allows us to not have to #include mozilla-config
+# in every .cpp file. If your not using GCC remove this line and add
+# #include "mozilla-config.h" to each of your .cpp files.
+GECKO_CONFIG_INCLUDE = -include mozilla-config.h
+
+GECKO_DEFINES = -DXPCOM_GLUE -DMOZILLA_STRICT_API
+
+GECKO_INCLUDES = -I $(GECKO_SDK_PATH) \
+ -I $(GECKO_SDK_PATH)/xpcom/include \
+ -I $(GECKO_SDK_PATH)/nspr/include \
+ -I $(GECKO_SDK_PATH)/string/include \
+ -I $(GECKO_SDK_PATH)/embedstring/include
+
+GECKO_LDFLAGS = -L $(GECKO_SDK_PATH)/xpcom/bin -lxpcomglue \
+ -L $(GECKO_SDK_PATH)/nspr/bin -lnspr4 \
+ -L $(GECKO_SDK_PATH)/nspr/bin -lplds4 \
+ -L $(GECKO_SDK_PATH)/embedstring/bin/ -lembedstring
+
+build:
+ $(CXX) -o MozShim.so $(GECKO_CONFIG_INCLUDE) $(GECKO_DEFINES) $(GECKO_INCLUDES) $(GECK\
+O_LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) MozShim.cpp
+ chmod +x MozShim.so
+
+clean:
+ rm MozShim.so
+</pre>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Creating_XPCOM_Components:Packaging_WebLock" style="float: left;">« 上一页</a><a href="/zh-CN/docs/Creating_XPCOM_Components:Resources">下一页 »</a></p>
+</div> <p></p><div class="licenseblock">
+<p>Copyright (c) 2003 by Doug Turner and Ian Oeschger. This material may be distributed only subject to the terms and conditions set forth in the <a class="external" href="http://www.opencontent.org/openpub/" rel="noopener">Open Publication License</a>, v1.02 or later. Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.</p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/starting_weblock/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/starting_weblock/index.html
new file mode 100644
index 0000000000..65efd53a72
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/starting_weblock/index.html
@@ -0,0 +1,1104 @@
+---
+title: 开始WebLock
+slug: Mozilla/Tech/XPCOM/Guide/Creating_components/Starting_WebLock
+tags:
+ - XPCOM
+ - 所有分类
+translation_of: Mozilla/Tech/XPCOM/Guide/Creating_components/Starting_WebLock
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Creating_XPCOM_Components:Using_XPCOM_Utilities_to_Make_Things_Easier" style="float: left;">« 上一页</a><a href="/zh-CN/docs/Creating_XPCOM_Components:Finishing_the_Component">下一页 »</a></p>
+</div><p></p>
+
+<p>在本章,我们开始设计和实现网络锁定功能本身。我们已经建立了实现多数通用组件功能的模块(例如注册)。这章将关注实际操作网页锁定的功能。</p>
+
+<h3 id="Getting_Called_at_Startup" name="Getting_Called_at_Startup">Getting Called at Startup</h3>
+
+<p>没有人是一个孤岛,组件也一样。你所建立的例子组件到目前为止还没有任何功能。当他被注册以后,他没做任何事情。</p>
+
+<p>为了当某些事件发生的时候被启动或者通知到,例子组件需要挂接到Mozilla,或者覆盖一个现存组件,或者注册到一些事件上面。<strong>WebLock</strong>用后面的方式在Gecko Profile Startup发生的时候被调用。当Gecko应用启动的时候,注册的组件被创建或者通过通用观察者接口被提醒<code>nsIObserver</code>。</p>
+
+<p><em>Observer</em>是一些对象,他们当特定的事件发生的时候被通知。使用这种机制提供了一个相互不必了解而可以在对象之间传送信息的机制。</p>
+
+<p>通常,一个对象会通知一系列观察者。例如一个对象被创建的时候它的<code>observe</code>方法被调用,或者它可以注册当XPCOM关闭的时候被通知。这个接口的核心是<code>observe</code>方法。</p>
+
+<pre>void observe(in nsISupports aSubject,
+ in string aTopic,
+ in wstring aData);
+</pre>
+
+<p>实际上ovserver方法的参数没有什么限制。这些参数根据事件的类型变化。例如,XPCOM关闭的时候,aSubject和aData被定义,aTopic被定义为“xpcom-shotdown’,如果你的对象希望注册到这些事件上面,他首先要实现nsIObserver接口,一旦你完成这些,实现nsIObserverService的observer服务将会利用接口通知你的对象,如下所示:</p>
+
+<p><span id="The_Observer_Interfaces"><a id="The_Observer_Interfaces"></a><strong>The Observer Interfaces</strong></span></p>
+
+<p><img alt="Image:observation-overview.png"></p>
+
+<p>上图表现了observer服务管理了所有<code>nsIObserver</code>对象的列表. 当通知产生的时候,<code>nsIObserverService</code>把呼叫者从<code>NotifyObserver()</code>发送出的消息传送给<code>nsIObserver</code>的<code>Observe()</code>方法。这是一个让不同的类解藕的办法。<code>nsIObserver</code>是一个通用的接口,用来在两个或多个对象间传递信息,而不必定义一个特定的冻结接口,它也是XPCOM建立扩展的一个方式。</p>
+
+<p>WebLock组件对<code>nsIObserver</code>接口的实现和对<code>nsIFactory</code>接口是类似的。<span class="comment">XXX what is Example 2?</span>下面的例子2中,你改变一个类的定义为支持<code>nsIObserver</code>接口并且改变<code>NS_IMPL_ISUPOORTS1</code>,从而<code>QueryInterface</code>实现知道组件也支持<code>nsIObserver</code>。启动的时候被通知的<code>WebLock</code>类定义如下:</p>
+
+<pre>class WebLock: public nsIObserver {
+ public:
+ WebLock();
+ virtual ~WebLock();
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIOBSERVER
+};
+
+NS_IMPL_ISUPPORTS1(WebLock, nsIObserver);
+</pre>
+
+<p><code>Observe()</code>最简单的实现仅仅是比较字符串<code>aTopic</code>和对象所接受事件所定义的值. 如果相匹配, 你可以按照你的方式处理事件. 如果对象仅仅注册到一个消息上, 那你可以忽略字符串 <code>aTopic</code> 而仅仅处理事件. 换句话说,对于对象所没有注册的事件,<code>Observe</code> 方法不应该被调用。</p>
+
+<pre>NS_IMETHODIMP
+WebLock::Observe(nsISupports *aSubject,
+ const char *aTopic,
+ const PRUnichar *aData)
+{
+ return NS_OK;
+}
+</pre>
+
+<p>从observer service来的消息可能是间接的. 直接获得来自observer service的消息的方法是初始化一个<code>nsIObserver</code> 对象. 大多数情况下这样是可以的,但是要注意当你通过这个消息建立组件的情况. 因为组件还没有被建立,所以不存在初始化的 <code>nsIObserver</code> 对象可以用来传递给 <code>nsIObserverService</code>, 组件代码在他被装载以前不能做什么.</p>
+
+<h4 id=".E6.B3.A8.E5.86.8C.E5.88.B0.E6.B6.88.E6.81.AF" name=".E6.B3.A8.E5.86.8C.E5.88.B0.E6.B6.88.E6.81.AF">注册到消息</h4>
+
+<p><code>nsIObserverService</code> 接口有处理注册和注销一个<code>nsIObserver</code>对象的方法. 这两个方法用来动态添加或者删除一个notification topic上的observer. 但是 <strong>WebLock</strong> 要被自动初始化和添加到observer service, 这就意味着需要一些数据持久化。(不管怎么说, 我们需要组件在程序每次启动的时候也启动).</p>
+
+<p>This is where a new service that manages sets of related data comes in handy. This service, the <code>nsICategoryService</code>, is what XPCOM and Gecko embedding applications use to persist lists of <code>nsIObserver</code> components that want to have startup notification.</p>
+
+<p>The <code>nsICategoryService</code> maintains sets of name-value pairs like the one below.</p>
+
+<p><span id="The_Category_Manager"><a id="The_Category_Manager"></a><strong>The Category Manager</strong></span></p>
+
+<p><img alt="Image:category-manager-table.png"></p>
+
+<p>Every category is identified by a string that represents the name of the category. Each category contains a set of name-value pairs. For example, you might have a category named "Important People" in which the name-value pairs would be names and phone numbers. The format of the name-value pair is left up to you.</p>
+
+<p>This data structure is more than enough to support the persisting of components that what to be started up. The category name also maps nicely onto the notion of a notification "topic." The topic name could be something like "xpcom-startup", for instance, and the name-value pair could contain the contract IDs required to create the components requesting startup. In fact, this is exactly how categories are used to handle registration with XPCOM for startup notification. You will see the code which does this in the next section.</p>
+
+<h4 id="Getting_Access_to_the_Category_Manager" name="Getting_Access_to_the_Category_Manager">Getting Access to the Category Manager</h4>
+
+<p>Two fields in the <code>nsModuleComponentInfo</code> structure introduced in the last section are addresses for registration and unregistration callbacks. The first callback is called when the component's <code>nsIModule::RegisterSelf</code> method is called. This callback allows the component to execute any one-time registration code it may need. The inverse of this function is the unregistration callback, where it's a good idea to undo whatever the registration function did. The two functions look like this:</p>
+
+<pre>static NS_METHOD
+WebLockRegistration(nsIComponentManager *aCompMgr,
+ nsIFile *aPath,
+ const char *registryLocation,
+ const char *componentType,
+ const nsModuleComponentInfo *info);
+
+static NS_METHOD
+WebLockUnregistration(nsIComponentManager *aCompMgr,
+ nsIFile *aPath,
+ const char *registryLocation,
+ const nsModuleComponentInfo *info);
+</pre>
+
+<p>The names of the functions can be anything you wish. Both functions are passed the Component Manager and the path to the component, including the opaque <code>registryLocation</code>. These are also parameters in the <code>nsIModule</code> implementation in <span class="comment">XXX what is Example 1? link to it here</span>Example 1. In addition to these parameters, the callback functions are passed the <code>nsModuleComponentInfo</code> struct, which is the same structure initially passed into <code>NS_IMPL_NSGETMODULE</code>.</p>
+
+<p>During registration, the registration callback is where you get the <code>nsICategoryManager</code>. Once you have it, you can add the component to the category of components that get started automatically. As a service, the <code>nsICategoryManager</code> is accessible via the <code>nsIServiceManager</code>. Also note that the <code>nsIComponentManager</code> is passed into the callback. Since the object that implements the <code>nsIComponentManager</code> interface also implements <code>nsIServiceManager</code>, all you have to do is <code>QueryInterface</code> the <code>nsIComponentManager</code> to <code>nsIServiceManager</code> to get the Service Manager. You can then use the Service Manager to add the component to the category:</p>
+
+<pre>nsresult rv;
+
+nsCOMPtr&lt;nsIServiceManager&gt; servman =
+ do_QueryInterface((nsISupports*)aCompMgr, &amp;rv);
+
+if (NS_FAILED(rv))
+ return rv;
+</pre>
+
+<div class="side-note">
+<p><span id="%3Ccode%3Edo_QueryInterface%3C/code%3E"><a id="%3Ccode%3Edo_QueryInterface%3C/code%3E"></a><strong><code>do_QueryInterface</code></strong></span></p>
+
+<p>The previous code uses the special <code>nsCOMPtr</code> function <code>do_QueryInterface</code> that lets you <code>QueryInterface</code> without having to worry about reference counting, error handling, and other overhead. The <code>do_QueryInterface</code> knows what interface to <abbr title="QueryInterface">QI</abbr> to based on the <code>nsCOMPtr</code> that is being assigned into. We could have just as easily have used the raw <code>QueryInterface()</code> method, but using <code>nsCOMPtr</code> is much more economical (see <a href="cn/Creating_XPCOM_Components/Using_XPCOM_Utilities_to_Make_Things_Easier#Smart_Pointers">Smart Pointers</a>).</p>
+</div>
+
+<p>Once you have a <code>nsIServiceManager</code> reference, you can ask it for the service you are interested in. This process is similar to using <code>CreateInstance</code> from the <code>nsIComponentManager</code>, but there is no aggregation parameter since the object has already been constructed.</p>
+
+<pre>nsCOMPtr&lt;nsICategoryManager&gt; catman;
+rv = servman-&gt;GetServiceByContractID(NS_CATEGORYMANAGER_CONTRACTID,
+ NS_GET_IID(nsICategoryManager),
+ getter_AddRefs(catman));
+if (NS_FAILED(rv))
+ return rv;
+</pre>
+
+<p>There are two service getters on the <code>nsIServiceManager</code> interface: one that takes a CID and another interface that takes a Contract ID. Here we'll use the latter. The first parameter to the <code>GetServiceByContractID</code> is of course the contract ID, which is defined in the <code>nsXPCOM.h</code> header file. The next parameter is a nifty macro that returns the IID for the interface name that you pass in. The last parameter assigns an out interface pointer to a <code>nsCOMPtr</code>. Assuming there weren't any unexpected errors, the variable <code>catman</code> holds the <code>nsICategoryManager</code> interface pointer, which you can use to add the component as a startup observer by calling a method on the <code>nsICategoryManager</code>.</p>
+
+<p>The next step is to figure out which parameters to pass to the method. There is a category name and a name-value pair, but since the name-value pair meaning is category-specific, you need to figure out which category to use.</p>
+
+<p>There are two startup notifications, both of which create the observer if it isn't already created. The first is provided by XPCOM. This notification will occur during initialization of XPCOM, where all XPCOM services are guaranteed to be available during the calls. Embedding applications may provide other notifications.</p>
+
+<p><span id="Common_XPCOM_Notifications"><a id="Common_XPCOM_Notifications"></a><strong>Common XPCOM Notifications</strong></span></p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Category</td>
+ <td class="header">Name</td>
+ <td class="header">Value</td>
+ <td class="header">Creates Component</td>
+ </tr>
+ <tr>
+ <td>xpcom-startup</td>
+ <td>Any</td>
+ <td>Contract ID</td>
+ <td>Yes</td>
+ </tr>
+ <tr>
+ <td>xpcom-shutdown</td>
+ <td>Any</td>
+ <td>Contract ID</td>
+ <td>No</td>
+ </tr>
+ <tr>
+ <td>xpcom-autoregistration</td>
+ <td>Any</td>
+ <td>Contract ID</td>
+ <td>No</td>
+ </tr>
+ <tr>
+ <td>app-startup</td>
+ <td>Any</td>
+ <td>service, Contract ID</td>
+ <td>*</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>The table above summarizes the popular persistent notifications registered through the category manager. The name of the category itself is a well defined string, but the name-value pairs can be anything.</p>
+
+<p>When naming your component in the category, take care to use something that means something and doesn't muddy up the namespace. In this case, "WebLock" is unique and provides context to anyone looking at the category. The value of the name-value part is expected to be the contract ID of the component.</p>
+
+<p>Since every category can define the name-value pairs, the application "app-startup" category can support not only services but component instances as well. For the app-startup notification, you must explicitly pass the string "service," prior to the component's Contract ID. If you do not, the component will be created and then released after the notification, which may cause the component to be deleted.</p>
+
+<p>In short, to register the <strong>WebLock</strong> component as an xpcom-startup observer, do the following:</p>
+
+<pre>char* previous = nsnull;
+rv = catman-&gt;AddCategoryEntry("xpcom-startup",
+ "WebLock",
+ WebLock_ContractID,
+ PR_TRUE, // persist category
+ PR_TRUE, // replace existing
+ &amp;previous);
+if (previous)
+ nsMemory::Free(previous); // free the memory the replaced value might have used
+</pre>
+
+<p>The unregistration, which should occur in the unregistration callback, looks like this:</p>
+
+<pre>rv = catman-&gt;DeleteCategoryEntry("xpcom-startup",
+ "WebLock",
+ PR_TRUE); // persist
+</pre>
+
+<p>A complete code listing for registering <strong>WebLock</strong> as a startup observer follows:</p>
+
+<pre>#define MOZILLA_STRICT_API
+
+#include "nsIGenericFactory.h"
+
+#include "nsCOMPtr.h"
+#include "nsXPCOM.h"
+#include "nsIServiceManager.h"
+#include "nsICategoryManager.h"
+
+#include "nsMemory.h"
+
+#include "nsIObserver.h"
+
+#include "nsEmbedString.h"
+
+#define WebLock_CID \
+{ 0x777f7150, 0x4a2b, 0x4301, \
+{ 0xad, 0x10, 0x5e, 0xab, 0x25, 0xb3, 0x22, 0xaa}}
+
+#define WebLock_ContractID "@dougt/weblock"
+
+class WebLock: public nsIObserver
+{
+ public:
+ WebLock();
+ virtual ~WebLock();
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIOBSERVER
+};
+
+WebLock::WebLock()
+{
+ NS_INIT_ISUPPORTS();
+}
+
+WebLock::~WebLock()
+{
+}
+
+NS_IMPL_ISUPPORTS1(WebLock, nsIObserver);
+
+NS_IMETHODIMP
+WebLock::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
+{
+ return NS_OK;
+}
+
+static NS_METHOD WebLockRegistration(nsIComponentManager *aCompMgr,
+ nsIFile *aPath,
+ const char *registryLocation,
+ const char *componentType,
+ const nsModuleComponentInfo *info)
+{
+ nsresult rv;
+
+ nsCOMPtr&lt;nsIServiceManager&gt; servman = do_QueryInterface((nsISupports*)aCompMgr, &amp;rv);
+ if (NS_FAILED(rv))
+ return rv;
+
+ nsCOMPtr&lt;nsICategoryManager&gt; catman;
+ rv = servman-&gt;GetServiceByContractID(NS_CATEGORYMANAGER_CONTRACTID,
+ NS_GET_IID(nsICategoryManager),
+ getter_AddRefs(catman));
+
+ if (NS_FAILED(rv))
+ return rv;
+
+ char* previous = nsnull;
+ rv = catman-&gt;AddCategoryEntry("xpcom-startup",
+ "WebLock",
+ WebLock_ContractID,
+ PR_TRUE,
+ PR_TRUE,
+ &amp;previous);
+ if (previous)
+ nsMemory::Free(previous);
+
+ return rv;
+}
+
+static NS_METHOD WebLockUnregistration(nsIComponentManager *aCompMgr,
+ nsIFile *aPath,
+ const char *registryLocation,
+ const nsModuleComponentInfo *info)
+{
+ nsresult rv;
+
+ nsCOMPtr&lt;nsIServiceManager&gt; servman = do_QueryInterface((nsISupports*)aCompMgr, &amp;rv);
+ if (NS_FAILED(rv))
+ return rv;
+
+ nsCOMPtr&lt;nsICategoryManager&gt; catman;
+ rv = servman-&gt;GetServiceByContractID(NS_CATEGORYMANAGER_CONTRACTID,
+ NS_GET_IID(nsICategoryManager),
+ getter_AddRefs(catman));
+ if (NS_FAILED(rv))
+ return rv;
+
+ rv = catman-&gt;DeleteCategoryEntry("xpcom-startup",
+ "WebLock",
+ PR_TRUE);
+
+ return rv;
+}
+
+NS_GENERIC_FACTORY_CONSTRUCTOR(WebLock)
+
+static const nsModuleComponentInfo components[] =
+{
+ {
+ "WebLock",
+ WebLock_CID,
+ WebLock_ContractID,
+ WebLockConstructor,
+ WebLockRegistration,
+ WebLockUnregistration
+ }
+};
+
+NS_IMPL_NSGETMODULE(WebLockModule, components)
+</pre>
+
+<h3 id="Providing_Access_to_WebLock" name="Providing_Access_to_WebLock">Providing Access to <strong>WebLock</strong></h3>
+
+<p>At this point, the component will be called when XPCOM starts up. <strong>WebLock</strong> has already implemented the <code>nsISupports</code>, <code>nsIFactory</code>, <code>nsIModule</code>, and <code>nsIObserver</code> interfaces that handle generic component functionality including being initialized at startup. And it speaks to the Component Manager, Service Manager, Category Manager, and the Component Registrar to register itself properly with XPCOM.</p>
+
+<p>The next step is to expose additional functionality to Gecko applications and other clients to query and control the <strong>WebLock</strong> component. For example, the user interface needs to be able to enable and disable the web locking functionality, see what sites are in the whitelist, and add or remove sites from that list. WebLock needs to provide an API, and it needs to hook into Gecko in order to implement the actual locking functionality.</p>
+
+<p>译: 下一步是expose另外的功能以使得Gecko应用以及其它clients查询和控制WebLock组件. 例如, user interface(用户接口)要有能力去允许或者禁止web locking(web锁定)功能, 查看哪些站点在白名单列表中, 并向列表中添加或移除站点. WebLock需要提供一个API并挂接到Gecko中进而实现实际的locking功能.</p>
+
+<div class="side-note">
+<p><span id="The_WebLock_User_Interface"><a id="The_WebLock_User_Interface"></a><strong>The WebLock User Interface</strong></span></p>
+
+<p>The <strong>WebLock</strong> component in this tutorial uses XUL to define the additional browser UI in a cross-platform way, and XUL uses JavaScript to access and control XPCOM components, but Gecko's pluggable UI allows any user interface to call into Gecko and the components you create as easily as you can from XUL. See <a href="cn/Creating_XPCOM_Components/Building_the_WebLock_UI#XUL">XUL</a> for a discussion of how XUL interacts with JavaScript and XPCOM.</p>
+
+<p>在这个教程中<strong>WebLock</strong>组件使用XUL来定义跨平台的浏览器UI, XUL使用JavaScript来访问和控制XPCOM组件, 但Gecko的可挂接UI也允许任何user interface调用Gecko和你所创建的组件, 就如同XUL一样容易. <a href="cn/Creating_XPCOM_Components/Building_the_WebLock_UI#XUL">XUL</a>讨论了XUL如何与JavaScript和XPCOM交互.</p>
+</div>
+
+<h3 id="Creating_the_WebLock_Programming_Interface" name="Creating_the_WebLock_Programming_Interface">Creating the WebLock Programming Interface</h3>
+
+<p>Design is one of the hardest parts of any programming problem. The question the interface for the <strong>WebLock</strong> component must answer is: How should <strong>WebLock</strong> look to the outside world? What, in other words, is the interaction of clients with the <strong>WebLock</strong> component? In this section, we enumerate the basic functionality the component should expose and create the single interface that organizes and provides this functionality.</p>
+
+<p>译: 设计是任何编程问题中最困难的部分之一. 问题是<strong>WebLock</strong>组件必须要回答一些问题: <strong>WebLock</strong>应该如何look to外面的世界? 换言之, 什么是clients与<strong>WebLock</strong>的交互? 在这部分列举了组件应该expose的基本功能和create一个组织和提供这些功能的接口.</p>
+
+<p>Instead of starting with the implementation, developers use XPIDL (see <a href="cn/Creating_XPCOM_Components/An_Overview_of_XPCOM#XPIDL_and_Type_Libraries">XPIDL and Type Libraries</a> for more information about XPIDL) to define the interface to the component: how the functionality should be organized, expressed, and exposed to its clients.</p>
+
+<p>译: 开发人员应该使用XPIDL(see <a href="cn/Creating_XPCOM_Components/An_Overview_of_XPCOM#XPIDL_and_Type_Libraries">XPIDL and Type Libraries</a> for more information about XPIDL)为组件定义接口(定义功能应该如何被组织, 描述和暴露给它的clients)做为开始, 而不应该从实现开始.</p>
+
+<p>In general, the <strong>WebLock</strong> service interface needs to include the following functionality:</p>
+
+<p>译: 通常, <strong>WebLock</strong>服务接口要包括以下功能:</p>
+
+<ul>
+ <li><code>Lock</code> - Enable web locking so that any browser in the Gecko application is restricted to the white list of website domains.</li>
+</ul>
+
+<p>        译: <code>Lock</code> - 允许web locking, 这样任何Gecko应用中的浏览器被限定只能访问白名单中的web站点域.</p>
+
+<ul>
+ <li><code>Unlock</code> - Disable web locking. This should allow any browser in the Gecko application to browse any website regardless of the white list.</li>
+</ul>
+
+<p>        译: <code>Unlock</code> - 禁止web locking. 允许Gecko应该中的浏览器访问任何web站点, 而不去管白名单列表.</p>
+
+<ul>
+ <li><code>AddSite</code> - Add the current URL to the white list.</li>
+</ul>
+
+<p>        译: <code>AddSite</code> - 添加当前URL到白名单列表.</p>
+
+<ul>
+ <li><code>RemoveSite</code> - Remove the current URL from the white list.</li>
+</ul>
+
+<p>        译: <code>RemoveSite</code> - 从白名单列表中移除当前URL.</p>
+
+<ul>
+ <li><code>EnumerateSites</code> - Allows the enumeration of all sites in the white list. <code>EnumerateSites</code> might be used in the user interface to provide something like an editable listbox of all sites in the white list.</li>
+</ul>
+
+<p>        译: <code>EnumerateSites</code> - 允许列举出所有白名单中的站点. <code>EnumerateSites</code>可能会被user         interface(用户接口/用户界面)所提供的例如显示所有白名单列表的可编辑列表框控件所使用.</p>
+
+<p>Even this simple outline presents some ambiguity, however. It's certainly not enough to spell out the interface for the <strong>WebLock</strong> component in this way. For example, <code>AddSite</code> is supposed to add the current URL to the white list, but is the URL an input parameter to the method, is it the topmost web page in the Gecko application, or is it something more random-a URL picked from global history or that's been given context in some other way?</p>
+
+<p>As a strongly typed and implementation-agnostic language, XPIDL requires that you be quite specific about the APIs, the list of parameters, their order, and their types. XPIDL requires that you spell it all out, in other words. And it's this formality that makes the interfaces in XPCOM effective contracts between services and clients.</p>
+
+<p>The next section shows the interface of the <strong>WebLock</strong> component, <code>iWebLock</code>, in XPIDL. Once the interface has been described in the XPIDL language, the interface file can be used to generate the header files needed for the implementation code, the binary type library files that let you use the interface of the <strong>WebLock</strong> component from JavaScript, and even <span class="comment">broken link</span><a href="cn/Javadoc">javadoc</a> style HTML documentation.</p>
+
+<h3 id="Defining_the_Weblock_Interface_in_XPIDL" name="Defining_the_Weblock_Interface_in_XPIDL">Defining the <strong>Weblock</strong> Interface in XPIDL</h3>
+
+<p>Most interfaces in the XPCOM world are described in XPIDL. The XPIDL file for the <code>iWebLock</code> interface can be used to generate the C++ header file, which you'll need to implement the interface in the component and also a type library that makes the component accessible from JavaScript or other interpreted languages. In Mozilla, JavaScript is the bridge between components and the XUL-based user interface.</p>
+
+<p>译: 在XPCOM世界里大多数接口都是用XPIDL描述的. <code>iWebLock</code>接口的XPIDL文件可以被用来生成C++ header file(你需要它来在组件中实现接口和用来使组件在JavaScript和其它的解译型语言中可访问的类型库). 在Mozilla中, JavaScript是组件与基于XUL的user interface之间的桥梁.</p>
+
+<p>The XPIDL Syntax (XPIDL语法)</p>
+
+<p>The XPIDL syntax is a mix of C++ and Java, and of course it's very much like the OMG IDL upon which it is closely based. The XPIDL for <code>iWebLock</code> appears below:</p>
+
+<p><span id="iWebLock"><a id="iWebLock"></a><strong>iWebLock</strong></span></p>
+
+<pre>#include "nsISupports.idl"
+interface nsISimpleEnumerator;
+[scriptable, uuid(ea54eee4-9548-4b63-b94d-c519ffc91d09)]
+interface iWeblock : nsISupports
+{
+ void lock();
+ void unlock();
+
+ // assume strings are UTF-8
+ void addSite(in string url);
+ void removeSite(in string url);
+ attribute nsISimpleEnumerator sites;
+};
+</pre>
+
+<p>The first line includes the file <code>nsISupports.idl</code>, which defines the <code>nsISupports</code> interface from which all XPCOM interfaces must derive, and makes it possible for the <code>iWebLock</code> interface to subclass that base interface.</p>
+
+<pre>#include "nsISupports.idl"
+</pre>
+
+<p>The next line of the XPIDL is a forward declaration of the interface <code>nsISimpleEnumerator</code>. Again, this is similar to the forward declare in C++ (except that C++ does not have the <code>interface</code> keyword seen here).</p>
+
+<pre>interface nsISimpleEnumerator;
+</pre>
+
+<p>See the <a href="cn/Creating_XPCOM_Components/Resources#XPCOM_Resources">XPCOM resources</a> for more information about the XPIDL syntax.</p>
+
+<h4 id="Scriptable_Interfaces" name="Scriptable_Interfaces">Scriptable Interfaces</h4>
+
+<p>The third line in <a href="#iWebLock">iWebLock</a> is more complex. The first thing it says is that <code>iWebLock</code> will be<em>scriptable</em> .</p>
+
+<pre>[scriptable, uuid(ea54eee4-9548-4b63-b94d-c519ffc91d09)]
+</pre>
+
+<p>The rest of the line provides a UUID for this interface. Recall that every interface has a unique number that is assigned to it. In the case of interfaces, the identifier is an IID. In the case of the components, which also require unique identifiers, the identifier is the CID.</p>
+
+<h4 id="Subclassing_nsISupports" name="Subclassing_nsISupports">Subclassing <code>nsISupports</code></h4>
+
+<p>The next line in <a href="#iWebLock">iWebLock</a> names the interface and defines its base interface. <code>iWeblock</code> derives from <code>nsISupports</code>. XPIDL has no way to define multiple inheritance - something that all scriptable objects must deal with.</p>
+
+<pre>interface iWebLock : nsISupports
+</pre>
+
+<h4 id="The_Web_Locking_Interface" name="The_Web_Locking_Interface">The Web Locking Interface</h4>
+
+<p>The body of the block (the stuff between the curly braces) defines the methods and attributes of our interface. There are basically two functional sets on this interface. The first section of the interface controls whether or not <strong>WebLock</strong> checks to see if a web page can be loaded. If locked, <strong>WebLock</strong> will prevent sites not on the white list from loading.</p>
+
+<pre> void lock();
+ void unlock();
+</pre>
+
+<p>This interface does not enforce any policy with respect to how the user enables or disables this feature. This allows maximum flexibility in the implementation. Any place in the application can acquire this interface via the Service Manager and call <code>unlock</code> or <code>lock</code>. For example, the user interface may bring up a dialog asking the user for a password before calling <code>unlock</code>. Another area of code, such as a "Profile Manager" that starts up and lets users choose which profile to use, may unconditionally call <code>unlock</code> on such a component when switching a profile.</p>
+
+<p>The next set of functionality manages the white list where acceptable domains are stored:</p>
+
+<pre> void addSite(in string url);
+ void removeSite(in string url);
+ attribute nsISimpleEnumerator sites;
+</pre>
+
+<p>Operations in this set - <code>add</code>, <code>remove</code>, and <code>enumerate</code> - will be called from a user interface that manages the white list and adds the current website to the white list. There is no policy applied to what sites get added or removed to this list, or who can remove a site.</p>
+
+<p>The most interesting method definition is the enumerator. First of all, it does not look like a method at all:</p>
+
+<pre>attribute nsISimpleEnumerator sites;
+</pre>
+
+<p>This line defines an attribute in the interface. In C++, this is considered a public variable and "compiled" into a <code>Get</code> method (e.g., <code>getSites</code>). If an attribute is not marked <code>readonly</code>, then both <code>Get</code> and <code>Set</code> methods are generated.</p>
+
+<p>The getter created by this attribute returns a <code>nsISimpleEnumerator</code> interface pointer. This interface allows you to pass a list of elements between interfaces. It has two methods: <code>hasMoreElements()</code> and <code>getNext()</code>.</p>
+
+<pre>[scriptable, uuid(D1899240-F9D2-11D2-BDD6-000064657374)]
+interface nsISimpleEnumerator : nsISupports
+{
+ /**
+ * Called to determine whether or not the enumerator has
+ * any elements that can be returned via getNext(). This method
+ * is generally used to determine whether or not to initiate or
+ * continue iteration over the enumerator, though it can be
+ * called without subsequent getNext() calls. Does not affect
+ * internal state of enumerator.
+ *
+ * @see getNext()
+ * @return PR_TRUE if there are remaining elements in the enumerator.
+ * PR_FALSE if there are no more elements in the enumerator.
+ */
+ boolean hasMoreElements();
+
+ /**
+ * Called to retrieve the next element in the enumerator. The "next"
+ * element is the first element upon the first call. Must be
+ * preceded by a call to hasMoreElements() which returns PR_TRUE.
+ * This method is generally called within a loop to iterate over
+ * the elements in the enumerator.
+ *
+ * @see hasMoreElements()
+ * @return NS_OK if the call succeeded in returning a non-null
+ * value through the out parameter.
+ * NS_ERROR_FAILURE if there are no more elements
+ * to enumerate.
+ * @return the next element in the enumeration.
+ */
+ nsISupports getNext();
+};
+</pre>
+
+<h3 id="Implementing_WebLock" name="Implementing_WebLock">Implementing <strong>WebLock</strong></h3>
+
+<p>Once you have defined the interfaces that the component will implement, you can begin to write the implementation code that will actually carry out the web locking functionality.</p>
+
+<p>The <strong>WebLock</strong> component implements three interfaces:</p>
+
+<ul>
+ <li><code>nsISupports</code></li>
+ <li><code>nsIObserver</code></li>
+ <li><code>iWebLock</code></li>
+</ul>
+
+<p><code>nsISupports</code> is the base interface that all XPCOM objects must implement. The <code>nsIObserver</code> interface is for listening to various events that Gecko generates. Finally, the <code>iWebLock</code> interface is the interface that actually controls the web locking functionality. The first two have already been implemented as part of the generic module code. Recall from <a href="cn/Creating_XPCOM_Components/Using_XPCOM_Utilities_to_Make_Things_Easier">Using XPCOM Utilities to Make Things Easier</a> that implementing these basic interfaces can be easy and straightforward if you use the macros and other utilities that XPCOM provides.</p>
+
+<h4 id="Declaration_Macros" name="Declaration_Macros">Declaration Macros</h4>
+
+<p>The class declaration for the <code>WebLock</code> class that implements these three interfaces is as follows:</p>
+
+<pre>class WebLock: public nsIObserver, public iWebLock
+{
+ public:
+ WebLock();
+ virtual ~WebLock();
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIOBSERVER
+ NS_DECL_IWEBLOCK
+};
+</pre>
+
+<p>Note that we derive from the <code>nsIObserver</code> interface as well as the <code>iWeblock</code> class. We do not need to explicitly derive from <code>nsISupports</code> as both of these two other interfaces are already subclasses of <code>nsISupports</code>:</p>
+
+<p><span id="Interface_Hierarchy_for_WebLock"><a id="Interface_Hierarchy_for_WebLock"></a><strong>Interface Hierarchy for WebLock</strong></span></p>
+
+<p><img alt="Image:weblock-interface-hierarchy.png"></p>
+
+<p>The body of the class declaration uses declaration macros that are generated from an XPIDL interface file. Every header generated from an XPIDL file has a similar macro that defines all the methods in that interface. This makes changes to the interface when designing a bit simpler, as you do not have to modify any class declarations.</p>
+
+<p>There are times, of course, when you cannot use these macros-as when two interfaces share the same method signatures. In these cases you have to manually declare the methods in your class. But in practice, manually declaring class methods in XPCOM is the exception and not the rule. The <code>NS_DECL_IWEBLOCK</code> declaration macro expands into the following:</p>
+
+<pre> NS_IMETHOD Lock(void);
+ NS_IMETHOD Unlock(void);
+ NS_IMETHOD AddSite(const char *url);
+ NS_IMETHOD RemoveSite(const char *url);
+ NS_IMETHOD GetSites(nsISimpleEnumerator * *aSites);
+ NS_IMETHOD SetSites(nsISimpleEnumerator *aSites);
+</pre>
+
+<h4 id="Representing_Return_Values_in_XPCOM" name="Representing_Return_Values_in_XPCOM">Representing Return Values in XPCOM</h4>
+
+<p>The code sample above is the C++ version of the <code>iWebLock</code> interface methods. The return result of XPCOM methods generated from XPIDL is always of the type <code>nsresult</code>, and the small macro used in these expansions, <code>NS_IMETHOD</code>, actually represents that return type. <code>nsresult</code> is returned even when in XPIDL you specify that the method return a <code>void</code>. If you require the return result to be something else, the methods are not truly XPCOM methods. If you really want to change the return result type you can use a special flag in your XPIDL that denotes this (see <a class="external" href="http://www.mozilla.org/scriptable/xpidl/">the XPIDL reference</a>). However, we suggest that you simply add an out parameter to the method.</p>
+
+<h4 id="XPIDL_Code_Generation" name="XPIDL_Code_Generation">XPIDL Code Generation</h4>
+
+<p>The XPIDL compiler also generates a stub implementation of the interface in a commented section of the generated header file, in which each method returns <code>NS_ERROR_NOT_IMPLEMENTED</code>. If you copy the stub implementation from the header file into the source, then rename the dummy class name ("<code>_MYCLASS_</code>") to the <code>WebLock</code> class name already defined, you should be able to compile the source successfully.</p>
+
+<h4 id="Getting_the_WebLock_Service_from_a_Client" name="Getting_the_WebLock_Service_from_a_Client">Getting the WebLock Service from a Client</h4>
+
+<p>At this point, you can install the XPCOM component and have other systems use it. The component doesn't do anything useful, of course, but you have written enough of the code to have it recognized and accessed as a component in XPCOM. The code snippet below illustrates how to get the <strong>WebLock</strong> service when the component is present:</p>
+
+<pre>nsCOMPtr&lt;nsIServiceManager&gt; servMan;
+nsresult rv = NS_GetServiceManager(getter_AddRefs(servMan));
+if (NS_FAILED(rv))
+{
+ printf("ERROR: XPCOM error [%x].\n", rv);
+ return -1;
+}
+nsCOMPtr&lt;iWebLock&gt; weblock;
+rv = servMan-&gt;GetServiceByContractID("@dougt/weblock",
+ NS_GET_IID(iWeblock),
+ getter_AddRefs(weblock));
+
+if (NS_FAILED(rv))
+{
+ printf("ERROR: XPCOM obtaining service [%x].\n", rv);
+ return -1;
+}
+</pre>
+
+<h4 id="Implementing_the_iWebLock_Interface_.28.E5.AE.9E.E7.8E.B0iWebLock.E6.8E.A5.E5.8F.A3.29" name="Implementing_the_iWebLock_Interface_.28.E5.AE.9E.E7.8E.B0iWebLock.E6.8E.A5.E5.8F.A3.29">Implementing the <code>iWebLock</code> Interface (实现iWebLock接口)</h4>
+
+<p>Once the interface is defined, you can focus on implementing the web lock startup functionality itself. The <strong>WebLock</strong> component starts automatically when XPCOM is started up because it's been registered as a category in XPCOM. When <strong>WebLock</strong> is called, one of the first things it wants to do is read in a file that lists the <abbr title="Uniform Resource Locator">URLs</abbr> that the browser is allowed to load. This file can exist anywhere on the local system, but we've placed it next to the application to keep things simple. The first step in this implementation phase, then, is to create the functionality that accesses this <strong>WebLock</strong> white list and uses its data to determine which domains are allowed and which are to be blocked. For this, we need to use the file interfaces available in XPCOM.</p>
+
+<p>一旦接口已被定义, 那你的重点应该放在实现web lock的功能上. 当XPCOM运行后WebLock组件也会被自动运行, 因为它已经被注册成为一个XPCOM中的category. 当WebLock被调用时, 它应该做的第一个事情就是读取一个文件, 这个文件列出了允许被浏览器加载的URLs. 这个文件可以位于本地系统中的任何位置, 但我们需要将其放置在距应用程序不远的地方以便操作起来简单一些. 接下来在实现阶段的第一步是实现两个功能, 一是访问WebLock的白名单, 二是使用这些数据去决定哪些域是被允许, 以及哪些是应该被拦截的. 为此, 我们需要使用XPCOM中的文件接口.</p>
+
+<h5 id="File_Interfaces" name="File_Interfaces">File Interfaces</h5>
+
+<p>Files and directories are abstracted and encapsulated by interfaces. There are a few reasons for not using strings to represent file locations, but the most important one is that not all file systems can be represented by a series of characters separated by a slash. On the Macintosh platform, for example, files are represented as a triplet - two numbers and one string - so using a string on the Macintosh does not adequately identify files on that operating system.</p>
+
+<p>文件和目录是通过接口来抽象和封装的. 这里有几个原因说明为什么不使用字符串来表示文件位置, 但更重要的一点是并不是所有的文件系统都能够表示成斜线所分割的字符序列. 例如, 在Macintosh(Apple的系统)平台上, 文件被表示成一个triplet(意思是由三个部分组成), 两个数字一个字符串, 因此在Macintosh系统上使用字符串并不能充分在标识文件.</p>
+
+<p><code>nsIFile</code>, the file interface in XPCOM, provides most of the functionally that file handling requires. That interface includes members representing the file name, file attributes, permissions, existence, and others. A related interface called <code>nsILocalFile</code> provides access to operations specific to local files, but the <code>nsIFile</code> functionality is adequate for the <strong>WebLock</strong> component.</p>
+
+<p>nsIFile, XPCOM中的文件接口, 提供了大多数操作文件所必须的功能. 这个接口中所包含的成员描述了文件的名字, 属性, 权限, 是否存在等等. 与之相关的接口nsILocalFile提供 操作特定的本地文件, 不过nsIFile的功能对于WebLock组件来说已经足够了.</p>
+
+<p><span id="File_Interface_Hierarchy"><a id="File_Interface_Hierarchy"></a><strong>File Interface Hierarchy</strong></span></p>
+
+<p><img alt="Image:file-iface-hierarchy.png"></p>
+
+<div class="side-note">
+<p><span id="Remote_Files_and_nsIFile"><a id="Remote_Files_and_nsIFile"></a><strong>Remote Files and nsIFile</strong></span></p>
+
+<p>It is not inconceivable for remote files to be represented by the <code>nsIFile</code> interface. Someone could write an <code>nsIFile</code> implementation that represented FTP files on some server. The existing code would need to change very little for a <strong>WebLock</strong> implementation to take advantage of files that do not actually exist on disk. This kind of implementation does not exist, but this expandability shows some of the flexibility that interface-based programming can provide.</p>
+
+<p>并不难想象, 为远程文件使用nsIFile接口来表示它. 某人可以写一个nsIFile的实现用以表示一些服务器上的FTP文件. 已经存在的代码必须要做一些效小的修改以使WebLock的实现可以接受实际上并不是存在于磁盘上的文件. 这种类型的实现虽然还并不存在, 但至少这种扩展性可以显现出一些基于接口的编程带来的灵活性.</p>
+
+<p>The <a href="cn/XPCOM_API_Reference">XPCOM API Reference</a> contains detailed information on <code>nsIFile</code> and other XPCOM interfaces.</p>
+</div>
+
+<h4 id="The_Directory_Service_.28.E7.9B.AE.E5.BD.95.E6.9C.8D.E5.8A.A1.29" name="The_Directory_Service_.28.E7.9B.AE.E5.BD.95.E6.9C.8D.E5.8A.A1.29">The Directory Service (目录服务)</h4>
+
+<p>The file interfaces are most useful when you can use them to find and manipulate files that are relative to the application. The Directory Service provides directory and file locations in a cross platform uniform way to make this easier. This service, available as <code>nsIDirectoryService</code>, stores the location of various common system locations, such as the the directory containing the running process, the user's <code>HOME</code> directory, and others. It can be expanded so that applications and components can define and store their own special locations - an application plugin directory, for example, preference files and/or directories, or other application specific paths. For example, to expose the location of the "white list" file containing all of the URLs that are safe for <strong>WebLock</strong>, you can add its location to the <code>nsDirectoryService</code>, which clients can then query for this infomation.</p>
+
+<p>文件接口较有助于当你使用它们去查找和操作与应用相关的文件. 目录服务提供了跨平台的目录与文件定位的统一方法, 这使得进行这种操作变得容易. 这个服务(利用nsIDirectoryService)存储了各种各样通用系统区域的位置, 例如像是包括了正在运行的程序的目录, 用户的HOME目录等等. 因此它可以被扩展为应用程序和组件能够定义并且存储它们自己的特定位置(应用程序插件目录), 例如, 用户自定义的文件和目录, 或者其它的应用程序的特定路径. 比如指定一个"white list"所在的位置, 它包括了所有对于WebLock来讲是安全的URLs, 你可以将这个位置添加到nsDirectoryService中, 使客户端接下来可以查询到这个信息.</p>
+
+<p>The Directory Service implements the <code>nsIProperties</code> interface, which allows you to <code>Get()</code>, <code>Set()</code>, and <code>Undefine()</code> interface pointers. In the case of <strong>WebLock</strong>, these interface pointers will be <code>nsIFile</code> objects.</p>
+
+<p>目录服务实现了nsIProperties接口, 它允许你Get(), Set()以及Undefine()接口指针. 在WebLock中这些接口指针是nsIFile对象.</p>
+
+<pre>[scriptable, uuid(78650582-4e93-4b60-8e85-26ebd3eb14ca)]
+interface nsIProperties : nsISupports
+{
+ /**
+ * Gets a property with a given name.
+ * 用给定的名字(name)取得一个属性(property)
+ *
+ * @return NS_ERROR_FAILURE if a property with that
+ * name doesn't exist.
+ * 如果给定名字的属性不存在, 函数返回NS_ERROR_FAILURE
+ * @return NS_ERROR_NO_INTERFACE if the
+ * found property fails to QI to the
+ * given iid.
+ * 如果取得的属性在以给定的iid于QI方法上调用失败,
+ * 函数返回NS_ERROR_NO_INTERFACE
+ */
+ void get(in string prop,
+ in nsIIDRef iid,
+ [iid_is(iid),retval] out nsQIResult result);
+
+ /**
+ * Sets a property with a given name to a given value.
+ * 用给定的名字和给定的值为设置一个属性
+ */
+ void set(in string prop, in nsISupports value);
+
+ /**
+ * Returns true if the property with the given name exists.
+ * 如果与给定名字的属性存在, 返回true
+ */
+ boolean has(in string prop);
+
+ /**
+ * Undefines a property. 取消一个属性的定义
+ * @return NS_ERROR_FAILURE if a property with that name doesn't
+ * already exist.
+ * 如果给定名字的属性还不存在, 那么函数返回NS_ERROR_FAILURE
+ */
+ void undefine(in string prop);
+
+ /**
+ * Returns an array of the keys.
+ * 返回一个key的集合
+ */
+ void getKeys(out PRUint32 count,
+ [array, size_is(count), retval] out string keys);
+};
+</pre>
+
+<p><span id="Directory_Service_Hierarchy"><a id="Directory_Service_Hierarchy"></a><strong>Directory Service Hierarchy</strong></span></p>
+
+<p><img alt="Image:directoryservice-iface-hierarchy.png"></p>
+
+<p>There are two steps involved to find directories or files with the Directory Service (<code>nsIDirectoryService</code>). You must know the string key (or property) that refers to the location you are interested in, which is published in the file <code>nsDirectoryServiceDefs.h</code> that comes with the Gecko SDK (for a listing of these locations, see the <a href="cn/XPCOM_API_Reference">XPCOM API Reference</a>). The string key for the directory containing the application executable is <code>NS_XPCOM_CURRENT_PROCESS_DIR</code>. Given this key, you can acquire the directory service, call <code>Get()</code>, and pass the key. In the example below, <code>appDir</code> will point to the directory that contains the executable.</p>
+
+<p>这里有两个步骤有关于通过目录服务(nsIDirectoryService)查找目录或文件. 你必须要知道字符串键(或叫属性)用以引用你所想要的位置, 字符串键(或叫属性)被公开于随Gecko SDK一起提供的nsDirectoryServiceDefs.h文件中(可参见<a href="cn/XPCOM_API_Reference">XPCOM API Reference</a>以得到这些位置的一个列表). 包含可执行程序的目录的字符串键是NS_XPCOM_CURRENT_PROCESS_DIR. 给定这个键, 你就可以通过调用Get()并将键传递到函数中以获得目录服务. 在下面的实例中, appDir将指向一个包含了可执行程序的目录.</p>
+
+<pre>nsCOMPtr&lt;nsIServiceManager&gt; servMan;
+nsresult rv = NS_GetServiceManager(getter_AddRefs(servMan));
+if (NS_FAILED(rv)) return -1;
+
+nsCOMPtr&lt;nsIProperties&gt; directoryService;
+rv = servMan-&gt;GetServiceByContractID(NS_DIRECTORY_SERVICE_CONTRACTID,
+ NS_GET_IID(nsIProperties),
+ getter_AddRefs(directoryService));
+
+if (NS_FAILED(rv)) return -1;
+
+nsCOMPtr&lt;nsIFile&gt; appDir;
+rv = directoryService-&gt;Get(NS_XPCOM_CURRENT_PROCESS_DIR,
+ NS_GET_IID(nsIFile),
+ getter_AddRefs(appDir));
+
+if (NS_FAILED(rv)) return -1;
+</pre>
+
+<p>Most of the useful functionality is exposed by the <code>nsIProperties</code> interface, but the directory service also implements <code>nsIDirectoryService</code>. This interface allows you to extend and override <code>nsIFile</code> objects registered with the directory service. There are currently two ways to add a file location to the directory service: directly and using the delayed method. The direct method is to add a new <code>nsIFile</code> object using the <code>nsIProperties</code> interface, in which case you pass the <code>nsIFile</code> object as an <code>nsISupports</code> to the <code>Set()</code> method of the <code>nsIProperties</code> interface.</p>
+
+<p>大多数有用的功能都是通过nsIProperties接口所提供, 但目录服务还实现了nsIDirectoryService. nsIDirectoryService接口允许利用目录服务你去扩展和重写nsIFile对象的注册. 当前有两种方法添加一个文件位置到目录服务中:立即的与延迟的两种方法. 立即的方法是使用nsIProperties接口添加一个新的nsIFile对象, 在这种情况下你要把nsIFile对象当成一个nsISupports传递给nsIProperties接口的Set()函数.</p>
+
+<p>In the delayed method, you register to be a callback that can provide an <code>nsIFile</code>. To do this, you must get the implementation like we did above. When you have it, <code>QueryInterface</code> for the <code>nsIDirectoryService</code> interface. In this interface, there is a function which allows you to register an <code>nsIDirectoryServiceProvider</code> interface. The interface callback looks like this:</p>
+
+<pre>[scriptable, uuid(bbf8cab0-d43a-11d3-8cc2-00609792278c)]
+interface nsIDirectoryServiceProvider: nsISupports
+{
+/**
+* getFile
+*
+* Directory Service calls this when it gets the first request for
+* a prop or on every request if the prop is not persistent.
+*
+* @param prop The symbolic name of the file.
+* @param persistent TRUE - The returned file will be cached by Directory
+* Service. Subsequent requests for this prop will
+* bypass the provider and use the cache.
+* FALSE - The provider will be asked for this prop
+* each time it is requested.
+*
+* @return The file represented by the property.
+*
+*/
+nsIFile getFile(in string prop, out PRBool persistent);
+};
+</pre>
+
+<h4 id="Modifying_Paths_with_nsIFile" name="Modifying_Paths_with_nsIFile">Modifying Paths with <code>nsIFile</code></h4>
+
+<p>The directory service returns an <code>nsIFile</code> object, but that object points to the application directory and not the file itself. To modify this <code>nsIFile</code> so that it points to the file, you must call the <code>Append</code> method of the <code>nsIFile</code>. <code>Append</code> adds the input string to the path already specified in the <code>nsIFile</code>. On Unix, for example, calling <code>Append("b")</code> on an <code>nsIFile</code> modifies that <code>nsIFile</code> representing <code>/u/home/dougt/a</code> to point to <code>/u/home/dougt/a/b</code>. The next operation on the <code>nsIFile</code> returns results associated with the "b" path. If "a" wasn't a directory, further operations would fail, even if the initial <code>Append</code> was successful. This is why <code>Append</code> is considered a string operation.</p>
+
+<p>目录服务返回一个nsIFile对象, 但nsIFile对象指向的是应用程序目录而并不是文件. 因此为了修改nsIFile对象以指向文件你必须要调用nsIFile的Append函数. Append函数将字符串输入参数追加到已经被指定到nsIFile的路径里. 例如在Unix里, 在一个nsIFile上调用Append("b")将使nsIFile从指向/u/home/dougt/a修改为指向/u/home/dougt/a/b. 在nsIFile上的后续操作返回的结果将是关于"b"这个路径的. 如果"a"不是一个目录, 那么进一步的操作将会失败, 尽管对于Append函数的调用是成功的. 这就是为什么Append函数被认为是对字符串的操作(不进行目录路径的有效性验证).</p>
+
+<p>The <strong>WebLock</strong> component manipulates a file named <code>weblock.txt</code>. The following snippet adjusts the <code>theFile</code> object representing that file:</p>
+
+<p>WebLock组件操作名为weblock.txt的文件, 以下程序片段调整了theFile对象以表示那个文件:</p>
+
+<pre>nsEmbedCString fileName("weblock.txt");
+appDir-&gt;AppendNative(fileName);
+</pre>
+
+<h4 id="Manipulating_Files_with_nsIFile" name="Manipulating_Files_with_nsIFile">Manipulating Files with <code>nsIFile</code></h4>
+
+<p>Once you have an <code>nsIFile</code> object pointing to the file that you're interested in, you can open it and read its contents into memory. There are many ways to do this: You can use Standard ANSI File I/O, or NSPR (see <a href="#The_Netscape_Portable_Runtime_Library">The Netscape Portable Runtime Library</a> below for a brief description of NSPR), or you can use the networking APIs that Gecko provides.</p>
+
+<div class="side-note">
+<p><span id="The_Netscape_Portable_Runtime_Library"><a id="The_Netscape_Portable_Runtime_Library"></a><strong>The Netscape Portable Runtime Library</strong></span></p>
+
+<p>The<em>Netscape Portable Runtime Library</em> (NSPR) is a platform-independent library that sits below XPCOM. As a layer of abstraction above the operating system, the NSPR allows Gecko applications to be platform independent by providing the following system-level facilities:</p>
+
+<ul>
+ <li>Threads</li>
+ <li>Thread synchronization</li>
+ <li>File and network I/O</li>
+ <li>Timing and intervals</li>
+ <li>Memory management</li>
+ <li>Shared library linking</li>
+</ul>
+
+<p>The NSPR is included in the Gecko SDK.</p>
+</div>
+
+<p>To keep things as simple as possible, we'll read the file into memory using standard ANSI file I/O, but for examples and information about how to use<em>necko</em> , the Gecko networking libraries, see <a class="external" href="http://www.mozilla.org/projects/netlib/" rel="freelink">http://www.mozilla.org/projects/netlib/</a>.</p>
+
+<h4 id="Using_nsILocalFile_for_Reading_Data" name="Using_nsILocalFile_for_Reading_Data">Using <code>nsILocalFile</code> for Reading Data</h4>
+
+<p>An <code>nsIFile</code> object returned from the directory service may also implement the <code>nsILocalFile</code> interface, which has a method that will return a <code>FILE</code> pointer that can be used in <code>fread()</code>. To implement the actual read, you need to allocate a buffer the length of the file, use the <code>nsILocalFile</code> interface pointer to obtain a <code>FILE *</code>, use this result with <code>fread</code>, and close the file pointer.</p>
+
+<p>The following code loads the contents of the file referenced by the <code>nsIFile</code> object <code>theFile</code> into the buffer <code>buf</code>:</p>
+
+<pre>nsCOMPtr&lt;nsILocalFile&gt; localFile = do_QueryInterface(theFile);
+if (!localFile)
+ return -1;
+
+PRBool exists;
+rv = theFile-&gt;Exists(&amp;exists);
+if (NS_FAILED(rv))
+ return -1;
+
+char *buf = NULL;
+
+if (exists)
+{
+ // determine file size:
+ PRUint32 fs, numread;
+ PRInt64 fileSize;
+ rv = theFile-&gt;GetFileSize(&amp;fileSize);
+ if (NS_FAILED(rv))
+ return -1;
+
+ // Converting 64 bit value to unsigned int
+ LL_L2UI(fs, fileSize);
+
+ FILE* openFile;
+ rv = localFile-&gt;OpenANSIFileDesc("rw", &amp;openFile);
+ if (NS_FAILED(rv))
+ return -1;
+
+ char *buf = (char *)malloc((fs+1) * sizeof(char));
+ if (!buf)
+ return -1;
+
+ numread = fread(buf, sizeof(char), fs, openFile);
+
+ if (numread != fs)
+ // do something useful.
+
+ // ...
+}
+
+if (buf)
+ free(buf);
+</pre>
+
+<p>The first line of the code calls <code>QueryInterface</code> on <code>theFile</code>, and if that succeeds assigns the new interface pointer to <code>localFile</code>. If the <code>QueryInterface</code> call fails, <code>localFile</code> will have a value of <code>NULL</code>.</p>
+
+<div class="side-note">
+<p>Note that the out parameter of the method <code>GetFileSize</code> is a 64-bit integer. The type of this variable is <code>PRInt64</code>, but this type is not represented as a primitive on all platforms. On some platforms, <code>PRInt64</code> is a <code>struct</code> with two fields - a high and a low 32-bit integer. So operations on this type must use special macros that do the right thing on each platform. On Windows or Linux, for example, it is possible to multiply a <code>PRInt64</code> by a long like this:</p>
+
+<pre>PRInt64 x = 1, y = 2;
+y = x * 2;
+</pre>
+
+<p>However, this same snippet will not compile on a platform like Macintosh OS 9, where you need to use macros to perform the calculation:</p>
+
+<pre>PRInt64 x, y, two;
+LL_I2L(x, 1);
+LL_I2L(y, 2);
+LL_I2L(two, 2);
+LL_MUL(y, x, two);
+</pre>
+
+<p>A full listing of NSPR's <code>long long</code> support can be found at <a class="external" href="http://www.mozilla.org/projects/nspr/" rel="freelink">http://www.mozilla.org/projects/nspr/</a>.</p>
+
+<p>The <strong>WebLock</strong> component doesn't have to deal with files that are longer than 2<sup>32</sup> bytes. Truncating this value to whatever can fit into a 32-bit unsigned integer may not work for every application, but in this case it doesn't really matter.</p>
+</div>
+
+<h4 id="Processing_the_White_List_Data" name="Processing_the_White_List_Data">Processing the White List Data</h4>
+
+<p>There are various ways to process the file data itself. The file <code>weblock.txt</code> consists of URL tokens separated by return characters, which makes them easy to read into a data structure.</p>
+
+<p>The white list file can be read in as soon as the component starts up (i.e., as <strong>WebLock</strong> intercepts the startup notification in the <code>Observe</code> method of the <code>nsIObserver</code> interface that we implement). Since we have only registered to receive a notification when XPCOM starts up, it's a safe assumption that <code>Observe</code> will only be called during the startup event, so we can read the file data in the callback.</p>
+
+<p>After you've read the data into memory, you need to store it in some way to make data access quick and efficient.</p>
+
+<div class="side-note">
+<p><span id="URL_Checking"><a id="URL_Checking"></a><strong>URL Checking</strong></span></p>
+
+<p>The way in which URL checking is implemented in the <strong>WebLock</strong> component is not at all optimal. The <strong>WebLock</strong> component manages a simple linked list of URL strings. A linear search through the data in the white list may not be terribly bad if the number of URLs is under a couple of dozen, but it decays as the list grows. There's also a large bottleneck in the network request. URL data is accessed as in the diagram below:</p>
+
+<p><img alt="Image:urldata-access-in-weblock.png"></p>
+
+<p>You might construct hash values for each of the URL strings instead, or add them to some kind of database. But we leave optimizations and real-world performance for web locking to the reader.</p>
+</div>
+
+<h3 id="iWebLock_Method_by_Method" name="iWebLock_Method_by_Method"><code>iWebLock</code> Method by Method</h3>
+
+<p>The implementation of the <code>iWeblock</code> interface is straightforward. <strong>WebLock</strong> is designed so that the user interface notifies this service when we should go into lock mode. During this time, any new URL request that is not in our list of "good" URLs will be denied. Through scriptable access to the <code>iWebLock</code> interface, the user interface can also add, remove, and enumerate the list of URLs that it knows about.</p>
+
+<h4 id="Lock_and_Unlock" name="Lock_and_Unlock"><code>Lock</code> and <code>Unlock</code></h4>
+
+<p>The <code>lock</code> and <code>unlock</code> methods simply set a Boolean representing state in the object. This Boolean value will be used later to determine if we should be denying URL requests:</p>
+
+<pre>/* void lock (); */
+NS_IMETHODIMP
+WebLock::Lock()
+{
+ mLocked = PR_TRUE;
+ return NS_OK;
+}
+
+/* void unlock (); */
+NS_IMETHODIMP WebLock::Unlock()
+{
+ mLocked = PR_FALSE;
+ return NS_OK;
+}
+</pre>
+
+<h4 id="AddSite" name="AddSite"><code>AddSite</code></h4>
+
+<p>For <code>AddSite</code>, we add a new node to our linked list. The link list nodes contain a <code>char*</code> which points to the string URL that we care about and, of course, a pointer to the next element in the list.</p>
+
+<div class="side-note">
+<p><span id="%3Ccode%3EnsMemory%3C/code%3E_for_Cross-component_Boundaries"><a id="%3Ccode%3EnsMemory%3C/code%3E_for_Cross-component_Boundaries"></a><strong><code>nsMemory</code> for Cross-component Boundaries</strong></span></p>
+
+<p>WebLock maintains ownership of all the memory it allocates, so you can use just about any allocator that you want for <strong>WebLock</strong>, but this is not always the case. In other places, where allocated buffers cross interface boundaries, you must ensure that the correct allocator is used - namely <code>nsMemory</code> - so that the allocators can match the allocation with the deallocation.</p>
+
+<p>Suppose you call <code>malloc</code> from object A and pass this buffer to another object B, for example. But if object B is using a special allocator that does garbage collection, then when object B deletes a buffer allocated by object A's allocator, the results are unpredictable: probably an assertion will be raised, possibly a memory leak, or a crash. The <code>nsMemory</code> class is a wrapper around the <code>nsIMemory</code> interface, whose only implementation is part of XPCOM. When you use <code>nsMemory</code>, you are guaranteed to be using this same memory allocator in all cases, and this avoids the problem described here.</p>
+</div>
+
+<h4 id="RemoveSite" name="RemoveSite"><code>RemoveSite</code></h4>
+
+<p><code>RemoveSite</code> deletes a node from the linked list:</p>
+
+<pre>// a simple link list.
+struct urlNode
+{
+ char* urlString;
+ struct urlNode* next;
+};
+
+/* void addSite (in string url); */
+NS_IMETHODIMP
+WebLock::AddSite(const char *url)
+{
+ // we don't special-case duplicates here
+ urlNode* node = (urlNode*) malloc(sizeof(urlNode));
+ node-&gt;urlString = strdup(url);
+ node-&gt;next = mRootURLNode;
+ mRootURLNode = node;
+
+ return NS_OK;
+}
+
+/* void removeSite (in string url); */
+NS_IMETHODIMP
+WebLock::RemoveSite(const char *url)
+{
+ // find our entry.
+ urlNode* node = mRootURLNode;
+ urlNode* prev = nsnull;
+
+ while (node) // test this!
+ {
+ if (strcmp(node-&gt;urlString, url) == 0)
+ {
+ free(node-&gt;urlString);
+ if (prev)
+ prev-&gt;next = node-&gt;next;
+ free(node);
+ return NS_OK;
+ }
+ prev = node;
+ node = node-&gt;next;
+ }
+
+ return NS_ERROR_FAILURE;
+}
+</pre>
+
+<h4 id="SetSites" name="SetSites"><code>SetSites</code></h4>
+
+<p>The purpose of <code>SetSites</code> is to allow clients to pass an enumeration, or set, of URL strings to add to the white list of URLs. <code>SetSites</code> uses an <code>nsISimpleEnumerator</code> and shows how primitive data can be passed as an <code>nsISupports</code> object. The <code>nsISimpleEnumerator</code> interface is shown in <a href="#The_Web_Locking_Interface">The Web Locking Interface</a>.</p>
+
+<p>The first method returns a Boolean if there are more elements in the set. Internally, the object knows the number of elements it has in its enumeration, and every time a client calls <code>getNext</code>, it decrements a counter - or adjusts a pointer to the next element. When the counter goes to zero or the pointer points to a non-element, <code>hasMoreElements</code> will return false.</p>
+
+<p>There is no way to reset an <code>nsISimpleEnumerator</code>. For example, you can't re-enumerate the set. If you need random access to the elements in a <code>nsISimpleEnumerator</code>, you can read them from the <code>nsISimpleEnumerator</code>, store them in an array, and access them there. The <code>getNext</code> method returns a <code>nsISupports</code> interface pointer.</p>
+
+<p>When you want to pass primitive data types like numbers, strings, characters, <code>void *</code>, and others, the solution is to use one of the <code>nsISupportsPrimitive</code> interfaces. These interfaces wrap primitive data types and derive from <code>nsISupports</code>. This allows types like the strings that represent URLs in the <strong>WebLock</strong> component to be passed though methods that take an <code>nsISupports</code> interface pointer. This becomes clear when when you see the implementation of <code>SetSites</code>:</p>
+
+<pre>NS_IMETHODIMP
+WebLock::SetSites(nsISimpleEnumerator * aSites)
+{
+ PRBool more = PR_TRUE;
+ while (more)
+ {
+ nsCOMPtr&lt;nsISupports&gt; supports;
+ aSites-&gt;GetNext(getter_AddRefs(supports));
+
+ nsCOMPtr&lt;nsISupportsCString&gt; supportsString = do_QueryInterface(supports);
+
+ if (supportsString)
+ {
+ nsEmbedCString url;
+ supportsString-&gt;GetData(url);
+ AddSite(url.get());
+ }
+
+ aSites-&gt;HasMoreElements(&amp;more);
+ }
+
+ return NS_OK;
+}
+</pre>
+
+<h4 id="GetNext" name="GetNext"><code>GetNext</code></h4>
+
+<p><code>GetNext</code> is called with the <code>nsCOMPtr</code> of an <code>nsISupportsCString</code>. <code>nsCOMPtr</code>s are nice because they do whatever <code>QueryInterface</code> calls are necessary under the hood. For example, we know that the <code>GetNext</code> method takes an <code>nsISupports</code> object, but we may not be sure whether the return result supports the interface we want, <code>nsISupportsCString</code>. But after <code>GetNext</code> returns, the <code>nsCOMPtr</code> code takes the out parameter from <code>GetNext</code> and tries to <code>QueryInterface</code> it to the <code>nsCOMPtr</code>'s type. In this case, if the out parameter of <code>GetData</code> does not return something that is <code>QueryInterface</code>-able to an <code>nsISupportsCString</code>, the variable will be set to <code>null</code>. Once you know that you have an <code>nsISupportsCString</code>, you can grab the data from the primitive supports interface.</p>
+
+<p>To get something you can pass into the <code>AddSite</code> method, you need to convert from an <code>nsEmbedCString</code> to a <code>const char*</code>. To do this, you can take advantage of the <code>nsEmbedCString</code> described in <a href="cn/Creating_XPCOM_Components/Using_XPCOM_Utilities_to_Make_Things_Easier#String_Classes_in_XPCOM">String Classes in XPCOM</a>.</p>
+
+<h4 id="GetSites" name="GetSites"><code>GetSites</code></h4>
+
+<p>The implementation of <code>GetSites</code> is more involved. You must construct an implementation of <code>nsISimpleEnumerator</code> and return it when <code>GetSites</code> is called. The class needs to walk the list of <code>urlNode</code>'s for every call to <code>GetNext</code>, so it makes sense for the constructor itself to take an <code>urlNode</code>:</p>
+
+<pre>class myEnumerator : public nsISimpleEnumerator
+{
+ public:
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSISIMPLEENUMERATOR
+
+ myEnumerator(urlNode* node) {
+ NS_INIT_ISUPPORTS()
+ mNode = node;
+ }
+ virtual ~myEnumerator(void) {}
+
+ protected:
+ urlNode* mNode;
+ nsCOMPtr&lt;nsIComponentManager&gt; mCompMgr;
+};
+
+NS_IMPL_ISUPPORTS1(myEnumerator, nsISimpleEnumerator);
+</pre>
+
+<p>The <code>myEnumerator</code> class is going to implement the <code>nsISupports</code> interface and also <code>nsISimpleEnumerator</code>. The only state that it needs to maintain is the current URL node - the one that will be return on the next call to <code>GetNext</code>. There is also an <code>nsCOMPtr</code> to the <code>nsIComponentManager</code>, which is used in every call to <code>GetNext</code> so that you can create <code>nsISupportsCString</code> objects and cache the interface pointer as an optimization.</p>
+
+<h4 id="HasMoreElements" name="HasMoreElements"><code>HasMoreElements</code></h4>
+
+<p><code>HasMoreElements</code> is simple. All you need to do is make sure that <code>mNode</code> isn't <code>null</code>:</p>
+
+<pre>NS_IMETHODIMP
+myEnumerator::HasMoreElements(PRBool* aResult)
+{
+ if (!aResult)
+ return NS_ERROR_NULL_POINTER;
+
+ if (!mNode) {
+ *aResult = PR_FALSE;
+ return NS_OK;
+ }
+
+ *aResult = PR_TRUE;
+ return NS_OK;
+}
+</pre>
+
+<p><code>GetNext</code> needs to create an <code>nsISupportsCString</code> so that you can pass the URL string out through the <code>nsISupports</code> parameter. You must also move <code>mNode</code> to point to the next <code>urlNode</code>.</p>
+
+<pre>static NS_DEFINE_CID(kSupportsCStringCID, NS_SUPPORTS_CSTRING_CID);
+
+NS_IMETHODIMP
+myEnumerator::GetNext(nsISupports** aResult)
+{
+ if (!aResult)
+ return NS_ERROR_NULL_POINTER;
+
+ *aResult = nsnull;
+
+ if (!mNode)
+ return NS_ERROR_FAILURE;
+
+ if (!mCompMgr)
+ {
+ NS_GetComponentManager(getter_AddRefs(mCompMgr));
+ if (!mCompMgr)
+ return NS_ERROR_UNEXPECTED;
+ }
+
+ nsISupportsCString* stringSupports;
+ mCompMgr-&gt;CreateInstance(kSupportsCStringCID,
+ nsnull,
+ NS_GET_IID(nsISupportsCString),
+ (void**)&amp;stringSupports);
+ if (!stringSupports)
+ return NS_ERROR_UNEXPECTED;
+
+ nsEmbedCString str(mNode-&gt;urlString);
+ stringSupports-&gt;SetData(str);
+
+ *aResult = stringSupports; // addref'ed above.
+
+ mNode = mNode-&gt;next;
+
+ return NS_OK;
+}
+</pre>
+
+<p>在实际的<code>GetSites</code>呼叫中, 你需要做的就是产生一个<code>myEnumerator</code>实例并且返回它.</p>
+
+<p>此前,我们建立了一个类并且把它注册到组件管理器。当一个客户端需要获取某个接口的实现时,实际上的对象建立过程隐藏在XPCOM代码中。 但是其中, 你要初始化你自己的<code>nsISimpleEnumerator</code>实现. 这是一个简单的事情,但是你需要注意<code>NS_ADDREF</code>.</p>
+
+<pre>NS_IMETHODIMP
+WebLock::GetSites(nsISimpleEnumerator * *aSites)
+{
+ myEnumerator* enumerator = new myEnumerator(mRootURLNode);
+ if (!enumerator)
+ return NS_ERROR_OUT_OF_MEMORY;
+
+ NS_ADDREF(*aSites = enumerator);
+ return NS_OK;
+}
+</pre>
+
+<div class="side-note">
+<p><span id="AddRef,_Releasing,_and_Deleting_Objects"><a id="AddRef,_Releasing,_and_Deleting_Objects"></a><strong>AddRef, Releasing, and Deleting Objects</strong></span></p>
+
+<p>永远不要忘记调用你通过<code>new</code>建立的XPCOM对象的<code>AddRef</code>方法。所有的代码或者活动组件都应该有一个起码一个引用计数。忘记这点可能引起麻烦。</p>
+
+<p>一个相关的警示试你不要忘记永远不要用<code>delete</code>删除一个XPCOM. 当系统的一部分不是释放而是删除一个XPCOM对象的时候,可能会引起几个小时的资源搜索并且引起崩溃。</p>
+</div>
+
+<p>注意上面的实现中,当其他的线程访问链接表的时候<code>myEnumerator</code> 可能变得非法。枚举仅仅表现了访问URL字符串链接表的一个方法。如果你需要枚举成为URL字符串链表的一个快照,你需要重构这个实现让枚举持有一个链表的copy。</p>
+
+<p>当组件中止的时候,你也需要把链表写到磁盘里并且释放空间。我们把这个作为练习留给读者。</p>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Creating_XPCOM_Components:Using_XPCOM_Utilities_to_Make_Things_Easier" style="float: left;">« 上一页</a><a href="/zh-CN/docs/Creating_XPCOM_Components:Finishing_the_Component">下一页 »</a></p>
+</div> <p></p><div class="licenseblock">
+<p>Copyright (c) 2003 by Doug Turner and Ian Oeschger. This material may be distributed only subject to the terms and conditions set forth in the <a class="external" href="http://www.opencontent.org/openpub/" rel="noopener">Open Publication License</a>, v1.02 or later. Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.</p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/using_xpcom_components/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/using_xpcom_components/index.html
new file mode 100644
index 0000000000..a0a5b301ba
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/using_xpcom_components/index.html
@@ -0,0 +1,311 @@
+---
+title: 创建_XPCOM_组件/使用_XPCOM_组件
+slug: Mozilla/Tech/XPCOM/Guide/Creating_components/Using_XPCOM_Components
+tags:
+ - XPCOM
+ - 所有分类
+translation_of: Mozilla/Tech/XPCOM/Guide/Creating_components/Using_XPCOM_Components
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/创建_XPCOM_组件:XPCOM_简介" style="float: left;">« 上一页</a><a href="/zh-CN/docs/Creating_XPCOM_Components:Component_Internals">下一页 »</a></p>
+</div><p></p>
+
+<p>创建一个新的 XPCOM 组件, 特别是在我们设计一个供别人使用的组件接口的时候, 最好方式是参照已有的组件. 我们在编写 <a href="cn/Creating_XPCOM_Components/Starting_WebLock">Starting WebLock</a> 这个例子的时候, 也是这么做的.</p>
+
+<p>Mozilla 浏览器应用是复杂的, 模块化的 XPCOM 客户程序. 实际上, 基本上所有与浏览器相关的功能都被定义成了组件的形式, 包括网页间的跳转, 窗口管理, cookie 管理, 书签, 安全, 搜索, 润色等等的其他功能, 这些功能都是由组件的接口提供的. Mozilla<em>就是</em>一堆 XPCOM 组件.</p>
+
+<p>本章将讨论 Mozilla 是如何使用象 CookieManager 这样的 XPCOM 对象, 然后根据这些例子我们定义 WebLock 组件的访问接口.</p>
+
+<h3 id=".E7.BB.84.E4.BB.B6.E7.9A.84.E4.BE.8B.E5.AD.90" name=".E7.BB.84.E4.BB.B6.E7.9A.84.E4.BE.8B.E5.AD.90">组件的例子</h3>
+
+<p>可以在这里 <a href="cn/XPCOM_API_Reference">XPCOM API Reference</a> 找到下面要描述的组件. 我们要了解的是象本节中所给出的组件是如何被 Mozilla 浏览器获取和使用的.</p>
+
+<h4 id="Cookie_.E7.AE.A1.E7.90.86.E5.99.A8" name="Cookie_.E7.AE.A1.E7.90.86.E5.99.A8">Cookie 管理器</h4>
+
+<p>Cookie 管理是以组件形式向 Mozilla 浏览器提供支持的众多组件之一, 这些组件可以被重用在需要类似功能的应用中. 当用户通过 Cookie 管理器对话框来观察, 组织, 或者删除 cookies 的时候, Cookie 管理器在背后默默的工作. <a href="#Cookie_管理器对话框">Cookie 管理器对话框</a>负责向用户提供 Cookie 管理器的 UI 界面<sup><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Guide/Creating_components/Using_XPCOM_Components#endnote_cookie-manager-ui">[cookie-manager-ui]</a></sup>.</p>
+
+<p><span id="Cookie_%E7%AE%A1%E7%90%86%E5%99%A8%E5%AF%B9%E8%AF%9D%E6%A1%86"><a id="Cookie_%E7%AE%A1%E7%90%86%E5%99%A8%E5%AF%B9%E8%AF%9D%E6%A1%86"></a><strong>Cookie 管理器对话框</strong></span></p>
+
+<p><img alt="Image:cookie_mgr_dlog.png"></p>
+
+<p>对话框是用 XUL (XML UI 语言) 和 JavaScript 语言编写, 使用称为<em>XPConnect</em> 的组件无缝连接到 Cookie 管理器组件(参看下面的 <a href="#从接口连接到组件">从接口连接到组件</a>). XUL 只是一种暴露 Cookie 管理器功能的方式, 但是却是 Mozilla 环境下最有用的方式之一.</p>
+
+<p>CookieManager 组件的功能通过 <code>nsICookieManager</code> 接口提供, 接口的方法如下:</p>
+
+<p><span id="%3Ccode%3EnsICookieManager%3C/code%3E_%E6%8E%A5%E5%8F%A3"><a id="%3Ccode%3EnsICookieManager%3C/code%3E_%E6%8E%A5%E5%8F%A3"></a><strong><code>nsICookieManager</code> 接口</strong></span></p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>removeAll</code></td>
+ <td>删除 cookie 列表中所有的 cookies.</td>
+ </tr>
+ <tr>
+ <td><code>enumerator</code></td>
+ <td>通过 cookie 列表枚举.</td>
+ </tr>
+ <tr>
+ <td><code>remove</code></td>
+ <td>从列表中删除某个 cookie .</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>XPCOM 中所有的接口必须固定, 虽然组件对接口的实现会有所变化. 接口都是<em>public</em> 的, 相对的, 接口实现是 private 的<sup><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Guide/Creating_components/Using_XPCOM_Components#endnote_private-xpcom-interfaces">[private-xpcom-interfaces]</a></sup>. 当用户选中 cookie 列表中的一个 cookie, 点击 Remove 按钮, <code>nsICookieManager</code> 接口的 <code>Remove</code> 方法被调用. CookieManager 组件执行该函数, 选中的组件就被删除了.</p>
+
+<p>下面的<a href="#从_JavaScript_中访问_CookieManager_组件">从 JavaScript 中访问 CookieManager 组件</a>代码, 展示了如何从 JavaScript 中调用 <code>Remove()</code> 方法:</p>
+
+<p><span id="%E4%BB%8E_JavaScript_%E4%B8%AD%E8%AE%BF%E9%97%AE_CookieManager_%E7%BB%84%E4%BB%B6"><a id="%E4%BB%8E_JavaScript_%E4%B8%AD%E8%AE%BF%E9%97%AE_CookieManager_%E7%BB%84%E4%BB%B6"></a><strong>从 JavaScript 中访问 CookieManager 组件</strong></span></p>
+
+<pre>// xpconnect to cookiemanager
+// get the cookie manager component in JavaScript
+var cmgr = Components.classes["@mozilla.org/cookiemanager;1"]
+ .getService();
+cmgr = cmgr.QueryInterface(Components.interfaces.nsICookieManager);
+
+// called as part of a largerDeleteAllCookies() function
+function FinalizeCookieDeletions() {
+ for (var c=0; c&lt;deletedCookies.length; c++) {
+ cmgr.remove(deletedCookies[c].host,
+ deletedCookies[c].name,
+ deletedCookies[c].path);
+ }
+ deletedCookies.length = 0;
+}
+</pre>
+
+<div class="side-note">
+<p><span id="%E4%BB%8E%E6%8E%A5%E5%8F%A3%E8%BF%9E%E6%8E%A5%E5%88%B0%E7%BB%84%E4%BB%B6"><a id="%E4%BB%8E%E6%8E%A5%E5%8F%A3%E8%BF%9E%E6%8E%A5%E5%88%B0%E7%BB%84%E4%BB%B6"></a><strong>从接口连接到组件</strong></span></p>
+
+<p>Mozilla 中使用的从 JavaScript 访问 XPCOM 组件的技术称为<em>XPConnect</em>, XPConnect 也是一个组件.</p>
+
+<p>XPConnect 把应用程序代码与 Mozilla 浏览器, 基于 Gecko 的 XUL, 和象 xpcshell 这样的 JavaScript 环境绑定在一起.</p>
+
+<p>xpcshsell 是 Mozilla 内嵌的 XPCOM 工具, 它是 JavaScript 的命令行解释器.</p>
+
+<p>参看 <a class="external" href="http://www.mozilla.org/scriptable/" rel="freelink">http://www.mozilla.org/scriptable/</a>, 获取更多关于 XPConnect 和 JavaScript 的信息.</p>
+</div>
+
+<p>上面展现的技术当然并不是 XPCOM 的全部, 但是却是一个重要的方面. XPCOM 强加的契约打开了一扇通往<em>二进制互操作</em>技术的大门. - 这是一种能够在运行时刻访问, 使用, 重用 XPCOM 组件的技术, 这种技术能够保证用某种语言编写的组件能够被其他的语言所访问.</p>
+
+<p>在 Mozilla 浏览器中, 组件常常通过接口在 JavaScript 中访问, 搜索 Mozilla 的源代码, 会发现 CookieManager 组件<em>只是</em>在 JavaScript 中被调用. 在本教程中, 我们也使用这种方式来访问它<sup><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Guide/Creating_components/Using_XPCOM_Components#endnote_教程中使用的_coocki_管理器">[教程中使用的 coocki 管理器]</a></sup>.</p>
+
+<div class="side-note">
+<p><span id="JavaScript_%E4%B8%8E_Mozilla"><a id="JavaScript_%E4%B8%8E_Mozilla"></a><strong>JavaScript 与 Mozilla</strong></span></p>
+
+<p>JavaScript 是 Mozilla 浏览器的喉舌, 它把自己与 XPCOM 紧紧地绑定在一起. XPCOM 的这种<em>可扩展</em>能力 - 从 XPConnect 绑定的语言中访问组件的能力, 是 XPCOM 的一个关键属性.</p>
+</div>
+
+<h4 id="WebBrowserFind_.E7.BB.84.E4.BB.B6" name="WebBrowserFind_.E7.BB.84.E4.BB.B6"><code>WebBrowserFind</code> 组件</h4>
+
+<p>组件的应用是广泛的: 在浏览这样的高级应用中, 会有 <code>nsWebBrowserFind</code> 这样的接口, 它提供 <code>find()</code> 和 <code>findNext()</code> 方法用于在网页上查找特定内容. 在一些低级应用中, 会提供数据管理这样的功能. 虽然 Mozilla 并不能将所有的 API 都写成 XPCOM 组件的形式, 但是绝大多数浏览器的典型功能都是用 XPCOM 的组件形式实现的, 因此可以被嵌入和扩展.</p>
+
+<p>除了 CookieManager 组件, 这里还要介绍一个 WebBrowserFind 组件. 它实现的 <code>nsIWebBrowserFind</code> 接口见下表 <a href="#nsIWebBrowserFind_接口">nsIWebBrowserFind 接口</a>.</p>
+
+<p><span id="nsIWebBrowserFind_%E6%8E%A5%E5%8F%A3"><a id="nsIWebBrowserFind_%E6%8E%A5%E5%8F%A3"></a><strong>nsIWebBrowserFind 接口</strong></span></p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>findNext</code></td>
+ <td>找到字符串出现的下一个位置.</td>
+ </tr>
+ <tr>
+ <td><code>findBackwards</code></td>
+ <td>布尔类型属性值, 控制 <code>findNext()</code> 方法向前/向后搜索.</td>
+ </tr>
+ <tr>
+ <td><code>searchFrames</code></td>
+ <td>布尔类型属性值, 标识是否搜索当前页面的子框(subframes).</td>
+ </tr>
+ <tr>
+ <td><code>matchCase</code></td>
+ <td>布尔类型属性值, 标识是否按照大小写匹配搜索网页.</td>
+ </tr>
+ <tr>
+ <td><code>entireWord</code></td>
+ <td>布尔类型属性值, 标识是否匹配整个词.</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>一旦我们使用接口来获的了某个组件, 我们就可以询问该组件是否支持其他的接口. 这种基本服务由 <code>nsISupports</code> 接口提供, 会由所有的 XPCOM 组件继承; 它允许我们查询组件的接口, 并在接口之间进行切换; 它展现了 XPCOM 的<em>运行时刻确定类型</em>的能力. 它由 <code>QueryInterface</code> 方法实现, 我们将在后面<a href="cn/Creating_XPCOM_Components/%e4%bb%80%e4%b9%88%e6%98%af_XPCOM%3f">什么是 XPCOM?</a>一章中介绍. <a href="cn/XPCOM_API_Reference">XPCOM API Reference</a> 中提供了完整的 XPCOM 组件的索引.</p>
+
+<h4 id="WebLock_.E7.BB.84.E4.BB.B6" name="WebLock_.E7.BB.84.E4.BB.B6"><strong>WebLock</strong> 组件</h4>
+
+<p>现在我们把 <strong>WebLock</strong> 组件看成另一个 XPCOM 组件的例子. 在面向对象编程中, 通常是先设计接口 - 首先定义要提供的功能, 而不是考虑如何实现这些功能. 因此我们把实现这个组件的细节问题放到下一章, 这一章先考虑从外部如何看待这个组件. - 即定义 WebLock 组件的接口.</p>
+
+<p><span id="IWebLock_%E6%8E%A5%E5%8F%A3"><a id="IWebLock_%E6%8E%A5%E5%8F%A3"></a><strong>IWebLock 接口</strong></span></p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>lock</code></td>
+ <td>锁定浏览器到当前站点, 或者是磁盘上保存的某个白名单上的站点.</td>
+ </tr>
+ <tr>
+ <td><code>unlock</code></td>
+ <td>解开浏览器锁定, 开放访问所有站点.</td>
+ </tr>
+ <tr>
+ <td><code>addSite</code></td>
+ <td>添加一个新的站点到白名单.</td>
+ </tr>
+ <tr>
+ <td><code>removeSite</code></td>
+ <td>从白名单上删除某个站点.</td>
+ </tr>
+ <tr>
+ <td><code>sites</code></td>
+ <td>枚举白名单上的站点.</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>WebLock 组件就是要实现上面接口定义的功能. 它在浏览器启动的时候, 注册自己. 当用户或者管理员点击浏览器上的 weblock 图标时, 类厂会创建对象实例.</p>
+
+<h3 id="Mozilla_.E4.B8.AD.E4.BD.BF.E7.94.A8.E7.9A.84.E7.BB.84.E4.BB.B6" name="Mozilla_.E4.B8.AD.E4.BD.BF.E7.94.A8.E7.9A.84.E7.BB.84.E4.BB.B6">Mozilla 中使用的组件</h3>
+
+<p>那么我们应该如何获得组件, 然后如何在 Mozilla 中使用它呢? 我们在前面已经看到了一小段 JavaScript 代码, 但是我们并没有解释一般情况下该如何获得 XPCOM 组件.</p>
+
+<p>这一节讨论 Mozilla 中实际使用的组件例子. 本节分成三部分: 一部分是关于该如何在 Mozilla 上找到组件. 其他两个部分是关于该如何访问这些组件.</p>
+
+<h4 id=".E6.9F.A5.E6.89.BE_Mozilla_.E7.BB.84.E4.BB.B6" name=".E6.9F.A5.E6.89.BE_Mozilla_.E7.BB.84.E4.BB.B6">查找 Mozilla 组件</h4>
+
+<p>本书试图向读者提供关于 XPCOM 组件和当前冻结的接口的索引信息. <a class="external" href="http://www.mozilla.org/projects/embedding/">Mozilla 嵌入工程</a>跟踪了当前冻结的接口.</p>
+
+<p>Mozilla 包含了 Gecko 提供的查找和显示组件信息的工具 -<em>XPCOM 组件观察器</em><a class="external" href="http://lxr.mozilla.org/">LXR</a>.</p>
+
+<p>提供 XPCOM 组件信息的主要问题是, Mozilla 接口在不断的发展, 试图选择一个冻结的断面是困难的. 组件观察器的实现并没有考虑组件是否已被冻结, 在 LXR 中我们会发现, 被冻结的接口会在头部标记 <code>@status frozen</code>.</p>
+
+<h5 id="XPCOM_.E7.BB.84.E4.BB.B6.E8.A7.82.E5.AF.9F.E5.99.A8" name="XPCOM_.E7.BB.84.E4.BB.B6.E8.A7.82.E5.AF.9F.E5.99.A8">XPCOM 组件观察器</h5>
+
+<p><a class="external" href="http://www.hacksrus.com/~ginda/cview">组件观察器</a> 是一个可选安装的浏览器插件.</p>
+
+<p><span id="XPCOM_%E7%BB%84%E4%BB%B6%E8%A7%82%E5%AF%9F%E5%99%A8"><a id="XPCOM_%E7%BB%84%E4%BB%B6%E8%A7%82%E5%AF%9F%E5%99%A8"></a><strong>XPCOM 组件观察器</strong></span></p>
+
+<p><img alt="Image:using-component-viewer.png"></p>
+
+<p>在上面的图中, 左列显示的是以<em>gtx</em> 字符串搜索契约 ID 得到的组件子集, 右列是左列选中组件实现的接口.</p>
+
+<p>XPCOM 观察器在获取组件的大致信息的时候非常有用, 但是要知道组件观察器显示的是<em>所有</em>的组件, 有些组件并不稳定, 组件的接口可能会在后续版本中变化, 所以要慎重选取我们自己工程中使用的组件.</p>
+
+<p><span class="comment">XXX mediawiki is t3h suxx0r</span> <span class="comment">XXX give me my C++</span></p>
+
+<h4 id=".E5.9C.A8_Cpp_.E4.BB.A3.E7.A0.81.E4.B8.AD.E4.BD.BF.E7.94.A8_XPCOM_.E7.BB.84.E4.BB.B6" name=".E5.9C.A8_Cpp_.E4.BB.A3.E7.A0.81.E4.B8.AD.E4.BD.BF.E7.94.A8_XPCOM_.E7.BB.84.E4.BB.B6">在 Cpp 代码中使用 XPCOM 组件</h4>
+
+<p>XPConnect 把对 XPCOM 组件作为 JavaScript 对象, 使得对 XPCOM 组件的访问变得非常简单, 从 C++ 代码中访问 XPCOM 要复杂一些.</p>
+
+<p><a href="#从_Cpp_代码管理_Cookies">从 Cpp 代码管理 Cookies</a> 以 C++ 代码重新实现了<a href="#从_JavaScript_中访问_CookieManager_组件">从 JavaScript 中访问 CookieManager 组件</a>的功能.</p>
+
+<p><span id="%E4%BB%8E_Cpp_%E4%BB%A3%E7%A0%81%E7%AE%A1%E7%90%86_Cookies"><a id="%E4%BB%8E_Cpp_%E4%BB%A3%E7%A0%81%E7%AE%A1%E7%90%86_Cookies"></a><strong>从 Cpp 代码管理 Cookies</strong></span></p>
+
+<pre>nsCOMPtr&lt;nsIServiceManager&gt; servMan;
+nsresult rv = NS_GetServiceManager(getter_AddRefs(servMan));
+if (NS_FAILED(rv))
+ return -1;
+
+nsCOMPtr&lt;nsICookieManager&gt; cookieManager;
+rv = servMan-&gt;GetServiceByContractID("@mozilla.org/cookiemanager",
+ NS_GET_IID(nsICookieManager),
+ getter_AddRefs(cookieManager));
+
+if (NS_FAILED(rv))
+ return -1;
+
+PRUint32 len;
+deletedCookies-&gt;GetLength(&amp;len);
+
+for (int c=0; c&lt;len; c++)
+ cookieManager-&gt;Remove(deletedCookies[c].host,
+ deletedCookies[c].name,
+ deletedCookies[c].path,
+ PR_FALSE);
+</pre>
+
+<p><span class="comment">XXX: In the original document, there were only the first three parameters to the |Remove| call. I added |PR_TRUE| as a fourth parameter because the interface seems to require it: <a class="external" href="http://lxr.mozilla.org/mozilla/source/netwerk/cookie/public/nsICookieManager.idl#64" rel="freelink">http://lxr.mozilla.org/mozilla/sourc...Manager.idl#64</a> This problem also appears in the JavaScript version below, and I've added |false| as a fourth parameter there as well.</span></p>
+
+<p>如果我们的应用是用 C++ 编写, <a href="#从_Cpp_代码管理_Cookies">从 Cpp 代码管理 Cookies</a> 这段代码向我们提供了很好的模板.</p>
+
+<h4 id="XPConnect:_.E5.9C.A8.E8.84.9A.E6.9C.AC.E4.B8.AD.E4.BD.BF.E7.94.A8_XPCOM_.E7.BB.84.E4.BB.B6" name="XPConnect:_.E5.9C.A8.E8.84.9A.E6.9C.AC.E4.B8.AD.E4.BD.BF.E7.94.A8_XPCOM_.E7.BB.84.E4.BB.B6">XPConnect: 在脚本中使用 XPCOM 组件</h4>
+
+<p>在本章开始我们讨论了CookieManager组件,他提供了一个很好的例子来说明如何使用javascript访问组件.在下面的代码片断里你可以看到如何通过getService()方法创建一个CookieManager组件对象,并且通过它提供的功能来让我们从用户界面来读取和删除cookies.</p>
+
+<p><span id="Managing_Cookies_from_JavaScript"><a id="Managing_Cookies_from_JavaScript"></a><strong>Managing Cookies from JavaScript</strong></span></p>
+
+<pre>var cmgr = Components.classes["@mozilla.org/cookiemanager;1"]
+ .getService();
+cmgr = cmgr.QueryInterface(Components.interfaces.nsICookieManager);
+
+function loadCookies() {
+ // load cookies into a table
+ var enumerator = cmgr.enumerator;
+ var count = 0;
+ var showPolicyField = false;
+ while (enumerator.hasMoreElements()) {
+ var nextCookie = enumerator.getNext();
+ nextCookie = nextCookie.QueryInterface(Components.interfaces.nsICookie);
+ /* .... */
+}
+function FinalizeCookieDeletions() {
+ for (var c=0; c&lt;deletedCookies.length; c++) {
+ cmgr.remove(deletedCookies[c].host,
+ deletedCookies[c].name,
+ deletedCookies[c].path,
+ false);
+ }
+ deletedCookies.length = 0;
+}
+</pre>
+
+<p><span class="comment">XXX: In the original document, there were only the first three parameters to the |remove| call. I added |false| as a fourth parameter because the interface seems to require it: <a class="external" href="http://lxr.mozilla.org/mozilla/source/netwerk/cookie/public/nsICookieManager.idl#64" rel="freelink">http://lxr.mozilla.org/mozilla/sourc...Manager.idl#64</a> This problem also appears in the C++ version above, and I've added |PR_FALSE| as a fourth parameter there as well.</span></p>
+
+<p>除了CookieManager被调用的方法以外(也就是<code>cookiemanager.remove</code>(他会映射到<code>remove()</code><a href="#The_&lt;code>nsICookieManager&lt;/code>_Interface">The <code>nsICookieManager</code> Interface</a>),请注意那些在Javascript中反映XPCOM组件的专门的XPConnect对象和方法。</p>
+
+<p><code>Components</code> 是用来控制到组件连接的JavaScript对象, 而<code>classes</code> 是一组所有你可以根据契约ID来查询的对象。为了在Javascript中实例化XPCOM组件,你创建一个新的<code>Component</code>对象同时传入你所需要查询的组件契约ID,返回的可能是一个singleton或者一个实例。</p>
+
+<pre>var cmgr = Components.classes["@mozilla.org/cookiemanager;1"]
+ .getService();
+</pre>
+
+<p><code>cookiemanager</code> 对象的结果提供组件的所有在IDL中编译好然后编译到类型库中的方法的入口。 使用CookieManager组件, 你可以写如下的代码来完成从系统中清除所有cookies的操作:</p>
+
+<pre>cmgr = Components.classes["@mozilla.org/cookiemanager;1"]
+ .getService();
+cmgr = cmgr.QueryInterface(Components.interfaces.nsICookieManager);
+
+// delete all cookies
+function trashEm() {
+ cmgr.removeAll();
+}
+</pre>
+
+<p>这个例子所展示的另外一个关键的XPConnect特性的是可以在所有从XPCOM映射到javascript的对象上执行的<code>QueryInterface</code>方法。如同在C++中, 你可以使用这个方法询问给定对象的别的接口。</p>
+
+<div class="side-note">
+<p><span id="Services_Versus_Regular_Instances"><a id="Services_Versus_Regular_Instances"></a><strong>Services Versus Regular Instances</strong></span></p>
+
+<p>到底让客户把你的组件作为一个实例还是服务是一个设计问题,你应当在你的组件文挡中进行描述。实际上,例子中通过方法<code>createInstance()调用</code><code>getService()</code>方法的方法实际上也可以是对组件对象调用并且缓存结果,并让他做为一个singlenton而不是实例。</p>
+
+<p>用来建立服务的singleton设计模式在<a href="cn/Creating_XPCOM_Components/What_is_XPCOM%3f#XPCOM_Services">XPCOM Services</a>进行描述。</p>
+</div>
+
+<p>请记住,<code>QueryInterface</code>让你查询一个对象所支持的接口。在<a href="#The_&lt;code>nsICookieManager&lt;/code>_Interface">The <code>nsICookieManager</code> Interface</a>的代码片断中, <code>QueryInterface</code>方法被用来从eunumerator中获得<code>nsICookie</code>接口,从而, 比如说, JavaScript代码就可以获得每个cookie的<code>value</code>和<code>name</code>属性。</p>
+
+<ol>
+ <li><div class="blockIndicator note"><strong>Note:</strong> cookie-manager-ui</div> 注意接口不是组件的一部分. XPCOM通过Mozilla's Cross Platform Front End (XPFE)和其他的用户接口使使用CookieManager这样的组件变得容易,但是组件本身并不提供自身的UI。</li>
+</ol>
+
+<ol>
+ <li><div class="blockIndicator note"><strong>Note:</strong> private-xpcom-interfaces</div>这方面也有例外. 一些XPCOM接口也可以是private并且不是作为公用的. Private接口和在IDL中公开的接口要求有所不同。</li>
+</ol>
+
+<ol>
+ <li><div class="blockIndicator note"><strong>Note:</strong> cookie-manager-in-tutorial</div> CookieManager组件用来支持本教程所描述的网页所定功能。</li>
+</ol>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/创建_XPCOM_组件:XPCOM_简介" style="float: left;">« 上一页</a><a href="/zh-CN/docs/Creating_XPCOM_Components:Component_Internals">下一页 »</a></p>
+</div> <p></p><div class="licenseblock">
+<p>Copyright (c) 2003 by Doug Turner and Ian Oeschger. This material may be distributed only subject to the terms and conditions set forth in the <a class="external" href="http://www.opencontent.org/openpub/" rel="noopener">Open Publication License</a>, v1.02 or later. Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.</p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/using_xpcom_utilities_to_make_things_easier/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/using_xpcom_utilities_to_make_things_easier/index.html
new file mode 100644
index 0000000000..98bb510dd8
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/creating_components/using_xpcom_utilities_to_make_things_easier/index.html
@@ -0,0 +1,388 @@
+---
+title: 创建XPCOM组件/使用XPCOM工具类让事情变得简单
+slug: >-
+ Mozilla/Tech/XPCOM/Guide/Creating_components/Using_XPCOM_Utilities_to_Make_Things_Easier
+tags:
+ - XPCOM
+ - 所有分类
+translation_of: >-
+ Mozilla/Tech/XPCOM/Guide/Creating_components/Using_XPCOM_Utilities_to_Make_Things_Easier
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Creating_XPCOM_Components:Creating_the_Component_Code" style="float: left;">« 上一页</a><a href="/zh-CN/docs/Creating_XPCOM_Components:Starting_WebLock">下一页 »</a></p>
+</div><p></p>
+
+<p>本章回顾你已经在教程第一部分建立的代码 (see <a href="cn/Creating_XPCOM_Components/Creating_the_Component_Code#webLock1.cpp">webLock1.cpp</a> in the previous chapter) 并且使用 XPCOM 工具类让代码更容易更有效. 同时,介绍一个在XPCOM和Gecko API中广泛使用基本的字符串类型.</p>
+
+<p>作为起点,第一部分描述可以替代<code>webLock1.cpp</code>中的很多代码的<em>C++ 宏</em> . 很多用来完成软件组织和组件注册的代码都可以缩减为精简的数据结构和宏代码.</p>
+
+<h3 id="XPCOM_Macros" name="XPCOM_Macros">XPCOM Macros</h3>
+
+<p>XPCOM 架构包含了一系列宏让C++开发变得简单. 尽管有某些重叠(例如,高层的宏可以用其他的宏来组织),他们通常可以组织成如下的类别.</p>
+
+<h4 id="Generic_XPCOM_Module_Macros" name="Generic_XPCOM_Module_Macros">Generic XPCOM Module Macros</h4>
+
+<p>The work in the <a href="cn/Creating_XPCOM_Components/Creating_the_Component_Code">previous chapter</a> was useful in setting up the generic component code. But there are only a few places in that code that are unique to the <strong>WebLock</strong> component, and it was a lot of typing. To write a different component library, you could copy the listing at the end of the chapter, change very little, and paste it into a new project. To avoid these kinds of redundancies, to regulate the way generic code is written, and to save typing, XPCOM provides<em>generic module macros</em> that expand into the module code you've already seen.</p>
+
+<p>Since these macros expand into "generic" implementations, they may not offer as much flexibility as you have when you are writing your own implementation. But they have the advantage of allowing much more rapid development. To get an idea about how much can be handled with the macros described in this section, compare the code listing in <a href="#weblock2.cpp">weblock2.cpp</a> at the end of the chapter with <a href="cn/Creating_XPCOM_Components/Creating_the_Component_Code#webLock1.cpp">webLock1.cpp</a> in the previous chapter.</p>
+
+<p>The module macros include one set of macros that define the exported <code>NSGetModule</code> entry point, the required <code>nsIModule</code> implementation code and another that creates a generic factory for your implementation class. Used together, these macros can take care of a lot of the component implementation code and leave you working on the actual logic for your component.</p>
+
+<div class="side-note">
+<p>Note that all of the macros described in this section are similar but are used in slightly different situations. Some differ only in whether or not a method is called when the module is created and/or destroyed. <a href="#XPCOM_Module_Macros">XPCOM Module Macros</a> lists the macros discussed in this section.</p>
+</div>
+
+<p><span id="XPCOM_Module_Macros"><a id="XPCOM_Module_Macros"></a><strong>XPCOM Module Macros</strong></span></p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Macro</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>NS_IMPL_NSGETMODULE(name, components)</code></td>
+ <td>Implements the <code>nsIModule</code> interface with the module name of <code>name</code> and the component list in <code>components</code>.</td>
+ </tr>
+ <tr>
+ <td><code>NS_IMPL_NSGETMODULE_WITH_CTOR(name, components, ctor)</code></td>
+ <td>Same as above but allows for a special function to be called when the module is created.</td>
+ </tr>
+ <tr>
+ <td><code>NS_IMPL_NSGETMODULE_WITH_DTOR(name, components, dtor)</code></td>
+ <td>Same as the first macro but allows for a special function to be called when the module is destroyed.</td>
+ </tr>
+ <tr>
+ <td><code>NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(name, components, ctor, dtor)</code></td>
+ <td>This combines the last two macros so that you can define functions to be called at the construction and destruction of the module object.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h5 id="Module_Implementation_Macros" name="Module_Implementation_Macros">Module Implementation Macros</h5>
+
+<p>The general case is to use <code>NS_IMPL_NSGETMODULE</code>, which doesn't take any callbacks, but all the macros follow the same general pattern. All of these macros work on an array of structures represented by the <code>components</code> parameter. Each structure describes a CID that is to be registered with XPCOM.</p>
+
+<p>The first parameter for each of these macros is an arbitrary string that names the module. In a debugging environment, this string will be printed to the screen when the component library is loaded or unloaded. You should pick a name that makes sense and helps you keep track of things. The four required parts<sup><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Guide/Creating_components/Using_XPCOM_Utilities_to_Make_Things_Easier#endnote_other-parts">[other-parts]</a></sup> of the structure contain the following information:</p>
+
+<ul>
+ <li>A human readable class name</li>
+ <li>the class ID (CID)</li>
+ <li>the contract ID (an optional but recommended argument)</li>
+ <li>a constructor for the given object</li>
+</ul>
+
+<pre>static const nsModuleComponentInfo components[] =
+{
+ { "Pretty Class Name",
+ CID,
+ CONTRACT_ID,
+ Constructor
+ },
+ // ...
+};
+</pre>
+
+<p>The important thing to note in the fictitious listing above is that it can support multiple components in a module. Modules such as the networking libraries in Gecko ("necko") have over 50 components declared in a single <code>nsModuleComponentInfo</code> array like this.</p>
+
+<p>The first entry of the <code>nsModuleComponentInfo</code> above is the name of the component. Though it isn't used that much internally at the present time, this name should be something that meaningfully describes the module.</p>
+
+<p>The second entry of the <code>nsModuleComponentInfo</code> is the CID. The usual practice is to put the class ID (CID) into a <code>#define</code> and use the define to declare the CID in the components list. Many CIDs take the following form:</p>
+
+<pre>#define NS_IOSERVICE_CID \
+{ /* 9ac9e770-18bc-11d3-9337-00104ba0fd40 */ \
+ 0x9ac9e770, \
+ 0x18bc, \
+ 0x11d3, \
+ {0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
+}
+</pre>
+
+<p>The next entry is the Contract ID string, which is also usually defined in a <code>#define</code> in a header file.</p>
+
+<p>These three entries constitute the required parameters for the <code>RegisterFactoryLocation</code> method we looked at in the prior chapter. When you use these implementation macros, you must declare a constructor for the object, and this keeps you from having to write a factory object.</p>
+
+<h5 id="Factory_Macros" name="Factory_Macros">Factory Macros</h5>
+
+<p>The factory macro makes it easy to write factory implementations. Given the class name <code>ConcreteClass</code>, the factory macro declaration is:</p>
+
+<pre>NS_GENERIC_FACTORY_CONSTRUCTOR(ConcreteClass)
+</pre>
+
+<p>This results in a function called <code>ConcreteClassConstructor</code> that can be used in the <code>nsModuleComponentInfo</code> structure.</p>
+
+<pre>#include "nsIGenericFactory.h"
+
+static const nsModuleComponentInfo components[] =
+{
+ { "Pretty Class Name",
+ SAMPLE_CID,
+ "@company.com/sample",
+ SampleConstructor
+ }
+}
+
+NS_IMPL_NSGETMODULE(nsSampleModule, components)
+</pre>
+
+<p>Most of the components in the Mozilla browser client use this approach.</p>
+
+<h4 id="Common_Implementation_Macros" name="Common_Implementation_Macros">Common Implementation Macros</h4>
+
+<p>Every XPCOM object implements <code>nsISupports</code>, but writing this implementation over and over is tedious. Unless you have very special requirements for managing reference counting or handling interface discovery, the<em>implementation macros</em> that XPCOM provides can be used. Instead of implementing the <code>nsISupports</code> yourself, <code>NS_IMPL_ISUPPORTS1</code> can expand to the implementation of <code>AddRef</code>, <code>Release</code>, and <code>QueryInterface</code> for any object.</p>
+
+<pre>NS_IMPL_ISUPPORTS1(classname, interface1)
+</pre>
+
+<p>Also, if you implement more than one interface, you can simply change the <code>1</code> in the macro to the number of interfaces you support and list the interfaces, separated by commas. For example:</p>
+
+<pre>NS_IMPL_ISUPPORTS2(classname, interface1, interface2)
+NS_IMPL_ISUPPORTSn(classname, interface1, ..., interfacen)
+</pre>
+
+<p>These macros automatically add the <code>nsISupports</code> entry for you, so you don't need to do something like this:</p>
+
+<pre class="eval">NS_IMPL_ISUPPORTS2(classname, interface1, <strong>nsISupports</strong>)
+</pre>
+
+<p><br>
+ Take a close look at the above example. Note that it uses the actual name of the interface and not an IID. Inside the macro, the interface name expands to <code>NS_GET_IID()</code>, which is another macro that extracts the IID from the generated header of the interface. When an interface is written in XPIDL, the headers include static declarations of their IIDs. On any interface that is generated by XPIDL, you can call <code>NS_GET_IID()</code> to obtain the IID which is associated with that interface.</p>
+
+<pre>// returns a reference to a shared nsIID object\
+static const nsIID iid1 = NS_GET_IID(nsISupports);
+
+// constructs a new nsIID object
+static const nsIID iid2 = NS_ISUPPORTS_IID;
+</pre>
+
+<p>In order to use <code>NS_IMPL_ISUPPORTSn</code>, you must be sure that a member variable of type <code>nsrefcnt</code> is defined and named <code>mRefCnt</code> in your class. But why even bother when you can use another macro?</p>
+
+<h4 id="Declaration_Macros" name="Declaration_Macros">Declaration Macros</h4>
+
+<p><code>NS_DECL_NSISUPPORTS</code> declares <code>AddRef</code>, <code>Release</code>, and <code>QueryInterface</code> for you, and it also defines the <code>mRefCnt</code> required by <code>NS_IMPL_ISUPPORTS</code>. Furthermore, <code>NS_DECL_</code> appended with any interface name in all caps will declare all of the methods of that interface for you. For example, <code>NS_DECL_NSIFOO</code> will declare all of the methods of <code>nsIFoo</code> provided that it exists and that <code>nsIFoo.h</code> was generated by the XPIDL compiler. Consider the following real class:</p>
+
+<pre>class myEnumerator : public nsISimpleEnumerator
+{
+ public:
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSISIMPLEENUMERATOR
+
+ myEnumerator();
+ virtual ~myEnumerator() {}
+};
+</pre>
+
+<p>The declaration of this <code>nsISimpleEnumerator</code> class doesn't include any methods other than the contructor and destructor. Instead, the class uses the <code>NS_DECL_</code> macro<sup><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Guide/Creating_components/Using_XPCOM_Utilities_to_Make_Things_Easier#endnote_nsISupports-warning">[nsISupports-warning]</a></sup>.</p>
+
+<p>Using these declaration macros not only saves a tremendous amount of time when you're writing the code, it can also save time if you make changes to your IDL file, since the C++ header file will then automatically include the updated list of methods to be supported.</p>
+
+<div class="side-note">
+<p>The <code>NS_INIT_ISUPPORTS</code> macro is also a bit of a special case. Historically, it gets called in the constructor for your class and sets <code>mRefCnt</code> to zero. However, a change in XPCOM that occurred before Mozilla 1.3 makes <code>NS_INIT_ISUPPORTS</code> no longer necessary: <code>mRefCnt</code>'s type has been changed from an integer to a class that provides its own auto-initialization. If you are building with versions earlier than Mozilla 1.3, this macro is still required.</p>
+</div>
+
+<p>The following table summarizes the macro usage in this portion of the <code>weblock.cpp</code> source file:</p>
+
+<p><span id="Common_XPCOM_Macros"><a id="Common_XPCOM_Macros"></a><strong>Common XPCOM Macros</strong></span></p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>NS_IMPL_ISUPPORTSn</code></td>
+ <td>Implements <code>nsISupports</code> for a given class with <code>n</code> number of interfaces</td>
+ </tr>
+ <tr>
+ <td><code>NS_DECL_ISUPPORTS</code></td>
+ <td>Declares methods of <code>nsISupports</code> including <code>mRefCnt</code></td>
+ </tr>
+ <tr>
+ <td><code>NS_INIT_ISUPPORTS</code></td>
+ <td>Initializes <code>mRefCnt</code> to zero. Must be called in class's constructor</td>
+ </tr>
+ <tr>
+ <td><code>NS_GET_IID</code></td>
+ <td>Returns the IID given the name of an interface. Interface must be generated by XPIDL</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>Using the macros described here, the code for the <strong>WebLock</strong> component has gone from around 340 lines of code to just under 40. Clearly from a code maintenance point of view, this kind of reduction is outstanding. The entire source file with these macros included appears in <a href="#weblock2.cpp">weblock2.cpp</a>.</p>
+
+<h3 id="weblock2.cpp" name="weblock2.cpp">weblock2.cpp</h3>
+
+<p>The listing below shows the generic module code from <a href="cn/Creating_XPCOM_Components/Creating_the_Component_Code#webLock1.cpp">webLock1.cpp</a> using the macros described in this chapter:</p>
+
+<p><span id="weblock2.cpp"><a id="weblock2.cpp"></a><strong>weblock2.cpp</strong></span></p>
+
+<pre>#include "nsIGenericFactory.h"
+#include "nsISupportsUtils.h"
+
+#define SAMPLE_CID \
+{ 0x777f7150, 0x4a2b, 0x4301, \
+{ 0xad, 0x10, 0x5e, 0xab, 0x25, 0xb3, 0x22, 0xaa}}
+
+class Sample: public nsISupports
+{
+ public:
+ Sample();
+ virtual ~Sample();
+
+ NS_DECL_ISUPPORTS
+};
+
+Sample::Sample()
+{
+ // note: in newer versions of Gecko (1.3 or later)
+ // you don't have to do this:
+ NS_INIT_ISUPPORTS();
+}
+
+Sample::~Sample()
+{
+}
+
+NS_IMPL_ISUPPORTS1(Sample, nsISupports);
+
+NS_GENERIC_FACTORY_CONSTRUCTOR(Sample);
+
+static const nsModuleComponentInfo components[] =
+{
+ { "Pretty Class Name",
+ SAMPLE_CID,
+ "@company.com/sample",
+ SampleConstructor
+ }
+};
+
+NS_IMPL_NSGETMODULE(nsSampleModule, components)
+</pre>
+
+<h3 id="String_Classes_in_XPCOM" name="String_Classes_in_XPCOM">String Classes in XPCOM</h3>
+
+<p>Strings are usually thought of as linear sequences of characters. In C++, the string literal "XPCOM", for example, consists of 6 consecutive bytes, where `X' is at byte offset zero and a null character is at byte offset 5. Other kinds of strings like "wide" strings use two bytes to represent each character, and are often used to deal with Unicode strings.</p>
+
+<p>The string classes in XPCOM are not just limited to representing a null terminated sequence of characters, however. They are fairly complex because they support the Gecko layout engine and other subsystems that manage large chunks of data. Additionally, in some versions of Mozilla the string classes support sequences of characters broken up into multiple fragments (fragments which may or may not be null terminated)<sup><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Guide/Creating_components/Using_XPCOM_Utilities_to_Make_Things_Easier#endnote_nulls-in-strings">[nulls-in-strings]</a></sup>.</p>
+
+<p>All string classes in XPCOM derive from one of two abstract classes<sup><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Guide/Creating_components/Using_XPCOM_Utilities_to_Make_Things_Easier#endnote_other-string-classes">[other-string-classes]</a></sup>: <code>nsAString</code> and <code>nsACString</code>. The former handles double byte characters, and the latter tends to be used in more general circumstances, but both of these classes define the functionality of a string. You can see these classes being passed as arguments in many of the XPCOM interfaces we'll look at in the following chapters.</p>
+
+<h4 id="Using_Strings" name="Using_Strings">Using Strings</h4>
+
+<p>Explaining how all the string classes work is outside the scope of this book, but we can show you how to use strings in the <strong>WebLock</strong> component. The first thing to note is that the string classes themselves are not frozen, which means that you should not link against them when you can avoid it.</p>
+
+<p>Linking the full string library (<code>.lib</code> or <code>.a</code>) into a component may raise its footprint by more than 100k (on Windows), which in many cases is an unacceptable gain (see the <a href="cn/XPCOM_string_guide">XPCOM string guide</a>). For <strong>WebLock</strong>, where the string classes need to be only wrappers around already existing string data, trading advanced functionality for a much smaller footprint is the right way to go. The <strong>WebLock</strong> string classes don't need to append, concatenate, search, or do any other real work on the string data; they just need to represent <code>char*</code> and other data and pass them to methods that expect an <code>nsACString</code>.</p>
+
+<h4 id="nsEmbedString_and_nsEmbedCString" name="nsEmbedString_and_nsEmbedCString"><code>nsEmbedString</code> and <code>nsEmbedCString</code></h4>
+
+<p>The strings used in this tutorial are <code>nsEmbedString</code> and <code>nsEmbedCString</code>, which implement the <code>nsAString</code> abstract class and the <code>nsACString</code> abstract classes, respectively. This first example shows an <code>nsEmbedCString</code> being used to pass an <code>nsACString</code> to a method that's not expected to modify the string.</p>
+
+<pre>// in IDL: method(in ACString thing);
+
+char* str = "How now brown cow?";
+nsEmbedCString data(str);
+rv = object-&gt;Method(data);
+</pre>
+
+<p>In this next example, the method is going to set the value of the string - as it might need to do when it returns the name of the current user or the last viewed URL.</p>
+
+<pre>// in IDL: attribute ACString data;
+
+nsEmbedCString data;
+method-&gt;GetData(data);
+
+// now to extract the data from the url class:
+
+const char* aStringURL = data.get();
+</pre>
+
+<p>Note that the memory pointed to by <code>aStringURL</code> after the call to <code>url.get()</code> is owned by the URL string object. If you need to keep this string data around past the lifetime of the string object, you must make a copy.</p>
+
+<div class="side-note">
+<p><span id="String_Size"><a id="String_Size"></a><strong>String Size</strong></span></p>
+
+<p>The examples above illustrate the use of the single byte string class, <code>nsEmbedCString</code>. The double byte version, <code>nsEmbedString</code>, has the same functionality but the constructor takes <code>nsAString</code> and the .get() method returns the type <code>PRUnichar*</code>. Note that <code>PRUnichar</code> is a two byte value. In the coming chapters, you'll see examples that use this version in the <strong>WebLock</strong> component.</p>
+</div>
+
+<h3 id="Smart_Pointers" name="Smart_Pointers">Smart Pointers</h3>
+
+<p>All of the interfaces that you've seen so far are reference counted. Leaking a reference by not releasing an object, as the code below demonstrates, can be a major problem.</p>
+
+<pre>{
+ nsISupports* value = nsnull;
+ object-&gt;method(&amp;value);
+ if (!value) return;
+
+ // ...
+
+ if (NS_FAILED(error))
+ return; // &lt;------------ leaks |value|
+ //...
+
+ NS_RELEASE(value); // release our reference
+}
+</pre>
+
+<p>A method returns an <code>nsISupports</code> interface pointer that has been reference counted before it is returned (assuming it wasn't <code>nsnull</code>). If you handle an error condition by returning prematurely, whatever value points at will leak-it will never be deleted. This is a trivial fix in this example, but in real code, this can easily happen in <code>goto</code> constructs, or in deep nesting with early <code>return</code>s.</p>
+
+<p>Having more than one interface pointer that needs to be released when a block goes out of scope begs for a tool that can aid the developer. In XPCOM, this tool is the <code>nsCOMPtr</code>, or<em>smart pointer</em> class, which can save you countless hours and simplify your code when you're dealing with interface pointers. Using smart pointers, the code above can be simplified to:</p>
+
+<pre>{
+ nsCOMPtr&lt;nsISupports&gt; value;
+ object-&gt;method(getter_AddRefs(value));
+ if (!value) return;
+
+ // ...
+
+ if (NS_FAILED(error))
+ return;
+ // ...
+}
+</pre>
+
+<p>The style or syntax may be unfamilar, but smart pointers are worth learning and using because they simplify the task of managing references. <code>nsCOMPtr</code> is a C++ template class that acts almost exactly like raw pointers, that can be compared and tested, and so on. When you pass them to a getter, you must do something special, however: You must wrap the variable with the function <code>getter_AddRefs</code>, as in the example above.</p>
+
+<p>You cannot call the <code>nsISupports</code> <code>AddRef</code> or <code>Release</code> methods on a <code>nsCOMPtr</code>. But this restriction is desirable, since the <code>nsCOMPtr</code> is handling reference counting for you. If for some reason you need to adjust the reference count, you must assign the <code>nsCOMPtr</code> to a new variable and <code>AddRef</code> that. This is a common pattern when you have a local <code>nsCOMPtr</code> in a function and you must pass back a reference to it, as in the following:</p>
+
+<pre>SomeClass::Get(nsISupports** aResult)
+{
+ if (!aResult)
+ return NS_ERROR_NULL_POINTER;
+
+ nsCOMPtr&lt;nsISupports&gt; value;
+ object-&gt;method(getter_AddRefs(value));
+
+ *aResult = value.get();
+ NS_IF_ADDREF(*aResult);
+ return NS_OK;
+}
+</pre>
+
+<p>The first thing that this method does is check to see that the caller passed a valid address. If not, it doesn't even try to continue. Next, it calls another method on an object that is presumed to exist in this context. You can call a <code>.get()</code> method on the <code>nsCOMPtr</code> and have it returned for use as a raw pointer. This raw pointer can then be assigned to a variable and have its reference updated by <code>NS_IF_ADDREF</code>. Be very careful with the result of <code>.get()</code>, however. You should never call <code>Release</code> on this result because it may result in a crash. Instead, to explicitly release the object being held by a <code>nsCOMPtr</code>, you can assign zero to that pointer.</p>
+
+<p>Another nice feature of smart pointers - the part that makes them smart - is that you can <code>QueryInterface</code> them quite easily. For example, there are two interfaces for representing a file on a file system, the <code>nsIFile</code> and <code>nsILocalFile</code>, and they are both implemented by an object. Although we haven't formally introduced these two interfaces, the next code sample shows how simple it is to switch between these two interface:</p>
+
+<pre>SomeClass::DoSomething(nsIFile* aFile)
+{
+ if (!aFile)
+ return NS_ERROR_NULL_POINTER;
+
+ nsresult rv;
+ nsCOMPtr&lt;nsILocalFile&gt; localFile = do_QueryInterface(aFile, &amp;rv);
+ // ...
+}
+</pre>
+
+<p>If the <code>QueryInterface</code> is successful, <code>localFile</code> will be non-null, and <code>rv</code> will be set to <code>NS_OK</code>. If <code>QueryInterface</code> fails, <code>localFile</code> will be null, and <code>rv</code> will be set to a specific error code corresponding to the reason for the failure. In this construct, the result code <code>rv</code> is an optional parameter. If you don't care what the error code is, you can simply drop it from the function call.</p>
+
+<p>From this point on, we'll be using <code>nsCOMPtr</code>s as much as possible in <strong>WebLock</strong>. For a complete listing of smart pointer functionality, see <a class="external" href="http://www.mozilla.org/projects/xpcom/nsCOMPtr/">mozilla.org's <code>nsCOMPtr</code> documentation</a><span class="comment">XXX this should be in devmo</span>.</p>
+
+<ol>
+ <li><div class="blockIndicator note"><strong>Note:</strong> other-parts</div> This section discusses the main parameters of this structure. For a complete listing of all available options you can look at the complete reference in the <a href="cn/XPCOM_API_Reference">XPCOM API Reference</a>.</li>
+ <li><div class="blockIndicator note"><strong>Note:</strong> nsISupports-warning</div> Note that <code>NS_DECL_ISUPPORTS</code> doesn't obey the general rule in which every interface has a declaration macro of the form <code>NS_DECL_INTERFACENAME</code>, where <code>INTERFACENAME</code> is the name of the interface being compiled.</li>
+ <li><div class="blockIndicator note"><strong>Note:</strong> nulls-in-strings</div> The string classes may also support embedded nulls.</li>
+ <li><div class="blockIndicator note"><strong>Note:</strong> other-string-classes</div> There are other abstract string classes, but they are outside the scope of this book.</li>
+</ol>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Creating_XPCOM_Components:Creating_the_Component_Code" style="float: left;">« 上一页</a><a href="/zh-CN/docs/Creating_XPCOM_Components:Starting_WebLock">下一页 »</a></p>
+</div> <p></p><div class="licenseblock">
+<p>Copyright (c) 2003 by Doug Turner and Ian Oeschger. This material may be distributed only subject to the terms and conditions set forth in the <a class="external" href="http://www.opencontent.org/openpub/" rel="noopener">Open Publication License</a>, v1.02 or later. Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.</p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/hashtables/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/hashtables/index.html
new file mode 100644
index 0000000000..24740b535c
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/hashtables/index.html
@@ -0,0 +1,282 @@
+---
+title: Hashtables
+slug: Mozilla/Tech/XPCOM/Guide/Hashtables
+tags:
+ - XPCOM
+ - 所有分类
+translation_of: Mozilla/Tech/XPCOM/Guide/Hashtables
+---
+<p> </p>
+<h2 id="What_Is_a_Hashtable.3F" name="What_Is_a_Hashtable.3F">What Is a Hashtable?</h2>
+<p>A hashtable is a data construct that stores a set of <b>items</b>. Each item has a <b>key</b> that identifies the item. Items are found, added, and removed from the hashtable by using the key. Hashtables may seem like <a href="cn/XPCOM_array_guide">arrays</a>, but there are important differences:</p>
+<p>哈希表是一个存储一系列<b>元素</b>的数据结构。每个元素都由一个<b>关键字</b>来标识。元素可以通过关键字来进行查找,添加,删除操作。哈希表非常类似<a href="cn/XPCOM_array_guide">arrays</a>,但是也有一些很大的区别。</p>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th> </th>
+ <th class="header">数组</th>
+ <th class="header">哈希表</th>
+ </tr>
+ <tr>
+ <td class="header">关键字:</td>
+ <td>
+ <i>
+ 整数:</i>
+ arrays are always keyed on integers, and must be contiguous. 数组必须用整数作为关键字,而且每两个元素之间必须相邻接</td>
+ <td>
+ <i>
+ 任意类型:</i>
+ almost any datatype can be used as key, including strings, integers, XPCOM interface pointers, IIDs, and almost anything else. Keys can be disjunct (i.e. you can store entries with keys 1, 5, and 3000). 任意类型都可以作为关键字,包括字符串,整数,XPCOM接口指针,IIDs等等。关键字之间可以不在一起(例如,你可以用1,5,和3000来作为关键字。)</td>
+ </tr>
+ <tr>
+ <td class="header">查询时间:</td>
+ <td>
+ <i>
+ O(1):</i>
+ lookup time is a simple constant。查找时间是个简单的定值</td>
+ <td>
+ <i>
+ O(1):</i>
+ lookup time is mostly-constant, but the constant time can be larger than an array lookup。查找时间几乎是定值,但是比数组慢点。</td>
+ </tr>
+ <tr>
+ <td class="header">排序:</td>
+ <td>
+ <i>
+ sorted:</i>
+ stored sorted; enumerated in a sorted fashion.</td>
+ <td>
+ <i>
+ unsorted:</i>
+ stored unsorted; cannot be enumerated in a sorted manner.</td>
+ </tr>
+ <tr>
+ <td class="header">插入/删除:</td>
+ <td>
+ <i>
+ O(n):</i>
+ adding and removing items from a large array can be time-consuming</td>
+ <td>
+ <i>
+ O(1):</i>
+ adding and removing items from hashtables is a quick operation</td>
+ </tr>
+ <tr>
+ <td class="header">浪费空间:</td>
+ <td>
+ <i>
+ none:</i>
+ Arrays are packed structures, so there is no wasted space.</td>
+ <td>
+ <i>
+ some:</i>
+ hashtables are not packed structures; depending on the implementation, there may be significant wasted memory.</td>
+ </tr>
+ </tbody>
+</table>
+<p>In their implementation, hashtables take the key and apply a mathematical <b>hash function</b> to <b>randomize</b> the key and then use the hash to find the location in the hashtable. Good hashtable implementations will automatically resize the hashtable in memory if extra space is needed, or if too much space has been allocated.</p>
+<h2 id="When_Should_I_Use_a_Hashtable.3F" name="When_Should_I_Use_a_Hashtable.3F">When Should I Use a Hashtable?</h2>
+<p>Hashtables are useful for</p>
+<ul>
+ <li>sets of data that need swift <b>random access</b>;</li>
+ <li>with <b>non-integral keys</b> or <b>non-contiguous integral keys</b>;</li>
+ <li>or where <b>items will be frequently added or removed</b>.</li>
+</ul>
+<p>Hashtables should
+ <i>
+ not</i>
+ be used for</p>
+<ul>
+ <li>Sets that need to be <b>sorted</b>;</li>
+ <li>Very small datasets (less than 12-16 items);</li>
+ <li>Data that does not need random access.</li>
+</ul>
+<p>In these situations, an array, a linked-list, or various tree data structures are more efficient.</p>
+<h2 id="Mozilla.27s_Hashtable_Implementations" name="Mozilla.27s_Hashtable_Implementations">Mozilla's Hashtable Implementations</h2>
+<p>Mozilla has several hashtable implementations, which have been tested and, tuned, and hide the inner complexities of hashtable implementations:</p>
+<ul>
+ <li><code><a href="#PLDHash_.28JSDHash.29">PLDHash</a></code> - low-level C API; stores keys and data in one large memory structure; uses the heap efficiently; client must declare an "entry class" and may not hold onto entry pointers.</li>
+ <li><code><a href="#PLHashTable">PLHashTable</a></code> - low-level C API; entry class pointers are constant; more efficient for large entry structures; often wastes memory making many small heap allocations.</li>
+ <li><code><a href="#nsTHashtable">nsTHashtable</a></code> - low-level C++ wrapper around <code>PLDHash</code>; generates callback functions and handles most casting automagically. Client writes their own entry class which can include complex key and data types.</li>
+ <li><code><a href="#nsBaseHashtable_and_friends:_nsDataHashtable.2C_nsInterfaceHashtable.2C_and_nsClassHashtable">nsDataHashtable/nsInterfaceHashtable/nsClassHashtable</a></code> - high-level C++ wrappers around <code>PLDHash</code>; simplifies the common usage pattern mapping a simple keytype to a simple datatype; client does not need to declare or manage an entry class; <code><b>nsDataHashtable</b></code> datatype is a scalar such as <code>RUint32</code>; <code><b>nsInterfaceHashtable</b></code> datatype is an interface; <code><b>nsClassHashtable</b></code> datatype is a class pointer owned by the hashtable.</li>
+</ul>
+<h3 id="Which_Hashtable_Should_I_Use.3F" name="Which_Hashtable_Should_I_Use.3F">Which Hashtable Should I Use?</h3>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th class="header" colspan="2" rowspan="2"> </th>
+ <th class="header" colspan="5">Key Type:</th>
+ </tr>
+ <tr>
+ <th class="header">integer</th>
+ <th class="header">String/CString</th>
+ <th class="header">nsID</th>
+ <th class="header">nsISupports*</th>
+ <th class="header">Complex</th>
+ </tr>
+ <tr>
+ <td class="header" rowspan="8">Data Type:</td>
+ <td class="header">None (Hash Set)</td>
+ <td><code>nsInt32HashSet</code></td>
+ <td><code>ns(C)StringHashSet</code></td>
+ <td colspan="3"><code>nsTHashtable&lt;...&gt;</code></td>
+ </tr>
+ <tr>
+ <td class="header" rowspan="2">Simple (PRUint32)</td>
+ <td colspan="4"><code>nsDataHashtable</code></td>
+ <td rowspan="6"><code>nsTHashtable&lt;...&gt;</code></td>
+ </tr>
+ <tr>
+ <td><code>&lt;nsUint32HashKey,<br>
+ PRUint32&gt;</code></td>
+ <td><code>&lt;ns(C)StringHashKey,<br>
+ PRUint32&gt;</code></td>
+ <td><code>&lt;nsIDHashKey,<br>
+ PRUint32&gt;</code></td>
+ <td><code>&lt;nsISupportsHashKey,<br>
+ PRUint32&gt;</code></td>
+ </tr>
+ <tr>
+ <td class="header" rowspan="2">Interface (nsISupports)</td>
+ <td colspan="4"><code>nsInterfaceHashtable</code></td>
+ </tr>
+ <tr>
+ <td><code>&lt;nsUint32HashKey,<br>
+ nsISupports&gt;</code></td>
+ <td><code>&lt;ns(C)StringHashKey,<br>
+ nsISupports&gt;</code></td>
+ <td><code>&lt;nsIDHashKey,<br>
+ nsISupports&gt;</code></td>
+ <td><code>&lt;nsISupportsHashKey,<br>
+ nsISupports&gt;</code></td>
+ </tr>
+ <tr>
+ <td class="header" rowspan="2">Class (nsString*)</td>
+ <td colspan="4"><code>nsClassHashtable</code></td>
+ </tr>
+ <tr>
+ <td><code>&lt;nsUint32HashKey,<br>
+ nsString&gt;</code></td>
+ <td><code>&lt;ns(C)StringHashKey,<br>
+ nsString&gt;</code></td>
+ <td><code>&lt;nsIDHashKey,<br>
+ nsString&gt;</code></td>
+ <td><code>&lt;nsISupportsHashKey,<br>
+ nsString&gt;</code></td>
+ </tr>
+ <tr>
+ <td class="header">Complex<br>
+ (structures, etc.)</td>
+ <td colspan="5"><code>nsTHashtable&lt;...&gt;</code></td>
+ </tr>
+ </tbody>
+</table>
+<h3 id="PLDHash_.28JSDHash.29" name="PLDHash_.28JSDHash.29">PLDHash (JSDHash)</h3>
+<p><code>PLDHash</code> and <code>JSDHash</code> are the same thing; one is linked from the XPCOM libraries, the other from the JS libraries. <code>JSDHash</code> is used extensively in the SpiderMonkey JS engine.</p>
+<p>The <code>PLDHash</code> implementation is a fairly low-level implementation, written in C. It is extremely flexible, but requires some time to understand and use. A basic guide is included here, but you should read most of <code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/pldhash.h" rel="custom">xpcom/glue/pldhash.h</a></code> if you intend to use <code>PLDHash</code>. The C++ wrappers for <code>PLDHash</code> (see below) are often much easier and safer to use in C++ code, as many potential casting errors are easily avoided.</p>
+<p>You must declare an <b>entry struct</b> type, deriving from <a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/pldhash.h#81" rel="custom">&lt;code&gt;PLDHashEntryHdr&lt;/code&gt;</a>. This entry struct should contain whatever data you wish to store in the hashtable (any pointer or fixed-length data type). <b>Note:</b> because of the double-hashing implementation, entries may move in memory when the hashtable is altered. If you need entry pointers to remain constant, you may want to consider using <code><a href="#PLHashTable">PLHashTable</a></code> instead.</p>
+<p>You must also initialize a <a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/pldhash.h#312" rel="custom">&lt;code&gt;PLDHashTableOps&lt;/code&gt;</a> structure. This serves similarly to a vtable in C++, with pointers to appropriate user-defined functions that initialize, compare, and match entries. Because <code>PLDHash</code> does not know what datatype your key is, all functions that work with keys are declared using <code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/pldhash.h#354" rel="custom">const void*</a></code>, and your client code must cast these pointers to the appropriate type.</p>
+<p>PLDHashTables can be allocated on the stack or the heap:</p>
+<ul>
+ <li>When allocated on the stack, or as a C++ class member, the table must be initialized using <code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/pldhash.h#427" rel="custom">PL_DHashTableInit</a></code>, and finalized using <code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/pldhash.h#459" rel="custom">PL_DHashTableFinish</a></code>;</li>
+ <li>When allocated on the heap, use <code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/pldhash.h#410" rel="custom">PL_NewDHashTable</a></code> and <code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/pldhash.h#420" rel="custom">PL_DHashTableDestroy</a></code> to allocate and delete the table.</li>
+</ul>
+<h3 id="PLHashTable" name="PLHashTable">PLHashTable</h3>
+<p><code>PLHashTable</code> is a part of NSPR. The header file can be found at <code><code><a href="https://dxr.mozilla.org/mozilla-central/source/nsprpub/lib/ds/plhash.h" rel="custom">nsprpub/lib/ds/plhash.h</a></code></code>. In general, <code><a href="#PLDHash_.28JSDHash.29">PLDHash</a></code> is a better solution than <code>PLHashTable</code>, because <code>PLHashTable</code> makes many heap allocations.</p>
+<p>There are two situations where <code>PLHashTable</code> may be preferable to <code>PLDHash</code>:</p>
+<ul>
+ <li>You need entry-pointers to remain constant.</li>
+ <li>The entries stored in the table are very large (larger than 12 words). <code>PLDHash</code> does not handle large entry structures efficiently.</li>
+</ul>
+<h3 id="nsTHashtable" name="nsTHashtable">nsTHashtable</h3>
+<p><code>nsTHashtable</code> is a C++ template that wraps <code>PLDHash</code>. It hides many of the complexities of <code>PLDHash</code> (callback functions, the ops structure, etc). You should read <code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/nsTHashtable.h" rel="custom">xpcom/glue/nsTHashtable.h</a></code>.</p>
+<p>To use <code>nsTHashtable</code>, you must declare an entry-class in a <a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/nsTHashtable.h#65" rel="custom">pre-defined format</a>. This entry class contains the key and the data that you are hashing (just like <code>PLDHash</code>, above). It also declares functions that manipulate the key. In most cases, the functions of this entry class can be entirely inline. For examples of entry classes, see the declarations at <code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/nsHashKeys.h" rel="custom">xpcom/glue/nsHashKeys.h</a></code>.</p>
+<p>The template parameter is the entry class. You must use the <code>Init()</code> function to initalize the table properly. At this point, use the functions <code>PutEntry/GetEntry/RemoveEntry</code> to alter the hashtable. <code>EnumerateEntries</code> will do enumeration, but beware that the enumeration will occur in a seemingly-random order (no sorting).</p>
+<ul>
+ <li><code>nsTHashtable</code>s can be allocated on the stack, as class members, or on the heap.</li>
+ <li>Entry pointers can and do change when items are added to the hashtable, or removed. Do not keep long-lasting pointers to entries.</li>
+ <li>because of this, <code>nsTHashtable</code> is not inherently thread-safe. If you use a hashtable in a multi-thread environment, you must provide locking as appropriate.</li>
+</ul>
+<p>Before using <code>nsTHashtable</code>, see if <code>nsBaseHashtable</code> and relatives will work for you. They are much easier to use, because you do not have to declare an entry class. If you are hashing a simple key type to a simple data type, they are generally a better choice.</p>
+<h3 id="nsBaseHashtable_and_friends:_nsDataHashtable.2C_nsInterfaceHashtable.2C_and_nsClassHashtable" name="nsBaseHashtable_and_friends:_nsDataHashtable.2C_nsInterfaceHashtable.2C_and_nsClassHashtable">nsBaseHashtable and friends: nsDataHashtable, nsInterfaceHashtable, and nsClassHashtable</h3>
+<p>These C++ templates provide a high-level interface for using hashtables that hides most of the complexities of <code>PLDHash</code>. They provide the following features:</p>
+<ul>
+ <li>hashtable operations can be completed without using an entry class, making code easier to read;</li>
+ <li>optional thread-safety: the hashtable can manage a read-write lock around the table;</li>
+ <li>predefined key classes provide automatic cleanup of strings/interfaces</li>
+ <li><code>nsInterfaceHashtable</code> and <code>nsClassHashtable</code> automatically release/delete data pointers to avoid leaks.</li>
+</ul>
+<p><code>nsBaseHashtable</code> is not used directly; choose one of the three derivative classes based on the data type you want to store. The <code>KeyClass</code> is taken from <code>nsHashKeys.h</code> and is the same for all three classes:</p>
+<ul>
+ <li><code>nsDataHashtable&lt;KeyClass,
+ <i>
+ DataType</i>
+ &gt;</code> - <code>DataType</code> is a simple type such as <code>PRUint32</code> or <code>PRBool</code>.</li>
+ <li><code>nsInterfaceHashtable&lt;KeyClass,
+ <i>
+ Interface</i>
+ &gt;</code> - <code>Interface</code> is an XPCOM interface such as <code>nsISupports</code> or <code>nsIDOMNode</code></li>
+ <li><code>nsClassHashtable&lt;KeyClass,
+ <i>
+ T</i>
+ &gt;</code> - <code>T</code> is any C++ class. The hashtable stores a pointer to the class, and deletes it when the entry is removed.</li>
+</ul>
+<p>The important files to read are <code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/nsBaseHashtable.h" rel="custom">xpcom/glue/nsBaseHashtable.h</a></code> and <code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/nsHashKeys.h" rel="custom">xpcom/glue/nsHashKeys.h</a></code>. These classes can be used on the stack, as a class member, or on the heap. Initialize using the <code>Init()</code> function; you can specify whether you need thread-safety at this time. Use the <code>Put()</code>, <code>Get()</code>, and <code>Remove()</code> methods to alter the table.</p>
+<p>There are two enumeration functions:</p>
+<ul>
+ <li><code>EnumerateRead()</code> performs a read-only enumeration, where entries cannot be changed or removed;</li>
+ <li><code>Enumerate()</code> performs a read-write enumeration, where entries may be changed or removed as necessary.</li>
+</ul>
+<h3 id="Using_nsTHashtable_as_a_hash-set" name="Using_nsTHashtable_as_a_hash-set">Using nsTHashtable as a hash-set</h3>
+<p>A hash set only tracks the existence of keys: it does not associate data with the keys. This can be done using <code>nsTHashtable&lt;nsSomeHashKey&gt;</code>. The appropriate entries are GetEntry and PutEntry.</p>
+<h2 id="Future_Plans" name="Future_Plans">Future Plans</h2>
+<h3 id="nsISimpleEnumerator_support" name="nsISimpleEnumerator_support">nsISimpleEnumerator support</h3>
+<p>The (obsolete) <code>nsHashtable</code> has a wrapper that exposes an <code>nsISimpleEnumerator</code> on its items. I will add this support to the various <code>nsBaseHashtable</code> classes as well, as needed.</p>
+<h2 id="Hash_Functions" name="Hash_Functions">Hash Functions</h2>
+<p>All of the above hashtables need a <a class="external" href="http://www.nist.gov/dads/HTML/hash.html">Hash Function</a>. This function converts the key into a semi-unique integer. The mozilla codebase already contains hash functions for most key types, including narrow and wide strings, pointers, and most binary data:</p>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>void*<br>
+ (or nsISupports*)</code></td>
+ <td>cast using <code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/base/nscore.h#443" rel="custom">NS_PTR_TO_INT32</a></code></td>
+ </tr>
+ <tr>
+ <td><code>char*</code> string</td>
+ <td rowspan="2"><code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/ds/nsCRT.h#228" rel="custom">nsCRT::HashCode()</a></code></td>
+ </tr>
+ <tr>
+ <td><code>PRUnichar*</code> string</td>
+ </tr>
+ <tr>
+ <td><code>nsAString</code></td>
+ <td rowspan="2"><code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/nsTHashtable.cpp#41" rel="custom">HashString()</a></code></td>
+ </tr>
+ <tr>
+ <td><code>nsACString</code></td>
+ </tr>
+ <tr>
+ <td><code>nsID&amp;</code></td>
+ <td><code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/nsHashKeys.h#227" rel="custom">nsIDHashKey::HashKey()</a></code></td>
+ </tr>
+ </tbody>
+</table>
+<p>Writing a good hash function is well beyond the scope of this document, and has been discussed extensively in computer-science circles for many years. There are many different types of hash functions. Mozilla has tuned a good general-purpose hash algorithm for strings and <code>nsID</code>.</p>
+<h2 id="Mozilla.27s_Old.2FObsolete.2FDeprecated.2FDecrepit_Hashtables" name="Mozilla.27s_Old.2FObsolete.2FDeprecated.2FDecrepit_Hashtables">Mozilla's Old/Obsolete/Deprecated/Decrepit Hashtables</h2>
+<h3 id="nsHashtable" name="nsHashtable">nsHashtable</h3>
+<p><code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/ds/nsHashtable.h" rel="custom">nsHashtable</a></code> was a C++ wrapper around <code>PLHashTable</code>, and now wraps <code>PLDHash</code>. The design of the key classes is not optimal, however, and <code>nsHashtable</code> has been deprecated in favor of <code>nsDataHashtable</code> and friends.</p>
+<h3 id="nsObjectHashtable" name="nsObjectHashtable">nsObjectHashtable</h3>
+<p><code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/ds/nsHashtable.h#163" rel="custom">nsObjectHashtable</a></code> is a form of <code>nsHashtable</code>. It has been replaced by <code>nsClassHashtable</code>.</p>
+<h3 id="nsSupportsHashtable" name="nsSupportsHashtable">nsSupportsHashtable</h3>
+<p><code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/ds/nsHashtable.h#193" rel="custom">nsSupportsHashtable</a></code> is a form of <code>nsHashtable</code>. It has been replaced by <code>nsInterfaceHashtable</code>.</p>
+<h3 id="nsHashSets" name="nsHashSets">nsHashSets</h3>
+<p><code>nsHashSets</code> has predefined hash sets for common keys, which are trivially easy to use. See <code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/ds/nsHashSets.h" rel="custom">xpcom/ds/nsHashSets.h</a></code>. This functionality has been replaced by <code>nsTHashtable&lt;nsSomeHashKey&gt;</code>.</p>
+<h3 id="nsDoubleHashtable" name="nsDoubleHashtable">nsDoubleHashtable</h3>
+<p><code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/ds/nsDoubleHashtable.h" rel="custom">nsDoubleHashtable</a></code> is the (obsolete) precursor to <code>nsTHashtable</code>. It uses macros instead of C++ templates.</p>
+<div class="originaldocinfo">
+ <h2 id="Original_Document_Information" name="Original_Document_Information">Original Document Information</h2>
+ <ul>
+ <li>Author(s): Benjamin Smedberg &lt;<a class="link-mailto" href="mailto:benjamin@smedbergs.us" rel="freelink">benjamin@smedbergs.us</a>&gt;</li>
+ </ul>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/index.html
new file mode 100644
index 0000000000..385888d9fb
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/index.html
@@ -0,0 +1,15 @@
+---
+title: XPCOM 指南
+slug: Mozilla/Tech/XPCOM/Guide
+tags:
+ - Landing
+ - Mozilla
+ - XPCOM
+translation_of: Mozilla/Tech/XPCOM/Guide
+---
+<p> </p>
+<p><span class="seoSummary" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px;">本文提供了关于 XPCOM 的说明和使用文档,包括如何在你的工程中使用,如何为你的 Firefox 扩展等构建 XPCOM 组件。</span></p>
+<p></p><div class="row topicpage-table">
+ <div class="section"><dl><dl><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Guide/Arrays">Array</a></dt><dd class="landingPageList"></dd><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Guide/Hashtables">Hashtables</a></dt><dd class="landingPageList"></dd><dt class="landingPageList"><a href="/zh-CN/docs/How_to_Build_an_XPCOM_Component_in_Javascript">How to Build an XPCOM Component in Javascript</a></dt><dd class="landingPageList"></dd></dl></dl></div>
+ <div class="section"><dl><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Guide/Internal_strings">Strings</a></dt><dd class="landingPageList"></dd><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Guide/Creating_components">创建_XPCOM_组件</a></dt><dd class="landingPageList"></dd></dl></div>
+ </div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/guide/internal_strings/index.html b/files/zh-cn/mozilla/tech/xpcom/guide/internal_strings/index.html
new file mode 100644
index 0000000000..fe5806168f
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/guide/internal_strings/index.html
@@ -0,0 +1,809 @@
+---
+title: Strings
+slug: Mozilla/Tech/XPCOM/Guide/Internal_strings
+tags:
+ - XPCOM
+ - 所有分类
+translation_of: Mozilla/Tech/XPCOM/Guide/Internal_strings
+---
+<p> </p>
+<h2 id="Preface" name="Preface">Preface</h2>
+<div>
+ <p>by Alec Flett<br>
+ Thanks to David Baron for <a class="external" href="http://dbaron.org/mozilla/coding-practices">actual docs</a>,<br>
+ Peter Annema for lots of direction,<br>
+ Myk Melez for some more docs, and<br>
+ David Bradley for a diagram<br>
+ Revised by Darin Fisher for Mozilla 1.7<br>
+ Revised by Jungshik Shin to clarify character encoding issues</p>
+</div>
+<p>This guide will attempt to document the plethora of string classes, and hopefully provide an answer to the age old question, "what string class should I use here?"</p>
+<div style="border: solid thin steelblue; padding: 0.5em;">
+ <p>If you are a Mozilla embedder or if you are writing an XPCOM component that will be distributed separately from the Mozilla code base, then this string guide is most likely not for you! Provided you are developing against Mozilla 1.7 or later, you should instead be using the new minimal <a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/nsStringAPI.h" rel="custom">Mozilla string API</a> and in particular the <a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/string/public/nsEmbedString.h" rel="custom">nsEmbedString</a> class.</p>
+</div>
+<p>In a hurry? Go check out the <a href="cn/XPCOM/String_Quick_Reference">String Quick-Reference</a> (<a class="external" href="http://www.mozilla.org/projects/xpcom/string-quickref.html">). </a></p>
+<h2 id="Introduction" name="Introduction"><a class="external" href="http://www.mozilla.org/projects/xpcom/string-quickref.html">Introduction </a></h2>
+<p><a class="external" href="http://www.mozilla.org/projects/xpcom/string-quickref.html">The string classes are a library of C++ classes which are used to manage buffers of unicode and single-byte character strings. They reside in the mozilla codebase in the <code></code></a><code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/string" rel="custom">xpcom/string</a></code> directory. </p>
+<p><a class="external" href="http://www.mozilla.org/projects/xpcom/string-quickref.html">Abstract (interface) classes begin with "nsA" and concrete classes simply begin with "ns". Classes with a "<code>CString</code>" in the name store 8-bit bytes (<code>char</code>'s) which may refer to single byte ASCII strings, or multibyte Unicode strings encoded in UTF-8 or a (multibyte or single byte) legacy character encoding (e.g. ISO-8859-1, Shift_JIS, GB2312, KOI8-R). All other classes simply have "<code>String</code>" in their name and refer to 16-bit strings made up of <code>PRUnichar</code>'s, For example: <code>nsAString</code> is an abstract class for storing Unicode characters in UTF-16 encoding, and <code>nsDependentCString</code> is a concrete class which stores a 8-bit string. Every 16-bit string class has an equivalent 8-bit string class. For example: <code>nsCString</code> is the 8-bit string class which corresponds to <code>nsString</code>. </a></p>
+<p><a class="external" href="http://www.mozilla.org/projects/xpcom/string-quickref.html">8-bit and 16-bit string classes have completely separate base classes, but share the same APIs. As a result, you cannot assign a 8-bit string to a 16-bit string without some kind of conversion helper class or routine. For the purpose of this document, we will refer to the 16-bit string classes in class documentation. It is safe to assume that every 16-bit class has an equivalent 8-bit class. </a></p>
+<h2 id="String_Guidelines" name="String_Guidelines"><a class="external" href="http://www.mozilla.org/projects/xpcom/string-quickref.html">String Guidelines </a></h2>
+<p><a class="external" href="http://www.mozilla.org/projects/xpcom/string-quickref.html">Follow these simple rules in your code to keep your fellow developers, reviewers, and users happy. </a></p>
+<ul>
+ <li><a class="external" href="http://www.mozilla.org/projects/xpcom/string-quickref.html">Avoid </a><code><a href="#Unicode_Conversion_ns.2ACString_vs._ns.2AString">*WithConversion</a></code> functions at all costs: <code>AssignWithConversion</code>, <code>AppendWithConversion</code>, <code>EqualsWithConversion</code>, etc</li>
+ <li>Use the most abstract string class that you can. Usually this is:
+ <ul>
+ <li><code><a href="#The_Abstract_Classes">nsAString</a></code> for function parameters</li>
+ <li><code><a href="#The_Concrete_Classes_-_which_classes_to_use_when">nsString</a></code> for member variables</li>
+ <li><a href="#The_Concrete_Classes_-_which_classes_to_use_when"><code>nsAutoString</code> or <code>nsXPIDLString</code></a> for local (stack-based) variables</li>
+ </ul>
+ </li>
+ <li>Use <a href="#Literal_Strings"><code>NS_LITERAL_[C]STRING</code> / <code>NS_NAMED_LITERAL_[C]STRING</code></a> to represent literal strings (i.e. "foo") as nsAString-compatible objects.</li>
+ <li>Use <a href="#String_Concatenation">string concatenation</a> (i.e. the "+" operator) when combining strings.</li>
+ <li>Use <code><a href="#Raw_Character_Pointers">nsDependentString</a></code> when you have a raw character pointer that you need to convert to an nsAString-compatible string.</li>
+ <li>Use <code><a href="#Substrings_.28string_fragments.29">Substring()</a></code> to extract fragments of existing strings.</li>
+ <li>Use <a href="#Iterators">iterators</a> to parse and extract string fragments.</li>
+</ul>
+<h2 id="The_Abstract_Classes" name="The_Abstract_Classes">The Abstract Classes</h2>
+<p>Every string class derives from <code>nsAString</code> (or <code>nsACString</code>). This class provides the fundamental interface for access and manipulation of strings. While concrete classes derive from <code>nsAString</code>, <code>nsAString</code> itself cannot be instantiated.</p>
+<p>This is very similar to the idea of an "interface" that mozilla uses to describe abstract object descriptions in the rest of the codebase. In the case of interfaces, class names begin with "nsI" where "I" refers to "Interface". In the case of strings, abstract classes begin with "nsA" and the "A" means "Abstract".</p>
+<p>There are a number of abstract classes which derive from <code>nsAString</code>. These abstract subclasses also cannot be instantiated, but they describe a string in slightly more detail than <code>nsAString</code>. They guarantee that the underlying implementation behind the abstract class provides specific capabilities above and beyond <code>nsAString</code>.</p>
+<p>The list below describes the main base classes. Once you are familiar with them, see the appendix describing What Class to Use When.</p>
+<ul>
+ <li><b><code>nsAString</code></b>: the abstract base class for all strings. It provides an API for assignment, individual character access, basic manipulation of characters in the string, and string comparison. This class corresponds to the XPIDL <code>AString</code> parameter type.</li>
+ <li><b><code>nsSubstring</code></b>: the common base class for all of the string classes. Provides optimized access to data within the string. A <code>nsSubstring</code> is not necessarily null-terminated. (For backwards compatibility, <code>nsASingleFragmentString</code> is a typedef for this string class.)</li>
+ <li><b><code>nsString</code></b>: builds on <code>nsSubstring</code> by guaranteeing a null-terminated storage. This allows for a method (<code>.get()</code>) to access the underlying character buffer. (For backwards compatibility, <code>nsAFlatString</code> is a typedef for this string class.)</li>
+</ul>
+<p>The remainder of the string classes inherit from either <code>nsSubstring</code> or <code>nsString</code>. Thus, every string class is compatible with <code>nsAString</code>.</p>
+<p>It's important to note that <code>nsSubstring</code> and <code>nsAString</code> both represent a contiguous array of characters that are not necessarily null-terminated. One might ask then ask why two different yet similar string classes need to exist. Well, <code>nsSubstring</code> exists primarily as an optimization since <code>nsAString</code> must retain binary compatibility with the frozen <code>nsAString</code> class that shipped with Mozilla 1.0. Up until the release of Mozilla 1.7, <code>nsAString</code> was capable of representing a string broken into multiple fragments. The cost associated with supporting multi-fragment strings was high and offered limited benefits. It was decided to eliminate support for multi-fragment strings in an effort to reduce the complexity of the string classes and improve performance. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=231995" title='FIXED: Exploring nsAString "defragmentation"'>bug 231995</a> for more details.</p>
+<p>Though <code>nsSubstring</code> provides a more efficient interface to its underlying buffer than <code>nsAString</code>, <code>nsAString</code> is still the most commonly used class for parameter passing. This is because it is the string class corresponding to <code>AString</code> in XPIDL. Therefore, this string guide will continue to discuss the string classes with an emphasis on <code>nsAString</code>.</p>
+<p>Since every string derives from <code>nsAString</code> (or <code>nsACString</code>), they all share a simple API. Common read-only methods:</p>
+<ul>
+ <li><b><code>.Length()</code></b> - the number of code units (bytes for 8-bit string classes and PRUnichar's for 16-bit string classes) in the string.</li>
+ <li><b><code>.IsEmpty()</code></b> - the fastest way of determining if the string has any value. Use this instead of testing <code>string.Length</code> == 0</li>
+ <li><b><code>.Equals(string)</code></b> - TRUE if the given string has the same value as the current string.</li>
+</ul>
+<p>Common methods that modify the string:</p>
+<ul>
+ <li><b><code>.Assign(string)</code></b> - Assigns a new value to the string.</li>
+ <li><b><code>.Append(string)</code></b> - Appends a value to the string.</li>
+ <li><b><code>.Insert(string, position)</code></b> - Inserts the given string before the code unit at position.</li>
+ <li><b><code>.Truncate(length)</code></b> - shortens the string to the given length.</li>
+</ul>
+<p>Complete documentation can be found in the <a href="#Appendix_B_-_nsAString_Reference">Appendix</a>.</p>
+<h3 id="Read-only_strings" name="Read-only_strings">Read-only strings</h3>
+<p>The <code>const</code> attribute on a string determines if the string is writable. If a string is defined as a <code>const nsAString</code> then the data in the string cannot be manipulated. If one tries to call a non-<code>const</code> method on a <code>const</code> string the compiler will flag this as an error at build time.</p>
+<p>For example:</p>
+<pre class="eval">void nsFoo::ReverseCharacters(nsAString&amp; str) {
+ ...
+ str.Assign(reversedStr); // modifies the string
+}
+</pre>
+<p>This should not compile, because you're assigning to a <code>const</code> class:</p>
+<pre class="eval">void nsFoo::ReverseCharacters(const nsAString&amp; str) {
+ ...
+ <b>str.Assign(reversedStr);</b>
+}
+</pre>
+<h3 id="As_function_parameters" name="As_function_parameters">As function parameters</h3>
+<p>It is recommended that you use the most abstract interface possible as a function parameter, instead of using concrete classes. The convention is to use C++ references (the '&amp;' character) instead of pointers (the '*' character) when passing string references around. For example:</p>
+<pre class="eval">// abstract reference
+nsFoo::PrintString(<b>const nsAString&amp;</b> str) {..}
+
+// using a concrete class!
+nsFoo::PrintString(<b>const nsString&amp;</b> str) {..}
+
+// using a pointer!
+nsFoo::PrintString(<b>const nsAString*</b> str) {..}
+</pre>
+<p>The abstract classes are also sometimes used to store temporary references to objects. You can see both of these uses in <a href="#Common_Patterns">Common Patterns</a>, below.</p>
+<p><b>NOTE:</b> While using abstract string classes increases the re-usability of your methods, it also incurs a codesize and performance penalty. Therefore, when writing methods that will only ever be used within the confines of your source file or module, it is better to use <b><code>const nsSubstring&amp;</code></b> for input parameters and <b><code>nsString&amp;</code></b> for output parameters. --Darin</p>
+<h2 id="The_Concrete_Classes_-_which_classes_to_use_when" name="The_Concrete_Classes_-_which_classes_to_use_when">The Concrete Classes - which classes to use when</h2>
+<p>The concrete classes are for use in code that actually needs to store string data. The most common uses of the concrete classes are as local variables, and members in classes or structs. Whereas the abstract classes differ in storage mechansim, for the most part the concrete classes differ in storage policy.</p>
+<p>The following is a list of the most common concrete classes. Once you are familiar with them, see the appendix describing <a href="#Appendix_A_-_What_class_to_use_when">What Class to Use When.</a></p>
+<ul>
+ <li><code><b>nsString / nsCString</b></code>- a null-terminated string whose buffer is allocated on the heap. Destroys its buffer when the string object goes away.</li>
+ <li><code><b>nsAutoString / nsCAutoString</b></code>- derived from <code>nsString</code>, a string which owns a 64 code unit buffer in the same storage space as the string itself. If a string less than 64 code units is assigned to an <code>nsAutoString</code>, then no extra storage will be allocated. For larger strings, a new buffer is allocated on the heap.</li>
+ <li><code><b>nsXPIDLString / nsXPIDLCString</b></code>- derived from <code>nsString</code>, this class supports the <code>getter_Copies()</code> operator which allows easy access to XPIDL <code>out wstring / string</code> parameters. This class also supports the notion of a null-valued buffer, whereas <code>nsString</code>'s buffer is never null.</li>
+ <li><code><b>nsDependentString</b></code>- derived from <code>nsString</code>, this string does
+ <i>
+ not</i>
+ own its buffer. It is useful for converting a raw string (<code>const PRUnichar*</code> or <code>const char*</code>) into a class of type <code>nsAString</code>.</li>
+ <li><code><b>nsPrintfCString</b></code>- derived from <code>nsCString</code>, this string behaves like an <code>nsCAutoString</code>. The constructor takes parameters which allows it to construct a 8-bit string from a <code>printf</code>-style format string and parameter list.</li>
+ <li><code><b>NS_LITERAL_STRING/NS_NAMED_LITERAL_STRING</b></code>- these convert a literal string (such as "abc") to a <code>nsString</code> or a subclass of <code>nsString</code>. On platforms supporting double-byte string literals (e.g., MSVC++ or GCC with the -fshort-wchar option), these are simply macros around the <code>nsDependentString</code> class. They are slightly faster than just wrapping them with an <code>nsDependentString</code> because they use the compiler to calculate their length, and they also hide the messy cross-platform details of non-byte literal strings.</li>
+</ul>
+<p>There are also a number of concrete classes that are created as a side-effect of helper routines, etc. You should avoid direct use of these classes. Let the string library create the class for you.</p>
+<ul>
+ <li><code><b>nsSubstringTuple</b></code> - created via <a href="#String_Concatenation">string concatenation</a></li>
+ <li><code><b>nsDependentSubstring</b></code> - created through <a href="#Substrings_.28string_fragments.29">Substring</a></li>
+ <li><code><b>nsPromiseFlatString</b></code> - created through <code><b><a href="#Raw_Character_Pointers">PromiseFlatString()</a></b></code></li>
+</ul>
+<p>Of course, there are times when it is necessary to reference these string classes in your code, but as a general rule they should be avoided.</p>
+<h2 id="Iterators" name="Iterators">Iterators</h2>
+<p>Iterators are objects that retain a reference to a position in a string. In some ways they are like a number which refers to an index in an array, or a character-pointer that refers to a position in a character string. They also provide a syntactic means to distinguish between reading and writing to a string.</p>
+<p>Iterators are most often used to extract substrings of a string. They provide the capability to modify the contents of a string, but often helper routines, or the string's own methods are quicker at complex string transformations.</p>
+<p>Iterators are declared from the string class which they are iterating:</p>
+<pre class="eval">nsAString::const_iterator start, end; // reading-only iterators for nsAString
+nsString::iterator substr_start, substr_end; // writing iterators for nsString
+</pre>
+<p>Iterators are initialized with one of 4 methods on the string you wish to reference:</p>
+<pre class="eval">// let's read from 'str'
+str.BeginReading(start); // initialize 'start' to the beginning of 'str'
+str.EndReading(end); // 'end' will be at the end of the string
+
+// say we also want to write to 'url'
+url.BeginWriting(substr_start);
+url.EndWriting(substr_end);
+</pre>
+<p>You can access the code unit that an iterator points to with the dereference operator *.</p>
+<pre class="eval">if (*start == '[')
+ printf("Starts with a bracket\n");
+</pre>
+<p>Note in the above examples, that '<code>end</code>' and '<code>substr_end</code>' will actually point to the code unit past the end of the string, so you should never dereference the direct result of <code>.EndReading()</code>.</p>
+<p>You can test if two iterators point to the same position with == or !=. You can advance iterators with ++. Putting the ++ before your iterator is preferred, and will prevent creation of a temporary iterator.</p>
+<pre class="eval">while (start != end) // iterate through the whole string
+ ++start;
+</pre>
+<p>You can effectively write to a string with writing iterators (as opposed to const-iterators):</p>
+<pre class="eval">// change all * to !
+while (substr_start != substr_end) {
+ if (*substr_start == '*')
+ *substr_start = '!';
+ ++substr_start;
+}
+</pre>
+<p>With the patch for <a class="external" href="http://bugzilla.mozilla.org/show_bug.cgi?id=231995">bug 231995</a>, this loop is now as efficient as iterating with raw character pointers.</p>
+<h2 id="Helper_Classes_and_Functions" name="Helper_Classes_and_Functions">Helper Classes and Functions</h2>
+<h3 id="Searching_strings_-_looking_for_substrings.2C_characters.2C_etc." name="Searching_strings_-_looking_for_substrings.2C_characters.2C_etc.">Searching strings - looking for substrings, characters, etc.</h3>
+<p><code>FindInReadable()</code> is the replacement for the old <code>string.Find(..)</code>. The syntax is:</p>
+<pre class="eval">PRBool FindInReadable(const nsAString&amp; pattern,
+ nsAString::const_iterator start, nsAString::const_iterator end,
+ nsStringComparator&amp; aComparator = nsDefaultStringComparator());
+</pre>
+<p>To use this, <code>start</code> and <code>end</code> should point to the beginning and end of a string that you would like to search. If the search string is found, <code>start</code> and <code>end</code> will be adjusted to point to the beginning and end of the found pattern. The return value is PR_TRUE or PR_FALSE, indicating whether or not the string was found.</p>
+<p>An example:</p>
+<pre class="eval">const nsAString&amp; str = GetSomeString();
+nsAString::const_iterator start, end;
+
+str.BeginReading(start);
+str.EndReading(end);
+
+NS_NAMED_LITERAL_STRING(valuePrefix, "value=");
+
+if (FindInReadable(valuePrefix, start, end)) {
+ // end now points to the character after the pattern
+ valueStart = end;
+
+}
+</pre>
+<h3 id="Memory_Allocation_-_how_to_avoid_it.2C_which_methods_to_use" name="Memory_Allocation_-_how_to_avoid_it.2C_which_methods_to_use">Memory Allocation - how to avoid it, which methods to use</h3>
+<p>The preferred method to allocate a new character buffer (<code>PRUnichar*</code>/<code>char*</code>) from an existing string is with one of the following methods:</p>
+<ul>
+ <li><code><b>PRUnichar* ToNewUnicode(
+ <i>
+ nsAString&amp;</i>
+ )</b></code> - Allocates a <code>PRUnichar*</code>buffer from an <code>nsAString</code>.</li>
+ <li><code><b>char *ToNewCString(
+ <i>
+ nsACString&amp;</i>
+ )</b></code> - Allocates a <code>char*</code>buffer from an <code>nsACString</code>. Note that this method will also work on nsAStrings, but it will do an implicit <a href="#Lossy_Conversion">lossy conversion</a>. This function should only be used if the input is known to be strictly ASCII. Often a conversion to UTF-8 is more appropriate. See <code><b>ToNewUTF8String</b></code> below.</li>
+ <li><code><b>char* ToNewUTF8String(
+ <i>
+ nsAString&amp;</i>
+ )</b></code> - Allocates a new <code>char*</code> buffer containing the UTF-8 encoded version of the given nsAString. See <a href="#Unicode_Conversion_ns.2ACString_vs._ns.2AString">Unicode Conversion</a> for more details.</li>
+</ul>
+<p>These methods return a buffer allocated using XPCOM's allocator (<code>nsMemory::Alloc</code>) instead of the traditional allocator (<code>malloc</code>, etc.). You should use <code>nsMemory::Free</code> to deallocate the result when you no longer need it.</p>
+<h3 id="Substrings_.28string_fragments.29" name="Substrings_.28string_fragments.29">Substrings (string fragments)</h3>
+<p>It is very simple to refer to a substring of an existing string without actually allocating new space and copying the characters into that substring. <code>Substring()</code> is the preferred method to create a reference to such a string.</p>
+<pre class="eval">void ProcessString(const nsAString&amp; str) {
+ const nsAString&amp; firstFive = Substring(str, 0, 5);
+ // firstFive is now a string representing the first 5 characters
+}
+</pre>
+<h2 id="Unicode_Conversion_ns.2ACString_vs._ns.2AString" name="Unicode_Conversion_ns.2ACString_vs._ns.2AString">Unicode Conversion ns*CString vs. ns*String</h2>
+<p>Strings can be
+ <i>
+ stored</i>
+ in two basic formats: 8-bit code unit (byte/<code>char</code>) strings, or 16-bit code unit (<code>PRUnichar</code>) strings. Any string class with a capital "C" in the classname contains 8-bit bytes. These classes include <code>nsCString</code>, <code>nsDependentCString</code>, and so forth. Any string class
+ <i>
+ without</i>
+ the "C" contains 16-bit code units.</p>
+<p>A 8-bit string can be in one of many character encodings while a 16-bit string is always in UTF-16. The most common encodings are:</p>
+<ul>
+ <li>ASCII - 8-bit encoding for basic English-only strings. Each ASCII value is stored in exactly one byte in the array.</li>
+ <li><a class="external" href="http://www.unicode.org/glossary/#UCS_2">UCS2</a> - 16-bit encoding for a
+ <i>
+ subset</i>
+ of Unicode, <a class="external" href="http://www.unicode.org/glossary/#BMP">BMP</a>. The Unicode value of a character stored in UCS2 is stored in exactly one 16-bit <code>PRUnichar</code> in a string class.</li>
+ <li><a class="external" href="http://www.faqs.org/rfcs/rfc3629.html">UTF-8</a> - 8-bit encoding for Unicode characters. Each Unicode characters is stored in up to 4 bytes in a string class. UTF-8 is capable of representing the entire Unicode character repertoire, and it efficiently maps to <a class="external" href="http://www.unicode.org/glossary/#UTF_32">UTF-32</a>.</li>
+ <li><a class="external" href="http://www.unicode.org/glossary/#UTF_16">UTF-16</a> - 16-bit encoding for Unicode storage, backwards compatible with UCS2. The Unicode value of a character stored in UTF-16 may require
+ <i>
+ one or two</i>
+ 16-bit <code>PRUnichar</code>s in a string class. The contents of <code>nsAString</code> always has to be regarded as in this encoding instead of UCS2. UTF-16 is capable of representing the entire Unicode character repertoire, and it efficiently maps to UTF-32. (Win32 W APIs and Mac OS X natively use UTF-16.)</li>
+</ul>
+<p>In addition, there are literally hundreds of encodings that are provided by internationalization libraries. Access to these libraries may be part of the application (such as <code>nsICharsetConversionManager</code> in Mozilla) or built into the operating system (such as <code>iconv()</code> in UNIX operating systems and <code>MultiByteToWideChar</code>/<code>WideCharToMultiByte</code> on Windows).</p>
+<p>When working with existing code, it is important to examine the current usage of the strings that you are manipulating, to determine the correct conversion mechanism.</p>
+<p>When writing new code, it can be confusing to know which storage class and encoding is the most appropriate. There is no single answer to this question, but there are a few important guidelines:</p>
+<ul>
+ <li><b>Is the string always ASCII?</b> First and foremost, you need to determine what kinds of values will be stored in the string. If the strings are always internal, ASCII strings such as "left", "true", "background" and so forth, then straight C-strings are probably the way to go.</li>
+ <li><b>If the string is ASCII, will it be compared to, assigned to, or otherwise interact with non-ASCII strings?</b> When assigning or comparing an 8-bit ASCII value (in)to a 16-bit UCS2 string, an "inflation" needs to happen at runtime. If your strings are small enough (say, less than 64 bytes) then it may make sense to store your string in a 16-bit unicode class as well, to avoid the extra conversion. The tradeoff is that your ASCII string takes up twice as much space as a 16-bit Unicode string than it would as an 8-bit string.</li>
+ <li><b>Is the string usually ASCII, but needs to support unicode?</b> If your string is most often ASCII but needs to be able to store Unicode characters, then UTF-8 may be the right encoding. ASCII characters will still be stored in 8-bit storage but other Unicode characters will take up 2 to 4 bytes. However if the string ever needs to be compared or assigned to a 16-bit string, a runtime conversion will be necessary.</li>
+ <li><b>Are you storing large strings of non-ASCII data?</b> Up until this point, UTF-8 might seem like the ideal encoding. The drawback is that for most non-European characters (such as Chinese, Indian and Japanese) in BMP, UTF-8 takes 50% more space than UTF-16. For characters in plane 1 and above, both UTF-8 and UTF-16 take 4 bytes.</li>
+ <li><b>Do you need to manipulate the contents of a Unicode string?</b> One problem with encoding Unicode characters in UTF-8 or other 8-bit storage formats is that the actual Unicode character can span multiple bytes in a string. In most encodings, the actual number of bytes varies from character to character. When you need to iterate over each character, you must take the encoding into account. This is vastly simplified when iterating 16-bit strings because each 16-bit code unit (<code>PRUnichar</code>) corresponds to a Unicode character as long as all characters are in BMP, which is often the case. However, you have to keep in mind that a single Unicode character in plane 1 and beyond is represented in two 16-bit code units in 16-bit strings so that the number of <code>PRUnichar</code>'s is
+ <i>
+ not</i>
+ always equal to the number of Unicode characters. For the same reason, the position and the index in terms of 16-bit code units are not always the same as the position and the index in terms of Unicode characters.</li>
+</ul>
+<p><br>
+ To assist with ASCII, UTF-8, and UTF-16 conversions, there are some helper methods and classes. Some of these classes look like functions, because they are most often used as temporary objects on the stack.</p>
+<h3 id="UTF-8_.2F_UTF-16_conversion" name="UTF-8_.2F_UTF-16_conversion">UTF-8 / UTF-16 conversion</h3>
+<p><code><b>NS_ConvertUTF8toUTF16(
+ <i>
+ const nsACString&amp;</i>
+ )</b></code> - a <code>nsAutoString</code> subclass that converts a UTF-8 encoded <code>nsACString</code> or <code>const char*</code> to a 16-bit UTF-16 string. If you need a <code>const PRUnichar*</code> buffer, you can use the <code>.get()</code> method. For example:</p>
+<pre class="eval">/* signature: void HandleUnicodeString(const nsAString&amp; str); */
+object-&gt;HandleUnicodeString(<b>NS_ConvertUTF8toUTF16</b>(utf8String));
+
+/* signature: void HandleUnicodeBuffer(const PRUnichar* str); */
+object-&gt;HandleUnicodeBuffer(<b>NS_ConvertUTF8toUTF16</b>(utf8String).get());
+</pre>
+<p><code><b>NS_ConvertUTF16toUTF8(
+ <i>
+ const nsAString&amp;</i>
+ )</b></code> - a <code>nsCAutoString</code> which converts a 16-bit UTF-16 string (<code>nsAString</code>) to a UTF-8 encoded string. As above, you can use <code>.get()</code> to access a <code>const char*</code> buffer.</p>
+<pre class="eval">/* signature: void HandleUTF8String(const nsACString&amp; str); */
+object-&gt;HandleUTF8String(<b>NS_ConvertUTF16toUTF8</b>(utf16String));
+
+/* signature: void HandleUTF8Buffer(const char* str); */
+object-&gt;HandleUTF8Buffer(<b>NS_ConvertUTF16toUTF8</b>(utf16String).get());
+</pre>
+<p><code><b>CopyUTF8toUTF16(
+ <i>
+ const nsACString&amp;, nsAString&amp;</i>
+ )</b></code> - converts and copies:</p>
+<pre class="eval">// return a UTF-16 value
+void Foo::GetUnicodeValue(nsAString&amp; result) {
+ <b>CopyUTF8toUTF16</b>(mLocalUTF8Value, result);
+ }
+</pre>
+<p><code><b>AppendUTF8toUTF16(
+ <i>
+ const nsACString&amp;, nsAString&amp;</i>
+ )</b></code> - converts and appends:</p>
+<pre class="eval">// return a UTF-16 value
+void Foo::GetUnicodeValue(nsAString&amp; result) {
+ result.AssignLiteral("prefix:");
+ <b>AppendUTF8toUTF16</b>(mLocalUTF8Value, result);
+}
+</pre>
+<p><br>
+ <code><b>UTF8ToNewUnicode(
+ <i>
+ const nsACString&amp;, PRUint32* aUTF16Count = nsnull</i>
+ )</b></code> - allocates and converts (the optional parameter will contain the number of 16-byte units upon return, if non-null):</p>
+<pre class="eval">void Foo::GetUTF16Value(PRUnichar** result) {
+ *result = <b>UTF8ToNewUnicode</b>(mLocalUTF8Value);
+}
+</pre>
+<p><br>
+ <code><b>CopyUTF16toUTF8(
+ <i>
+ const nsAString&amp;, nsACString&amp;</i>
+ )</b></code> - converts and copies:</p>
+<pre class="eval">// return a UTF-8 value
+void Foo::GetUTF8Value(nsACString&amp; result) {
+ <b>CopyUTF16toUTF8</b>(mLocalUTF16Value, result);
+}
+</pre>
+<p><code><b>AppendUTF16toUTF8(
+ <i>
+ const nsAString&amp;, nsACString&amp;</i>
+ )</b></code> - converts and appends:</p>
+<pre class="eval">// return a UTF-8 value
+void Foo::GetUnicodeValue(nsACString&amp; result) {
+ result.AssignLiteral("prefix:");
+ <b>AppendUTF16toUTF8</b>(mLocalUTF16Value, result);
+}
+</pre>
+<p><code><b>ToNewUTF8String(
+ <i>
+ const nsAString&amp;</i>
+ )</b></code> - allocates and converts:</p>
+<pre class="eval">void Foo::GetUTF8Value(char** result) {
+ *result = <b>ToNewUTF8String</b>(mLocalUTF16Value);
+}
+</pre>
+<h3 id="Lossy_Conversion" name="Lossy_Conversion">Lossy Conversion</h3>
+<p>The following should only be used when you can guarantee that the original string is ASCII. These helpers are very similar to the UTF-8 / UTF-16 conversion helpers above.</p>
+<h4 id="UTF-16_to_ASCII_converters" name="UTF-16_to_ASCII_converters">UTF-16 to ASCII converters</h4>
+<p>These converters are
+ <i>
+ <b>very dangerous</b></i>
+ because they
+ <i>
+ <b>lose information</b></i>
+ during the conversion process. You should
+ <i>
+ <b>avoid UTF-16 to ASCII conversions</b></i>
+ unless your strings are guaranteed to be ASCII. Each 16-bit code unit in 16-bit string is simply cast to an 8-bit byte, which means all Unicode character values above 0xFF are converted to an arbitrary 8-bit byte.</p>
+<ul>
+ <li><code><b>NS_LossyConvertUTF16toASCII(
+ <i>
+ nsAString</i>
+ )</b></code> - a <code>nsCAutoString</code> which holds a temporary buffer containing the deflated value of the string.</li>
+ <li><code><b>LossyCopyUTF16toASCII(
+ <i>
+ nsAString, nsACString</i>
+ )</b></code> - does an in-place conversion from UTF-16 into an ASCII string object.</li>
+ <li><code><b>LossyAppendUTF16toASCII(
+ <i>
+ nsAString, nsACString</i>
+ )</b></code> - appends an UTF-16 string to an ASCII string, losing non-ASCII values.</li>
+ <li><code><b>ToNewCString(
+ <i>
+ nsAString</i>
+ )</b></code> - allocates a new <code>char*</code> string.</li>
+</ul>
+<h4 id="ASCII_to_UTF-16_converters" name="ASCII_to_UTF-16_converters">ASCII to UTF-16 converters</h4>
+<p>These converters are
+ <i>
+ <b>very dangerous</b></i>
+ because they will
+ <i>
+ <b>mangle any non-ASCII string</b></i>
+ into a meaningless UTF-16 string. You should
+ <i>
+ <b>avoid ASCII to UTF-16 conversions</b></i>
+ unless your strings are guaranteed to be ASCII. For instance, if you have an 8-bit string encoded in a multibyte character encoding, each byte of the string will be "inflated" to a 16-bit number by simple casting.</p>
+<p>For example, imagine a UTF-8 string where the first Unicode character of the string is represented with a 3-byte UTF-8 sequence, the "inflated" UTF-16 string will contain the 3 <code>PRUnichar</code>'s instead of the single <code>PRUnichar</code> that represents the first character. These <code>PRUnichar</code>'s have nothing to do with the first Unicode character in the UTF-8 string.</p>
+<ul>
+ <li><code><b>NS_ConvertASCIItoUTF16(
+ <i>
+ nsACString</i>
+ )</b></code> - a <code>nsAutoString</code> which holds a temporary buffer containing the inflated value of the string.</li>
+ <li><code><b>CopyASCIItoUTF16(
+ <i>
+ nsACString, nsAString</i>
+ )</b></code> - does an in-place conversion from one string into a Unicode string object.</li>
+ <li><code><b>AppendASCIItoUTF16(
+ <i>
+ nsACString, nsAString</i>
+ )</b></code> - appends an ASCII string to a Unicode string.</li>
+ <li><code><b>ToNewUnicode(
+ <i>
+ nsACString</i>
+ )</b></code> - Creates a new <code>PRUnichar*</code> string which contains the inflated value.</li>
+</ul>
+<h2 id="Common_Patterns" name="Common_Patterns">Common Patterns</h2>
+<h3 id="Callee-allocated_Parameters" name="Callee-allocated_Parameters">Callee-allocated Parameters</h3>
+<p>Many APIs result in a method allocating a buffer in order to return strings to its caller. This can be tricky because the caller has to remember to free the string when they have finished using it. Fortunately, the <code>nsXPIDLString</code> class makes this very easy.</p>
+<p>A method may look like this:</p>
+<pre class="eval">void GetValue(PRUnichar** aValue)
+{
+ *aValue = ToNewUnicode(foo);
+}
+</pre>
+<p>Without the string classes, the caller would need to free the string:</p>
+<pre>{
+ PRUnichar* val;
+ GetValue(&amp;val);
+
+ if (someCondition) {
+ // don't forget to free the value!
+ nsMemory::Free(val);
+ return NS_ERROR_FAILURE;
+ }
+
+ ...
+ // and later, still don't forget to free!
+ nsMemory::Free(val);
+}
+</pre>
+<p>With <code>nsXPIDLString</code> you never have to worry about this. You can just use <code>getter_Copies()</code> to wrap the string class, and the class will remember to free the buffer when it goes out of scope:</p>
+<pre>{
+ nsXPIDLString val;
+ GetValue(getter_Copies(val));
+
+ // val will free itself here
+ if (someCondition)
+ return NS_ERROR_FAILURE;
+ ...
+ // and later, still nothing to free
+}
+</pre>
+<p>The resulting code is much simpler, and easy to read.</p>
+<h3 id="Literal_Strings" name="Literal_Strings">Literal Strings</h3>
+<p>A
+ <i>
+ literal string</i>
+ is a raw string value that is written in some C++ code. For example, in the statement <code>printf("Hello World\n");</code> the value <code>"Hello World\n"</code> is a literal string. It is often necessary to insert literal string values when an <code>nsAString</code> or <code>nsACString</code> is required. These four macros will provide you with the necessary conversion:</p>
+<ul>
+ <li><code><b>NS_LITERAL_CSTRING(
+ <i>
+ literal string</i>
+ )</b></code> - a temporary <code>nsCString</code></li>
+ <li><code><b>NS_NAMED_LITERAL_CSTRING(
+ <i>
+ variable,literal string</i>
+ )</b></code> - declares a <code>nsCString</code> variable named
+ <i>
+ variable</i>
+ </li>
+ <li><code><b>NS_LITERAL_STRING(
+ <i>
+ literal string</i>
+ )</b></code> - a temporary <code>nsString</code> with the unicode version of
+ <i>
+ literal string</i>
+ </li>
+ <li><code><b>NS_NAMED_LITERAL_STRING(
+ <i>
+ variable,literal string</i>
+ )</b></code> - declares a <code>nsString</code> variable named
+ <i>
+ variable</i>
+ with the unicode version of
+ <i>
+ literal string</i>
+ </li>
+</ul>
+<p>The purpose of the <code>CSTRING</code> versions of these macros may seem unnecessary, given that <code>nsDependentCString</code> will also wrap a string value in an <code>nsCString</code>. The advantage to these macros is that the length of these strings is calculated at compile time, so the string does not need to be scanned at runtime to determine its length.</p>
+<p>The <code>STRING</code> versions of these macros provide a portable way of declaring UTF-16 versions of the given literal string, avoiding runtime conversion on platforms which support literal UTF-16 strings (e.g., MSVC++ and GCC with the -fshort-wchar option).</p>
+<pre>// call Init(const PRUnichar*)
+Init(L"start value"); // bad - L"..." is not portable!
+Init(NS_ConvertASCIItoUTF16("start value").get()); // bad - runtime ASCII-&gt;UTF-16 conversion!
+
+// call Init(const nsAString&amp;)
+Init(nsDependentString(L"start value")); // bad - not portable!
+Init(NS_ConvertASCIItoUTF16("start value")); // bad - runtime ASCII-&gt;UTF-16 conversion!
+
+// call Init(const nsACString&amp;)
+Init(nsDependentCString("start value")); // bad - length determined at runtime
+</pre>
+<p>Here are some examples of proper <code>NS_LITERAL_[C]STRING</code> usage.</p>
+<pre>// call Init(const PRUnichar*)
+Init(NS_LITERAL_STRING("start value").get());
+
+// call Init(const nsAString&amp;)
+Init(NS_LITERAL_STRING("start value"));
+
+// call Init(const nsACString&amp;)
+Init(NS_LITERAL_CSTRING("start value"));
+</pre>
+<p>There are a few details which can be useful in tracking down issues with these macros:</p>
+<p><code>NS_LITERAL_STRING</code> does compile-time conversion to UTF-16 on some platforms (e.g. Windows, Linux, and Mac) but does runtime conversion on other platforms. By using <code>NS_LITERAL_STRING</code> your code is guaranteed to use the best possible conversion for the platform in question.</p>
+<p>Because some platforms do runtime conversion, the use of literal string concatenation inside a <code>NS_LITERAL_STRING/NS_NAMED_LITERAL_STRING</code> macro will compile on these platforms, but not on platforms which support compile-time conversion.</p>
+<p>For example:</p>
+<pre>// call Init(nsAString&amp;)
+Init(NS_LITERAL_STRING("start "
+ "value")); // only compiles on some platforms
+</pre>
+<p>The reason for this is that on some platforms, the <code>L"..."</code> syntax is used, but it is only applied to the first string in the concatenation (<code>"start "</code>). When the compiler attempts to concatenate this with the non-Unicode string <code>"value"</code> it gets confused.</p>
+<p>Also, using preprocessor macros as the string literal is unsupported:</p>
+<pre>#define some_string "See Mozilla Run"
+...
+Init(NS_LITERAL_STRING( some_string )); // only compiles on some platforms/with some compilers.
+
+</pre>
+<h3 id="String_Concatenation" name="String_Concatenation">String Concatenation</h3>
+<p>Strings can be concatenated together using the + operator. The resulting string is a <code>const nsSubstringTuple</code> object. The resulting object can be treated and referenced similarly to a <code>nsAString</code> object. Concatenation
+ <i>
+ does not copy the substrings</i>
+ . The strings are only copied when the concatenation is assigned into another string object. The <code>nsSubstringTuple</code> object holds pointers to the original strings. Therefore, the <code>nsSubstringTuple</code> object is dependent on all of its substrings, meaning that their lifetime must be at least as long as the <code>nsSubstringTuple</code> object.</p>
+<p>For example, you can use the value of two strings and pass their concatenation on to another function which takes an <code>const nsAString&amp;:</code></p>
+<pre class="eval">void HandleTwoStrings(const nsAString&amp; one, const nsAString&amp; two) {
+ // call HandleString(const nsAString&amp;)
+ HandleString(one + two);
+}
+</pre>
+<p>NOTE: The two strings are implicitly combined into a temporary <code>nsString</code> in this case, and the temporary string is passed into <code>HandleString</code>. If <code>HandleString</code> assigns its input into another <code>nsString</code>, then the string buffer will be shared in this case negating the cost of the intermediate temporary. You can concatenate N strings and store the result in a temporary variable:</p>
+<pre class="eval">NS_NAMED_LITERAL_STRING(start, "start ");
+NS_NAMED_LITERAL_STRING(middle, "middle ");
+NS_NAMED_LITERAL_STRING(end, "end");
+// create a string with 3 dependent fragments - no copying involved!
+nsString combinedString = start + middle + end;
+
+// call void HandleString(const nsAString&amp;);
+HandleString(combinedString);
+</pre>
+<p>If you are using <code>NS_LITERAL_STRING</code> to create a temporary that is only used once, then it is safe to define it inside a concatenation because the string buffer will live as long as the temporary concatenation object (of type <code>nsSubstringTuple</code>).</p>
+<pre class="eval">// call HandlePage(const nsAString&amp;);
+// safe because the concatenated-string will live as long as its substrings
+HandlePage(NS_LITERAL_STRING("start ") + NS_LITERAL_STRING("end"));
+</pre>
+<h3 id="Local_variables" name="Local_variables">Local variables</h3>
+<p>Local variables within a function are usually stored on the stack. The <code>nsAutoString/nsCAutoString</code> classes are derivatives of the <code>nsString/nsCString classes</code>. They own a 64-character buffer allocated in the same storage space as the string itself. If the <code>nsAutoString</code> is allocated on the stack, then it has at its disposal a 64-character stack buffer. This allows the implementation to avoid allocating extra memory when dealing with small strings.</p>
+<pre class="eval">...
+nsAutoString value;
+GetValue(value); // if the result is less than 64 code units,
+ // then this just saved us an allocation
+...
+</pre>
+<h3 id="Member_variables" name="Member_variables">Member variables</h3>
+<p>In general, you should use the concrete classes <code>nsString</code> and <code>nsCString</code> for member variables.</p>
+<pre class="eval">class Foo {
+ ...
+ // these store UTF-8 and UTF-16 values respectively
+ nsCString mLocalName;
+ nsString mTitle;
+};
+</pre>
+<p>Note that the strings are declared directly in the class, not as pointers to strings. Don't do this:</p>
+<pre>class Foo {
+public:
+ Foo() {
+ mLocalName = new nsCString();
+ mTitle = new nsString();
+ }
+ ~Foo() { delete mLocalName; delete mTitle; }
+
+private:
+ // these store UTF-8 and UTF-16 values respectively
+ nsCString* mLocalName;
+ nsString* mTitle;
+};
+</pre>
+<p>The above code may appear to save the cost of the string objects, but <code>nsString/nsCString</code> are small objects - the overhead of the allocation outweighs the few bytes you'd save by keeping a pointer.</p>
+<p>Another common incorrect pattern is to use <code>nsAutoString/nsCAutoString</code> for member variables. As described in <a href="#Local_variables">Local Variables</a>, these classes have a built in buffer that make them very large. This means that if you include them in a class, they bloat the class by 64 bytes (<code>nsCAutoString</code>) or 128 bytes (<code>nsAutoString</code>).</p>
+<p>An example:</p>
+<pre>class Foo {
+ ...
+
+ // bloats 'Foo' by 128 bytes!
+ nsAutoString mLocalName;
+};
+</pre>
+<h3 id="Raw_Character_Pointers" name="Raw_Character_Pointers">Raw Character Pointers</h3>
+<p><code>PromiseFlatString()</code> can be used to create a temporary buffer which holds a null-terminated buffer containing the same value as the source string. <code>PromiseFlatString()</code> will create a temporary buffer if necessary. This is most often used in order to pass an <code>nsAString</code> to an API which requires a null-terminated string.</p>
+<p>In the following example, an <code>nsAString</code> is combined with a literal string, and the result is passed to an API which requires a simple character buffer.</p>
+<pre class="eval">// Modify the URL and pass to AddPage(const PRUnichar* url)
+void AddModifiedPage(const nsAString&amp; url) {
+ NS_NAMED_LITERAL_STRING(httpPrefix, <span class="nowiki">"http://"</span>);
+ const nsAString&amp; modifiedURL = httpPrefix + url;
+
+ // creates a temporary buffer
+ AddPage(PromiseFlatString(modifiedURL).get());
+}
+</pre>
+<p><code>PromiseFlatString()</code> is smart when handed a string that is already null-terminated. It avoids creating the temporary buffer in such cases.</p>
+<pre class="eval">// Modify the URL and pass to AddPage(const PRUnichar* url)
+void AddModifiedPage(const nsAString&amp; url, PRBool addPrefix) {
+ if (addPrefix) {
+ // MUST create a temporary buffer - string is multi-fragmented
+ NS_NAMED_LITERAL_STRING(httpPrefix, <span class="nowiki">"http://"</span>);
+ AddPage(PromiseFlatString(httpPrefix + modifiedURL));
+ } else {
+ // MIGHT create a temporary buffer, does a runtime check
+ AddPage(PromiseFlatString(url).get());
+ }
+}
+</pre>
+<h3 id="printf_and_a_UTF-16_string" name="printf_and_a_UTF-16_string"><code>printf</code> and a UTF-16 string</h3>
+<p>For debugging, it's useful to <code>printf</code> a UTF-16 string (nsString, nsAutoString, nsXPIDLString, etc). To do this usually requires converting it to an 8-bit string, because that's what printf expects. However, on Windows, the following should work:</p>
+<pre class="eval">printf("%S\n", yourString.get());
+</pre>
+<p>(Note: I didn't test this. Also, I'm not sure what exactly this does to non-ASCII characters, especially when they are outside the system codepage). The reason that this doesn't work on Unix is because a wchar_t, which is what %S expects, is usually 4 bytes there (even when Mozilla is compiled with -fshort-wchar, because this would require libc to be compiled with -fshort-wchar).</p>
+<p>If non-ASCII characters aren't important, use:</p>
+<pre class="eval">printf("%s\n", NS_LossyConvertUTF16toASCII(yourString).get());
+</pre>
+<p>On platforms that use UTF-8 for console output (most Linux distributions), this works:</p>
+<pre class="eval">printf("%s\n", NS_ConvertUTF16toUTF8(yourString).get());
+</pre>
+<h2 id="IDL" name="IDL">IDL</h2>
+<p>The string library is also available through IDL. By declaring attributes and methods using the specially defined IDL types, string classes are used as parameters to the corresponding methods.</p>
+<h3 id="IDL_String_types" name="IDL_String_types">IDL String types</h3>
+<p>The C++ signatures follow the abstract-type convention described above, such that all method parameters are based on the <a href="#The_Abstract_Classes">abstract classes</a>. The following table describes the purpose of each string type in IDL.</p>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th class="header">IDL type</th>
+ <th class="header">C++ Type</th>
+ <th class="header">Purpose</th>
+ </tr>
+ <tr>
+ <td><code>string</code></td>
+ <td><code>char*</code></td>
+ <td>Raw character pointer to ASCII (7-bit) string, no string classes used. High bit is not guaranteed across XPConnect boundaries</td>
+ </tr>
+ <tr>
+ <td><code>wstring</code></td>
+ <td><code>PRUnichar*</code></td>
+ <td>Raw character pointer to UTF-16 string, no string classes used</td>
+ </tr>
+ <tr>
+ <td><code>AString</code></td>
+ <td><code>nsAString</code></td>
+ <td>UTF-16 string</td>
+ </tr>
+ <tr>
+ <td><code>ACString</code></td>
+ <td><code>nsACString</code></td>
+ <td>8-bit string, all bits are preserved across XPConnect boundaries</td>
+ </tr>
+ <tr>
+ <td><code>AUTF8String</code></td>
+ <td><code>nsACString</code></td>
+ <td>UTF-8 string - converted to UTF-16 as necessary when value is used across XPConnect boundaries</td>
+ </tr>
+ <tr>
+ <td><code>DOMString</code></td>
+ <td><code>nsAString</code></td>
+ <td>UTF-16 string used in the DOM. More or less the same as <code>AString</code>, but in JavaScript it has no distinction between whether the string is void or just empty. (not sure on this, looking for corrections.</td>
+ </tr>
+ </tbody>
+</table>
+<h3 id="C.2B.2B_Signatures" name="C.2B.2B_Signatures">C++ Signatures</h3>
+<p>In IDL, <code>in</code> parameters are read-only, and the C++ signatures for <code>*String</code> parameters follows the above guidelines by using <code>const nsAString&amp;</code> for these parameters. <code>out</code> and <code>inout</code> parameters are defined simply as <code>nsAString</code> so that the callee can write to them.</p>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th class="header">IDL</th>
+ <th class="header">C++</th>
+ </tr>
+ <tr>
+ <td>
+ <pre class="eval">
+interface nsIFoo : nsISupports {
+
+ attribute AString utf16String;
+
+
+
+
+ AUTF8String getValue(in ACString key);
+
+};
+</pre>
+ </td>
+ <td>
+ <pre class="eval">
+class nsIFoo : public nsISupports {
+
+ NS_IMETHOD GetUtf16String(nsAString&amp;
+ aResult) = 0;
+ NS_IMETHOD SetUtf16String(const nsAString&amp;
+ aValue) = 0;
+
+ NS_IMETHOD GetValue(const nsACString&amp; aKey,
+ nsACString&amp; aResult) = 0;
+};
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>In the above example, <code>utf16String</code> is treated as a UTF-16 string. The implementation of <code>GetUtf16String()</code> will use <code>aResult.Assign</code> to "return" the value. In <code>SetUtf16String()</code> the value of the string can be used through a variety of methods including <a href="#Iterators">Iterators</a>, <code><a href="#Raw_Character_Pointers">PromiseFlatString</a></code>, and assignment to other strings.</p>
+<p>In <code>GetValue()</code>, the first parameter, <code>aKey</code>, is treated as a raw sequence of 8-bit values. Any non-ASCII characters in <code>aKey</code> will be preserved when crossing XPConnect boundaries. The implementation of <code>GetValue()</code> will assign a UTF-8 encoded 8-bit string into <code>aResult</code>. If the <code>this</code> method is called across XPConnect boundaries, such as from a script, then the result will be decoded from UTF-8 into UTF-16 and used as a Unicode value.</p>
+<h3 id="Choosing_a_string_type" name="Choosing_a_string_type">Choosing a string type</h3>
+<p>It can be difficult to determine the correct string type to use for IDL. The following points should help determine the appropriate string type.</p>
+<ul>
+ <li>Using string classes may avoid new memory allocation for <code>out</code> parameters. For example, if the caller is using an <code>nsAutoString</code> to receive the value for an <code>out</code> parameter, (defined in C++ as simply <code>nsAString&amp;</code> then assignment of short (less than 64-characters) values to an <code>out</code> parameter will only copy the value into the <code>nsAutoString</code>'s buffer. Moreover, using the string classes allows for sharing of string buffers. In many cases, assigning from one string object to another avoids copying in favor of simply incrementing a reference count.</li>
+ <li><code>in</code> strings using string classes often have their length pre-calculated. This can be a performance win.</li>
+ <li>In cases where a raw-character buffer is required, <code>string</code> and <code>wstring</code> provide faster access than <code>PromiseFlatString</code>.</li>
+ <li>UTF-8 strings defined with <code>AUTF8String</code> may need to be decoded when crossing XPConnect boundaries. This can be a performance hit. On the other hand, UTF-8 strings take up less space for strings that are commonly ASCII.</li>
+ <li>UTF-16 strings defined with <code>wstring</code> or <code>AString</code> are fast when the unicode value is required. However, if the value is more often ASCII, then half of the storage space of the underlying string may be wasted.</li>
+</ul>
+<h2 id="Appendix_A_-_What_class_to_use_when" name="Appendix_A_-_What_class_to_use_when">Appendix A - What class to use when</h2>
+<p>This table provides a quick reference for what classes you should be using.</p>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th class="header">Context</th>
+ <th class="header">class</th>
+ <th class="header">Notes</th>
+ </tr>
+ <tr>
+ <td>Local Variables</td>
+ <td><code>nsAutoString<br>
+ nsCAutoString</code></td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>Class Member Variables</td>
+ <td><code>nsString<br>
+ nsCString</code></td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>Method Parameter types</td>
+ <td><code>nsAString<br>
+ nsACString</code></td>
+ <td>Use abstract classes for parameters. Use <code>const nsAString&amp;</code> for "in" parameters and <code>nsAString&amp;</code> for "out" parameters.</td>
+ </tr>
+ <tr>
+ <td>Retrieving "out" string/wstrings</td>
+ <td><code>nsXPIDLString<br>
+ nsXPIDLCString</code></td>
+ <td>Use <code>getter_Copies()</code>. Similar to <code>nsString / nsCString</code>.</td>
+ </tr>
+ <tr>
+ <td>Wrapping character buffers</td>
+ <td><code>nsDependentString<br>
+ nsDependentCString</code></td>
+ <td>Wrap <code>const char* / const PRUnichar*</code> buffers.</td>
+ </tr>
+ <tr>
+ <td>Literal strings</td>
+ <td><code>NS_LITERAL_STRING<br>
+ NS_LITERAL_CSTRING</code></td>
+ <td>Similar to <code>nsDependent[C]String</code>, but pre-calculates length at build time.</td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Appendix_B_-_nsAString_Reference" name="Appendix_B_-_nsAString_Reference">Appendix B - nsAString Reference</h2>
+<p>Read-only methods.</p>
+<ul>
+ <li><code><b>Length()</b></code></li>
+ <li><code><b>IsEmpty()</b></code></li>
+ <li><code><b>IsVoid()</b></code> - XPConnect will convert void nsAStrings to JavaScript <code>null</code>.</li>
+ <li><code><b>BeginReading(
+ <i>
+ iterator</i>
+ )</b></code></li>
+ <li><code><b>EndReading(
+ <i>
+ iterator</i>
+ )</b></code></li>
+ <li><code><b>Equals(
+ <i>
+ string[, comparator]</i>
+ )</b></code></li>
+ <li><code><b>First()</b></code></li>
+ <li><code><b>Last()</b></code></li>
+ <li><code><b>CountChar()</b></code></li>
+ <li><code><b>Left(
+ <i>
+ outstring, length</i>
+ )</b></code></li>
+ <li><code><b>Mid(
+ <i>
+ outstring, position, length</i>
+ )</b></code></li>
+ <li><code><b>Right(
+ <i>
+ outstring, length</i>
+ )</b></code></li>
+ <li><code><b>FindChar(
+ <i>
+ character</i>
+ )</b></code></li>
+</ul>
+<p>Methods that modify the string.</p>
+<ul>
+ <li><code><b>Assign(
+ <i>
+ string</i>
+ )</b></code></li>
+ <li><code><b>Append(
+ <i>
+ string</i>
+ )</b></code></li>
+ <li><code><b>Insert(
+ <i>
+ string</i>
+ )</b></code></li>
+ <li><code><b>Cut(
+ <i>
+ start, length</i>
+ )</b></code></li>
+ <li><code><b>Replace(
+ <i>
+ start, length, string</i>
+ )</b></code></li>
+ <li><code><b>Truncate(
+ <i>
+ length</i>
+ )</b></code></li>
+ <li><code><b>SetIsVoid(
+ <i>
+ state</i>
+ )</b></code> - XPConnect will convert void nsAStrings to JavaScript <code>null</code>.</li>
+ <li><code><b>BeginWriting(
+ <i>
+ iterator</i>
+ )</b></code></li>
+ <li><code><b>EndWriting(
+ <i>
+ iterator</i>
+ )</b></code></li>
+ <li><code><b>SetCapacity()</b></code></li>
+</ul>
diff --git a/files/zh-cn/mozilla/tech/xpcom/index.html b/files/zh-cn/mozilla/tech/xpcom/index.html
new file mode 100644
index 0000000000..98620642db
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/index.html
@@ -0,0 +1,44 @@
+---
+title: XPCOM
+slug: Mozilla/Tech/XPCOM
+tags:
+ - XPCOM
+ - 所有分类
+translation_of: Mozilla/Tech/XPCOM
+---
+<p><strong>XPCOM</strong>(Cross Platform Component Object Model)是一种跨平台组件对象模型,其原理与微软的COM技术类似,它支持多种语言绑定(<a href="cn/XPCOM/Language_Bindings">Language Bindings</a>)。也就是说,我们可以使用C++、JAVA、JavaScript、Python、Ruby、Perl等语言来编写组件。而XPCOM的接口是用一种叫做<a href="cn/XPIDL">XPIDL</a>的IDL(Interface Description Language)来定义的。</p>
+
+<div>
+<p>XPCOM 本身提供了一套核心的组件和类,用于诸如内存管理,线程,基本数据结构(strings, arrays, variants)等 。但是大部分的XPCOM组件并不是这个核心库提供的,而是由很多第三方的平台(例如<a href="cn/Gecko">Gecko</a>或者<a href="Necko">Necko</a>)提供,或者由一个应用,甚至一个扩展提供。</p>
+
+<p> </p>
+
+<p></p><div class="row topicpage-table">
+ <div class="section"><dl><dl><dt class="landingPageList"><a href="/zh-CN/docs/Generic_factory">Generic factory</a></dt><dd class="landingPageList">Most XPCOM factories can be very simple. Rick Potts wrote a templated-based generic factory (nsFactory&lt;t&gt;) that simplifies the factory creation process that just requires writing a CreateInstance() method. The new nsIGenericFactory interface takes this a step further, by providing a single interface that can be reused anytime a simple implementation of nsIFactory is needed. Here is the interface, and a description of its use.&lt;/t&gt;</dd><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Observer_Notifications">Observer Notifications</a></dt><dd class="landingPageList">The following are topics that you can observe during the course of an application. Unless otherwise noted you register for the topics using the <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIObserverService" title="">nsIObserverService</a></code>.</dd><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Setting_HTTP_request_headers">Setting HTTP request headers</a></dt><dd class="landingPageList"><a href="https://developer.mozilla.org/en-US/docs/HTTP">HTTP</a> 是网络背后的核心技术之一。除了实质内容之外,一些重要的信息通过HTTP 头传递给HTTP 请求和响应。</dd><dt class="landingPageList"><a href="/zh-CN/docs/Storage">Storage</a></dt><dd class="landingPageList"><strong>Storage</strong> 存储是一个 <a class="external" href="http://www.sqlite.org/">SQLite</a> 数据库API。它可用于受信任的调用者,仅限于扩展和Firefox组件。</dd><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Glue">XPCOM Glue</a></dt><dd class="landingPageList">The XPCOM Glue is a static library which component developers and embedders can link against. It allows developers to link only against the frozen XPCOM method symbols and maintain compatibility with multiple versions of XPCOM.</dd><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference">XPCOM reference</a></dt><dd class="landingPageList">This reference describes the interfaces and functions provided by the <a href="/en-US/docs/Mozilla/Tech/XPCOM">XPCOM</a> library. In addition, it details the various helper classes and functions, as well as the components, provided by the <a href="/en-US/docs/Mozilla/Tech/XPCOM/Glue">XPCOM glue</a> library. The contents herein are oriented primarily toward extension developers and people embedding XPCOM in other projects.</dd></dl></dl></div>
+ <div class="section"><dl><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Guide">XPCOM 指南</a></dt><dd class="landingPageList">本文提供了关于 XPCOM 的说明和使用文档,包括如何在你的工程中使用,如何为你的 Firefox 扩展等构建 XPCOM 组件。</dd><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Interfacing_with_the_XPCOM_cycle_collector">与XPCOM cycle collector交互</a></dt><dd class="landingPageList">本文是对于在Firefox 3的XPCOM中引入的cycle collector的一个简要描述,描述了将一个已有的C++类修改为一个XPCOM cycle collection中的参与项的步骤。如果你认为你有关于类的循环引用导致的内存泄漏,那可以看看这个。</dd><dt class="landingPageList"><a href="/zh-CN/docs/Using_the_Clipboard">使用剪贴板</a></dt><dd class="landingPageList">This section provides information about cutting, copying and pasting to and from the clipboard.</dd><dt class="landingPageList"><a href="/zh-CN/docs/Creating_a_Python_XPCOM_component">创建Python XPCOM组件</a></dt><dd class="landingPageList"><a href="http://books.mozdev.org/html"><em>Creating Applications with Mozilla</em></a> 已经包含了一个<a href="http://books.mozdev.org/html/mozilla-chp-8-sect-2.html" title="http://books.mozdev.org/html/mozilla-chp-8-sect-2.html">教程</a>用于编写简单的基于JavaScript和C++(实现<code>nsISimple</code>接口)的组件,本文阐述如何通过Python语言使用<a href="/en-US/docs/PyXPCOM" title="/en-US/docs/PyXPCOM">PyXPCOM</a>创建相同的组件。</dd><dt class="landingPageList"><a href="/zh-CN/docs/Aggregating_the_In-Memory_Datasource">收集 In-Memory 数据源</a></dt><dd class="landingPageList"></dd><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Language_Bindings">语言绑定</a></dt><dd class="landingPageList">一款 <strong>XPCOM 的语言绑定</strong>是连接某种特定的程序设计语言与 <a href="/cn/XPCOM" title="cn/XPCOM">XPCOM</a> 之间的纽带,它用来提供从语言到 XPCOM 对象的访问, 并且将此种语言写成的模块作为其他进行 XPCOM 绑定的程序语言的 XPCOM 对象。</dd></dl></div>
+ </div><p></p>
+
+<p></p><div class="blockIndicator communitybox">
+
+ <div class="column-container">
+ <h2 id="加入_XPCOM_社区">加入 XPCOM 社区</h2>
+ <div class="column-half">
+ <div class="communitysubhead">请选择你喜欢的方式加入我们:</div>
+ <ul class="communitymailinglist">
+ <li><a href="https://lists.mozilla.org/listinfo/dev-tech-xpcom"> 邮件列表</a></li>
+
+
+ <li><a href="http://groups.google.com/group/mozilla.dev.tech.xpcom"> 新闻组</a></li>
+ <li><a href="http://groups.google.com/group/mozilla.dev.tech.xpcom/feeds"> Web feed</a></li>
+</ul>
+ </div>
+ <div class="column-half">
+ <ul class="communitycontact"><li><strong>IRC: </strong><a href="irc://irc.mozilla.org/developers">#developers</a> <span class="smaller">(<a href="https://wiki.mozilla.org/IRC">了解 IRC</a>)</span></li><li><strong>Tools: </strong><a href="http://ted.mielczarek.org/code/mozilla/jscomponentwiz/">JavaScript Component Wizard</a>, <a href="http://www.mytools360.com-a.googlepages.com/home#XPComPro">Visual C++ Component Wizard</a>, <a href="http://www.yutools.com/wp/tools/yuxpcomwizard/?lang=en">Visual C++ Component Wizard for Visual Studio 2010</a></li></ul>
+ </div>
+ </div>
+</div><p></p>
+
+<p></p><section id="Quick_Links"><ol><li><a href="http://www.ibm.com/developerworks/library/os-xpcomfirefox/">Tutorial from IBM DeveloperWorks</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Creating_Custom_Firefox_Extensions_with_the_Mozilla_Build_System">Binary components tutorial</a></li><li><a href="http://www.iosart.com/firefox/xpcom/">Linux and Windows how-to guide</a></li><li><a href="http://starkravingfinkle.org/blog/2006/10/mozilla-platform-xpcom-in-c/">Windows example blog post</a></li><li><a href="http://wanderingstan.com/2007-11-16/geekout_how_to_make_a_c_xpcom_component">Another Windows example</a></li><li><a href="http://rcrowley.org/2007/07/17/cross-platform-xpcom-a-howto.html">Mac OS X example</a></li><li><a href="/en-US/docs/Web/JavaScript" title="JavaScript (JS) is a lightweight interpreted or JIT-compiled programming language with first-class functions. While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as Node.js, Apache CouchDB and Adobe Acrobat.">JavaScript</a></li></ol></section><p></p>
+</div>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/interfacing_with_the_xpcom_cycle_collector/index.html b/files/zh-cn/mozilla/tech/xpcom/interfacing_with_the_xpcom_cycle_collector/index.html
new file mode 100644
index 0000000000..a0b4472d02
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/interfacing_with_the_xpcom_cycle_collector/index.html
@@ -0,0 +1,141 @@
+---
+title: 与XPCOM cycle collector交互
+slug: Mozilla/Tech/XPCOM/Interfacing_with_the_XPCOM_cycle_collector
+translation_of: Mozilla/Tech/XPCOM/Interfacing_with_the_XPCOM_cycle_collector
+---
+<p>本文是对于在Firefox 3的XPCOM中引入的cycle collector的一个简要描述,描述了将一个已有的C++类修改为一个XPCOM cycle collection中的参与项的步骤。如果你认为你有关于类的循环引用导致的内存泄漏,那可以看看这个。</p>
+
+<p>本文面向Mozilla C++开发者。</p>
+
+<h2 id="What_the_cycle_collector_does" name="What_the_cycle_collector_does">cycle collector干了些什么</h2>
+
+<p>cycle collector大部分时间在记录可能导致循环引用的XPCOM对象指针。在collector的空闲阶段,<code>nsAutoRefCnt的变体通过collector快速的修改自己的注册状态(注册/注销),会传递出一个“可疑”的引用计数事件(从N+1到N,N≠0)。</code></p>
+
+<p>collector会阶段性的唤醒并验证缓冲区中记录过的可疑指针。这是collector的扫描阶段。在这个阶段,collector会请求每个候选项的cycle-collection helper类,如果存在,则需要helper来描述候选项拥有的子结构。collector可以以这种方式建立一个从可疑对象开始的拥有权关系图。</p>
+
+<p>如果collector发现一组对象出现了彼此互相引用,并且确定组内对象的引用计数全由组内其他对象提供,则认定这组对象为循环引用,并尝试释放它们。这是collector的释放阶段。在这个阶段,collector遍历已找到的循环引用对象,再次请求它们的helper对象,释放其子结构和其他对象的引用。</p>
+
+<p>collector也能遍历JS堆,并定位传入和传出的循环引用。</p>
+
+<h2 id="How_the_collector_can_fail" name="How_the_collector_can_fail">collector失效</h2>
+
+<p>cycle collector是一个保守的设备。有些情况下,它无法回收循环引用。</p>
+
+<ol>
+ <li>它默认不怀疑任何指针;对象必须要标记它们自己为可疑对象,一般用<code>nsCycleCollectingAutoRefCnt而不是nsAutoRefCnt。</code></li>
+ <li>它只遍历那些在QI(QueryInterface)时返回helper对象的对象。如果在遍历图的过程中遇到了未知的边,那它会直接放弃这条边,因此每条边都需要被标记为可疑对象,否则找不到环。</li>
+ <li>helper对象中的<code>Traverse<font face="Open Sans, arial, x-locale-body, sans-serif">和</font></code><code>Unlink</code>方法不是魔法,是程序员编码的,如果代码写错了,那collector也还是会崩。</li>
+ <li>collector不知道怎么去搜索一个存在栈中的具有所有权的临时指针,所以将它放在程序的最顶层运行是有必要的。虽然有额外的所有权指针时不会崩,但是它会无法统计已记录的对象的引用计数,这也有可能导致回收失败。</li>
+</ol>
+
+<h2 id="How_to_make_your_classes_participate" name="How_to_make_your_classes_participate">怎么标记一个类为候选项</h2>
+
+<p>cycle collector和你的类之间的接口使用<code>xpcom/base/nsCycleCollector.h中的内容实现直接获取,但是在xpcom/glue/nsCycleCollectionParticipant.h中提供了很多方便的宏用来标记你的类。通常,如果你用nsCOMPtr的mBar和mBaz来修改类nsFoo,可以简化为几个简单的修改:</code></p>
+
+<ol>
+ <li>在nsFoo.h和nsFoo.cpp中包含头文件<code>nsCycleCollectionParticipant.h。</code> </li>
+ <li>在nsFoo.cpp中加一行用于声明nsFoo类是cycle collection的候选项的语句:
+ <pre class="brush: cpp">NS_IMPL_CYCLE_COLLECTION_CLASS(nsFoo)</pre>
+ </li>
+ <li>在nsFoo的定义里,将写有<code>NS_DECL_ISUPPORTS的行修改为</code><code>NS_DECL_CYCLE_COLLECTING_ISUPPORTS</code>.</li>
+ <li>
+ <p><code><font face="Open Sans, arial, x-locale-body, sans-serif">在nsFoo的定义里public部分加一行</font>NS_DECL_CYCLE_COLLECTION_CLASS(nsFoo)。如果nsFoo从多个接口继承而来的话,可以写成NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsFoo, nsIBar),在你QueryInterface nsFoo为nsISSupports时,nsIBar作为接口返回。(我们把nsIBar称为nsFoo的典型ISupport类型。)</code></p>
+ </li>
+ <li>在nsFoo.cpp里接口map处加一行<code>NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsFoo)</code> :
+ <pre class="brush: cpp">NS_INTERFACE_TABLE_HEAD(nsFoo)
+ NS_INTERFACE_TABLE2(nsFoo,
+ nsIBar,
+ nsIBaz)
+ NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsFoo)
+NS_INTERFACE_MAP_END
+</pre>
+ </li>
+ <li>在nsFoo.cpp里把<code>NS_IMPL_ADDREF(nsFoo)</code>修改为<code>NS_IMPL_CYCLE_COLLECTING_ADDREF(nsFoo),同样的修改</code><code>NS_IMPL_RELEASE(nsFoo)</code>为<code>NS_IMPL_CYCLE_COLLECTING_RELEASE(nsFoo)。</code></li>
+ <li><code><font face="Open Sans, arial, x-locale-body, sans-serif">可以在nsFoo.cpp中添加合适的</font>NS_IMPL_CYCLE_COLLECTION_#</code>宏, <code>#是你类中的成员数量。如果nsFoo包含两个成员变量,mBar和mBaz,我们可以写成NS_IMPL_CYCLE_COLLECTION_2(nsFoo, mBar, mBaz)。</code></li>
+</ol>
+
+<p>你的类可能会比这张图的结构更复杂。例如,你的类可能有好几个nsISupport基类,需要使用一些执行消除歧义的* _AMBIGUOUS宏。或者说你的类拥有复杂的所有权结构,这样简单的NS_IMPL_CYCLE_COLLECTION_N宏就低效了;你可能需要手动的实现helper类的<em>Traverse和Unlink方法。即使是这样的情况,也可以使用NS_IMPL_CYCLE_COLLECTION_TRAVERSE_ {BEGIN,END}和NS_IMPL_CYCLE_COLLECTION_UNLINK_ {BEGIN,END}。可以在一些复杂的类中看到实例,例如content/base/src/nsGenericElement.cpp。</em> If your class has tearoffs or is being aggregated by other classes it is important to make the tearoff classes or the outer classes participate in cycle collection too, not doing so could lead to the cycle collector trying to collect the objects too soon.</p>
+
+<h3 id="手动的实现Traverse和Unlink方法">手动的实现<em>Traverse和Unlink方法</em></h3>
+
+<p>每个可能包含循环回收对象的域都需要被传递给cycle collector,以检查通过这些域的循环。</p>
+
+<p>用于Traverse的宏主要是是NS_IMPL_CYCLE_COLLECTION_TRAVERSE:</p>
+
+<p>  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSomeMember)</p>
+
+<p>Unlink同理:</p>
+
+<p>  NS_IMPL_CYCLE_COLLECTION_UNLINK(mSomeMember)</p>
+
+<p>这些宏应当处理各种情况,像指向nsISupports对象的指针或者非nsISupports对象的指针,或者这些指针的数组,当然这些指针都是有引用计数的、被collector记录的指针。</p>
+
+<h3 id="处理JSObject">处理JSObject</h3>
+
+<p>如果你的类需要保存一个指向JSObject的指针,你需要告知cycle collector。像这样操作:</p>
+
+<p>首先,它必须被保存在<code>JS::Heap&lt;JSObject *&gt;域,假如你的类nsFoo有一个域mSomeObj:</code></p>
+
+<pre class="brush: cpp">private:
+ ...
+ JS::Heap&lt;JSObject*&gt; mSomeObj;
+ ...</pre>
+
+<p>当你在JS对象指针中存了东西时,你需要用<code>mozilla::HoldJSObjects来告诉GC遍历它并保持这个对象的存活:</code></p>
+
+<pre class="brush: cpp">...
+mSomeObj = ... ;
+<code>mozilla::HoldJSObjects</code>(this);
+...
+</pre>
+
+<p>在Unlink方法(或者析构函数)里,需要将对象指针置为空:</p>
+
+<pre class="brush: cpp">NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsFoo)
+ ...
+  NS_IMPL_CYCLE_COLLECTION_UNLINK(mSomeMember)
+  ...
+  //如果你的类是wrapper cache:
+ //NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
+
+  tmp-&gt;mSomeObj = nullptr;
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+</pre>
+
+<p>在析构函数里调用</p>
+
+<pre class="brush: cpp"><code>mozilla::DropJSObjects</code>(this);</pre>
+
+<p>你需要在Traverse方法列出cycle collector中记录的成员,也就是非JS对象:</p>
+
+<pre class="brush: cpp">NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsFoo)
+ ...
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSomeMember)
+ ...
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+</pre>
+
+<p>最后你需要把JS对象加入Trace方法:</p>
+
+<pre class="brush: cpp">NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsFoo)
+  //if your class is a wrapper cache:
+ //NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
+
+  NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mSomeObj)
+NS_IMPL_CYCLE_COLLECTION_TRACE_END
+</pre>
+
+<p>如果你的类是一个wrapper cache,可能生成的代码用了<code>NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_#</code>宏而不是<code>NS_IMPL_CYCLE_COLLECTION_#</code>. 这个宏不能定义Trace方法,因此不能列出JS对象;所以你需要向上面那样手动实现Trace和Unlink。</p>
+
+<h3 id="处理_JSValue_fields">处理 JS::Value fields</h3>
+
+<p> <a href="/en-US/docs/SpiderMonkey/JSAPI_Reference/Jsval" title="/en-US/docs/SpiderMonkey/JSAPI_Reference/Jsval">这里</a>说过,一个<code>JS::Value可能引用一个字符串或者对象并且被GC控制。于是我们需要告知cycle collector这种成员变量的存在。这与JSObject相似,但是使用的是NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK宏:</code></p>
+
+<pre class="brush: cpp">NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsFoo)
+ ...
+ NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mSomeJSVal).
+ ...
+NS_IMPL_CYCLE_COLLECTION_TRACE_END
+</pre>
+
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/language_bindings/components.utils.cloneinto/index.html b/files/zh-cn/mozilla/tech/xpcom/language_bindings/components.utils.cloneinto/index.html
new file mode 100644
index 0000000000..0bc55dbf99
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/language_bindings/components.utils.cloneinto/index.html
@@ -0,0 +1,290 @@
+---
+title: Components.utils.cloneInto
+slug: Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.cloneInto
+translation_of: Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.cloneInto
+---
+<div><section class="Quick_links" id="Quick_Links">
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions"><strong>Browser extensions</strong></a></li>
+ <li class="toggle">
+ <details>
+ <summary>Getting started</summary>
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/What_are_WebExtensions">What are extensions?</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension">Your first extension</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Your_second_WebExtension">Your second extension</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Anatomy_of_a_WebExtension">Anatomy of an extension</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Examples">Example extensions</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/What_next_">What next?</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Concepts</summary>
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Using_the_JavaScript_APIs">Using the JavaScript APIs</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">Content scripts</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Match_patterns">Match patterns</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Working_with_files">Working with files</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Internationalization">Internationalization</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Security_best_practices">Security best practices</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy">Content Security Policy</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Native_messaging">Native messaging</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>User interface</summary>
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface">User Interface</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Browser_action">Toolbar button</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Page_actions">Address bar button</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Sidebars">Sidebars</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Context_menu_items">Context menu items</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Options_pages">Options page</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Extension_pages">Extension pages</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Notifications">Notifications</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/Omnibox">Address bar suggestions</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/user_interface/devtools_panels">Developer tools panels</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>How to</summary>
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Intercept_HTTP_requests">Intercept HTTP requests</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Modify_a_web_page">Modify a web page</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Safely_inserting_external_content_into_a_page">Insert external content</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Add_a_button_to_the_toolbar">Add a button to the toolbar</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Implement_a_settings_page">Implement a settings page</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Working_with_the_Tabs_API">Work with the Tabs API</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Work_with_the_Bookmarks_API">Work with the Bookmarks API</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Work_with_the_Cookies_API">Work with the Cookies API</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Work_with_contextual_identities">Work with contextual identities</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/onboarding_upboarding_offboarding_best_practices">Onboard, upboard, and offboard users</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Porting</summary>
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Firefox_differentiators">Firefox differentiators</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Porting_a_Google_Chrome_extension">Porting a Google Chrome extension</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Porting_a_legacy_Firefox_add-on">Porting a legacy Firefox extension</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Embedded_WebExtensions">Embedded WebExtensions</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Comparison_with_the_Add-on_SDK">Comparison with the Add-on SDK</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Comparison_with_XUL_XPCOM_extensions">Comparison with XUL/XPCOM extensions</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Differences_between_API_implementations">Differences between API implementations</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Chrome_incompatibilities">Chrome incompatibilities</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Differences_between_desktop_and_Android">Differences between desktop and Android</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Firefox workflow</summary>
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Development_Tools">Developer tools</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/User_experience_best_practices">User Experience</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Temporary_Installation_in_Firefox">Temporary Installation in Firefox</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Debugging">Debugging</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Testing_persistent_and_restart_features">Testing persistent and restart features</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Developing_WebExtensions_for_Firefox_for_Android">Developing for Firefox for Android</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Getting_started_with_web-ext">Getting started with web-ext</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/web-ext_command_reference">web-ext command reference</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/WebExtensions_and_the_Add-on_ID">Extensions and the Add-on ID</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Request_the_right_permissions">Request the right permissions</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>JavaScript APIs</summary>
+ <ol><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Browser_support_for_JavaScript_APIs">Browser support for JavaScript APIs</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API/alarms">alarms</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API/bookmarks">bookmarks</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API/browserAction">browserAction</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API/contextMenus">contextMenus</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API/cookies">cookies</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API/devtools.inspectedWindow">devtools.inspectedWindow</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API/history">history</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API/runtime">runtime</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API/storage">storage</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API/tabs">tabs</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API/webNavigation">webNavigation</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API/webRequest">webRequest</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API/windows">windows</a></li></ol>
+ </details>
+ </li>
+
+ <li class="toggle">
+ <details>
+ <summary>Manifest keys</summary>
+ <ol><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings">applications</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_action">browser_action</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts">content_scripts</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/default_locale">default_locale</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/developer">developer</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/manifest_version">manifest_version</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/version">version</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/%E4%B8%BB%E9%A1%B5%E5%9C%B0%E5%9D%80">主页地址</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/author">作者 - author</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/name">名称 - name</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/background">后台 - background</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/description">描述 - description</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">权限 - permissions</a></li><li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json/short_name">短名称 - short_name</a></li></ol>
+ </details>
+ </li>
+
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/Themes"><strong>Themes</strong></a></li>
+ <li class="toggle">
+ <details>
+ <summary>Browser themes</summary>
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/Themes/Theme_concepts">Browser theme concepts</a></li>
+ </ol>
+ </details>
+ </li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/Distribution"><strong>Publishing and Distribution</strong></a></li>
+ <li class="toggle">
+ <details>
+ <summary>Publishing add-ons</summary>
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/Distribution">Signing and distribution overview</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Package_your_extension_">Package your extension</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/Distribution/Submitting_an_add-on">Submit an add-on</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/Source_Code_Submission">Source code submission</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/Distribution/Resources_for_publishers">Resources for publishers</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/Listing">Creating an appealing listing</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/Distribution/Make_money_from_browser_extensions">Make money from browser extensions</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/Distribution/Promoting_your_extension_or_theme">Promoting your extension or theme</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/AMO/Policy/Reviews">Review policies</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/AMO/Policy/Agreement">Developer agreement</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/AMO/Policy/Featured">Featured add-ons</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/Distribution/Retiring_your_extension">Retiring your extension</a></li>
+ </ol>
+ </details>
+ </li>
+ <li class="toggle">
+ <details>
+ <summary>Distributing add-ons</summary>
+ <ol>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Alternative_distribution_options/Sideloading_add-ons">For sideloading</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Alternative_distribution_options/Add-ons_for_desktop_apps">For desktop apps</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/Alternative_distribution_options/Add-ons_in_the_enterprise">For an enterprise</a></li>
+ </ol>
+ </details>
+ </li>
+ <li><a href="https://discourse.mozilla.org/c/add-ons"><strong>Community and Support</strong></a></li>
+ <li class="toggle">
+ <details>
+ <summary>Channels</summary>
+ <ol>
+ <li><a href="https://blog.mozilla.org/addons">Add-ons blog</a></li>
+ <li><a href="https://discourse.mozilla.org/c/add-ons">Add-on forums</a></li>
+ <li><a href="http://stackoverflow.com/questions/tagged/firefox-addon">Stack Overflow</a></li>
+ <li><a href="/zh-CN/docs/Mozilla/Add-ons/#Contact_us">Contact us</a></li>
+ </ol>
+ </details>
+ </li>
+ </ol>
+</section></div>
+
+<p><span class="seoSummary">该函数为定义在某一作用域中的对象提供了一个安全的、将其<a href="https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/The_structured_clone_algorithm">结构化克隆</a>到其字作用域中的方法,</span>并返回对克隆对象的引用:</p>
+
+<pre class="brush: js">var clonedObject = cloneInto(myObject, targetWindow);</pre>
+
+<p>可以将克隆后的对象作为可扩展对象的动态属性引入到特定作用域中,以便运行在该作用域的脚本进行访问:</p>
+
+<pre class="brush: js">targetWindow.foo = clonedObject;</pre>
+
+<p>通过这种方式,运行在某一作用域中的代码可以和运行在另一作用域中的代码共享对某一对象的访问。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="brush: js">Components.utils.cloneInto(obj, targetScope[, options]);</pre>
+
+<h3 id="参数列表">参数列表</h3>
+
+<dl>
+ <dt><code>obj : object</code></dt>
+ <dd>被克隆对象。</dd>
+ <dt><code>targetScope : object</code></dt>
+ <dd>对象克隆后的容器。</dd>
+ <dt><code>options : object</code></dt>
+ <dd>该参数为一可选参数。该参数为一拥有以下可选属性的对象:</dd>
+</dl>
+
+<ul>
+ <li><code>cloneFunctions</code>: 决定函数是否被克隆的布尔值。默认值为 <code>false</code>。Cloned functions have the same semantics as functions exported using <a href="/en-US/docs/Components.utils.exportFunction"><code>Components.utils.exportFunction</code></a>. See <a href="/en-US/docs/Components.utils.cloneInto#Cloning_objects_that_have_functions">Cloning objects that have functions</a> below.</li>
+ <li><code>wrapReflectors</code>: a Boolean value that determines if objects reflected from C++, such as DOM objects, should be cloned. If omitted the default value is <code>false</code>. See <a href="/en-US/docs/Components.utils.cloneInto#Cloning_objects_that_contain_DOM_elements">Cloning objects that contain DOM elements</a> below.</li>
+</ul>
+
+<h3 id="返回值">返回值</h3>
+
+<p>对克隆后的对象的引用。</p>
+
+<h2 id="范例">范例</h2>
+
+<p>This add-on script creates an object, clones it into the content window and makes it a property of the content window global:</p>
+
+<pre class="brush: js">// add-on script
+
+var addonScriptObject = {"greeting" : "hello from add-on"};
+contentWindow.addonScriptObject = cloneInto(addonScriptObject, contentWindow);</pre>
+
+<p>Scripts running in the page can now access the object:</p>
+
+<pre class="brush: js">// page script
+
+button.addEventListener("click", function() {
+ console.log(window.addonScriptObject.greeting); // "hello from add-on"
+}, false);</pre>
+
+<p>Of course, you don't have to assign the clone to the window itself: you can assign it to some other object in the target scope:</p>
+
+<pre class="brush: js">contentWindow.foo.addonScriptObject = cloneInto(addonScriptObject, contentWindow);</pre>
+
+<p>You can also pass it into a function defined in the page script. Suppose the page script defines a function like this:</p>
+
+<pre class="brush: js">// page script
+
+function foo(greeting) {
+ console.log("they said: " + greeting.message);
+}
+</pre>
+
+<p>The add-on script can define an object, clone it, and pass it into this function:</p>
+
+<pre class="brush: js">// add-on script
+
+var addonScriptObject = {"message" : "hello from add-on"};
+contentWindow.foo(cloneInto(addonScriptObject, contentWindow)); // "they said: hello from add-on"</pre>
+
+<h3 id="Cloning_objects_that_have_functions">Cloning objects that have functions</h3>
+
+<p>If the object to be cloned contains functions, you must pass the <code>{cloneFunctions:true}</code> flag or you'll get an error. If you do pass this flag, then functions in the object are cloned using the same mechanism as that used in <a href="/en-US/docs/Components.utils.exportFunction"><code>Components.utils.exportFunction</code></a>:</p>
+
+<pre class="brush: js">// add-on script
+
+var addonScriptObject = {
+ greetme: function() {
+ alert("hello from add-on");
+ }
+};
+
+contentWindow.addonScriptObject = cloneInto(addonScriptObject,
+ contentWindow,
+ {cloneFunctions: true});
+</pre>
+
+<pre class="brush: js">// page script
+
+var test = document.getElementById("test");
+
+test.addEventListener("click", function() {
+ window.addonScriptObject.greetme();
+}, false);</pre>
+
+<h3 id="Cloning_objects_that_contain_DOM_elements">Cloning objects that contain DOM elements</h3>
+
+<p>By default, if the object you clone contains objects that are reflected from C++, such as DOM elements, the cloning operation will fail with an error. If you pass the <code>{wrapReflectors:true}</code> flag, then the object you clone is allowed to contain these objects:</p>
+
+<pre class="brush: js">// add-on script
+
+var addonScriptObject = {
+ body: contentWindow.document.body
+};
+
+contentWindow.addonScriptObject = cloneInto(addonScriptObject,
+ contentWindow,
+ {wrapReflectors: true});</pre>
+
+<pre class="brush: js">// page script
+
+var test = document.getElementById("test");
+
+test.addEventListener("click", function() {
+ console.log(window.addonScriptObject.body.innerHTML);
+}, false);</pre>
+
+<p>Access to these objects in the target scope is subject to the normal <a href="/en-US/docs/Security_check_basics">security checks</a>.</p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/language_bindings/components.utils.getglobalforobject/index.html b/files/zh-cn/mozilla/tech/xpcom/language_bindings/components.utils.getglobalforobject/index.html
new file mode 100644
index 0000000000..a22b49a2d5
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/language_bindings/components.utils.getglobalforobject/index.html
@@ -0,0 +1,41 @@
+---
+title: Components.utils.getGlobalForObject
+slug: Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.getGlobalForObject
+translation_of: Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.getGlobalForObject
+---
+<p></p>
+
+<p><font>此方法是用于确定与对象关联的全局对象。用于</font>获取创建对象时所处的全局对象, 即在执行创建对象的脚本时使用的全局对象。</p>
+
+<h3 id="Syntax" name="Syntax">语法</h3>
+
+<pre class="eval">var global = Components.utils.getGlobalForObject(<em>obj</em>);
+</pre>
+
+<h3 id="Parameters" name="Parameters">参数</h3>
+
+<dl>
+ <dt><code>obj</code></dt>
+ <dd>其对应的全局对象将被检索的对象; 非可选参数,必须是对象。</dd>
+</dl>
+
+<h3 id="Example" name="Example">例子</h3>
+
+<pre class="eval">var obj = {};
+function foo() { }
+var global = this;
+
+var g1 = Components.utils.getGlobalForObject(foo);
+var g2 = Components.utils.getGlobalForObject(obj);
+// g1 === global, g2 === global, g1 === g2
+
+// In a script in another window
+var global2 = this;
+function bar() { }
+var obj2 = {};
+
+// Then, assuming bar refers to the function defined in that other window:
+var o1 = Components.utils.getGlobalForObject(bar);
+var o2 = Components.utils.getGlobalForObject(obj2);
+// o1 === global2, o2 === global2
+</pre>
diff --git a/files/zh-cn/mozilla/tech/xpcom/language_bindings/index.html b/files/zh-cn/mozilla/tech/xpcom/language_bindings/index.html
new file mode 100644
index 0000000000..cf8ced2678
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/language_bindings/index.html
@@ -0,0 +1,20 @@
+---
+title: 语言绑定
+slug: Mozilla/Tech/XPCOM/Language_Bindings
+tags:
+ - XPCOM
+ - 'XPCOM:Language Bindings'
+translation_of: Mozilla/Tech/XPCOM/Language_Bindings
+---
+<p>一款 <strong>XPCOM 的语言绑定</strong>是连接某种特定的程序设计语言与 <a href="/cn/XPCOM" title="cn/XPCOM">XPCOM</a> 之间的纽带,它用来提供从语言到 XPCOM 对象的访问, 并且将此种语言写成的模块作为其他进行 XPCOM 绑定的程序语言的 XPCOM 对象。 </p>
+<p>更具体的说, 一个 XPCOM 语言绑定:</p>
+<ul>
+ <li>允许<em>在特定的程序设计语言中访问 XPCOM 对象</em>(此处,访问的意思是能够读取、写入和创建 XPCOM 对象以及调用这些对象的方法)。</li>
+ <li>暴露<em>由</em><em>特定的程序设计语言</em><em>编写的模块并使之成为一个 XPCOM 对象</em>,从而允许所有已绑定的其它程序设计语言能够访问这些模块。</li>
+</ul>
+<p>由于 XPCOM 层本身使用 C/C++ 编写,因此可以使用 C/C++ 直接访问其 API。而当其它的程序设计语言需要访问该 API 时,则需要通过额外的桥接层来实现。</p>
+<p>当前有效的链接层如下:</p>
+<p></p><div class="row topicpage-table">
+ <div class="section"><dl><dl><dt class="landingPageList"><a href="/zh-CN/docs/Components_object">Components</a></dt><dd class="landingPageList"><code>Components</code> 对象是 <a href="https://developer.mozilla.org/en/XPConnect" title="en/XPConnect">XPConnect</a> 功能被映射到 <a href="https://developer.mozilla.org/en/JavaScript" title="en/JavaScript">JavaScript</a> 上的对象。<code>Components</code> 对象的 native 实现位置在   <a href="https://dxr.mozilla.org/mozilla-central/source/js/xpconnect/idl/xpccomponents.idl" rel="custom">nsIXPCComponents</a> , 这个接口会被映射成JavaScript 作为使用 XPConnect 的最高层级的对象。</dd><dt class="landingPageList"><a href="/zh-CN/docs/Components.classes">Components.classes</a></dt><dd class="landingPageList"></dd><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.cloneInto">Components.utils.cloneInto</a></dt><dd class="landingPageList">该函数为定义在某一作用域中的对象提供了一个安全的、将其<a href="https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/The_structured_clone_algorithm">结构化克隆</a>到其字作用域中的方法,</dd><dt class="landingPageList"><a href="/zh-CN/docs/Components.utils.evalInSandbox">Components.utils.evalInSandbox</a></dt><dd class="landingPageList"></dd><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.getGlobalForObject">Components.utils.getGlobalForObject</a></dt><dd class="landingPageList"><font>此方法是用于确定与对象关联的全局对象。用于</font>获取创建对象时所处的全局对象, 即在执行创建对象的脚本时使用的全局对象。</dd></dl></dl></div>
+ <div class="section"><dl><dt class="landingPageList"><a href="/zh-CN/docs/Components.utils.import">Components.utils.import</a></dt><dd class="landingPageList">这个方法在 <a href="/en/Firefox_3_for_developers" title="en/Firefox_3_for_developers">Firefox 3</a> 中被引入,它使得在不同的作用域之间分享代码变得更加容易。例如:你可以直接导入 <a href="/en/JavaScript_code_modules/XPCOMUtils.jsm" title="en/XPCOMUtils.jsm">XPCOMUtils.jsm</a> 而不必复制/粘贴冗长的XPCOM组件。</dd><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Language_bindings/JavaXPCOM">JavaXPCOM</a></dt><dd class="landingPageList"></dd><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Language_bindings/PyXPCOM">PyXPCOM</a></dt><dd class="landingPageList"></dd><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Language_bindings/XPConnect">XPConnect</a></dt><dd class="landingPageList">[<a class="external" href="http://developer.mozilla.org/en/docs/XPConnect">] </a></dd></dl></div>
+ </div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/language_bindings/javaxpcom/index.html b/files/zh-cn/mozilla/tech/xpcom/language_bindings/javaxpcom/index.html
new file mode 100644
index 0000000000..6ce4c6a6ba
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/language_bindings/javaxpcom/index.html
@@ -0,0 +1,49 @@
+---
+title: JavaXPCOM
+slug: Mozilla/Tech/XPCOM/Language_bindings/JavaXPCOM
+tags:
+ - Java
+ - JavaXPCOM
+translation_of: Mozilla/Tech/XPCOM/Language_bindings/JavaXPCOM
+---
+<p>
+</p><p><b>JavaXPCOM</b>允许在Java和<a href="cn/XPCOM">XPCOM</a>间进行会话,这样一来,Java应用程序就可以访问XPCOM对象,并且XPCOM也可以访问任何实现了XPCOM接口的Java类。借助JavaXPCOM,开发者可以在Java应用程序中同XPCOM或嵌入的<a href="cn/Gecko">Gecko</a>对话。JavaXPCOM和<a href="cn/XPConnect">XPConnect</a>(JavaScript-XPCOM桥)十分相似,并且使用<a href="cn/XPIDL">XPIDL</a>实现其功能。
+</p><p>JavaXPCOM默认地作为<a href="cn/XULRunner">XULRunner</a>的一部分被构建。下载最近的编译成品或<a href="cn/XULRunner_1.8.0.4">XULRunner 1.8.0.4</a>进行尝试。
+</p>
+<table class="topicpage-table">
+<tbody><tr><td>
+<h4 id=".E9.A2.84.E8.A7.88" name=".E9.A2.84.E8.A7.88"> 预览 </h4>
+<ul><li> <a href="cn/JavaXPCOM/%e5%bc%80%e5%8f%91">JavaXPCOM:开发</a>
+</li><li> <a href="cn/JavaXPCOM/%e8%8c%83%e4%be%8b">JavaXPCOM:范例</a>
+</li></ul>
+<h4 id=".E6.96.87.E7.AB.A0.E7.B2.BE.E9.80.89" name=".E6.96.87.E7.AB.A0.E7.B2.BE.E9.80.89"> 文章精选 </h4>
+<ul><li> <a href="cn/JavaXPCOM/%e4%bd%bf%e7%94%a8JavaXPCOM%e5%9c%a8Java%e5%ba%94%e7%94%a8%e7%a8%8b%e5%ba%8f%e4%b8%ad%e5%b5%8c%e5%85%a5Mozilla">JavaXPCOM:使用JavaXPCOM在Java应用程序中嵌入Mozilla</a>
+</li></ul>
+<p><span class="alllinks"><a>View All...</a></span>
+</p>
+</td>
+<td>
+<h4 id=".E5.85.B6.E4.BB.96.E9.A1.B5.E9.9D.A2" name=".E5.85.B6.E4.BB.96.E9.A1.B5.E9.9D.A2"> 其他页面 </h4>
+<ul><li> <a>参考</a>
+</li><li> <a>文章</a>
+</li><li> <a>范例</a>
+</li><li> <a href="cn/JavaXPCOM/Community">社区</a>
+</li><li> <a href="cn/JavaXPCOM/Other_Resources">其他资源</a>
+</li></ul>
+<h4 id=".E7.9B.B8.E5.85.B3.E4.B8.BB.E9.A2.98" name=".E7.9B.B8.E5.85.B3.E4.B8.BB.E9.A2.98"> 相关主题 </h4>
+<dl><dd> <a href="cn/XPCOM">XPCOM</a>, <a href="cn/Embedding_Mozilla">嵌入式Mozilla</a>
+</dd></dl>
+<p><span class="comment">there's no javaxpcom category on webwatch &lt;rss&gt;<a class=" external" href="http://developer.mozilla.org/webwatch/?cat=23&amp;feed=rss2" rel="freelink">http://developer.mozilla.org/webwatc...t=23&amp;feed=rss2</a>|short|max=5|charset=UTF-8&lt;/rss&gt; &lt;span class="alllinks"&gt;<a class="external" href="http://developer.mozilla.org/webwatch/?cat=23" title="http://developer.mozilla.org/webwatch/?cat=23">View All...</a>&lt;/span&gt;</span>
+</p>
+</td>
+</tr>
+</tbody></table>
+<div class="originaldocinfo">
+<h2 id=".E5.8E.9F.E5.A7.8B.E6.96.87.E6.A1.A3.E4.BF.A1.E6.81.AF" name=".E5.8E.9F.E5.A7.8B.E6.96.87.E6.A1.A3.E4.BF.A1.E6.81.AF">原始文档信息</h2>
+<ul><li> 作者: <a class="link-mailto" href="mailto:jhpedemonte@gmail.com">Javier Pedemonte</a>
+</li><li> 最后更新: December 22, 2005
+</li><li> 版权信息: Copyright (C) <a class="link-mailto" href="mailto:jhpedemonte@gmail.com">Javier Pedemonte</a>
+</li></ul>
+</div>
+<p><br>
+</p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/language_bindings/javaxpcom/使用javaxpcom在java应用程序中嵌入mozilla/index.html b/files/zh-cn/mozilla/tech/xpcom/language_bindings/javaxpcom/使用javaxpcom在java应用程序中嵌入mozilla/index.html
new file mode 100644
index 0000000000..9a8e1805fa
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/language_bindings/javaxpcom/使用javaxpcom在java应用程序中嵌入mozilla/index.html
@@ -0,0 +1,65 @@
+---
+title: 使用JavaXPCOM在Java应用程序中嵌入Mozilla
+slug: Mozilla/Tech/XPCOM/Language_bindings/JavaXPCOM/使用JavaXPCOM在Java应用程序中嵌入Mozilla
+tags:
+ - 'JavaXPCOM:Articles'
+translation_of: Archive/Mozilla/Embedding_Mozilla_in_a_Java_Application_using_JavaXPCOM
+---
+<p>
+</p><p><br>
+<a href="cn/XULRunner">XULRunner</a>中包含了<a href="cn/JavaXPCOM">JavaXPCOM</a>组件,允许Java代码与XPCOM对象交互。在这片文章中您将会看到,在Java中使用XPCOM对象,要比在C++中容易得多。
+</p>
+<h4 id=".E5.BF.85.E8.A6.81.E6.9D.A1.E4.BB.B6" name=".E5.BF.85.E8.A6.81.E6.9D.A1.E4.BB.B6"> 必要条件 </h4>
+<ul><li> Java 1.4.2或者更新
+</li><li> XULRunner
+</li></ul>
+<div class="note">
+<p><b>2006-01-16</b>:XULRunner目前还没有官方发布版本,因此,为了能XULRunner加上JavaXPCOM一起使用,您应该马上下载1.8.0版分支的一个每夜构建。(<a class="external" href="http://ftp.mozilla.org/pub/mozilla.org/xulrunner/nightly/latest-mozilla1.8.0/xulrunner-1.8.0.1.en-US.linux-i686.tar.gz">Linux</a>,<a class="external" href="http://ftp.mozilla.org/pub/mozilla.org/xulrunner/nightly/latest-mozilla1.8.0/xulrunner-1.8.0.1.en-US.mac.dmg">Mac OS X</a>,<a class="external" href="http://ftp.mozilla.org/pub/mozilla.org/xulrunner/nightly/latest-mozilla1.8.0/xulrunner-1.8.0.1.en-US.win32.zip">Windows</a>)。下面提到的<i>MozillaInterfaces.jar</i>文件可以在<i>sdk</i>顶层文件夹中找到。
+</p>
+</div>
+<h4 id=".E5.B5.8C.E5.85.A5" name=".E5.B5.8C.E5.85.A5"> 嵌入 </h4>
+<p>为了在Java应用程序中嵌入Mozilla,您需要将库文件<i>MozillaInterfaces.jar</i>加入您的classpath中。这个库(它是SDK的一部分)提供了启动Mozilla和调用XPCOM方法所必需的接口。
+</p><p>要开始嵌入,我们使用<a href="https://dxr.mozilla.org/mozilla-central/source/extensions/java/xpcom/interfaces/Mozilla.java" rel="custom">Mozilla</a>单件类提供的方法。首先,Java应用程序必须找到一个合适的XULRunner安装:
+</p>
+<pre class="eval"> Mozilla mozilla = Mozilla.getInstance();
+ GREVersionRange[] range = new GREVersionRange[1];
+ range[0] = new GREVersionRange("1.8.*", false, "1.9", false);
+ <span class="highlightgreen">// work with trunk nightly version 1.9a1 ^^</span>
+
+ try {
+ File grePath = Mozilla.getGREPathWithProperties(range, null);
+ LocationProvider locProvider = new LocationProvider(grePath);
+ mozilla.initEmbedding(grePath, grePath, locProvider);
+ } catch (FileNotFoundException e) {
+ <span class="highlightgreen">// this exception is thrown if greGREPathWithProperties cannot find a GRE</span>
+ } catch (XPCOMException e) {
+ <span class="highlightgreen">// this exception is thrown if initEmbedding failed</span>
+ }
+</pre>
+<p><code>LocationProvider</code>是Java应用程序提供的一个类。它实现了<a href="https://dxr.mozilla.org/mozilla-central/source/extensions/java/xpcom/interfaces/IAppFileLocProvider.java" rel="custom">IAppFileLocProvider</a>接口,并且告诉XPCOM那里可以找到那些文件和目录。
+</p><p><code>initEmbedding</code>方法启动嵌入进程,允许Java应用程序与XPCOM和Mozilla一起工作。一旦Java应用程序使用完Mozilla,就需要中止嵌入进程:
+</p>
+<pre class="eval"> try {
+ mozilla.termEmbedding();
+ } catch (XPCOMException e) {
+ <span class="highlightgreen">// this exception is thrown if termEmbedding failed</span>
+ }
+</pre>
+<h4 id=".E4.B8.8EXPCOM.E5.AF.B9.E8.B1.A1.E4.B8.80.E8.B5.B7.E5.B7.A5.E4.BD.9C" name=".E4.B8.8EXPCOM.E5.AF.B9.E8.B1.A1.E4.B8.80.E8.B5.B7.E5.B7.A5.E4.BD.9C"> 与XPCOM对象一起工作 </h4>
+<p>现在,Mozilla已经嵌入了,Java应用程序可以和XPCOM对象工作了。<code>Mozilla</code>类提供了多种方法使工作更加容易,例如<code>getServiceManager</code>,<code>getComponentManager</code>,和<code>newLocalFile</code>。为了在XPCOM对象中增加查询和调用的方法,JavaXPCOM允许Java应用程序传递Java类对象给XPCOM方法。
+</p><p>例如:
+</p>
+<pre class="eval"> Mozilla mozilla = Mozilla.getInstance();
+ WindowCreator creator = new WindowCreator(); <span class="highlightgreen">// implements nsIWindowCreator</span>
+
+ nsIServiceManager serviceManager = mozilla.getServiceManager();
+
+ nsIWindowWatcher windowWatcher = (nsIWindowWatcher) serviceManager
+ .getServiceManagerByContractID(NS_WINDOWWATCHER_CONTRACTID,
+ nsIWindowWatcher.NS_IWINDOWWATCHER_IID);
+ windowWatcher.setWindowCreator(creator);
+</pre>
+<p>在这个例子中,我们有一个叫<code>WindowCreator</code>的类,它实现了<code>nsIWindowCreator</code>接口,我们想要在Mozilla中注册它。要做到这点,我们首先获取服务管理器(service manager),通过它,我们可以获取Mozilla窗口监视器的引用。
+</p>
+<div class="noinclude">
+</div>
diff --git a/files/zh-cn/mozilla/tech/xpcom/language_bindings/javaxpcom/开发/index.html b/files/zh-cn/mozilla/tech/xpcom/language_bindings/javaxpcom/开发/index.html
new file mode 100644
index 0000000000..d21deddbb6
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/language_bindings/javaxpcom/开发/index.html
@@ -0,0 +1,26 @@
+---
+title: 开发
+slug: Mozilla/Tech/XPCOM/Language_bindings/JavaXPCOM/开发
+tags:
+ - JavaXPCOM
+translation_of: Mozilla/Tech/XPCOM/Language_bindings/JavaXPCOM/Development
+---
+<p>
+</p>
+<h3 id=".E7.AE.80.E8.BF.B0" name=".E7.AE.80.E8.BF.B0"> 简述 </h3>
+<p>JavaXPCOM源于Mozilla的Java版firefox计划,后来演变为Mozilla的一项重要的扩展应用技术。目前JavaXPCOM是Mozilla最活跃的扩展应用技术之一。
+简单的说,JavaXPCOM就是通过Java运行环境启动GRE(Gecko Runtime Environment)环境,然后通过Java Interface与GRE typelib的映射关系,使得Java对象可以与XPCOM对象进行对象交互。当然,与XPCOM一样,JavaXPCOM也支持通过XPConnect映射同以xul/js为主体的Mozilla界面环境进行对象交互。
+</p>
+<h3 id=".E6.BA.90.E4.BB.A3.E7.A0.81" name=".E6.BA.90.E4.BB.A3.E7.A0.81"> 源代码 </h3>
+<p>最新的源代码可以在Mozilla主干上找到,在<code><a href="https://dxr.mozilla.org/mozilla-central/source/extensions/java/xpcom" rel="custom">extensions/java/xpcom</a></code>目录中。
+</p>
+<h3 id=".E6.9E.84.E5.BB.BA.E6.8C.87.E4.BB.A4" name=".E6.9E.84.E5.BB.BA.E6.8C.87.E4.BB.A4"> 构建指令 </h3>
+<p>构建指令可以在这里找到:<a href="cn/%e6%9e%84%e5%bb%baJavaXPCOM">构建JavaXPCOM</a>。
+</p>
+<h3 id="Bugs" name="Bugs"> Bugs </h3>
+<p>所有的JavaXPCOM的bugs都在<a class="external" href="http://bugzilla.mozilla.org/">Bugzilla</a>中被跟踪, 使用"Core"产品和"Java to XPCOM Bridge"组件。
+</p>
+<ul><li> <a class="link-https" href="https://bugzilla.mozilla.org/buglist.cgi?query_format=advanced&amp;product=Core&amp;component=Java+to+XPCOM+Bridge&amp;bug_status=UNCONFIRMED&amp;bug_status=NEW&amp;bug_status=ASSIGNED&amp;bug_status=REOPENED&amp;chfieldto=Now">List</a>共开的JavaXPCOM bugs
+</li><li> <a class="link-https" href="https://bugzilla.mozilla.org/enter_bug.cgi?product=Core&amp;component=Java+to+XPCOM+Bridge&amp;rep_platform=All&amp;op_sys=All">Open</a> 一个新的JavaXPCOM的bug
+</li><li> <a class="external" href="http://bonsai.mozilla.org/cvsquery.cgi?treeid=default&amp;module=all&amp;branch=HEAD&amp;branchtype=match&amp;dir=mozilla%2Fextensions%2Fjava%2Fxpcom&amp;file=&amp;filetype=match&amp;who=&amp;whotype=match&amp;sortby=Date&amp;hours=2&amp;date=month&amp;mindate=&amp;maxdate=&amp;cvsroot=%2Fcvsroot">Checkins</a> 最近一个月之内
+</li></ul>
diff --git a/files/zh-cn/mozilla/tech/xpcom/language_bindings/pyxpcom/index.html b/files/zh-cn/mozilla/tech/xpcom/language_bindings/pyxpcom/index.html
new file mode 100644
index 0000000000..397d95ff78
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/language_bindings/pyxpcom/index.html
@@ -0,0 +1,67 @@
+---
+title: PyXPCOM
+slug: Mozilla/Tech/XPCOM/Language_bindings/PyXPCOM
+translation_of: Mozilla/Tech/XPCOM/Language_bindings/PyXPCOM
+---
+<p> </p>
+<div>
+ <p><strong>PyXPCOM</strong>允许在<a href="http://www.python.org/" title="http://www.python.org/">Python</a>和<a href="/en/XPCOM" title="/en/XPCOM">XPCOM</a>之间进行通信,例如Python应用能够访问XPCOM对象,XPCOM能够访问任何实现了XPCOM接口的Python类。使用PyXPCOM一个开发者可以与XPCOM交互或者从一个Python应用中嵌入<a href="/en/Gecko" title="/en/Gecko">Gecko</a>。PyXPCOM就类似于<a href="/en/JavaXPCOM" title="/en/JavaXPCOM">JavaXPCOM</a>(Java-XPCOM桥)或者是<a href="/en/XPConnect" title="/en/XPConnect">XPConnect</a>(JavaScript-XPCOM桥)。</p>
+ <p>Python类和接口:Mozilla定义了许多外部接口并允许用于嵌入使用和组件开发。PyXPCOM提供了方法以像Python语言接口那样来访问这些接口。PyXPCOM同时也包含了几个用于提供从Python访问那些初始化及关闭XPCOM和Gecko功能的类,以及一些XPCOM的帮助函数。</p>
+</div>
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h4 id="Documentation" name="Documentation"><a href="/Special:Tags?tag=PyXPCOM&amp;language=en" title="Special:Tags?tag=PyXPCOM&amp;language=en">文档</a></h4>
+ <dl>
+ <dt>
+ <a href="/zh-CN/docs/Building_PyXPCOM" title="en/Building_PyXPCOM">构建 PyXPCOM</a></dt>
+ <dd>
+ <small>PyXPCOM</small>构建指导。</dd>
+ </dl>
+ <dl>
+ <dt>
+ <a href="/zh-CN/docs/Creating_a_Python_XPCOM_component" title="en/Creating_a_Python_XPCOM_component">创建 Python XPCOM 组件</a></dt>
+ <dd>
+ 如何使用Python创建简单的<a href="/en/XPCOM" title="/en/XPCOM">XPCOM</a>组件的例子。</dd>
+ </dl>
+ <dl>
+ <dt>
+ <a class="external" href="http://www-128.ibm.com/developerworks/webservices/library/co-pyxp1/">PyXPCOM 入门</a></dt>
+ <dd>
+ PyXPCOM是XPCOM与Python之间的一种桥接技术。本节带给你的是PyXPCOM入门级的向导。</dd>
+ </dl>
+ <p><span class="comment">NOTE: The links to Part II and III of this series are broken and I cannot find them on the IBM site. Please update this page if/when the links can be found.</span></p>
+ <p><span class="alllinks"><a href="/Special:Tags?tag=PyXPCOM&amp;language=en" title="Special:Tags?tag=PyXPCOM&amp;language=en">View All...</a></span></p>
+ <h4 id="History" name="History">历史</h4>
+ <p>PyXPCOM was initially developed by <a class="external" href="http://www.activestate.com/">ActiveState Tool Corporation</a>, and <a class="external" href="http://aspn.activestate.com/ASPN/Downloads/Komodo/index/PyXPCOM/">came out</a> of their <a class="external" href="http://www.activestate.com/Products/Komodo">Komodo project</a>. Current releases are now <a class="external" href="http://public.activestate.com/pyxpcom/">integrated</a> with the Mozilla build system.</p>
+ <p>Other Resources<br>
+ <a class="external" href="http://pyxpcomext.mozdev.org/" title="http://pyxpcomext.mozdev.org/">PythonExt</a> - extension that provides PyXPCOM<br>
+ <a class="external" href="http://pyxpcomext.mozdev.org/samples.html" title="http://pyxpcomext.mozdev.org/samples.html">Samples</a> - demo applications using PyXPCOM</p>
+ </td>
+ <td>
+ <h4 id="Community" name="Community">交流</h4>
+ <br>
+ <ul>
+ <li><a class="external" href="http://listserv.activestate.com/mailman/listinfo/pyxpcom">Python-XPCOM bindings mailing list (ActiveState)</a></li>
+ <li><a class="link-irc" href="irc://irc.mozilla.org:6667/pyxpcom">#pyxpcom on irc.mozilla.org</a></li>
+ </ul>
+ <h4 id="Source_Code" name="Source_Code">源代码</h4>
+ <ul>
+ <li>The PyXPCOM code is available here: <a class="external" href="http://hg.mozilla.org/pyxpcom/">http://hg.mozilla.org/pyxpcom/</a></li>
+ <li>To build PyXPCOM, see <a href="/en/Building_PyXPCOM" title="en/Building_PyXPCOM">Building PyXPCOM</a>.</li>
+ </ul>
+ <h4 id="Related_Topics" name="Related_Topics">相关主题</h4>
+ <dl>
+ <dd>
+ <a href="/en/XPCOM" title="en/XPCOM">XPCOM</a></dd>
+ <dd>
+ <a href="/en/PyDOM" title="en/PyDOM">PyDOM</a>: replace JavaScript with Python</dd>
+ <dd>
+ <a class="external" href="http://code.google.com/p/python-spidermonkey/">Python-SpiderMonkey</a></dd>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/language_bindings/xpconnect/index.html b/files/zh-cn/mozilla/tech/xpcom/language_bindings/xpconnect/index.html
new file mode 100644
index 0000000000..df0270b533
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/language_bindings/xpconnect/index.html
@@ -0,0 +1,67 @@
+---
+title: XPConnect
+slug: Mozilla/Tech/XPCOM/Language_bindings/XPConnect
+translation_of: Mozilla/Tech/XPCOM/Language_bindings/XPConnect
+---
+<p>XPConnect是<a href="/zh-CN/docs/Web/JavaScript">JavaScript</a>和<a href="/zh-CN/docs/Mozilla/Tech/XPCOM">XPCOM</a>之间的桥梁。利用XPConnect,你可以通过JavaScript代码使用XPCOM组件,同时让XPCOM组件与JavaScript对象交互。XPConnect是<a href="/zh-CN/Firefox">Firefox</a>的组成部分,同时也应用于<a href="/zh-CN/docs/Mozilla/Tech/XUL">XUL</a>应用。</p>
+
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h2 id="Documentation" name="Documentation">文档</h2>
+
+ <dl>
+ <dt><a href="/zh-CN/docs/XPConnect/Architecture_basics">结构基础</a></dt>
+ <dd>XPConnect, JavaScript, XPCOM, XUL...</dd>
+ <dt><a href="/zh-CN/docs/XPConnect/Using_components">使用组件</a></dt>
+ <dd>如何与XPCOM组件通信。</dd>
+ <dt><a class="external" href="https://www-archive.mozilla.org/scriptable/faq.html">XPConnect 和 XPIDL 的常见问题解答</a></dt>
+ <dd>关于使用XPConnect和XPIDL的常见问题解答。<strong>该页面尚未迁移至MDN。</strong></dd>
+ <dt><a href="/zh-CN/docs/Mozilla/XPConnect/XPConnect_wrappers">XPConnect Wrappers</a></dt>
+ <dd>XPConnect的wrappers的生成和使用</dd>
+ </dl>
+
+ <p><strong><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Language_bindings/XPConnect/XPConnect_security_membranes">XPConnect 脚本安全</a></strong></p>
+ </td>
+ <td>
+ <h2 id="Tools" name="Tools">工具</h2>
+
+ <ul>
+ <li><a href="/zh-CN/docs/XPConnect/xpcshell">xpcshell</a></li>
+ </ul>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<div class="blockIndicator communitybox" dir="ltr">
+<div class="column-container">
+<h2 id="加入XPCOM社区">加入XPCOM社区</h2>
+
+<div class="column-half">
+<div class="communitysubhead">选择你喜欢的方式来加入讨论:</div>
+
+<ul class="communitymailinglist">
+ <li><a href="https://lists.mozilla.org/listinfo/dev-tech-xpcom">Mailing list</a></li>
+ <li><a href="http://groups.google.com/group/mozilla.dev.tech.xpcom">Newsgroup</a></li>
+ <li><a href="http://groups.google.com/group/mozilla.dev.tech.xpcom/feeds">RSS feed</a></li>
+</ul>
+</div>
+
+<div class="column-half">
+<ul class="communitycontact">
+ <li><strong>IRC: </strong><a href="irc://irc.mozilla.org/developers">#developers</a> <span class="smaller">(<a href="https://wiki.mozilla.org/IRC">learn more</a>)</span></li>
+ <li><strong>Tools: </strong><a href="http://ted.mielczarek.org/code/mozilla/jscomponentwiz/">JavaScript Component Wizard</a>, <a href="http://www.mytools360.com-a.googlepages.com/home#XPComPro">Visual C++ Component Wizard</a>, <a href="http://www.yutools.com/wp/tools/yuxpcomwizard/?lang=en">Visual C++ Component Wizard for Visual Studio 2010</a></li>
+</ul>
+</div>
+</div>
+</div>
+
+<section id="Quick_Links">
+<ol>
+ <li><a href="/en-US/docs/Mozilla/XPCOM">XPCOM</a></li>
+ <li><a href="/en-US/docs/Mozilla/XPIDL" title="XPIDL is an Interface Description Language used to specify XPCOM interface classes.">XPIDL</a></li>
+ <li><a href="/en-US/docs/Mozilla/Projects/SpiderMonkey" title="Standalone source code releases can be found on the Releases page.">SpiderMonkey</a></li>
+</ol>
+</section>
diff --git a/files/zh-cn/mozilla/tech/xpcom/observer_notifications/index.html b/files/zh-cn/mozilla/tech/xpcom/observer_notifications/index.html
new file mode 100644
index 0000000000..86fdd81a37
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/observer_notifications/index.html
@@ -0,0 +1,880 @@
+---
+title: Observer Notifications
+slug: Mozilla/Tech/XPCOM/Observer_Notifications
+translation_of: Mozilla/Tech/XPCOM/Observer_Notifications
+---
+<h2 id="Observer_topics" name="Observer_topics">Observer topics</h2>
+
+<p>The following are topics that you can observe during the course of an application. Unless otherwise noted you register for the topics using the <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIObserverService" title="">nsIObserverService</a></code>.</p>
+
+<h3 id="Application_startup" name="Application_startup">Application startup</h3>
+
+<p>These are the topics that you can observe on startup, in order of appearance.</p>
+
+<p>If your component requires access to the user profile, or any services which require access to the profile (preferences, bookmarks, and so on) then a common pattern is to register with the <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsICategoryManager" title="">nsICategoryManager</a></code> for the app-startup topic which can be done in the component's registration code, and then in that notification register with the observer service for the profile-after-change notification. See <a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Guide/Receiving_startup_notifications" title="zh-CN/XPCOM/Receiving startup notifications">Receiving startup notifications</a> for more information about how this works.</p>
+
+<p>Starting in Firefox 3.5 components can simply register for the profile-after-change notification in <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsICategoryManager" title="">nsICategoryManager</a></code>.</p>
+
+<table class="standard-table" style="width: 846px;">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>*</td>
+ <td>
+ <p>Everything.  [<a class="external" href="http://mxr.mozilla.org/mozilla-central/source/xpcom/ds/nsObserverService.cpp#152" title="http://mxr.mozilla.org/mozilla-central/source/xpcom/ds/nsObserverService.cpp#184">nsObserverService.cpp</a>]</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<table class="standard-table" style="height: 880px; width: 846px;">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>xpcom-startup</td>
+ <td>
+ <p></p><div class="blockIndicator note"><strong>Note:</strong> An extension can no longer be registered to receive this notification in Firefox 4 and later. See <a href="zh-CN/XPCOM/XPCOM_changes_in_Gecko_2.0#Category_registration">XPCOM changes in Gecko 2.0</a> for details.</div><p></p>
+
+ <p>Called when xpcom is initialized. Many things are not available for use at this point. To receive this notification you have to register with <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsICategoryManager" title="">nsICategoryManager</a></code>. The registered component is always retrieved as a singleton (That is getService() will be used to instantiate it).</p>
+ </td>
+ </tr>
+ <tr>
+ <td>app-startup</td>
+ <td>
+ <p></p><div class="blockIndicator note"><strong>Note:</strong> An extension can no longer be registered to receive this notification in Firefox 4 and later. See <a href="zh-CN/XPCOM/XPCOM_changes_in_Gecko_2.0#Category_registration">XPCOM changes in Gecko 2.0</a> for details.</div><p></p>
+
+ <p>General event for application startup. To receive this notification you have to register with <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsICategoryManager" title="">nsICategoryManager</a></code>. Prepend "service," to the contract ID in the category registration to be invoked via getService() instead of createInstance().</p>
+ </td>
+ </tr>
+ <tr>
+ <td>profile-do-change</td>
+ <td>This is fired after the profile has been selected. You will not be able to access user preferences, bookmarks, or anything that uses the profile folder until this event occurs. This occurs after any profile migration.</td>
+ </tr>
+ <tr>
+ <td>profile-after-change</td>
+ <td>
+ <p>This is fired after all the observers for profile-do-change have been notified.</p>
+
+ <p>You can register with <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsICategoryManager" title="">nsICategoryManager</a></code> to receive this notification. Prior to Firefox 3.5, this was available to observers observing the app-startup/xpcom-startup notification.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>final-ui-startup</td>
+ <td>
+ <p>Triggered just before the first window for the application is displayed.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>sessionstore-windows-restored </td>
+ <td>
+ <p>Sent by the session restore process to indicate that all initial browser windows have opened. Note that while the window are open and the chrome loaded the tabs in the windows may still be being restored after this notification.</p>
+
+ <p></p><div class="blockIndicator note"><strong>Note:</strong> This notification is specific to Firefox and SeaMonkey 2.0 applications</div><p></p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Application_shutdown" name="Application_shutdown">Application shutdown</h3>
+
+<p>These are the topics that you can observe on shutdown, in order of appearance.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>quit-application-requested</td>
+ <td>Something has requested that the application be shutdown. You can cancel the shutdown from here by setting <code>aSubject.data</code> to <code>true</code> (<code>aSubject</code> is the first parameter to your observer, the data value is an <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupportsPRBool" title="">nsISupportsPRBool</a></code>).</td>
+ </tr>
+ <tr>
+ <td>quit-application-granted</td>
+ <td>All observers have agreed to the shutdown.</td>
+ </tr>
+ <tr>
+ <td>quit-application</td>
+ <td>The application is about to quit. This can be in response to a normal shutdown, or a restart. <div class="blockIndicator note"><strong>Note:</strong> The data value for this notification is either 'shutdown' or 'restart'.</div></td>
+ </tr>
+ <tr>
+ <td>profile-change-net-teardown</td>
+ <td>The network connection is going offline at this point. <div class="blockIndicator note"><strong>Note:</strong> The data value for this notification is either 'shutdown-persist' or 'shutdown-cleanse'.</div></td>
+ </tr>
+ <tr>
+ <td>profile-change-teardown</td>
+ <td>Part of the shutdown, profile data is still available at this point. <div class="blockIndicator note"><strong>Note:</strong> The data value for this notification is either 'shutdown-persist' or 'shutdown-cleanse'.</div></td>
+ </tr>
+ <tr>
+ <td>profile-before-change</td>
+ <td>Called just before the profile is lost. <div class="blockIndicator note"><strong>Note:</strong> The data value for this notification is either 'shutdown-persist' or 'shutdown-cleanse'.</div></td>
+ </tr>
+ <tr>
+ <td>xpcom-will-shutdown </td>
+ <td>Called just before xpcom-shutdown. Observer must not spin event loop.</td>
+ </tr>
+ <tr>
+ <td>xpcom-shutdown</td>
+ <td>This is the end. Many things will not be available here.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Browser" name="Browser">Browser</h3>
+
+<p>These topics indicate interesting things that happen that the browser alerts you to.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>browser:purge-session-history</td>
+ <td>Sent when the sanitizer runs to purge all history and other information.</td>
+ </tr>
+ <tr>
+ <td>browser:purge-domain-data</td>
+ <td>Sent after domain-specific history and other information have been purged. The data value is a string form of the domain. </td>
+ </tr>
+ <tr>
+ <td>browser-lastwindow-close-requested</td>
+ <td>Sent when the browser wishes to close the last open browser window. When this is sent, it is possible that other windows may still be open, such as the download manager or preferences. The data value is an <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupportsPRBool" title="">nsISupportsPRBool</a></code>. Recipients may set this to <code>true</code> to abort the close. </td>
+ </tr>
+ <tr>
+ <td>browser-lastwindow-close-granted</td>
+ <td>Sent when all interested parties have responded to the browser-lastwindow-close-requested notification and none of them requested that the close be aborted. After this is sent and handled, the browser window will close. </td>
+ </tr>
+ <tr>
+ <td>browser-delayed-startup-finished</td>
+ <td>Sent when the browser window and all its components have been loaded and initialized.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Documents" name="Documents">Documents</h3>
+
+<p>These topics indicate notifications you can monitor related to DOM documents.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Subject</th>
+ <th>Data</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>chrome-document-global-created </td>
+ <td><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindow" title="">nsIDOMWindow</a></code></td>
+ <td>null</td>
+ <td>Sent immediately after a chrome document window has been set up, but before any script code has been executed. This lets extensions inject API into chrome windows as needed (see <a href="/zh-CN/XPCOM_Interface_Reference/nsIDOMGlobalPropertyInitializer" title="zh-CN/XPCOM_Interface_Reference/nsIDOMGlobalPropertyInitializer">nsIDOMGlobalPropertyInitializer</a> for an alternative method of doing this, which uses significantly less memory).<br>
+ <code>data</code> is intentionally left blank.</td>
+ </tr>
+ <tr>
+ <td>content-document-global-created </td>
+ <td><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindow" title="">nsIDOMWindow</a></code></td>
+ <td>origin</td>
+ <td>Sent immediately after a web content document window has been set up, but before any script code has been executed. This lets extensions inject API into content windows as needed (see <a href="/zh-CN/XPCOM_Interface_Reference/nsIDOMGlobalPropertyInitializer" title="zh-CN/XPCOM_Interface_Reference/nsIDOMGlobalPropertyInitializer">nsIDOMGlobalPropertyInitializer</a> for an alternative method of doing this).<br>
+ <code>data</code> is a string form of the origin (for use in security checks), eg "http://developer.mozilla.org".</td>
+ </tr>
+ <tr>
+ <td>document-element-inserted </td>
+ <td><a href="/zh-CN/docs/Web/API/Document" title="Document接口表示任何在浏览器中已经加载好的网页,并作为一个入口去操作网页内容(也就是DOM tree)。DOM tree包括像 &lt;body> 、&lt;table>这样的还有其他的元素。它提供了全局操作document的功能,像获取网页的URL和在document里创建一个新的元素。"><code>Document</code></a></td>
+ <td>null</td>
+ <td>Sent immediately after the root element of a document has been created, but before executing any script on it.</td>
+ </tr>
+ <tr>
+ <td>user-interaction-active </td>
+ <td><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindow" title="">nsIDOMWindow</a></code></td>
+ <td>null</td>
+ <td>
+ <p>Sent once every 5000ms while this chrome document sees some kind of user activity (for example, keyboard or mouse events), <em>and</em> at the exact moment of the state transition from idle to active.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>user-interaction-inactive </td>
+ <td><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindow" title="">nsIDOMWindow</a></code></td>
+ <td>null</td>
+ <td>
+ <p>Sent when the chrome document has seen no user activity for a while. The notification is not repeated during a continuous inactivity period.</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Windows" name="Windows">Windows</h3>
+
+<p>These topics indicate points of interest during the lifetime of a window.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Data</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>dom-window-destroyed </td>
+ <td> </td>
+ <td>Called just before a DOM window is destroyed.</td>
+ </tr>
+ <tr>
+ <td>inner-window-destroyed </td>
+ <td> <code>null</code></td>
+ <td>Called when an inner window is removed from the backward/forward cache. See <a href="/zh-CN/Working_with_BFCache" title="zh-CN/Working with BFCache">Working With BFCache</a> for information about the bfcache, and <a href="/zh-CN/Inner_and_outer_windows" title="zh-CN/Inner and outer windows">Inner and outer windows</a> for details about how the window hierarchy works. Extensions that cache information about windows may wish to observe this so they can release information when the window is destroyed.  The <a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=534149" title="https://bugzilla.mozilla.org/show_bug.cgi?id=534149">window id</a> can be obtained from subject.QueryInterface(Components.interfaces.nsISupportsPRUint64).data</td>
+ </tr>
+ <tr>
+ <td>outer-window-destroyed </td>
+ <td><code>null</code></td>
+ <td>Called when an outer window is disconnected from its docshell.  See <a href="/zh-CN/Inner_and_outer_windows" title="zh-CN/Inner and outer windows">Inner and outer windows</a> for details about how the window hierarchy works. Extensions that cache information about windows may wish to observe this so they can release information when the window is destroyed.  The<a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=534149" title="https://bugzilla.mozilla.org/show_bug.cgi?id=534149"> window id</a> can be obtained from subject.QueryInterface(Components.interfaces.nsISupportsPRUint64).data</td>
+ </tr>
+ <tr>
+ <td>toplevel-window-ready</td>
+ <td> </td>
+ <td>Called just after a new top level window has been opened and is ready, but has not yet loaded a document.</td>
+ </tr>
+ <tr>
+ <td>xul-window-destroyed</td>
+ <td> </td>
+ <td>Called just before a XUL window is destroyed.</td>
+ </tr>
+ <tr>
+ <td>xul-window-registered</td>
+ <td> </td>
+ <td>Called just after a top level XUL window is registered with the window mediator service.</td>
+ </tr>
+ <tr>
+ <td>xul-window-visible</td>
+ <td> </td>
+ <td>Called just after a XUL window is made visible.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Spelling checker" name="Spelling checker">Spelling checker </h3>
+
+<p>These topics indicate activities that have occurred related to the spelling checker.</p>
+
+<table class="standard-table" style="width: auto;">
+ <tbody>
+ <tr>
+ <td class="header">Topic</td>
+ <td class="header">Data</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td>spellcheck-dictionary-update</td>
+ <td> </td>
+ <td>Sent by a spell checker implemented by the <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/mozISpellingChecker" title="">mozISpellingChecker</a></code> interface when something has happened that causes a change that may interest the editor; these are received primarily by <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIEditor" title="">nsIEditor</a></code>.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="IO_Notifications" name="IO_Notifications">IO Notifications</h3>
+
+<p>These topics can be used to watch the IO service for useful information.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>offline-requested</td>
+ <td>Called to query whether the application can go offline. The attempt to go offline can be canceled.
+ <p></p><div class="blockIndicator note"><strong>Note:</strong> If your code chooses to cancel the attempt to go offline, it <strong>must</strong> notify the user.</div><p></p>
+ </td>
+ </tr>
+ <tr>
+ <td>network:offline-about-to-go-offline</td>
+ <td>Called just before all network IO is taken offline.</td>
+ </tr>
+ <tr>
+ <td>network:offline-status-changed</td>
+ <td>Called when the offline state has changed. <div class="blockIndicator note"><strong>Note:</strong> The data value for this notification 'offline' or 'online' to indicate the new state.</div></td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="HTTP_requests" name="HTTP_requests">HTTP requests</h3>
+
+<p>These are the topics that you can observe during a HTTP request (see <a href="/zh-CN/Setting_HTTP_request_headers" title="zh-CN/Setting_HTTP_request_headers">Setting HTTP request headers</a> and <a href="/zh-CN/Creating_Sandboxed_HTTP_Connections#HTTP_notifications" title="zh-CN/Creating_Sandboxed_HTTP_Connections#HTTP_notifications"> Creating Sandboxed HTTP Connections</a>). Both are passed an <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIHttpChannel" title="">nsIHttpChannel</a></code> as the subject parameter.</p>
+
+<table class="standard-table" style="height: 221px; width: 1106px;">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>http-on-modify-request</td>
+ <td>Called as a http request is made. The channel is available to allow you to modify headers and such. See <a class="internal" href="/zh-CN/Code_snippets/Tabbed_browser#Getting_the_tab_that_fires_the_http-on-modify-request_notification" title="zh-CN/Code snippets/Tabbed browser#Getting the tab that fires the http-on-modify-request notification">this code snippet</a> to learn how to get the tab that issued the request.</td>
+ </tr>
+ <tr>
+ <td>http-on-opening-request </td>
+ <td>Similar to http-on-modify-request, but called earlier (synchronously during the channel's asyncOpen() call), and some channel atttributes (proxyInfo) may be missing.  Use only if your observer must be called before asyncOpen returns.</td>
+ </tr>
+ <tr>
+ <td>http-on-examine-response</td>
+ <td>Called after a response has been received from the web server. Headers are available on the channel. The response can be accessed and modified via <a href="XPCOM_Interface_Reference/NsITraceableChannel" rel="internal" title="nsITraceableChannel">nsITraceableChannel</a>.</td>
+ </tr>
+ <tr>
+ <td>http-on-examine-cached-response </td>
+ <td>Called instead of http-on-examine-response when a response will be read completely from the cache. Headers are available on the channel.</td>
+ </tr>
+ <tr>
+ <td>http-on-examine-merged-response</td>
+ <td>Called instead of http-on-examine-response when a response will be read partially from cache, and partially from the network (HTTP 206 or 304 response). Headers are available on the channel.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Cookies" name="Cookies">Cookies</h3>
+
+<p>These topics indicate whenever a cookie has been changed (added, changed, cleared, or deleted) or its setting rejected by the browser. See <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsICookieService" title="">nsICookieService</a></code> for details.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>cookie-changed</td>
+ <td>Called upon a cookie change (added, changed, cleared, or deleted)</td>
+ </tr>
+ <tr>
+ <td>cookie-rejected</td>
+ <td>Called when the setting of a cookie was rejected by the browser (per the user's preferences)</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Download_Manager" name="Download_Manager">Download Manager</h3>
+
+<p>These topics indicate that events related to the Download Manager have occurred.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>download-manager-ui-done</td>
+ <td>Called when the list of downloads in the Download Manager windows finishes updating.  This can happen multiple times, such as when the window first opens, when multiple items are removed, and when entering private browsing mode.</td>
+ </tr>
+ <tr>
+ <td>download-manager-remove-download </td>
+ <td>Called when a download of the list is removed or all the list is cleared. The subject will be the download id wrapped in <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupportsPRUint32" title="">nsISupportsPRUint32</a></code>, for one download removed, or null for multi download remove, for example when the download list is cleared.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Extension_Manager" name="Extension_Manager">Extension Manager</h3>
+
+<div class="note">
+<p><strong>Note:</strong> These notifications are no longer available starting with <span title="(Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)">Gecko 2.0</span>, instead use <code><a href="/zh-CN/Addons/Add-on_Manager/AddonManager#addAddonListener()" title="https://developer.mozilla.org/zh-CN/Addons/Add-on_Manager/AddonManager#addAddonListener()">AddonManager.addAddonListener()</a></code> to receive similar events.</p>
+</div>
+
+<p>This topic indicates when the extension manager performs some action. Note that any action will be taken the next time the application starts. See <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIExtensionManager" title="">nsIExtensionManager</a></code> for details.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Data</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>em-action-requested</td>
+ <td>item-installed</td>
+ <td>A new extension has been installed.</td>
+ </tr>
+ <tr>
+ <td>em-action-requested</td>
+ <td>item-upgraded</td>
+ <td>A different version of an existing extension has been installed.</td>
+ </tr>
+ <tr>
+ <td>em-action-requested</td>
+ <td>item-uninstalled</td>
+ <td>An addon has been marked to be uninstalled.</td>
+ </tr>
+ <tr>
+ <td>em-action-requested</td>
+ <td>item-enabled</td>
+ <td>An addon has been enabled.</td>
+ </tr>
+ <tr>
+ <td>em-action-requested</td>
+ <td>item-disabled</td>
+ <td>An addon has been disabled.</td>
+ </tr>
+ <tr>
+ <td>em-action-requested</td>
+ <td>item-cancel-action</td>
+ <td>A previous action has been cancelled.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Idle_Service" name="Idle_Service">Idle Service</h3>
+
+<p>This topic indicates when actions related to the Idle Service, provided by the <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIIdleService" title="">nsIIdleService</a></code> interface. Unlike the user-interaction-active and user-interaction-inactive topics listed above, the Idle Service monitors user activity in general, whether related to the Mozilla application or not (acting somewhat like the user activity/inactivity events a screen saver would be interested in).</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Data</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>idle</td>
+ <td>The length of time the user has been idle, in milliseconds.</td>
+ <td>Sent when the user becomes idle.</td>
+ </tr>
+ <tr>
+ <td>idle-daily</td>
+ <td>The length of time the user has been idle, in milliseconds.</td>
+ <td>Sent once a day while the user is idle. </td>
+ </tr>
+ <tr>
+ <td>back</td>
+ <td>The length of time the user has been idle, in milliseconds.</td>
+ <td>Sent when the user returns from being idle.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Computer_sleep_and_wake" name="Computer_sleep_and_wake">Computer sleep and wake</h3>
+
+<p>This topic indicates when actions related to the computer going to sleep or waking up occur.  (Note: these notifications are not currently available on Linux.  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=758848" title="https://bugzilla.mozilla.org/show_bug.cgi?id=758848">See bug 758848</a>.)</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Data</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>sleep_notification</td>
+ <td>null</td>
+ <td>Sent when the computer is going to sleep.</td>
+ </tr>
+ <tr>
+ <td>wake_notification</td>
+ <td>null</td>
+ <td>Sent when the computer is waking up.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Login_Manage" name="Login_Manage">Login Manager</h3>
+
+<p>This topic indicates when actions related to the Login Manager occur.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Data</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>passwordmgr-found-form</td>
+ <td>noAutofillForms</td>
+ <td>A login is available for this form, but autofill of forms is disabled, so the form was not automatically filled out.  </td>
+ </tr>
+ <tr>
+ <td>passwordmgr-found-form</td>
+ <td>autocompleteOff</td>
+ <td>A login is available for this form, but autocomplete is disabled.</td>
+ </tr>
+ <tr>
+ <td>passwordmgr-storage-changed</td>
+ <td>addLogin</td>
+ <td>A login has been added to the Login Manager's database. The notification's subject is the login that was added to the database. </td>
+ </tr>
+ <tr>
+ <td>passwordmgr-storage-changed</td>
+ <td>removeLogin</td>
+ <td>A login was removed from the Login Manager's database. The notification's subject is the login that was removed from the database. </td>
+ </tr>
+ <tr>
+ <td>passwordmgr-storage-changed</td>
+ <td>modifyLogin</td>
+ <td>A login in the Login Manager's database was modified. The notification's subject is an array whose first entry is the old login and whose second entry is the new one. </td>
+ </tr>
+ <tr>
+ <td>passwordmgr-storage-changed</td>
+ <td>removeAllLogins</td>
+ <td>All logins have been removed from the Login Manager's database. </td>
+ </tr>
+ <tr>
+ <td>passwordmgr-storage-changed</td>
+ <td>hostSavingEnabled</td>
+ <td>Host saving has been enabled. </td>
+ </tr>
+ <tr>
+ <td>passwordmgr-storage-changed</td>
+ <td>hostSavingDisabled</td>
+ <td>Host saving has been disabled. </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Places" name="Places">Places</h3>
+
+<p>This topic indicates when actions related to Places (the history and bookmarks database) occur.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Data</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>places-autocomplete-feedback-updated</td>
+ <td> </td>
+ <td>Sent when Places updates the location bar's autocompletion display.</td>
+ </tr>
+ <tr>
+ <td>places-connection-closed</td>
+ <td> </td>
+ <td>Sent after Places has closed its database connection. Once this has been sent, no Places features will work. </td>
+ </tr>
+ <tr>
+ <td>places-connection-closing</td>
+ <td> </td>
+ <td>
+ <p>Sent as the last notification before the Places service closes its database connection. </p>
+
+ <div class="warning"><strong>Warning:</strong> This is for internal use only.</div>
+ </td>
+ </tr>
+ <tr>
+ <td>places-database-locked</td>
+ <td> </td>
+ <td>The Places database is currently locked by a third-party process and cannot be opened.</td>
+ </tr>
+ <tr>
+ <td>places-favicons-expired</td>
+ <td> </td>
+ <td>Sent when all favicons have been expired. </td>
+ </tr>
+ <tr>
+ <td>places-init-complete</td>
+ <td> </td>
+ <td>The Places database has been successfully initialized. You should wait until this notification occurs before querying the places database.</td>
+ </tr>
+ <tr>
+ <td>places-maintenance-finished</td>
+ <td> </td>
+ <td>Sent when maintenance of the Places database is complete; this is done periodically in the background to keep the Places database tidy.</td>
+ </tr>
+ <tr>
+ <td>places-shutdown</td>
+ <td> </td>
+ <td>Sent when Places shuts down. If you are referencing instances of <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/mozIStorageStatement" title="">mozIStorageStatement</a></code> referencing Places databases when this notification occurs, you should call their <code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/mozIStorageStatement#finalize()">mozIStorageStatement.finalize()</a></code> method </td>
+ </tr>
+ <tr>
+ <td>places-sync-finished</td>
+ <td> </td>
+ <td>Sent when the Places database has been successfully flushed to disk.</td>
+ </tr>
+ <tr>
+ <td>places-will-close-connection</td>
+ <td> </td>
+ <td>
+ <p>Sent when the Places service is about to close its database connection. Only necessary cleanup tasks should run at this point, and nothing should be added to the database. In addition, after this has been sent, no Places APIs should be called. </p>
+
+ <div class="warning"><strong>Warning:</strong> This is for internal use only.</div>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Session_Store" name="Session_Store">Session Store</h3>
+
+<p>These topics are used when actions related to Session Store occur.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Data</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>sessionstore-state-read</td>
+ <td> </td>
+ <td>Sent immediately after session store data is read and before it's used. </td>
+ </tr>
+ <tr>
+ <td>sessionstore-state-finalized</td>
+ <td> </td>
+ <td>Sent immediately after the session is restored.</td>
+ </tr>
+ <tr>
+ <td>sessionstore-state-write</td>
+ <td> </td>
+ <td>Sent immediately before the session store data is written to disk. </td>
+ </tr>
+ <tr>
+ <td>sessionstore-state-write-complete</td>
+ <td> </td>
+ <td>Sent immediately after the session store data is written to disk.</td>
+ </tr>
+ <tr>
+ <td>sessionstore-state-purge-complete</td>
+ <td> </td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Private_browsing" name="Private_browsing">Private browsing</h3>
+
+<p>These topics indicate when actions related to private browsing occur.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Data</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>private-browsing</td>
+ <td>enter</td>
+ <td>Sent when private browsing mode is activated. </td>
+ </tr>
+ <tr>
+ <td>private-browsing</td>
+ <td>exit</td>
+ <td>Sent when private browsing mode is deactivated. </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Bookmarks" name="Bookmarks">Bookmarks</h3>
+
+<p>These topics indicate when actions related to bookmarks occur.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Data</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>bookmarks-restore-begin</td>
+ <td>json</td>
+ <td>Sent just before bookmarks are restored from JSON. </td>
+ </tr>
+ <tr>
+ <td>bookmarks-restore-begin</td>
+ <td>html</td>
+ <td>Sent just before bookmarks are restored from HTML. If bookmarks will be restored into a specific folder, observers will be passed an <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupportsPRInt64" title="">nsISupportsPRInt64</a></code> through their subject parameters indicating the ID of the folder. The subject is null otherwise. </td>
+ </tr>
+ <tr>
+ <td>bookmarks-restore-begin</td>
+ <td>html-initial</td>
+ <td>Sent just before bookmarks are restored from HTML on initial import. If bookmarks are restored into a specific folder, observers will be passed an <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupportsPRInt64" title="">nsISupportsPRInt64</a></code> through their subject parameters indicating the ID of the folder. The subject is null otherwise. </td>
+ </tr>
+ <tr>
+ <td>bookmarks-restore-success</td>
+ <td>json</td>
+ <td>Sent just after bookmarks are restored from JSON. </td>
+ </tr>
+ <tr>
+ <td>bookmarks-restore-success</td>
+ <td>html</td>
+ <td>Sent just after bookmarks are restored from HTML. If bookmarks were restored into a specific folder, observers will be passed an <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupportsPRInt64" title="">nsISupportsPRInt64</a></code> through their subject parameters indicating the ID of the folder. The subject is null otherwise. </td>
+ </tr>
+ <tr>
+ <td>bookmarks-restore-success</td>
+ <td>html-initial</td>
+ <td>Sent just after bookmarks are restored from HTML on initial import. If bookmarks were restored into a specific folder, observers will be passed an <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupportsPRInt64" title="">nsISupportsPRInt64</a></code> through their subject parameters indicating the ID of the folder. The subject is null otherwise. </td>
+ </tr>
+ <tr>
+ <td>bookmarks-restore-failed</td>
+ <td>json</td>
+ <td>Sent when bookmarks could not be sucessfully restored from JSON. </td>
+ </tr>
+ <tr>
+ <td>bookmarks-restore-failed</td>
+ <td>html</td>
+ <td>Sent when bookmarks could not be successfully restored from HTML. If bookmarks were to have been restored into a specific folder, observers will be passed an <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupportsPRInt64" title="">nsISupportsPRInt64</a></code> through their subject parameters indicating the ID of the folder. The subject is null otherwise. </td>
+ </tr>
+ <tr>
+ <td>bookmarks-restore-failed</td>
+ <td>html-initial</td>
+ <td>Sent when bookmarks could not be successfully restored from HTML on intial import. If bookmarks were to have been restored into a specific folder, observers will be passed an <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupportsPRInt64" title="">nsISupportsPRInt64</a></code> through their subject parameters indicating the ID of the folder. The subject is null otherwise. </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Themes" name="Themes">Themes</h3>
+
+<p>These topics indicate when actions related to themes occur.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Data</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>lightweight-theme-preview-requested </td>
+ <td>json</td>
+ <td>Sent when the user requests to preview a lightweight theme, but before existing windows are styled with the new theme.</td>
+ </tr>
+ <tr>
+ <td>lightweight-theme-change-requested </td>
+ <td>json</td>
+ <td>Sent to indicate that the user has chosen a new theme in the add-ons manager, but before the change takes effect.</td>
+ </tr>
+ <tr>
+ <td>lightweight-theme-changed </td>
+ <td>-</td>
+ <td>Sent after the current theme is changed.</td>
+ </tr>
+ <tr>
+ <td>lightweight-theme-styling-update </td>
+ <td>json</td>
+ <td>Sent when the current theme being used is changed; this is sent even when the user is previewing a theme, not just when the theme is actually selected.</td>
+ </tr>
+ <tr>
+ <td>lightweight-theme-list-changed </td>
+ <td>-</td>
+ <td>The list of available lightweight themes has changed.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Developer_tools">Developer tools</h3>
+
+<p>These topics let you know about things that have happened related to Firefox's built-in developer tools.</p>
+
+<p> </p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Topic</th>
+ <th>Data</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>highlighter-ready </td>
+ <td>-</td>
+ <td>
+ <p>Sent when the highlighter component is initialized.</p>
+
+ <div class="note"><strong>Note:</strong> This is used by the Inspector to detect when it should begin its initialization process.</div>
+ </td>
+ </tr>
+ <tr>
+ <td>inspector-closed </td>
+ <td>-</td>
+ <td>Sent when the Inspector tool is closed.</td>
+ </tr>
+ <tr>
+ <td>inspector-editor-closed </td>
+ <td>-</td>
+ <td>Sent after the attribute-value editor has been closed.</td>
+ </tr>
+ <tr>
+ <td>inspector-editor-opened </td>
+ <td>-</td>
+ <td>Sent after the attribute-value editor has been opened and initialized.</td>
+ </tr>
+ <tr>
+ <td>inspector-editor-saved </td>
+ <td>-</td>
+ <td>Sent when changes have been saved in the attribute-value editor.</td>
+ </tr>
+ <tr>
+ <td>inspector-highlighting </td>
+ <td>-</td>
+ <td>Sent every time a different node in the page gets highlighted.</td>
+ </tr>
+ <tr>
+ <td>inspector-opened </td>
+ <td>-</td>
+ <td>Sent after the Inspector tool has finished its initialization.</td>
+ </tr>
+ <tr>
+ <td>inspector-ruleview-ready </td>
+ <td>-</td>
+ <td>Sent when the inspector's CSS Rule View is opened and initialized.</td>
+ </tr>
+ <tr>
+ <td>inspector-state-restored </td>
+ <td>-</td>
+ <td>Sent when the Inspector is re-opened after a tab switch.</td>
+ </tr>
+ <tr>
+ <td>inspector-treepanel-ready </td>
+ <td>-</td>
+ <td>Sent when the Inspector's Tree Panel is opened and initialized.</td>
+ </tr>
+ <tr>
+ <td>inspector-unhighlighting </td>
+ <td>-</td>
+ <td>Sent every time the highlighter stops highlighting a node.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Telemetry">Telemetry</h3>
+
+<table class="standard-table" style="width: auto;">
+ <tbody>
+ <tr>
+ <td class="header">Topic</td>
+ <td class="header">Data</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td>gather-telemetry </td>
+ <td>-</td>
+ <td>Sent by the telemetry service when it's time to start gathering telemetry data, since the telemetry ping is coming soon.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Plugins">Plugins</h3>
+
+<table class="standard-table" style="width: auto;">
+ <tbody>
+ <tr>
+ <td class="header">Topic</td>
+ <td class="header">Data</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td>plugin-crashed</td>
+ <td>-</td>
+ <td>Sent when a plugin has crashed.</td>
+ </tr>
+ </tbody>
+</table>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/glue_classes/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/glue_classes/index.html
new file mode 100644
index 0000000000..92f0a47369
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/glue_classes/index.html
@@ -0,0 +1,16 @@
+---
+title: XPCOM glue classes
+slug: Mozilla/Tech/XPCOM/Reference/Glue_classes
+tags:
+ - Classes
+ - Landing
+ - NeedsTranslation
+ - TopicStub
+ - XPCOM
+translation_of: Mozilla/Tech/XPCOM/Reference/Glue_classes
+---
+<p><span class="seoSummary">These "glue" classes are provided to make it easier to use XPCOM from C++ code.</span> When these classes are used by a component, you may need to link the component against the XPCOM glue library.</p>
+<p></p><div class="row topicpage-table">
+ <div class="section"><dl><dl><dt></dt></dl></dl></div>
+ <div class="section"><dl><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Glue_classes/nsCOMPtr">使用nsCOMPtr</a></dt><dd class="landingPageList">这篇文档是对nsCOMPtr的一个总述。如果您所遇到的问题,无法在该文档中找到答案,可能就没有其他文档可以回答它了。您需要求助于XPCOM新闻组或者有nsCOMPtr使用经验的人来求解,或者根据自己的试验获取答案。</dd></dl></div>
+ </div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/glue_classes/nscomptr/getting_started_guide/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/glue_classes/nscomptr/getting_started_guide/index.html
new file mode 100644
index 0000000000..32dedcf102
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/glue_classes/nscomptr/getting_started_guide/index.html
@@ -0,0 +1,478 @@
+---
+title: 入门指南
+slug: Mozilla/Tech/XPCOM/Reference/Glue_classes/nsCOMPtr/Getting_Started_Guide
+translation_of: Mozilla/Tech/XPCOM/Using_nsCOMPtr/Getting_Started_Guide
+---
+<p>下面开始探讨智能指针问题。</p>
+<h3 id="Introduction" name="Introduction">介绍</h3>
+<h4 id="What_is_nsCOMPtr.3F" name="What_is_nsCOMPtr.3F">什么是 <code>nsCOMPtr</code>?</h4>
+<p><code>nsCOMPtr</code> 是防止内存泄漏的一种工具。</p>
+<p><code>nsCOMPtr</code> 是一种智能指针。 它是一个模板类,在使用上类似C/C++中的普通指针。如:可使用*或者-&gt;得到其所指定的内容。<code>nsCOMPtr</code>之所以智能,是因为它不像一般指向XPCOM对象的指针<code>,nsCOMPtr还管理</code><code>AddRef</code>, <code>Release</code>, 和<code>QueryInterface</code>方法。 <code>nsCOMPtr</code>是在以下源文件中定义的:</p>
+<ul>
+ <li>{{ Source("xpcom/glue/nsCOMPtr.h", "xpcom/glue/nsCOMPtr.h") }}</li>
+ <li>{{ Source("xpcom/glue/nsCOMPtr.cpp", "xpcom/glue/nsCOMPtr.cpp") }}</li>
+</ul>
+<p>...though you probably don't want to look in there, just yet.</p>
+<p><code>利用nsCOMPtr</code>,比使用原始的XPCOM接口指针,能够把代码写的更简短,更清晰,更明白,更安全。</p>
+<h4 id=".5BXP.5DCOM_Basics:_Ownership_and_Reference_Counting" name=".5BXP.5DCOM_Basics:_Ownership_and_Reference_Counting">[XP]COM Basics: Ownership and Reference Counting</h4>
+<p>这段是对XPCOM的一些基本问题的一个复习。对<code>nsCOMPtr</code>s的理解,需要对XPCOM有一个基本的认识。您可通过以下方式对XPCOM进行学习。<a class="external" href="http://www.develop.com/dbox/">Don Box</a>的<a class="external" href="http://www.amazon.com/exec/obidos/ASIN/0201634465">Essential COM</a> 介绍了COM的基本规则和使用。 Don Box 在 <a class="external" href="http://www.amazon.com/exec/obidos/ASIN/0201379686">Effective COM</a>.一书中更详尽的说明了COM的细节,缺陷和易犯的错误。您还需要对C++有基本的了解。这里列举三本比较有用的书:Bjarne Stroustrup 的 <a class="external" href="http://www.amazon.com/exec/obidos/ASIN/0201889544">The C++ Programming Language</a>,Scott Meyers 的 <a class="external" href="http://www.amazon.com/exec/obidos/ASIN/0201924889">Effective C++</a> 和 <a class="external" href="http://www.amazon.com/exec/obidos/ASIN/020163371X">More Effective C++</a>。</p>
+<p>All XPCOM objects are allocated on the heap. Clients don't get to know much about the implementation of any such object. They reference it only through a pointer to an `interface', i.e., the static type of the pointer is a pointer to an abstract base class, the actual object pointed to is a class derived from that abstract base class. The XPCOM object is said to `implement that interface'. The client's reference to the object is typically called `an interface pointer'.</p>
+<p>An object may implement many interfaces. Each interface is (at least conceptually) separately `reference counted'. That is, the interface keeps a count of the number of clients holding references to it. When that count goes to zero, the interface may <code>delete</code> itself. Clients are expected to keep this reference count accurate by incrementing it when they acquire a reference to the interface, and decrementing it before they let go. To facilitate this, all interfaces inherit from an abstract base class that provides the member functions <code>AddRef</code>, and <code>Release</code>.</p>
+<p>A rule of XPCOM is that any function that creates or returns an interface pointer will have already <code>AddRef</code>ed it. The caller can then hold onto the reference indefinitely, calling <code>Release</code> when it no longer needs it. When the last pointer to an interface is <code>Release</code>d, the interface (and consequently, typically the underlying object) will <code>delete</code> itself. As long as there is an outstanding <code>AddRef</code> against the interface, it continues to exist. If you forget to call <code>Release</code>, the object will leak, i.e., the storage for that object will never be reclaimed. Leaks are bad <code><span class="nowiki">:-)</span></code>.</p>
+<p>A reference through which you will call <code>AddRef</code> and <code>Release</code> is called an <strong>owning reference</strong>. It holds a stake in the underlying object. That object cannot go away until the owning reference has relinquished its claim. Not all references need to be owning references. In fact, if two objects somehow end up owning each other (even transitively) it becomes difficult for either of those object to be reclaimed without adding some `out-of-band' mechanism for breaking the ownership cycle. The document <a href="/en/XPCOM_ownership_guidelines" title="en/XPCOM_ownership_guidelines">Some COM Ownership Guidelines</a> provides some hints on when ownership is needed. The following lists are good starting point, but by no means complete.</p>
+<p>You use an owning reference when</p>
+<ul>
+ <li>you created the object;</li>
+ <li>you got the object from a function that <em>might</em> have created it, e.g., any `getter' function, such as <code>QueryInterface</code>, or <code>CreateInstance</code>. All good getters <code>AddRef</code> the interface pointers they produce, thus providing you with an owning reference;</li>
+ <li>you will hold onto the reference longer than the scope of the function in which you acquired it, e.g., you got it as a parameter, but you're hanging onto it in a member variable (see, for example, {{ web.link("#Comparison_1", "Comparison 1") }}, below).</li>
+</ul>
+<p>You don't need an owning reference when</p>
+<ul>
+ <li>the object is passed in as a parameter, and you <em>don't</em> need to keep it any longer than the scope of this function;</li>
+ <li>the object's lifetime is known to contain yours in some well defined way, e.g., in the nodes of a tree, parent nodes keep owning references to their children, children need not keep owning references to their parents.</li>
+</ul>
+<p>It turns out that reference counting by hand is hard for programmers to get right. It may sound simple, but in practice it's very easy to forget to <code>Release</code> at the appropriate moment. Or to <code>AddRef</code> too many or too few times.</p>
+<h4 id="How_does_nsCOMPtr_help.3F" name="How_does_nsCOMPtr_help.3F">How does <code>nsCOMPtr</code> help?</h4>
+<p><code>nsCOMPtr</code> manages <code>AddRef</code>, <code>Release</code>, and other red-tape for you. An <code>nsCOMPtr</code> looks and acts as much like a raw XPCOM interface pointer as C allows, but it knows it owns the object it points to. This takes a little getting used to on your part, but ends up with less typing, clearer, safer code, and less leaks.</p>
+<p>For instance, here is a typical snippet of code (at its most compact) where you assign a XPCOM interface pointer into a member variable, i.e., the body of a `setter' function, side-by-side using raw XPCOM interface pointers and <code>nsCOMPtr</code>s. </p>
+<p>对照1.设置成员变量。</p>
+<p> </p>
+<table>
+ <caption>
+  </caption>
+ <tbody>
+ <tr>
+ <td>
+ <pre class="eval">
+<span class="comment">// raw [XP]COM interface pointers...</span>
+<span class="comment">// given: |nsIFoo* mFooPtr;|</span>
+
+<span class="comment"><span class="nowiki">/*
+ |AddRef| the new value if it's not
+ |NULL|; assign it in; and |Release|
+ the old value, if any (so we don't
+ leak it).
+
+ This order of assignment is special
+ and must be used to avoid particular
+ ownership bugs.
+ */</span></span>
+
+<strong>NS_IF_ADDREF(aFooPtr);
+nsIFoo* temp = mFooPtr;</strong>
+mFooPtr = aFooPtr;
+<strong>NS_IF_RELEASE(temp);</strong>
+</pre>
+ </td>
+ <td>
+ <pre class="eval">
+<span class="comment">// |nsCOMPtr|...</span>
+<span class="comment">// given: |nsCOMPtr&lt;nsIFoo&gt; mFooPtr;|</span>
+
+<span class="comment"><span class="nowiki">/*
+ This assignment automatically
+ |Release|s the old value in
+ |mFooPtr|, if any, and |AddRef|s the
+ new one, in the appropriate sequence
+ to avoid the ownership bug mentioned
+ earlier.
+ */</span></span>
+
+
+
+
+
+mFooPtr = aFooPtr;
+
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>Additionally, the class using raw XPCOM interface pointers will need a destructor to <code>Release</code> <code>mFooPtr</code><span class="nowiki">; and a constructor to ensure that </span><code>mFooPtr</code> is initially set to <code>NULL</code> (or some other reasonable value).</p>
+<p><code>nsCOMPtr</code> helps you write code that is leak-proof, exception safe, and significantly less verbose than you would with raw XPCOM interface pointers. With <code>nsCOMPtr</code>, you may never have to call <code>AddRef</code>, <code>Release</code>, or <code>QueryInterface</code> by hand.</p>
+<p>You still have to understand XPCOM. You still have to know which functions return interface pointers that have already been <code>AddRef</code>ed and which don't. You still have to ensure your program logic doesn't produce circularly referencing garbage. <code>nsCOMPtr</code> is not a panacea. It is, however, helpful, easy to use, well-tested, and polite. It doesn't require that a function author cooperate with you, nor does your use force others to use it.</p>
+<h3 id="Using_nsCOMPtr" name="Using_nsCOMPtr"><span style="font-family: monospace;">使用</span><code>nsCOMPtr</code></h3>
+<h4 id="The_Basics" name="The_Basics">The Basics</h4>
+<p>多数情况下,使用nsCOMPtr和一个一般的XPCOM接口指针是类似的。注意在声明中的细微区别。</p>
+<table>
+ <caption>
+ 对照 2. 相似点: <code>nsCOMPtr</code>类似于 XPCOM接口指针</caption>
+ <tbody>
+ <tr>
+ <td>
+ <pre class="eval">
+<span class="comment">// raw [XP]COM interface pointers...</span>
+
+nsIFoo<strong><span class="nowiki">*</span></strong> fooPtr <strong><span class="nowiki">= 0</span></strong><span class="nowiki">;
+ </span><span class="comment">// ...</span>
+fooPtr-&gt;SomeFunction(x, y, z);
+AnotherFunction(fooPtr);
+
+if ( fooPtr )
+ <span class="comment">// ...</span>
+
+if ( fooPtr == foo2Ptr )
+ <span class="comment">// ...</span>
+</pre>
+ </td>
+ <td>
+ <pre class="eval">
+<span class="comment">// |nsCOMPtr|...</span>
+
+<strong>nsCOMPtr&lt;</strong>nsIFoo<strong>&gt;</strong> fooPtr;
+<span class="comment">// ...</span>
+fooPtr-&gt;SomeFunction(x, y, z);
+AnotherFunction(fooPtr);
+
+if ( fooPtr )
+ <span class="comment">// ...</span>
+
+if ( fooPtr == foo2Ptr )
+ <span class="comment">// ...</span>
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
+<p>有两点主要区别。第一:不需要也不再允许调用<code>AddRef</code> 和 <code>Release</code>方法。 </p>
+<table>
+ <caption>
+ 对照 3. 不同点: <code>AddRef</code> <span style="font-family: monospace;">和 </span><code>Release</code> 对于 <code>nsCOMPtr</code>s 来说是非法的。</caption>
+ <tbody>
+ <tr>
+ <td>
+ <pre class="eval">
+<span class="comment">// raw [XP]COM interface pointers...</span>
+<span class="comment">// given: |nsIFoo* mFooPtr;|</span>
+
+ <span class="comment">/*
+ Note: this sequence is not the
+ correct order to do assign
+ raw pointers anyway (see
+ {{ Anch("Comparison 1") }}) but I need it
+ for this comparison.
+ */</span>
+
+NS_IF_RELEASE(mFooPtr);
+
+mFooPtr = aFooPtr;
+NS_IF_ADDREF(mFooPtr);
+
+</pre>
+ </td>
+ <td>
+ <pre class="eval">
+<span class="comment">// |nsCOMPtr|...</span>
+<span class="comment">// given: |nsCOMPtr&lt;nsIFoo&gt; mFooPtr;|</span>
+
+ <span class="comment">/*
+ You no longer need, nor will the
+ compiler let you, call |AddRef|,
+ or |Release|.
+ */</span>
+
+
+
+<span class="warning">NS_IF_RELEASE(mFooPtr);</span>
+ <span class="comment">// Error: |Release| is private</span>
+mFooPtr = aFooPtr;
+<span class="warning">NS_IF_ADDREF(mFooPtr);</span>
+ <span class="comment">// Error: |AddRef| is private</span>
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
+<p>第二:使用 <a href="/en/Using_nsCOMPtr/Reference_Manual#.60Out.27_Parameters:_getter_AddRefs" title="en/Using_nsCOMPtr/Reference_Manual#.60Out.27_Parameters:_getter_AddRefs"><code>getter_AddRefs</code></a> 标识nsCOMPtr,作为获取指针返回值的函数的参数,而不能只使用<code>nsCOMPtr</code>的地址作为参数。</p>
+<table>
+ <caption>
+ 对照 4. 不同点: <span style="font-family: monospace;">当 </span><code>nsCOMPtr</code> 作为输出参数时,使用 getter_AddRefs。</caption>
+ <tbody>
+ <tr>
+ <td>
+ <pre class="eval">
+<span class="comment">// raw [XP]COM interface pointers...</span>
+
+nsIFoo* foo;
+
+GetFoo(<strong>&amp;</strong>foo);
+</pre>
+ </td>
+ <td>
+ <pre class="eval">
+<span class="comment">// |nsCOMPtr|s...</span>
+
+nsCOMPtr&lt;nsIFoo&gt; foo;
+
+GetFoo(<strong>getter_AddRefs(</strong>foo<strong>)</strong>);
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
+<p>以上是对nsCOMPtrS的一些说明,基本涵盖了平日使用的90%。以下是在一些复杂情况下,对其的细节说明。</p>
+<p> </p>
+<h4 id="A_Few_Details" name="A_Few_Details">一些细节</h4>
+<p> </p>
+<p>以下是更多细节让您更了解 <code>nsCOMPtr</code>。</p>
+<p>通常,通过调用 <code>QueryInterface 获取接口指针</code><span style="font-family: monospace;">。</span> <code>QueryInterface</code> 是一个 getter 函数,由以上方法,可通过 <code>getter_AddRefs</code> 方法来获取。</p>
+<table>
+ <caption>
+ The hard way to <code>QueryInterface</code> into an <code>nsCOMPtr</code>.</caption>
+ <tbody>
+ <tr>
+ <td>
+ <pre class="eval">
+<span class="comment">// A way (though not the best way) to |QueryInterface| into an |nsCOMPtr|...</span>
+
+nsCOMPtr&lt;nsIFoo&gt; foo;
+
+nsresult rv = bar-&gt;QueryInterface(NS_GET_IID(nsIFoo), getter_AddRefs(foo));
+
+ <span class="comment">// Or, if you're a savvy [XP]COM programmer,</span>
+ <span class="comment">// you use the type-safe version...</span>
+nsresult rv = CallQueryInterface(bar, getter_AddRefs(foo));
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p><code>因为 QueryInterface</code> 使用频繁,<code>nsCOMPtr</code> 提供了一种特殊方式对其调用。这种方式是类型安全的,<code>QueryInterface的返回值能</code>直接构造nsCOMPtr。这种构造方式比通过赋值进行构造效率更高。这种方式是 <a href="/en/Using_nsCOMPtr/Reference_Manual#nsCOMPtr.3CT.3E_.3D_do_QueryInterface.28_nsISupports.2A_.29.2CnsCOMPtr.3CT.3E_.3D_do_QueryInterface.28_nsISupports.2A.2C_nsresult.2A_.29" title="en/Using_nsCOMPtr/Reference_Manual#nsCOMPtr.3CT.3E_.3D_do_QueryInterface.28_nsISupports.2A_.29.2CnsCOMPtr.3CT.3E_.3D_do_QueryInterface.28_nsISupports.2A.2C_nsresult.2A_.29"><code>do_QueryInterface</code></a> 。通过使用这种方式,以上例子可写为:</p>
+<table>
+ <caption>
+ How to <code>QueryInterface</code> into an <code>nsCOMPtr</code>.</caption>
+ <tbody>
+ <tr>
+ <td>
+ <pre class="eval">
+<span class="comment">// The best way to |QueryInterface| into an |nsCOMPtr|...</span>
+
+nsresult rv;
+nsCOMPtr&lt;nsIFoo&gt; foo( <strong>do_QueryInterface(</strong>bar, &amp;rv<strong>)</strong> );
+
+ <span class="comment">// Or, if you don't care about the |nsresult|</span>
+nsCOMPtr&lt;nsIFoo&gt; foo( <strong>do_QueryInterface(</strong>bar<strong>)</strong> );
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p><code>nsCOMPtr</code> happily calls <code>AddRef</code> and <code>Release</code> implicitly. This same favor is <em>not</em> extended to <code>QueryInterface</code>. <code>nsCOMPtr</code> does not <code>QueryInterface</code> on assignment without your explicit permission in the form of the <code>do_QueryInterface</code> directive. You need never worry about hidden queries. However, be aware that if you <em>should</em> have queried but didn't, e.g., when assigning in a raw pointer where C allows the assignment, but XPCOM wouldn't, <code>nsCOMPtr</code> will <a href="/en/Using_nsCOMPtr/Reference_Manual#Type_Safeguards" title="en/Using_nsCOMPtr/Reference_Manual#Type_Safeguards">assert at runtime</a>. Use <code>do_QueryInterface</code> whenever you assign in a pointer to a XPCOM interface of a different type, even if that type happens to derive from the base type of the <code>nsCOMPtr</code></p>
+<p> </p>
+<table>
+ <caption>
+ 对照6. <code>do_QueryInterface</code> 避免了XPCOM 中的类型错误。</caption>
+ <tbody>
+ <tr>
+ <td>
+ <pre class="eval">
+class nsIBar
+  : public nsIFoo ... { ... };
+
+nsIBar* p = ...;
+
+ <span class="comment">// C thinks every |nsIBar*| is an</span>
+ <span class="comment">// |nsIFoo*|, therefore, C allows</span>
+ <span class="comment">// this...</span>
+nsCOMPtr&lt;nsIFoo&gt; <span class="warning">foo = p;</span>
+ <span class="comment">// ...even though it is an [XP]COM</span>
+ <span class="comment">// type error</span>
+</pre>
+ </td>
+ <td>
+ <pre class="eval">
+class nsIBar
+  : public nsIFoo ... { ... };
+
+nsIBar* p = ...;
+
+
+
+ <span class="comment">// No type error here...</span>
+nsCOMPtr&lt;nsIFoo&gt; foo( <strong>do_QueryInterface(</strong>p<strong>)</strong> );
+
+
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>Remember, the C type system and the XPCOM type system are really two independent things. Because XPCOM interfaces are expressed as abstract C base classes, you may be tempted to let C handle the differences, or to use C casts to navigate between interface types. This is wrong. The only sanctioned way to get between XPCOM types is with <code>QueryInterface</code>. In the example above, there is no reason to assume that the <code>nsIFoo*</code> C pulls out of <code>p</code> would be the same one that <code>p-&gt;QueryInterface()</code> would return.</p>
+<p><a href="/en/Using_nsCOMPtr/Reference_Manual#nsCOMPtr.3CT.3E_.3D_dont_AddRef.28_T.2A_.29.2CnsCOMPtr.3CT.3E_.3D_getter_AddRefs.28_T.2A_.29" title="en/Using_nsCOMPtr/Reference_Manual#nsCOMPtr.3CT.3E_.3D_dont_AddRef.28_T.2A_.29.2CnsCOMPtr.3CT.3E_.3D_getter_AddRefs.28_T.2A_.29"><code>dont_AddRef</code></a> is a similar directive that helps you when you assign in a pointer that has already been <code>AddRef</code>ed, e.g., because you called a getter that returned the pointer as its function result.</p>
+<table>
+ <caption>
+ Using <code>dont_AddRef</code>.</caption>
+ <tbody>
+ <tr>
+ <td>
+ <pre class="eval">
+nsCOMPtr&lt;nsIFoo&gt; foo( <strong>dont_AddRef(</strong>CreateFoo()<strong>)</strong> );
+ <span class="comment">// |CreateFoo| |AddRef|s its result, as all good getters do</span>
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<h4 id="Something_nsCOMPtr_Doesn.27t_Do" name="Something_nsCOMPtr_Doesn.27t_Do">Something <code>nsCOMPtr</code> <em>Doesn't</em> Do</h4>
+<p>An <code>nsCOMPtr</code> does all that is necessary to behave as an owning reference. A given <code>nsCOMPtr</code> does not, however, cooperate in making <em>other</em> owning pointers. After learning how <code>nsCOMPtr</code> automatically <code>AddRef</code>s a pointer as it is being assigned <em>in</em>, the natural assumption is that it does the same thing when assigning <em>out</em>. Here is a snippet of code that demonstrates this misconception.</p>
+<table>
+ <tbody>
+ <tr>
+ <td>
+ <pre class="eval">
+<span class="comment">// Incorrect assumptions about |nsCOMPtr|...</span>
+
+nsresult
+nsCacheRecord::GetFileSpec( nsIFileSpec** aFileSpecResult )
+ <span class="comment">/*
+ ...fills in the callers |nsFileSpec*| (which the caller supplied
+ the address of) with a copy of my member variable |mFileSpec|,
+ an |nsCOMPtr|. I.e., this function is a `getter'.
+
+ Remember: good [XP]COM getters always |AddRef| their result.
+ */</span>
+ {
+ <span class="comment">// ...</span>
+ *aFileSpec = mFileSpec;
+ <span class="warning"><span class="comment">// the |nsCOMPtr| should take care of the refcount here, right?</span></span>
+ return NS_OK;
+ }
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>Plainly, the author believed (though perhaps with some question) that the <code>nsCOMPtr</code>, <code>mFileSpec</code>, would <code>AddRef</code> automatically as it was assigned into <code><span class="nowiki">*aFileSpec</span></code>. This is <em>not</em> the case. An <code>nsCOMPtr</code> automatically calls <code>AddRef</code> and <code>Release</code> (only) on its <em>own</em> behalf. In all other situations, it is designed to be a drop in replacement for a raw XPCOM pointer. Where ever an <code>nsCOMPtr</code> is used in a situation where a raw pointer is needed, the <code>nsCOMPtr</code> automatically provides one.</p>
+<table>
+ <tbody>
+ <tr>
+ <td>
+ <pre class="eval">
+<span class="comment">// |nsCOMPtr| produces a raw pointer when needed...</span>
+
+nsCOMPtr&lt;nsIFoo&gt; foo = ...;
+
+ <span class="comment">// 1. Assigning into a raw pointer</span>
+nsIFoo* raw_foo = foo;
+
+ <span class="comment">// 2. Assigning into another |nsCOMPtr|</span>
+nsCOMPtr&lt;nsIFoo&gt; foo2 = foo;
+
+ <span class="comment">// 3. As a parameter</span>
+SetFoo(foo);
+
+ <span class="comment">// 4. Testing the value in an |if| expression</span>
+ <span class="comment">// 5. Calling a member function</span>
+if ( foo )
+ foo-&gt;DoSomething();
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>In all of these cases, pretty much the exact same code is executed (case 2 is slightly different, but the intent is the same). In each case, you are essentially extracting the raw pointer value for your own purpose. If the <code>nsCOMPtr</code> <code>AddRef</code>ed the value each time you did that, cases 4 and 5 would obviously always generate leaks. <code>SetFoo</code>, from case 3, would have to be written two different ways when given an <code>nsCOMPtr</code>, it would know the value was already <code>AddRef</code>ed, and when given a raw pointer it would assume the value was not <code>AddRef</code>ed. Actually the contradictions run deeper than that. All these cases show that automatically <code>AddRef</code>ing on `output' makes <code>nsCOMPtr</code>s and raw-pointers act differently from the point of view of the clients. The goal is to make them act the same so that <code>nsCOMPtr</code>s can be a drop in replacement (modulo managing its own `ownership').</p>
+<p>Given what you now know, the rule is predictable. As described above, and unless you tell it otherwise, an <code>nsCOMPtr</code> <code>AddRef</code>s when you assign <em>in</em> to it. It does nothing when you assign <em>out</em> of it.</p>
+<h4 id="Where_should_I_use_nsCOMPtrs.3F" name="Where_should_I_use_nsCOMPtrs.3F">Where should I use <code>nsCOMPtr</code>s?</h4>
+<p>You should use an <code>nsCOMPtr</code> any place you use an interface pointer as an owning reference, i.e., where you call <code>AddRef</code> and <code>Release</code> on it. You should use <code>nsCOMPtr</code> as a member variable, where it will simplify setters, and eliminate constructors, destructors, and assignment operators. You should use <code>nsCOMPtr</code> on the stack, where it makes calling <code>QueryInterface</code> almost pleasant, and eliminates the complex logic that falls out of error handling.</p>
+<h4 id="Where_shouldn.27t_I_use_nsCOMPtrs.3F" name="Where_shouldn.27t_I_use_nsCOMPtrs.3F">Where shouldn't I use <code>nsCOMPtr</code>s?</h4>
+<p>Don't use <code>nsCOMPtr</code>s where you don't need an owning reference. See <a href="/en/XPCOM_ownership_guidelines" title="en/XPCOM_ownership_guidelines">Some COM Ownership Guidelines</a>. <code>nsCOMPtr</code> is designed to be used with XPCOM interfaces, so don't use it with non-interfaces with specific exceptions described <a href="/en/Using_nsCOMPtr/Getting_Started_Guide#nsCOMPtrs_for_non-interface_classes" title="en/Using_nsCOMPtr/Getting_Started_Guide#nsCOMPtrs_for_non-interface_classes">below</a>. Don't use <code>nsCOMPtr</code>s in XPCOM interfaces. Don't use them in plain old C code; <code>nsCOMPtr</code>s are, of course, a C only construct. <a href="/en/Using_nsCOMPtr/Reference_Manual#Casting" title="en/Using_nsCOMPtr/Reference_Manual#Casting">Never cast</a> an <code>nsCOMPtr</code>, it's almost guaranteed to leak.</p>
+<h4 id="nsCOMPtrs_for_non-interface_classes" name="nsCOMPtrs_for_non-interface_classes"><code>nsCOMPtr</code>s for non-interface classes</h4>
+<p>Appropriately formatted answer to come, in the meanwhile, the full details are available in <a class="link-news" href="news://news.mozilla.org/scc-3E1526.12182423042001@h-204-29-187-152.netscape.com">this news posting</a> (<a class="external" href="http://groups.google.com/group/netscape.public.mozilla.xpcom/browse_frm/thread/77258f1cd7d99773/268b949066f2ba4a?hl=de&amp;q=#268b949066f2ba4a" title="http://groups.google.com/group/netscape.public.mozilla.xpcom/browse_frm/thread/77258f1cd7d99773/268b949066f2ba4a?hl=de&amp;q=#268b949066f2ba4a">via Google Groups</a>).</p>
+<h4 id="nsCOMPtrs_in_function_signatures" name="nsCOMPtrs_in_function_signatures"><code>nsCOMPtr</code>s in function signatures</h4>
+<p>In general, you won't want to use <code>nsCOMPtr</code> in the signature of XPCOM (i.e., `scriptable') functions. <code>nsCOMPtr</code> is not currently directly supported by IDL. However, you may sometime be tempted to use an <code>nsCOMPtr</code> in a non-scriptable function.</p>
+<h5 id="nsCOMPtr.3CT.3E_f.28.29_don.27t_return_an_nsCOMPtr" name="nsCOMPtr.3CT.3E_f.28.29_don.27t_return_an_nsCOMPtr"><span class="warning"><code>nsCOMPtr&lt;T&gt; f()</code></span> 不返回 <code>nsCOMPtr</code></h5>
+<p>This practice is dangerous. Returning an <code>AddRef</code>ed pointer in almost any form as a function result leads to several potential errors, some of which are leaks, some of which are dangling pointers. Returning an <code>nsCOMPtr</code> may seem like a good idea (since it tells clients you are giving them ownership), however it can be the cause of an dangling pointer. Consider:</p>
+<table>
+ <tbody>
+ <tr>
+ <td>
+ <pre class="eval">
+<span class="comment">// Don't return |nsCOMPtr|s...</span>
+nsCOMPtr&lt;nsIFoo&gt; CreateFoo();
+<span class="comment">// ...</span>
+
+<span class="warning">nsIFoo* myFoo = CreateFoo();</span> <span class="comment">// Oops: |myFoo| now dangles!</span>
+ <span class="comment">// |CreateFoo| returns an |nsCOMPtr|, which</span>
+ <span class="comment">// automatically |Release|s right after this</span>
+ <span class="comment">// assignment. Now |myFoo| refers to a</span>
+ <span class="comment">// deleted object.</span>
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>You can tell callers you are giving them ownership in a way that doesn't pose this hazard by returning a <code>already_AddRefed&lt;T&gt;</code> (see bug <a class="external" href="http://bugzilla.mozilla.org/show_bug.cgi?id=59212"><span class="nowiki">#59212</span></a>). An <code>nsCOMPtr</code> knows not to <code>AddRef</code> a value that is <code>already_AddRefed</code>.</p>
+<table>
+ <tbody>
+ <tr>
+ <td>
+ <pre class="eval">
+<span class="comment">// Preferred form: if you must return a pointer, use |already_AddRefed|...</span>
+already_AddRefed&lt;nsIFoo&gt; CreateFoo();
+<span class="comment">// ...</span>
+
+nsIFoo* myFoo1 = CreateFoo(); <span class="comment">// doesn't dangle</span>
+nsCOMPtr&lt;nsIFoo&gt; myFoo2( CreateFoo() ); <span class="comment">// doesn't leak</span>
+nsCOMPtr&lt;nsIFoo&gt; myFoo3( dont_AddRef(CreateFoo()) ); <span class="comment">// redundant, but legal and correct</span>
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>Compare this to the most frequent leaks caused by returning a raw pointer you have already <code>AddRef</code>ed:</p>
+<table>
+ <tbody>
+ <tr>
+ <td>
+ <pre class="eval">
+<span class="comment">// Don't return raw pointers; that incites leaks...</span>
+nsIFoo* CreateFoo(); <span class="comment">// returns an |AddRef|ed pointer</span>
+<span class="comment">// ...</span>
+
+<span class="warning">nsCOMPtr&lt;nsIFoo&gt; myFoo = CreateFoo();</span> <span class="comment">// Oops: leak;</span>
+nsCOMPtr&lt;nsIFoo&gt; myFoo( <span class="notice">dont_AddRef(</span>CreateFoo()<span class="notice">)</span> );
+ <span class="comment">// Since |CreateFoo| already |AddRef|s its result, we must remind</span>
+ <span class="comment">// our |nsCOMPtr| not to. It's easy to forget. Prevent it in advance</span>
+ <span class="comment">// by not returning pointers as function results, or else by returning</span>
+ <span class="comment">// an |already_AddRefed&lt;T&gt;| as above.</span>
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<h5 id="void_f.28_nsCOMPtr.3CT.3E_.29_don.27t_pass_an_nsCOMPtr_by_value" name="void_f.28_nsCOMPtr.3CT.3E_.29_don.27t_pass_an_nsCOMPtr_by_value"><span class="warning"><code>void f( nsCOMPtr&lt;T&gt; )</code></span> don't pass an <code>nsCOMPtr</code> by value</h5>
+<p>This practice is wasteful, but not otherwise harmful. There is no need to <code>AddRef</code> parameters, as they are guaranteed to live as long as the function call. You only need to <code>AddRef</code> them as you store them in a structure that will live longer than the function call. Which means the appropriate member of that structure should be an <code>nsCOMPtr</code>, not the function parameter. Additionally, this signature may confuse callers into thinking they need an <code>nsCOMPtr</code> just to call the function.</p>
+<h5 id="void_f.28_const_nsCOMPtr.3CT.3E&amp;_.29_don.27t_pass_an_nsCOMPtr_by_const_reference" name="void_f.28_const_nsCOMPtr.3CT.3E&amp;_.29_don.27t_pass_an_nsCOMPtr_by_const_reference"><span class="warning"><code>void f( const nsCOMPtr&lt;T&gt;&amp; )</code></span> don't pass an <code>nsCOMPtr</code> by <code>const</code> reference</h5>
+<p>Exactly as the signature above, this practice is wasteful, but not otherwise harmful, and has the same impact as passing an <code>nsCOMPtr</code> by value if the caller only supplied a raw pointer.</p>
+<h5 id="void_f.28_nsCOMPtr.3CT.3E.2A_.29_avoid_passing_an_nsCOMPtr_by_address.2C_if_possible" name="void_f.28_nsCOMPtr.3CT.3E.2A_.29_avoid_passing_an_nsCOMPtr_by_address.2C_if_possible"><span class="warning"><code>void f( nsCOMPtr&lt;T&gt;* )</code></span> avoid passing an <code>nsCOMPtr</code> by address, if possible</h5>
+<p>This practice requires callers to have an <code>nsCOMPtr</code>, and requires them to do a little extra work, as <code>operator&amp;</code> for <code>nsCOMPtr</code>s is <code>private</code> (to help prevent <a href="/en/Using_nsCOMPtr/Reference_Manual#Casting" title="en/Using_nsCOMPtr/Reference_Manual#Casting">leaks caused by casting</a>; also see {{ Bug(59414) }}). This is an acceptable way to declare `in/out' parameters, but prefer passing <code>nsCOMPtr</code>s by reference, as below.</p>
+<table>
+ <tbody>
+ <tr>
+ <td>
+ <pre class="eval">
+<span class="comment">// Passing an |nsCOMPtr| by pointer requires extra work...</span>
+void f( nsCOMPtr&lt;nsIFoo&gt;* );
+<span class="comment">// ...</span>
+
+nsCOMPtr&lt;nsIFoo&gt; myFoo = ...;
+
+f( <span class="notice">address_of(</span>myFoo<span class="notice">)</span> );
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<h5 id="void_f.28_nsCOMPtr.3CT.3E&amp;_.29_do_pass_an_nsCOMPtr_by_reference_for_.60in.2Fout.27_parameters" name="void_f.28_nsCOMPtr.3CT.3E&amp;_.29_do_pass_an_nsCOMPtr_by_reference_for_.60in.2Fout.27_parameters"><code>void f( nsCOMPtr&lt;T&gt;&amp; )</code> do pass an <code>nsCOMPtr</code> by reference for `in/out' parameters</h5>
+<p>This is the prefered scheme for providing `in/out' parameters. If you were to use a raw pointer instead, your function couldn't know what ownership relationship the caller had to the input value, and hence, couldn't know whether to <code>Release</code> it or not before assigning in the new value. By declaring the parameter as an <code>nsCOMPtr&amp;</code>, the relationship is explicit.</p>
+<h3 id="Summary" name="Summary">Summary</h3>
+<p>An <code>nsCOMPtr</code> is an owning reference. Whatever it points to has been <code>AddRef</code>ed, counting the <code>nsCOMPtr</code> as one of its `owners'. An <code>nsCOMPtr</code> always calls <code>Release</code> before letting go, whether the <code>nsCOMPtr</code> is letting go so that it can point to a different object, or because the <code>nsCOMPtr</code> is going out of scope. Any time a new value is assigned into an <code>nsCOMPtr</code>, the <code>nsCOMPtr</code> automatically always <code>Release</code>s its old referent, if any, and (unless you tell it you already have) <code>AddRef</code>s the new.</p>
+<p>You use an <code>nsCOMPtr</code> exactly as you would a raw XPCOM interface pointer in almost all cases. You won't have to explictly call <code>AddRef</code> or <code>Release</code> through it, nor will the compiler allow it. The only place you can't use an <code>nsCOMPtr</code> without change is where a raw XPCOM interface pointer is an `out' parameter. In this case, you wrap the <code>nsCOMPtr</code> with <a href="/en/Using_nsCOMPtr/Reference_Manual#.60Out.27_Parameters:_getter_AddRefs" title="en/Using_nsCOMPtr/Reference_Manual#.60Out.27_Parameters:_getter_AddRefs"><code>getter_AddRefs</code></a> (see {{ web.link("#Comparison_4", "Comparison 4") }}).</p>
+<p>When assigning into an <code>nsCOMPtr</code>, you will usually just supply another pointer (either a raw XPCOM interface pointer or an <code>nsCOMPtr</code>), with no additional directives { web.link("#Comparison_1", "Comparison 1") }}). As stated above, with no directives, the <code>nsCOMPtr</code> will <code>Release</code> its old referent, if any, and <code>AddRef</code> the new. This is appropriate when the thing you're assigning in hasn't yet been <code>AddRef</code>ed to account for the new reference. This is typically the case when you are assigning in a pointer that you <em>didn't</em> call a function to get, e.g., one that was passed in as a parameter, or that you pulled out of a structure.</p>
+<p>You can tell <code>nsCOMPtr</code> it doesn't need to <code>AddRef</code> the new value on assignment by wrapping the new value in <a href="/en/Using_nsCOMPtr/Reference_Manual#nsCOMPtr.3CT.3E_.3D_dont_AddRef.28_T.2A_.29.2CnsCOMPtr.3CT.3E_.3D_getter_AddRefs.28_T.2A_.29" title="en/Using_nsCOMPtr/Reference_Manual#nsCOMPtr.3CT.3E_.3D_dont_AddRef.28_T.2A_.29.2CnsCOMPtr.3CT.3E_.3D_getter_AddRefs.28_T.2A_.29"><code>dont_AddRef</code></a>. Do this, for example, when you got the new value from a function which, like all good XPCOM getters, already called <code>AddRef</code> on your behalf.</p>
+<p>You may not assign in a pointer to a different interface type; you must first query it to the right type (see, e.g., {{ web.link("#Comparison_6", "Comparison 6") }} and the surrounding discussion). <code>nsCOMPtr</code> <em>never</em> calls <code>QueryInterface</code> implicitly, i.e., you must call it yourself, or explictly ask <code>nsCOMPtr</code> to call it with <a href="/en/Using_nsCOMPtr/Reference_Manual#nsCOMPtr.3CT.3E_.3D_do_QueryInterface.28_nsISupports.2A_.29.2CnsCOMPtr.3CT.3E_.3D_do_QueryInterface.28_nsISupports.2A.2C_nsresult.2A_.29" title="en/Using_nsCOMPtr/Reference_Manual#nsCOMPtr.3CT.3E_.3D_do_QueryInterface.28_nsISupports.2A_.29.2CnsCOMPtr.3CT.3E_.3D_do_QueryInterface.28_nsISupports.2A.2C_nsresult.2A_.29"><code>do_QueryInterface</code></a>. The <code>do_QueryInterface</code> directive allows you to do the query as part of the assignment. This better facilitates constructing an <code>nsCOMPtr</code> directly from the right value, rather than constructing it and assigning in the correct value later. Construction alone is more efficient than construction followed by assignment. Prefer construction over assignment whereever reasonable. Be careful not to apply <code>do_QueryInterface</code> to a function returning an <code>AddRef</code>ed pointer [see <a href="/en/Using_nsCOMPtr/Reference_Manual#nsCOMPtr.3CT.3E_.3D_.2F.2A_call_QueryInterface_but_don.27t_AddRef_.2A.2F" title="en/Using_nsCOMPtr/Reference_Manual#nsCOMPtr.3CT.3E_.3D_.2F.2A_call_QueryInterface_but_don.27t_AddRef_.2A.2F">this short section</a> for an explanation]</p>
+<p>For more details, continue on to the <a href="/en/Using_nsCOMPtr/Reference_Manual" title="en/Using_nsCOMPtr/Reference_Manual">Reference Manual</a>.</p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/glue_classes/nscomptr/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/glue_classes/nscomptr/index.html
new file mode 100644
index 0000000000..d9c427784a
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/glue_classes/nscomptr/index.html
@@ -0,0 +1,56 @@
+---
+title: 使用nsCOMPtr
+slug: Mozilla/Tech/XPCOM/Reference/Glue_classes/nsCOMPtr
+translation_of: Mozilla/Tech/XPCOM/Reference/Glue_classes/nsCOMPtr
+---
+<p>这篇文档是对nsCOMPtr的一个总述。如果您所遇到的问题,无法在该文档中找到答案,可能就没有其他文档可以回答它了。您需要求助于XPCOM新闻组或者有nsCOMPtr使用经验的人来求解,或者根据自己的试验获取答案。</p>
+
+<p>如果您尚未使用过nsCOMPtr,您正好可从这里开始。当您使用了一段时间后,或者遇到了不熟悉的领域,或者出现编译错误,您可返回该文档,在参考手册或者FAQ中求助。</p>
+
+<h2 id="Contents" name="Contents">内容</h2>
+
+<ol>
+ <li><a href="/en/Using_nsCOMPtr/Status,_Recent_Changes,_and_Plans" title="en/Using_nsCOMPtr/Status,_Recent_Changes,_and_Plans">状态,最新修改和计划</a>
+
+ <ol>
+ <li><a href="/en/Using_nsCOMPtr/Status,_Recent_Changes,_and_Plans#Recent_changes_to_nsCOMPtr" title="en/Using_nsCOMPtr/Status,_Recent_Changes,_and_Plans#Recent_changes_to_nsCOMPtr"><span style="font-family: monospace;">对</span><code>nsCOMPtr的最新修改</code></a></li>
+ </ol>
+ </li>
+ <li><a href="/en/Using_nsCOMPtr/Getting_Started_Guide" title="en/Using_nsCOMPtr/Getting_Started_Guide">入门指南</a>
+ <ol>
+ <li><a href="/en/Using_nsCOMPtr/Getting_Started_Guide#Introduction" title="en/Using_nsCOMPtr/Getting_Started_Guide#Introduction">介绍</a></li>
+ <li><a href="/en/Using_nsCOMPtr/Getting_Started_Guide#Using_nsCOMPtr" title="en/Using_nsCOMPtr/Getting_Started_Guide#Using_nsCOMPtr">使用 <code>nsCOMPtr</code></a></li>
+ <li><a href="/en/Using_nsCOMPtr/Getting_Started_Guide#Summary" title="en/Using_nsCOMPtr/Getting_Started_Guide#Summary">小结</a></li>
+ </ol>
+ </li>
+ <li><a href="/en/Using_nsCOMPtr/Reference_Manual" title="en/Using_nsCOMPtr/Reference_Manual">参考手册</a>
+ <ol>
+ <li><a href="/en/Using_nsCOMPtr/Reference_Manual#The_Basics" title="en/Using_nsCOMPtr/Reference_Manual#The_Basics">基本原理</a></li>
+ <li><a href="/en/Using_nsCOMPtr/Reference_Manual#Initialization_and_Assignment" title="en/Using_nsCOMPtr/Reference_Manual#Initialization_and_Assignment">初始化和赋值</a></li>
+ <li><a href="/en/Using_nsCOMPtr/Reference_Manual#Using_an_nsCOMPtr.3CT.3E_as_a_T.2A" title="en/Using_nsCOMPtr/Reference_Manual#Using_an_nsCOMPtr.3CT.3E_as_a_T.2A">Using an <code>nsCOMPtr&lt;T&gt;</code> as a <code>T*</code></a></li>
+ <li><a href="/en/Using_nsCOMPtr/Reference_Manual#Efficiency_and_Correctness" title="en/Using_nsCOMPtr/Reference_Manual#Efficiency_and_Correctness">Efficiency and Correctness</a></li>
+ <li><a href="/en/Using_nsCOMPtr/Reference_Manual#Compiler_Annoyances" title="en/Using_nsCOMPtr/Reference_Manual#Compiler_Annoyances">Compiler Annoyances</a></li>
+ </ol>
+ </li>
+ <li><a href="/en/Using_nsCOMPtr/Frequently_Asked_Questions" title="en/Using_nsCOMPtr/Frequently_Asked_Questions">FAQ</a>
+ <ol>
+ <li><a href="/en/Using_nsCOMPtr/Frequently_Asked_Questions#Buildtime_Errors" title="en/Using_nsCOMPtr/Frequently_Asked_Questions#Buildtime_Errors">编译时错误</a></li>
+ <li><a href="/en/Using_nsCOMPtr/Frequently_Asked_Questions#Runtime_Errors" title="en/Using_nsCOMPtr/Frequently_Asked_Questions#Runtime_Errors">运行时错误</a></li>
+ <li><a href="/en/Using_nsCOMPtr/Frequently_Asked_Questions#How_do_I..." title="en/Using_nsCOMPtr/Frequently_Asked_Questions#How_do_I...">How do I...</a></li>
+ <li><a href="/en/Using_nsCOMPtr/Frequently_Asked_Questions#General" title="en/Using_nsCOMPtr/Frequently_Asked_Questions#General">General</a></li>
+ <li><a href="/en/Using_nsCOMPtr/Frequently_Asked_Questions#Bibliography" title="en/Using_nsCOMPtr/Frequently_Asked_Questions#Bibliography">Bibliography</a></li>
+ </ol>
+ </li>
+</ol>
+
+<div class="originaldocinfo">
+<h2 id="Original_Document_Information" name="Original_Document_Information">Original Document Information</h2>
+
+<ul>
+ <li>Author(s): <a class="link-mailto" href="mailto:scc@mozilla.org">Scott Collins</a></li>
+ <li>Last Updated Date: December 11, 2001</li>
+ <li>Copyright Information: Copyright © 1999, 2000 by the Mozilla organization; use is subject to the <a class="external" href="http://www.mozilla.org/MPL/">MPL</a>. Portions of this content are © 1998–2007 by individual mozilla.org contributors; content available under a Creative Commons license | <a class="external" href="http://www.mozilla.org/foundation/licensing/website-content.html">Details</a>.</li>
+</ul>
+</div>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/index.html
new file mode 100644
index 0000000000..188a822ae6
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/index.html
@@ -0,0 +1,14 @@
+---
+title: XPCOM reference
+slug: Mozilla/Tech/XPCOM/Reference
+translation_of: Mozilla/Tech/XPCOM/Reference
+---
+<p>This reference describes the interfaces and functions provided by the <a href="/en-US/docs/Mozilla/Tech/XPCOM">XPCOM</a> library. In addition, it details the various helper classes and functions, as well as the components, provided by the <a href="/en-US/docs/Mozilla/Tech/XPCOM/Glue">XPCOM glue</a> library. The contents herein are oriented primarily toward extension developers and people embedding XPCOM in other projects.</p>
+<div class="note">
+ <p><strong>Note:</strong> If you're working on a module in the Mozilla codebase that's compiled with the <code>MOZILLA_INTERNAL_API</code> flag set, some of these APIs -- the string functions and classes in particular -- are not the ones you should be using. See the <a href="/en-US/docs/Mozilla/Tech/XPCOM/Guide/Internal_strings">XPCOM internal string guide</a> for documentation of the internal string API used within the Mozilla codebase.</p>
+</div>
+<p></p><div class="row topicpage-table">
+ <div class="section"><dl><dl><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Glue_classes">XPCOM glue classes</a></dt><dd class="landingPageList">These "glue" classes are provided to make it easier to use XPCOM from C++ code.</dd><dt class="landingPageList"><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface">XPCOM Interface Reference</a></dt><dd class="landingPageList"><span class="long_text short_text" id="result_box" lang="zh-CN"><span>这是一个</span><span>由</span><span>Mozilla平台</span><span>提供</span><span>的</span><span>XPCOM接口</span><span>的</span><span>参考</span></span>.</dd></dl></dl></div>
+ <div class="section"><dl><dt></dt></dl></div>
+ </div><p></p>
+<p>Many XPCOM pages return an <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Core_functions/nsresult">nsresult</a></code>. Prior to Gecko 19 (Firefox 19 / Thunderbird 19 / SeaMonkey 2.16), this was an integer that simply returned an error code. It is now a strongly typed <code>enum</code> when XPCOM is built using a C++11 compiler. This causes compile-time errors to occur when improper values are returned as nsresult values, thereby making it easier to catch many bugs.</p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/index.html
new file mode 100644
index 0000000000..da50238f6f
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/index.html
@@ -0,0 +1,11 @@
+---
+title: XPCOM Interface Reference
+slug: Mozilla/Tech/XPCOM/Reference/Interface
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface
+---
+<p><span class="long_text short_text" id="result_box" lang="zh-CN"><span>这是一个</span><span>由</span><span>Mozilla平台</span><span>提供</span><span>的</span><span>XPCOM接口</span><span>的</span><span>参考</span></span>.</p>
+<div style=""><ul><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIAccessibleProvider">nsIAccessibleProvider</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIClipboard">nsIClipboard</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIClipboardHelper">nsIClipboardHelper</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIConsoleService">nsIConsoleService</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMClientRect">nsIDOMClientRect</a></li><li><a href="/zh-CN/docs/nsIDOMParser">nsIDOMParser</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDirectoryServiceProvider">nsIDirectoryServiceProvider</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile">nsIFile</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFilePicker">nsIFilePicker</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIHttpChannel">nsIHttpChannel</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIIdleService">nsIIdleService</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile">nsILocalFile</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIProcess">nsIProcess</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPrompt">nsIPrompt</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPromptService">nsIPromptService</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIScriptableUnicodeConverter">nsIScriptableUnicodeConverter</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISyncMessageSender">nsISyncMessageSender</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITimer">nsITimer</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/NsITraceableChannel">nsITraceableChannel</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIURI">nsIURI</a></li><li><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIXMLHttpRequest">nsIXMLHttpRequest</a></li></ul></div>
+<h2 id="See_also" name="See_also">相关链接</h2>
+<ul> <li><a href="/zh-cn/XPCOM_Interface_Reference_group" title="https://developer.mozilla.org/zh-cn/XPCOM_Interface_Reference_group">Interfaces grouped by function</a></li>
+</ul>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiaccessibleprovider/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiaccessibleprovider/index.html
new file mode 100644
index 0000000000..488e504556
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiaccessibleprovider/index.html
@@ -0,0 +1,45 @@
+---
+title: nsIAccessibleProvider
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIAccessibleProvider
+tags:
+ - Accessibility
+ - Interfaces
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIAccessibleProvider
+---
+<p> </p>
+<p><br>
+ </p><div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/accessible/public/nsIAccessibleProvider.idl" rel="custom">accessible/public/nsIAccessibleProvider.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">
+
+<i>Please add a summary to this article.</i>
+</span>
+
+<div style="background: #eee; padding: 2px;">
+<span> </span>
+<span style="text-align: right; float: right;">最后修改于Gecko 1.9 (Firefox 3)</span></div>
+</div><p></p>
+<p>Inherits from: <a href="cn/NsISupports">nsISupports</a></p>
+<h2 id="Attributes" name="Attributes">Attributes</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Attribute</td>
+ <td class="header">Type</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>accessible</code></td>
+ <td><code><a href="cn/NsIAccessible">nsIAccessible</a></code></td>
+ <td>Returns an accessible.
+ <i>
+ Read only</i>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<h3 id="See_also" name="See_also">See also</h3>
+<ul>
+ <li><a href="cn/Accessibility">Accessibility</a></li>
+ <li><a href="cn/NsIAccessible">nsIAccessible</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiclipboard/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiclipboard/index.html
new file mode 100644
index 0000000000..a1778f2cbb
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiclipboard/index.html
@@ -0,0 +1,91 @@
+---
+title: nsIClipboard
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIClipboard
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIClipboard
+---
+<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/widget/public/nsIClipboard.idl" rel="custom">widget/public/nsIClipboard.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">
+
+This interface supports basic clipboard operations such as: setting, retrieving, emptying, matching and supporting clipboard data.
+</span>
+
+<div style="background: #eee; padding: 2px;">
+继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code>
+<span style="text-align: right; float: right;">最后修改于Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)</span></div>
+</div><p></p>
+<h2 id="Method_overview" name="Method_overview"><span class="long_text short_text" id="result_box" lang="zh-CN"><span>方法</span><span>概述</span></span></h2>
+<table class="standard-table"> <tbody> <tr> <td><code>void <a href="#emptyClipboard()">emptyClipboard</a>(in long aWhichClipboard);</code></td> </tr> <tr> <td><code>void <a href="#forceDataToClipboard()">forceDataToClipboard</a>(in long aWhichClipboard);</code> <span class="inlineIndicator obsolete obsoleteInline" title="(Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)">已废弃 Gecko 1.8</span></td> </tr> <tr> <td><code>void <a href="#getData()">getData</a>(in nsITransferable aTransferable, in long aWhichClipboard);</code></td> </tr> <tr> <td><code>boolean <a href="#hasDataMatchingFlavors()">hasDataMatchingFlavors</a>([array, size_is(aLength)] in string aFlavorList, in unsigned long aLength, in long aWhichClipboard);</code></td> </tr> <tr> <td><code>void <a href="#setData()">setData</a>(in nsITransferable aTransferable, in nsIClipboardOwner anOwner, in long aWhichClipboard);</code></td> </tr> <tr> <td><code>boolean <a href="#supportsSelectionClipboard()">supportsSelectionClipboard</a>();</code></td> </tr> </tbody>
+</table>
+<h2 id="Constants" name="Constants">常量</h2>
+<p>Most users will expect clipboard operations to use the global clipboard. In fact, the <code>kSelectionClipboard</code> is peculiar to the X Windows System, and not used much even under X.</p>
+<table class="standard-table"> <tbody> <tr> <td class="header">常量名称</td> <td class="header">值</td> <td class="header">描述</td> </tr> <tr> <td><code>kSelectionClipboard</code></td> <td><code>0</code></td> <td>Clipboard for selection.</td> </tr> <tr> <td><code>kGlobalClipboard</code></td> <td><code>1</code></td> <td>Clipboard for global use.</td> </tr> </tbody>
+</table>
+<h2 id="Methods" name="Methods">方法</h2>
+<h3 id="emptyClipboard()" name="emptyClipboard()">emptyClipboard()</h3>
+<p>This method empties the clipboard and notifies the clipboard owner. It empties the "logical" clipboard. It does not clear the native clipboard.</p>
+<pre class="eval">void emptyClipboard(
+ in long aWhichClipboard
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl> <dt><code>aWhichClipboard</code></dt> <dd>Specifies the clipboard to which this operation applies.</dd>
+</dl>
+<p></p><div class="headingWithIndicator">
+ <h3 id="forceDataToClipboard()">forceDataToClipboard()</h3>
+ <span class="indicatorInHeadline obsolete obsoleteMethod">已废弃 Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)</span>
+ </div><p></p>
+<p>Some platforms support deferred notification for putting data on the clipboard This method forces the data onto the clipboard in its various formats This may be used if the application going away.</p>
+<pre class="eval">void forceDataToClipboard(
+ in long aWhichClipboard
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl> <dt><code>aWhichClipboard</code></dt> <dd>Specifies the clipboard to which this operation applies.</dd>
+</dl>
+<h3 id="getData()" name="getData()">getData()</h3>
+<p>This method retrieves data from the clipboard into a transferable.</p>
+<pre class="eval">void getData(
+ in nsITransferable aTransferable,
+ in long aWhichClipboard
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl> <dt><code>aTransferable</code></dt> <dd>The transferable to receive data from the clipboard.</dd> <dt><code>aWhichClipboard</code></dt> <dd>Specifies the clipboard to which this operation applies.</dd>
+</dl>
+<h3 id="hasDataMatchingFlavors()" name="hasDataMatchingFlavors()">hasDataMatchingFlavors()</h3>
+<p>This method provides a way to give correct UI feedback about, for instance, whether a paste should be allowed. It does <strong>not</strong> actually retrieve the data and should be a very inexpensive call. All it does is check if there is data on the clipboard matching any of the flavors in the given list.</p>
+<pre class="eval">boolean hasDataMatchingFlavors(
+ [array, size_is(aLength)] in string aFlavorList,
+ in unsigned long aLength,
+ in long aWhichClipboard
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl> <dt><code>aFlavorList</code></dt> <dd>An array of ASCII strings.</dd> <dt><code>aLength</code></dt> <dd>The length of the <code>aFlavorList</code>.</dd> <dt><code>aWhichClipboard</code></dt> <dd>Specifies the clipboard to which this operation applies.</dd>
+</dl>
+<h6 id="Return_value" name="Return_value">返回值</h6>
+<p>Returns <code>true</code>, if data is present and it matches the specified flavor. Otherwise it returns <code>false</code>.</p>
+<h3 id="setData()" name="setData()">setData()</h3>
+<p>This method sets the data from a transferable on the native clipboard.</p>
+<pre class="eval">void setData(
+ in nsITransferable aTransferable,
+ in nsIClipboardOwner anOwner,
+ in long aWhichClipboard
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl> <dt><code>aTransferable</code></dt> <dd>The transferable containing the data to put on the clipboard.</dd> <dt><code>anOwner</code></dt> <dd>The owner of the transferable.</dd> <dt><code>aWhichClipboard</code></dt> <dd>Specifies the clipboard to which this operation applies.</dd>
+</dl>
+<h3 id="supportsSelectionClipboard()" name="supportsSelectionClipboard()">supportsSelectionClipboard()</h3>
+<p>This method allows clients to determine if the implementation supports the concept of a separate clipboard for selection.</p>
+<pre class="eval">boolean supportsSelectionClipboard();
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<p>None.</p>
+<h6 id="Return_value" name="Return_value">返回值</h6>
+<p>Returns <code>true</code> if <code>kSelectionClipboard</code> is available. Otherwise it returns <code>false</code>.</p>
+<h2 id="See_also" name="See_also">相关链接</h2>
+<ul> <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIClipboardOwner" title="">nsIClipboardOwner</a></code></li> <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITransferable" title="">nsITransferable</a></code></li> <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIArray" title="">nsIArray</a></code></li> <li><a class="internal" href="/zh-cn/Using_the_Clipboard" title="Using the Clipboard">Using the Clipboard</a></li>
+</ul>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiclipboardhelper/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiclipboardhelper/index.html
new file mode 100644
index 0000000000..b4c7881597
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiclipboardhelper/index.html
@@ -0,0 +1,65 @@
+---
+title: nsIClipboardHelper
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIClipboardHelper
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIClipboardHelper
+---
+<div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/widget/public/nsIClipboardHelper.idl" rel="custom">widget/public/nsIClipboardHelper.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">
+
+<code>nsIClipboardHelper接口是能够快速方便的使用</code> nsIClipboard 接口中常用方法的辅助接口.
+</span>
+
+<div style="background: #eee; padding: 2px;">
+继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code>
+<span style="text-align: right; float: right;">最后修改于Gecko 1.7 </span></div>
+</div>
+<h2 id="Method_overview" name="Method_overview">方法概述</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>void <a href="#copyString()">copyString</a>(in AString aString);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#copyStringToClipboard()">copyStringToClipboard</a>(in AString aString, in long aClipboardID);</code></td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Methods" name="Methods">方法</h2>
+<h3 id="copyString()" name="copyString()">copyString()</h3>
+<p>该方法将字符串复制到默认剪切板.</p>
+<pre class="eval">void copyString(
+ in AString aString
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ 将要复制到剪切板的字符串.</dd>
+</dl>
+<h3 id="copyStringToClipboard()" name="copyStringToClipboard()">copyStringToClipboard()</h3>
+<p>该方法将字符串复制到指定剪切板.</p>
+<pre class="eval">void copyStringToClipboard(
+ in AString aString,
+ in long aClipboardID
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ 将要复制到指定剪切板的字符串.</dd>
+ <dt>
+ <code>aClipboardID</code></dt>
+ <dd>
+ 指定剪切板的ID(例如<code>kSelectionClipboard</code>).</dd>
+</dl>
+<h2 id="See_also" name="See_also">相关连接</h2>
+<ul>
+ <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIClipboard" title="">nsIClipboard</a></code></li>
+ <li><a href="/zh-cn/Using_the_Clipboard" title="zh-cn/Using the Clipboard">Using the Clipboard</a></li>
+</ul>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiconsoleservice/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiconsoleservice/index.html
new file mode 100644
index 0000000000..b373505057
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiconsoleservice/index.html
@@ -0,0 +1,215 @@
+---
+title: nsIConsoleService
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIConsoleService
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIConsoleService
+---
+<div class="warning">
+ <p>Error Console在Firefox中已经过期,只有将<code>devtools.errorconsole.enabled<font face="Open Sans, sans-serif"><span style="line-height: 23.33333396911621px;">
+ <i>
+ 设为</i>
+ </span></font></code><code>true<em>才能使用</em></code>. 对于web应用使用 <a href="/en-US/docs/Tools/Web_Console" title="/en-US/docs/Tools/Web_Console">Web Console </a>代替, 对于浏览器中的chrome应用,使用 <a href="/en-US/docs/Tools/Browser_Console" title="/en-US/docs/Tools/Browser_Console">Browser Console</a> 代替 .</p>
+</div>
+<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/base/nsIConsoleService.idl" rel="custom">xpcom/base/nsIConsoleService.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">
+
+console service是<a title="en/Error_Console">Error Console</a> 后端的一部分, 与每一个Mozilla应用绑定在一起. 它用来记录各种消息、警告以及错误,同时可获取所有已经记录的消息
+</span>
+
+<div style="background: #eee; padding: 2px;">
+继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code>
+<span style="text-align: right; float: right;">最后修改于Gecko 1.9 (Firefox 3)</span></div>
+</div><p></p>
+<p>实现方式: <code>@mozilla.org/consoleservice;1</code> as a service:</p>
+<pre class="eval">var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
+ .getService(Components.interfaces.nsIConsoleService);
+</pre>
+<h2 id="Method_overview" name="Method_overview">Method overview</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>void <a href="#getMessageArray()">getMessageArray</a>([array, size_is(count)] out nsIConsoleMessage messages, out uint32_t count);</code><span class="inlineIndicator obsolete obsoleteInline" title="(Firefox 19 / Thunderbird 19 / SeaMonkey 2.16)">已废弃 Gecko 19</span><br>
+ <code>void <a href="#getMessageArray()">getMessageArray</a>(</code><code>[optional] out uint32_t count, </code><code>[retval, array, size_is(count)] out nsIConsoleMessage messages);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#logMessage()">logMessage</a>(in nsIConsoleMessage message);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#logStringMessage()">logStringMessage</a>(in wstring message);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#registerListener()">registerListener</a>(in nsIConsoleListener listener);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#reset()">reset</a>();</code> </td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#unregisterListener()">unregisterListener</a>(in nsIConsoleListener listener);</code></td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Methods" name="Methods">Methods</h2>
+<h3 id="getMessageArray()" name="getMessageArray()">getMessageArray()</h3>
+<p>获取有关目前所有控制台记录的信息的数组</p>
+<p></p><div class="blockIndicator obsolete obsoleteHeader"><p><strong><span class="icon-only-inline" title="This is an obsolete API and is no longer guaranteed to work."><i class="icon-trash"> </i></span> 已废弃 Gecko 19 (Firefox 19 / Thunderbird 19 / SeaMonkey 2.16)</strong><br>This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.</p></div><p></p>
+<pre class="eval">void getMessageArray(
+ [array, size_is(count)] out nsIConsoleMessage messages,
+ out PRUint32 count
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>messages</code></dt>
+ <dd>
+ 已经记录的消息数组</dd>
+ <dt>
+ <code>count</code></dt>
+ <dd>
+ 数组中消息的数。如果没有消息被记录,函数会返回0,但同时仍会为message分配一个标记,在从脚本调用时,表示返回的一个长度为0的消息。</dd>
+</dl>
+<p></p>
+<pre class="eval">void getMessageArray(
+ [optional] out PRUint32 count,
+ [retval, array, size_is(count)] out nsIConsoleMessage messages
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>count</code></dt>
+ <dd>
+ The number of messages in the array. If no messages are logged, this function will return a count of 0 but still will allocate one word for messages, so as to show up as a 0-length array when called from script.</dd>
+</dl>
+<p></p><div class="blockIndicator note"><strong>Note:</strong> See the code samples below for how to call getMessageArray.</div><p></p>
+<h3 id="logMessage()" name="logMessage()">logMessage()</h3>
+<pre class="eval">void logMessage(
+ in nsIConsoleMessage message
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>message</code></dt>
+ <dd>
+ An <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIConsoleMessage" title="">nsIConsoleMessage</a></code> to log.</dd>
+</dl>
+<h3 id="logStringMessage()" name="logStringMessage()">logStringMessage()</h3>
+<p>Convenience method for logging simple messages.</p>
+<pre class="eval">void logStringMessage(
+ in wstring message
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>message</code></dt>
+ <dd>
+ The string to log.</dd>
+</dl>
+<h3 id="registerListener()" name="registerListener()">registerListener()</h3>
+<p>Registers a listener for notification when an error is logged.</p>
+<p></p><div class="blockIndicator note"><strong>Note:</strong> To guard against stack overflows from listeners that could log messages (it is easy to do this inadvertently from listeners implemented in JavaScript), we do not call any listeners when another error is already being logged.</div><p></p>
+<pre class="eval">void registerListener(
+ in nsIConsoleListener listener
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>listener</code></dt>
+ <dd>
+ The <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIConsoleListener" title="">nsIConsoleListener</a></code> to add.</dd>
+</dl>
+<p></p><h3 id="reset()">reset()</h3><p></p>
+<p>Clear the message buffer (For example, for privacy reasons).</p>
+<pre class="eval">void reset();
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<p>None.</p>
+<p></p><div class="blockIndicator note"><strong>Note:</strong> Console listeners expect you to log an empty string message before calling <code>reset</code> so that they can clear their message buffers too. (This works before Gecko 1.9 too of course.)</div><p></p>
+<h3 id="unregisterListener()" name="unregisterListener()">unregisterListener()</h3>
+<p>Unregisters a listener.</p>
+<pre class="eval">void unregisterListener(
+ in nsIConsoleListener listener
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>listener</code></dt>
+ <dd>
+ The <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIConsoleListener" title="">nsIConsoleListener</a></code> to remove.</dd>
+</dl>
+<h2 id="Examples" name="Examples">Examples</h2>
+<h4 id="Retrieving_the_message_array" name="Retrieving_the_message_array">Retrieving the message array</h4>
+<p>To retrieve the message array in Gecko prior to version 19:</p>
+<pre class="brush: js">function getConsoleMessageArray() {
+ var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
+ .getService(Components.interfaces.nsIConsoleService);
+ var array = {};
+ consoleService.getMessageArray(array, {});
+ return array.value;
+}
+</pre>
+<p>To retrieve the message array in Gecko 19 or later:</p>
+<pre class="brush: js">function getConsoleMessageArray() {
+ var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
+ .getService(Components.interfaces.nsIConsoleService);
+ return consoleService.getMessageArray();
+}
+</pre>
+<p>To retrieve the message array in a compatible way:</p>
+<pre class="brush: js">function getConsoleMessageArray() {
+ var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
+ .getService(Components.interfaces.nsIConsoleService);
+ var array = {};
+ return consoleService.getMessageArray(array, {}) || array.value;
+}
+</pre>
+<h4 id="Logging_a_simple_message" name="Logging_a_simple_message">Logging a simple message</h4>
+<p>A common usage is to log a string message to console:</p>
+<pre class="brush: js">function LOG(msg) {
+ var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
+ .getService(Components.interfaces.nsIConsoleService);
+ consoleService.logStringMessage(msg);
+}
+</pre>
+<p>Alternative logging methods include <a href="/en/Components.utils.reportError" title="en/Components.utils.reportError">Components.utils.reportError</a> and <a href="/en/DOM/window.dump" title="en/DOM/window.dump">dump()</a>.</p>
+<h4 id="Logging_a_message_with_additional_information" name="Logging_a_message_with_additional_information">Logging a message with additional information</h4>
+<p>To include other information an <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIConsoleMessage" title="">nsIConsoleMessage</a></code> object must be used. In this example <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIScriptError" title="">nsIScriptError</a></code>, which implements <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIConsoleMessage" title="">nsIConsoleMessage</a></code>, is used to include information about the source file and line number of the error.</p>
+<pre class="brush: js">function myLogToConsole(aMessage, aSourceName, aSourceLine, aLineNumber,
+ aColumnNumber, aFlags, aCategory)
+{
+ var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
+ .getService(Components.interfaces.nsIConsoleService);
+ var scriptError = Components.classes["@mozilla.org/scripterror;1"]
+ .createInstance(Components.interfaces.nsIScriptError);
+ scriptError.init(aMessage, aSourceName, aSourceLine, aLineNumber,
+ aColumnNumber, aFlags, aCategory);
+ consoleService.logMessage(scriptError);
+}
+</pre>
+<ul>
+ <li><code>aMessage</code> — the string to be logged. You must provide this.</li>
+ <li><code>aSourceName</code> — the URL of file with error. This will be a hyperlink in the Error Console, so you'd better use real URL. You may pass <code>null</code> if it's not applicable.</li>
+ <li><code>aSourceLine</code> — the line #<code>aLineNumber</code> from <code>aSourceName</code> file. You are responsible for providing that line. You may pass <code>null</code> if you are lazy; that will prevent showing the source line in Error Console.</li>
+ <li><code>aLineNumber</code> and <code>aColumnNumber</code> — specify the exact location of error. <code>aColumnNumber</code> is used to draw the arrow pointing to the problem character.</li>
+ <li><code>aFlags</code> — one of flags declared in <code>nsIScriptError</code>. At the time of writing, possible values are:
+ <ul>
+ <li><code>nsIScriptError.errorFlag = 0</code></li>
+ <li><code>nsIScriptError.warningFlag = 1</code></li>
+ <li><code>nsIScriptError.exceptionFlag = 2</code> and</li>
+ <li><code>nsIScriptError.strictFlag = 4</code>.</li>
+ </ul>
+ </li>
+ <li><code>aCategory</code> — a string indicating what kind of code caused the message. There are quite a few category strings and they do not seem to be listed in a single place. Hopefully, they will all be listed in <code>nsIScriptError.idl</code> eventually.</li>
+</ul>
+<h2 id="See_also" name="See_also">See also</h2>
+<ul>
+ <li><a href="/en/Error_Console" title="en/Error_Console">Error Console</a></li>
+ <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIConsoleMessage" title="">nsIConsoleMessage</a></code></li>
+</ul>
+<p></p>
+<div id="cke_pastebin" style="position: absolute; top: 894.333px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">
+  </div>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsidirectoryserviceprovider/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsidirectoryserviceprovider/index.html
new file mode 100644
index 0000000000..20d094eaf3
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsidirectoryserviceprovider/index.html
@@ -0,0 +1,65 @@
+---
+title: nsIDirectoryServiceProvider
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIDirectoryServiceProvider
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIDirectoryServiceProvider
+---
+<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/io/nsIDirectoryService.idl" rel="custom">xpcom/io/nsIDirectoryService.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">
+
+本接口是目录服务用于得到文件位置的函数。
+</span>
+
+<div style="background: #eee; padding: 2px;">
+继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code>
+<span style="text-align: right; float: right;">最后修改于Gecko 1.7 </span></div>
+</div><p></p>
+<p><code>nsIDirectoryServiceProvider</code>.</p>
+<h2 id="Method_overview" name="Method_overview">方法概览</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>nsIFile <a href="#getFile()">getFile</a>(in string prop, out PRBool persistent);</code></td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Methods" name="Methods">方法</h2>
+<h3 id="getFile()" name="getFile()">getFile()</h3>
+<p>The Directory Service calls this method when it gets the first request for a prop or on every request if the prop is not persistent.</p>
+<pre class="eval">nsIFile getFile(
+ in string prop,
+ out PRBool persistent
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>prop</code></dt>
+ <dd>
+ The symbolic name of the file.</dd>
+ <dt>
+ <code>persistent</code></dt>
+ <dd>
+ <code>true</code> if the returned file will be cached by Directory Service. Subsequent requests for this prop will bypass the provider and use the cache. <code>false</code> if the provider will be asked for this prop each time it is requested.</dd>
+</dl>
+<h6 id="Return_value" name="Return_value">Return value</h6>
+<p>The <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile" title="">nsIFile</a></code> represented by the property.</p>
+<h2 id="Example" name="Example">示例</h2>
+<p>This code creates a global, read-only string called <code>currDir</code> with the value of the current working directory.</p>
+<pre class="eval"> __defineGetter__("currDir",
+ function getCurrDir() {
+ return Components.classes["@mozilla.org/file/directory_service;1"]
+ .getService(Components.interfaces.nsIDirectoryServiceProvider)
+ .getFile("CurWorkD",{}).path;
+ });
+</pre>
+<p>Test it with to see the magic happen.</p>
+<pre class="eval"> alert(currDir);
+</pre>
+<h2 id="See_also" name="See_also">参见</h2>
+<ul>
+ <li><a href="/en/nsDirectoryService" title="en/nsDirectoryService">nsDirectoryService</a></li>
+ <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDirectoryService" title="">nsIDirectoryService</a></code></li>
+ <li>(译注)其它目录服务关键字见<a href="http://mxr.mozilla.org/mozilla-central/source/xpcom/io/nsDirectoryServiceDefs.h" title="http://mxr.mozilla.org/mozilla-central/source/xpcom/io/nsDirectoryServiceDefs.h">nsDirectoryServiceDefs.h</a></li>
+</ul>
+<p>Additionally, see <a class="external" href="http://mb.eschew.org/16.php#sub_16.5.2">section 16.5.2</a> of the <a class="external" href="http://mb.eschew.org/">Rapid Application Development with Mozilla</a> book for instructions on how to get the <strong>current working directory</strong> and the <strong>process binary directory</strong>, among other things.</p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsidomclientrect/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsidomclientrect/index.html
new file mode 100644
index 0000000000..20a00c9e26
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsidomclientrect/index.html
@@ -0,0 +1,92 @@
+---
+title: nsIDOMClientRect
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMClientRect
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMClientRect
+---
+<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/dom/interfaces/base/nsIDOMClientRect.idl" rel="custom">dom/interfaces/base/nsIDOMClientRect.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">代表一个矩形盒子。盒子类型由返回这种盒子对象的方法指定的。它是由像<a href="/zh-CN/docs/Web/API/Element/getBoundingClientRect" title="Element.getBoundingClientRect()方法返回元素的大小及其相对于视口的位置。"><code>element.getBoundingClientRect</code></a>的函数返回的。.</span>
+
+ <div style="height: 42px; position: relative; padding: 2px; width: auto;">
+
+ <div style="top: 22px; font-size: 11px; position: absolute;">1.0</div>
+
+ <div style="top: 22px; font-size: 11px; position: absolute; left: 0px; text-align: right; float: right; width: 100%;">66</div>
+
+ <div style="height: 8px; top: 16px; background: #dd0000; left: 0px; position: absolute; width: 8.571428571428571%;"></div>
+
+<div style="height: 8px; top: 16px; left: 8.571428571428571%; background: #00dd00; position: absolute; width: 91.42857142857143%;" title="Introduced in Gecko 1.9 (Firefox 3)"></div>
+
+<div style="top: 0px; font-size: 11px; position: absolute; left: 8.571428571428571%;">Introduced</div>
+<div style="top: 22px; font-size: 11px; position: absolute; left: 8.571428571428571%;">Gecko 1.9</div>
+
+ <div style="height: 8px; top: 16px; left: 9.023809428571429%; background: #eeee00; position: absolute; width: 1%; border-radius: 4px; -webkit-border-radius: 4px;" title="Last changed in Gecko 1.9.1 (Firefox 3.5 / Thunderbird 3.0 / SeaMonkey 2.0)"></div>
+
+</div>
+
+<div style="background: #eee; padding: 2px;">
+继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code>
+<span style="text-align: right; float: right;">最后修改于Gecko 1.9.1 (Firefox 3.5 / Thunderbird 3.0 / SeaMonkey 2.0)</span></div>
+</div><p></p>
+
+<h2 id="Attributes" name="Attributes">属性</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Attribute</td>
+ <td class="header">Type</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>bottom</code></td>
+ <td><code><a href="/en/float" title="en/float">float</a></code></td>
+ <td>Y 轴,相对于视口原点(viewport origin)矩形盒子的底部。<strong>只读。 </strong></td>
+ </tr>
+ <tr>
+ <td><code>height</code></td>
+ <td><code><a href="/en/float" title="en/float">float</a></code></td>
+ <td>矩形盒子的高度(等同于 bottom 减 top)。<strong>只读。</strong></td>
+ </tr>
+ <tr>
+ <td><code>left</code></td>
+ <td><code><a href="/en/float" title="en/float">float</a></code></td>
+ <td>X 轴,相对于视口原点(viewport origin)矩形盒子的左侧。<strong>只读。 </strong></td>
+ </tr>
+ <tr>
+ <td><code>right</code></td>
+ <td><code><a href="/en/float" title="en/float">float</a></code></td>
+ <td>X 轴,相对于视口原点(viewport origin)矩形盒子的右侧。<strong>只读。 </strong></td>
+ </tr>
+ <tr>
+ <td><code>top</code></td>
+ <td><code><a href="/en/float" title="en/float">float</a></code></td>
+ <td>Y 轴,相对于视口原点(viewport origin)矩形盒子的顶部。<strong>只读。</strong></td>
+ </tr>
+ <tr>
+ <td><code>width</code></td>
+ <td><code><a href="/en/float" title="en/float">float</a></code></td>
+ <td>矩形盒子的宽度(等同于 right 减 left)。<strong>只读。</strong> </td>
+ </tr>
+ <tr>
+ <td><code>x</code></td>
+ <td><code><a href="/en/float" title="en/float">float</a></code></td>
+ <td>X 轴,相对于视口原点(viewport origin)矩形盒子的左侧。<strong>只读。</strong> </td>
+ </tr>
+ <tr>
+ <td><code>y</code></td>
+ <td><code><a href="/en/float" title="en/float">float</a></code></td>
+ <td>Y 轴,相对于视口原点(viewport origin)矩形盒子的顶部。<strong>只读。</strong></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="See_also" name="See_also">参考资料</h2>
+
+<ul>
+ <li><a href="http://www.w3.org/TR/cssom-view/#the-clientrect-interface">CSSOM View Module : The ClientRect Interface</a><span style="color: #fff; background: #e66e33; display: inline-block; font-size: x-small; margin-left: 6px; white-space: nowrap; padding: 2px 5px;" title="工作草案">WD</span></li>
+</ul>
+
+<p><span style="line-height: 1.5;">这个对象几次易名:最初叫做 TextRectangle,</span><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=916520" style="line-height: 1.5;">然后</a><span style="line-height: 1.5;">叫做 ClientRect,</span><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=916520" style="line-height: 1.5;">后来</a><span style="line-height: 1.5;">叫做 DOMRect。</span></p>
+
+<p><span style="line-height: 1.5;">该对象最初只有 top、left、right、bottom 属性,后来添加了 width、height、x、y 属性。</span></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsifile/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsifile/index.html
new file mode 100644
index 0000000000..d966771e83
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsifile/index.html
@@ -0,0 +1,828 @@
+---
+title: nsIFile
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIFile
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIFile
+---
+<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/io/nsIFile.idl" rel="custom">xpcom/io/nsIFile.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">
+
+An instance of this interface is a cross-platform representation of a location in the filesystem.
+</span>
+
+<div style="background: #eee; padding: 2px;">
+继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code>
+<span style="text-align: right; float: right;">最后修改于Gecko 1.0 </span></div>
+</div><p></p>
+<p><code>nsIFile</code> is the correct platform-agnostic way to specify a file; you should always use this instead of a string to ensure compatibility.</p>
+<p>With an <code>nsIFile</code> you can navigate to ancestors or descendants without having to deal with the different path separators used on different platforms, query the state of any file or directory at the position represented by the <code>nsIFile</code> and create, move or copy items in the filesystem.</p>
+<p>An <code>nsIFile</code> can be retrieved by either instantiating an <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile" title="">nsILocalFile</a></code> using a platform specific path string or by using cross-platform locations retrieved from the <a href="/en/Code_snippets/File_I//O#Getting_special_files" title="en/Code_snippets/File_I//O#Getting_special_files">directory service</a>.</p>
+<p>All methods with string parameters have two forms. The preferred form operates on UTF-16 encoded characters strings. An alternate form operates on characters strings encoded in the "native" charset. A string containing characters encoded in the native charset cannot be safely passed to javascript via xpconnect. Therefore, the UTF-16 forms are scriptable, but the "native methods" are not. In addition, the native form <strong>cannot</strong> deal with files whose name contains characters outside the default system code page on Windows. Using the native form limits the ability of your code to deal with the full Unicode support on Windows 2000 or later where the OS itself does not have such a limitation. Therefore, you <strong>must not</strong> use the native form unless it is <strong>guaranteed</strong> that the path passed to a native form function is <strong>always</strong> ASCII.</p>
+<div class="note">
+ <strong>Note:</strong> <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile" title="">nsILocalFile</a></code> was merged with this interface in Gecko 14. Much of the documentation has not been updated to reflect this change.</div>
+<h2 id="Method_overview" name="Method_overview">Method overview</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>void <a href="#append()">append</a>(in AString node);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#appendNative()">appendNative</a>(in ACString node);</code> <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="/en/XPCOM_Interface_Reference/nsILocalFile#appendRelativeNativePath()" title="/en/XPCOM_Interface_Reference/nsILocalFile#appendRelativeNativePath()">appendRelativeNativePath</a>(in ACString relativeFilePath);</code> <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="/en/XPCOM_Interface_Reference/nsILocalFile#appendRelativePath()" title="/en/XPCOM_Interface_Reference/nsILocalFile#appendRelativePath()">appendRelativePath</a>(in AString relativeFilePath);</code> </td>
+ </tr>
+ <tr>
+ <td><code>nsIFile <a href="#clone()">clone</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#contains()">contains</a>(in nsIFile inFile, in boolean recur);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#copyTo()">copyTo</a>(in nsIFile newParentDir, in AString newName);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#copyToFollowingLinks()">copyToFollowingLinks</a>(in nsIFile newParentDir, in AString newName);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#copyToFollowingLinksNative()">copyToFollowingLinksNative</a>(in nsIFile newParentDir, in ACString newName);</code> <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#CopyToNative()">CopyToNative</a>(in nsIFile newParentDir, in ACString newName);</code> <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#create()">create</a>(in unsigned long type, in unsigned long permissions);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#createUnique()">createUnique</a>(in unsigned long type, in unsigned long permissions);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#equals()">equals</a>(in nsIFile inFile);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#exists()">exists</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>ACString <a href="/en/XPCOM_Interface_Reference/nsILocalFile#getRelativeDescriptor()" title="/en/XPCOM_Interface_Reference/nsILocalFile#getRelativeDescriptor()">getRelativeDescriptor</a>(in nsIFile fromFile);</code> </td>
+ </tr>
+ <tr>
+ <td><code>void <a href="/en/XPCOM_Interface_Reference/nsILocalFile#initWithFile()" title="/en/XPCOM_Interface_Reference/nsILocalFile#initWithFile()">initWithFile</a>(in nsIFile aFile);</code> </td>
+ </tr>
+ <tr>
+ <td><code>void <a href="/en/XPCOM_Interface_Reference/nsILocalFile#initWithNativePath()" title="/en/XPCOM_Interface_Reference/nsILocalFile#initWithNativePath()">initWithNativePath</a>(in ACString filePath);</code> <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="/en/XPCOM_Interface_Reference/nsILocalFile#initWithPath()" title="/en/XPCOM_Interface_Reference/nsILocalFile#initWithPath()">initWithPath</a>(in AString filePath);</code> </td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#isDirectory()">isDirectory</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#isExecutable()">isExecutable</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#isFile()">isFile</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#isHidden()">isHidden</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#isReadable()">isReadable</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#isSpecial()">isSpecial</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#isSymlink()">isSymlink</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#isWritable()">isWritable</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="/en/XPCOM_Interface_Reference/nsILocalFile#launch()" title="/en/XPCOM_Interface_Reference/nsILocalFile#launch()">launch</a>();</code> </td>
+ </tr>
+ <tr>
+ <td><code>PRLibraryStar <a href="/en/XPCOM_Interface_Reference/nsILocalFile#load()" title="/en/XPCOM_Interface_Reference/nsILocalFile#load()">load</a>();</code> <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#moveTo()">moveTo</a>(in nsIFile newParentDir, in AString newName);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#moveToNative()">moveToNative</a>(in nsIFile newParentDir, in ACString newName);</code> <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#normalize()">normalize</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>FILE <a href="/en/XPCOM_Interface_Reference/nsILocalFile#openANSIFileDesc()" title="/en/XPCOM_Interface_Reference/nsILocalFile#openANSIFileDesc()">openANSIFileDesc</a>(in string mode);</code> <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>PRFileDescStar <a href="/en/XPCOM_Interface_Reference/nsILocalFile#openNSPRFileDesc()" title="/en/XPCOM_Interface_Reference/nsILocalFile#openNSPRFileDesc()">openNSPRFileDesc</a>(in long flags, in long mode);</code> <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#remove()">remove</a>(in boolean recursive);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="/en/XPCOM_Interface_Reference/nsILocalFile#reveal()" title="/en/XPCOM_Interface_Reference/nsILocalFile#reveal()">reveal</a>();</code> </td>
+ </tr>
+ <tr>
+ <td><code>void <a href="/en/XPCOM_Interface_Reference/nsILocalFile#setRelativeDescriptor()" title="/en/XPCOM_Interface_Reference/nsILocalFile#setRelativeDescriptor()">setRelativeDescriptor</a>(in nsIFile fromFile, in ACString relativeDesc);</code> </td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Attributes" name="Attributes">Attributes</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Attribute</td>
+ <td class="header">Type</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>directoryEntries</code></td>
+ <td><code><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISimpleEnumerator" title="">nsISimpleEnumerator</a></code></code></td>
+ <td>Returns an enumeration of the elements in a directory. Each element in the enumeration is an <code>nsIFile</code>. <strong>Read only.</strong>
+ <h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+ <dl>
+ <dt>
+ <code>NS_ERROR_FILE_NOT_DIRECTORY</code></dt>
+ <dd>
+ Indicates that this <code>nsIFile</code> does not reference a directory.</dd>
+ </dl>
+ </td>
+ </tr>
+ <tr>
+ <td><code>diskSpaceAvailable</code> </td>
+ <td><code><a href="/en/PRInt64" title="en/PRInt64">PRInt64</a></code></td>
+ <td>The number of bytes available to non-superuser on the disk volume containing the <code>nsIFile</code>. <strong>Read only.</strong></td>
+ </tr>
+ <tr>
+ <td><code>fileSize</code></td>
+ <td><code><a href="/en/PRInt64" title="en/PRInt64">PRInt64</a></code></td>
+ <td>
+ <p>The value of this attribute is the number of bytes corresponding to the data represented by the file.</p>
+ <p>On the Mac, getting/setting the file size with <code>nsIFile</code> only deals with the size of the data fork. If you need to know the size of the combined data and resource forks use <code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsILocalFileMac#GetFileSizeWithResFork()">nsILocalFileMac.GetFileSizeWithResFork()</a></code>.</p>
+ Changing the size of a <code>nsIFile</code> operates on the underlying filesystem, possibly truncating the existing file to specified size.</td>
+ </tr>
+ <tr>
+ <td><code>fileSizeOfLink</code></td>
+ <td><code><a href="/en/PRInt64" title="en/PRInt64">PRInt64</a></code></td>
+ <td>
+ <p>This attribute exposes the size of the symbolic link referenced by this <code>nsIFile</code>.</p>
+ <p>Unlike <code>fileSize</code>, this attribute corresponds to the size of the symbolic link referenced by this <code>nsIFile</code>. If this <code>nsIFile</code> does not reference a symbolic link, then the value of this attribute is undefined.</p>
+ The value of this attribute is the number of bytes corresponding to the data represented by the symbolic link. Any meta data, such as a resource fork on the Mac, is not included in the measurement of the file size. <strong>Read only.</strong></td>
+ </tr>
+ <tr>
+ <td><code>followLinks</code> </td>
+ <td><code><a href="/en/PRBool" title="en/PRBool">PRBool</a></code></td>
+ <td>
+ <p>Determines whether or not the <code>nsIFile</code> will automatically resolve symbolic links.</p>
+ By default, this value is <code>false</code> on all non-UNIX systems. As of Mozilla 1.7, this attribute is ignored on UNIX systems.</td>
+ </tr>
+ <tr>
+ <td><code>lastModifiedTime</code></td>
+ <td><code><a href="/en/PRInt64" title="en/PRInt64">PRInt64</a></code></td>
+ <td>
+ <p>This attribute exposes the time when the file referenced by this <code>nsIFile</code> was last modified.</p>
+ <p>The value of this attribute is milliseconds since midnight (00:00:00), January 1, 1970 Greenwich Mean Time (GMT).</p>
+ Changing the last modified time of a <code>nsIFile</code> operates on the underlying filesystem. As of <span title="">Gecko 1.7</span>, changing the last modified time of a non-existent file has undefined behavior.</td>
+ </tr>
+ <tr>
+ <td><code>lastModifiedTimeOfLink</code></td>
+ <td><code><a href="/en/PRInt64" title="en/PRInt64">PRInt64</a></code></td>
+ <td>
+ <p>This attribute exposes the time when the symbolic link referenced by this <code>nsIFile</code> was last modified.</p>
+ <p>Unlike <code>lastModifiedTime</code>, this attribute corresponds to the last modified time of the symbolic link referenced by this <code>nsIFile</code>. If this <code>nsIFile</code> does not reference a symbolic link, then the value of this attribute is undefined.</p>
+ <p>The value of this attribute is milliseconds since midnight (00:00:00), January 1, 1970 Greenwich Mean Time (GMT).</p>
+ Changing the last modified time of a <code>nsIFile</code> operates on the underlying filesystem. As of <span title="">Gecko 1.7</span>, changing the last modified time of a non-existent file has undefined behavior.</td>
+ </tr>
+ <tr>
+ <td><code>leafName</code></td>
+ <td><code><a href="/en/AString" title="en/AString">AString</a></code></td>
+ <td>
+ <p>This attribute exposes the name of the <code>nsIFile</code> without any directory components.</p>
+ Changing the leaf name of a <code>nsIFile</code> does not affect the underlying filesystem. It only changes what this <code>nsIFile</code> references.</td>
+ </tr>
+ <tr>
+ <td><code>nativeLeafName</code></td>
+ <td><code><a href="/en/ACString" title="en/ACString">ACString</a></code></td>
+ <td>
+ <p>This attribute exposes the name of the <code>nsIFile</code> without any directory components. [native character encoding variant]</p>
+ Changing the leaf name of a <code>nsIFile</code> does not affect the underlying filesystem. It only changes what this <code>nsIFile</code> references. <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>nativePath</code></td>
+ <td><code><a href="/en/ACString" title="en/ACString">ACString</a></code></td>
+ <td>
+ <p>This attribute exposes the full path of the <code>nsIFile</code>. [native character encoding variant]</p>
+ The value of this attribute is a platform-specific file path. <strong>Read only.</strong> <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>nativeTarget</code></td>
+ <td><code><a href="/en/ACString" title="en/ACString">ACString</a></code></td>
+ <td>
+ <p>This attribute exposes the full target of the <code>nsIFile</code> - the full path with any symbolic links dereferenced. [native character encoding variant]</p>
+ The value of this attribute is a platform-specific file path. <strong>Read only.</strong> <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>parent</code></td>
+ <td><code><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile" title="">nsIFile</a></code></code></td>
+ <td>
+ <p>This attribute returns the parent <code>nsIFile</code> for this <code>nsIFile</code>.</p>
+ The parent will be <code>null</code> when this <code>nsIFile</code> references the top of the volume. For example, C:\ does not have a parent. <strong>Read only.</strong></td>
+ </tr>
+ <tr>
+ <td><code>path</code></td>
+ <td><code><a href="/en/AString" title="en/AString">AString</a></code></td>
+ <td>
+ <p>This attribute exposes the full platform-specific path of the <code>nsIFile</code> (including the <code>leafName</code>). <strong>Read only.</strong></p>
+ Example, this could return "/home/user/foo.txt" or "C:\Images\my.jpeg"</td>
+ </tr>
+ <tr>
+ <td><code>permissions</code></td>
+ <td><code><a href="/en/unsigned_long" title="en/unsigned long">unsigned long</a></code></td>
+ <td>
+ <p>The value of this attribute is a UNIX-style file permission mask for this <code>nsIFile</code>.</p>
+ Changing the permissions of a <code>nsIFile</code> operates on the underlying filesystem. As of <span title="">Gecko 1.7</span>, changing the permissions of a non-existent file has undefined behavior.</td>
+ </tr>
+ <tr>
+ <td><code>permissionsOfLink</code></td>
+ <td><code><a href="/en/unsigned_long" title="en/unsigned long">unsigned long</a></code></td>
+ <td>
+ <p>The value of this attribute is a UNIX-style file permission mask for this <code>nsIFile</code>.</p>
+ <p>Unlike <code>permissions</code>, this attribute corresponds to the permissions of the symbolic link referenced by this <code>nsIFile</code>. If this <code>nsIFile</code> does not reference a symbolic link, then the value of this attribute is undefined.</p>
+ Changing the permissions of a <code>nsIFile</code> operates on the underlying filesystem. As of <span title="">Gecko 1.7</span>, changing the permissions of a non-existent file has undefined behavior.</td>
+ </tr>
+ <tr>
+ <td><code>persistentDescriptor</code> </td>
+ <td><code><a href="/en/ACString" title="en/ACString">ACString</a></code></td>
+ <td>
+ <p>On some platforms, the value of <a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsIFile#path">nsIFile.path</a> may be insufficient to uniquely identify the file on the local file system. The persistent descriptor is intended to be used whenever a <code>nsIFile</code> needs to be serialized to disk and later recovered. This string is not intended for display to users.</p>
+ <div class="blockIndicator note"><strong>Note:</strong> The value of the <code>followLinks</code> attribute is not encoded in the persistent descriptor.</div></td>
+ </tr>
+ <tr>
+ <td><code>target</code></td>
+ <td><code><a href="/en/AString" title="en/AString">AString</a></code></td>
+ <td>
+ <p>This attribute exposes the full target of the <code>nsIFile</code> - the full path with any symbolic links dereferenced.</p>
+ <p>Accessor to the string <code>path</code>. The native version of these strings are not guaranteed to be a usable <code>path</code> to pass to NSPR or the C stdlib. There are problems that affect platforms on which a <code>path</code> does not fully specify a file because two volumes can have the same name (For example Mac). This is solved by holding "private", native data in the <code>nsIFile</code> implementation. This native data is lost when you convert to a string. DO NOT PASS TO USE WITH NSPR OR STDLIB! <strong>Read only.</strong></p>
+ <h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+ <dl>
+ <dt>
+ <code>NS_ERROR_FILE_INVALID_PATH</code></dt>
+ <dd>
+ Indicates that this <code>nsIFile</code> does not reference a symbolic links.</dd>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Constants" name="Constants">Constants</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Constant</td>
+ <td class="header">Value</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>NORMAL_FILE_TYPE</code></td>
+ <td><code>0</code></td>
+ <td>A normal file.</td>
+ </tr>
+ <tr>
+ <td><code>DIRECTORY_TYPE</code></td>
+ <td><code>1</code></td>
+ <td>A directory/folder.</td>
+ </tr>
+ <tr>
+ <td><code>DELETE_ON_CLOSE</code> </td>
+ <td><code>0x80000000</code></td>
+ <td>Optional parameter used by <a href="/en/XPCOM_Interface_Reference/nsILocalFile#openNSPRFileDesc()" title="/en/XPCOM_Interface_Reference/nsILocalFile#openNSPRFileDesc()">openNSPRFileDesc</a></td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Methods" name="Methods">Methods</h2>
+<h3 id="append()" name="append()">append()</h3>
+<p>This function is used for constructing a descendant of the current <code>nsIFile</code>.</p>
+<div class="note style-wrap">
+ <p><strong>Note:</strong> This method does not return a new <code>nsIFile</code>; it modifies the object it was called on. If the old <code>nsIFile</code> should be retained, use <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile#clone()">clone()</a></code>.</p>
+</div>
+<pre class="eval">void append(
+ in AString node
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>node</code></dt>
+ <dd>
+ A string which is intended to be a child node of the <code>nsIFile</code>. This string must not contain a path separator character.</dd>
+</dl>
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+<dl>
+ <dt>
+ <code>NS_ERROR_FILE_UNRECOGNIZED_PATH</code></dt>
+ <dd>
+ Indicates that aNode incorrectly contains a path separator character.</dd>
+</dl>
+<p></p><div><span class="indicatorInHeadline noscript noscriptMethod" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span><h3 id="appendNative">appendNative</h3></div><p></p>
+<p>This method is used for constructing a descendant of the current <code>nsIFile</code>. [native character encoding variant]</p>
+<pre class="eval">void appendNative(
+ in ACString node
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>node</code></dt>
+ <dd>
+ A string that is intended to be a child node of the current <code>nsIFile</code>. This string must not contain a path separator character. This string must be encoded using the native character encoding.</dd>
+</dl>
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+<dl>
+ <dt>
+ <code>NS_ERROR_FILE_UNRECOGNIZED_PATH</code></dt>
+ <dd>
+ Indicates that aNode incorrectly contains a path separator character.</dd>
+</dl>
+<h3 id="clone()" name="clone()">clone()</h3>
+<p>This method creates a clone of the <code>nsIFile</code>. (It does NOT clone the file itself; see the copy methods.)</p>
+<pre class="eval">nsIFile clone();
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<p>None.</p>
+<h6 id="Return_value" name="Return_value">Return value</h6>
+<p>A new <code>nsIFile</code> instance that corresponds to the same file or directory as this <code>nsIFile</code>.</p>
+<h3 id="contains()" name="contains()">contains()</h3>
+<p>This method tests whether or not a <code>nsIFile</code> instance is a descendant of the this <code>nsIFile</code>.</p>
+<pre class="eval">boolean contains(
+ in nsIFile inFile,
+ in boolean recur
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>inFile</code></dt>
+ <dd>
+ The <code>nsIFile</code> to test.</dd>
+ <dt>
+ <code>recur</code></dt>
+ <dd>
+ This parameter specifies whether or not subdirectories should be inspected. As of <span title="">Gecko 1.7</span>, this parameter is ignored and always treated as false by the canonical Local File implementation.</dd>
+</dl>
+<h6 id="Return_value" name="Return_value">Return value</h6>
+<p><code>true</code> if inFile is a descendant of this <code>nsIFile</code>.</p>
+<h3 id="copyTo()" name="copyTo()">copyTo()</h3>
+<p>This method copies a source file to a new location if it does not already exist.</p>
+<p>This method will NOT resolve aliases/shortcuts during the copy.</p>
+<pre class="eval">void copyTo(
+ in nsIFile newParentDir,
+ in AString newName
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>newParentDir</code></dt>
+ <dd>
+ This parameter specifies the parent directory to copy the file into. If this parameter is <code>null</code>, then the parent directory of the file will be used.</dd>
+ <dt>
+ <code>newName</code></dt>
+ <dd>
+ This parameter allows you to specify a new leaf name for the file to be copied. This parameter may be empty, in which case the current leaf name will be used.</dd>
+</dl>
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+<dl>
+ <dt>
+ <code>NS_ERROR_FILE_DESTINATION_NOT_DIR</code></dt>
+ <dd>
+ If the "newParentDir" is not a directory.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_TARGET_DOES_NOT_EXIST</code></dt>
+ <dd>
+ Indicates that the current file path does not exist. It is not possible to copy a file that does not exist.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_ALREADY_EXISTS</code></dt>
+ <dd>
+ Indicates that there is already a file named "newName" in the destination directory.</dd>
+</dl>
+<h3 id="copyToFollowingLinks()" name="copyToFollowingLinks()">copyToFollowingLinks()</h3>
+<p>This method copies a source file to a new location if it does not already exist.</p>
+<p>This method is identical to <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile#copyTo()">copyTo()</a></code> except that any symbolic links will be followed as the name suggests.</p>
+<pre class="eval">void copyToFollowingLinks(
+ in nsIFile newParentDir,
+ in AString newName
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>newParentDir</code></dt>
+ <dd>
+ This parameter specifies the parent directory to copy the file into. If this parameter is <code>null</code>, then the parent directory of the file will be used.</dd>
+ <dt>
+ <code>newName</code></dt>
+ <dd>
+ This parameter allows you to specify a new leaf name for the file to be copied. This parameter may be empty, in which case the current leaf name will be used.</dd>
+</dl>
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+<dl>
+ <dt>
+ <code>NS_ERROR_FILE_DESTINATION_NOT_DIR</code></dt>
+ <dd>
+ If the "newParentDir" is not a directory.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_TARGET_DOES_NOT_EXIST</code></dt>
+ <dd>
+ Indicates that the current file path does not exist. It is not possible to copy a file that does not exist.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_ALREADY_EXISTS</code></dt>
+ <dd>
+ Indicates that there is already a file named "newName" in the destination directory.</dd>
+</dl>
+<p></p><div><span class="indicatorInHeadline noscript noscriptMethod" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span><h3 id="copyToFollowingLinksNative">copyToFollowingLinksNative</h3></div><p></p>
+<p>This method copies this file to a new location. [native character encoding variant]</p>
+<p>This method is identical to <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile#copyToNative()">copyToNative()</a></code> except that any symbolic links will be followed as the name suggests.</p>
+<pre class="eval">void copyToFollowingLinksNative(
+ in nsIFile newParentDir,
+ in ACString newName
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>newParentDir</code></dt>
+ <dd>
+ This parameter specifies the parent directory to copy the file into. If this parameter is <code>null</code>, then the parent directory of the file will be used.</dd>
+ <dt>
+ <code>newName</code></dt>
+ <dd>
+ This parameter allows you to specify a new leaf name for the file to be copied. This parameter may be empty, in which case the current leaf name will be used. This string must be encoded using the native character encoding.</dd>
+</dl>
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+<dl>
+ <dt>
+ <code>NS_ERROR_FILE_DESTINATION_NOT_DIR</code></dt>
+ <dd>
+ If the "newParentDir" is not a directory.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_TARGET_DOES_NOT_EXIST</code></dt>
+ <dd>
+ Indicates that the current file path does not exist. It is not possible to copy a file that does not exist.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_ALREADY_EXISTS</code></dt>
+ <dd>
+ Indicates that there is already a file named "newName" in the destination directory.</dd>
+</dl>
+<p></p><div><span class="indicatorInHeadline noscript noscriptMethod" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span><h3 id="CopyToNative">CopyToNative</h3></div><p></p>
+<p>This method copies this file to a new location. [native character encoding variant]</p>
+<pre class="eval">void CopyToNative(
+ in nsIFile newParentDir,
+ in ACString newName
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>newParentDir</code></dt>
+ <dd>
+ This parameter specifies the parent directory to copy the file into. If this parameter is <code>null</code>, then the parent directory of the file will be used.</dd>
+ <dt>
+ <code>newName</code></dt>
+ <dd>
+ This parameter allows you to specify a new leaf name for the file to be copied. This parameter may be empty, in which case the current leaf name will be used. This string must be encoded using the native character encoding.</dd>
+</dl>
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+<dl>
+ <dt>
+ <code>NS_ERROR_FILE_DESTINATION_NOT_DIR</code></dt>
+ <dd>
+ If the "newParentDir" is not a directory.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_TARGET_DOES_NOT_EXIST</code></dt>
+ <dd>
+ Indicates that the current file path does not exist. It is not possible to copy a file that does not exist.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_ALREADY_EXISTS</code></dt>
+ <dd>
+ Indicates that there is already a file named "newName" in the destination directory.</dd>
+</dl>
+<h3 id="create()" name="create()">create()</h3>
+<p>This method creates a new file or directory in the file system corresponding to the file path represented by this <code>nsIFile</code>. This method will create any path segments that do not already exist.</p>
+<pre class="eval">void create(
+ in unsigned long type,
+ in unsigned long permissions
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>type</code></dt>
+ <dd>
+ This specifies the type of file system object to be made. The only two types at this time are file and directory which are defined above.</dd>
+ <dt>
+ <code>permissions</code></dt>
+ <dd>
+ A UNIX-style file permissions value. For example, the octal value 0600 may be used to limit read and write access to the current user of the system. This parameter may be ignored on systems that do not support file permissions.</dd>
+</dl>
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+<dl>
+ <dt>
+ <code>NS_ERROR_FILE_ALREADY_EXISTS</code></dt>
+ <dd>
+ Indicates that the file or directory already exists.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_UNKNOWN_TYPE</code></dt>
+ <dd>
+ Indicates that the value of "type" does not correspond to a known type.</dd>
+</dl>
+<h3 id="createUnique()" name="createUnique()">createUnique()</h3>
+<p>This function will create a new file or directory in the file system. Any nodes that have not been created or resolved, will be. If this file already exists, we try variations on the leaf name "suggestedName" until we find one that did not already exist. This method will create any path segments that do not already exist.</p>
+<pre class="eval">void createUnique(
+ in unsigned long type,
+ in unsigned long permissions
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>type</code></dt>
+ <dd>
+ This specifies the type of file system object to be made. The only two types at this time are file and directory which are defined above.</dd>
+ <dt>
+ <code>permissions</code></dt>
+ <dd>
+ A UNIX-style file permissions value. For example, the octal value 0600 may be used to limit read and write access to the current user of the system. This parameter may be ignored on systems that do not support file permissions.</dd>
+</dl>
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+<dl>
+ <dt>
+ <code>NS_ERROR_FILE_UNKNOWN_TYPE</code></dt>
+ <dd>
+ Indicates that the value of "type" does not correspond to a known type.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_TOO_BIG</code></dt>
+ <dd>
+ Indicates that the search for nonexistent files was unsuccessful because all of the attempted leaf name variants already exist.</dd>
+</dl>
+<h3 id="equals()" name="equals()">equals()</h3>
+<p>This method tests whether or not two <code>nsIFile</code> instances correspond to the same file or directory.</p>
+<pre class="eval">boolean equals(
+ in nsIFile inFile
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>inFile</code></dt>
+ <dd>
+ The <code>nsIFile</code> to compare this <code>nsIFile</code> against.</dd>
+</dl>
+<h6 id="Return_value" name="Return_value">Return value</h6>
+<p><code>true</code> if "inFile" is equivalent to this <code>nsIFile</code>.</p>
+<h3 id="exists()" name="exists()">exists()</h3>
+<p>This method tests whether or not this <code>nsIFile</code> exists.</p>
+<pre class="eval">boolean exists()
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<p>None.</p>
+<h6 id="Return_value" name="Return_value">Return value</h6>
+<p><code>true</code> if the file or directory exists. Otherwise it returns <code>false</code>.</p>
+<h3 id="isDirectory()" name="isDirectory()">isDirectory()</h3>
+<p>This method tests whether or not this <code>nsIFile</code> corresponds to a directory.</p>
+<pre class="eval">boolean isDirectory();
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<p>None.</p>
+<h6 id="Return_value" name="Return_value">Return value</h6>
+<p><code>true</code> if this <code>nsIFile</code> corresponds to a directory. Otherwise it returns <code>false</code>.</p>
+<h3 id="isExecutable()" name="isExecutable()">isExecutable()</h3>
+<p>This method tests whether or not this <code>nsIFile</code> corresponds to a file that may be executed.</p>
+<div class="note style-wrap">
+ <p><strong>Note:</strong> This method does not work on all platforms due to <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=322865" title="isExecutable method of nsILocalFile reports false for executable files on OSX">bug 322865</a>.</p>
+</div>
+<pre class="eval">boolean isExecutable();
+</pre>
+<div class="note style-wrap">
+ <p><strong>Note:</strong> Use <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIProcess" title="">nsIProcess</a></code> to then execute/run this file.</p>
+</div>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<p>None.</p>
+<h6 id="Return_value" name="Return_value">Return value</h6>
+<p><code>true</code> if the <code>nsIFile</code> may be executed by the user. Otherwise it returns <code>false</code>.</p>
+<h3 id="isFile()" name="isFile()">isFile()</h3>
+<p>This method tests whether or not this <code>nsIFile</code> corresponds to a normal file.</p>
+<pre class="eval">boolean isFile();
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<p>None.</p>
+<h6 id="Return_value" name="Return_value">Return value</h6>
+<p><code>true</code> if this <code>nsIFile</code> corresponds to a normal file. Otherwise it returns <code>false</code>.</p>
+<h3 id="isHidden()" name="isHidden()">isHidden()</h3>
+<p>This method tests whether or not this <code>nsIFile</code> corresponds to a file or directory that is hidden. In Unix, hidden files start with a period. On Mac and Windows, they have an attribute bit set.</p>
+<pre class="eval">boolean isHidden();
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<p>None.</p>
+<h6 id="Return_value" name="Return_value">Return value</h6>
+<p><code>true</code> if the file or directory is hidden. Otherwise it returns <code>false</code>.</p>
+<h3 id="isReadable()" name="isReadable()">isReadable()</h3>
+<p>This method tests whether or not this <code>nsIFile</code> corresponds to a file or directory that may be read by the user.</p>
+<pre class="eval">boolean isReadable();
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<p>None.</p>
+<h6 id="Return_value" name="Return_value">Return value</h6>
+<p><code>true</code> if the file or directory may be read by the user. Otherwise it returns <code>false</code>.</p>
+<h3 id="isSpecial()" name="isSpecial()">isSpecial()</h3>
+<p>This method tests whether or not this <code>nsIFile</code> corresponds to a special system file.</p>
+<p></p><div class="blockIndicator note"><strong>Note:</strong> The definition of a special system file is platform dependent. For example, under UNIX platforms this might correspond to a device file, socket, or fifo.</div><p></p>
+<pre class="eval">boolean isSpecial();
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<p>None.</p>
+<h6 id="Return_value" name="Return_value">Return value</h6>
+<p><code>true</code> if this <code>nsIFile</code> corresponds to a special system file. Otherwise it returns <code>false</code>.</p>
+<h3 id="isSymlink()" name="isSymlink()">isSymlink()</h3>
+<p>This method tests whether or not this <code>nsIFile</code> corresponds to a symbolic link, shortcut, or alias.</p>
+<pre class="eval">boolean isSymlink();
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<p>None.</p>
+<h6 id="Return_value" name="Return_value">Return value</h6>
+<p><code>true</code> if this <code>nsIFile</code> corresponds to a symbolic link. Otherwise it returns <code>false</code>.</p>
+<h3 id="isWritable()" name="isWritable()">isWritable()</h3>
+<p>This method tests whether or not this <code>nsIFile</code> corresponds to a file or directory that may be modified by the user.  As of Gecko 9, files on read only shares will return false.  Files that are exclusively opened on Win32 will return true if they are normally writable, and files that don't have write permissions will return false. For specific handling before Gecko 9 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6), please see <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=682571" title="FIXED: nsLocalFile::isWritable behaves wrongly on Windows">bug 682571</a>.</p>
+<pre class="eval">boolean isWritable();
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<p>None.</p>
+<h6 id="Return_value" name="Return_value">Return value</h6>
+<p><code>true</code> if the file or directory may be modified by the user. Otherwise it returns <code>false</code>.</p>
+<h3 id="moveTo()" name="moveTo()">moveTo()</h3>
+<p>This method moves this file to a new location.</p>
+<div class="note">
+ <strong>Note:</strong> If this method succeeds, this instance will be updated to point to the new file.</div>
+<p>If the current file path corresponds to a regular file (for storage of bytes), and if the new leaf name identifies a regular file that already exists, then this method will overwrite the destination file.</p>
+<p>Usually, "move" means to relocate the file to a different directory without changing the file's contents or properties, or in fact the file's serial number (inode). That is a very fast operation because it just changes directory information. The actual data doesn't move.</p>
+<p>Unfortunately, an actual "move" is impossible between different volumes (disks or partitions). This method attempts to do the "right thing" when moving files across volumes. That is, it will copy the old file to the new location, try to assign the file attributes as the old file had them, and then delete the old file. You should be aware of these possible problems:</p>
+<ul>
+ <li>This process may take a long time if the file is large and/or the bandwidth is narrow.</li>
+ <li>If the <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile#copyTo()">copyTo()</a></code> method loses data, such as Mac resource data, then so will such a move.</li>
+ <li>If attribute data cannot be recreated (like the file owner if you don't have enough privileges, or ACL data if moving to a non-ACL volume), then those attributes will be lost.</li>
+ <li>The new file's serial number will almost certainly be different, because it is a different file, probably stored in a different physical location.</li>
+</ul>
+<pre class="eval">void moveTo(
+ in nsIFile newParentDir,
+ in AString newName
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>newParentDir</code></dt>
+ <dd>
+ This parameter specifies the parent directory to move the file into. If this parameter is <code>null</code>, then the parent directory of the file will be used.</dd>
+ <dt>
+ <code>newName</code></dt>
+ <dd>
+ This parameter allows you to specify a new leaf name for the file to be moved. This parameter may be empty, in which case the current leaf name will be used.</dd>
+</dl>
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+<dl>
+ <dt>
+ <code>NS_ERROR_FILE_TARGET_DOES_NOT_EXIST</code></dt>
+ <dd>
+ Indicates that the current file path does not exist. It is not possible to move a file that does not exist.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_DIR_NOT_EMPTY</code></dt>
+ <dd>
+ Indicates that an attempt was made to move a directory to the location of an existing directory that is not empty.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_ACCESS_DENIED</code></dt>
+ <dd>
+ Indicates that an attempt was made to move a directory to the location of an existing directory that is not writable.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_DESTINATION_NOT_DIR</code></dt>
+ <dd>
+ Indicates that "newParentDir" exists and is not a directory.</dd>
+</dl>
+<p></p><div><span class="indicatorInHeadline noscript noscriptMethod" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span><h3 id="moveToNative">moveToNative</h3></div><p></p>
+<p>This method moves this file to a new location. [native character encoding variant]</p>
+<div class="note">
+ <strong>Note:</strong> If this method succeeds, this instance will be updated to point to the new file.</div>
+<p>If the current file path corresponds to a regular file (for storage of bytes), and if the new leaf name identifies a regular file that already exists, then this method will overwrite the destination file.</p>
+<p>Usually, "move" means to relocate the file to a different directory without changing the file's contents or properties, or in fact the file's serial number (inode). That is a very fast operation because it just changes directory information. The actual data doesn't move.</p>
+<p>Unfortunately, an actual "move" is impossible between different volumes (disks or partitions). This method attempts to do the "right thing" when moving files across volumes. That is, it will copy the old file to the new location, try to assign the file attributes as the old file had them, and then delete the old file. You should be aware of these possible problems:</p>
+<ul>
+ <li>This process may take a long time if the file is large and/or the bandwidth is narrow.</li>
+ <li>If the <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile#copyTo()">copyTo()</a></code> method loses data, such as Mac resource data, then so will such a move.</li>
+ <li>If attribute data cannot be recreated (like the file owner if you don't have enough privileges, or ACL data if moving to a non-ACL volume), then those attributes will be lost.</li>
+ <li>The new file's serial number will almost certainly be different, because it is a different file, probably stored in a different physical location.</li>
+</ul>
+<pre class="eval">void moveToNative(
+ in nsIFile newParentDir,
+ in ACString newName
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<p> </p>
+<dl>
+ <dt>
+ <code>newParentDir</code></dt>
+ <dd>
+ This parameter specifies the parent directory to copy the file into. If this parameter is <code>null</code>, then the parent directory of the file will be used.</dd>
+ <dt>
+ <code>newName</code></dt>
+ <dd>
+ This parameter allows you to specify a new leaf name for the file to be copied. This parameter may be empty, in which case the current leaf name will be used. This string must be encoded using the native character encoding.</dd>
+</dl>
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+<dl>
+ <dt>
+ <code>NS_ERROR_FILE_TARGET_DOES_NOT_EXIST</code></dt>
+ <dd>
+ Indicates that the current file path does not exist. It is not possible to move a file that does not exist.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_DIR_NOT_EMPTY</code></dt>
+ <dd>
+ Indicates that an attempt was made to move a directory to the location of an existing directory that is not empty.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_ACCESS_DENIED</code></dt>
+ <dd>
+ Indicates that an attempt was made to move a directory to the location of an existing directory that is not writable.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_DESTINATION_NOT_DIR</code></dt>
+ <dd>
+ Indicates that "newParentDir" exists and is not a directory.</dd>
+</dl>
+<h3 id="normalize()" name="normalize()">normalize()</h3>
+<p>This method is used to canonicalize the path represented by this <code>nsIFile</code>. (for example removing .. and . components on Unix).</p>
+<p>As of <span title="">Gecko 1.7</span>, this method is only implemented under UNIX builds (except for Mac OSX). This method will fail if the path does not exist.</p>
+<pre class="eval">void normalize();
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<p>None.</p>
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+<dl>
+ <dt>
+ <code>NS_ERROR_FILE_TARGET_DOES_NOT_EXIST</code></dt>
+ <dd>
+ Indicates that the file path does not exist.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_DESTINATION_NOT_DIR</code></dt>
+ <dd>
+ Indicates that a component of the path prefix is not a directory.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_ACCESS_DENIED</code></dt>
+ <dd>
+ Read or search permission was denied for a component of the path prefix.</dd>
+</dl>
+<h3 id="remove()" name="remove()">remove()</h3>
+<p>This method removes the file or directory corresponding to the file path represented by this <code>nsIFile</code>.</p>
+<p>This method will not resolve any symlinks.</p>
+<pre class="eval">void remove(
+ in boolean recursive
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>recursive</code></dt>
+ <dd>
+ If this <code>nsIFile</code> corresponds to a directory that is not empty, then this parameter must be <code>true</code> in order for the directory to be deleted. Otherwise, this parameter is ignored.</dd>
+</dl>
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+<dl>
+ <dt>
+ <code>NS_ERROR_FILE_TARGET_DOES_NOT_EXIST</code></dt>
+ <dd>
+ Indicates that the current file path does not exist. It is not possible to remove a file that does not exist.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_DIR_NOT_EMPTY</code></dt>
+ <dd>
+ Indicates that an attempt was made to remove a directory that is not empty.</dd>
+ <dt>
+ <code>NS_ERROR_FILE_ACCESS_DENIED</code></dt>
+ <dd>
+ Indicates that an attempt was made to remove a file in a way that exceeded your permissions. Details depend on your file system and how its permissions work.</dd>
+</dl>
+<h2 id="Remarks" name="Remarks">Remarks</h2>
+<p>All string-valued methods and attributes have two forms. The preferred form operates on UTF-16 (Unicode) encoded character strings. The alternate form operates on character strings encoded in the "native" multibyte character set. The native character encoding is defined as the single-byte character encoding used with the standard fopen function on the host system.</p>
+<p>The native character encoding is determined using platform specific methods. As of <span title="">Gecko 1.7</span>, it is UTF-8 on Mac OS X. On Linux and other UNIX platforms, it is the value returned from nl_langinfo (CODESET), which usually corresponds to the value of the LC_ALL, LC_CTYPE and LANG environment variables (with the precedence the same as the order they're enumerated). On Win32 platforms, it is the currently selected ANSI codepage (specified by CP_ACP).</p>
+<p>The word "Native" appears in the name of methods that operate on or return strings encoded in the native character set.</p>
+<p>A string containing characters encoded in the native character set cannot be safely passed to JavaScript via XPConnect. Therefore, the "native" methods and attributes are not scriptable.</p>
+<p>XPCOM provides the string conversion functions <a href="/en/NS_CStringToUTF16" title="en/NS_CStringToUTF16">NS_CStringToUTF16</a> and <a href="/en/NS_UTF16ToCString" title="en/NS_UTF16ToCString">NS_UTF16ToCString</a>, which can be used to convert a string between UTF-16 and the native character encoding.</p>
+<p>This interface was frozen for <span title="">Gecko 1.0</span>. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=129279" title="FIXED: nsIFile unicode/utf8/ascii task">bug 129279</a> for details. From <span title="(Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)">Gecko 2.0</span> interfaces are no longer frozen.</p>
+<h2 id="See_also" name="See_also">See also</h2>
+<ul>
+ <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile" title="">nsILocalFile</a></code></li>
+ <li><a href="/en/NS_CStringToUTF16" title="en/NS_CStringToUTF16">NS_CStringToUTF16</a></li>
+ <li><a href="/en/NS_UTF16ToCString" title="en/NS_UTF16ToCString">NS_UTF16ToCString</a></li>
+</ul>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsifilepicker/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsifilepicker/index.html
new file mode 100644
index 0000000000..7122dcd1ef
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsifilepicker/index.html
@@ -0,0 +1,376 @@
+---
+title: nsIFilePicker
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIFilePicker
+tags:
+ - Filepicker
+ - 文件选取器
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIFilePicker
+---
+<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/widget/nsIFilePicker.idl" rel="custom">widget/nsIFilePicker.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">
+
+文件选择器组件是通过显示标准的用户界面来让用户来选择文件和目录,以及选择目的地来命名和新建文件。
+</span>
+
+<div style="background: #eee; padding: 2px;">
+继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code>
+<span style="text-align: right; float: right;">最后修改于Gecko 17.0 (Firefox 17.0 / Thunderbird 17.0 / SeaMonkey 2.14)</span></div>
+</div><p></p>
+
+<p>实现自: <code>@mozilla.org/filepicker;1</code>。要创建一个实例,使用以下代码:</p>
+
+<pre class="eval">var filePicker = Components.classes["@mozilla.org/filepicker;1"]
+ .createInstance(Components.interfaces.nsIFilePicker);
+</pre>
+
+<h2 id="Method_overview" name="Method_overview">方法概述</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>void <a href="#appendFilter()">appendFilter</a>(in AString title, in AString filter);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#appendFilters()">appendFilters</a>(in long filterMask);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#init()">init</a>(in nsIDOMWindow parent, in AString title, in short mode);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#open()">open</a>(in nsIFilePickerShownCallback aFilePickerShownCallback);</code> </td>
+ </tr>
+ <tr>
+ <td><code>short <a href="#show()">show</a>();</code> <span class="inlineIndicator deprecated deprecatedInline" title="(Firefox 17.0 / Thunderbird 17.0 / SeaMonkey 2.14)">已废弃 Gecko 17.0</span></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Attributes" name="Attributes">属性</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">属性</td>
+ <td class="header">类型</td>
+ <td class="header">说明</td>
+ </tr>
+ <tr>
+ <td><code>addToRecentDocs</code> </td>
+ <td><code>boolean</code></td>
+ <td>If <code>true</code>, the file is added to the operating system's "recent documents" list (if the operating system has one; nothing happens if there is no such concept on the user's platform). This attribute has no effect if private browsing mode is in effect.</td>
+ </tr>
+ <tr>
+ <td><code>defaultExtension</code></td>
+ <td><code><a href="/en/AString" title="en/AString">AString</a></code></td>
+ <td>The extension for the type of files you want to work with. On some platforms, this is automatically appended to filenames the user enters, if required.  Specify it without a leading dot, for example "jpg".</td>
+ </tr>
+ <tr>
+ <td><code>defaultString</code></td>
+ <td><code><a href="/en/AString" title="en/AString">AString</a></code></td>
+ <td>The filename, including extension, that should be suggested to the user as a default. This should be set this before calling <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFilePicker#open()">open()</a></code> or <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFilePicker#show()">show()</a></code>.
+ <h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+
+ <dl>
+ <dt><code>NS_ERROR_FAILURE</code></dt>
+ <dd>If you try to read this attribute.</dd>
+ </dl>
+ </td>
+ </tr>
+ <tr>
+ <td><code>displayDirectory</code></td>
+ <td><code><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile" title="">nsILocalFile</a></code></code></td>
+ <td>The directory that the file picker dialog should initially display. This should be set this before calling <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFilePicker#open()">open()</a></code> or <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFilePicker#show()">show()</a></code> to specify a starting point.</td>
+ </tr>
+ <tr>
+ <td><code>file</code></td>
+ <td><code><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile" title="">nsILocalFile</a></code></code></td>
+ <td>The currently selected file or directory. <strong>Read only.</strong></td>
+ </tr>
+ <tr>
+ <td><code>files</code></td>
+ <td><code><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISimpleEnumerator" title="">nsISimpleEnumerator</a></code></code></td>
+ <td>
+ <p>An enumerator of the currently selected files. <strong>Read only.</strong></p>
+ <div class="blockIndicator note"><strong>Note:</strong> Only works with <code>modeOpenMultiple</code> mode.</div></td>
+ </tr>
+ <tr>
+ <td><code>fileURL</code></td>
+ <td><code><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIURI" title="">nsIURI</a></code></code></td>
+ <td>The URI of the currently selected file or directory. <strong>Read only.</strong></td>
+ </tr>
+ <tr>
+ <td><code>filterIndex</code></td>
+ <td><code><a href="/en/long" title="en/long">long</a></code></td>
+ <td>The (0-based) index of the filter which is currently selected in the file picker dialog. Set this to choose a particular filter to be selected by default.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Constants" name="Constants">常量</h2>
+
+<h3 id="Mode_constants" name="Mode_constants">模式常量</h3>
+
+<p>These constants are used to specify the type of file picker to create when calling <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFilePicker#init()">init()</a></code>.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">常量</td>
+ <td class="header">值</td>
+ <td class="header">说明</td>
+ </tr>
+ <tr>
+ <td><code>modeOpen</code></td>
+ <td><code>0</code></td>
+ <td>Load a file or directory.</td>
+ </tr>
+ <tr>
+ <td><code>modeSave</code></td>
+ <td><code>1</code></td>
+ <td>Save a file or directory.</td>
+ </tr>
+ <tr>
+ <td><code>modeGetFolder</code></td>
+ <td><code>2</code></td>
+ <td>Select a folder/directory.</td>
+ </tr>
+ <tr>
+ <td><code>modeOpenMultiple</code></td>
+ <td><code>3</code></td>
+ <td>Load multiple files.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Return_value_constants" name="Return_value_constants">返回值常量</h3>
+
+<p>These values are returned by <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFilePicker#show()">show()</a></code>, indicating the result of the file picker activity.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Constant</td>
+ <td class="header">Value</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>returnOK</code></td>
+ <td><code>0</code></td>
+ <td>The file picker dialog was closed by the user hitting 'Ok'</td>
+ </tr>
+ <tr>
+ <td><code>returnCancel</code></td>
+ <td><code>1</code></td>
+ <td>The file picker dialog was closed by the user hitting 'Cancel'</td>
+ </tr>
+ <tr>
+ <td><code>returnReplace</code></td>
+ <td><code>2</code></td>
+ <td>The user chose an existing file and acknowledged that they want to overwrite the file</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Filter_constants" name="Filter_constants">筛选器常量</h3>
+
+<p>These constants are used to create filters for commonly-used file types. For the most up to date list see <a href="https://dxr.mozilla.org/mozilla-central/source/toolkit/content/filepicker.properties" rel="custom">filepicker.properties</a>.</p>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Constant</td>
+ <td class="header">Value</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>filterAll</code></td>
+ <td><code>0x001</code></td>
+ <td>Corresponds to the *.* filter for file extensions. All files will pass through the filter.</td>
+ </tr>
+ <tr>
+ <td><code>filterHTML</code></td>
+ <td><code>0x002</code></td>
+ <td>Corresponds to the *.html, *.htm, *.shtml and *.xhtml filters for file extensions.</td>
+ </tr>
+ <tr>
+ <td><code>filterText</code></td>
+ <td><code>0x004</code></td>
+ <td>Corresponds to the *.txt and *.text filter for file extensions.</td>
+ </tr>
+ <tr>
+ <td><code>filterImages</code></td>
+ <td><code>0x008</code></td>
+ <td>Corresponds to the *.jpe, *.jpg, *.jpeg, *.gif, *.png, *.bmp, *.ico, *.svg, *.svgz, *.tif, *.tiff, *.ai, *.drw, *.pct, *.psp, *.xcf, *.psd and *.raw filters for file extensions.</td>
+ </tr>
+ <tr>
+ <td><code>filterXML</code></td>
+ <td><code>0x010</code></td>
+ <td>Corresponds to the *.xml filter for file extensions.</td>
+ </tr>
+ <tr>
+ <td><code>filterXUL</code></td>
+ <td><code>0x020</code></td>
+ <td>Corresponds to the *.xul filter for file extensions.</td>
+ </tr>
+ <tr>
+ <td><code>filterApps</code></td>
+ <td><code>0x040</code></td>
+ <td>Corresponds to the platform specific application filter for file extensions. Application files for the user's platform will pass through the filter.</td>
+ </tr>
+ <tr>
+ <td><code>filterAllowURLs</code></td>
+ <td><code>0x80</code></td>
+ <td>Allow URLs. </td>
+ </tr>
+ <tr>
+ <td><code>filterAudio</code></td>
+ <td><code>0x100</code></td>
+ <td>Corresponds to the *.aac, *.aif, *.flac, *.iff, *.m4a, *.m4b, *.mid, *.midi, *.mp3, *.mpa, *.mpc, *.oga, *.ogg, *.ra, *.ram, *.snd, *.wav and *.wma filters for file extensions. </td>
+ </tr>
+ <tr>
+ <td><code>filterVideo</code></td>
+ <td><code>0x200</code></td>
+ <td>Corresponds to the *.avi, *.divx, *.flv, *.m4v, *.mkv, *.mov, *.mp4, *.mpeg, *.mpg, *.ogm, *.ogv, *.ogx, *.rm, *.rmvb, *.smil, *.webm, *.wmv and *.xvid filters for file extensions. </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Methods" name="Methods">方法</h2>
+
+<h3 id="appendFilter()" name="appendFilter()">appendFilter()</h3>
+
+<p>Appends a custom file extension filter to the dialog. The filter appended first will be used to display the <code>nsIFilePicker</code> dialog, the user may then select another from the list.</p>
+
+<pre class="eval">void appendFilter(
+ in AString title,
+ in AString filter
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>title</code></dt>
+ <dd>The title of the filter.</dd>
+ <dt><code>filter</code></dt>
+ <dd>The filter string. Multiple extensions may be included, separated by a semicolon and a space.</dd>
+</dl>
+
+<h6 id="appendFilter_example" name="appendFilter_example">Example</h6>
+
+<p>Some example filter strings:</p>
+
+<ul>
+ <li>"*.ics"</li>
+ <li>"*.txt; *.doc; *.rtf"</li>
+</ul>
+
+<h3 id="appendFilters()" name="appendFilters()">appendFilters()</h3>
+
+<p>Appends a list of file extension filters, from the predefined list, to the dialog.</p>
+
+<pre class="eval">void appendFilters(
+ in long filterMask
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<div class="note"><strong>Note:</strong> If <code>appendFilters</code> is the first (or only) call to set the file filters the filter with the smallest code will be used as default filter when displaying the <code>nsIFilePicker</code> dialog. If you would like to use another you must append it separately before the others you want to go into the drop down list.</div>
+
+<dl>
+ <dt><code>filterMask</code></dt>
+ <dd>A combination of the <a class="internal" href="#Filter_constants" title="Filter constants">filters</a> you wish to use. You may OR multiple filters together; for example <code>filterAll | filterHTML</code>.</dd>
+</dl>
+
+<h3 id="init()" name="init()">init()</h3>
+
+<p>Initialize the file picker widget. The file picker is not valid until this method is called.</p>
+
+<pre class="eval">void init(
+ in nsIDOMWindow parent,
+ in AString title,
+ in short mode
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>parent</code></dt>
+ <dd>The <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindow" title="">nsIDOMWindow</a></code> parent. This dialog will be dependent on this parent. Must be non-null.</dd>
+ <dt><code>title</code></dt>
+ <dd>The file picker dialog title. If this is <code>null</code>, the dialog will have the default title.</dd>
+ <dt><code>mode</code></dt>
+ <dd>One of the <a class="internal" href="#Mode_constants" title="Mode constants">mode constants</a>, indicating the type of picker to create.</dd>
+</dl>
+
+<h3 id="open">open</h3>
+
+<p>Opens the file dialog asynchrounously. The passed in object's done method will be called upon completion.</p>
+
+<pre class="eval">void open(
+ in nsIFilePickerShownCallback aFilePickerShownCallback
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>aFilePickerShownCallback</code></dt>
+ <dd>The <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFilePickerShownCallback" title="">nsIFilePickerShownCallback</a></code> to be called on completion.</dd>
+</dl>
+
+<h3 id="show">show</h3>
+
+<p>Displays the file picker dialog. The dialog is displayed modally.</p>
+
+<pre class="eval">short show();
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<p>None.</p>
+
+<h6 id="Return_value" name="Return_value">Return value</h6>
+
+<p>One of the <a class="internal" href="#Return_value_constants" title="Return value constants">return constants</a>.</p>
+
+<h2 id="Example" name="Example">示例</h2>
+
+<p>Here's an example:</p>
+
+<pre>const nsIFilePicker = Components.interfaces.nsIFilePicker;
+
+var fp = Components.classes["@mozilla.org/filepicker;1"]
+ .createInstance(nsIFilePicker);
+fp.init(window, "Dialog Title", nsIFilePicker.modeOpen);
+fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);
+
+var rv = fp.show();
+if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
+ var file = fp.file;
+ // Get the path as string. Note that you usually won't
+ // need to work with the string paths.
+ var path = fp.file.path;
+ // work with returned nsILocalFile...
+}
+</pre>
+
+<p>If your code is a component and <code>window</code> is not defined, you can get one using <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWindowMediator" title="">nsIWindowMediator</a></code>.</p>
+
+<p>When selecting multiple files:</p>
+
+<pre> ....
+ fp.init(window, "Dialog Title", nsIFilePicker.modeOpenMultiple);
+ ....
+
+ var files = fp.files;
+ var paths = [];
+ while (files.hasMoreElements())
+ {
+ var arg = files.getNext().QueryInterface(Components.interfaces.nsILocalFile).path;
+ paths.push(arg);
+ }
+</pre>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsihttpchannel/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsihttpchannel/index.html
new file mode 100644
index 0000000000..b469773f43
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsihttpchannel/index.html
@@ -0,0 +1,365 @@
+---
+title: nsIHttpChannel
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIHttpChannel
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIHttpChannel
+---
+<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/netwerk/protocol/http/nsIHttpChannel.idl" rel="custom">netwerk/protocol/http/nsIHttpChannel.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">
+
+This interface allows for the modification of HTTP request parameters and the inspection of the resulting HTTP response status and headers when they become available.
+</span>
+
+<div style="background: #eee; padding: 2px;">
+继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIChannel" title="">nsIChannel</a></code>
+<span style="text-align: right; float: right;">最后修改于Gecko 1.3 </span></div>
+</div><p></p>
+
+<p>To create an HTTP channel, use <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIIOService" title="">nsIIOService</a></code> with a HTTP URI, for example:</p>
+
+<pre class="eval">var ios = Components.classes["@mozilla.org/network/io-service;1"]
+ .getService(Components.interfaces.nsIIOService);
+var ch = ios.newChannel("<a class="linkification-ext external" href="http://www.example.com/" title="Linkification: http://www.example.com/">http://www.example.com/</a>", null, null);
+</pre>
+
+<h2 id="Method_overview" name="Method_overview">方法概述</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>ACString <a href="#getRequestHeader()">getRequestHeader</a>(in ACString aHeader);</code></td>
+ </tr>
+ <tr>
+ <td><code>ACString <a href="#getResponseHeader()">getResponseHeader</a>(in ACString header);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#isNoCacheResponse()">isNoCacheResponse</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#isNoStoreResponse()">isNoStoreResponse</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#setRequestHeader()">setRequestHeader</a>(in ACString aHeader, in ACString aValue, in boolean aMerge);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#setResponseHeader()">setResponseHeader</a>(in ACString header, in ACString value, in boolean merge);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#visitRequestHeaders()">visitRequestHeaders</a>(in nsIHttpHeaderVisitor aVisitor);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#visitResponseHeaders()">visitResponseHeaders</a>(in nsIHttpHeaderVisitor aVisitor);</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Attributes" name="Attributes">属性</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">属性名</td>
+ <td class="header">类型</td>
+ <td class="header">描述</td>
+ </tr>
+ <tr>
+ <td><code>allowPipelining</code></td>
+ <td><code><a href="/zh-CN/boolean" title="zh-CN/boolean">boolean</a></code></td>
+ <td>
+ <p>This attribute is a hint to the channel to indicate whether or not the underlying HTTP transaction should be allowed to be pipelined with other transactions. This should be set to <code>false</code>, for example, if the application knows that the corresponding document is likely to be very large.</p>
+
+ <p>This attribute is <code>true</code> by default, though other factors may prevent pipelining.</p>
+ This attribute may only be set before the channel is opened.
+
+ <h6 id="Exceptions_thrown" name="Exceptions_thrown">可能抛出的异常</h6>
+
+ <dl>
+ <dt><code>NS_ERROR_FAILURE</code></dt>
+ <dd>If set after the channel has been opened.</dd>
+ </dl>
+ </td>
+ </tr>
+ <tr>
+ <td><code>redirectionLimit</code></td>
+ <td><code><a href="/zh-CN/unsigned_long" title="zh-CN/unsigned long">unsigned long</a></code></td>
+ <td>
+ <p>This attribute specifies the number of redirects this channel is allowed to make. If zero, the channel will fail to redirect and will generate a <code>NS_ERROR_REDIRECT_LOOP</code> failure status.</p>
+ <div class="blockIndicator note"><strong>Note:</strong> An HTTP redirect results in a new channel being created. If the new channel supports <code>nsIHttpChannel</code>, then it will be assigned a value to its <code>redirectionLimit</code> attribute one less than the value of the redirected channel's <code>redirectionLimit</code> attribute. The initial value for this attribute may be a configurable preference (depending on the implementation).</div></td>
+ </tr>
+ <tr>
+ <td><code>referrer</code></td>
+ <td><code><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIURI" title="">nsIURI</a></code></code></td>
+ <td>
+ <p>Get or set the URI of the HTTP <code>Referer:</code> header. This is the address (URI) of the resource from which this channel's URI was obtained (see RFC2616 section 14.36).</p>
+
+ <p>This attribute may only be set before the channel is opened.</p>
+ <div class="blockIndicator note"><strong>Note:</strong> The channel may silently refuse to set the Referer: header if the URI does not pass certain security checks (e.g., a "https://" URL will never be sent as the <code>referrer</code> for a plaintext HTTP request). The implementation is not required to throw an exception when the <code>referrer</code> URI is rejected.</div>
+
+ <h6 id="Exceptions_thrown" name="Exceptions_thrown">可能抛出的异常</h6>
+
+ <dl>
+ <dt><code>NS_ERROR_IN_PROGRESS</code></dt>
+ <dd>If set after the channel has been opened.</dd>
+ </dl>
+ </td>
+ </tr>
+ <tr>
+ <td><code>requestMethod</code></td>
+ <td><code><a href="/zh-CN/ACString" title="zh-CN/ACString">ACString</a></code></td>
+ <td>
+ <p>获取或设置HTTP请求方法(默认为"GET").设置时不区分大小写,获取时返回的都是大写字母组成的字符串.</p>
+
+ <p>该属性的值只能在通道打开之前进行设置.</p>
+
+ <p></p><div class="blockIndicator note"><strong>Note:</strong>  The data for a "POST" or "PUT" request can be configured via <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIUploadChannel" title="">nsIUploadChannel</a></code>. However, after setting the upload data, it may be necessary to set the request method explicitly. The documentation for <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIUploadChannel" title="">nsIUploadChannel</a></code> has further details. </div><p></p>
+
+ <h6 id="Exceptions_thrown" name="Exceptions_thrown">可能抛出的异常</h6>
+
+ <dl>
+ <dt><code>NS_ERROR_IN_PROGRESS</code></dt>
+ <dd>If set after the channel has been opened.</dd>
+ </dl>
+ </td>
+ </tr>
+ <tr>
+ <td><code>requestSucceeded</code></td>
+ <td><code><a href="/zh-CN/boolean" title="zh-CN/boolean">boolean</a></code></td>
+ <td>
+ <p>Returns <code>true</code> if the HTTP response code indicates success. The value of <code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsIRequest#status()">nsIRequest.status()</a></code> will be NS_OK even when processing a <code><a href="/zh-CN/HTTP/HTTP_response_codes#404" title="https://developer.mozilla.org/zh-CN/HTTP/HTTP_response_codes#404">404 File Not Found</a></code> response because such a response may include a message body that (in some cases) should be shown to the user. Use this attribute to distinguish server error pages from normal pages, instead of comparing the response status manually against the set of valid response codes, if that is required by your application. <strong>Read only.</strong></p>
+
+ <h6 id="Exceptions_thrown" name="Exceptions_thrown">可能抛出的异常</h6>
+
+ <dl>
+ <dt><code>NS_ERROR_NOT_AVAILABLE</code></dt>
+ <dd>If called before the response has been received (before <code>onStartRequest()</code>).</dd>
+ </dl>
+ </td>
+ </tr>
+ <tr>
+ <td><code>responseStatus</code></td>
+ <td><code><a href="/zh-CN/unsigned_long" title="zh-CN/unsigned long">unsigned long</a></code></td>
+ <td>获取HTTP响应状态码(比如200). <strong>只读.</strong>
+ <h6 id="Exceptions_thrown" name="Exceptions_thrown">可能抛出的异常</h6>
+
+ <dl>
+ <dt><code>NS_ERROR_NOT_AVAILABLE</code></dt>
+ <dd>If called before the response has been received (before <code>onStartRequest()</code>).</dd>
+ </dl>
+ </td>
+ </tr>
+ <tr>
+ <td><code>responseStatusText</code></td>
+ <td><code><a href="/zh-CN/ACString" title="zh-CN/ACString">ACString</a></code></td>
+ <td>
+ <p>获取HTTP响应状态信息(比如"OK").</p>
+ <div class="blockIndicator note"><strong>Note:</strong> This returns the raw (possibly 8-bit) text from the server. There are no assumptions made about the charset of the returned text. You have been warned!</div> <strong>Read only.</strong>
+
+ <h6 id="Exceptions_thrown" name="Exceptions_thrown">可能抛出的异常</h6>
+
+ <dl>
+ <dt><code>NS_ERROR_NOT_AVAILABLE</code></dt>
+ <dd>If called before the response has been received (before <code>onStartRequest()</code>).</dd>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Methods" name="Methods">方法</h2>
+
+<h3 id="getRequestHeader()" name="getRequestHeader()">getRequestHeader()</h3>
+
+<p>Get the value of a particular request header.</p>
+
+<pre class="eval">ACString getRequestHeader(
+ in ACString aHeader
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">参数</h6>
+
+<dl>
+ <dt><code>aHeader</code></dt>
+ <dd>需要查询的请求头名称,不区分大小写(比如"Cache-Control").</dd>
+</dl>
+
+<h6 id="Return_value" name="Return_value">返回值</h6>
+
+<p>指定请求头的值.</p>
+
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">可能抛出的异常</h6>
+
+<dl>
+ <dt><code>NS_ERROR_NOT_AVAILABLE</code></dt>
+ <dd>如果没有这个请求头</dd>
+</dl>
+
+<h3 id="getResponseHeader()" name="getResponseHeader()">getResponseHeader()</h3>
+
+<p>获取指定响应头的值.</p>
+
+<pre class="eval">ACString getResponseHeader(
+ in ACString header
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">参数</h6>
+
+<dl>
+ <dt><code>header</code></dt>
+ <dd>需要查询的响应头名称,不区分大小写(比如"Set-Cookie").</dd>
+</dl>
+
+<h6 id="Return_value" name="Return_value">返回值</h6>
+
+<p>指定响应头的值.</p>
+
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">可能抛出的异常</h6>
+
+<dl>
+ <dt><code>NS_ERROR_NOT_AVAILABLE</code></dt>
+ <dd>在响应头还未完全返回的时候调用了该方法(before <code>onStartRequest()</code>),或者响应中没有包含此响应头的情况下.</dd>
+</dl>
+
+<h3 id="isNoCacheResponse()" name="isNoCacheResponse()">isNoCacheResponse()</h3>
+
+<p>Returns <code>true</code> if the server sent the equivalent of a "Cache-Control: no-cache" response header. Equivalent response headers include: "Pragma: no-cache", "Expires: 0", and "Expires" with a date value in the past relative to the value of the "Date" header.</p>
+
+<pre class="eval">boolean isNoCacheResponse();
+</pre>
+
+<h6 id="Parameters" name="Parameters">参数</h6>
+
+<p>无</p>
+
+<h6 id="Return_value" name="Return_value">返回值</h6>
+
+<p>如果服务器返回了"Cache-control: no-cache"或者其他能够禁止缓存的响应头,则<code>该方法返回true</code>,否则返回<code>false</code>.</p>
+
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">可能抛出的异常</h6>
+
+<dl>
+ <dt><code>NS_ERROR_NOT_AVAILABLE</code></dt>
+ <dd>在响应头还未完全返回的时候调用了该方法(before <code>onStartRequest()</code>).</dd>
+</dl>
+
+<h3 id="isNoStoreResponse()" name="isNoStoreResponse()">isNoStoreResponse()</h3>
+
+<pre class="eval">boolean isNoStoreResponse();
+</pre>
+
+<h6 id="Parameters" name="Parameters">参数</h6>
+
+<p>无</p>
+
+<h6 id="Return_value" name="Return_value">返回值</h6>
+
+<p>如果服务器返回了"Cache-Control: no-store"这样的响应头,则<code>该方法返回true</code>,否则返回<code>false</code>.</p>
+
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">可能抛出的异常</h6>
+
+<dl>
+ <dt><code>NS_ERROR_NOT_AVAILABLE</code></dt>
+ <dd>在响应头还未完全返回的时候调用了该方法(before <code>onStartRequest()</code>).</dd>
+</dl>
+
+<h3 id="setRequestHeader()" name="setRequestHeader()">setRequestHeader()</h3>
+
+<p>This method is called to set the value of a particular request header. This method allows, for example, the cookies module to add "Cookie" headers to the outgoing HTTP request. This method may only be called before the channel is opened. If aValue is empty and aMerge is <code>false</code>, the header will be cleared.</p>
+
+<pre class="eval">void setRequestHeader(
+ in ACString aHeader,
+ in ACString aValue,
+ in boolean aMerge
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">参数</h6>
+
+<dl>
+ <dt><code>aHeader</code></dt>
+ <dd>指定请求头的名称,不区分大小写(例如"Cookie").</dd>
+ <dt><code>aValue</code></dt>
+ <dd>指定请求头的值(例如"X=1").</dd>
+ <dt><code>aMerge</code></dt>
+ <dd>如果该参数为<code>true</code>,则新指定的请求头的值会合并到该请求头已有的值的后面.如果指定的请求头不支持(或者说不适合)新旧值的合并操作,则这个参数会被忽略(比如"<span>Connection</span>"头就只能有一个值).具体那些请求头会忽略掉这个参数,本文档不会给出.如果该参数的值为<code>false</code>,则新指定的请求头的值会覆盖掉该请求头已有的值.</dd>
+</dl>
+
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">可能抛出的异常</h6>
+
+<dl>
+ <dt><code>NS_ERROR_IN_PROGRESS</code></dt>
+ <dd>在通道已经打开之后才调用了该方法</dd>
+</dl>
+
+<h3 id="setResponseHeader()" name="setResponseHeader()">setResponseHeader()</h3>
+
+<p>设置指定响应头的值.This method allows, for example, the HTML content sink to inform the HTTP channel about HTTP-EQUIV headers found in HTML &lt;META&gt; tags. If value is empty and merge is <code>false</code>, the header will be cleared.</p>
+
+<pre class="eval">void setResponseHeader(
+ in ACString header,
+ in ACString value,
+ in boolean merge
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">参数</h6>
+
+<dl>
+ <dt><code>header</code></dt>
+ <dd>指定响应头的名称,不区分大小写(例如"Cache-Control").</dd>
+ <dt><code>value</code></dt>
+ <dd>指定响应头的值(例如"no-cache").</dd>
+ <dt><code>merge</code></dt>
+ <dd>如果该参数为<code>true</code>,则新指定的响应头的值会合并到该响应头已有的值的后面.如果指定的响应头不支持(或者说不适合)新旧值的合并操作,则这个参数会被忽略(比如"Content-Type"头就只能有一个值).具体那些响应头会忽略掉这个参数,本文档不会给出.如果该参数的值为<code>false</code>,则新指定的响应头的值会覆盖掉该响应头已有的值.</dd>
+</dl>
+
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">可能抛出的异常</h6>
+
+<dl>
+ <dt><code>NS_ERROR_NOT_AVAILABLE</code></dt>
+ <dd>在响应头还未完全返回的时候调用了该方法(before <code>onStartRequest()</code>).</dd>
+ <dt><code>NS_ERROR_ILLEGAL_VALUE</code></dt>
+ <dd>If changing the value of this response header is not allowed.</dd>
+</dl>
+
+<h3 id="visitRequestHeaders()" name="visitRequestHeaders()">visitRequestHeaders()</h3>
+
+<p>Call this method to visit all request headers. Calling <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIHttpChannel#setRequestHeader()">setRequestHeader()</a></code> while visiting request headers has undefined behavior. Don't do it!</p>
+
+<pre class="eval">void visitRequestHeaders(
+ in nsIHttpHeaderVisitor aVisitor
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">参数</h6>
+
+<dl>
+ <dt><code>aVisitor</code></dt>
+ <dd>The header visitor instance.</dd>
+</dl>
+
+<h3 id="visitResponseHeaders()" name="visitResponseHeaders()">visitResponseHeaders()</h3>
+
+<p>Call this method to visit all response headers.</p>
+
+<p>{</p><div class="warning"> Calling <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIHttpChannel#setResponseHeader()">setResponseHeader()</a></code> while visiting response headers has undefined behavior. Don't do it! </div><p></p>
+
+<pre class="eval">void visitResponseHeaders(
+ in nsIHttpHeaderVisitor aVisitor
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">参数</h6>
+
+<dl>
+ <dt><code>aVisitor</code></dt>
+ <dd>The header visitor instance.</dd>
+</dl>
+
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">可能抛出的异常</h6>
+
+<dl>
+ <dt><code>NS_ERROR_NOT_AVAILABLE</code></dt>
+ <dd>If called before the response has been received (before <code>onStartRequest()</code>).</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiidleservice/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiidleservice/index.html
new file mode 100644
index 0000000000..a0dec4ad73
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiidleservice/index.html
@@ -0,0 +1,119 @@
+---
+title: nsIIdleService
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIIdleService
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIIdleService
+---
+<p><span class="lang lang-en"><code>nsIIdleService </code>的定义文档是:<span class="lang lang-en"><a class="external" href="http://mxr.mozilla.org/mozilla-central/source/widget/public/nsIIdleService.idl" rel="external nofollow" title="http://mxr.mozilla.org/mozilla-central/source/widget/public/nsIIdleService.idl"><code>widget/public/nsIIdleService.idl</code></a> </span>。 It is <span class="lang lang-en"><a href="../../../../en/Interfaces/About_Scriptable_Interfaces" rel="internal">scriptable</a> </span> and <span class="lang lang-en"> <a href="../../../../en/Interfaces/About_Frozen_Interfaces" rel="internal">unfrozen</a> (hasn't changed since Mozilla 1.9a) </span>. </span></p>
+<h2 id="Summary" name="Summary">概要</h2>
+<p>该服务可使您监测到空闲时间,例如,用户没有进行鼠标或者键盘等操作。您可直接捕获到空闲的时间,但一般,需要注册一个监听。</p>
+<p>目前<code> nsIIdleService</code> 服务在 Windows, Mac OS X, and Linux (via XScreenSaver) 等系统上都已实现。</p>
+<p>实现: <code>@mozilla.org/widget/idleservice;1</code>。创建实例如:</p>
+<pre class="eval">var idleService = Components.classes["@mozilla.org/widget/idleservice;1"]
+ .getService(Components.interfaces.nsIIdleService)
+</pre>
+<h2 id="Method_overview" name="Method_overview">方法预览</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>void <a href="#addIdleObserver.28.29">addIdleObserver</a>(in <a href="/en/nsIObserver" title="en/nsIObserver">nsIObserver</a> observer, in unsigned long time)</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#removeIdleObserver.28.29">removeIdleObserver</a>(in <a href="/en/nsIObserver" title="en/nsIObserver">nsIObserver</a> observer, in unsigned long time)</code></td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Attributes" name="Attributes">属性</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">属性</td>
+ <td class="header">类型</td>
+ <td class="header">描述</td>
+ </tr>
+ <tr>
+ <td><code>idleTime</code></td>
+ <td><code>long</code></td>
+ <td>The amount of time in milliseconds that has passed since the last user activity. <em>Read only.</em></td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Methods" name="Methods">方法</h2>
+<h3 id="addIdleObserver.28.29" name="addIdleObserver.28.29">addIdleObserver()</h3>
+<p>添加一个observer,用于侦听使用者何时离开,及何时归来。</p>
+<pre class="eval">void addIdleObserver(
+ in nsIObserver observer,
+ in unsigned long time
+)
+</pre>
+<h6 id="Parameters" name="Parameters">参数 </h6>
+<dl>
+ <dt>
+ <code>observer</code></dt>
+ <dd>
+ The <a href="/en/nsIObserver" title="en/nsIObserver">observer</a> to be notified.</dd>
+</dl>
+<dl>
+ <dt>
+ <code>time</code></dt>
+ <dd>
+    使用者离开多少秒钟后,开始侦听。</dd>
+</dl>
+<h6 id="Remarks" name="Remarks">备注</h6>
+<ul>
+ <li>observer 侦听的 subject 一直是 nsIIdleSerivce 。当空闲时, observer 的 topic 是 'idle' , 当他回来时,将为 'back' 。侦听的参数中包含当前使用空闲的时间。</li>
+</ul>
+<ul>
+ <li>相同的 observer 可以添加两次。</li>
+</ul>
+<ul>
+ <li>大多数实现需要自己在 OS 中查询 idle 信息,侦听可能会出现延迟,这取决于在实现中查询的间隔时间的长度。当前实现中使用的是 5 秒钟的延迟时间。</li>
+</ul>
+<p></p><div class="blockIndicator geckoMinVer standardNote">
+ <div style="text-align: center; font-weight: bold; padding-bottom: 0.5em;">Gecko 1.9.2 note</div>
+ <div>从版本 Gecko 1.9.2 开始,增加一个新的侦听消息:‘idle-daily’ 。</div>
+</div><p></p>
+<h3 id="removeIdleObserver.28.29" name="removeIdleObserver.28.29">removeIdleObserver()</h3>
+<p>删除observer。</p>
+<pre class="eval">void removeIdleObserver(
+ in nsIObserver observer,
+ in unsigned long time
+)
+</pre>
+<h6 id="Parameters_2" name="Parameters_2">参数</h6>
+<dl>
+ <dt>
+ <code>observer</code></dt>
+ <dd>
+ the <a href="/en/nsIObserver" title="en/nsIObserver">observer</a> to be removed</dd>
+</dl>
+<dl>
+ <dt>
+ <code>time</code></dt>
+ <dd>
+ 消息侦听的时间(一段时间)。</dd>
+</dl>
+<p>备注</p>
+<p>删除 observer 时,根据指定的 idle 时间来删除。如果已经添加了多个 observer ,则需要删除多次。</p>
+<h2 id="Example_Code" name="Example_Code">示例:</h2>
+<p>例一:</p>
+<pre class="eval">var idleService = Components.classes["@mozilla.org/widget/idleservice;1"]
+ .getService(Components.interfaces.nsIIdleService)
+setTimeout(function() { alert(idleService.idleTime) }, 1000)
+// if you don't use the mouse or the keyboard after running this snippet,
+// you'll see a number around 1000 alerted.
+</pre>
+<p>例二:</p>
+<pre class="eval">var idleService = Components.classes["@mozilla.org/widget/idleservice;1"]
+ .getService(Components.interfaces.nsIIdleService)
+var idleObserver = {
+ observe: function(subject, topic, data) {
+ alert("topic: " + topic + "\ndata: " + data);
+ }
+};
+idleService.addIdleObserver(idleObserver, 60); // one minute
+// ...
+// Don't forget to remove the observer using removeIdleObserver!
+idleService.removeIdleObserver(idleObserver, 60);
+</pre>
+<p><span class="comment">Interwiki Language Links</span></p>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsilocalfile/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsilocalfile/index.html
new file mode 100644
index 0000000000..882450bf87
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsilocalfile/index.html
@@ -0,0 +1,478 @@
+---
+title: nsILocalFile
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile
+---
+<p> </p>
+
+<div class="note">
+<p>In <span title="(Firefox 14 / Thunderbird 14 / SeaMonkey 2.11)">Gecko 14</span> this Interface was merged into the <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile" title="">nsIFile</a></code> interface.</p>
+</div>
+
+<p> </p>
+
+<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/io/nsILocalFile.idl" rel="custom">xpcom/io/nsILocalFile.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">
+
+This interface adds methods to <code>nsIFile</code> that are particular to a file that is accessible via the local file system.
+</span>
+
+ <div style="height: 42px; position: relative; padding: 2px; width: auto;">
+
+ <div style="top: 22px; font-size: 11px; position: absolute; left: 0px; text-align: right; float: right; width: 100%;">66</div>
+
+<div style="height: 8px; top: 16px; left: 0%; background: #00dd00; position: absolute; width: 25.71428571428571%;" title="Introduced in Gecko 1.0 "></div>
+
+<div style="top: 0px; font-size: 11px; position: absolute; left: 0%;">Introduced</div>
+<div style="top: 22px; font-size: 11px; position: absolute; left: 0%;">Gecko 1.0</div>
+
+ <div style="height: 8px; top: 16px; left: 25.71428571428571%; background: #ff8000; position: absolute; width: 74.28571428571429%;" title="Deprecated in Gecko 14 (Firefox 14 / Thunderbird 14 / SeaMonkey 2.11)"></div>
+
+ <div style="top: 0px; font-size: 11px; position: absolute; left: 25.71428571428571%;">Deprecated</div>
+ <div style="top: 22px; font-size: 11px; position: absolute; left: 25.71428571428571%;">Gecko 14</div>
+
+</div>
+
+<div style="background: #eee; padding: 2px;">
+继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile" title="">nsIFile</a></code>
+<span style="text-align: right; float: right;">最后修改于Gecko 1.0 </span></div>
+</div><p></p>
+
+<p>Implemented by: <code>@mozilla.org/file/local;1</code>. To create an instance, use:</p>
+
+<pre class="eval">var localFile = Components.classes["@mozilla.org/file/local;1"]
+ .createInstance(Components.interfaces.nsILocalFile);
+</pre>
+
+<h2 id="Method_overview" name="Method_overview">Method overview</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>void <a href="#appendRelativeNativePath()">appendRelativeNativePath</a>(in ACString relativeFilePath);</code> <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#appendRelativePath()">appendRelativePath</a>(in AString relativeFilePath);</code></td>
+ </tr>
+ <tr>
+ <td><code>ACString <a href="#getRelativeDescriptor()">getRelativeDescriptor</a>(in nsILocalFile fromFile);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#initWithFile()">initWithFile</a>(in nsILocalFile aFile);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#initWithNativePath()">initWithNativePath</a>(in ACString filePath);</code> <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#initWithPath()">initWithPath</a>(in AString filePath);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#launch()">launch</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>PRLibraryStar <a href="#load()">load</a>();</code> <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>FILE <a href="#openANSIFileDesc()">openANSIFileDesc</a>(in string mode);</code> <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>PRFileDescStar <a href="#openNSPRFileDesc()">openNSPRFileDesc</a>(in long flags, in long mode);</code> <span class="inlineIndicator noscript noscriptInline" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#reveal()">reveal</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#setRelativeDescriptor()">setRelativeDescriptor</a>(in nsILocalFile fromFile, in ACString relativeDesc);</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Attributes" name="Attributes">Attributes</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Attribute</td>
+ <td class="header">Type</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>diskSpaceAvailable</code></td>
+ <td><code><a href="/zh-cn/PRInt64" title="zh-cn/PRInt64">PRInt64</a></code></td>
+ <td>The number of bytes available to non-superuser on the disk volume containing the <code>nsILocalFile</code>. <strong>Read only.</strong></td>
+ </tr>
+ <tr>
+ <td><code>followLinks</code></td>
+ <td><code><a href="/zh-cn/PRBool" title="zh-cn/PRBool">PRBool</a></code></td>
+ <td>
+ <p>Determines whether or not the <code>nsILocalFile</code> will automatically resolve symbolic links.</p>
+ By default, this value is <code>false</code> on all non-UNIX systems. As of Mozilla 1.7, this attribute is ignored on UNIX systems.</td>
+ </tr>
+ <tr>
+ <td><code>persistentDescriptor</code></td>
+ <td><code><a href="/zh-cn/ACString" title="zh-cn/ACString">ACString</a></code></td>
+ <td>
+ <p>On some platforms, the value of <a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsIFile#path">nsIFile.path</a> may be insufficient to uniquely identify the file on the local file system. The persistent descriptor is intended to be used whenever a <code>nsILocalFile</code> needs to be serialized to disk and later recovered. This string is not intended for display to users.</p>
+ <div class="blockIndicator note"><strong>Note:</strong> The value of the <code>followLinks</code> attribute is not encoded in the persistent descriptor.</div></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Constants" name="Constants">Constants</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Constant</td>
+ <td class="header">Value</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>DELETE_ON_CLOSE</code></td>
+ <td><code>0x80000000</code></td>
+ <td>Optional parameter used by <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile#openNSPRFileDesc()">openNSPRFileDesc()</a></code>. </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Methods" name="Methods">Methods</h2>
+
+<p></p><div><span class="indicatorInHeadline noscript noscriptMethod" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span><h3 id="appendRelativeNativePath">appendRelativeNativePath</h3></div><p></p>
+
+<p>Appends a relative, native character encoding, path to the current path of the <code>nsILocalFile</code> object.</p>
+
+<pre class="eval">void appendRelativeNativePath(
+ in ACString relativeFilePath
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>relativeFilePath</code></dt>
+ <dd>A native relative path. For security reasons, this cannot contain '..' or cannot start with a directory separator '.'. Must be in the native file system character set.</dd>
+</dl>
+
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+
+<dl>
+ <dt><code>NS_ERROR_FILE_UNRECOGNIZED_PATH</code></dt>
+ <dd>Indicates that <code>relativeFilePath</code> incorrectly begins with a path separator character or otherwise contains invalid characters.</dd>
+</dl>
+
+<h3 id="appendRelativePath()" name="appendRelativePath()">appendRelativePath()</h3>
+
+<p>Appends a relative native path to the current path of the <code>nsILocalFile</code> object.</p>
+
+<pre class="eval">void appendRelativePath(
+ in AString relativeFilePath
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>relativeFilePath</code></dt>
+ <dd>A native relative path. For security reasons, this cannot contain '..' or cannot start with a directory separator '.' .</dd>
+</dl>
+
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+
+<dl>
+ <dt><code>NS_ERROR_FILE_UNRECOGNIZED_PATH</code></dt>
+ <dd>Indicates that <code>relativeFilePath</code> incorrectly begins with a path separator character or otherwise contains invalid characters.</dd>
+</dl>
+
+<h3 id="getRelativeDescriptor()" name="getRelativeDescriptor()">getRelativeDescriptor()</h3>
+
+<p>Returns a relative file path in an opaque, cross platform format. It is therefore not a native path.</p>
+
+<pre class="eval">ACString getRelativeDescriptor(
+ in nsILocalFile fromFile
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>fromFile</code></dt>
+ <dd>The file from which the descriptor is relative. There is no defined result if this parameter is <code>null</code>.</dd>
+</dl>
+
+<h6 id="Return_value" name="Return_value">Return value</h6>
+
+<p>An opaque string value with undefined character encoding. This string is not intended for display to users.</p>
+
+<p>The result returned from this method may be used with <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile#setRelativeDescriptor()">setRelativeDescriptor()</a></code> to initialize a <code>nsILocalFile</code> instance.</p>
+
+<h3 id="initWithFile()" name="initWithFile()">initWithFile()</h3>
+
+<p>Initializes this object with another file.</p>
+
+<pre class="eval">void initWithFile(
+ in nsILocalFile aFile
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>aFile</code></dt>
+ <dd>The file this becomes equivalent to.</dd>
+</dl>
+
+<p></p><div><span class="indicatorInHeadline noscript noscriptMethod" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span><h3 id="initWithNativePath">initWithNativePath</h3></div><p></p>
+
+<p>Used to set the full path that this <code>nsILocalFile</code> references. All current settings will be reset.</p>
+
+<pre class="eval">void initWithNativePath(
+ in ACString filePath
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>filePath</code></dt>
+ <dd>A string that specifies a platform-specific, full path to a file or directory. Must be in the native file system character set.</dd>
+</dl>
+
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+
+<dl>
+ <dt><code>NS_ERROR_FILE_UNRECOGNIZED_PATH</code></dt>
+ <dd>Indicates that FilePath is not an absolute file path.</dd>
+</dl>
+
+<h3 id="initWithPath()" name="initWithPath()">initWithPath()</h3>
+
+<p>Used to set the full path that this <code>nsILocalFile</code> references. All current settings will be reset.</p>
+
+<pre class="eval">void initWithPath(
+ in AString filePath
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>filePath</code></dt>
+ <dd>A string that specifies a platform-specific, full path to a file or directory.</dd>
+</dl>
+
+<h6 id="Exceptions_thrown" name="Exceptions_thrown">Exceptions thrown</h6>
+
+<dl>
+ <dt><code>NS_ERROR_FILE_UNRECOGNIZED_PATH</code></dt>
+ <dd>Indicates that FilePath is not an absolute file path.</dd>
+</dl>
+
+<h3 id="launch()" name="launch()">launch()</h3>
+
+<p>Requests that the operating system attempt to open this file.</p>
+
+<pre class="eval">void launch();
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<p>None.</p>
+
+<p></p><div><span class="indicatorInHeadline noscript noscriptMethod" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span><h3 id="load">load</h3></div><p></p>
+
+<p>Returns the result of <a href="/zh-cn/PR_LoadLibrary" title="zh-cn/PR LoadLibrary"><code>PR_LoadLibrary()</code></a> on the file. The caller is responsible for calling <a href="/zh-cn/PR_UnloadLibrary" title="zh-cn/PR UnloadLibrary"><code>PR_UnloadLibrary()</code></a> on the result.</p>
+
+<pre class="eval">PRLibraryStar load();
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<p>None.</p>
+
+<h6 id="Return_value" name="Return_value">Return value</h6>
+
+<p>A pointer to a <a href="/zh-cn/PRLibrary" title="zh-cn/PRLibrary"><code>PRLibrary</code></a>.</p>
+
+<h6 id="Example" name="Example">Example</h6>
+
+<pre class="brush: cpp">#include "prlink.h"
+#include "nsError.h"
+#include "nsILocalFile.h"
+
+// Load the DLL corresponding to the given nsILocalFile...
+
+nsresult LoadDLL(nsILocalFile *aLocalFile)
+{
+ PRLibrary *dll;
+ nsresult rv = aLocalFile-&gt;Load(&amp;dll);
+ if (NS_FAILED(rv))
+ return rv;
+
+ // Do something with the library now that it is open...
+
+ PR_FreeLibrary(dll);
+ return NS_OK;
+}
+</pre>
+
+<p></p><div><span class="indicatorInHeadline noscript noscriptMethod" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span><h3 id="openANSIFileDesc">openANSIFileDesc</h3></div><p></p>
+
+<p>Returns the result of <code>fopen()</code> on the file. The caller is responsible for calling <code>fclose()</code> on the result.</p>
+
+<pre class="eval">FILE openANSIFileDesc(
+ in string mode
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>mode</code></dt>
+ <dd>An ANSI file open mode string, which will be passed to <code>fopen()</code>.</dd>
+</dl>
+
+<h6 id="Return_value" name="Return_value">Return value</h6>
+
+<p>A pointer to an ANSI <code>FILE</code> type.</p>
+
+<h6 id="Example" name="Example">Example</h6>
+
+<pre class="brush: cpp">#include &lt;stdio.h&gt;
+#include "nsError.h"
+#include "nsILocalFile.h"
+
+// Read the contents of a nsILocalFile...
+
+nsresult ReadLocalFile(nsILocalFile *aLocalFile)
+{
+ FILE *fp;
+ nsresult rv = aLocalFile-&gt;OpenANSIFileDesc("r", &amp;fp);
+ if (NS_FAILED(rv))
+ return rv;
+
+ char buf[512];
+ size_t n;
+
+ while ((n = fread(buf, sizeof(buf), 1, fp)) &gt; 0)
+ {
+ // Do something with n-byte block of data from file...
+ }
+
+ if (ferror(fp) != 0)
+ rv = NS_ERROR_UNEXPECTED;
+
+ fclose(fp);
+ return rv;
+}
+</pre>
+
+<p></p><div><span class="indicatorInHeadline noscript noscriptMethod" title="This method may only be called from C++; don't use it from JavaScript.">Native code only!</span><h3 id="openNSPRFileDesc">openNSPRFileDesc</h3></div><p></p>
+
+<p>Returns the result of <a href="/zh-cn/PR_Open" title="zh-cn/PR Open"><code>PR_Open()</code></a> on the file. The caller is responsible for calling <a href="/zh-cn/PR_Close" title="zh-cn/PR Close"><code>PR_Close()</code></a> on the result.</p>
+
+<pre class="eval">PRFileDescStar openNSPRFileDesc(
+ in long flags,
+ in long mode
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>flags</code></dt>
+ <dd>
+ <p>The <a href="/zh-cn/PR_Open" title="zh-cn/PR Open"><code>PR_Open()</code></a> flags from <code><a href="https://dxr.mozilla.org/mozilla-central/source/nsprpub/pr/include/prio.h" rel="custom">nsprpub/pr/include/prio.h</a></code>, plus optionally <code>DELETE_ON_CLOSE</code>. <code>DELETE_ON_CLOSE</code> may be implemented by removing the file (by path name) immediately after opening it, so beware of possible races; the file should be exclusively owned by this process.</p>
+
+ <p>A bitwise combination of the following open flags:</p>
+
+ <ul>
+ <li><code><strong>PR_RDONLY</strong></code> Open for reading only.</li>
+ <li><code><strong>PR_WRONLY</strong></code> Open for writing only.</li>
+ <li><code><strong>PR_RDWR</strong></code> Open for reading and writing.</li>
+ <li><code><strong>PR_CREATE_FILE</strong></code> If the file does not exist, the file is created. If the file exists, this flag has no effect.</li>
+ <li><code><strong>PR_APPEND</strong></code> The file pointer is set to the end of the file prior to each write.</li>
+ <li><code><strong>PR_TRUNCATE</strong></code> If the file exists, its length is truncated to 0.</li>
+ <li><code><strong>PR_SYNC</strong></code> If set, each write will wait for both the file data and file status to be physically updated.</li>
+ <li><code><strong>PR_EXCL</strong></code> With <code>PR_CREATE_FILE</code>, if the file does not exist, the file is created. If the file already exists, no action and null is returned.</li>
+ <li><code><strong>DELETE_ON_CLOSE</strong></code> File will be deleted when closed.</li>
+ </ul>
+ </dd>
+ <dt><code>mode</code></dt>
+ <dd>A UNIX-style file permissions value. For example, the octal value 0600 may be used to limit read and write access to the current user of the system. This parameter may be ignored on systems that do not support file permissions.</dd>
+</dl>
+
+<h6 id="Return_value" name="Return_value">Return value</h6>
+
+<p>If the file is successfully opened, returns a pointer to the <a href="/zh-cn/PRFileDesc" title="zh-cn/PRFileDesc"><code>PRFileDesc</code></a> created for the newly opened file. Returns a null pointer if the open failed.</p>
+
+<h6 id="Example" name="Example">Example</h6>
+
+<pre class="brush: cpp">#include "prio.h"
+#include "nsError.h"
+#include "nsILocalFile.h"
+
+// Read the contents of a nsILocalFile...
+
+nsresult ReadLocalFile(nsILocalFile *aLocalFile)
+{
+ PRFileDesc *fd;
+ nsresult rv = aLocalFile-&gt;OpenNSPRFileDesc(PR_RDONLY, 0, &amp;fd);
+ if (NS_FAILED(rv))
+ return rv;
+
+ char buf[512];
+ PRInt32 n;
+
+ while ((n = PR_Read(fd, buf, sizeof(buf))) &gt; 0)
+ {
+ // Do something with n-byte block of data from file...
+ }
+
+ if (n &lt; 0)
+ rv = NS_ERROR_UNEXPECTED;
+
+ PR_Close(fd);
+ return rv;
+}
+</pre>
+
+<h3 id="reveal()" name="reveal()">reveal()</h3>
+
+<p>Ask the operating system to open the folder which contains this file or folder. This routine only works on platforms which support the ability to open a folder. See the note in the <a href="#Remarks">remarks</a> below.</p>
+
+<pre class="eval">void reveal();
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<p>None.</p>
+
+<h3 id="setRelativeDescriptor()" name="setRelativeDescriptor()">setRelativeDescriptor()</h3>
+
+<p>Initializes the file to the location relative to <code>fromFile</code> using a string returned by <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile#getRelativeDescriptor()">getRelativeDescriptor()</a></code>.</p>
+
+<pre class="eval">void setRelativeDescriptor(
+ in nsILocalFile fromFile,
+ in ACString relativeDesc
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>fromFile</code></dt>
+ <dd>The file to which the descriptor is relative.</dd>
+ <dt><code>relativeDesc</code></dt>
+ <dd>The relative descriptor obtained from <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile#getRelativeDescriptor()">getRelativeDescriptor()</a></code>.</dd>
+</dl>
+
+<h2 id="Remarks" name="Remarks">Remarks</h2>
+
+<p>The methods <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile#initWithNativePath()">initWithNativePath()</a></code> and <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile#appendRelativeNativePath()">appendRelativeNativePath()</a></code> take string valued parameters that are encoded using the native character encoding. That means, you cannot deal with files whose name contain characters outside the default code page on Windows even though Windows 2000 or later has no problem with them. Therefore, <strong>never</strong> use these functions unless you are absolutely sure that the path passed to them is <strong>always</strong> ASCII-only. See <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile" title="">nsIFile</a></code> for more information on the native character encoding.</p>
+
+<h2 id="See_also" name="See_also">See also</h2>
+
+<ul>
+ <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile" title="">nsIFile</a></code></li>
+</ul>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiprocess/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiprocess/index.html
new file mode 100644
index 0000000000..1abc109440
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiprocess/index.html
@@ -0,0 +1,283 @@
+---
+title: nsIProcess
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIProcess
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIProcess
+---
+<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/threads/nsIProcess.idl" rel="custom">xpcom/threads/nsIProcess.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">
+
+This interface represents an executable process.
+</span>
+
+<div style="background: #eee; padding: 2px;">
+继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code>
+<span style="text-align: right; float: right;">最后修改于Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)</span></div>
+</div><p></p>
+<p>Implemented by: <code>@mozilla.org/process/util;1</code>. To create an instance, use:</p>
+<pre class="eval">var process = Components.classes["@mozilla.org/process/util;1"]
+ .createInstance(Components.interfaces.nsIProcess);
+</pre>
+<h2 id="Method_overview" name="Method_overview">Method overview</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>void <a href="#init()">init</a>(in nsIFile executable);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#initWithPid()">initWithPid</a>(in unsigned long pid);</code> <span class="inlineIndicator obsolete obsoleteInline" title="(Firefox 3.6 / Thunderbird 3.1 / Fennec 1.0)">已废弃 Gecko 1.9.2</span></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#kill()">kill</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#run()">run</a>(in boolean blocking, [array, size_is(count)] in string args, in unsigned long count);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#runAsync()">runAsync</a>([array, size_is(count)] in string args, in unsigned long count, [optional] in nsIObserver observer, [optional] in boolean holdWeak);</code> </td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#runw()">runw</a>(in boolean blocking, [array, size_is(count)] in wstring args, in unsigned long count);</code> </td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#runwAsync()">runwAsync</a>([array, size_is(count)] in wstring args, in unsigned long count, [optional] in nsIObserver observer, [optional] in boolean holdWeak);</code> </td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Attributes" name="Attributes">属性</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">属性名称</td>
+ <td class="header">属性类型</td>
+ <td class="header">属性描述</td>
+ </tr>
+ <tr>
+ <td><code>exitValue</code></td>
+ <td><code><a href="/zh-cn/long" title="zh-cn/long">long</a></code></td>
+ <td>The value returned by the process upon exit. This is only valid after the process has exited. <strong>Read only.</strong></td>
+ </tr>
+ <tr>
+ <td><code>isRunning</code></td>
+ <td><code><a href="/zh-cn/boolean" title="zh-cn/boolean">boolean</a></code></td>
+ <td><code>true</code> if the process is running, otherwise <code>false</code>. Only accurate if the process was run with blocking disabled. <strong>Read only.</strong> </td>
+ </tr>
+ <tr>
+ <td><code>location</code></td>
+ <td><code><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile" title="">nsIFile</a></code></code></td>
+ <td>
+ <p>The location of the executable file on disk. <strong>Read only.</strong></p>
+ <p></p><div class="blockIndicator geckoMinVer standardNote">
+ <div style="text-align: center; font-weight: bold; padding-bottom: 0.5em;">Gecko 1.9.1 note</div>
+ <div>This attribute is no longer implemented as of Gecko 1.9.1, and is removed entirely in Gecko 1.9.2.</div>
+</div><p></p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>pid</code></td>
+ <td><code><a href="/zh-cn/unsigned_long" title="zh-cn/unsigned long">unsigned long</a></code></td>
+ <td>The process ID of the process. This value is only available after the process has started; in addition, some platforms may not offer this value at all. <strong>Read only.</strong></td>
+ </tr>
+ <tr>
+ <td><code>processName</code></td>
+ <td><code><a href="/zh-cn/string" title="zh-cn/string">string</a></code></td>
+ <td>
+ <p>The name of the process. <strong>Read only.</strong></p>
+ <p></p><div class="blockIndicator geckoMinVer standardNote">
+ <div style="text-align: center; font-weight: bold; padding-bottom: 0.5em;">Gecko 1.9.1 note</div>
+ <div>This attribute is no longer implemented as of Gecko 1.9.1, and is removed entirely in Gecko 1.9.2.</div>
+</div><p></p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>processSignature</code></td>
+ <td><code><a href="/zh-cn/unsigned_long" title="zh-cn/unsigned long">unsigned long</a></code></td>
+ <td>
+ <p>The process signature. <strong>Read only.</strong></p>
+ <p></p><div class="blockIndicator geckoMinVer standardNote">
+ <div style="text-align: center; font-weight: bold; padding-bottom: 0.5em;">Gecko 1.9.1 note</div>
+ <div>This attribute is no longer implemented as of Gecko 1.9.1, and is removed entirely in Gecko 1.9.2.</div>
+</div><p></p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Methods" name="Methods">方法</h2>
+<h3 id="init()" name="init()">init()</h3>
+<p>Initializes the <code>nsIProcess</code> with the specified executable file. Once initialized, you can start the process executing by calling <code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIProcess#run()">run()</a></code>.</p>
+<p></p><div class="blockIndicator note"><strong>Note:</strong> This function does not work with application bundles on Mac OS X, see <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=307463" title="nsProcess::init fails for Mac OS X application bundles (foo.app)">bug 307463</a> for details.</div><p></p>
+<pre class="eval">void init(
+ in nsIFile executable
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl>
+ <dt>
+ <code>executable</code></dt>
+ <dd>
+ The <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile" title="">nsIFile</a></code> executable file to be represented by the <code>nsIProcess</code> object.</dd>
+</dl>
+<p></p><div class="headingWithIndicator">
+ <h3 id="initWithPid()">initWithPid()</h3>
+ <span class="indicatorInHeadline obsolete obsoleteMethod">已废弃 Gecko 1.9.2 (Firefox 3.6 / Thunderbird 3.1 / Fennec 1.0)</span>
+ </div><p></p>
+<p>Initializes the <code>nsIProcess</code> to represent an existing process, given that process's ID.</p>
+<p></p><div class="blockIndicator geckoMinVer standardNote">
+ <div style="text-align: center; font-weight: bold; padding-bottom: 0.5em;">Gecko 1.9.1 note</div>
+ <div>This method is no longer implemented as of Gecko 1.9.1, and is removed entirely in Gecko 1.9.2.</div>
+</div><p></p>
+<pre class="eval">void initWithPid(
+ in unsigned long pid
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl>
+ <dt>
+ <code>pid</code></dt>
+ <dd>
+ The process ID to begin to represent.</dd>
+</dl>
+<h3 id="kill()" name="kill()">kill()</h3>
+<p>立即终止该<code>nsIProcess对象所代表的进程</code>,只在该进程是非阻塞方式启动的情况下才有效.</p>
+<p></p><div class="blockIndicator geckoMinVer standardNote">
+ <div style="text-align: center; font-weight: bold; padding-bottom: 0.5em;">Gecko 1.9.1 note</div>
+ <div>在Gecko 1.9.1 (Firefox 3.5)之前版本中, 该方法在Windows和Mac OS X下无效.目前此bug已经修复.</div>
+</div><p></p>
+<pre class="eval">void kill();
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<p>无.</p>
+<h3 id="run()" name="run()">run()</h3>
+<p>开始执行进程.</p>
+<p></p><div class="blockIndicator geckoMinVer standardNote">
+ <div style="text-align: center; font-weight: bold; padding-bottom: 0.5em;">Gecko 1.9.1 note</div>
+ <div>在Gecko 1.9.1 (Firefox 3.5)之前版本中,该方法会返回一个新执行进程的进程ID,目前已经不会返回任何值.</div>
+</div><p></p>
+<pre class="eval">void run(
+ in boolean blocking,
+ [array, size_is(count)] in string args,
+ in unsigned long count
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl>
+ <dt>
+ <code>blocking</code></dt>
+ <dd>
+ 如果为<code>true</code>,则该方法会阻塞,直到所打开的进程关闭为止,如果为<code>false</code>,则该方法会立即返回.</dd>
+ <dt>
+ <code>args</code></dt>
+ <dd>
+ An array of <code>count</code> arguments, using the native character set, to be passed to the executable on its command line.</dd>
+ <dt>
+ <code>count</code></dt>
+ <dd>
+ 参数<code>args中的参数个数</code>.</dd>
+</dl>
+<p></p><h3 id="runAsync()">runAsync()</h3><p></p>
+<p>Asynchronously runs the process with which the object was initialized, optionally calling an observer when the process finishes running.</p>
+<pre class="eval">void runAsync(
+ [array, size_is(count)] in string args,
+ in unsigned long count,
+ in nsIObserver observer, <span class="inlineIndicator optional optionalInline">可选</span>
+ in boolean holdWeak <span class="inlineIndicator optional optionalInline">可选</span>
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>args</code></dt>
+ <dd>
+ An array of arguments to pass into the process, using the native character set. This array must have <code>count</code> entries.</dd>
+ <dt>
+ <code>count</code></dt>
+ <dd>
+ The number of arguments passed in the <code>args</code> array.</dd>
+ <dt>
+ <code>observer</code> <span class="inlineIndicator optional optionalInline">可选</span></dt>
+ <dd>
+ An observer that will be notified when the process exits. The observer will receive this <code>nsIProcess</code> instance as the subject and "process-finished" or "process-failed" as the topic. The observer will be notified on the main thread.</dd>
+ <dt>
+ <code>holdWeak</code> <span class="inlineIndicator optional optionalInline">可选</span></dt>
+ <dd>
+ If <code>true</code>, a <a class="internal" href="/zh-cn/Weak_reference" title="zh-cn/Weak reference">weak reference</a> is used to hold the observer.</dd>
+ <dd>
+  </dd>
+</dl>
+<p></p><h3 id="runw()">runw()</h3><p></p>
+<p>Executes the file this object was initialized with.</p>
+<pre class="eval">void runw(
+ in boolean blocking,
+ [array, size_is(count)] in wstring args,
+ in unsigned long count
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>blocking</code></dt>
+ <dd>
+ If <code>true</code>, this method will block until the process terminates; if <code>false</code>, the method returns immediately.</dd>
+ <dt>
+ <code>args</code></dt>
+ <dd>
+ An array of <code>count</code> arguments, using UTF-16, to be passed to the executable on its command line.</dd>
+ <dt>
+ <code>count</code></dt>
+ <dd>
+ The number of arguments in the <code>args</code> array.</dd>
+</dl>
+<p></p><h3 id="runwAsync()">runwAsync()</h3><p></p>
+<p>Asynchronously runs the process with which the object was initialized, optionally calling an observer when the process finishes running.</p>
+<pre class="eval">void runwAsync(
+ [array, size_is(count)] in wstring args,
+ in unsigned long count,
+ in nsIObserver observer, <span class="inlineIndicator optional optionalInline">可选</span>
+ in boolean holdWeak <span class="inlineIndicator optional optionalInline">可选</span>
+);
+</pre>
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>args</code></dt>
+ <dd>
+ An array of arguments to pass into the process, using UTF-16. This array must have <code>count</code> entries.</dd>
+ <dt>
+ <code>count</code></dt>
+ <dd>
+ The number of arguments passed in the <code>args</code> array.</dd>
+ <dt>
+ <code>observer</code> <span class="inlineIndicator optional optionalInline">可选</span></dt>
+ <dd>
+ An observer that will be notified when the process exits. The observer will receive this <code>nsIProcess</code> instance as the subject and "process-finished" or "process-failed" as the topic. The observer will be notified on the main thread.</dd>
+ <dt>
+ <code>holdWeak</code> <span class="inlineIndicator optional optionalInline">可选</span></dt>
+ <dd>
+ If <code>true</code>, a <a class="internal" href="/zh-cn/Weak_reference" title="zh-cn/Weak reference">weak reference</a> is used to hold the observer.</dd>
+</dl>
+<h2 id="See_also" name="See_also">Example</h2>
+<pre class="brush: js">// create an nsILocalFile for the executable
+var file = Components.classes["@mozilla.org/file/local;1"]
+ .createInstance(Components.interfaces.nsILocalFile);
+file.initWithPath("c:\\myapp.exe");
+
+// create an nsIProcess
+var process = Components.classes["@mozilla.org/process/util;1"]
+ .createInstance(Components.interfaces.nsIProcess);
+process.init(file);
+
+// Run the process.
+// If first param is true, calling thread will be blocked until
+// called process terminates.
+// Second and third params are used to pass command-line arguments
+// to the process.
+var args = ["argument1", "argument2"];
+process.run(false, args, args.length);
+</pre>
+<h2 id="See_also" name="See_also">See also</h2>
+<ul>
+ <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile" title="">nsIFile</a></code></li>
+ <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile" title="">nsILocalFile</a></code></li>
+ <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIProcess2" title="">nsIProcess2</a></code> <span class="inlineIndicator obsolete obsoleteInline" title="(Firefox 3.6 / Thunderbird 3.1 / Fennec 1.0)">已废弃 Gecko 1.9.2</span></li>
+</ul>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiprompt/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiprompt/index.html
new file mode 100644
index 0000000000..9bd2106964
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiprompt/index.html
@@ -0,0 +1,55 @@
+---
+title: nsIPrompt
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIPrompt
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIPrompt
+---
+<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsIPrompt.idl" rel="custom">netwerk/base/public/nsIPrompt.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">
+
+This is the prompt interface which can be used without knowledge of a parent window. The parentage is hidden by the <code>GetInterface</code> though which it is obtained.
+</span>
+
+<div style="background: #eee; padding: 2px;">
+继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code>
+<span style="text-align: right; float: right;">最后修改于Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)</span></div>
+</div><p></p>
+<div class="note">
+ <strong>注:</strong> 本接口基本等价于<code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPromptService" title="">nsIPromptService</a></code>,只是没有parent <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindow" title="">nsIDOMWindow</a></code>这个参数.为了避免重复的文档,下面的所有方法都链接到了<code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPromptService" title="">nsIPromptService</a></code>.如果你准备使用这个接口,一定要删除那些方法中的<code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindow" title="">nsIDOMWindow</a></code>参数.</div>
+<p>Normally you would use the prompt service as it is more flexible, but sometimes a callback will request an <code>nsIPrompt</code> via <code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsIInterfaceRequestor#getInterface()">nsIInterfaceRequestor.getInterface()</a></code>. To get an instance, call the <code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsIWindowWatcher#getNewPrompter()">nsIWindowWatcher.getNewPrompter()</a></code>.</p>
+<h2 id="Method_overview" name="Method_overview">方法概述</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>void <a href="/zh-CN/docs/XPCOM_Interface_Reference/nsIPromptService#alert()" title="en/XPCOM_Interface_Reference/nsIPromptService#alert()">alert</a>(in wstring dialogTitle, in wstring text);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="/zh-CN/docs/XPCOM_Interface_Reference/nsIPromptService#alertCheck()" title="en/XPCOM_Interface_Reference/nsIPromptService#alertCheck()">alertCheck</a>(in wstring dialogTitle, in wstring text, in wstring checkMsg, inout boolean checkValue);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="/zh-CN/docs/XPCOM_Interface_Reference/nsIPromptService#confirm()" title="en/XPCOM_Interface_Reference/nsIPromptService#confirm()">confirm</a>(in wstring dialogTitle, in wstring text);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="/zh-CN/docs/XPCOM_Interface_Reference/nsIPromptService#confirmCheck()" title="en/XPCOM_Interface_Reference/nsIPromptService#confirmCheck()">confirmCheck</a>(in wstring dialogTitle, in wstring text, in wstring checkMsg, inout boolean checkValue);</code></td>
+ </tr>
+ <tr>
+ <td><code>PRInt32 <a href="/zh-CN/docs/XPCOM_Interface_Reference/nsIPromptService#confirmEx()" title="en/XPCOM_Interface_Reference/nsIPromptService#confirmEx()">confirmEx</a>(in wstring dialogTitle, in wstring text, in unsigned long buttonFlags, in wstring button0Title, in wstring button1Title, in wstring button2Title, in wstring checkMsg, inout boolean checkValue);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="/zh-CN/docs/XPCOM_Interface_Reference/nsIPromptService#prompt()" title="en/XPCOM_Interface_Reference/nsIPromptService#prompt()">prompt</a>(in wstring dialogTitle, in wstring text, inout wstring value, in wstring checkMsg, inout boolean checkValue);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="/zh-CN/docs/XPCOM_Interface_Reference/nsIPromptService#promptPassword()" title="en/XPCOM_Interface_Reference/nsIPromptService#promptPassword()">promptPassword</a>(in wstring dialogTitle, in wstring text, inout wstring password, in wstring checkMsg, inout boolean checkValue);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="/zh-CN/docs/XPCOM_Interface_Reference/nsIPromptService#promptUsernameAndPassword()" title="en/XPCOM_Interface_Reference/nsIPromptService#promptUsernameAndPassword()">promptUsernameAndPassword</a>(in wstring dialogTitle, in wstring text, inout wstring username, inout wstring password, in wstring checkMsg, inout boolean checkValue);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="/zh-CN/docs/XPCOM_Interface_Reference/nsIPromptService#select()" title="en/XPCOM_Interface_Reference/nsIPromptService#select()">select</a>(in wstring dialogTitle, in wstring text, in PRUint32 count, [array, size_is(count)] in wstring selectList, out long outSelection);</code></td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Constants" name="Constants">常量</h2>
+<p><code>nsIPrompt中的</code>按钮标识同样等同于<code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsIPromptService#Constants">nsIPromptService.Constants</a></code>中定义的那些.示例代码可以在这里找到: <a href="/zh-CN/docs/XPCOM_Interface_Reference/nsIPromptService#Using_the_button_flags" title="en/XPCOM_Interface_Reference/nsIPromptService#Using_the_button_flags">使用按钮标识</a></p>
+<h2 id="相关链接">相关链接</h2>
+<p><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPromptService" title="">nsIPromptService</a></code></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsipromptservice/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsipromptservice/index.html
new file mode 100644
index 0000000000..b194faca6b
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsipromptservice/index.html
@@ -0,0 +1,696 @@
+---
+title: nsIPromptService
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIPromptService
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIPromptService
+---
+<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/embedding/components/windowwatcher/public/nsIPromptService.idl" rel="custom">embedding/components/windowwatcher/public/nsIPromptService.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">该接口用来显示一些简单的对话框.在chrome上下文,你应该使用该接口的所属方法来替代常规的DOM方法,例如 <a href="/zh-CN/docs/Web/API/Window/alert" title='显示一个警告对话框,上面显示有指定的文本内容以及一个"确定"按钮。'><code>window.alert</code></a>, <a href="/zh-CN/docs/Web/API/Window/confirm" title="Window.confirm() 方法显示一个具有一个可选消息和两个按钮(确定和取消)的模态对话框 。"><code>window.confirm</code></a>, 等.</span>
+
+<div style="background: #eee; padding: 2px;">
+继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code>
+<span style="text-align: right; float: right;">最后修改于Gecko 1.7.5 </span></div>
+</div><p></p>
+<p>You can define access keys (or keyboard shortcuts) for buttons by including an ampersand ("&amp;") in front of the character that should be the access key for that button. If you need to include an ampersand in the button's text, use two of them, like this: "&amp;&amp;".</p>
+<div class="note">
+ <strong>Note:</strong> Some of these interface methods use <code>out</code> and <code>inout</code> parameters. In C++, <code>out</code> parameters are pointers. For JavaScript, they are extra work, as you can't use an <code>out</code> parameter directly. You need to wrap them in a temporary object, which can be either empty or have a <code>value</code> property set to the <code>out</code> parameter type. For more information on out parameters and JavaScript refer to <a href="/zh-cn/Working_with_out_parameters" title="zh-cn/Working with out parameters">Working with out parameters</a>.</div>
+<p>该接口由: <code>@mozilla.org/embedcomp/prompt-service;1</code> 组件实现,下面的代码可以得到一个promptService对象实例:</p>
+<pre>var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+</pre>
+<h2 id="Method_overview" name="Method_overview">方法概述</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>void <a href="#alert()">alert</a>(in <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindow" title="">nsIDOMWindow</a></code> aParent, in wstring aDialogTitle, in wstring aText);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="#alertCheck()">alertCheck</a>(in <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindow" title="">nsIDOMWindow</a></code> aParent, in wstring aDialogTitle, in wstring aText, in wstring aCheckMsg, inout boolean aCheckState);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#confirm()">confirm</a>(in <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindow" title="">nsIDOMWindow</a></code> aParent, in wstring aDialogTitle, in wstring aText);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#confirmCheck()">confirmCheck</a>(in <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindow" title="">nsIDOMWindow</a></code> aParent, in wstring aDialogTitle, in wstring aText, in wstring aCheckMsg, inout boolean aCheckState);</code></td>
+ </tr>
+ <tr>
+ <td><code>PRInt32 <a href="#confirmEx()">confirmEx</a>(in <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindow" title="">nsIDOMWindow</a></code> aParent,in wstring aDialogTitle,in wstring aText, in unsigned long aButtonFlags,in wstring aButton0Title, in wstring aButton1Title,in wstring aButton2Title,in wstring aCheckMsg, inout boolean aCheckState);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#prompt()">prompt</a>(in <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindow" title="">nsIDOMWindow</a></code> aParent, in wstring aDialogTitle, in wstring aText, inout wstring aValue, in wstring aCheckMsg, inout boolean aCheckState);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#promptUsernameAndPassword()">promptUsernameAndPassword</a>(in <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindow" title="">nsIDOMWindow</a></code> aParent, in wstring aDialogTitle, in wstring aText, inout wstring aUsername, inout wstring aPassword, in wstring aCheckMsg, inout boolean aCheckState);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#promptPassword()">promptPassword</a>(in <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindow" title="">nsIDOMWindow</a></code> aParent, in wstring aDialogTitle, in wstring aText, inout wstring aPassword, in wstring aCheckMsg, inout boolean aCheckState);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#select()">select</a>(in <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMWindow" title="">nsIDOMWindow</a></code> aParent, in wstring aDialogTitle, in wstring aText, in PRUint32 aCount, [array, size_is(aCount)] in wstring aSelectList, out long aOutSelection);</code></td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Constants" name="Constants">常量</h2>
+<p>The following flags are combined to form the <code>aButtonFlags</code> parameter passed to <a href="#confirmEx">confirmEx</a>. All flags are defined as <code>unsigned long</code> constants and can be accessed as <code>Components.interfaces.nsIPromptService.<em>flagname</em></code> from JavaScript and as nsIPromptService::<code><em>flagname</em></code> from C++.</p>
+<h3 id="Button_position_flags">Button position flags</h3>
+<p>On Linux and Mac, button 2 is on the left of the prompt, while buttons 1 and 0 are on the right. On Windows and OS/2, the buttons are centred in the order 0, 2, 1.</p>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Constant</td>
+ <td class="header">Value</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>BUTTON_POS_0</code></td>
+ <td><code>1</code></td>
+ <td>This is usually the button used to confirm the prompt. It typically has the label "OK", "Yes" or "Save".</td>
+ </tr>
+ <tr>
+ <td><code>BUTTON_POS_1</code></td>
+ <td><code>256</code></td>
+ <td>This is the button used to cancel the prompt. It typically has the label "Cancel" or "No". It is equivalent to pressing the Escape key (or Cmd+. on the Mac), or closing the window through the OS controls.</td>
+ </tr>
+ <tr>
+ <td><code>BUTTON_POS_2</code></td>
+ <td><code>65536</code></td>
+ <td>This button can be used to give the user a choice of options, but still allowing the user to cancel the prompt. For instance, it might have the label "Don't Save".</td>
+ </tr>
+ </tbody>
+</table>
+<h3 id="Button_title_flags">Button title flags</h3>
+<p>These flags are used along with <a href="#Button_position_flags">Button position flags</a> to set the labels of buttons in the prompt.</p>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Constant</td>
+ <td class="header">Value</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>BUTTON_TITLE_OK</code></td>
+ <td><code>1</code></td>
+ <td rowspan="7"> These flags are used to select standard labels from the user's current locale.</td>
+ </tr>
+ <tr>
+ <td><code>BUTTON_TITLE_CANCEL</code></td>
+ <td><code>2</code></td>
+ </tr>
+ <tr>
+ <td><code>BUTTON_TITLE_YES</code></td>
+ <td><code>3</code></td>
+ </tr>
+ <tr>
+ <td><code>BUTTON_TITLE_NO</code></td>
+ <td><code>4</code></td>
+ </tr>
+ <tr>
+ <td><code>BUTTON_TITLE_SAVE</code></td>
+ <td><code>5</code></td>
+ </tr>
+ <tr>
+ <td><code>BUTTON_TITLE_DONT_SAVE</code></td>
+ <td><code>6</code></td>
+ </tr>
+ <tr>
+ <td><code>BUTTON_TITLE_REVERT</code></td>
+ <td><code>7</code></td>
+ </tr>
+ <tr>
+ <td><code>BUTTON_TITLE_IS_STRING</code></td>
+ <td><code>127</code></td>
+ <td>This flag indicates that the label is passed as a separate string. Use this for labels that don't match one of the constants above.</td>
+ </tr>
+ </tbody>
+</table>
+<h3 id="Button_default_flags">Button default flags</h3>
+<p>These flags are used to select which button is the default.</p>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Constant</td>
+ <td class="header">Value</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td>BUTTON_POS_0_DEFAULT</td>
+ <td>0</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>BUTTON_POS_1_DEFAULT</td>
+ <td>16777216</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>BUTTON_POS_2_DEFAULT</td>
+ <td>33554432</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+<h3 id="BUTTON_DELAY_ENABLE">BUTTON_DELAY_ENABLE</h3>
+<p><code>BUTTON_DELAY_ENABLE</code> causes the buttons to be initially disabled. They are enabled after a timeout expires. The implementation may interpret this loosely, as the intent is to ensure that the user does not click through a security dialog too quickly. Strictly speaking, the implementation could choose to ignore this flag. A delay can be useful not only to give the user more time to think before acting, but also as a countermeasure against malicious web sites that intentionally create a race condition whereby the user intends to click or type a key responding, for example, to the web site's prompt but the security dialog pops up unexpectedly and its button is unintentionally activated.</p>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Constant</td>
+ <td class="header">Value</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td>BUTTON_DELAY_ENABLE</td>
+ <td>67108864</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+<h3 id="Standard_Buttons_flags">Standard Buttons flags</h3>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Constant</td>
+ <td class="header">Value</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>STD_OK_CANCEL_BUTTONS</code></td>
+ <td>513</td>
+ <td>
+ <p>selects the standard set of OK/Cancel buttons.</p>
+ <code>(BUTTON_TITLE_OK *BUTTON_POS_0) +(BUTTON_TITLE_CANCEL * BUTTON_POS_1)</code></td>
+ </tr>
+ <tr>
+ <td><code>STD_YES_NO_BUTTONS</code></td>
+ <td>1027</td>
+ <td>
+ <p>selects the standard set of Yes/No buttons.</p>
+ <code>(BUTTON_TITLE_YES *BUTTON_POS_0) +(BUTTON_TITLE_NO * BUTTON_POS_1)</code></td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Methods" name="Methods">方法</h2>
+<h3 id="alert()">alert()</h3>
+<p><code>alert</code> 方法显示一个警告对话框,包含一个确认按钮. 除了可以设置对话框的标题以外,效果和<a href="/zh-CN/docs/Web/API/Window/alert" title='显示一个警告对话框,上面显示有指定的文本内容以及一个"确定"按钮。'><code>window.alert</code></a>全都相同 . 在chrome上下文,你应该使用该xpcom方法来替代<code>window.alert</code>.</p>
+<pre>void alert(
+ in nsIDOMWindow aParent,
+ in wstring aDialogTitle,
+ in wstring aText
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl>
+ <dt>
+ <code>aParent</code></dt>
+ <dd>
+ 对话框的父窗口,如果该值设为 <code>null</code>,则父窗口为当前激活的窗口 <code>nsIWindowWatcher.activeWindow</code>.</dd>
+ <dt>
+ <code>aDialogTitle</code></dt>
+ <dd>
+ 对话框的标题文字.</dd>
+ <dt>
+ <code>aText</code></dt>
+ <dd>
+ 对话框的内容文字.</dd>
+</dl>
+<p>代码示例:<a href="#alert_example">alert_example</a>.</p>
+<h3 id="alertCheck()">alertCheck()</h3>
+<p>显示一个警告对话框,包含一个确认按钮和一个复选框.</p>
+<pre>void alertCheck(
+ in nsIDOMWindow aParent,
+ in wstring aDialogTitle,
+ in wstring aText,
+ in wstring aCheckMsg,
+ inout boolean aCheckState
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl>
+ <dt>
+ <code>aParent</code></dt>
+ <dd>
+ 对话框的父窗口,如果该值设为 <code>null</code>,则父窗口为当前激活的窗口 <code>nsIWindowWatcher.activeWindow</code>..</dd>
+ <dt>
+ <code>aDialogTitle</code></dt>
+ <dd>
+ 对话框的标题文字.</dd>
+ <dt>
+ <code>aText</code></dt>
+ <dd>
+ 对话框的内容文字.</dd>
+ <dt>
+ <code>aCheckMsg</code></dt>
+ <dd>
+ 复选框的说明文字.</dd>
+ <dt>
+ <code>aCheckState</code></dt>
+ <dd>
+ 该变量是一个对象引用,当对话框打开时,变量的value属性控制了复选框的初始选择状态.当对话框关闭时,变量的value属性会存储下复选框的最后选择状态.该变量初始化时可以包含一个类型为布尔值的value属性或者是空对象.</dd>
+</dl>
+<p>代码示例:<a href="#alertCheck_example">alertCheck_example</a>.</p>
+<h3 id="confirm()">confirm()</h3>
+<p>显示一个确认对话框,包含一个确认按钮和一个取消按钮.</p>
+<pre>boolean confirm(
+ in nsIDOMWindow aParent,
+ in wstring aDialogTitle,
+ in wstring aText
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl>
+ <dt>
+ <code>aParent</code></dt>
+ <dd>
+ 对话框的父窗口,如果该值设为 <code>null</code>,则父窗口为当前激活的窗口 <code>nsIWindowWatcher.activeWindow</code>.</dd>
+ <dt>
+ <code>aDialogTitle</code></dt>
+ <dd>
+ 对话框的标题文字.</dd>
+ <dt>
+ <code>aText</code></dt>
+ <dd>
+ 对话框的内容文字.</dd>
+</dl>
+<h6 id="Return_value" name="Return_value">返回值</h6>
+<dl>
+ <dd>
+ 点确定按钮返回 <code>true</code> , 点取消按钮返回 <code>false</code></dd>
+</dl>
+<p>代码示例:<a href="#confirm_example">confirm_example</a>.</p>
+<h3 id="confirmCheck()">confirmCheck()</h3>
+<p>显示一个对话框,包含一个确认按钮,一个取消按钮和一个复选框.</p>
+<p>代码示例:<a href="#confirm_example">confirm_example</a>.</p>
+<pre>boolean confirmCheck(
+ in nsIDOMWindow aParent,
+ in wstring aDialogTitle,
+ in wstring aText,
+ in wstring aCheckMsg,
+ inout boolean aCheckState
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl>
+ <dt>
+ <code>aParent</code></dt>
+ <dd>
+ 对话框的父窗口,如果该值设为 <code>null</code>,则父窗口为当前激活的窗口 <code>nsIWindowWatcher.activeWindow</code>.</dd>
+ <dt>
+ <code>aDialogTitle</code></dt>
+ <dd>
+ 对话框的标题文字.</dd>
+ <dt>
+ <code>aText</code></dt>
+ <dd>
+ 对话框的内容文字.</dd>
+ <dt>
+ <code>aCheckMsg</code></dt>
+ <dd>
+ 复选框的说明文字.</dd>
+ <dt>
+ <code>aCheckState</code></dt>
+ <dd>
+ 该变量是一个对象引用,当对话框打开时,变量的value属性控制了复选框的初始选择状态.当对话框关闭时,变量的value属性会存储下复选框的最后选择状态.该变量初始化时可以包含一个类型为布尔值的value属性或者是空对象.</dd>
+</dl>
+<h6 id="Return_value" name="Return_value">返回值</h6>
+<dl>
+ <dd>
+ 点确定按钮返回 <code>true</code> , 点取消按钮返回 <code>false</code></dd>
+</dl>
+<h3 id="confirmEx()">confirmEx()</h3>
+<p>Puts up a dialog with up to 3 buttons and an optional, labeled checkbox.</p>
+<p>The Buttons are numbered 0 - 2. The implementation can decide what order the buttons appear in, and it may not be simply right-to-left (2, 1, 0) or left-to-right (0, 1, 2). See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=624043" title="nsIPromptService.confirmEx : buttons show up in the order 0,2,1 instead of 0,1,2">bug 624043</a> for more on this. Button 0 is the default button unless one of the Button Default Flags is specified (see <a href="/zh-cn/XPCOM_Interface_Reference/nsIPromptService#Button_default_flags" title="https://developer.mozilla.org/zh-cn/XPCOM_Interface_Reference/nsIPromptService#Button_default_flags">Button default flags</a>).</p>
+<p>A button may use a predefined title, specified by one of the Button Title Flags values. Each title value can be multiplied by a position value to assign the title to a particular button. If BUTTON_TITLE_IS_STRING is used for a button, the string parameter for that button will be used. If the value for a button position is zero, the button will not be shown.</p>
+<p>The following Example creates a Dialog with an OK button an an custom button description.</p>
+<p><code>aButtonFlags = (BUTTON_POS_0) * (BUTTON_TITLE_OK) +<br>
+ (BUTTON_POS_1) * (BUTTON_TITLE_IS_STRING) +<br>
+ BUTTON_POS_1_DEFAULT; </code></p>
+<div class="note">
+ confirmEx always returns 1 if the user closes the window using the close button in the titlebar! <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=345067" title="Issues with prompt service's confirmEx - confirmEx always returns 1 when user closes dialog window using the X button in titlebar">bug 345067</a></div>
+<pre>PRInt32 confirmEx(
+ in nsIDOMWindow aParent,
+ in wstring aDialogTitle,
+ in wstring aText,
+ in unsigned long aButtonFlags,
+ in wstring aButton0Title,
+ in wstring aButton1Title,
+ in wstring aButton2Title,
+ in wstring aCheckMsg,
+ inout boolean aCheckState
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl>
+ <dt>
+ <code>aParent</code></dt>
+ <dd>
+ 对话框的父窗口,如果该值设为 <code>null</code>,则父窗口为当前激活的窗口 <code>nsIWindowWatcher.activeWindow</code>.</dd>
+ <dt>
+ <code>aDialogTitle</code></dt>
+ <dd>
+ 对话框的标题文字.</dd>
+ <dt>
+ <code>aText</code></dt>
+ <dd>
+ 对话框的内容文字.</dd>
+ <dt>
+ <code>aButtonFlags</code></dt>
+ <dd>
+ <code>aButtonFlags</code> is a combination of <a href="#Button_flags">Button flags</a> as described in <a href="#Using_the_button_flags">Using the button flags</a> below.</dd>
+ <dt>
+ <code>aButton0Title</code></dt>
+ <dd>
+ caption displayed for button 0 if<code>(BUTTON_TITLE_IS_STRING*</code><code>BUTTON_TITLE_POS_0)</code> flags are set in aButtonFlags</dd>
+ <dt>
+ <code>aButton1Title</code></dt>
+ <dd>
+ caption displayed for button 1 if<code>(BUTTON_TITLE_IS_STRING*</code><code>BUTTON_TITLE_POS_1)</code> flags are set in aButtonFlags</dd>
+ <dt>
+ <code>aButton2Title</code></dt>
+ <dd>
+ caption displayed for button 2 if<code>(BUTTON_TITLE_IS_STRING*</code><code>BUTTON_TITLE_POS_2)</code> flags are set in aButtonFlags</dd>
+ <dt>
+ <code>aCheckMsg</code></dt>
+ <dd>
+  复选框的说明文字. 如果值设为Null,则复选框不会显示.</dd>
+ <dt>
+ <code>aCheckState</code></dt>
+ <dd>
+ 该变量是一个对象引用,当对话框打开时,变量的value属性控制了复选框的初始选择状态.当对话框关闭时,变量的value属性会存储下复选框的最后选择状态.该变量初始化时可以包含一个类型为布尔值的value属性或者是空对象.</dd>
+</dl>
+<h6 id="Return_value" name="Return_value">返回值</h6>
+<dl>
+ <dd>
+ 按下按钮的索引.</dd>
+</dl>
+<h3 id="prompt()">prompt()</h3>
+<p>显示一个对话框,包含一个文本框,一个可选的复选框.</p>
+<p>代码示例:<a href="#prompt_example">prompt_example</a>.</p>
+<pre>boolean prompt(
+ in nsIDOMWindow aParent,
+ in wstring aDialogTitle,
+ in wstring aText,
+ inout wstring aValue,
+ in wstring aCheckMsg,
+ inout boolean aCheckState
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl>
+ <dt>
+ <code>aParent</code></dt>
+ <dd>
+ 对话框的父窗口,如果该值设为 <code>null</code>,则父窗口为当前激活的窗口 <code>nsIWindowWatcher.activeWindow</code>.</dd>
+ <dt>
+ <code>aDialogTitle</code></dt>
+ <dd>
+ 对话框的标题文字.</dd>
+ <dt>
+ <code>aText</code></dt>
+ <dd>
+ 对话框的内容文字.</dd>
+ <dt>
+ <code>aValue</code></dt>
+ <dd>
+ 该变量是一个对象引用,当对话框打开时,变量的value属性值就是文本输入框的的初始值.当用户点击确认按钮关闭对话框时,变量的value属性会存储下文本输入框的最后确定值.其他方法关闭对话框时,变量的value属性值不会改变.该变量初始化时可以包含一个类型为字符串值的value属性或者是空对象.</dd>
+ <dt>
+ <code>aCheckMsg</code></dt>
+ <dd>
+ 复选框的说明文字. 如果值设为Null,则复选框不会显示.</dd>
+ <dt>
+ <code>aCheckState</code></dt>
+ <dd>
+ 该变量是一个对象引用,当对话框打开时,变量的value属性控制了复选框的初始选择状态.当对话框关闭时,变量的value属性会存储下复选框的最后选择状态.该变量初始化时可以包含一个类型为布尔值的value属性或者是空对象.</dd>
+</dl>
+<h6 id="Return_value" name="Return_value">返回值</h6>
+<dl>
+ <dd>
+ 点确定按钮返回 <code>true</code> , 点取消按钮返回 <code>false</code></dd>
+</dl>
+<h3 id="promptUsernameAndPassword()">promptUsernameAndPassword()</h3>
+<p>显示一个对话框,内部包含一个文本输入框,一个密码输入框,和一个可选的复选框.</p>
+<p>代码示例:<a href="#promptUsernameAndPassword_example">promptUsernameAndPassword_example</a>.</p>
+<pre>boolean promptUsernameAndPassword(
+ in nsIDOMWindow aParent,
+ in wstring aDialogTitle,
+ in wstring aText,
+ inout wstring aUsername,
+ inout wstring aPassword,
+ in wstring aCheckMsg,
+ inout boolean aCheckState
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl>
+ <dt>
+ <code>aParent</code></dt>
+ <dd>
+ 对话框的父窗口,如果该值设为 <code>null</code>,则父窗口为当前激活的窗口 <code>nsIWindowWatcher.activeWindow</code>.</dd>
+ <dt>
+ <code>aDialogTitle</code></dt>
+ <dd>
+ 对话框的标题文字.</dd>
+ <dt>
+ <code>aText</code></dt>
+ <dd>
+ 对话框的内容文字.</dd>
+ <dt>
+ <code>aUsername</code></dt>
+ <dd>
+ 该变量是一个对象引用,当对话框打开时,变量的value属性值就是用户名输入框的的初始值.当用户点击确认按钮关闭对话框时,变量的value属性会存储下用户名输入框的最后确定值.其他方法关闭对话框时,变量的value属性值不会改变.该变量初始化时可以包含一个类型为字符串值的value属性或者是空对象.</dd>
+ <dt>
+ <code>aPassword</code></dt>
+ <dd>
+ 该变量是一个对象引用,当对话框打开时,变量的value属性值就是密码输入框的的初始值.当用户点击确认按钮关闭对话框时,变量的value属性会存储下密码输入框的最后确定值.其他方法关闭对话框时,变量的value属性值不会改变.该变量初始化时可以包含一个类型为字符串值的value属性或者是空对象.</dd>
+ <dt>
+ <code>aCheckMsg</code></dt>
+ <dd>
+ 复选框的说明文字. 如果值设为Null,则复选框不会显示.</dd>
+ <dt>
+ <code>aCheckState</code></dt>
+ <dd>
+ 该变量是一个对象引用,当对话框打开时,变量的value属性控制了复选框的初始选择状态.当对话框关闭时,变量的value属性会存储下复选框的最后选择状态.该变量初始化时可以包含一个类型为布尔值的value属性或者是空对象.</dd>
+</dl>
+<h6 id="Return_value" name="Return_value">返回值</h6>
+<dl>
+ <dd>
+ 点确定按钮返回 <code>true</code> , 点取消按钮返回 <code>false</code></dd>
+</dl>
+<h3 id="promptPassword()">promptPassword()</h3>
+<p>显示一个对话框,包含一个密码框,一个可选的复选框.</p>
+<p>代码示例:<a href="#promptPassword_example">promptPassword_example</a>.</p>
+<pre>boolean promptPassword(
+ in nsIDOMWindow aParent,
+ in wstring aDialogTitle,
+ in wstring aText,
+ inout wstring aPassword,
+ in wstring aCheckMsg,
+ inout boolean aCheckState
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl>
+ <dt>
+ <code>aParent</code></dt>
+ <dd>
+ 对话框的父窗口,如果该值设为 <code>null</code>,则父窗口为当前激活的窗口 <code>nsIWindowWatcher.activeWindow</code>.</dd>
+ <dt>
+ <code>aDialogTitle</code></dt>
+ <dd>
+ 对话框的标题文字.</dd>
+ <dt>
+ <code>aText</code></dt>
+ <dd>
+ 对话框的内容文字.</dd>
+ <dt>
+ <code>aPassword</code></dt>
+ <dd>
+ 该变量是一个对象引用,当对话框打开时,变量的value属性值就是密码输入框的的初始值.当用户点击确认按钮关闭对话框时,变量的value属性会存储下密码输入框的最后确定值.其他方法关闭对话框时,变量的value属性值不会改变.该变量初始化时可以包含一个类型为字符串值的value属性或者是空对象.</dd>
+ <dt>
+ <code>aCheckMsg</code></dt>
+ <dd>
+ 复选框的说明文字. 如果值设为Null,则复选框不会显示.</dd>
+ <dt>
+ <code>aCheckState</code></dt>
+ <dd>
+     该变量是一个对象引用,当对话框打开时,变量的value属性控制了复选框的初始选择状态.当对话框关闭时,变量的value属性会存储下复选框的最后选择状态.该变量初始化时可以包含一个类型为布尔值的value属性或者是空对象.</dd>
+</dl>
+<h6 id="Return_value" name="Return_value">返回值</h6>
+<dl>
+ <dd>
+ 点确定按钮返回 <code>true</code> , 点取消按钮返回 <code>false</code></dd>
+</dl>
+<h3 id="select()">select()</h3>
+<p>显示一个对话框,包含一个单项选择的字符串列表.</p>
+<p>代码示例:<a href="#select_example">select_example</a>.</p>
+<pre>boolean select(
+ in nsIDOMWindow aParent,
+ in wstring aDialogTitle,
+ in wstring aText,
+ in PRUint32 aCount,
+ [array, size_is(aCount)] in wstring aSelectList,
+ out long aOutSelection
+);
+</pre>
+<dl>
+ <dt>
+ <code>aParent</code></dt>
+ <dd>
+ 对话框的父窗口,如果该值设为 <code>null</code>,则父窗口为当前激活的窗口 <code>nsIWindowWatcher.activeWindow</code>.</dd>
+ <dt>
+ <code>aDialogTitle</code></dt>
+ <dd>
+ 对话框的标题文字.</dd>
+ <dt>
+ <code>aText</code></dt>
+ <dd>
+ 对话框的内容文字.</dd>
+ <dt>
+ <code>aCount</code></dt>
+ <dd>
+ 参数aSelectList的数组长度.</dd>
+ <dt>
+ <code>aSelectList</code></dt>
+ <dd>
+ 构成字符串列表的字符串数组.</dd>
+ <dt>
+ <code>aOutSelection</code></dt>
+ <dd>
+ 该变量是一个对象引用,当用户选择某个项目后,变量的value属性值存储了用户所选列表项目的索引值.</dd>
+</dl>
+<h6 id="Return_value" name="Return_value">返回值</h6>
+<dl>
+ <dd>
+ 点确定按钮返回 <code>true</code> , 点取消按钮返回 <code>false</code></dd>
+</dl>
+<h2 id="代码示例">代码示例</h2>
+<p> </p>
+<h3 id="alert_example">alert example</h3>
+<p><a href="#alert()">alert()</a> 显示一个简单的对话框.</p>
+<p><img alt="" class="internal" src="/@api/deki/files/4072/=AlertExample.png" style="width: 365px; height: 129px;"></p>
+<pre class="brush: js">var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+prompts.alert(null, "Title of this Dialog", "Hello! You have now been alerted.");
+</pre>
+<h3 id="alertCheck_example">alertCheck example</h3>
+<p><a href="#alertCheck()">alertCheck()</a> 显示一个包含复选框的对话框</p>
+<p><img alt="" class="internal" src="/@api/deki/files/4073/=AlertCheckExample.png" style="width: 365px; height: 152px;"></p>
+<pre class="brush: js">var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+var check = {value: false}; // default the checkbox to false
+
+prompts.alertCheck(null, "Title of this Dialog", "Hello! You have now been alerted.",
+ "And this is a checkbox", check);
+
+// check.value is now true if the box was checked and false if the box was cleared
+</pre>
+<h3 id="confirm_example">confirm example</h3>
+<p><a href="#confirm()">confirm()</a> 显示一个提示框,内部包含一个确认按钮和一个取消按钮.</p>
+<pre class="brush: js">var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+var result = prompts.confirm(null, "Title of this Dialog", "Are you sure?");
+
+// result is now true if OK was clicked, and false if cancel was clicked
+</pre>
+<h3 id="confirmCheck_example">confirmCheck example</h3>
+<p><a href="#confirmCheck">confirmCheck</a> 显示一个提示框,内部包含一个确认按钮,一个取消按钮,一个复选框.</p>
+<pre class="brush: js">var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+var check = {value: true}; // default the checkbox to true
+
+var result = prompts.confirmCheck(null, "Title of this Dialog", "Are you sure?",
+ "Don't ask again", check);
+
+// check.value is now true if the box was checked AND OK was pressed, false if
+// the box was cleared AND OK was pressed, and is the default of true if Cancel was pressed.
+</pre>
+<h3 id="confirmEx_example">confirmEx example</h3>
+<p><a href="#confirmEx()">confirmEx()</a>  显示一个对话框,内部包含三个或三个以下的按纽,和一个可选的复选框.</p>
+<p><img alt="" class="internal" src="/@api/deki/files/4075/=confirmExExample.png" style="width: 365px; height: 129px;"></p>
+<pre class="brush: js">var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+var check = {value: false}; // default the checkbox to false
+
+var flags = prompts.BUTTON_POS_0 * prompts.BUTTON_TITLE_SAVE +
+ prompts.BUTTON_POS_1 * prompts.BUTTON_TITLE_IS_STRING +
+ prompts.BUTTON_POS_2 * prompts.BUTTON_TITLE_CANCEL;
+// This value of flags will create 3 buttons. The first will be "Save", the
+// second will be the value of aButtonTitle1, and the third will be "Cancel"
+
+var button = prompts.confirmEx(null, "Title of this Dialog", "What do you want to do?",
+ flags, "", "Button 1", "", null, check);
+
+// The checkbox will be hidden, and button will contain the index of the button pressed,
+// 0, 1, or 2.
+</pre>
+<h3 id="prompt_example">prompt example</h3>
+<p><a href="#prompt()">prompt()</a> 显示一个对话框,内部包含一个文本输入框.</p>
+<pre class="brush: js">var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+var check = {value: false}; // default the checkbox to false
+
+var input = {value: "Bob"}; // default the edit field to Bob
+
+var result = prompts.prompt(null, "Title", "What is your name?", input, null, check);
+
+// result is true if OK is pressed, false if Cancel. input.value holds the value of the edit field if "OK" was pressed.
+</pre>
+<h3 id="promptUsernameAndPassword_example">promptUsernameAndPassword example</h3>
+<p><a href="#promptUsernameAndPassword()">promptUsernameAndPassword()</a> 显示一个对话框,内部包含一个文本输入框,一个密码输入框和一个可选的复选框.</p>
+<p><img alt="" class="internal" src="/@api/deki/files/4076/=promptUsernameAndPasswordExample.png" style="width: 365px; height: 200px;"></p>
+<pre class="brush: js">var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+var username = {value: "user"}; // default the username to user
+
+var password = {value: "pass"}; // default the password to pass
+
+var check = {value: true}; // default the checkbox to true
+
+var result = prompts.promptUsernameAndPassword(null, "Title", "Enter username and password:",
+ username, password, "Save", check);
+
+// result is true if OK was pressed, false if cancel was pressed. username.value,
+// password.value, and check.value are set if OK was pressed.
+</pre>
+<h3 id="promptPassword_example">promptPassword example</h3>
+<p><a href="#promptPassword()">promptPassword()</a> 显示一个对话框,内部包含一个密码输入框和一个可选的复选框.</p>
+<pre class="brush: js">var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+var password = {value: "pass"}; // default the password to pass
+
+var check = {value: true}; // default the checkbox to true
+
+var result = prompts.promptPassword(null, "Title", "Enter password:", password, null, check);
+
+// result is true if OK was pressed, false if cancel was pressed. password.value is
+// set if OK was pressed. The checkbox is not displayed.
+</pre>
+<h3 id="select_example">select example</h3>
+<p><a href="#select()">select()</a> 显示一个对话框,内部是一个包含多个选项的列表框.</p>
+<p><img alt="" class="internal" src="/@api/deki/files/4074/=selectExample.png" style="width: 333px; height: 196px;"></p>
+<pre class="brush: js">var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+var items = ["Hello", "Welcome", "Howdy", "Hi", ":)"]; // list items
+
+var selected = {};
+
+var result = prompts.select(null, "Title", "What greeting do you want?", items.length,
+ items, selected);
+
+// result is true if OK was pressed, false if cancel. selected is the index of the item array
+// that was selected. Get the item using items[selected.value].
+</pre>
+<h2 id="See_also" name="See_also">相关链接</h2>
+<ul>
+ <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPrompt" title="">nsIPrompt</a></code></li>
+ <li><a href="/zh-cn/Working_with_out_parameters" title="zh-cn/Working with out parameters">Working with out parameters</a></li>
+</ul>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiscriptableunicodeconverter/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiscriptableunicodeconverter/index.html
new file mode 100644
index 0000000000..fe406f1bba
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiscriptableunicodeconverter/index.html
@@ -0,0 +1,609 @@
+---
+title: nsIScriptableUnicodeConverter
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIScriptableUnicodeConverter
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIScriptableUnicodeConverter
+---
+<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/intl/uconv/idl/nsIScriptableUConv.idl" rel="custom">intl/uconv/idl/nsIScriptableUConv.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">
+
+This interface is a Unicode encoder for use by scripts.
+</span>
+
+<div style="background: #eee; padding: 2px;">
+继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code>
+<span style="text-align: right; float: right;">最后修改于Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)</span></div>
+</div><p></p>
+<p>Implemented by: <code>@mozilla.org/intl/scriptableunicodeconverter</code>. To create an instance, use:</p>
+<pre class="eval">var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
+ .createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
+</pre>
+<h2 id="Method_overview" name="Method_overview">Method overview</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>ACString <a href="/zh-cn/XPCOM_Interface_Reference/nsIScriptableUnicodeConverter#ConvertFromUnicode()" title="zh-cn/nsIScriptableUnicodeConverter#ConvertFromUnicode()">ConvertFromUnicode</a>(in AString aSrc);</code></td>
+ </tr>
+ <tr>
+ <td><code>ACString <a href="/zh-cn/XPCOM_Interface_Reference/nsIScriptableUnicodeConverter#Finish()" title="zh-cn/nsIScriptableUnicodeConverter#Finish()">Finish</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>AString <a href="/zh-cn/XPCOM_Interface_Reference/nsIScriptableUnicodeConverter#ConvertToUnicode()" title="zh-cn/nsIScriptableUnicodeConverter#ConvertToUnicode()">ConvertToUnicode</a>(in ACString aSrc);</code></td>
+ </tr>
+ <tr>
+ <td><code>AString <a href="/zh-cn/XPCOM_Interface_Reference/nsIScriptableUnicodeConverter#convertFromByteArray()" title="zh-cn/nsIScriptableUnicodeConverter#convertFromByteArray()">convertFromByteArray</a>([const,array,size_is(aCount)] in octet aData, in unsigned long aCount);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="/zh-cn/XPCOM_Interface_Reference/nsIScriptableUnicodeConverter#convertToByteArray()" title="zh-cn/nsIScriptableUnicodeConverter#convertToByteArray()">convertToByteArray</a>(in AString aString,[optional] out unsigned long aLen,[array, size_is(aLen),retval] out octet aData);</code></td>
+ </tr>
+ <tr>
+ <td><code><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIInputStream" title="">nsIInputStream</a></code> <a href="/zh-cn/XPCOM_Interface_Reference/nsIScriptableUnicodeConverter#convertToInputStream()" title="zh-cn/nsIScriptableUnicodeConverter#convertToInputStream()">convertToInputStream</a>(in AString aString);</code></td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Attributes">Attributes</h2>
+<table class="standard-table" style="width: auto;">
+ <tbody>
+ <tr>
+ <td class="header">Attribute</td>
+ <td class="header">Type</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>charset</code></td>
+ <td><code>string</code></td>
+ <td>Current character set. Throws <code>NS_ERROR_UCONV_NOCONV</code> if the requested charset is not supported.</td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Methods" name="Methods">Methods</h2>
+<h3 id="ConvertFromUnicode()" name="ConvertFromUnicode()">ConvertFromUnicode()</h3>
+<p>Converts the data from Unicode to one Charset. Returns the converted string. After converting, Finish should be called and its return value appended to this return value.</p>
+<pre class="eval">ACString ConvertFromUnicode(
+ in AString aSrc
+);
+</pre>
+<h3 id="Finish()">Finish()</h3>
+<p>Returns the terminator string. Should be called after ConvertFromUnicode() and appended to that function's return value.</p>
+<pre>ACString Finish();
+</pre>
+<h3 id="ConvertToUnicode()">ConvertToUnicode()</h3>
+<p>Converts the data from one Charset to Unicode.</p>
+<pre>AString ConvertToUnicode(
+ in ACString aSrc
+);
+</pre>
+<h3 id="convertFromByteArray()">convertFromByteArray()</h3>
+<p>Converts an array of bytes to a unicode string.</p>
+<pre>AString convertFromByteArray(
+ [const,array,size_is(aCount)] in octet aData,
+ in unsigned long aCount
+);
+</pre>
+<h3 id="convertToByteArray()">convertToByteArray()</h3>
+<p>Convert a unicode string to an array of bytes. Finish does not need to be called.</p>
+<pre>void convertToByteArray(in AString aString,
+ out unsigned long aLen, <span class="inlineIndicator optional optionalInline">可选</span>
+ [array, size_is(aLen),retval] out octet aData
+);
+</pre>
+<h3 id="convertToInputStream()">convertToInputStream()</h3>
+<p>Converts a Unicode string to an input stream. The bytes in the stream are encoded according to the <code>charset</code> attribute. The returned stream is non-blocking.</p>
+<pre>nsIInputStream convertToInputStream(
+  in AString aString
+ );
+</pre>
+<h6 id="Parameters">Parameters</h6>
+<h6 id="Return_value">Return value</h6>
+<p>An <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIInputStream" title="">nsIInputStream</a></code> that will present the text specified in <code>aString</code> as its data.</p>
+<ul>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <ul>
+ <li>
+ <dl>
+ <dt>
+ <code>aString</code></dt>
+ <dd>
+ The text to encode to the stream. The text is encoded into the character set specified by the <code>charset</code> attribute.</dd>
+ </dl>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+</ul>
+<dl>
+</dl>
+<h2 id="Examples" name="Examples">Examples</h2>
+<p>See <a href="/zh-cn/Reading_textual_data" title="zh-cn/Reading_textual_data">Reading textual data</a> and <a href="/zh-cn/Writing_textual_data" title="zh-cn/Writing_textual_data">Writing textual data</a> for examples.</p>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsisyncmessagesender/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsisyncmessagesender/index.html
new file mode 100644
index 0000000000..1af1e116c3
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsisyncmessagesender/index.html
@@ -0,0 +1,65 @@
+---
+title: nsISyncMessageSender
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsISyncMessageSender
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsISyncMessageSender
+---
+<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/content/base/public/nsIMessageManager.idl" rel="custom">content/base/public/nsIMessageManager.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">
+
+Handles sending messages synchronously to a destination frame.
+</span>
+
+ <div style="height: 42px; position: relative; padding: 2px; width: auto;">
+
+ <div style="top: 22px; font-size: 11px; position: absolute;">1.0</div>
+
+ <div style="top: 22px; font-size: 11px; position: absolute; left: 0px; text-align: right; float: right; width: 100%;">66</div>
+
+ <div style="height: 8px; top: 16px; background: #dd0000; left: 0px; position: absolute; width: 11.428571428571429%;"></div>
+
+<div style="height: 8px; top: 16px; left: 11.428571428571429%; background: #00dd00; position: absolute; width: 88.57142857142857%;" title="Introduced in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)"></div>
+
+<div style="top: 0px; font-size: 11px; position: absolute; left: 11.428571428571429%;">Introduced</div>
+<div style="top: 22px; font-size: 11px; position: absolute; left: 11.428571428571429%;">Gecko 2.0</div>
+
+</div>
+
+<div style="background: #eee; padding: 2px;">
+继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFrameMessageManager" title="">nsIFrameMessageManager</a></code>
+<span style="text-align: right; float: right;">最后修改于Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)</span></div>
+</div><p></p>
+<h2 id="Method_overview" name="Method_overview">方法概述</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>void sendSyncMessage(in messageName, in JSON, in [array] jsObjects);</code></td>
+ </tr>
+ </tbody>
+</table>
+<h3 id="sendSyncMessage()">sendSyncMessage()</h3>
+<p>同步发送一条短消息.</p>
+<pre>void sendSyncMessage(
+  in DOMString messageName,
+  in DOMString json,
+);
+</pre>
+<h6 id="Parameters">Parameters</h6>
+<dl>
+ <dt>
+ <code>messageName</code></dt>
+ <dd>
+ 消息的名称.</dd>
+ <dt>
+ <code>json</code></dt>
+ <dd>
+ 一个JSON格式的字符串,代表了要发送的数据.</dd>
+</dl>
+<h2 id="See_also" name="See_also">相关链接</h2>
+<ul>
+ <li><a href="/en/Content_process_event_handling" title="en/Content process event handling">Content process event handling</a></li>
+ <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIChromeFrameMessageManager" title="">nsIChromeFrameMessageManager</a></code></li>
+ <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentFrameMessageManager" title="">nsIContentFrameMessageManager</a></code></li>
+ <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFrameLoader" title="">nsIFrameLoader</a></code></li>
+ <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFrameMessageListener" title="">nsIFrameMessageListener</a></code></li>
+</ul>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsitimer/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsitimer/index.html
new file mode 100644
index 0000000000..24cfb2eb4f
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsitimer/index.html
@@ -0,0 +1,285 @@
+---
+title: nsITimer
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsITimer
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsITimer
+---
+<div id="page-top">
+ <div class="pageText" id="pageText">
+ <p>nsITimer 接口的功能是:在指定延迟后唤醒一个程序。</p>
+ <p><span class="lang lang-en"><code>nsITimer</code> 的定义文档: <span class="lang lang-en"><a class="external" href="http://mxr.mozilla.org/mozilla-central/source/xpcom/threads/nsITimer.idl" rel="external nofollow" title="http://mxr.mozilla.org/mozilla-central/source/xpcom/threads/nsITimer.idl"><code>xpcom/threads/nsITimer.idl</code></a> </span>。It is <span class="lang lang-en"><a href="../../../../en/Interfaces/About_Scriptable_Interfaces" rel="internal">scriptable</a> </span> and <span class="lang lang-en"> <a href="../../../../en/Interfaces/About_Frozen_Interfaces" rel="internal">unfrozen</a> (hasn't changed since 1.9.1) </span>. </span></p>
+ <p>继承自: <span class="lang lang-en"><code><a href="../../../../en/nsISupports" rel="internal">nsISupports</a></code> </span></p>
+ <p>实现: <code>@mozilla.org/timer;1</code>。创建实例如:</p>
+ <pre class="eval">var timer = Components.classes["@mozilla.org/timer;1"]
+ .createInstance(Components.interfaces.nsITimer);
+</pre>
+ <div id="section_1">
+ <h2 class="editable" id="方法预览"><span>方法预览</span></h2>
+ <div class="editIcon">
+ <a href="/../../../../En/NsITimer#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>void <a href="/../../../../En/NsITimer#initWithCallback.28.29" title="../../../../En/NsITimer#initWithCallback.28.29">initWithCallback</a>(in <span class="lang lang-en"><code><a href="../../../../en/nsITimerCallback" rel="internal">nsITimerCallback</a></code> </span> aCallback, in unsigned long aDelay, in unsigned long aType);</code></td>
+ </tr>
+ <tr>
+ <td><code>[noscript] void <a href="/../../../../En/NsITimer#initWithFuncCallback.28.29" title="../../../../En/NsITimer#initWithFuncCallback.28.29">initWithFuncCallback</a>(in <span class="lang lang-en"><code><a class="new" href="../../../../en/nsITimerCallbackFunc" rel="internal">nsITimerCallbackFunc</a></code> </span> aCallback, in voidPtr aClosure, in unsigned long aDelay, in unsigned long aType);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="/../../../../En/NsITimer#init.28.29" title="../../../../En/NsITimer#init.28.29">init</a>(in <span class="lang lang-en"><code><a href="../../../../en/nsIObserver" rel="internal">nsIObserver</a></code> </span> aObserver, in unsigned long aDelay, in unsigned long aType);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="/../../../../En/NsITimer#cancel.28.29" title="../../../../En/NsITimer#cancel.28.29">cancel</a>();</code></td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ <div id="section_2">
+ <h2 class="editable" id="属性"><span>属性</span></h2>
+ <div class="editIcon">
+ <a href="/../../../../En/NsITimer#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Attribute</td>
+ <td class="header">Type</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>delay</code></td>
+ <td><code>unsigned long</code></td>
+ <td>The timeout delay in millisecond.</td>
+ </tr>
+ <tr>
+ <td><code>type</code></td>
+ <td><code>unsigned long</code></td>
+ <td>Defines the timer type: one shot, repeating slack or repeating precise. Must be one of the constants defined under <span class="lang lang-en"><a href="/../../../../En/NsITimer#Constants" title="../../../../En/NsITimer#Constants">Constants</a> </span> on this page</td>
+ </tr>
+ <tr>
+ <td><code>callback</code></td>
+ <td><code>readonly <span class="lang lang-en"><code><a href="../../../../en/nsITimerCallback" rel="internal">nsITimerCallback</a></code> </span> </code></td>
+ <td>The <code>nsITimerCallback</code> object passed to <code>initWithCallback()</code>.</td>
+ </tr>
+ <tr>
+ <td><code>closure</code></td>
+ <td><code>[noscript] readonly voidPtr</code></td>
+ <td>
+ <p>The opaque pointer pass to <code>initWithFuncCallback()</code>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>target</td>
+ <td><span class="lang lang-en"><code><a class="new" href="../../../../en/nsIEventTarget" rel="internal">nsIEventTarget</a></code> </span></td>
+ <td>The <span class="lang lang-en"><code><a class="new" href="../../../../en/nsIEventTarget" rel="internal">nsIEventTarget</a></code> </span> to which the callback is dispatched.  This target must be set before calling any of the initialization methods.</td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ <div id="section_3">
+ <h2 class="editable" id="常量"><span>常量</span></h2>
+ <div class="editIcon">
+ <a href="/../../../../En/NsITimer#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Constant</td>
+ <td class="header">Value</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td><code>TYPE_ONE_SHOT</code></td>
+ <td>0</td>
+ <td>Type of a timer that fires once only.</td>
+ </tr>
+ <tr>
+ <td><code>TYPE_REPEATING_SLACK</code></td>
+ <td>1</td>
+ <td>After firing, the timer is stopped and not restarted until its callback completes. Specified timer period will be at least the time between when processing for last firing the callback completes and when the next firing occurs.</td>
+ </tr>
+ <tr>
+ <td><code>TYPE_REPEATING_PRECISE</code></td>
+ <td>2</td>
+ <td>This repeating timer aims to have constant period between firings. The processing time for each timer callback should not influence the timer period. However, if the processing for the last timer firing could not be completed until just before the next firing occurs, then you could have two timer notification routines being executed in quick succession.</td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ <div id="section_4">
+ <h2 class="editable" id="方法"><span>方法</span></h2>
+ <div class="editIcon">
+ <a href="/../../../../En/NsITimer#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <div id="section_5">
+ <h3 class="editable" id="initWithCallback()"><span>initWithCallback()</span></h3>
+ <div class="editIcon">
+ <a href="/../../../../En/NsITimer#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>Initialize a timer to fire after the given millisecond interval. This version takes a function to call and a closure to pass to that function.</p>
+ <pre class="eval"> void initWithCallback (
+ in nsITimerCallback aCallback,
+ in unsigned long aDelay,
+ in unsigned long aType
+ );
+</pre>
+ <div id="section_6">
+ <h6 class="editable" id="Parameters"><span>Parameters</span></h6>
+ <div class="editIcon">
+ <a href="/../../../../En/NsITimer#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <dl>
+ <dt>
+ <code>aFunc</code></dt>
+ <dd>
+ <span class="lang lang-en"><code><a href="../../../../en/nsITimerCallback" rel="internal">nsITimerCallback</a></code> </span> interface to call when timer expires.</dd>
+ </dl>
+ <dl>
+ <dt>
+ <code>aDelay</code></dt>
+ <dd>
+ timeout delay in milliseconds.</dd>
+ </dl>
+ <dl>
+ <dt>
+ <code>aType</code></dt>
+ <dd>
+ Defines the timer type: one shot, repeating slack or repeating precise. Must be one of the constants defined under <span class="lang lang-en"><a href="/../../../../En/NsITimer#Constants" title="../../../../En/NsITimer#Constants">Constants</a> </span> on this page.</dd>
+ </dl>
+ </div>
+ </div>
+ <div id="section_7">
+ <h3 class="editable" id="initWithFuncCallback()"><span>initWithFuncCallback()</span></h3>
+ <div class="editIcon">
+ <a href="/../../../../En/NsITimer#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>Initialize a timer to fire after the given millisecond interval. This version takes a function to call and a closure to pass to that function.</p>
+ <pre class="eval"> [noscript] void initWithFuncCallback(
+ in nsTimerCallbackFunc aCallback,
+ in voidPtr aClosure,
+ in unsigned long aDelay,
+ in unsigned long aType
+ );
+</pre>
+ <div id="section_8">
+ <h6 class="editable" id="Parameters_2"><span>Parameters</span></h6>
+ <div class="editIcon">
+ <a href="/../../../../En/NsITimer#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <dl>
+ <dt>
+ <code>aFunc</code></dt>
+ <dd>
+ a <span class="lang lang-en"><code><a class="new" href="../../../../en/nsITimerCallbackFunc" rel="internal">nsITimerCallbackFunc</a></code> </span> interface compatible function to call when timer fires.</dd>
+ </dl>
+ <dl>
+ <dt>
+ <code>aClosure</code></dt>
+ <dd>
+ An opaque pointer to pass to that function.</dd>
+ </dl>
+ <dl>
+ <dt>
+ <code>aDelay</code></dt>
+ <dd>
+ timeout delay in milliseconds.</dd>
+ </dl>
+ <dl>
+ <dt>
+ <code>aType</code></dt>
+ <dd>
+ Defines the timer type: one shot, repeating slack or repeating precise. Must be one of the constants defined under <span class="lang lang-en"><a href="/../../../../En/NsITimer#Constants" title="../../../../En/NsITimer#Constants">Constants</a> </span> on this page.</dd>
+ </dl>
+ </div>
+ </div>
+ <div id="section_9">
+ <h3 class="editable" id="init()"><span>init()</span></h3>
+ <div class="editIcon">
+ <a href="/../../../../En/NsITimer#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>Initialize a timer that will fire after the specified delay. A user must keep a reference to this timer till it is no longer needed or has been canceled.</p>
+ <pre class="eval"> void init(
+ in nsIObserver aObserver,
+ in unsigned long aDelay,
+ in unsigned long aType
+ );
+</pre>
+ <div id="section_10">
+ <h6 class="editable" id="Parameters_3"><span>Parameters</span></h6>
+ <div class="editIcon">
+ <a href="/../../../../En/NsITimer#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <dl>
+ <dt>
+ <code>aObserver</code></dt>
+ <dd>
+ A callback Object, that is capable listening to timer events. If the timer fires, the observer will be notified via the <span class="lang lang-en"><code><a href="../../../../en/nsIObserver" rel="internal">nsIObserver</a></code> </span> Interface. The subject is set to the <code>nsITimer</code> Object which fired, the topic is equal to "timer-callback" and data is always set to null.</dd>
+ </dl>
+ <dl>
+ <dt>
+ <code>aDelay</code></dt>
+ <dd>
+ timeout delay in milliseconds.</dd>
+ </dl>
+ <dl>
+ <dt>
+ <code>aType</code></dt>
+ <dd>
+ Defines the timer type: one shot, repeating slack or repeating precise. Must be one of the constants defined under <span class="lang lang-en"><a href="/../../../../En/NsITimer#Constants" title="../../../../En/NsITimer#Constants">Constants</a> </span> on this page.</dd>
+ </dl>
+ </div>
+ </div>
+ <div id="section_11">
+ <h3 class="editable" id="cancel()"><span>cancel()</span></h3>
+ <div class="editIcon">
+ <a href="/../../../../En/NsITimer#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>Cancels the timer. This method works on all types, not just on repeating timers -- you might want to cancel a TYPE_ONE_SHOT timer, and even reuse it by re-initializing it (to avoid object destruction and creation costs by conserving one timer instance).</p>
+ <pre class="eval"> void cancel();
+</pre>
+ <div id="section_12">
+ <h6 class="editable" id="Parameters_4"><span>Parameters</span></h6>
+ <div class="editIcon">
+ <a href="/../../../../En/NsITimer#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>None.</p>
+ </div>
+ </div>
+ </div>
+ <div id="section_13">
+ <h2 class="editable" id="备注"><span>备注</span></h2>
+ <div class="editIcon">
+ <a href="/../../../../En/NsITimer#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>TYPE_REPEATING_SLACK timer is the preferable repeating timer type for most situations<span id="1243145776531S" style="display: none;"> </span></p>
+ </div>
+ <div id="section_14">
+ <h2 class="editable" id="sect1"> </h2>
+ <div class="editIcon">
+ 实例</div>
+ <div class="editIcon">
+ <a href="/../../../../En/NsITimer#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <pre class="eval"> // we need a <span class="lang lang-en"><code><a href="../../../../en/nsITimerCallback" rel="internal">nsITimerCallback</a></code>
+</span> compatible...
+ // ... interface for the callbacks.
+ var event
+ = { notify: function(timer) { alert("Fire!"); } }
+
+ // Now it is time to create the timer...
+ var timer
+ = Components.classes["@mozilla.org/timer;1"]
+ .createInstance(Components.interfaces.nsITimer);
+
+ // ... and to initialize it, we want to call event.notify() ...
+ // ... one time after exactly ten second.
+ timer.initWithCallback(
+ event,
+ 10000,
+ Components.interfaces.nsITimer.TYPE_ONE_SHOT);
+</pre>
+ <p> </p>
+ </div>
+ <div id="section_15">
+ <h2 class="editable" id="请参阅"><span>请参阅</span></h2>
+ <div class="editIcon">
+ <a href="/../../../../En/NsITimer#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p><span class="lang lang-en"><code><a class="new" href="../../../../en/nsITimerCallbackFunc" rel="internal">nsITimerCallbackFunc</a></code> </span>, <span class="lang lang-en"><code><a href="../../../../en/nsITimerCallback" rel="internal">nsITimerCallback</a></code></span></p>
+ </div>
+ </div>
+</div>
+
+<p><strong class="tag-label">标记:</strong></p>
+<div id="pageTags">
+ <div class="pageTagList">
+ <div class="item taglist">
+ <a href="/../../../../Special:Tags?tag=Interfaces&amp;language=en" title="Interfaces">Interfaces</a>, <a href="/../../../../Special:Tags?tag=Interfaces:Scriptable&amp;language=en" title="Interfaces:Scriptable">Interfaces:Scriptable</a>, <a href="/../../../../Special:Tags?tag=XPCOM&amp;language=en" title="XPCOM">XPCOM</a>, <a href="/../../../../Special:Tags?tag=XPCOM+API+Reference&amp;language=en" title="XPCOM API Reference">XPCOM API Reference</a></div>
+ </div>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsitraceablechannel/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsitraceablechannel/index.html
new file mode 100644
index 0000000000..ce7c6deb2f
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsitraceablechannel/index.html
@@ -0,0 +1,71 @@
+---
+title: nsITraceableChannel
+slug: Mozilla/Tech/XPCOM/Reference/Interface/NsITraceableChannel
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/NsITraceableChannel
+---
+<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsITraceableChannel.idl" rel="custom">netwerk/base/public/nsITraceableChannel.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">这个接口用于允许拦截 <a href="/en-US/docs/HTTP" title="/en-US/docs/HTTP">HTTP</a> 流量。It is implemented by <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIHttpChannel" title="">nsIHttpChannel</a></code>.</span>
+
+ <div style="height: 42px; position: relative; padding: 2px; width: auto;">
+
+ <div style="top: 22px; font-size: 11px; position: absolute;">1.0</div>
+
+ <div style="top: 22px; font-size: 11px; position: absolute; left: 0px; text-align: right; float: right; width: 100%;">66</div>
+
+ <div style="height: 8px; top: 16px; background: #dd0000; left: 0px; position: absolute; width: 8.952380571428572%;"></div>
+
+<div style="height: 8px; top: 16px; left: 8.952380571428572%; background: #00dd00; position: absolute; width: 91.04761942857142%;" title="Introduced in Gecko 1.9.0.4 "></div>
+
+<div style="top: 0px; font-size: 11px; position: absolute; left: 8.952380571428572%;">Introduced</div>
+<div style="top: 22px; font-size: 11px; position: absolute; left: 8.952380571428572%;">Gecko 1.9.0.4</div>
+
+</div>
+
+<div style="background: #eee; padding: 2px;">
+继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code>
+<span style="text-align: right; float: right;">最后修改于Gecko 1.9.0.4 </span></div>
+</div><p></p>
+<p>使用这个接口的典型方式如下:</p>
+<ul>
+ <li><a href="/en/XUL_School/Intercepting_Page_Loads#HTTP_Observers" title="en/XUL_School/Intercepting_Page_Loads#HTTP_Observers">注册“http-on-examine-response”通知</a>来跟综全部 HTTP 响应;</li>
+ <li>跳过重定义 (<code>responseStatus</code> = 3xx on <a href="/en-US/docs/XPCOM_Interface_Reference/nsIHttpChannel" title="/en-US/docs/XPCOM_Interface_Reference/nsIHttpChannel">nsIHttpChannel</a>),否则你可能<a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=728901#c8" title="https://bugzilla.mozilla.org/show_bug.cgi?id=728901#c8">最终有两个监听视(listeners)注册通道(channel)</a>;</li>
+ <li>QI the channel passed as the "<code>subject</code>" to your observer to <code>nsITraceableChannel</code>, and replace the default <code>nsIStreamListener</code> (that passes the data to the original requester - e.g. to XMLHttpRequest or to the browser tab that made the request) with your own implementation (see <a href="#Using_channel_listeners" title="#Using_channel_listeners">"Implementing nsIStreamListener"</a> below).</li>
+</ul>
+<p>之后,你的 nsIStreamListener 实现将会获取到响应数据(response data),并且能够传递数据到原始的 nsIStreamListener(可能会修改它)。</p>
+<p>See <a class="external" href="http://www.softwareishard.com/blog/firebug/nsitraceablechannel-intercept-http-traffic/" title="http://www.softwareishard.com/blog/firebug/nsitraceablechannel-intercept-http-traffic/">nsITraceableChannel, Intercept HTTP Traffic</a> for a more detailed description with code samples.</p>
+<p>See <a href="http://stackoverflow.com/questions/5205672/modify-url-before-loading-page-in-firefox/" title="http://stackoverflow.com/questions/5205672/modify-url-before-loading-page-in-firefox/"> Modify URL before loading page in firefox</a> for an overview of how to <strong>modify</strong> a request before it is made.</p>
+<h2 id="Method_overview" name="Method_overview">Method overview</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>nsIStreamListener <a href="#setNewListener()">setNewListener</a>(in nsIStreamListener aListener);</code></td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="Methods" name="Methods">Methods</h2>
+<h3 id="setNewListener()" name="setNewListener()">setNewListener()</h3>
+<p>用一个新的来替换该通道的当前监听器,返回先前分配给该通道的监听器。</p>
+<pre class="eval">nsIStreamListener setNewListener(
+ in nsIStreamListener aListener
+);
+</pre>
+<h6 id="Parameters" name="Parameters">参数</h6>
+<dl>
+ <dt>
+ <code>aListener</code></dt>
+ <dd>
+ An <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIStreamListener" title="">nsIStreamListener</a></code> to be notified of events on the HTTP channel.</dd>
+</dl>
+<h6 id="Return_value" name="Return_value">返回值</h6>
+<p>该通道的前一个监听器。Each listener call through to the previous listener for every call, in order to establish a call chain to allow all interested parties a chance to act on each event.</p>
+<h2 id="Using_channel_listeners" name="Using_channel_listeners">实现 nsIStreamListener</h2>
+<p>一个 <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIStreamListener" title="">nsIStreamListener</a></code> 接口传递给 <code>setNewListener()</code> 需要实现下列的方法,这是通过调用(这些方法)来通知它在 HTTP stream 上发生的事件:</p>
+<ul>
+ <li><code>onStartRequest</code>:一个 HTTP 请求开始。</li>
+ <li><code>onDataAvailable:</code>数据到达 HTTP 通道(HTTP channel)。</li>
+ <li><code>onStopRequest</code>:HTTP 请求结束。</li>
+</ul>
+<div class="note">
+ <strong>Note:</strong> It is critical that you pass along requests to the previous listener as soon as possible -- especially for <code>onStartRequest</code>.</div>
+<p>Channels may restrict when you may replace the listener. In particular, listeners typically should not be replaced after <code>onStartRequest</code> has been called.</p>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiuri/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiuri/index.html
new file mode 100644
index 0000000000..d133861ac3
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsiuri/index.html
@@ -0,0 +1,407 @@
+---
+title: nsIURI
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIURI
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIURI
+---
+<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;">
+<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsIURI.idl" rel="custom">netwerk/base/public/nsIURI.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div>
+<span style="padding: 4px 2px;">
+
+这是具有国际化支持的统一资源标识符的接口,提供允许设置和查询URI基本组件的属性以及用于在URI上执行基本操作的方法。
+</span>
+
+<div style="background: #eee; padding: 2px;">
+继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code>
+<span style="text-align: right; float: right;">最后修改于Gecko 6.0 (Firefox 6.0 / Thunderbird 6.0 / SeaMonkey 2.3)</span></div>
+</div><p></p>
+
+<p>细节请查看下列 RFCs:</p>
+
+<ul>
+ <li><a class="external" href="http://www.ietf.org/rfc/rfc3490.txt" title="http://www.ietf.org/rfc/rfc3490.txt">RFC3490</a>: 在应用程序中的国际域名 (IDNA)</li>
+ <li><a class="external" href="http://tools.ietf.org/rfc/rfc3986.txt" title="http://tools.ietf.org/rfc/rfc3986.txt">RFC3986</a>: 统一资源标识符 (URI): 通用词法</li>
+ <li><a class="external" href="http://tools.ietf.org/rfc/rfc3987.txt" title="http://tools.ietf.org/rfc/rfc3987.txt">RFC3987</a>: 国际化的内容标识</li>
+</ul>
+
+<p><code>nsIURI</code>的子类,  例如 <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIURL" title="">nsIURL</a></code>, 加强了URI未来的结构化.</p>
+
+<p>为了创建一个 <code>nsIURI</code> 对象, 你应该如此使用 <code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsIIOService#newURI()">nsIIOService.newURI()</a></code>:</p>
+
+<pre class="brush: js">function makeURI(aURL, aOriginCharset, aBaseURI) {
+ var ioService = Components.classes["@mozilla.org/network/io-service;1"]
+ .getService(Components.interfaces.nsIIOService);
+ return ioService.newURI(aURL, aOriginCharset, aBaseURI);
+}
+</pre>
+
+<h2 id="Components_of_a_URI" name="Components_of_a_URI">一个 URI 的组件</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th colspan="7" scope="col" style="text-align: center;">prePath</th>
+ <th colspan="2" scope="col" style="text-align: center;">path</th>
+ </tr>
+ <tr>
+ <th scope="col" style="text-align: center;">scheme</th>
+ <th scope="col" style="text-align: center;"> </th>
+ <th scope="col" style="text-align: center;">userPass</th>
+ <th scope="col" style="text-align: center;"> </th>
+ <th scope="col" style="text-align: center;">host</th>
+ <th scope="col" style="text-align: center;"> </th>
+ <th scope="col" style="text-align: center;">port</th>
+ <th scope="col" style="text-align: center;"> </th>
+ <th scope="col" style="text-align: center;">ref</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td style="text-align: right;">ftp</td>
+ <td>://</td>
+ <td>username@password</td>
+ <td>@</td>
+ <td>hostname</td>
+ <td>:</td>
+ <td>portnumber</td>
+ <td>/pathname?query=value</td>
+ <td>#ref</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Method_overview" name="Method_overview">函数预览</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>nsIURI <a href="#clone()">clone</a>();</code></td>
+ </tr>
+ <tr>
+ <td><code>nsIURI <a href="#cloneIgnoringRef()">cloneIgnoringRef</a>();</code> </td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#equals()">equals</a>(in nsIURI other);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#equalsExceptRef()">equalsExceptRef</a>(in nsIURI other);</code> </td>
+ </tr>
+ <tr>
+ <td><code>AUTF8String <a href="#resolve()">resolve</a>(in AUTF8String relativePath);</code></td>
+ </tr>
+ <tr>
+ <td><code>boolean <a href="#schemeIs()">schemeIs</a>(in string scheme);</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Attributes" name="Attributes">属性</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">属性</td>
+ <td class="header">类别</td>
+ <td class="header">描述</td>
+ </tr>
+ <tr>
+ <td><code>asciiHost</code></td>
+ <td><code><a href="/en/ACString" title="en/ACString">ACString</a></code></td>
+ <td>
+ <p>The URI <code>host</code> with an ASCII compatible encoding. Follows the IDNA draft specification for converting internationalized domain names (UTF-8) to ASCII for compatibility with existing Internet infrastructure. <strong>Read only.</strong></p>
+
+ <div class="note">
+ <p><strong>Note:</strong> IPv6 addresses are not enclosed in square brackets.</p>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>asciiSpec</code></td>
+ <td><code><a href="/en/ACString" title="en/ACString">ACString</a> (US-ASCII)</code></td>
+ <td>The URI spec with an ASCII compatible encoding. The host portion follows the IDNA draft spec. Other parts are URL-escaped per the rules of <a class="external" href="http://tools.ietf.org/rfc/rfc3986.txt" title="http://tools.ietf.org/rfc/rfc3986.txt">RFC3986</a>. The result is strictly ASCII. <strong>Read only.</strong></td>
+ </tr>
+ <tr>
+ <td><code>hasRef</code></td>
+ <td><code>boolean</code></td>
+ <td>Returns if there is a reference portion (the part after the "#") of the URI.<br>
+ <br>
+ </td>
+ </tr>
+ <tr>
+ <td><code>host</code></td>
+ <td><code><a href="/en/AUTF8String" title="en/AUTF8String">AUTF8String</a></code></td>
+ <td>
+ <p>The host is the Internet domain name to which this URI refers. It could be an IPv4 (or IPv6) address literal. If supported, it could be a non-ASCII internationalized domain name.</p>
+
+ <h6 id="Exceptions_thrown">Exceptions thrown</h6>
+
+ <dl>
+ <dt><code>NS_ERROR_FAILURE</code></dt>
+ <dd>If host is not applicable to the URI scheme (e.g. about:blank)</dd>
+ </dl>
+
+ <div class="note"><strong>Note:</strong> Characters are <strong>not</strong> escaped. IPv6 addresses are not enclosed in square brackets.</div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>hostPort</code></td>
+ <td><code><a href="/en/AUTF8String" title="en/AUTF8String">AUTF8String</a></code></td>
+ <td>
+ <p>The "host:port" part of the URI (or simply the host, if port is -1).</p>
+
+ <h6 id="Exceptions_thrown_2">Exceptions thrown</h6>
+
+ <dl>
+ <dt><code>NS_ERROR_FAILURE</code></dt>
+ <dd>If hostPort is not applicable to the URI scheme (e.g. about:blank)</dd>
+ </dl>
+
+ <div class="note"><strong>Note:</strong> Characters are <strong>not</strong> escaped.</div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>originCharset</code></td>
+ <td><code><a href="/en/ACString" title="en/ACString">ACString</a></code></td>
+ <td>
+ <p>The charset of the document from which this URI originated. An empty value implies UTF-8.</p>
+ If this value is something other than UTF-8 then the URI components (for example <code>spec</code>, <code>prePath</code>, <code>username</code>, and so on) are all fully URL-escaped. Otherwise, the URI components may contain unescaped multibyte UTF-8 characters. <strong>Read only.</strong></td>
+ </tr>
+ <tr>
+ <td><code>password</code></td>
+ <td><code><a href="/en/AUTF8String" title="en/AUTF8String">AUTF8String</a></code></td>
+ <td>
+ <p>The optional password, assuming the <code>preHost</code> consists of "username:password".</p>
+
+ <h6 id="Exceptions_thrown_3">Exceptions thrown</h6>
+
+ <dl>
+ <dt><code>NS_ERROR_FAILURE</code></dt>
+ <dd>If password is not applicable to the URI scheme (e.g. about:blank)</dd>
+ </dl>
+
+ <p></p><div class="blockIndicator note"><strong>Note:</strong> Some characters may be escaped.</div><p></p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>path</code></td>
+ <td><code><a href="/en/AUTF8String" title="en/AUTF8String">AUTF8String</a></code></td>
+ <td>
+ <p>The path, typically including at least a leading '/' (but may also be empty, depending on the protocol).</p>
+ <div class="blockIndicator note"><strong>Note:</strong> Some characters may be escaped.</div></td>
+ </tr>
+ <tr>
+ <td><code>port</code></td>
+ <td><code><a href="/en/long" title="en/long">long</a></code></td>
+ <td>
+ <p>The URI's port. A port value of -1 corresponds to the protocol's default port (for example -1 implies port 80 for HTTP URIs).</p>
+
+ <h6 id="Exceptions_thrown_4">Exceptions thrown</h6>
+
+ <dl>
+ <dt><code>NS_ERROR_FAILURE</code></dt>
+ <dd>If port is not applicable to the URI scheme (e.g. about:blank)</dd>
+ </dl>
+ </td>
+ </tr>
+ <tr>
+ <td><code>prePath</code></td>
+ <td><code><a href="/en/AUTF8String" title="en/AUTF8String">AUTF8String</a></code></td>
+ <td>
+ <p>The <code>prePath</code> returns the string before the path (such as "<a class="external" rel="freelink">scheme://user:password@host</a>:port").</p>
+
+ <p>This is related to the <a class="external" href="http://tools.ietf.org/html/rfc6454" title="http://tools.ietf.org/html/rfc6454">Web Origin Concept of RFC6454</a>.</p>
+
+ <p>This is useful for authentication, managing sessions, or for checking the <code>origin</code> of an URI to prevent cross-site scripting attacks while using methods such as <a href="/zh-CN/docs/Web/API/Window/postMessage" title="window.postMessage() 方法可以安全地实现跨源通信。通常,对于两个不同页面的脚本,只有当执行它们的页面位于具有相同的协议(通常为https),端口号(443为https的默认值),以及主机  (两个页面的模数 Document.domain设置为相同的值) 时,这两个脚本才能相互通信。window.postMessage() 方法提供了一种受控机制来规避此限制,只要正确的使用,这种方法就很安全。"><code>window.postMessage()</code></a>.</p>
+ <div class="blockIndicator note"><strong>Note:</strong> Some characters may be escaped.</div> <strong>Read only.</strong></td>
+ </tr>
+ <tr>
+ <td><code>ref</code></td>
+ <td><code><a href="/en/AUTF8String" title="en/AUTF8String">AUTF8String</a></code></td>
+ <td>
+ <p>Returns the reference portion (the part after the "#") of the URI. If there is not one, an empty string is returned.</p>
+ <div class="blockIndicator note"><strong>Note:</strong> Some characters may be escaped.</div> </td>
+ </tr>
+ <tr>
+ <td><code>scheme</code></td>
+ <td><code><a href="/en/ACString" title="en/ACString">ACString</a> (US-ASCII)</code></td>
+ <td>
+ <p>The <code>scheme</code> is the protocol to which this URI refers. The scheme is restricted to the US-ASCII charset per <a class="external" href="http://tools.ietf.org/rfc/rfc3986.txt" title="http://tools.ietf.org/rfc/rfc3986.txt">RFC3986</a>.</p>
+
+ <div class="warning"><strong>Warning:</strong> Setting this is highly discouraged outside of a protocol handler implementation, since doing so will generally lead to unpredictable results.</div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>spec</code></td>
+ <td><code><a href="/en/AUTF8String" title="en/AUTF8String">AUTF8String</a></code></td>
+ <td>
+ <p>Returns a string representation of the URI. Setting the <code>spec</code> causes the new spec to be parsed using the rules for the scheme the URI currently has. If the string cannot be parsed as a URI, <code>NS_ERROR_MALFORMED_URI</code> thrown.</p>
+
+ <div class="warning"><strong>Warning:</strong> Because parsing the string is done using the current URI's scheme, setting the spec to a URI with a different scheme will produce incorrect results. Therefore, only protocol handler implementations should do this.</div>
+
+ <p>If the URI stores information from the <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIIOService" title="">nsIIOService</a></code> interface's <code><a href="https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/nsIIOService#newURI()">nsIIOService.newURI()</a></code> call that created it, other than just the parsed string, the behavior of this information when setting the <code>spec</code> attribute is undefined.</p>
+ <div class="blockIndicator note"><strong>Note:</strong> Some characters may be escaped.</div></td>
+ </tr>
+ <tr>
+ <td><code>specIgnoringRef</code></td>
+ <td><code><a href="/en/AUTF8String" title="en/AUTF8String">AUTF8String</a></code></td>
+ <td>Returns a string representation of the URI without the <code>ref</code> (part after the #) portion.<br>
+ <br>
+ <div class="blockIndicator note"><strong>Note:</strong> Some characters may be escaped.</div> </td>
+ </tr>
+ <tr>
+ <td><code>username</code></td>
+ <td><code><a href="/en/AUTF8String" title="en/AUTF8String">AUTF8String</a></code></td>
+ <td>
+ <p>The optional username, assuming the <code>preHost</code> consists of "username:password".</p>
+
+ <h6 id="Exceptions_thrown_5">Exceptions thrown</h6>
+
+ <dl>
+ <dt><code>NS_ERROR_FAILURE</code></dt>
+ <dd>If username is not applicable to the URI scheme (e.g. about:blank)</dd>
+ </dl>
+ <div class="blockIndicator note"><strong>Note:</strong> Some characters may be escaped.</div></td>
+ </tr>
+ <tr>
+ <td><code>userPass</code></td>
+ <td><code><a href="/en/AUTF8String" title="en/AUTF8String">AUTF8String</a></code></td>
+ <td>
+ <p>The "username:password" (or username only if the value doesn't contain a ':').</p>
+
+ <h6 id="Exceptions_thrown_6">Exceptions thrown</h6>
+
+ <dl>
+ <dt><code>NS_ERROR_FAILURE</code></dt>
+ <dd>If userPass is not applicable to the URI scheme (e.g. about:blank)</dd>
+ </dl>
+ <div class="blockIndicator note"><strong>Note:</strong> Some characters may be escaped.</div></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Methods" name="Methods">Methods</h2>
+
+<h3 id="clone()" name="clone()">clone()</h3>
+
+<p>Clones the URI, returning a new <code>nsIURI</code> object.</p>
+
+<div class="note"><strong>Note:</strong> For some protocols, this is more than just an optimization. For example, under Mac OS X, the spec of a file URI doesn't necessarily uniquely identify a file, since two volumes can have the same name.</div>
+
+<pre class="eval">nsIURI clone();
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<p>None.</p>
+
+<h6 id="Return_value" name="Return_value">Return value</h6>
+
+<p>An <code>nsIURI</code> object that represents the same URI as the current <code>nsIURI</code>.</p>
+
+<p></p><h3 id="cloneIgnoringRef()">cloneIgnoringRef()</h3><p></p>
+
+<p>Clones the current URI, clearing the <code>'ref'</code> attribute in the clone.</p>
+
+<pre class="eval">nsIURI cloneIgnoringRef();
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<p>None.</p>
+
+<h6 id="Return_value" name="Return_value">Return value</h6>
+
+<p>An <code>nsIURI</code> object that represents the same URI as the current <code>nsIURI</code> without the <code>'ref'</code> attribute.</p>
+
+<h3 id="equals()" name="equals()">equals()</h3>
+
+<p>Compares the current URI with another URI.</p>
+
+<div class="note"><strong>Note:</strong> This is more than a string comparison, as two different URI strings can represent the same location. For example, comparing "<a class="external" href="http://foo.com:80/" rel="freelink">http://foo.com:80/</a>" and "<a class="external" href="http://foo.com/" rel="freelink">http://foo.com/</a>" will return <code>true</code>.</div>
+
+<pre class="eval">boolean equals(
+ in nsIURI other
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>other</code></dt>
+ <dd>Another <code>nsIURI</code> to compare to.</dd>
+</dl>
+
+<h6 id="Return_value" name="Return_value">Return value</h6>
+
+<p><code>true</code> if the two URIs represent the same location; otherwise <code>false</code>.</p>
+
+<p></p><h3 id="equalsExceptRef()">equalsExceptRef()</h3><p></p>
+
+<p>Compares the current URI with another URI, ignoring the value of the <code>.ref</code> member.</p>
+
+<div class="note"><strong>Note:</strong> This is more than a string comparison, as two different URI strings can represent the same location. For example, comparing "<a class="external" href="http://foo.com/#" rel="freelink">http://foo.com/#</a>" and "<a class="external" href="http://foo.com/" rel="freelink">http://foo.com/</a>" or "<a class="external" href="http://foo.com/#aaa" rel="freelink">http://foo.com/#aaa</a>" and "<a class="external" href="http://foo.com/#bbb" rel="freelink">http://foo.com/#bbb</a>" will return <code>true</code>.</div>
+
+<pre class="eval">boolean equalsExceptRef(
+ in nsIURI other
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>other</code></dt>
+ <dd>Another <code>nsIURI</code> to compare to.</dd>
+</dl>
+
+<h6 id="Return_value" name="Return_value">Return value</h6>
+
+<p><code>true</code> if the two URIs represent the same location; otherwise <code>false</code>.</p>
+
+<h3 id="resolve()" name="resolve()">resolve()</h3>
+
+<p>Resolves a relative URI string, using this URI as the base.</p>
+
+<p></p><div class="blockIndicator note"><strong>Note:</strong> Some implementations may have no concept of a relative URI.</div><p></p>
+
+<pre class="eval">AUTF8String resolve(
+ in AUTF8String relativePath
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>relativePath</code></dt>
+ <dd>The relative path to resolve.</dd>
+</dl>
+
+<h6 id="Return_value" name="Return_value">Return value</h6>
+
+<p>The resolved absolute URI string.</p>
+
+<h3 id="schemeIs()" name="schemeIs()">schemeIs()</h3>
+
+<p>Quickly reports whether the <code>nsIURI</code> represents a URI with the specified scheme. This comparison is case-insensitive.</p>
+
+<p></p><div class="blockIndicator note"><strong>Note:</strong> This is an optimization, allowing you to check the scheme of the URI without having to get the scheme and do the comparison yourself; this saves memory allocations.</div><p></p>
+
+<pre class="eval">boolean schemeIs(
+ in string scheme
+);
+</pre>
+
+<h6 id="Parameters" name="Parameters">Parameters</h6>
+
+<dl>
+ <dt><code>scheme</code></dt>
+ <dd>A string representing the scheme to compare to.</dd>
+</dl>
+
+<h6 id="Return_value" name="Return_value">Return value</h6>
+
+<p><code>true</code> if the URI is for the specified scheme; otherwise <code>false</code>.</p>
+
+<h2 id="See_also" name="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en/Code_snippets/URI_parsing" title="en/Code_snippets/URI_parsing">Code snippets:URI parsing</a></li>
+</ul>
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsixmlhttprequest/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsixmlhttprequest/index.html
new file mode 100644
index 0000000000..f12f52cb12
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsixmlhttprequest/index.html
@@ -0,0 +1,90 @@
+---
+title: nsIXMLHttpRequest
+slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIXMLHttpRequest
+tags:
+ - XMLHttpRequest
+ - XPCOM API 参考
+ - XPCOM 接口参考
+ - 指南
+ - 接口
+translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIXMLHttpRequest
+---
+<div class="blockIndicator obsolete obsoleteHeader"><p><strong><span class="icon-only-inline" title="This is an obsolete API and is no longer guaranteed to work."><i class="icon-trash"> </i></span> Obsolete since Gecko 60 (Firefox 60 / Thunderbird 60 / SeaMonkey 2.57)</strong><br>This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.</p></div>
+
+<p><code>nsIXMLHttpRequest</code> along with <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIJSXMLHttpRequest" title="">nsIJSXMLHttpRequest</a></code> and <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIXMLHttpRequestEventTarget" title="">nsIXMLHttpRequestEventTarget</a></code> are Mozilla's implementation details of the DOM <a href="/en/DOM/XMLHttpRequest" title="en/DOM/XMLHttpRequest">XMLHttpRequest</a> object.</p>
+
+<div class="note"><strong>注意:</strong> 如果你是 Web 开发者或者 Mozilla add-on 开发者,请参考 <a href="/en/DOM/XMLHttpRequest">XMLHttpRequest</a>。</div>
+
+<p>This page contains documentation, specific to Mozilla application and add-on developers.</p>
+
+<p>The interface definition: <a href="https://dxr.mozilla.org/mozilla-central/source/dom/xhr/nsIXMLHttpRequest.idl">https://dxr.mozilla.org/mozilla-central/source/dom/xhr/nsIXMLHttpRequest.idl</a></p>
+
+<h3 id="Elevated_Privileges">Elevated Privileges</h3>
+
+<p>As mentioned in the "Non-Standard Properties" the property of <code>channel</code> was read-only. When using the XPCOM interface, as seen below in <a href="#Example_code">Example 2</a>, we can get access to this. The most obvious benefit is that we can set <a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/NsIRequest#Constants">nsiRequest - Constants</a> in the <code>xhr.channel.loadFlags</code>. For instance, as done in <a href="#Example_code">Example 2</a>, the flag of <code>LOAD_ANONYMOUS</code> is added, this strips all user data (cookies, tokens, etc).</p>
+
+<h3 id="Using_event_handlers_from_native_code">Using event handlers from native code</h3>
+
+<p>(Not sure if it's up-to-date)</p>
+
+<p>From native code, the way to set up onload and onerror handlers is a bit different. Here is a comment from Johnny Stenback &lt;<a class="link-mailto" href="mailto:jst@netscape.com" rel="freelink">jst@netscape.com</a>&gt;:</p>
+
+<blockquote>The mozilla implementation of nsIXMLHttpRequest implements the interface nsIDOMEventTarget and that's how you're supported to add event listeners. Try something like this: nsCOMPtr&lt;nsIDOMEventTarget&gt; target(do_QueryInterface(myxmlhttpreq)); target-&gt;AddEventListener(NS_LITERAL_STRING("load"), mylistener, PR_FALSE) where mylistener is your event listener object that implements the interface nsIDOMEventListener. The 'onload', 'onerror', and 'onreadystatechange' attributes moved to nsIJSXMLHttpRequest, but if you're coding in C++ you should avoid using those.</blockquote>
+
+<p>Though actually, if you use addEventListener from C++ weird things will happen too, since the result will depend on what JS happens to be on the stack when you do it....</p>
+
+<p>Conclusion: Do not use event listeners on XMLHttpRequest from C++, unless you're aware of all the security implications. And then think twice about it.</p>
+
+<h2 id="Example_code" name="Example_code">Example code</h2>
+
+<p>This is a simple example code for opening a simple HTTP request from a xul application (like a Mozilla extension) without using observers:</p>
+
+<pre class="eval"> var req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance();
+ req.open('POST', "<a class="external" href="http://www.foo.bar:8080/nietzsche.do" rel="freelink">http://www.foo.bar:8080/nietzsche.do</a>", true);
+ req.send('your=data&amp;and=more&amp;stuff=here');
+</pre>
+
+<h2 id="Example_code" name="Example_code">Example 2</h2>
+
+<pre><code>var {Cu: utils, Cc: classes, Ci: instances} = Components;
+Cu.import('resource://gre/modules/Services.jsm');
+function xhr(url, cb) {
+ let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
+
+ let handler = ev =&gt; {
+ evf(m =&gt; xhr.removeEventListener(m, handler, !1));
+ switch (ev.type) {
+ case 'load':
+ if (xhr.status == 200) {
+ cb(xhr.response);
+ break;
+ }
+ default:
+ Services.prompt.alert(null, 'XHR Error', 'Error Fetching Package: ' + xhr.statusText + ' [' + ev.type + ':' + xhr.status + ']');
+ break;
+ }
+ };
+
+ let evf = f =&gt; ['load', 'error', 'abort'].forEach(f);
+ evf(m =&gt; xhr.addEventListener(m, handler, false));
+
+ xhr.mozBackgroundRequest = true;
+ xhr.open('GET', url, true);
+ xhr.channel.loadFlags |= Ci.nsIRequest.LOAD_ANONYMOUS | Ci.nsIRequest.LOAD_BYPASS_CACHE | Ci.nsIRequest.INHIBIT_PERSISTENT_CACHING;
+ xhr.responseType = "arraybuffer"; //dont set it, so it returns string, you dont want arraybuffer. you only want this if your url is to a zip file or some file you want to download and make a nsIArrayBufferInputStream out of it or something
+ xhr.send(null);
+}
+
+xhr('https://www.gravatar.com/avatar/eb9895ade1bd6627e054429d1e18b576?s=24&amp;d=identicon&amp;r=PG&amp;f=1', data =&gt; {
+ Services.prompt.alert(null, 'XHR Success', data);
+ var file = OS.Path.join(OS.Constants.Path.desktopDir, "test.png");
+ var promised = OS.File.writeAtomic(file, new UInt8Array(data));
+ promised.then(
+ function() {
+ alert('succesfully saved image to desktop')
+ },
+ function(ex) {
+ alert('FAILED in saving image to desktop')
+ }
+ );
+});</code></pre>
diff --git a/files/zh-cn/mozilla/tech/xpcom/setting_http_request_headers/index.html b/files/zh-cn/mozilla/tech/xpcom/setting_http_request_headers/index.html
new file mode 100644
index 0000000000..b91030b424
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpcom/setting_http_request_headers/index.html
@@ -0,0 +1,261 @@
+---
+title: Setting HTTP request headers
+slug: Mozilla/Tech/XPCOM/Setting_HTTP_request_headers
+translation_of: Mozilla/Tech/XPCOM/Setting_HTTP_request_headers
+---
+<p><a href="https://developer.mozilla.org/en-US/docs/HTTP">HTTP</a> 是网络背后的核心技术之一。除了实质内容之外,一些重要的信息通过HTTP 头传递给HTTP 请求和响应。</p>
+
+<p>你可以添加你自己的HTTP头到应用程序所做的任何请求中,不论你的代码是否启动了显式打开了基于 <a href="/zh-cn/nsIXMLHttpRequest" title="zh-cn/XMLHttpRequest">XMLHttpRequest</a> 活动、&lt;img&gt;元素或者甚至是从css中的 HTTP Channel的请求。</p>
+
+<h3 id="HTTP_Channels">HTTP Channels</h3>
+
+<p>当你处理HTTP请求和响应时,通常情况下你是通过 <code><a href="/zh-cn/XPCOM_Interface_Reference/nsIHttpChannel" title="zh-cn/XPCOM_Interface_Reference/nsIHttpChannel">nsIHttpChannel</a></code>来做的。 <code><a href="/zh-cn/XPCOM_Interface_Reference/nsIHttpChannel" title="zh-cn/XPCOM_Interface_Reference/nsIHttpChannel">nsIHttpChannel</a></code>接口有一些属性和方法,但是这下方法中我们只对<code>setRequestHeader感兴趣。这个方法允许我们设置一个</code> <em>HTTP request header</em>.</p>
+
+<p>下面是设置一个HTTP header 的简单代码</p>
+
+<pre class="eval">// adds "X-Hello: World" header to the request
+httpChannel.setRequestHeader("X-Hello", "World", false);
+</pre>
+
+<p>在这个示例代码中我们有一个变量名为httpChannel,它是一个nsIHttpChannel的实例。</p>
+
+<p>setRequestHeader有三个参数,第一个参数是HTTP请求头的名字,第二个参数是HTTP请求头的值,第三个参数我们暂时忽略它,总设置其为false。</p>
+
+<p>在我们的示例代码中,我们为HTTP reques header中增加了被我们命名为X-Hello的HTTP请求头,其值为World</p>
+
+<div class="note">
+<p><s><strong>NOTE</strong>: If you are making up your own HTTP header, you MUST put a <code>X-</code> in front of the name. (In our example, our made up HTTP header is <code>X-Hello</code> and NOT <code>Hello</code> because we correctly added the <code>X-</code> in front of our name.)</s></p>
+
+<p><br>
+ <strong>No longer the case: <a class="external" href="http://tools.ietf.org/html/draft-ietf-appsawg-xdash-02" title="http://tools.ietf.org/html/draft-ietf-appsawg-xdash-02">http://tools.ietf.org/html/draft-ietf-appsawg-xdash-02</a></strong></p>
+</div>
+
+<h3 id="Notifications" name="Notifications">Notifications</h3>
+
+<p>The question that may be coming to your mind right now is, how do you get the <code>nsIHttpChannel</code> when an HTTP request is made.</p>
+
+<p>In the case your code initiates the request, you probably already have one. Trapping other requests is done with notifications, which are a lot like <em>events</em> or <em>signals</em> found in other languages and frameworks.</p>
+
+<p>In particular, to get the <code>nsIHttpChannel</code> just before the HTTP request is made we need to <em>observe</em> the <code>"http-on-modify-request"</code> topic. (And yes, <code>"http-on-modify-request"</code> is a string.)</p>
+
+<div class="note">
+<p><strong>NOTE</strong>: There are many topics, besides just <code>"http-on-modify-request"</code>, that you can get notifications about, for example <code>"http-on-examine-response"</code> and <code>"xpcom-shutdown"</code>. You can also make up your own topics and send out your own notifications.</p>
+
+<p>For more information about notifications framework and a list of common notification topics, see <a href="/zh-cn/Observer_Notifications" title="zh-cn/Observer_Notifications">Observer Notifications</a>.</p>
+</div>
+
+<h3 id="Observers" name="Observers">Observers</h3>
+
+<p>To get notified about some topic (like <code>"http-on-modify-request"</code>) we need to create an <strong>observer</strong>. An observer is a component implementing <a href="/zh-cn/XPCOM_Interface_Reference/nsIObserver" title="zh-cn/nsIObserver">nsIObserver</a> interface. And once the observer is <em>registered</em> for a topic, it will get notified about the topic by having its <code>observe</code> method called.</p>
+
+<p>Below is an example observer that adds a custom header "X-Hello" to the channel passed in for http-on-modify-request notification:</p>
+
+<pre class="brush: js">var httpRequestObserver =
+{
+ observe: function(subject, topic, data)
+ {
+ if (topic == "http-on-modify-request") {
+ var httpChannel = subject.QueryInterface(Components.interfaces.nsIHttpChannel);
+ httpChannel.setRequestHeader("X-Hello", "World", false);
+ }
+ }
+};
+</pre>
+
+<p><span class="comment">div class="note"&gt; Doesn't seem very suitable for this article; readers should are typically assumed to be familiar with JS. Nickolay '''NOTE''': Often people expect <a href="/zh-cn/JavaScript" title="zh-cn/JavaScript">JavaScript</a> to be just like <a href="/zh-cn/Java" title="zh-cn/Java">Java</a>. And while superficially, they look very similar, there are some important differences between the two. For example, while Java is an &lt;em&gt;object-oriented programming language&lt;/em&gt;, JavaScript is not. JavaScript is &lt;em&gt;prototype-based programming language&lt;/em&gt; and as such while it has &lt;em&gt;objects&lt;/em&gt; it does not have &lt;em&gt;classes&lt;/em&gt;. (Which is why, if you are not well versed with JavaScript, the object creation in the sample code above may look strange.) &lt;/div</span></p>
+
+<p>Note that the number of parameter that the <code>observe</code> method takes is important. It takes 3 parameters (as we've shown in the example code above). For the <code>"http-on-modify-request"</code> topic, the first parameter (named <code>subject</code> in the code above) will be the <code>nsIHttpChannel</code>. However, it is passed to us as an <code><a href="/zh-cn/XPCOM_Interface_Reference/nsISupports" title="zh-cn/nsISupports">nsISupports</a></code>. So we need to <em>change</em> the <code>nsISupports</code> into a <code>nsIHttpChannel</code> which is what the <code>QueryInterface</code> call does. And yes, <em>converting</em> objects from one kind to another is very ugly, and lacks (what is usually called) <em>syntactic sugar</em>.</p>
+
+<p>The second line of code in the <code>if</code> block should already be familiar to you. It is the same code we used before, earlier in this article, to add the HTTP request header.</p>
+
+<p>The name of this object -- <code>httpRequestObserver</code> -- isn't important. We could have named it anything we liked.</p>
+
+<h3 id="Registering" name="Registering">Registering</h3>
+
+<p>After we've created the observer, we need to register it. In our case, we want to register it for the <code>"http-on-modify-request"</code> topic. We can do this with the code below.</p>
+
+<pre class="eval">var observerService = Components.classes["@<a class="linkification-ext external" href="http://mozilla.org/observer-service;1" title="Linkification: http://mozilla.org/observer-service;1">mozilla.org/observer-service;1</a>"]
+ .getService(Components.interfaces.<a href="/zh-cn/XPCOM_Interface_Reference/nsIObserverService" title="zh-cn/XPCOM_Interface_Reference/nsIObserverService">nsIObserverService</a>);
+observerService.addObserver(httpRequestObserver, "http-on-modify-request", false);
+</pre>
+
+<p>The first statement gets the object that will let us register with topics that we want to get notified about.</p>
+
+<p>The second statement does the actual registering. We are saying we want <code>httpRequestObserver</code> to be notified (by calling its <code>observe</code> method) when a <code>"http-on-modify-request"</code> topic takes place (which we know happens just before each HTTP request).</p>
+
+<h3 id="Unregistering" name="Unregistering">Unregistering</h3>
+
+<p>You should unregister the observer on shutdown. Failing to do that may cause memory leaks. To unregister the observer use <code>nsIObserverService.removeObserver</code> as follows:</p>
+
+<pre class="eval">observerService.removeObserver(httpRequestObserver, "http-on-modify-request");</pre>
+
+<h3 id="All-in-one_example">All-in-one example</h3>
+
+<p>Here is a slightly different version of our <code>httpRequestObserver</code> object. While the previous version we showed before was good for learning, in an actual real-world application, you'd probably want to code it more like the following.</p>
+
+<pre class="brush: js">var httpRequestObserver =
+{
+ observe: function(subject, topic, data)
+ {
+ if (topic == "http-on-modify-request") {
+ var httpChannel = subject.QueryInterface(Components.interfaces.nsIHttpChannel);
+ httpChannel.setRequestHeader("X-Hello", "World", false);
+ }
+ },
+
+ get observerService() {
+ return Components.classes["@<a class="linkification-ext" href="http://mozilla.org/observer-service;1" title="Linkification: http://mozilla.org/observer-service;1">mozilla.org/observer-service;1</a>"]
+ .getService(Components.interfaces.nsIObserverService);
+ },
+
+ register: function()
+ {
+ this.observerService.addObserver(this, "http-on-modify-request", false);
+ },
+
+ unregister: function()
+ {
+ this.observerService.removeObserver(this, "http-on-modify-request");
+ }
+};
+</pre>
+
+<p>This object has a convenience <code>register()</code> and <code>unregister()</code> methods, so in order to activate it you just need to call:</p>
+
+<pre class="eval">httpRequestObserver.register();
+</pre>
+
+<p>You should also remember to unregister the observer at shutdown:</p>
+
+<pre class="eval">httpRequestObserver.unregister();
+</pre>
+
+<p>And that's it.</p>
+
+<h3 id="XPCOM_components" name="XPCOM_components">XPCOM components</h3>
+
+<p>You need to register a single <code>http-on-modify-request</code> observer per application (and not one per window). This means that you should put the observer's implementation in an <a href="/zh-cn/How_to_Build_an_XPCOM_Component_in_Javascript" title="zh-cn/How_to_Build_an_XPCOM_Component_in_Javascript">XPCOM component</a> instead of an <a href="/zh-cn/XUL_Overlays" title="zh-cn/XUL_Overlays">overlay</a>. If you want to support Gecko2 (Firefox4) you need to register your javascript component as described here: <a class="linkification-ext" href="/zh-cn/XPCOM/XPCOM_changes_in_Gecko_2.0#JavaScript_components" title="Linkification: https://developer.mozilla.org/zh-cn/XPCOM/XPCOM_changes_in_Gecko_2.0#JavaScript_components">https://developer.mozilla.org/zh-cn/XPCOM/XPCOM_changes_in_Gecko_2.0#JavaScript_components</a>.</p>
+
+<pre class="brush: js">var headerName = "X-hello";
+var headerValue = "world";
+
+function LOG(text)
+{
+ // var consoleService = Components.classes["@<a class="linkification-ext" href="http://mozilla.org/consoleservice;1" title="Linkification: http://mozilla.org/consoleservice;1">mozilla.org/consoleservice;1</a>"].getService(Components.interfaces.nsIConsoleService);
+ // consoleService.logStringMessage(text);
+}
+
+function myHTTPListener() { }
+
+myHTTPListener.prototype = {
+
+ observe: function(subject, topic, data)
+ {
+ if (topic == "http-on-modify-request") {
+
+ LOG("----------------------------&gt; (" + subject + ") mod request");
+
+ var httpChannel = subject.QueryInterface(Components.interfaces.nsIHttpChannel);
+ httpChannel.setRequestHeader(headerName, headerValue, false);
+ return;
+ }
+
+
+ if (topic == "profile-after-change") {
+
+ LOG("----------------------------&gt; profile-after-change");
+
+ var os = Components.classes["@<a class="linkification-ext" href="http://mozilla.org/observer-service;1" title="Linkification: http://mozilla.org/observer-service;1">mozilla.org/observer-service;1</a>"]
+ .getService(Components.interfaces.nsIObserverService);
+
+ os.addObserver(this, "http-on-modify-request", false);
+ return;
+ }
+ },
+
+ QueryInterface: function (iid) {
+ if (iid.equals(Components.interfaces.nsIObserver) ||
+ iid.equals(Components.interfaces.nsISupports))
+ return this;
+
+ Components.returnCode = Components.results.NS_ERROR_NO_INTERFACE;
+ return null;
+ },
+};
+
+var myModule = {
+ registerSelf: function (compMgr, fileSpec, location, type) {
+
+ var compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+ compMgr.registerFactoryLocation(this.myCID,
+ this.myName,
+ this.myProgID,
+ fileSpec,
+ location,
+ type);
+
+
+ LOG("----------------------------&gt; registerSelf");
+
+ var catMgr = Components.classes["@<a class="linkification-ext" href="http://mozilla.org/categorymanager;1" title="Linkification: http://mozilla.org/categorymanager;1">mozilla.org/categorymanager;1</a>"].getService(Components.interfaces.nsICategoryManager);
+ catMgr.addCategoryEntry("app-startup", this.myName, this.myProgID, true, true);
+ },
+
+
+ getClassObject: function (compMgr, cid, iid) {
+
+ LOG("----------------------------&gt; getClassObject");
+
+ return this.myFactory;
+ },
+
+ myCID: Components.ID("{9cf5f3df-2505-42dd-9094-c1631bd1be1c}"),
+
+ myProgID: "@dougt/myHTTPListener;1",
+
+ myName: "Simple HTTP Listener",
+
+ myFactory: {
+ QueryInterface: function (aIID) {
+ if (!aIID.equals(Components.interfaces.nsISupports) &amp;&amp;
+  !aIID.equals(Components.interfaces.nsIFactory))
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ return this;
+ },
+
+ createInstance: function (outer, iid) {
+
+ LOG("----------------------------&gt; createInstance");
+
+ return new myHTTPListener();
+ }
+ },
+
+ canUnload: function(compMgr) {
+ return true;
+ }
+};
+
+function NSGetModule(compMgr, fileSpec) {
+ return myModule;
+}
+</pre>
+
+<h3 id="Privacy_and_security_good_practice">Privacy and security good practice</h3>
+
+<p>A use case for setting specific a HTTP request header is to have a specific web site be able to check if a specific plugin / addon / extension is installed.</p>
+
+<p>The good practice is not to have this specific HTTP header (<code>for example </code>"X-site.net-extension") sent all the time but only when doing requests with this specific web sites. By not advertising to all sites what extensions are installed this improves both privacy (this makes it harder to track a user known by his set of plugins, addons and extensions) and security (some plugins, addons and extensions may be known to have flaws by attackers).</p>
+
+<p>With this privacy and security addition the code to use becomes:</p>
+
+<pre class="brush: js"> observe: function(subject, topic, data)
+ {
+ if (topic == "http-on-modify-request") {
+ var httpChannel = subject.QueryInterface(Components.interfaces.nsIHttpChannel);
+<code> if (/site.net/.test(</code>httpChannel<code>.originalURI.host)) {
+</code> httpChannel.setRequestHeader("X-Hello", "World", false);
+ }
+ }
+ },
+</pre>
diff --git a/files/zh-cn/mozilla/tech/xpidl/index.html b/files/zh-cn/mozilla/tech/xpidl/index.html
new file mode 100644
index 0000000000..c976d0bae9
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpidl/index.html
@@ -0,0 +1,502 @@
+---
+title: XPIDL
+slug: Mozilla/Tech/XPIDL
+tags:
+ - XPCOM
+ - xpidl
+translation_of: Mozilla/Tech/XPIDL
+---
+<p> </p>
+<p><strong>XPIDL</strong> 是一个用于指定 <a href="https://developer.mozilla.org/en-US/docs/XPCOM" title="XPCOM">XPCOM</a> 接口类的接口描述语言</p>
+<p>Interface Description Languages (IDL) are used to describe interfaces in a language- and machine-independent way. IDLs make it possible to define interfaces which can then be processed by tools to autogenerate language-dependent interface specifications. XPIDL is expected to converge towards WebIDL in the future.</p>
+<div class="note">
+ <p><strong>Note:</strong> Starting in {{Gecko("9.0")}}, the older <a href="https://developer.mozilla.org/en-US/docs/XPIDL/xpidl" title="XPIDL/xpidl">xpidl</a> utility, which was previously used to generate C++ header files, typelib information, and so forth has been replaced with<a href="https://developer.mozilla.org/en-US/docs/XPIDL/pyxpidl" title="XPIDL/pyxpidl">pyxpidl</a> in the <a href="https://developer.mozilla.org/en-US/docs/Gecko_SDK" title="Gecko SDK">Gecko SDK</a>. <a href="https://developer.mozilla.org/en-US/docs/XPIDL/pyxpidl" title="XPIDL/pyxpidl">pyxpidl</a> has been used for some time now, but now the older tool has been fully retired.</p>
+</div>
+<h2 id="Writing_XPIDL_interface_files" name="Writing_XPIDL_interface_files" style="margin-bottom: 20px; line-height: 30px;">Writing XPIDL interface files</h2>
+<p>XPIDL closely resembles <a class="external external-icon" href="http://www.omg.org/gettingstarted/omg_idl.htm" style="white-space: pre-line;">OMG IDL</a>, with extended syntax to handle IIDs and additional types. Some examples are in the {{Source("xpcom/base")}} and {{Source("xpcom/ds")}} directories of the Mozilla tree.</p>
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/docs/XPIDL/Syntax" title="XPIDL/Syntax">XPIDL:Syntax</a> (Now up to date again)</li>
+ <li><a class="external external-icon" href="http://www.mozilla.org/scriptable/xpidl/syntax.html" style="white-space: pre-line;">XPIDL syntax</a> (Out of date)</li>
+ <li><a class="external external-icon" href="http://www.mozilla.org/scriptable/xpidl/idl-authors-guide/index.html" style="white-space: pre-line;">XPIDL Author's Guide</a> (Not as out of date)</li>
+</ul>
+<h2 id="Explanation_of_IDL_semantics" name="Explanation_of_IDL_semantics" style="margin-bottom: 20px; line-height: 30px;">Explanation of IDL semantics</h2>
+<p>A full guide to the syntax can be found at <a href="https://developer.mozilla.org/en-US/docs/XPIDL/Syntax" title="XPIDL/Syntax">XPIDL:Syntax</a>, which is written in an ABNF form.</p>
+<p>An xpidl file is essentially just a series of declarations. At the top level, we can define typedefs, native types, or interfaces. Interfaces may furthermore contain typedefs, natives, methods, constants, or attributes. Most declarations can have properties applied to them.</p>
+<h3 id="Types" style="line-height: 24px; letter-spacing: normal;">Types</h3>
+<p>There are three ways to make types: a typedef, a native, or an interface. In addition, there are a few built-in native types. The built-in native types are those listed under the type_spec production above. The following is the correspondence table:</p>
+<table class="standard-table">
+ <caption>
+ Table 1: Standard IDL types</caption>
+ <thead>
+ <tr>
+ <th scope="col">IDL</th>
+ <th scope="col">C++ in parameter</th>
+ <th scope="col">C++ out parameter</th>
+ <th scope="col">JS type</th>
+ <th scope="col">Notes</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>boolean</code></td>
+ <td><code>bool</code></td>
+ <td><code>bool *</code></td>
+ <td>boolean</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>char</code></td>
+ <td><code>char</code></td>
+ <td><code>char *</code></td>
+ <td>string</td>
+ <td>Only chars in range \u0000-\u00ff permitted</td>
+ </tr>
+ <tr>
+ <td><code>double</code></td>
+ <td><code>double</code></td>
+ <td><code>double *</code></td>
+ <td>number</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>float</code></td>
+ <td><code>float</code></td>
+ <td><code>float *</code></td>
+ <td>number</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>long</code></td>
+ <td><code>int32_t</code></td>
+ <td><code>int32_t *</code></td>
+ <td>number</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>long long</code></td>
+ <td><code>int64_t</code></td>
+ <td><code>int64_t *</code></td>
+ <td>number</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>octet</code></td>
+ <td><code>uint8_t</code></td>
+ <td><code>uint8_t *</code></td>
+ <td>number</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>short</code></td>
+ <td><code>int16_t</code></td>
+ <td><code>int16_t *</code></td>
+ <td>number</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>string</code></td>
+ <td><code>const char *</code></td>
+ <td><code>char **</code></td>
+ <td>string</td>
+ <td>Only chars in range \u0000-\u00ff permitted</td>
+ </tr>
+ <tr>
+ <td><code>unsigned long</code></td>
+ <td><code>uint32_t</code></td>
+ <td><code>uint32_t *</code></td>
+ <td>number</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>unsigned long long</code></td>
+ <td><code>uint64_t</code></td>
+ <td><code>uint64_t *</code></td>
+ <td>number</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>unsigned short</code></td>
+ <td><code>uint16_t</code></td>
+ <td><code>uint16_t *</code></td>
+ <td>number</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>wchar</code></td>
+ <td><code>PRUnichar</code></td>
+ <td><code>PRUnichar *</code></td>
+ <td>string</td>
+ <td>Full Unicode set permitted</td>
+ </tr>
+ <tr>
+ <td><code>wstring</code></td>
+ <td><code>const PRUnichar *</code></td>
+ <td><code>PRUnichar **</code></td>
+ <td>string</td>
+ <td>Full Unicode set permitted</td>
+ </tr>
+ </tbody>
+</table>
+<p>In addition to this list, nearly every IDL file includes <code>nsrootidl.idl</code> in some fashion, which also defines the following types:</p>
+<table class="standard-table">
+ <caption>
+ Table 2: Types provided by nsrootidl.idl</caption>
+ <thead>
+ <tr>
+ <th scope="col">IDL typedef</th>
+ <th scope="col">C++ in parameter</th>
+ <th scope="col">C++ out parameter</th>
+ <th scope="col">JS type</th>
+ <th scope="col">Notes</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>PRTime</code></td>
+ <td colspan="2" rowspan="1">(XPIDL <code>unsigned long long</code> typedef, 64 bits)</td>
+ <td rowspan="1">number</td>
+ <td rowspan="1">PRTime is in microseconds, while JS date assumes time in milliseconds</td>
+ </tr>
+ <tr>
+ <td><code>nsresult</code></td>
+ <td colspan="2" rowspan="1">(XPIDL <code>unsigned long</code>typedef, 32 bits)</td>
+ <td rowspan="1">number</td>
+ <td rowspan="1"> </td>
+ </tr>
+ <tr>
+ <td><code>nsrefcnt</code></td>
+ <td colspan="2" rowspan="1">(XPIDL <code>unsigned long</code>typedef, 32 bits)</td>
+ <td rowspan="1">number</td>
+ <td rowspan="1"> </td>
+ </tr>
+ <tr>
+ <td><code>size_t</code></td>
+ <td colspan="2" rowspan="1">(XPIDL <code>unsigned long</code>typedef, 32 bits)</td>
+ <td rowspan="1">number</td>
+ <td rowspan="1"> </td>
+ </tr>
+ <tr>
+ <td><code>voidPtr</code></td>
+ <td><code>void *</code></td>
+ <td><code>void *</code></td>
+ <td>not allowed</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>charPtr</code></td>
+ <td><code>char *</code></td>
+ <td><code>char **</code></td>
+ <td>not allowed</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>unicharPtr</code></td>
+ <td><code>PRUnichar *</code></td>
+ <td><code>PRUnichar **</code></td>
+ <td>not allowed</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>nsIDRef</code></td>
+ <td><code>const nsID &amp;</code></td>
+ <td><code>nsID *</code></td>
+ <td>?</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>nsIIDRef</code></td>
+ <td><code>const nsIID &amp;</code></td>
+ <td><code>nsIID *</code></td>
+ <td>?</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>nsCIDRef</code></td>
+ <td><code>const nsCID &amp;</code></td>
+ <td><code>nsCID *</code></td>
+ <td>?</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>nsIDPtr</code></td>
+ <td><code>const nsID *</code></td>
+ <td><code>nsID **</code></td>
+ <td>?</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>nsIIDPtr</code></td>
+ <td><code>const nsIID *</code></td>
+ <td><code>nsIID **</code></td>
+ <td>?</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>nsCIDPtr</code></td>
+ <td><code>const nsCID *</code></td>
+ <td><code>nsCID **</code></td>
+ <td>?</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>nsIID</code></td>
+ <td><code>const nsIID</code></td>
+ <td><code>nsIID *</code></td>
+ <td>?</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>nsID</code></td>
+ <td><code>const nsID</code></td>
+ <td><code>nsID *</code></td>
+ <td>?</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>nsCID</code></td>
+ <td><code>const nsCID</code></td>
+ <td><code>nsCID *</code></td>
+ <td>?</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>nsQIResult</code></td>
+ <td><code>void *</code></td>
+ <td><code>void **</code></td>
+ <td>object</td>
+ <td>Should only be used with methods that act like QueryInterface</td>
+ </tr>
+ <tr>
+ <td><code>DOMString</code></td>
+ <td><code>const nsAString &amp;</code></td>
+ <td><code>nsAString &amp;</code></td>
+ <td>string</td>
+ <td>Full Unicode set permitted</td>
+ </tr>
+ <tr>
+ <td><code>AUTF8String</code></td>
+ <td><code>const nsACString &amp;</code></td>
+ <td><code>nsACString &amp;</code></td>
+ <td>string</td>
+ <td>Full Unicode set permitted (translated to UTF-8)</td>
+ </tr>
+ <tr>
+ <td><code>ACString</code></td>
+ <td><code>const nsACString &amp;</code></td>
+ <td><code>nsACString &amp;</code></td>
+ <td>string</td>
+ <td>Only chars in range \u0000-\u00ff permitted</td>
+ </tr>
+ <tr>
+ <td><code>AString</code></td>
+ <td><code>const nsAString &amp;</code></td>
+ <td><code>nsAString &amp;</code></td>
+ <td>string</td>
+ <td>Full Unicode set permitted</td>
+ </tr>
+ <tr>
+ <td><code>jsval</code></td>
+ <td><code>const jsval &amp;</code></td>
+ <td><code>jsval *</code></td>
+ <td>anything</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td><code>jsid</code></td>
+ <td><code>jsid</code></td>
+ <td><code>jsid *</code></td>
+ <td>not allowed</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+<p>Typedefs in IDL are basically as they are in C or C++: you define first the type that you want to refer to and then the name of the type. Types can of course be one of the fundamental types, or any other type declared via a typedef, interface, or a native type.</p>
+<p>Native types are types which correspond to a given C++ type. Most native types are not scriptable: if it is not present in the list above, then it is certainly not scriptable (some of the above, particularly jsid, are not scriptable).</p>
+<p>The contents of the parentheses of a native type declaration (although native declarations without parentheses are parsable, I do not trust that they are properly handled by the xpidl handlers) is a string equivalent to the C++ type. XPIDL itself does not interpret this string, it just literally pastes it anywhere the native type is used. The interpretation of the type can be modified by having properties on the native declaration:</p>
+<table class="standard-table">
+ <caption>
+ Table 3: Native type definitions</caption>
+ <tbody>
+ <tr>
+ <td>astring</td>
+ <td>This is an nsAString declaration. Overrides native string.</td>
+ </tr>
+ <tr>
+ <td>cstring</td>
+ <td>This is an nsACString declaration. Overrides native string.</td>
+ </tr>
+ <tr>
+ <td>domstring</td>
+ <td>This is an nsAString declaration. Overrides native string.</td>
+ </tr>
+ <tr>
+ <td>jsval</td>
+ <td>This type gets const when an in type. Special in typelib.</td>
+ </tr>
+ <tr>
+ <td>nsid</td>
+ <td>This type gets const when an in type. Special in typelib.</td>
+ </tr>
+ <tr>
+ <td>ptr</td>
+ <td>The type is really (native str)*</td>
+ </tr>
+ <tr>
+ <td>ref</td>
+ <td>The type is really (native str)&amp;</td>
+ </tr>
+ <tr>
+ <td>utf8string</td>
+ <td>This is an nsACString declaration whose text is UTF-8.</td>
+ </tr>
+ </tbody>
+</table>
+<p class="warning" style="background-color: rgba(193, 56, 50, 0.839844); font-size: 14px;">As far as I can tell, these properties also apply to typedefs. Need to verify.</p>
+<h3 id="Constants" style="line-height: 24px; letter-spacing: normal;">Constants</h3>
+<p>Constants are technically legal at the top level, but xpidl I forbids them from being placed there; instead, they must be in an interface. The only constants supported are those which become integer types when compiled to source code; string constants and floating point constants, though parseable, cannot be made into a header or xpt file.</p>
+<p>Constants are emitted in header files using anonymous enums, although there is an outstanding patch that combines adjacent constants into the same anonymous enums to quiet enum mismatch warnings.</p>
+<h3 id="Interfaces" style="line-height: 24px; letter-spacing: normal;">Interfaces</h3>
+<p>Specifying interfaces is the primary purpose of using xpidl. Interfaces are basically a collection of constants, methods, and attributes; in Mozilla, these are the primary ways in which JavaScript code can interact with native C++ code. Furthermore, interfaces can also inherit from another interface. Every interface should inherit <a href="https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsISupports" title="nsISupports">nsISupports</a> in some fashion. However, it is generally not recommended to have a chain of interfaces inheriting from each other if you intend to have a chain of implementations for each interface, as it can cause problems in C++ code.</p>
+<table class="standard-table">
+ <caption>
+ Table 4: Basic interface attributes</caption>
+ <thead>
+ <tr>
+ <th scope="col">Attribute</th>
+ <th scope="col">Interpretation</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>uuid(12345678-fedc-ba98-7654-0123456789ab)</code></td>
+ <td>This is the internal way this interface is accessed; it must be unique, and the uuid must be changed anytime any part of the interface or its ancestors are changed. For instructions on how to generate an UUID see <a href="https://developer.mozilla.org/en-US/docs/Generating_GUIDs" title="Generating GUIDs">Generating GUIDs</a>.</td>
+ </tr>
+ <tr>
+ <td><code>builtinclass</code></td>
+ <td>JavaScript classes are forbidden from implementing this interface. All children must also be marked with this property.</td>
+ </tr>
+ <tr>
+ <td><code>function</code></td>
+ <td>The JavaScript implementation of this interface may be a function that is invoked on property calls instead of an object with the given property</td>
+ </tr>
+ <tr>
+ <td><code>scriptable</code></td>
+ <td>This interface is usable by JavaScript classes. Must inherit from a<code>scriptable</code> interface.</td>
+ </tr>
+ <tr>
+ <td><code>deprecated</code></td>
+ <td>This interface should no longer be used. The compiler will emit warnings if you attempt to use this.</td>
+ </tr>
+ </tbody>
+</table>
+<h3 id="Methods_and_attributes" style="line-height: 24px; letter-spacing: normal;">Methods and attributes</h3>
+<p>Interfaces declare a series of attributes and methods. Attributes in IDL are akin to JavaScript properties, in that they are a getter and (optionally) a setter pair. In JavaScript contexts, attributes are exposed as a regular property access, while native code sees attributes as a Get and possibly a Set method.</p>
+<p>Attributes can be declared readonly, in which case setting causes an error to be thrown in script contexts and native contexts lack the Set method, by using the "readonly" keyword.</p>
+<p>To native code, on attribute declared 'attribute type foo;' is syntactic sugar for the declaration of two methods 'type getFoo();' and 'void setFoo(in type foo);'. If foo were declared readonly, the latter method would not be present. Attributes support all of the properties of methods with the exception of <code>optional_argc</code>, as this does not make sense for attributes.</p>
+<p>There are some special rules for attribute naming. As a result of vtable munging by the MSVC++ compiler, an attribute with the name `IID' is forbidden. In addition, any attribute whose name matches the regex /^[a-z]{2,3}I[A-Z][a-z]/ is emitted with a warning, as its name looks like an nsIInterface or a mozIInterface declaration. Also like methods, if the first character of an attribute is lowercase in IDL, it is made uppercase in native code only.</p>
+<p>Methods define a return type and a series of in and out parameters. When called from a JavaScript context, they invocation looks as it is declared for the most part; some parameter properties can adjust what the code looks like. The calls are more mangled in native contexts.</p>
+<p>An important attribute for methods and attributes is scriptability. A method or attribute is scriptable if it is declared in a <code>scriptable</code> interface and it lacks a<code>noscript</code> or <code>notxpcom</code> property. Any method that is not scriptable can only be accessed by native code. However, scriptable methods must contain parameters and a return type that can be translated to script: any native type, save those declared with an <code>nsid</code>, <code>domstring</code>, <code>utf8string</code>, <code>cstring</code>, <code>astring</code>, or <code>jsval</code> property, may not be used in a scriptable method or attribute. An exception to the above rule is if the parameter has the <code>iid_is</code> property (a special case for some QueryInterface-like operations). In general, this means that the only usable native types are those declared in nsrootidl.idl (see above).</p>
+<p>Methods and attributes are mangled on conversion to native code. If a method is declared <code>notxpcom</code>, the mangling of the return type is prevented, so it is called mostly as it looks. Otherwise, the return type of the native method is nsresult, and the return type acts as a final outparameter if it is not void. The name is translated so that the first character is unconditionally uppercase; subsequent characters are unaffected. However, the presence of the <code>binaryname</code> property allows the user to select another name to use in native code (to avoid conflicts with other functions). For example, the method '[binaryname(foo)] void bar();' becomes 'nsresult Foo()' in native code (note that capitalization is still applied). However, the capitalization is not applied when using <code>binaryname</code> with attributes; i.e., <code>[binaryname(foo)] readonly attribute Quux bar;</code> becomes <code>Getfoo(Quux**)</code> in native code. Attributes named 'IID' and methods named 'GetIID' are forbidden, although this is checked before binaryname conversion.</p>
+<p>The <code>implicit_jscontext</code> and <code>optional_argc</code> parameters are properties which help native code implementations determine how the call was made from script. If<code>implicit_jscontext</code> is present on a method, then an additional JSContext *cx parameter is added just after the regular list which receives the context of the caller. If <code>optional_argc</code> is present, then an additional uint8_t _argc method is added at the end which receives the number of optional arguments that were actually used (obviously, you need to have an optional argument in the first place). Note that if both properties are set, the JSContext *cx is added first, followed by the uint8_t _argc, and then ending with return value parameter. Finally, as an exception to everything already mentioned, for attribute getters and setters the JSContext *cx comes before any other arguments.</p>
+<p>In addition, methods and attributes can be both marked as deprecated with the<code>deprecated</code> property, which causes compilers to emit deprecation usage warnings. Note that this is only verified in native code and not script code.</p>
+<p>The final native-only property is <code>nostdcall</code>. Normally, declarations are made in the stdcall ABI on Windows to be ABI-compatible with COM interfaces. Any non-scriptable method or attribute with <code>nostdcall</code> instead uses the thiscall ABI convention. Methods without this property generally use NS_IMETHOD in their declarations and NS_IMETHODIMP in their definitions to automatically add in the stdcall declaration specifier on requisite compilers; those that use this method may use a plain `nsresult' instead.</p>
+<h4 id="Source_and_Binary_Compatibility" style="line-height: 18px; letter-spacing: normal;">Source and Binary Compatibility</h4>
+<p>Some consumers of IDL interfaces create binary plugins that expect the interfaces to be stored in a specific way in memory. In other words, some changes made to IDL interfaces require the author to modify the unique identifier (IID) in order to make it clear to plugins that utilize these interfaces that they have changed, and thus their plugin must be recompiled.</p>
+<p>Common changes to an interface, such as changes to a method signature, number of arguments, and number or type of attributes, automatically require an IID change. In addition, some changes to interface attributes require that an IID be changed, as well. When a change to an interface made by an XPIDL developer requires that third-party binary addons be recompiled, we say that it affects <em>binary compatibility</em>. When a change to an interface made by an XPIDL developer requires that third-party binary addons change their source code, we say that it affects <em>source compatibility. </em>In table 5, the columns on the far right indicate whether changes to a specific attribute affect source compatibility, binary compatibility, or both.</p>
+<table>
+ <caption>
+ Table 5: Optional interface attributes</caption>
+ <thead>
+ <tr>
+ <th scope="row">Attribute</th>
+ <th scope="col">Valid for methods</th>
+ <th scope="col">Valid for attributes</th>
+ <th scope="col">Effect</th>
+ <th scope="col">Changes Source Compatibility?</th>
+ <th scope="col">Changes Binary Compatibility?</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>binaryname(foo)</code></td>
+ <td>Y</td>
+ <td>Y</td>
+ <td>Results in the C++ method being called "<code>Foo</code>"</td>
+ <td>Y</td>
+ <td>N</td>
+ </tr>
+ <tr>
+ <td><code>deprecated</code></td>
+ <td>Y</td>
+ <td>Y</td>
+ <td>Emits a compiler warning if used in C++ code</td>
+ <td>N</td>
+ <td>N</td>
+ </tr>
+ <tr>
+ <td><code>implicit_jscontext</code></td>
+ <td>Y</td>
+ <td>Y</td>
+ <td>Adds an additional<code>JSContext *cx</code> parameter to the C++ implementation</td>
+ <td>Y</td>
+ <td>Y</td>
+ </tr>
+ <tr>
+ <td><code>noscript</code></td>
+ <td>Y</td>
+ <td>Y</td>
+ <td>Prohibits the method/attribute from being accessible in JS code</td>
+ <td>N</td>
+ <td>N</td>
+ </tr>
+ <tr>
+ <td><code>nostdcall</code></td>
+ <td>Y</td>
+ <td>Y</td>
+ <td>The C++ implementation uses <code>virtual nsresult</code>instead of<code>NS_IMETHOD</code>/<code>NS_IMETHODIMP</code></td>
+ <td>Y</td>
+ <td>Y</td>
+ </tr>
+ <tr>
+ <td><code>notxpcom</code></td>
+ <td>Y</td>
+ <td>Y</td>
+ <td>The C++ implementation does not return <code>nsresult</code>(implies <code>noscript</code>)</td>
+ <td>Y</td>
+ <td>Y</td>
+ </tr>
+ <tr>
+ <td><code>optional_argc</code></td>
+ <td>Y</td>
+ <td>N</td>
+ <td>Adds an additional <code>uint8_t _argc</code> parameter to the C++ implementation</td>
+ <td>Y</td>
+ <td>Y</td>
+ </tr>
+ </tbody>
+</table>
+<h4 id="Method_parameters" style="line-height: 18px; letter-spacing: normal;">Method parameters</h4>
+<p>Each method parameter can be specified in one of three modes: <code>in</code>, <code>out</code>, or <code>inout</code>. An out parameter is essentially an auxiliary return value, although these are moderately cumbersome to use from script contexts and should therefore be avoided if reasonable. An inout parameter is an in parameter whose value may be changed as a result of the method; these parameters are rather annoying to use and should generally be avoided if at all possible.</p>
+<p>Out and inout parameters are reflected as objects having the .value property which contains the real value of the parameter; it is not initialized in the case of out parameters and is initialized to the passed-in-value for inout parameters. The script code would need to set this property to assign a value to the parameter. Regular in parameters are reflected more or less normally, with numeric types all representing numbers, booleans as true or false, the various strings (including AString et al) as a JavaScript string, and nsid types as a Components.ID instance. In addition, the jsval type is translated as the appropriate JavaScript value (since a jsval is the internal representation of all JavaScript values), and objects that are marked nsIVariant have their<br>
+ types automatically boxed and unboxed as appropriate.</p>
+<p>The equivalent representations of all IDL types in native code is given in the earlier tables; parameters of type inout follow their out form. Native code should pay particular attention to not passing in null values for out parameters (although some parts of the codebase are known to violate this, it is strictly enforced at the JS&lt;-&gt;native barrier), and also ensuring that boolean types only receive values of 0 (false) or 1 (true).</p>
+<p>Representations of types additionally depend on some of the many types of properties they may have. The <code>array</code> property turns the parameter into an array; the parameter must also have a corresponding <code>size_is</code> property whose argument is the parameter that has the size of the array. In native code, the type gains another pointer indirection, and JavaScript arrays are used in script code. Script code callers can ignore the value of array parameter, but implementors must still set the values appropriately.</p>
+<p>The <code>const</code> and <code>shared</code> properties are special to native code. As its name implies, the const property makes its corresponding argument const. The shared property is only meaningful for out or inout parameters and it means that the pointer value should not be freed by the caller. Only the string, wstring, and native types having the nsid, domstring, utf8string, cstirng, astring, or jsval properties may be declared shared, and, even then, only if the parameter is not an array parameter. The shared property also makes its corresponding argument const.<br>
+ <br>
+ The <code>retval</code> property indicates that the parameter is actually acting as the return value, and it is only the need to assign properties to the parameter that is causing it to be specified as a parameter. It has no effect on native code, but script code uses it like a regular return value. Naturally, a method which contains a retval parameter must be declared void, and the parameter itself must be an out parameter and the last parameter.</p>
+<p>Other properties are the <code>optional</code> and <code>iid_is</code> property. The optional property indicates that script code may omit the property without problems; all subsequent parameters must either by optional themselves or the retval parameter. Note that optional out parameters still pass in a variable for the parameter, but its value will be ignored. The iid_is parameter indicates that the real IID of an nsQIResult parameter may be found in the corresponding parameter, to allow script code to automatically unbox the type.</p>
+<p>Not all type combinations are possible. Native types with the various string properties are all forbidden from being used as an inout parameter or as an array parameter. In addition, native types with the nsid property but lacking either a ptr or ref property are forbidden unless the method is notxpcom and it is used as an inparameter.</p>
+<p>For types that reference heap-allocated data (strings, arrays, interface pointers, etc), you must follow the XPIDL data ownership conventions in order to avoid memory corruption and security vulnerabilities:</p>
+<ul>
+ <li>For <code>in</code> parameters, the caller allocates and deallocates all data. If the callee needs to use the data after the call completes, it must make a private copy of the data, or, in the case of interface pointers, AddRef it.</li>
+ <li>For <code>out</code> parameters, the callee creates the data, and transfers ownership to the caller. For buffers, the callee allocates the buffer with NS_Alloc, and the caller frees the buffer with NS_Free. For interface pointers, the callee does the AddRef on behalf of the caller, and the caller must call Release.</li>
+ <li>For <code>inout</code> parameters, the callee must clean up the old data if it chooses to replace it. Buffers must be deallocated with NS_Free, and interface pointers must be Release'd. Afterwards, the above rules for <code>out</code> apply.</li>
+ <li>Shared out-parameters should not be freed, as they are intended to refer to constant string literals.</li>
+</ul>
+<h2 id="Resources" name="Resources" style="margin-bottom: 20px; line-height: 30px;">Resources (mostly outdated)</h2>
+<ul>
+ <li><a class="external external-icon" href="http://www.mozilla.org/scriptable/xpidl/notes/" style="white-space: pre-line;">Some unsorted notes</a> including a <a class="external external-icon" href="http://www.mozilla.org/scriptable/xpidl/notes/keywords.txt" style="white-space: pre-line;">keyword list</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/XPIDL/xpidl" title="XPIDL/xpidl">xpidl</a> is a tool for generating C++ headers, Java interfaces, <a href="https://developer.mozilla.org/en-US/docs/XPConnect" title="XPConnect">XPConnect</a> typelibs, and HTML documentation from XPIDL files</li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/XPIDL/Generating_xpt_on_Windows" title="XPIDL/Generating_xpt_on_Windows">Generating xpt files on Windows</a></li>
+ <li><a class="external external-icon" href="http://groups.google.com/group/mozilla.dev.extensions/browse_thread/thread/371b5f04e4ecdcfb/a9d48a45c9453d16?q=idl+OR+xpidl+variable+argument+group:mozilla.dev.*#a9d48a45c9453d16" style="white-space: pre-line;" title="http://groups.google.com/group/mozilla.dev.extensions/browse_thread/thread/371b5f04e4ecdcfb/a9d48a45c9453d16?q=idl+OR+xpidl+variable+argument+group:mozilla.dev.*#a9d48a45c9453d16">A Google groups post</a> with instructions on how to use variable-length argument lists using XPIDL.</li>
+</ul>
diff --git a/files/zh-cn/mozilla/tech/xpidl/syntax/index.html b/files/zh-cn/mozilla/tech/xpidl/syntax/index.html
new file mode 100644
index 0000000000..daca23f49f
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpidl/syntax/index.html
@@ -0,0 +1,127 @@
+---
+title: Syntax
+slug: Mozilla/Tech/XPIDL/Syntax
+tags:
+ - xpidl
+translation_of: Mozilla/Tech/XPIDL/Syntax
+---
+<h3 id="Status_of_this_document" name="Status_of_this_document">Status of this document</h3>
+
+<p>This is a partial reverse-engineering of the libIDL source code's parser, limited mostly to the subset of functionality that is supported by the Mozilla xpidl binary.</p>
+
+<h3 id="Purpose_of_this_document" name="Purpose_of_this_document">Purpose of this document</h3>
+
+<p>This document is <strong>not</strong> an introduction to XPIDL or IDL in general. It is more focused on XPIDL syntax and grammar. See <a href="/en/XPIDL" title="en/XPIDL">XPIDL Main Page</a> for more links and introductory content.</p>
+
+<h3 id="Simplifications.2C_conventions_and_notation" name="Simplifications.2C_conventions_and_notation">Simplifications, conventions and notation</h3>
+
+<p>The syntax is specified according to ABNF as defined by <a class="external" href="http://tools.ietf.org/html/rfc5234" title="http://tools.ietf.org/html/rfc5234">RFC 5234</a>, although a few productions use prose for clarity of understanding.</p>
+
+<p>Lexically, tokens are delimited by whitespace (defined here as spaces, tabs, vertical tabs, form feeds, line feeds, and carriage returns, or [ \t\v\f\r\n] in regular expression form). LibIDL only considers a single line feed as a newline, and not carriage returns (although xpidl begs to differ). Additionally, the use of both C-style (/* ... */) and C++-style (// ... end-of-line) comments are permitted between any two tokens.</p>
+
+<p>Some productions can only occur at the beginning of lines; to simplify the grammar, I will not mention them in the grammar, especially since they are handled as a preprocessing step before the IDL source code is actually parsed.</p>
+
+<ol>
+ <li>A `<code>%{</code>' that appears at the beginning of a line is the start of a <strong>raw code fragment</strong>, which extends until the end of a line that begins with `<code>%}</code>'. Text inside raw code fragments are not otherwise parsed by xpidl directly. This may be followed by the language, as in `<code>%{C++</code>', to output the raw fragment only in the specified language.</li>
+ <li>A `<code>#include "file"</code>' line instructs the xpidl processor to include that file in the same sense that the C preprocessor includes a file. Note that includes within comments or raw code fragments are not processed by xpidl. Unlike the C preprocessor, when a file is included multiple times, it acts as if the subsequent includes did not happen; this prevents the need for include guards.</li>
+</ol>
+
+<h3 id="XPIDL_Syntax_.28BNF.29" name="XPIDL_Syntax_.28BNF.29">XPIDL Syntax (ABNF)</h3>
+
+<p>The root production here is <code>idl_file</code>.</p>
+
+<p><code><code>idl_file = 1*definition<br>
+ definition = [type_decl / const_decl / interface] ";"<br>
+ interface = [prop_list] "interface" ident [[inheritance] "{" *(ifacebody) "}"]<br>
+ inheritance = ":" *(scoped_name ",") scoped_name]<br>
+ ifacebody = [type_decl / op_decl /attr_decl / const_decl] ";" / codefrag<br>
+ <br>
+ type_decl = [prop_list] "typedef" type_spec *(ident ",") ident<br>
+ type_decl /= [prop_list] "native" ident [parens]<br>
+ const_decl = "const" type_spec ident "=" expr<br>
+ op_decl = [prop_list] (type_spec / "void") parameter_decls raise_list<br>
+ parameter_decls = "(" [*(param_decl ",") param_decl] ")"<br>
+ param_decl = [prop_list] ("in" / "out" / "inout") type_spec ident<br>
+ attr_decl = [prop_list] ["readonly"] "attribute" type_spec *(ident ",") ident<br>
+ <br>
+ ; Descending order of precedence<br>
+ expr /= expr ("|" / "^" / "&amp;") expr ; Unequal precedence "|" is lowest<br>
+ expr /= expr ("&lt;&lt;" / "&gt;&gt;") expr<br>
+ expr /= expr ("+" / "-") expr<br>
+ expr /= expr ("*" / "/" / "%") expr<br>
+ expr /= ["-" / "+" / "~"] (scoped_name / literal / "(" expr ")" )<br>
+ <br>
+ ; Numeric literals: quite frankly, I'm sure you know how these kinds of<br>
+ ; literals work, and these are annoying to specify in ABNF.<br>
+ literal = octal_literal / decimal_literal / hex_literal / floating_literal<br>
+ literal /= string_literal / char_literal<br>
+ literal /= "TRUE" / "FALSE"<br>
+ <br>
+ ; In regex: /"[^"\n]*["\n]/. Yes, newline terminates.<br>
+ string_literal = 1*(%x22 *(any char except %x22 or %x0a) (%x22 / %x0a))<br>
+ ; Same as above, but s/"/'/g<br>
+ char_literal = 1*(%x27 *(any char except %x27 or %x0a) (%x27 / %x0a))<br>
+ <br>
+ type_spec = "float" / "double" / "string" / "wstring"<br>
+ type_spec /= ["unsigned"] ("short" / "long" / "long" "long")<br>
+ type_spec /= "char" / "wchar" / "boolean" / "octet"<br>
+ type_spec /= scoped_name<br>
+ <br>
+ prop_list = "[" *(property ",") property "]"<br>
+ property = ident [parens]<br>
+ raise_list = "raises" "(" *(scoped_name) ",") scoped_name ")"<br>
+ <br>
+ scoped_name = *(ident "::") ident / "::" ident</code></code><br>
+ <code><code>; In regex: [A-Za-z_][A-Za-z0-9_]*; identifiers beginning with _ cause warnings</code></code><br>
+ <code><code>ident = (%x41-5a / %x61-7a / "_") *(%x41-5a / %x61-7a / %x30-39 / "_")<br>
+ parens = "(" 1*(any char except ")") ")"</code></code></p>
+
+<h3 id="Functionality_not_used_in_xpidl">Functionality not used in xpidl</h3>
+
+<p>The libIDL parser we use is more powerful than xpidl itself can understand. The following is a list of potential features which are parseable but may not result in expected code:</p>
+
+<ul>
+ <li>Struct, union, and enumerated types</li>
+ <li>Array declarators (appears to be supported in xpidl_header.c but not xpidl_typelib.c)</li>
+ <li>Exception declarations</li>
+ <li>Module declarations</li>
+ <li>Variable arguments (that makes the ABNF get more wonky)</li>
+ <li>Sequence types</li>
+ <li>Max-length strings</li>
+ <li>Fixed-point numbers</li>
+ <li>"any" and "long double" types.</li>
+</ul>
+
+<h3 id="Pyxpidl_syntax">Pyxpidl syntax</h3>
+
+<p><code><code>idlfile = *(CDATA / INCLUDE / interface / typedef / native)<br>
+ <br>
+ typedef = "typedef" IDENTIFER IDENTIFIER ";"<br>
+ native = [attributes] "native" IDENTIFIER "(" NATIVEID ")"<br>
+ interface = [attributes] "interface" IDENTIFIER" [ifacebase] [ifacebody] ";"<br>
+ ifacebase = ":" IDENTIFIER<br>
+ ifacebody = "{" *(member) "}"<br>
+ <br>
+ member = CDATA / "const" IDENTIFIER IDENTIFIER "=" number ";"<br>
+ member /= [attributes] ["readonly"] "attribute" IDENTIFIER IDENTIFER ";"<br>
+ member /= [attributes] IDENTIFIER IDENTIFIER "(" paramlist ")" raises ";"<br>
+ paramlist = [param *("," param)]<br>
+ raises = ["raises" "(" IDENTIFIER *("," identifier) ")"]<br>
+ attributes = "[" attribute *("," attribute) "]"<br>
+ attribute = (IDENTIFIER / CONST) ["(" (IDENTIFIER / IID) ")"]<br>
+ param = [attributes] ("in" / "out" / "inout") IDENTIFIER IDENTIFIER<br>
+ <br>
+ number = NUMBER / IDENTIFIER<br>
+ number /= "(" number ")"<br>
+ number /= "-" number<br>
+ number /= number ("+" / "-" / "*") number<br>
+ number /= number ("&lt;&lt;" / &gt;&gt;") number<br>
+ number /= number "|" number<br>
+ <br>
+ ; Lexical tokens, I'm going to specify these in regex form<br>
+ NUMBER = /-?\d+|0x[0-9A-Fa-f]+/<br>
+ CDATA = /%\{[ ]*C\+\+[ ]*\n(.*?\n?)%\}[ ]*(C\+\+)?/s<br>
+ INCLUDE = /\#include[ \t]+"[^"\n]+"/<br>
+ NATIVEID = /[^()\n]+(?=\))/<br>
+ IID = /[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}/<br>
+ IDENTIFIER = /unsigned long long|unsigned short|unsigned long|long long|[A-Za-z][A-Za-z_0-9]*/</code></code></p>
diff --git a/files/zh-cn/mozilla/tech/xpidl/xpidl/index.html b/files/zh-cn/mozilla/tech/xpidl/xpidl/index.html
new file mode 100644
index 0000000000..57838ceae4
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xpidl/xpidl/index.html
@@ -0,0 +1,58 @@
+---
+title: xpidl
+slug: Mozilla/Tech/XPIDL/xpidl
+tags:
+ - 'Developing_Mozilla:Tools'
+ - Tools
+ - xpidl
+ - 开发Mozilla
+ - 所有分类
+translation_of: Mozilla/Tech/XPIDL/xpidl
+---
+<p> </p>
+<p><b>xpidl</b> 是一个基于 <a href="cn/XPIDL">XPIDL</a> 接口描述文件, 用于生成 <a href="cn/XPCOM">XPCOM</a> 接口信息的工具. 它会自动生成:</p>
+<ul>
+ <li>C++ 头文件 (&lt;tt&gt;.h&lt;/tt&gt;), 该头文件中包含了一个带注释的 C++ 接口的完整声明.</li>
+ <li>Java 接口文件 (&lt;tt&gt;.java&lt;/tt&gt;)</li>
+ <li><a href="cn/XPConnect">XPConnect</a> typelib 文件 (&lt;tt&gt;.xpt&lt;/tt&gt;), 这个文件中定义了通过 <a href="cn/XPConnect">XPConnect</a> 动态调用 XPCOM 对象的运行时刻类型信息.</li>
+ <li>HTML 格式的文档 (&lt;tt&gt;.html&lt;/tt&gt;)</li>
+</ul>
+<h2 id=".E7.BC.96.E8.AF.91_xpidl" name=".E7.BC.96.E8.AF.91_xpidl">编译 xpidl</h2>
+<p>xpidl 的实现是基于 <a class="external" href="http://www.gnome.org/">Gnome</a> 工程中的 <a class="external" href="http://andrewtv.org/libIDL/">libIDL idl 编译器</a>. libIDL 编译器依赖的 glib 库也来自于 gnome 工程. xpidl 编译器现在是 Mozilla 整个编译过程中必须包含的一分子, 我们用它来生成 XPCOM 组件的头文件. 如何得到 libIDL 和 glib 请看 <a href="cn/Build_Documentation">Build Documentation</a>.</p>
+<p>Unix: 如果你<b>仅仅</b>想编译 xpidl 本身, 你只需要编译很少一部分目录. 在获取 mozilla 源码后, 执行 'configure', 然后以下面的命令就可以在 dist/bin 目录下编译出 xpidl:</p>
+<pre class="eval">make -C config
+make -C nsprpub
+make -C xpcom/typelib
+</pre>
+<h2 id=".E4.BD.BF.E7.94.A8_xpidl" name=".E4.BD.BF.E7.94.A8_xpidl">使用 xpidl</h2>
+<p><a class="external" href="http://www.mozilla.org/scriptable/xpidl/xpidl-in-the-build.html">xpidl build page</a> 有关于如何添加一个 XPIDL 文件到 Mozilla 的编译过程的说明. xpidl 也可以在 Unix 和 Windows 下以命令行的形式执行:</p>
+<pre class="eval">Usage: ./xpidl -m mode [-w] [-v] [-t version number]
+ [-I path] [-o basename | -e filename.ext] filename.idl
+ -a emit annotations to typelib
+ -w turn on warnings (recommended)
+ -v verbose mode (NYI)
+ -t create a typelib of a specific version number
+ -I add entry to start of include path for ``#include "nsIThing.idl"
+ -o use basename (e.g. ``/tmp/nsIThing<i>) for output</i>
+ -e use explicit output filename
+ -m specify output mode:
+ header Generate C++ header (.h)
+ typelib Generate XPConnect typelib (.xpt)
+ doc Generate HTML documentation (.html)
+ java Generate Java interface (.java)
+</pre>
+<h2 id=".E8.B5.84.E6.BA.90" name=".E8.B5.84.E6.BA.90">资源</h2>
+<ul>
+ <li>关于 xpidl 的<a class="external" href="http://bugzilla.mozilla.org/buglist.cgi?bug_status=NEW&amp;bug_status=ASSIGNED&amp;bug_status=REOPENED&amp;component=xpidl">Open bugs</a>.</li>
+</ul>
+<p>Flames to <a class="link-mailto" href="mailto:mike+mozilla@meer.net,mang@subcarrier.org?Subject=xpidl">docs mike+mozilla@meer.net &amp; mang@subcarrier.org</a></p>
+<p> </p>
+<div class="originaldocinfo">
+ <h2 id=".E5.8E.9F.E5.A7.8B.E6.96.87.E6.A1.A3.E4.BF.A1.E6.81.AF" name=".E5.8E.9F.E5.A7.8B.E6.96.87.E6.A1.A3.E4.BF.A1.E6.81.AF">原始文档信息</h2>
+ <ul>
+ <li>作者: <a class="link-mailto" href="mailto:mike+mozilla@meer.net">mike+mozilla@meer.net</a>, <a class="link-mailto" href="mailto:mang@subcarrier.org">mang@subcarrier.org</a></li>
+ <li>上一次更新日期:版权信息 五月 29, 2002</li>
+ <li> : 版权所有(C) <a class="link-mailto" href="mailto:mike+mozilla@meer.net">mike+mozilla@meer.net</a>, <a class="link-mailto" href="mailto:mang@subcarrier.org">mang@subcarrier.org</a></li>
+ </ul>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/acceltext/index.html b/files/zh-cn/mozilla/tech/xul/attribute/acceltext/index.html
new file mode 100644
index 0000000000..77bc1dccbe
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/acceltext/index.html
@@ -0,0 +1,23 @@
+---
+title: acceltext
+slug: Mozilla/Tech/XUL/Attribute/acceltext
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/acceltext
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-acceltext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/acceltext">acceltext</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Text that appears beside beside the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> label to indicate the shortcut key (accelerator key) to use to invoke the command. If this value is set, it overrides an assigned key set in the key attribute. This attribute does not apply to menus directly on the menubar.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/accesskey/index.html b/files/zh-cn/mozilla/tech/xul/attribute/accesskey/index.html
new file mode 100644
index 0000000000..e6697bda0d
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/accesskey/index.html
@@ -0,0 +1,43 @@
+---
+title: accesskey
+slug: Mozilla/Tech/XUL/Attribute/accesskey
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/accesskey
+---
+<div class="noinclude"><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+
+<div class="noinclude">
+<dl>
+ <dd>Attribute of: <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/button" title="button">button</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/checkbox" title="checkbox">checkbox</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/caption" title="caption">caption</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/description" title="description">description</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/label" title="label">label</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listitem" title="listitem">listitem</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/tab" title="tab">tab</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/radio" title="radio">radio</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbarbutton" title="toolbarbutton">toolbarbutton</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/textbox (Firefox autocomplete)" title="textbox (Firefox autocomplete)">textbox (Firefox autocomplete)</a></code></dd>
+</dl>
+</div>
+
+<dl>
+ <dt><code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code></dt>
+ <dd>类型:
+ <i>character【字符】</i>
+ </dd>
+ <dd>本属性允许为控件(元素)设定一个字符作为快捷键,这个字符应该是 <code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code> 属性文本中的一个字符。该字符将会被加下划线以重点强调,平台和主体的变换并不影响这一表现行为。 当用户点击 ALT (在其他平台上具有类似功能的键) 和这个字符对应的按键时, 控件(元素)将立刻被从窗口中的某处激活或/并且获得焦点 <b>。虽说字符不分大小写,但是当label中存在大写字符和小写字符时,快捷键的字符将首先选择与之完全匹配的那一个,如果label中存在两个或更多的与accesskey字符相同的字符,其中的第一个字符将被加下划线。</b></dd>
+ <dt>      *(有些键在监听按键事件时,分别对应event.ctrlKey和event.metaKey。)</dt>
+</dl>
+
+<p> </p>
+
+<h4 id="Example" name="Example">Example</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_accesskey_attr.png"></div>
+
+<pre>&lt;vbox&gt;
+ &lt;label value="Enter Name" accesskey="e" control="myName"/&gt;
+ &lt;textbox id="myName"/&gt;
+ &lt;button label="Cancel" accesskey="n"/&gt;
+ &lt;button label="Ok" accesskey="O"/&gt;
+&lt;/vbox&gt;
+</pre>
+
+<h4 id="See_also" name="See_also">See also</h4>
+
+<p><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute, <code id="a-acceltext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/acceltext">acceltext</a></code> attribute</p>
+
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/activetitlebarcolor/index.html b/files/zh-cn/mozilla/tech/xul/attribute/activetitlebarcolor/index.html
new file mode 100644
index 0000000000..5352f49114
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/activetitlebarcolor/index.html
@@ -0,0 +1,19 @@
+---
+title: activetitlebarcolor
+slug: Mozilla/Tech/XUL/Attribute/activetitlebarcolor
+translation_of: Archive/Mozilla/XUL/Attribute/activetitlebarcolor
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-activetitlebarcolor"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/activetitlebarcolor">activetitlebarcolor</a></code> </dt>
+ <dd>
+ Type: <em>color string</em></dd>
+ <dd>
+ Specify background color of the window's titlebar when it is active (foreground). Moreover this hides separator between titlebar and window contents. <em>This only affects Mac OS X.</em></dd>
+</dl>
+<div class="noinclude">
+ <p></p>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/align/index.html b/files/zh-cn/mozilla/tech/xul/attribute/align/index.html
new file mode 100644
index 0000000000..f940cbdbb3
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/align/index.html
@@ -0,0 +1,54 @@
+---
+title: align
+slug: Mozilla/Tech/XUL/Attribute/align
+tags:
+ - Reference
+ - XUL
+translation_of: Archive/Mozilla/XUL/Attribute/align
+---
+<div class="noinclude"><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+
+<dl>
+ <dt><code id="a-align"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/align">align</a></code></dt>
+ <dd>Type: <em>one of the values below</em></dd>
+ <dd>The align attribute specifies how child elements of the box are aligned, when the size of the box is larger than the total size of the children.<br>
+ 当box的尺寸大于全部子元素的尺寸时,align属性指定box元素的对齐方式。
+ <ul>
+ <li>For boxes that have horizontal orientation, it specifies how its children will be aligned vertically.</li>
+ <li>当box设置水平排列,它指定子元素如何垂直对齐。</li>
+ <li>For boxes that have vertical orientation, it specifies how its children will be aligned horizontally.</li>
+ <li>当box设置垂直排列,它指定子元素如何水平对齐</li>
+ </ul>
+ </dd>
+ <dd>
+ <dl>
+ <dt><code>start</code></dt>
+ <dd>Child elements are aligned starting from the left or top edge of the box. If the box is larger than the total size of the children, the extra space is placed on the right or bottom side.<br>
+ 子元素从box的左边或顶部开始排列。如果box大于全部子元素的总和,多出的空间在右边或底部。</dd>
+ <dt><code>center</code></dt>
+ <dd>Extra space is split equally along each side of the child elements, resulting in the children being placed in the center of the box.<br>
+ 多出的空间在子元素的周围,使子元素放置在box的中间。</dd>
+ <dt><code>end</code></dt>
+ <dd>Child elements are placed on the right or bottom edge of the box. If the box is larger than the total size of the children, the extra space is placed on the left or top side.<br>
+ 子元素从box的右边或底部开始排列。如果box大于全部子元素的总和,多出的空间在左边或顶部部。</dd>
+ <dt><code>baseline</code></dt>
+ <dd>This value applies to horizontally oriented boxes only. It causes the child elements to be aligned so that their text labels are lined up.<br>
+ 这个值只适用于水平方向的box元素。它让子元素的文本标签成一条直线。</dd>
+ <dt><code>stretch</code></dt>
+ <dd><em>This is the default value.</em> The child elements are stretched to fit the size of the box. For a horizontal box, the children are stretched to be the height of the box. For a vertical box, the children are stretched to be the width of the box. If the size of the box changes, the children stretch to fit. Use the flex attribute to create elements that stretch in the opposite direction.<br>
+ 这是默认值。拉伸子元素来填充box。在水平的box元素中,子元素在高度上被拉伸。在垂直的box元素中,子元素在宽度上被拉伸。如果box元素尺寸改变,子元素也随之改变。使用flex属性创建的元素在相反方向被拉伸。</dd>
+ <dt><code>left</code> <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span></dt>
+ <dd>The elements are aligned on their left edges.<br>
+ 元素左边缘对齐。</dd>
+ <dt><code>center</code> <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span></dt>
+ <dd>The elements are centered horizontally.<br>
+ 元素水平居中。</dd>
+ <dt><code>right</code> <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span></dt>
+ <dd>The elements are aligned on their right edges.<br>
+ 元素右边缘对齐。</dd>
+ </dl>
+ </dd>
+ <dd>The <a href="/en-US/docs/XUL/Attribute/pack" title="XUL/Attribute/pack">pack</a> attribute is related to the alignment but is used to specify the position in the opposite direction. You can also specify the value of align using the style property <a href="/zh-CN/docs/Web/CSS/-moz-box-align" title="此页面仍未被本地化, 期待您的翻译!"><code>-moz-box-align</code></a>.<br>
+ <a href="/en-US/docs/XUL/Attribute/pack" title="XUL/Attribute/pack">pack</a>也是有关对齐的属性,但是指定相反方向的位置。你也可以在style中使用对齐的方式<a href="/zh-CN/docs/Web/CSS/-moz-box-align" title="此页面仍未被本地化, 期待您的翻译!"><code>-moz-box-align</code></a>。</dd>
+ <dt></dt>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/allowevents/index.html b/files/zh-cn/mozilla/tech/xul/attribute/allowevents/index.html
new file mode 100644
index 0000000000..5d17570f74
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/allowevents/index.html
@@ -0,0 +1,30 @@
+---
+title: allowevents
+slug: Mozilla/Tech/XUL/Attribute/allowevents
+tags:
+ - XUL Attributes
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/Attribute/allowevents
+---
+<div class="noinclude"><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+
+<dl>
+ <dt><code id="a-allowevents"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allowevents">allowevents</a></code></dt>
+ <dd>Type:
+ <i>boolean<br>
+ </i>
+ 类型:boolean</dd>
+ <dd>If true, events are passed to children of the element. Otherwise, events are passed to the element only.<br>
+ 如果为真,事件向子元素传递。否则,事件只传递到当前元素。</dd>
+</dl>
+
+<div class="noinclude">
+<p>On <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listitem" title="listitem">listitem</a></code> and <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/titlebar" title="titlebar">titlebar</a></code> elements, mouse events normally do not get sent to their children; instead they are retargeted to the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listitem" title="listitem">listitem</a></code> and <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/titlebar" title="titlebar">titlebar</a></code> element itself. This means that elements placed inside a listitem do not respond to events, and instead clicking the mouse simply selects that item within the list. By setting the allowevents attribute to <code>true</code>, this special behavior is disabled, and the events are targeted the same as other elements.<br>
+ 在 <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listitem" title="listitem">listitem</a></code> 和 <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/titlebar" title="titlebar">titlebar</a></code> 元素中,鼠标事件通常不发送给子元素;相反它们重定向到 <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listitem" title="listitem">listitem</a></code> 和 <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/titlebar" title="titlebar">titlebar</a></code> 元素本身。这意味着,放置在listitem内部的元素并不响应事件,而点击鼠标仅仅是选择在列表中的元素。当设置allowevents属性为真时,这种特殊的响应被禁止,事件则被定向到其他相同的元素。</p>
+
+<p>For <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuseparator" title="menuseparator">menuseparator</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> and <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/treecol" title="treecol">treecol</a></code> elements, as well as menu buttons, and the popup <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/datepicker" title="datepicker">datepicker</a></code>, mouse events are also retargeted to the element itself. However, the allowevents attribute is handled in a different way. Instead, the allowevents may be set to <code>true</code> on a descendant instead. This does the same thing in that it allows events to be targeted normally, but allows this to be different for each descendant.</p>
+
+<p>This behavior is used for menus, for instance, to allow a menu button to behave as a menu when clicking on it, yet have part of the menu behave as a button. For the latter, the allowevents attribute is set to <code>true</code> to have a click on the child button receive events instead of targeting all events at the menu.</p>
+</div>
+
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/allownegativeassertions/index.html b/files/zh-cn/mozilla/tech/xul/attribute/allownegativeassertions/index.html
new file mode 100644
index 0000000000..51c8c4e222
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/allownegativeassertions/index.html
@@ -0,0 +1,18 @@
+---
+title: allownegativeassertions
+slug: Mozilla/Tech/XUL/Attribute/allownegativeassertions
+translation_of: Archive/Mozilla/XUL/Attribute/allownegativeassertions
+---
+<div class="noinclude"><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+
+<dl>
+ <dt><code id="a-allownegativeassertions"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allownegativeassertions">allownegativeassertions</a></code></dt>
+ <dd>Type: <em>boolean</em><br>
+ 类型:布尔类型</dd>
+ <dd>Valid on any element that has a <code id="a-datasources"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/datasources">datasources</a></code> attribute. When multiple datasources are used, one may override an assertion from another. This attribute, if <code>true</code>, which is the default, allows a datasource to negate an earlier assertion.<br>
+ 适用于任何有 <code id="a-datasources"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/datasources">datasources</a></code> 属性的元素。当使用多个数据源,一个数据源可以指定覆盖另一个。这个属性,如果为真,这是默认值,允许一个数据源覆盖之前的数据源。</dd>
+</dl>
+
+<div class="noinclude">
+<p></p>
+</div>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/autocheck/index.html b/files/zh-cn/mozilla/tech/xul/attribute/autocheck/index.html
new file mode 100644
index 0000000000..edd3c5e9ed
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/autocheck/index.html
@@ -0,0 +1,24 @@
+---
+title: autocheck
+slug: Mozilla/Tech/XUL/Attribute/autocheck
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/autoCheck
+---
+<div class="noinclude"><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+
+<dl>
+ <dt><code id="a-autocheck"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/autocheck">autocheck</a></code></dt>
+ <dd>类型:
+ <i>boolean</i>
+ </dd>
+ <dd>如果此属性为 <code>true</code>,或空白, 每次点击按钮时,此按钮的状态检查都会被执行一次。如果此属性为<code>false</code>, 检查会手动的被拒绝。当autocheck值为true的时候,按钮将会变为多选框或者单选框。</dd>
+</dl>
+
+<div class="noinclude">
+<h3 id="See_also" name="See_also">See also</h3>
+
+<p><code><a href="cn/XUL/Attribute/autoCheck">autoCheck</a></code></p>
+</div>
+
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/autoscroll/index.html b/files/zh-cn/mozilla/tech/xul/attribute/autoscroll/index.html
new file mode 100644
index 0000000000..9bc1366f88
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/autoscroll/index.html
@@ -0,0 +1,12 @@
+---
+title: autoscroll
+slug: Mozilla/Tech/XUL/Attribute/autoscroll
+translation_of: Archive/Mozilla/XUL/Attribute/autoscroll
+---
+<div class="noinclude"><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/en-US/docs/XUL/XUL_Reference">XUL Reference home</a></span></div>
+
+<dl>
+ <dt><code id="a-autoscroll"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/autoscroll">autoscroll</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>Set to <code>false</code> to disable autoscroll for this browser. If this attribute is set to <code>true</code> or omitted, autoscroll will be enabled or depending on the user preference <code>general.autoScroll</code>.</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/buttonaccesskeyaccept/index.html b/files/zh-cn/mozilla/tech/xul/attribute/buttonaccesskeyaccept/index.html
new file mode 100644
index 0000000000..4e42f14bad
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/buttonaccesskeyaccept/index.html
@@ -0,0 +1,20 @@
+---
+title: buttonaccesskeyaccept
+slug: Mozilla/Tech/XUL/Attribute/buttonaccesskeyaccept
+translation_of: Archive/Mozilla/XUL/Attribute/buttonaccesskeyaccept
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-buttonaccesskeyaccept"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/buttonaccesskeyaccept">buttonaccesskeyaccept</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The access key to use for the "accept" button.</dd>
+</dl>
+<p> </p>
+<div class="noinclude">
+ <p></p>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/buttonlabelextra1/index.html b/files/zh-cn/mozilla/tech/xul/attribute/buttonlabelextra1/index.html
new file mode 100644
index 0000000000..1de5913a9b
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/buttonlabelextra1/index.html
@@ -0,0 +1,19 @@
+---
+title: buttonlabelextra1
+slug: Mozilla/Tech/XUL/Attribute/buttonlabelextra1
+translation_of: Archive/Mozilla/XUL/Attribute/buttonlabelextra1
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-buttonlabelextra1"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/buttonlabelextra1">buttonlabelextra1</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The label to appear on the first extra button.</dd>
+</dl>
+<div class="noinclude">
+ <p></p>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/buttonlabelextra2/index.html b/files/zh-cn/mozilla/tech/xul/attribute/buttonlabelextra2/index.html
new file mode 100644
index 0000000000..1a7f700eac
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/buttonlabelextra2/index.html
@@ -0,0 +1,19 @@
+---
+title: buttonlabelextra2
+slug: Mozilla/Tech/XUL/Attribute/buttonlabelextra2
+translation_of: Archive/Mozilla/XUL/Attribute/buttonlabelextra2
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-buttonlabelextra2"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/buttonlabelextra2">buttonlabelextra2</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The label to appear on the second extra button.</dd>
+</dl>
+<div class="noinclude">
+ <p></p>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/buttons/index.html b/files/zh-cn/mozilla/tech/xul/attribute/buttons/index.html
new file mode 100644
index 0000000000..5759eabd90
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/buttons/index.html
@@ -0,0 +1,28 @@
+---
+title: buttons
+slug: Mozilla/Tech/XUL/Attribute/buttons
+translation_of: Archive/Mozilla/XUL/Attribute/buttons
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/buttons">buttons</a></span></code></dt>
+ <dd>
+ 类型: 列表,下面的值用逗号分隔</dd>
+ <dd>
+ 需要显示在对话框上的按钮的一个列表,使用逗号分隔。将按钮放置在合适的位置,将根据用户平台自动执行基本的事件处理。在列表中可以使用以下值:
+ <ul>
+ <li><code>accept</code>:“确定”按钮,按下按钮时将接受更改。此按钮为默认按钮。</li>
+ <li><code>cancel</code>:“取消”按钮,将取消操作。</li>
+ <li><code>help</code>:“帮助”按钮,在对话框显示一个“帮助”按钮。</li>
+ <li><code>disclosure</code>:“更多信息”按钮,显示一个“more info”按钮。该按钮可能是一个按钮或一个三角形。</li>
+ <li><code>extra1</code>:一个可选的额外的按钮。你可以通过<code><code id="a-buttonlabelextra1"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/buttonlabelextra1">buttonlabelextra1</a></code></code> 属性设置它的label。</li>
+ <li><code>extra2</code>:第二个可选的额外的按钮。你可以通过 <code><code id="a-buttonlabelextra2"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/buttonlabelextra2">buttonlabelextra2</a></code></code> 属性设置它的label。</li>
+ </ul>
+ </dd>
+</dl>
+<div class="noinclude">
+ <p></p>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/checked/index.html b/files/zh-cn/mozilla/tech/xul/attribute/checked/index.html
new file mode 100644
index 0000000000..249a1f1ee1
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/checked/index.html
@@ -0,0 +1,24 @@
+---
+title: checked
+slug: Mozilla/Tech/XUL/Attribute/checked
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/checked
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-checked"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/checked">checked</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Indicates whether the element is checked or not.</dd>
+ <dd>
+ Use <code>hasAttribute()</code> to determine whether this attribute is set instead of <code>getAttribute()</code>.</dd>
+ <dd>
+ For buttons, the <code>type</code> attribute must be set to <code>checkbox</code> or <code>radio</code> for this attribute to have any effect.&lt;magic name="\"PAGENAME\"/"&gt;&lt;/magic&gt;</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/class/index.html b/files/zh-cn/mozilla/tech/xul/attribute/class/index.html
new file mode 100644
index 0000000000..45eb8dbc87
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/class/index.html
@@ -0,0 +1,23 @@
+---
+title: class
+slug: Mozilla/Tech/XUL/Attribute/class
+tags:
+ - XUL Attributes
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/Attribute/class
+---
+<div class="noinclude"><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+
+<dl>
+ <dt><code id="a-class"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/class">class</a></code></dt>
+ <dd>Type:
+ <i>string<br>
+ </i>
+ 类型:字符串(string)</dd>
+ <dd>The style class of the element. Multiple classes may be specified by separating them with spaces.<br>
+ 元素样式类型。多个类可以使用空格分开。</dd>
+</dl>
+
+<div class="noinclude"> </div>
+
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/coalesceduplicatearcs/index.html b/files/zh-cn/mozilla/tech/xul/attribute/coalesceduplicatearcs/index.html
new file mode 100644
index 0000000000..01e6ddd51f
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/coalesceduplicatearcs/index.html
@@ -0,0 +1,17 @@
+---
+title: coalesceduplicatearcs
+slug: Mozilla/Tech/XUL/Attribute/coalesceduplicatearcs
+tags:
+ - XUL Attributes
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/Attribute/coalesceduplicatearcs
+---
+<div class="noinclude"><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+
+<dl>
+ <dt><code id="a-coalesceduplicatearcs"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/coalesceduplicatearcs">coalesceduplicatearcs</a></code></dt>
+ <dd>Type: <em>boolean</em><br>
+ 类型:布尔类型(boolean)</dd>
+ <dd>Valid on any element that has a <code id="a-datasources"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/datasources">datasources</a></code> attribute. When multiple datasources are used, one may override an assertion from another. This attribute, if <code>true</code>, which is the default, allows a datasource to negate an earlier assertion.<br>
+ 任何有 <code id="a-datasources"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/datasources">datasources</a></code> 属性的元素有效。当有多个数据源时使用,可以覆盖另一个声明。这个属性,如果是真,这是默认属性,允许一个数据源取消更早的声明。 </dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/collapsed/index.html b/files/zh-cn/mozilla/tech/xul/attribute/collapsed/index.html
new file mode 100644
index 0000000000..50d54b771f
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/collapsed/index.html
@@ -0,0 +1,27 @@
+---
+title: collapsed
+slug: Mozilla/Tech/XUL/Attribute/collapsed
+translation_of: Archive/Mozilla/XUL/Attribute/collapsed
+---
+<div class="noinclude"><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+
+<dl>
+ <dt><code id="a-collapsed"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/collapsed">collapsed</a></code></dt>
+ <dd>Type: <em>boolean</em><br>
+ 类型:布尔类型(boolean)</dd>
+ <dd>If <code>true</code>, then the element is collapsed and does not appear. It is equivalent to setting the CSS <a href="/en-US/docs/CSS/visibility" title="/en-US/docs/CSS/visibility">visibility</a> property to <code>collapse</code>.<br>
+ 如果是真,那么这个元素可以折叠并且隐藏。相当于设置CSS的 <a href="/en-US/docs/CSS/visibility" title="/en-US/docs/CSS/visibility">visibility</a> 属性为 collapse。</dd>
+</dl>
+
+<div class="noinclude">
+<h2 id="See_also_相关参考">See also<br>
+ 相关参考</h2>
+
+<ul>
+ <li><code id="a-hidden"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/hidden">hidden</a></code></li>
+</ul>
+
+<p></p>
+</div>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/command/index.html b/files/zh-cn/mozilla/tech/xul/attribute/command/index.html
new file mode 100644
index 0000000000..75c4957f0e
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/command/index.html
@@ -0,0 +1,30 @@
+---
+title: command
+slug: Mozilla/Tech/XUL/Attribute/command
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/command
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-command"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/command">command</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ element id</i>
+ </dd>
+ <dd>
+ Set to the <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> of a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/command" title="command">command</a></code> element that is being observed by the element.</dd>
+</dl>
+<div class="noinclude">
+ <h3 id="Example" name="Example">Example</h3>
+ <pre>&lt;command id="cmd_openhelp" oncommand="alert('Help');"/&gt;
+&lt;button label="Help" command="cmd_openhelp"/&gt;
+&lt;button label="More Help" command="cmd_openhelp"/&gt;
+</pre>
+ <h3 id="See_also" name="See_also">See also</h3>
+ <p><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/command" title="command">command</a></code></code> element, <code><code id="a-oncommand"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/oncommand">oncommand</a></code></code> and <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/commandset" title="commandset">commandset</a></code></code></p>
+</div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/container/index.html b/files/zh-cn/mozilla/tech/xul/attribute/container/index.html
new file mode 100644
index 0000000000..4b1429ae43
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/container/index.html
@@ -0,0 +1,18 @@
+---
+title: container
+slug: Mozilla/Tech/XUL/Attribute/container
+translation_of: Archive/Mozilla/XUL/Attribute/container
+---
+<div class="noinclude"><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+
+<dl>
+ <dt><code id="a-container"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/container">container</a></code></dt>
+ <dd>Type: <em>boolean</em><br>
+ 类型:布尔类型(boolean)</dd>
+ <dd>Set to true if the element is to act as a container which can have child elements. This would be used for folders. This will be set by the template builder as needed.<br>
+ 如果该元素是作为一个容器可以有子元素,设置为真。</dd>
+</dl>
+
+<div class="noinclude">
+<p></p>
+</div>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/control/index.html b/files/zh-cn/mozilla/tech/xul/attribute/control/index.html
new file mode 100644
index 0000000000..74a0edec5a
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/control/index.html
@@ -0,0 +1,23 @@
+---
+title: control
+slug: Mozilla/Tech/XUL/Attribute/control
+tags:
+ - XUL Attributes
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/Attribute/control
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-control"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/control">control</a></code></dt>
+ <dd>
+ Type: <em>element id</em></dd>
+ <dd>
+ This attribute specifies the <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> of the element with which the label is associated. When the user clicks on the label, the associated element is given focus.<br>
+ 这个属性定义了元素的<code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code>,它与<code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code>相关联。当用户点击 <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> 的时候,相关联的元素将获得焦点。</dd>
+</dl>
+<div class="noinclude">
+ <p></p>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/crop/index.html b/files/zh-cn/mozilla/tech/xul/attribute/crop/index.html
new file mode 100644
index 0000000000..1ab3f59210
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/crop/index.html
@@ -0,0 +1,37 @@
+---
+title: crop
+slug: Mozilla/Tech/XUL/Attribute/crop
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/crop
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ one of the values below</i>
+ </dd>
+ <dd>
+ If the label of the element is too big to fit in its given space, the text will be cropped on the side specified by the <code>crop</code> attribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.</dd>
+</dl>
+<ul>
+ <li><code>start</code>: The text will be cropped on its left side.</li>
+ <li><code>end</code>: The text will be cropped on its right side.</li>
+ <li><code>left</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its left side.</li>
+ <li><code>right</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its right side.</li>
+ <li><code>center</code>: The text will be cropped in the middle, showing both the start and end of the text normally.</li>
+ <li><code>none</code>: The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.</li>
+</ul>
+<div class="noinclude">
+ <dl>
+ <dd>
+ Depending on the platform and theme being used, some elements will have a set maximum width so they will be always appear cropped. If you wish to use the value <code>none</code> and the displayed text is larger than this maximum width, you may be able to use the max-width CSS property (or the maxwidth attribute) to override this size. For example, for a menuitem in a menu you can add the following CSS rule when you want to use the value <code>none</code>:</dd>
+ </dl>
+ <pre class="eval">menupopup &gt; menuitem, menupopup &gt; menu { max-width: none; }
+</pre>
+</div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/description/index.html b/files/zh-cn/mozilla/tech/xul/attribute/description/index.html
new file mode 100644
index 0000000000..008aa1281c
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/description/index.html
@@ -0,0 +1,23 @@
+---
+title: description
+slug: Mozilla/Tech/XUL/Attribute/description
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/description
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-description"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/description">description</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Descriptive text to appear in addition to the dialog title.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/dir/index.html b/files/zh-cn/mozilla/tech/xul/attribute/dir/index.html
new file mode 100644
index 0000000000..0b4c5c36a4
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/dir/index.html
@@ -0,0 +1,39 @@
+---
+title: dir
+slug: Mozilla/Tech/XUL/Attribute/dir
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/dir
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ one of the values below</i>
+ </dd>
+ <dd>
+ The direction in which the child elements of the element are placed.</dd>
+</dl>
+<dl>
+ <dt>
+ <code>normal</code></dt>
+ <dd>
+ For scales, the scale's values are ordered from left to right (for horizontal scales) or from top to bottom (for vertical scales)  For other elements, the elements are placed left to right or top to bottom in the order they appear in the XUL code</dd>
+ <dt>
+ <code>reverse</code></dt>
+ <dd>
+ For scales, the scale's values are ordered from right to left (for horizontal scales) or from bottom to top (for vertical scales). For other elements, they are placed right to left or bottom to top. This is reverse of the order in which they appear in the XUL code.</dd>
+</dl>
+<ul>
+</ul>
+<div class="noinclude">
+ <h3 id="See_also" name="See_also">See also</h3>
+ <ul>
+ <li><a href="cn/XUL/Attribute/resizer.dir">resizer.dir</a></li>
+ </ul>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/disabled/index.html b/files/zh-cn/mozilla/tech/xul/attribute/disabled/index.html
new file mode 100644
index 0000000000..057bca261d
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/disabled/index.html
@@ -0,0 +1,38 @@
+---
+title: disabled
+slug: Mozilla/Tech/XUL/Attribute/disabled
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/disabled
+---
+<div class="noinclude"><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd> </dd>
+ <dd>
+ <h5 id="类型boolean">类型:<em>boolean</em></h5>
+ </dd>
+ <dd>
+ <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>
+
+ <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>
+
+ <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
+ </dd>
+</dl>
+
+<h4 id="示例:">示例:</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>
+
+<pre><code>// Disabling an element
+document.getElementById('buttonRemove').setAttribute("disabled", "true");
+
+// Enabling back an element by removing the "disabled" attribute
+document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>
+
+<p></p><div class="blockIndicator standardNote">
+ <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
+ <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/flex/index.html b/files/zh-cn/mozilla/tech/xul/attribute/flex/index.html
new file mode 100644
index 0000000000..7d9954d30a
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/flex/index.html
@@ -0,0 +1,23 @@
+---
+title: flex
+slug: Mozilla/Tech/XUL/Attribute/flex
+tags:
+ - XUL Attributes
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/Attribute/flex
+---
+<div class="noinclude"><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+
+<dl>
+ <dt><code id="a-flex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flex">flex</a></code></dt>
+ <dd>Type: <em>string</em> (representing an integer)<br>
+ 类型:字符串 (string) 表示一个整数</dd>
+ <dd>Indicates the flexibility of the element, which indicates how an element's container distributes remaining empty space among its children. Flexible elements grow and shrink to fit their given space. Elements with larger flex values will be made larger than elements with lower flex values, at the ratio determined by the two elements. The actual value is not relevant unless there are other flexible elements within the same container. Once the default sizes of elements in a box are calculated, the remaining space in the box is divided among the flexible elements, according to their flex ratios. Specifying a flex value of 0 has the same effect as leaving the flex attribute out entirely.<br>
+ 指示一个元素的伸缩性,</dd>
+</dl>
+
+<div class="noinclude">
+<p></p>
+</div>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/href/index.html b/files/zh-cn/mozilla/tech/xul/attribute/href/index.html
new file mode 100644
index 0000000000..50013e44b3
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/href/index.html
@@ -0,0 +1,24 @@
+---
+title: href
+slug: Mozilla/Tech/XUL/Attribute/href
+tags:
+ - XUL 参考
+ - XUL 属性
+translation_of: Archive/Mozilla/XUL/Attribute/href
+---
+<div class="noinclude"><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+
+<dl>
+ <dt><code id="a-href"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/href">href</a></code></dt>
+ <dd>类型: <em>文本</em></dd>
+ <dd>定义一个当元素被点击时将会打开的 URL 。需要引用类 <a href="/en/XUL/Style/text-link" title="en/XUL/Style/text-link">text-link </a>。</dd>
+</dl>
+
+<div class="noinclude">
+<pre class="eval">&lt;label href="<span class="nowiki">http://example.com</span>" class="text-link" value="点击这里前往 example.com"/&gt;
+</pre>
+</div>
+
+<div class="noinclude">
+<p></p>
+</div>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/id/index.html b/files/zh-cn/mozilla/tech/xul/attribute/id/index.html
new file mode 100644
index 0000000000..50e8e7b188
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/id/index.html
@@ -0,0 +1,41 @@
+---
+title: id
+slug: Mozilla/Tech/XUL/Attribute/id
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/id
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code></dt>
+ <dd>
+ 类型: <em>元素的ID,在主窗口中必须唯一</em></dd>
+ <dd>
+ 一个唯一的标识一边开发者能够定义. 你可以使用方法 <code><a href="/cn/DOM/document.getElementById" title="cn/DOM/document.getElementById">getElementById()</a></code> 或者其他 DOM 的函数并在样式表中添加对元素的引用。</dd>
+</dl>
+<div class="noinclude">
+ <h4 id="Example" name="Example">示例</h4>
+ <pre>&lt;button id="foo" label="Click Me" oncommand="doSomething()"/&gt;
+
+&lt;script&gt;
+function doSomething(){
+ var myButton = document.getElementById('foo');
+ myButton.setAttribute('label','The button was pressed');
+}
+&lt;/script&gt;
+</pre>
+ <p>一个更加抽象的版本</p>
+ <pre>&lt;button id="foo" label="Click Me" oncommand="setWidgetLabel(this, 'I was pressed')"/&gt;
+&lt;script&gt;
+function setWidgetLabel(idName, newCaption){
+ document.getElementById( idName.id ).setAttribute('label',newCaption)
+}
+
+&lt;/script&gt;
+</pre>
+ <h4 id="See_also" name="See_also">同样,这里还有一些资料</h4>
+ <p><code id="a-name"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/name">name</a></code></p>
+</div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/image.onload/index.html b/files/zh-cn/mozilla/tech/xul/attribute/image.onload/index.html
new file mode 100644
index 0000000000..846d404d89
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/image.onload/index.html
@@ -0,0 +1,12 @@
+---
+title: image.onload
+slug: Mozilla/Tech/XUL/Attribute/image.onload
+translation_of: Archive/Mozilla/XUL/Attribute/image.onload
+---
+<div class="noinclude"><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/en-US/docs/XUL/XUL_Reference">XUL Reference home</a></span></div>
+
+<dl>
+ <dt><code id="a-image.onload"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/image.onload">image.onload</a></code></dt>
+ <dd>类型: <em>脚本代码</em></dd>
+ <dd>该事件的处理函数将会在 <code><a href="/en-US/docs/Mozilla/Tech/XUL/image" title="image">image</a></code> 元素指示的图片加载完毕之后触发。此事件触发适用于用 <code id="a-src"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/src">src</a></code> 元素属性或用 <code>list-style-image</code> css属性声明元素样式。如果图片的加载源发生变化,该事件会在图片加载完毕之后再次触发。该事件不会在文档树上向上冒泡。</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/image/index.html b/files/zh-cn/mozilla/tech/xul/attribute/image/index.html
new file mode 100644
index 0000000000..dd82594964
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/image/index.html
@@ -0,0 +1,25 @@
+---
+title: image
+slug: Mozilla/Tech/XUL/Attribute/image
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/image
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ image URL</i>
+ </dd>
+ <dd>
+ The URL of the image to appear on the element. If this attribute is empty or left out, no image appears. The position of the image is determined by the <code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code> and <code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code> attributes.</dd>
+</dl>
+<div class="noinclude">
+ <h4 id="See_also" name="See_also">See also</h4>
+ <p><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/image" title="image">image</a></code></code> element</p>
+</div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/increment/index.html b/files/zh-cn/mozilla/tech/xul/attribute/increment/index.html
new file mode 100644
index 0000000000..782156bb47
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/increment/index.html
@@ -0,0 +1,15 @@
+---
+title: increment
+slug: Mozilla/Tech/XUL/Attribute/increment
+translation_of: Archive/Mozilla/XUL/Attribute/increment
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-increment"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/increment">increment</a></code></dt>
+ <dd>
+ 类型:整数</dd>
+ <dd>
+ 拖动刻度条控件(<code>scale</code>元素)中的拉杆,点击滚动条控件(<code>scrollbar</code>元素)中的箭头(拖动拉杆也可以),点击数字输入框(<code>type</code>属性为<code>number</code>的<code>textbox</code>元素)中的箭头时,其<code id="a-curpos"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/curpos">curpos</a></code>属性或者value属性每次改变的数字值,默认值为1.</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/index.html b/files/zh-cn/mozilla/tech/xul/attribute/index.html
new file mode 100644
index 0000000000..097a3d6678
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/index.html
@@ -0,0 +1,304 @@
+---
+title: Attributes
+slug: Mozilla/Tech/XUL/Attribute
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute
+---
+<p><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span>
+</p>
+<ul><li> <a href="cn/XUL/Attribute/acceltext">acceltext</a>
+</li><li> <a href="cn/XUL/Attribute/accessible">accessible</a>
+</li><li> <a href="cn/XUL/Attribute/accesskey">accesskey</a>
+</li><li> <a href="cn/XUL/Attribute/activetitlebarcolor">activetitlebarcolor</a>
+</li><li> <a href="cn/XUL/Attribute/afterselected">afterselected</a>
+</li><li> <a href="cn/XUL/Attribute/align">align</a>
+</li><li> <a href="cn/XUL/Attribute/allowevents">allowevents</a>
+</li><li> <a href="cn/XUL/Attribute/allownegativeassertions">allownegativeassertions</a>
+</li><li> <a href="cn/XUL/Attribute/alternatingbackground">alternatingbackground</a>
+</li><li> <a href="cn/XUL/Attribute/alwaysopenpopup">alwaysopenpopup</a>
+</li><li> <a href="cn/XUL/Attribute/attribute">attribute</a>
+</li><li> <a href="cn/XUL/Attribute/autocheck">autocheck</a>
+</li><li> <a href="cn/XUL/Attribute/autoCheck">autoCheck</a>
+</li><li> <a href="cn/XUL/Attribute/autocompleteenabled">autocompleteenabled</a>
+</li><li> <a href="cn/XUL/Attribute/autocompletepopup">autocompletepopup</a>
+</li><li> <a href="cn/XUL/Attribute/autocompletesearch">autocompletesearch</a>
+</li><li> <a href="cn/XUL/Attribute/autocompletesearchparam">autocompletesearchparam</a>
+</li><li> <a href="cn/XUL/Attribute/autoFill">autoFill</a>
+</li><li> <a href="cn/XUL/Attribute/autoFillAfterMatch">autoFillAfterMatch</a>
+</li><li> <a href="cn/XUL/Attribute/autoscroll">autoscroll</a>
+</li><li> <a href="cn/XUL/Attribute/beforeselected">beforeselected</a>
+</li><li> <a href="cn/XUL/Attribute/buttonaccesskeyaccept">buttonaccesskeyaccept</a>
+</li><li> <a href="cn/XUL/Attribute/buttonaccesskeycancel">buttonaccesskeycancel</a>
+</li><li> <a href="cn/XUL/Attribute/buttonaccesskeydisclosure">buttonaccesskeydisclosure</a>
+</li><li> <a href="cn/XUL/Attribute/buttonaccesskeyextra1">buttonaccesskeyextra1</a>
+</li><li> <a href="cn/XUL/Attribute/buttonaccesskeyextra2">buttonaccesskeyextra2</a>
+</li><li> <a href="cn/XUL/Attribute/buttonaccesskeyhelp">buttonaccesskeyhelp</a>
+</li><li> <a href="cn/XUL/Attribute/buttonalign">buttonalign</a>
+</li><li> <a href="cn/XUL/Attribute/buttondir">buttondir</a>
+</li><li> <a href="cn/XUL/Attribute/buttonlabelaccept">buttonlabelaccept</a>
+</li><li> <a href="cn/XUL/Attribute/buttonlabelcancel">buttonlabelcancel</a>
+</li><li> <a href="cn/XUL/Attribute/buttonlabeldisclosure">buttonlabeldisclosure</a>
+</li><li> <a href="cn/XUL/Attribute/buttonlabelextra1">buttonlabelextra1</a>
+</li><li> <a href="cn/XUL/Attribute/buttonlabelextra2">buttonlabelextra2</a>
+</li><li> <a href="cn/XUL/Attribute/buttonlabelhelp">buttonlabelhelp</a>
+</li><li> <a href="cn/XUL/Attribute/buttonorient">buttonorient</a>
+</li><li> <a href="cn/XUL/Attribute/buttonpack">buttonpack</a>
+</li><li> <a href="cn/XUL/Attribute/buttons">buttons</a>
+</li><li> <a href="cn/XUL/Attribute/checked">checked</a>
+</li><li> <a href="cn/XUL/Attribute/checkState">checkState</a>
+</li><li> <a href="cn/XUL/Attribute/class">class</a>
+</li><li> <a href="cn/XUL/Attribute/closebutton">closebutton</a>
+</li><li> <a href="cn/XUL/Attribute/coalesceduplicatearcs">coalesceduplicatearcs</a>
+</li><li> <a href="cn/XUL/Attribute/collapse">collapse</a>
+</li><li> <a href="cn/XUL/Attribute/collapsed">collapsed</a>
+</li><li> <a href="cn/XUL/Attribute/color">color</a>
+</li><li> <a href="cn/XUL/Attribute/cols">cols</a>
+</li><li> <a href="cn/XUL/Attribute/command">command</a>
+</li><li> <a href="cn/XUL/Attribute/commandupdater">commandupdater</a>
+</li><li> <a href="cn/XUL/Attribute/completedefaultindex">completedefaultindex</a>
+</li><li> <a href="cn/XUL/Attribute/container">container</a>
+</li><li> <a href="cn/XUL/Attribute/containment">containment</a>
+</li><li> <a href="cn/XUL/Attribute/contentcontextmenu">contentcontextmenu</a>
+</li><li> <a href="cn/XUL/Attribute/contenttooltip">contenttooltip</a>
+</li><li> <a href="cn/XUL/Attribute/context">context</a>
+</li><li> <a href="cn/XUL/Attribute/contextmenu">contextmenu</a>
+</li><li> <a href="cn/XUL/Attribute/control">control</a>
+</li><li> <a href="cn/XUL/Attribute/crop">crop</a>
+</li><li> <a href="cn/XUL/Attribute/curpos">curpos</a>
+</li><li> <a href="cn/XUL/Attribute/current">current</a>
+</li><li> <a href="cn/XUL/Attribute/currentset">currentset</a>
+</li><li> <a href="cn/XUL/Attribute/customindex">customindex</a>
+</li><li> <a href="cn/XUL/Attribute/customizable">customizable</a>
+</li><li> <a href="cn/XUL/Attribute/cycler">cycler</a>
+</li><li> <a href="cn/XUL/Attribute/datasources">datasources</a>
+</li><li> <a href="cn/XUL/Attribute/decimalplaces">decimalplaces</a>
+</li><li> <a href="cn/XUL/Attribute/default">default</a>
+</li><li> <a href="cn/XUL/Attribute/defaultButton">defaultButton</a>
+</li><li> <a href="cn/XUL/Attribute/defaultset">defaultset</a>
+</li><li> <a href="cn/XUL/Attribute/description">description</a>
+</li><li> <a href="cn/XUL/Attribute/dir">dir</a>
+</li><li> <a href="cn/XUL/Attribute/disableAutocomplete">disableAutocomplete</a>
+</li><li> <a href="cn/XUL/Attribute/disableautocomplete">disableautocomplete</a>
+</li><li> <a href="cn/XUL/Attribute/disableautoselect">disableautoselect</a>
+</li><li> <a href="cn/XUL/Attribute/disableclose">disableclose</a>
+</li><li> <a href="cn/XUL/Attribute/disabled">disabled</a>
+</li><li> <a href="cn/XUL/Attribute/disablehistory">disablehistory</a>
+</li><li> <a href="cn/XUL/Attribute/disableKeyNavigation">disableKeyNavigation</a>
+</li><li> <a href="cn/XUL/Attribute/disablekeynavigation">disablekeynavigation</a>
+</li><li> <a href="cn/XUL/Attribute/disablesecurity">disablesecurity</a>
+</li><li> <a href="cn/XUL/Attribute/dlgtype">dlgtype</a>
+</li><li> <a href="cn/XUL/Attribute/dragging">dragging</a>
+</li><li> <a href="cn/XUL/Attribute/editable">editable</a>
+</li><li> <a href="cn/XUL/Attribute/editortype">editortype</a>
+</li><li> <a href="cn/XUL/Attribute/element">element</a>
+</li><li> <a href="cn/XUL/Attribute/empty">empty</a>
+</li><li> <a href="cn/XUL/Attribute/emptytext">emptytext</a>
+</li><li> <a href="cn/XUL/Attribute/enableColumnDrag">enableColumnDrag</a>
+</li><li> <a href="cn/XUL/Attribute/enablehistory">enablehistory</a>
+</li><li> <a href="cn/XUL/Attribute/equalsize">equalsize</a>
+</li><li> <a href="cn/XUL/Attribute/eventnode">eventnode</a>
+</li><li> <a href="cn/XUL/Attribute/events">events</a>
+</li><li> <a href="cn/XUL/Attribute/expr">expr</a>
+</li><li> <a href="cn/XUL/Attribute/firstdayofweek">firstdayofweek</a>
+</li><li> <a href="cn/XUL/Attribute/firstpage">firstpage</a>
+</li><li> <a href="cn/XUL/Attribute/first-tab">first-tab</a>
+</li><li> <a href="cn/XUL/Attribute/fixed">fixed</a>
+</li><li> <a href="cn/XUL/Attribute/flags">flags</a>
+</li><li> <a href="cn/XUL/Attribute/flex">flex</a>
+</li><li> <a href="cn/XUL/Attribute/focused">focused</a>
+</li><li> <a href="cn/XUL/Attribute/forceComplete">forceComplete</a>
+</li><li> <a href="cn/XUL/Attribute/forcecomplete">forcecomplete</a>
+</li><li> <a href="cn/XUL/Attribute/grippyhidden">grippyhidden</a>
+</li><li> <a href="cn/XUL/Attribute/grippytooltiptext">grippytooltiptext</a>
+</li><li> <a href="cn/XUL/Attribute/group">group</a>
+</li><li> <a href="cn/XUL/Attribute/handleCtrlPageUpDown">handleCtrlPageUpDown</a>
+</li><li> <a href="cn/XUL/Attribute/handleCtrlTab">handleCtrlTab</a>
+</li><li> <a href="cn/XUL/Attribute/height">height</a>
+</li><li> <a href="cn/XUL/Attribute/helpURI">helpURI</a>
+</li><li> <a href="cn/XUL/Attribute/hidden">hidden</a>
+</li><li> <a href="cn/XUL/Attribute/hidechrome">hidechrome</a>
+</li><li> <a href="cn/XUL/Attribute/hidecolumnpicker">hidecolumnpicker</a>
+</li><li> <a href="cn/XUL/Attribute/hideheader">hideheader</a>
+</li><li> <a href="cn/XUL/Attribute/hideseconds">hideseconds</a>
+</li><li> <a href="cn/XUL/Attribute/hidespinbuttons">hidespinbuttons</a>
+</li><li> <a href="cn/XUL/Attribute/homepage">homepage</a>
+</li><li> <a href="cn/XUL/Attribute/href">href</a>
+</li><li> <a href="cn/XUL/Attribute/icon">icon</a>
+</li><li> <a href="cn/XUL/Attribute/id">id</a>
+</li><li> <a href="cn/XUL/Attribute/ignoreBlurWhileSearching">ignoreBlurWhileSearching</a>
+</li><li> <a href="cn/XUL/Attribute/ignoreblurwhilesearching">ignorebluewhilesearching</a>
+</li><li> <a href="cn/XUL/Attribute/ignorecase">ignorecase</a>
+</li><li> <a href="cn/XUL/Attribute/ignoreincolumnpicker">ignoreincolumnpicker</a>
+</li><li> <a href="cn/XUL/Attribute/ignorekeys">ignorekeys</a>
+</li><li> <a href="cn/XUL/Attribute/image">image</a>
+</li><li> <a href="cn/XUL/Attribute/inactivetitlebarcolor">inactivetitlebarcolor</a>
+</li><li> <a href="cn/XUL/Attribute/increment">increment</a>
+</li><li> <a href="cn/XUL/Attribute/inputtooltiptext">inputtooltiptext</a>
+</li><li> <a href="cn/XUL/Attribute/insertafter">insertafter</a>
+</li><li> <a href="cn/XUL/Attribute/insertbefore">insertbefore</a>
+</li><li> <a href="cn/XUL/Attribute/instantApply">instantApply</a>
+</li><li> <a href="cn/XUL/Attribute/inverted">inverted</a>
+</li><li> <a href="cn/XUL/Attribute/iscontainer">iscontainer</a>
+</li><li> <a href="cn/XUL/Attribute/isempty">isempty</a>
+</li><li> <a href="cn/XUL/Attribute/key">key</a>
+</li><li> <a href="cn/XUL/Attribute/keycode">keycode</a>
+</li><li> <a href="cn/XUL/Attribute/keytext">keytext</a>
+</li><li> <a href="cn/XUL/Attribute/label">label</a>
+</li><li> <a href="cn/XUL/Attribute/lastpage">lastpage</a>
+</li><li> <a href="cn/XUL/Attribute/lastSelected">lastSelected</a>
+</li><li> <a href="cn/XUL/Attribute/last-tab">last-tab</a>
+</li><li> <a href="cn/XUL/Attribute/left">left</a>
+</li><li> <a href="cn/XUL/Attribute/linkedpanel">linkedpanel</a>
+</li><li> <a href="cn/XUL/Attribute/max">max</a>
+</li><li> <a href="cn/XUL/Attribute/maxheight">maxheight</a>
+</li><li> <a href="cn/XUL/Attribute/maxlength">maxlength</a>
+</li><li> <a href="cn/XUL/Attribute/maxpos">maxpos</a>
+</li><li> <a href="cn/XUL/Attribute/maxrows">maxrows</a>
+</li><li> <a href="cn/XUL/Attribute/maxwidth">maxwidth</a>
+</li><li> <a href="cn/XUL/Attribute/member">member</a>
+</li><li> <a href="cn/XUL/Attribute/menu">menu</a>
+</li><li> <a href="cn/XUL/Attribute/menuactive">menuactive</a>
+</li><li> <a href="cn/XUL/Attribute/min">min</a>
+</li><li> <a href="cn/XUL/Attribute/minheight">minheight</a>
+</li><li> <a href="cn/XUL/Attribute/minResultsForPopup">minResultsForPopup</a>
+</li><li> <a href="cn/XUL/Attribute/minresultsforpopup">minresultsforpopup</a>
+</li><li> <a href="cn/XUL/Attribute/minwidth">minwidth</a>
+</li><li> <a href="cn/XUL/Attribute/mode">mode</a>
+</li><li> <a href="cn/XUL/Attribute/modifiers">modifiers</a>
+</li><li> <a href="cn/XUL/Attribute/mousethrough">mousethrough</a>
+</li><li> <a href="cn/XUL/Attribute/multiline">multiline</a>
+</li><li> <a href="cn/XUL/Attribute/multiple">multiple</a>
+</li><li> <a href="cn/XUL/Attribute/name">name</a>
+</li><li> <a href="cn/XUL/Attribute/negate">negate</a>
+</li><li> <a href="cn/XUL/Attribute/newlines">newlines</a>
+</li><li> <a href="cn/XUL/Attribute/next">next</a>
+</li><li> <a href="cn/XUL/Attribute/noautofocus">noautofocus</a>
+</li><li> <a href="cn/XUL/Attribute/noautohide">noautohide</a>
+</li><li> <a href="cn/XUL/Attribute/nomatch">nomatch</a>
+</li><li> <a href="cn/XUL/Attribute/object">object</a>
+</li><li> <a href="cn/XUL/Attribute/observes">observes</a>
+</li><li> <a href="cn/XUL/Attribute/onbeforeaccept">onbeforeaccept</a>
+</li><li> <a href="cn/XUL/Attribute/onbookmarkgroup">onbookmarkgroup</a>
+</li><li> <a href="cn/XUL/Attribute/onchange">onchange</a>
+</li><li> <a href="cn/XUL/Attribute/onclosetab">onclosetab</a>
+</li><li> <a href="cn/XUL/Attribute/oncommand">oncommand</a>
+</li><li> <a href="cn/XUL/Attribute/oncommandupdate">oncommandupdate</a>
+</li><li> <a href="cn/XUL/Attribute/ondialogaccept">ondialogaccept</a>
+</li><li> <a href="cn/XUL/Attribute/ondialogcancel">ondialogcancel</a>
+</li><li> <a href="cn/XUL/Attribute/ondialogdisclosure">ondialogclosure</a>
+</li><li> <a href="cn/XUL/Attribute/ondialogextra1">ondialogextra1</a>
+</li><li> <a href="cn/XUL/Attribute/ondialogextra2">ondialogextra2</a>
+</li><li> <a href="cn/XUL/Attribute/ondialoghelp">ondialoghelp</a>
+</li><li> <a href="cn/XUL/Attribute/onerror">onerror</a>
+</li><li> <a href="cn/XUL/Attribute/onerrorcommand">onerrorcommand</a>
+</li><li> <a href="cn/XUL/Attribute/onextra1">onextra1</a>
+</li><li> <a href="cn/XUL/Attribute/onextra2">onextra2</a>
+</li><li> <a href="cn/XUL/Attribute/oninput">oninput</a>
+</li><li> <a href="cn/XUL/Attribute/onload">onload</a>
+</li><li> <a href="cn/XUL/Attribute/onnewtab">onnewtab</a>
+</li><li> <a href="cn/XUL/Attribute/onpageadvanced">onpageadvanced</a>
+</li><li> <a href="cn/XUL/Attribute/onpagehide">onpagehide</a>
+</li><li> <a href="cn/XUL/Attribute/onpagerewound">onpagerewound</a>
+</li><li> <a href="cn/XUL/Attribute/onpageshow">onpageshow</a>
+</li><li> <a href="cn/XUL/Attribute/onpaneload">onpaneload</a>
+</li><li> <a href="cn/XUL/Attribute/onpopuphidden">onpopuphidden</a>
+</li><li> <a href="cn/XUL/Attribute/onpopuphiding">onpopuphiding</a>
+</li><li> <a href="cn/XUL/Attribute/onpopupshowing">onpopupshowing</a>
+</li><li> <a href="cn/XUL/Attribute/onpopupshown">onpopupshown</a>
+</li><li> <a href="cn/XUL/Attribute/onsearchcomplete">onsearchcomplete</a>
+</li><li> <a href="cn/XUL/Attribute/onselect">onselect</a>
+</li><li> <a href="cn/XUL/Attribute/ontextcommand">ontextcommand</a>
+</li><li> <a href="cn/XUL/Attribute/ontextentered">ontextentered</a>
+</li><li> <a href="cn/XUL/Attribute/ontextrevert">ontextrevert</a>
+</li><li> <a href="cn/XUL/Attribute/ontextreverted">ontextreverted</a>
+</li><li> <a href="cn/XUL/Attribute/onwizardback">onwizardback</a>
+</li><li> <a href="cn/XUL/Attribute/onwizardcancel">onwizardcancel</a>
+</li><li> <a href="cn/XUL/Attribute/onwizardfinish">onwizardfinish</a>
+</li><li> <a href="cn/XUL/Attribute/onwizardnext">onwizardnext</a>
+</li><li> <a href="cn/XUL/Attribute/open">open</a>
+</li><li> <a href="cn/XUL/Attribute/ordinal">ordinal</a>
+</li><li> <a href="cn/XUL/Attribute/orient">orient</a>
+</li><li> <a href="cn/XUL/Attribute/pack">pack</a>
+</li><li> <a href="cn/XUL/Attribute/pageid">pageid</a>
+</li><li> <a href="cn/XUL/Attribute/pageincrement">pageincrement</a>
+</li><li> <a href="cn/XUL/Attribute/pagestep">pagestep</a>
+</li><li> <a href="cn/XUL/Attribute/parent">parent</a>
+</li><li> <a href="cn/XUL/Attribute/parsetype">parsetype</a>
+</li><li> <a href="cn/XUL/Attribute/persist">persist</a>
+</li><li> <a href="cn/XUL/Attribute/persistence">persistence</a>
+</li><li> <a href="cn/XUL/Attribute/phase">phase</a>
+</li><li> <a href="cn/XUL/Attribute/pickertooltiptext">pickertooltiptext</a>
+</li><li> <a href="cn/XUL/Attribute/popup">popup</a>
+</li><li> <a href="cn/XUL/Attribute/position">position</a>
+</li><li> <a href="cn/XUL/Attribute/predicate">predicate</a>
+</li><li> <a href="cn/XUL/Attribute/preference">preference</a>
+</li><li> <a href="cn/XUL/Attribute/preference-editable">preference-editable</a>
+</li><li> <a href="cn/XUL/Attribute/primary">primary</a>
+</li><li> <a href="cn/XUL/Attribute/priority">priority</a>
+</li><li> <a href="cn/XUL/Attribute/properties">properties</a>
+</li><li> <a href="cn/XUL/Attribute/querytype">querytype</a>
+</li><li> <a href="cn/XUL/Attribute/readonly">readonly</a>
+</li><li> <a href="cn/XUL/Attribute/ref">ref</a>
+</li><li> <a href="cn/XUL/Attribute/rel">rel</a>
+</li><li> <a href="cn/XUL/Attribute/removeelement">removeelement</a>
+</li><li> <a href="cn/XUL/Attribute/resizeafter">resizeafter</a>
+</li><li> <a href="cn/XUL/Attribute/resizebefore">resizebefore</a>
+</li><li> <a href="cn/XUL/Attribute/rows">rows</a>
+</li><li> <a href="cn/XUL/Attribute/screenX">screenX</a>
+</li><li> <a href="cn/XUL/Attribute/screenY">screenY</a>
+</li><li> <a href="cn/XUL/Attribute/searchSessions">searchSessions</a>
+</li><li> <a href="cn/XUL/Attribute/searchlabel">searchlabel</a>
+</li><li> <a href="cn/XUL/Attribute/selected">selected</a>
+</li><li> <a href="cn/XUL/Attribute/selectedIndex">selectedIndex</a>
+</li><li> <a href="cn/XUL/Attribute/seltype">seltype</a>
+</li><li> <a href="cn/XUL/Attribute/setfocus">setfocus</a>
+</li><li> <a href="cn/XUL/Attribute/showcaret">showcaret</a>
+</li><li> <a href="cn/XUL/Attribute/showCommentColumn">showCommentColumn</a>
+</li><li> <a href="cn/XUL/Attribute/showcommentcolumn">showcommentcolumn</a>
+</li><li> <a href="cn/XUL/Attribute/showpopup">showpopup</a>
+</li><li> <a href="cn/XUL/Attribute/size">size</a>
+</li><li> <a href="cn/XUL/Attribute/sizemode">sizemode</a>
+</li><li> <a href="cn/XUL/Attribute/sizetopopup">sizetopopup</a>
+</li><li> <a href="cn/XUL/Attribute/smoothscroll">smoothscroll</a>
+</li><li> <a href="cn/XUL/Attribute/sort">sort</a>
+</li><li> <a href="cn/XUL/Attribute/sortActive">sortActive</a>
+</li><li> <a href="cn/XUL/Attribute/sortDirection">sortDirection</a>
+</li><li> <a href="cn/XUL/Attribute/sortResource">sortResource</a>
+</li><li> <a href="cn/XUL/Attribute/sortResource2">sortResource2</a>
+</li><li> <a href="cn/XUL/Attribute/spellcheck">spellcheck</a>
+</li><li> <a href="cn/XUL/Attribute/src">src</a>
+</li><li> <a href="cn/XUL/Attribute/state">state</a>
+</li><li> <a href="cn/XUL/Attribute/statedatasource">statedatasource</a>
+</li><li> <a href="cn/XUL/Attribute/statusbar">statusbar</a>
+</li><li> <a href="cn/XUL/Attribute/statustext">statustext</a>
+</li><li> <a href="cn/XUL/Attribute/style">style</a>
+</li><li> <a href="cn/XUL/Attribute/subject">subject</a>
+</li><li> <a href="cn/XUL/Attribute/substate">substate</a>
+</li><li> <a href="cn/XUL/Attribute/suppressonselect">suppressonselect</a>
+</li><li> <a href="cn/XUL/Attribute/tabindex">tabindex</a>
+</li><li> <a href="cn/XUL/Attribute/tabScrolling">tabScrolling</a>
+</li><li> <a href="cn/XUL/Attribute/tabscrolling">tabscrolling</a>
+</li><li> <a href="cn/XUL/Attribute/targets">targets</a>
+</li><li> <a href="cn/XUL/Attribute/template">template</a>
+</li><li> <a href="cn/XUL/Attribute/timeout">timeout</a>
+</li><li> <a href="cn/XUL/Attribute/title">title</a>
+</li><li> <a href="cn/XUL/Attribute/toolbarname">toolbarname</a>
+</li><li> <a href="cn/XUL/Attribute/tooltip">tooltip</a>
+</li><li> <a href="cn/XUL/Attribute/tooltiptext">tooltiptext</a>
+</li><li> <a href="cn/XUL/Attribute/tooltiptextnew">tooltiptextnew</a>
+</li><li> <a href="cn/XUL/Attribute/top">top</a>
+</li><li> <a href="cn/XUL/Attribute/type">type</a>
+</li><li> <a href="cn/XUL/Attribute/uri">uri</a>
+</li><li> <a href="cn/XUL/Attribute/userAction">userAction</a>
+</li><li> <a href="cn/XUL/Attribute/validate">validate</a>
+</li><li> <a href="cn/XUL/Attribute/value">value</a>
+</li><li> <a href="cn/XUL/Attribute/var">var</a>
+</li><li> <a href="cn/XUL/Attribute/wait-cursor">wait-cursor</a>
+</li><li> <a href="cn/XUL/Attribute/width">width</a>
+</li><li> <a href="cn/XUL/Attribute/windowtype">windowtype</a>
+</li><li> <a href="cn/XUL/Attribute/wrap">wrap</a>
+</li><li> <a href="cn/XUL/Attribute/wraparound">wraparound</a>
+</li></ul>
+<div class="noinclude">
+</div>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/label/index.html b/files/zh-cn/mozilla/tech/xul/attribute/label/index.html
new file mode 100644
index 0000000000..1846c63a8e
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/label/index.html
@@ -0,0 +1,41 @@
+---
+title: label
+slug: Mozilla/Tech/XUL/Attribute/label
+tags:
+ - XUL Attributes
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/Attribute/label
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The label that will appear on the element. If this is left out, no text appears.<br>
+ label 在元素上显示。如果左侧出界,则不显示任何文字。</dd>
+</dl>
+<div class="noinclude">
+ <h3 id="See_also" name="See_also">See also</h3>
+ <ul>
+ <li><a href="/cn/XUL/Attribute/treeitem.label" title="cn/XUL/Attribute/treeitem.label">treeitem.label</a>, <code><a href="/cn/XUL/label" title="cn/XUL/label">&lt;label&gt;</a></code> element</li>
+ </ul>
+ <h4 id="Examples_in_JavaScript" name="Examples_in_JavaScript">Examples in JavaScript</h4>
+ <pre>&lt;label value="Whaw" id="the-big-label" command="the-big-button"/&gt;
+&lt;button id="the-big-button" label="Click me"
+ oncommand="alert(document.getElementById('the-big-label').value)"/&gt;
+
+&lt;label id="myLabel" value="My label"/&gt;
+&lt;button label="Click me"
+ oncommand="document.getElementById('myLabel').setAttribute('value','Value changed');" /&gt;
+
+&lt;checkbox label="my Checkbox" id="myCheckboX"/&gt;
+&lt;button label="Another click"
+ oncommand="document.getElementById('myCheckboX').setAttribute('label','Still not checked');"/&gt;
+&lt;button label="Show label of checkbox"
+ oncommand="alert( document.getElementById('myCheckboX').getAttribute('label') )"/&gt;
+</pre>
+</div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/max/index.html b/files/zh-cn/mozilla/tech/xul/attribute/max/index.html
new file mode 100644
index 0000000000..93eb88d4f7
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/max/index.html
@@ -0,0 +1,20 @@
+---
+title: max
+slug: Mozilla/Tech/XUL/Attribute/max
+translation_of: Archive/Mozilla/XUL/Attribute/max
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dd>
+ 类型:整数</dd>
+ <dd>
+ 设置刻度条控件(scale元素)或者数字输入框控件(type属性为number的textbox元素)中能输入的最大数字.刻度条控件中,该属性的默认值为100,数字输入框中,该属性的默认值为无穷大.</dd>
+</dl>
+<div class="noinclude">
+ <h3 id="See_also" name="See_also">相关链接</h3>
+ <ul>
+ <li><a href="/en/XUL/Attribute/progressmeter.max" title="en/XUL/Attribute/progressmeter.max">progressmeter.ma</a></li>
+ </ul>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/menuitem.key/index.html b/files/zh-cn/mozilla/tech/xul/attribute/menuitem.key/index.html
new file mode 100644
index 0000000000..b4239b866d
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/menuitem.key/index.html
@@ -0,0 +1,23 @@
+---
+title: menuitem.key
+slug: Mozilla/Tech/XUL/Attribute/menuitem.key
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/menuitem.key
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-menuitem.key"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/menuitem.key">key</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ element id</i>
+ </dd>
+ <dd>
+ Set to the <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> of a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/key" title="key">key</a></code> element whose key shortcut is displayed in the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/menuitem.name/index.html b/files/zh-cn/mozilla/tech/xul/attribute/menuitem.name/index.html
new file mode 100644
index 0000000000..a485138846
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/menuitem.name/index.html
@@ -0,0 +1,38 @@
+---
+title: menuitem.name
+slug: Mozilla/Tech/XUL/Attribute/menuitem.name
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/menuitem.name
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-menuitem.name"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/menuitem.name">name</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ string name</i>
+ </dd>
+ <dd>
+ Radio <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>s with the same name as put into a group. Only one <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> in each radio group can be checked at a time.</dd>
+</dl>
+<div class="noinclude">
+ <h3 id="Example" name="Example">Example</h3>
+ <pre>&lt;toolbox&gt;
+ &lt;menubar id="planets-menubar"&gt;
+ &lt;menu id="planet-menu" label="Planet"&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem id="jupiter" label="Jupiter" type="radio" name="planet"/&gt;
+ &lt;menuitem id="saturn" label="Saturn" type="radio" name="planet" checked="true"/&gt;
+ &lt;menuitem id="uranus" label="Uranus" type="radio" name="planet"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menu&gt;
+ &lt;/menubar&gt;
+&lt;/toolbox&gt;
+</pre>
+ <h3 id="See_also" name="See_also">See also</h3>
+ <p><a href="cn/XUL/Attribute/name">name</a> and <a href="cn/XUL_Tutorial/More_Menu_Features#Adding_Checkmarks_to_Menus">menus in the XUL Tutorial</a></p>
+</div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/menuitem.type/index.html b/files/zh-cn/mozilla/tech/xul/attribute/menuitem.type/index.html
new file mode 100644
index 0000000000..872c50331b
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/menuitem.type/index.html
@@ -0,0 +1,28 @@
+---
+title: menuitem.type
+slug: Mozilla/Tech/XUL/Attribute/menuitem.type
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/menuitem.type
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-menuitem.type"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/menuitem.type">type</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ one of the values below</i>
+ </dd>
+ <dd>
+ Can be used to create checkable menuitems or for radio button menuitems.</dd>
+</dl>
+<ul>
+ <li><code>checkbox</code>: The <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> is checked. The <code id="a-checked"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/checked">checked</a></code> attribute determines whether the menuitem is checked or not.</li>
+ <li><code>radio</code>: The <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> becomes part of a radio group. Other menuitems that have the same value for their <code id="a-name"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/name">name</a></code> attributes are part of the same <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/radio" title="radio">radio</a></code> group. Only one menuitem in the same radio group can be checked at once.</li>
+</ul>
+<p>More information on adding checkmarks to menus in the <a href="cn/XUL_Tutorial/More_Menu_Features#Adding_Checkmarks_to_Menus">XUL tutorial</a></p>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/min/index.html b/files/zh-cn/mozilla/tech/xul/attribute/min/index.html
new file mode 100644
index 0000000000..9646b1da96
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/min/index.html
@@ -0,0 +1,16 @@
+---
+title: min
+slug: Mozilla/Tech/XUL/Attribute/min
+translation_of: Archive/Mozilla/XUL/Attribute/min
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-min"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/min">min</a></code></dt>
+ <dd>
+ 类型:整数</dd>
+ <dd>
+ 该控件可以有的最小的整数值,默认值为0.</dd>
+</dl>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/name/index.html b/files/zh-cn/mozilla/tech/xul/attribute/name/index.html
new file mode 100644
index 0000000000..cd1695a84c
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/name/index.html
@@ -0,0 +1,16 @@
+---
+title: name
+slug: Mozilla/Tech/XUL/Attribute/name
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/name
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span>
+ <h3 id="See_also" name="See_also">See also</h3>
+ <ul>
+ <li><a href="cn/XUL/Attribute/menuitem.name">menuitem.name</a></li>
+ <li><a href="cn/XUL/Attribute/preference.name">preference.name</a></li>
+ </ul>
+</div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/onpopupshowing/index.html b/files/zh-cn/mozilla/tech/xul/attribute/onpopupshowing/index.html
new file mode 100644
index 0000000000..ec821daefe
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/onpopupshowing/index.html
@@ -0,0 +1,21 @@
+---
+title: onpopupshowing
+slug: Mozilla/Tech/XUL/Attribute/onpopupshowing
+translation_of: Archive/Mozilla/XUL/Attribute/onpopupshowing
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-onpopupshowing"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/onpopupshowing">onpopupshowing</a></code></dt>
+ <dd>
+ Type: <em>script code</em></dd>
+ <dd>
+ This event is sent to a popup just before it is opened. This handler is usually used to dynamically set the contents when the user requests to display it. Returning <code>false</code> from this event handler prevents the popup from appearing.</dd>
+ <dd>
+ 该事件在 popup 打开之前传给它。它用于动态生成菜单项。如果返回 false 值,则 popup 将不会显示菜单项。</dd>
+</dl>
+<div class="noinclude">
+ <p></p>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/onpopupshown/index.html b/files/zh-cn/mozilla/tech/xul/attribute/onpopupshown/index.html
new file mode 100644
index 0000000000..a94af052a2
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/onpopupshown/index.html
@@ -0,0 +1,21 @@
+---
+title: onpopupshown
+slug: Mozilla/Tech/XUL/Attribute/onpopupshown
+translation_of: Archive/Mozilla/XUL/Attribute/onpopupshown
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-onpopupshown"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/onpopupshown">onpopupshown</a></code></dt>
+ <dd>
+ Type: <em>script code</em></dd>
+ <dd>
+ This event is sent to a popup after it has been opened, much like the <code>onload</code> event is sent to a window when it is opened.</dd>
+ <dd>
+ 该事件在 popup 打开之后触发,与 window 的 onload 事件比较类似。</dd>
+</dl>
+<div class="noinclude">
+ <p></p>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/orient/index.html b/files/zh-cn/mozilla/tech/xul/attribute/orient/index.html
new file mode 100644
index 0000000000..aa1c735a6c
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/orient/index.html
@@ -0,0 +1,16 @@
+---
+title: orient
+slug: Mozilla/Tech/XUL/Attribute/orient
+translation_of: Archive/Mozilla/XUL/Attribute/orient
+---
+<p><strong>布局(orient)</strong></p>
+<dl>
+ <dd>
+ 值类型:可以是下面值中的一种。<br>
+ 指定了子控件的布局(orient)为水平分布的(horizontally)或者是垂直分布的(vertically)。默认值依赖于控件本身。你也可以使用<a href="cn/-moz-box-orient">-moz-box-orient</a>中的样式属性。
+ <ul>
+ <li><strong>horizontally</strong>: 子控件会被按照在xul源文件中出现的位置依次布置在一行中。</li>
+ <li><strong>vertically</strong>: 子控件会被按照在xul源文件中出现的位置依次布置在一列中。</li>
+ </ul>
+ </dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/pending/index.html b/files/zh-cn/mozilla/tech/xul/attribute/pending/index.html
new file mode 100644
index 0000000000..0ab9643c8f
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/pending/index.html
@@ -0,0 +1,15 @@
+---
+title: pending
+slug: Mozilla/Tech/XUL/Attribute/pending
+translation_of: Archive/Mozilla/XUL/Attribute/pending
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-pending"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/pending">pending</a></code> </dt>
+ <dd>
+ Type: <em>boolean</em></dd>
+ <dd>
+ This attribute is set to <code>true</code> if the tab is currently in the process of being restored by the session store service. Once the tab is restored, this attribute is removed. You can determine if a tab is being restored by checking to see if <code>hasAttribute("pending")</code> is <code>true</code>. If the user has turned on the "Don't load tabs until selected" preference, the <code id="a-pending"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/pending">pending</a></code> attribute is set on tabs until they get loaded.</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/persist/index.html b/files/zh-cn/mozilla/tech/xul/attribute/persist/index.html
new file mode 100644
index 0000000000..b1d30d5a59
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/persist/index.html
@@ -0,0 +1,24 @@
+---
+title: persist
+slug: Mozilla/Tech/XUL/Attribute/persist
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/persist
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-persist"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/persist">persist</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ space-separated list of attribute names</i>
+ </dd>
+ <dd>
+ A space-separated list of attributes that are maintained when the window is closed. When the window is re-opened, the values of persistent attributes are restored. In Mozilla, persistent attributes are stored in the per-profile file <code>localstore.rdf</code>. Persistence can also be stored using the <code>document.persist</code> function. In order for persistence to work, the element must also have an <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code>.</dd>
+</dl>
+<p> </p>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/selected/index.html b/files/zh-cn/mozilla/tech/xul/attribute/selected/index.html
new file mode 100644
index 0000000000..47971cd8c8
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/selected/index.html
@@ -0,0 +1,28 @@
+---
+title: selected
+slug: Mozilla/Tech/XUL/Attribute/selected
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/selected
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-selected"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/selected">selected</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Indicates whether the element is selected or not. This value is read-only. To change the selection, set either the <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code> or <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedItem">selectedItem</a></span></code> property of the containing element.</dd>
+</dl>
+<div class="noinclude">
+ <h3 id="See_also" name="See_also">See also</h3>
+ <ul>
+ <li><a href="cn/XUL/Attribute/prefpane.selected">prefpane.selected</a></li>
+ <li><a href="cn/XUL/Attribute/tab.selected">tab.selected</a></li>
+ </ul>
+</div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/selectedindex/index.html b/files/zh-cn/mozilla/tech/xul/attribute/selectedindex/index.html
new file mode 100644
index 0000000000..72dd679801
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/selectedindex/index.html
@@ -0,0 +1,15 @@
+---
+title: selectedIndex
+slug: Mozilla/Tech/XUL/Attribute/selectedIndex
+translation_of: Archive/Mozilla/XUL/Attribute/selectedIndex
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-selectedIndex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/selectedIndex">selectedIndex</a></code></dt>
+ <dd>
+ 类型: 整数</dd>
+ <dd>
+ 获取或设置当前所选面板的索引号,索引号从0开始.</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/tabindex/index.html b/files/zh-cn/mozilla/tech/xul/attribute/tabindex/index.html
new file mode 100644
index 0000000000..c5e54fdd1c
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/tabindex/index.html
@@ -0,0 +1,18 @@
+---
+title: tabindex
+slug: Mozilla/Tech/XUL/Attribute/tabindex
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/tabindex
+---
+<div class="noinclude"><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+
+<dl>
+ <dt><code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code></dt>
+ <dd>Type:<em>integer</em></dd>
+ <dd>当用户按下 "<kbd>tab</kbd>" 键时焦点移动到元素上的顺序。<code>tabindex</code> 数字越大,顺序越靠后。</dd>
+</dl>
+
+<div class="noinclude"> </div>
+
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/validate/index.html b/files/zh-cn/mozilla/tech/xul/attribute/validate/index.html
new file mode 100644
index 0000000000..a56181d8b7
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/validate/index.html
@@ -0,0 +1,27 @@
+---
+title: validate
+slug: Mozilla/Tech/XUL/Attribute/validate
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/validate
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-validate"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/validate">validate</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ one of the values below</i>
+ </dd>
+ <dd>
+ This attribute indicates whether to load the image from the cache or not. This would be useful if the images are stored remotely or you plan on swapping the image frequently. The following values are accepted, or leave out the attribute entirely for default handling:</dd>
+</dl>
+<ul>
+ <li><code>always</code>: The image is always checked to see whether it should be reloaded.</li>
+ <li><code>never</code>: The image will be loaded from the cache if possible.</li>
+</ul>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/attribute/value/index.html b/files/zh-cn/mozilla/tech/xul/attribute/value/index.html
new file mode 100644
index 0000000000..f436308d89
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/attribute/value/index.html
@@ -0,0 +1,30 @@
+---
+title: value
+slug: Mozilla/Tech/XUL/Attribute/value
+tags:
+ - XUL Attributes
+translation_of: Archive/Mozilla/XUL/Attribute/value
+---
+<div class="noinclude">
+ <span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ The string attribute allows you to associate a data value with an element. It is not used for any specific purpose, but you can access it with a script for your own use.</dd>
+</dl>
+<div class="noinclude">
+ <h3 id="See_also" name="See_also">See also</h3>
+ <ul>
+ <li><a href="cn/XUL/Attribute/label.value">label.value</a></li>
+ <li><a href="cn/XUL/Attribute/progressmeter.value">progressmeter.value</a></li>
+ <li><a href="cn/XUL/Attribute/textbox.value">textbox.value</a></li>
+ <li><a href="cn/XUL/Attribute/textnode.value">textnode.value</a></li>
+ </ul>
+</div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/broadcaster/index.html b/files/zh-cn/mozilla/tech/xul/broadcaster/index.html
new file mode 100644
index 0000000000..be97efef42
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/broadcaster/index.html
@@ -0,0 +1,91 @@
+---
+title: broadcaster
+slug: Mozilla/Tech/XUL/broadcaster
+translation_of: Archive/Mozilla/XUL/broadcaster
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<div class="noinclude">
+ <br>
+ 当您希望若干个元素共享一个或多个属性值时,或者当您想要多个元素对某一个状态改变做出响应是,可以使用 broadcaster。任何监视 broadcaster 的元素都会共享到 broadcaster 中的属性。比如说,假设我们有一个 broadcaster,它拥有一个 <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> 属性,而它的观察者们正在监视这个 label。这时如果 label 发生了改变,label 的观察者们将立刻被唤醒(update)。改变发生时,每个观察者都会收到一个 <code>onbroadcast 事件。</code><br>
+ <br>
+ 对于 <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> 或者 <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/button" title="button">button</a></code> 来说,如果只是为了根据功能是否可用,即时更新菜单项目的 <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> 状态,那么您应该优先考虑 <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/command" title="command">command</a></code>。</div>
+<p>更多内容请参考 <a href="/en/XUL_Tutorial/Broadcasters_and_Observers" title="en/XUL_Tutorial/Broadcasters_and_Observers">Broadcasters and Observers</a> XUL Tutorial.</p>
+<h3 id="Examples" name="Examples">Examples</h3>
+<p>(example needed)</p>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0 0 10px 10px; padding: 0 10px; background: rgb(238, 238, 238);">
+<tbody>
+<tr>
+<td><p><strong>Inherited from XUL element</strong><br> <small>
+<code id="a-align"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/align">align</a></code>,
+<code id="a-allowevents"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allowevents">allowevents</a></code>,
+<code id="a-allownegativeassertions"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allownegativeassertions">allownegativeassertions</a></code>,
+<code id="a-class"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/class">class</a></code>,
+<code id="a-coalesceduplicatearcs"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/coalesceduplicatearcs">coalesceduplicatearcs</a></code>,
+<code id="a-collapsed"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/collapsed">collapsed</a></code>,
+<code id="a-container"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/container">container</a></code>,
+<code id="a-containment"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/containment">containment</a></code>,
+<code id="a-context"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/context">context</a></code>,
+<code id="a-contextmenu"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/contextmenu">contextmenu</a></code>,
+<code id="a-datasources"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/datasources">datasources</a></code>,
+<code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code>,
+<code id="a-empty"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/empty">empty</a></code>,
+<code id="a-equalsize"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/equalsize">equalsize</a></code>,
+<code id="a-flags"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flags">flags</a></code>,
+<code id="a-flex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flex">flex</a></code>,
+<code id="a-height"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/height">height</a></code>,
+<code id="a-hidden"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/hidden">hidden</a></code>,
+<code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code>,
+<code id="a-insertafter"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/insertafter">insertafter</a></code>,
+<code id="a-insertbefore"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/insertbefore">insertbefore</a></code>,
+<code id="a-left"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/left">left</a></code>,
+<code id="a-maxheight"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/maxheight">maxheight</a></code>,
+<code id="a-maxwidth"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/maxwidth">maxwidth</a></code>,
+<code id="a-menu"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/menu">menu</a></code>,
+<code id="a-minheight"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/minheight">minheight</a></code>,
+<code id="a-minwidth"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/minwidth">minwidth</a></code>,
+<code id="a-mousethrough"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/mousethrough">mousethrough</a></code>,
+<code id="a-observes"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/observes">observes</a></code>,
+<code id="a-ordinal"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/ordinal">ordinal</a></code>,
+<code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code>,
+<code id="a-pack"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/pack">pack</a></code>,
+<code id="a-persist"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/persist">persist</a></code>,
+<code id="a-popup"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/popup">popup</a></code>,
+<code id="a-position"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/position">position</a></code>,
+<code id="a-preference-editable"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/preference-editable">preference-editable</a></code>,
+<code id="a-querytype"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/querytype">querytype</a></code>,
+<code id="a-ref"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/ref">ref</a></code>,
+<code id="a-removeelement"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/removeelement">removeelement</a></code>,
+<code id="a-sortDirection"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortDirection">sortDirection</a></code>,
+<code id="a-sortResource"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortResource">sortResource</a></code>,
+<code id="a-sortResource2"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortResource2">sortResource2</a></code>,
+<code id="a-statustext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/statustext">statustext</a></code>,
+<code id="a-style"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/style">style</a></code>,
+<code id="a-template"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/template">template</a></code>,
+<code id="a-tooltip"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tooltip">tooltip</a></code>,
+<code id="a-tooltiptext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tooltiptext">tooltiptext</a></code>,
+<code id="a-top"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/top">top</a></code>,
+<code id="a-uri"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/uri">uri</a></code>,
+<code id="a-wait-cursor"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/wait-cursor">wait-cursor</a></code>,
+<code id="a-width"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/width">width</a></code> </small></p>
+</td>
+</tr>
+</tbody>
+</table><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited Properties</strong><br> <small> <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/align">align</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/allowEvents">allowEvents</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/boxObject">boxObject</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/builder">builder</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/className">className</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/collapsed">collapsed</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/contextMenu">contextMenu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/controllers">controllers</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/database">database</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/datasources">datasources</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/dir">dir</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/flex">flex</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/height">height</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/hidden">hidden</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/id">id</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/left">left</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxHeight">maxHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxWidth">maxWidth</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menu">menu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minHeight">minHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minWidth">minWidth</a></span></code>, , , , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/observes">observes</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ordinal">ordinal</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/orient">orient</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/pack">pack</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/persist">persist</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ref">ref</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/resource">resource</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/statusText">statusText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/style">style</a></span></code>, ,, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltip">tooltip</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltipText">tooltipText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/top">top</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/width">width</a></span></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<p>TBD</p>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/browser/index.html b/files/zh-cn/mozilla/tech/xul/browser/index.html
new file mode 100644
index 0000000000..4f9a039f3a
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/browser/index.html
@@ -0,0 +1,409 @@
+---
+title: browser
+slug: Mozilla/Tech/XUL/browser
+translation_of: Archive/Mozilla/XUL/browser
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>A frame which is expected to contain a view of a Web document. It is similar to an <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/iframe" title="iframe">iframe</a></code> except that it holds a page history and contains additional methods to manipulate the currently displayed page.</p>
+<p>Most of the properties and methods of the browser will rarely be used and can only be called from chrome URLs. Other URLs will need to use the document and history objects to change the displayed document.</p>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-autocompleteenabled">autocompleteenabled</a>, <a href="#a-autocompletepopup">autocompletepopup</a>, <a href="#a-autoscroll">autoscroll</a>, <a href="#a-disablehistory">disablehistory</a>, <a href="#a-disablesecurity">disablesecurity</a>, <a href="#a-homepage">homepage</a>, <a href="#a-showcaret">showcaret</a>, <a href="#a-src">src</a>, <a href="#a-browser.type">type</a></dd>
+</dl>
+<dl>
+ <dt>
+ Properties</dt>
+ <dd>
+ <a href="#p-accessibleType">accessibleType</a>, <a href="#p-canGoBack">canGoBack</a>, <a href="#p-canGoForward">canGoForward</a>, <a href="#p-contentDocument">contentDocument</a>, <a href="#p-contentPrincipal">contentPrincipal</a>, <a href="#p-contentTitle">contentTitle</a>, <a href="#p-contentViewerEdit">contentViewerEdit</a>, <a href="#p-contentViewerFile">contentViewerFile</a>, <a href="#p-contentWindow">contentWindow</a>, <a href="#p-currentURI">currentURI</a>, <a href="#p-docShell">docShell</a>, <a href="#p-documentCharsetInfo">documentCharsetInfo</a>, <a href="#p-homePage">homePage</a>, <a href="#p-markupDocumentViewer">markupDocumentViewer</a>, <a href="#p-messageManager">messageManager</a>, <a href="#p-browser.preferences">preferences</a>, <a href="#p-securityUI">securityUI</a>, <a href="#p-sessionHistory">sessionHistory</a>, <a href="#p-webBrowserFind">webBrowserFind</a>, <a href="#p-webNavigation">webNavigation</a>, <a href="#p-webProgress">webProgress</a></dd>
+</dl>
+<dl>
+ <dt>
+ Methods</dt>
+ <dd>
+ <a href="#m-addProgressListener">addProgressListener</a>, <a href="#m-goBack">goBack</a>, <a href="#m-goForward">goForward</a>, <a href="#m-goHome">goHome</a>, <a href="#m-gotoIndex">gotoIndex</a>, <a href="#m-loadURI">loadURI</a>, <a href="#m-loadURIWithFlags">loadURIWithFlags</a>, <a href="#m-reload">reload</a>, <a href="#m-reloadWithFlags">reloadWithFlags</a>, <a href="#m-removeProgressListener">removeProgressListener</a>, <a href="#m-stop">stop</a>, <a href="#m-swapDocShells">swapDocShells</a></dd>
+</dl>
+<h3 id="Examples" name="Examples">Examples</h3>
+<div class="float-right">
+ <img alt="Image:XUL_ref_browser.png" class="internal" src="/@api/deki/files/447/=XUL_ref_browser.png"></div>
+<pre>&lt;!-- shows Mozilla homepage inside a groupbox --&gt;
+&lt;groupbox flex="1"&gt;
+ &lt;caption label="Mozilla homepage"/&gt;
+ &lt;browser type="content" src="http://www.mozilla.org" flex="1"/&gt;
+&lt;/groupbox&gt;
+</pre>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p></p>
+<p></p><div id="a-autocompleteenabled">
+
+
+<dl>
+ <dt><code id="a-autocompleteenabled"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/autocompleteenabled">autocompleteenabled</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>Set to <code>true</code> to enable autocomplete of fields.</dd>
+</dl>
+</div> <div id="a-autocompletepopup">
+
+<dl>
+ <dt>
+ <code id="a-autocompletepopup"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/autocompletepopup">autocompletepopup</a></code></dt>
+ <dd>
+ Type: <em>id</em></dd>
+ <dd>
+ The <code id="a-id"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> of a <code><a href="/en-US/docs/Mozilla/Tech/XUL/popup" title="popup">popup</a></code> element used to hold autocomplete results for the element.</dd>
+</dl>
+
+</div> <div id="a-autoscroll">
+
+
+<dl>
+ <dt><code id="a-autoscroll"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/autoscroll">autoscroll</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>Set to <code>false</code> to disable autoscroll for this browser. If this attribute is set to <code>true</code> or omitted, autoscroll will be enabled or depending on the user preference <code>general.autoScroll</code>.</dd>
+</dl>
+</div> <div id="a-disablehistory">
+
+<dl> <dt><code id="a-disablehistory"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/disablehistory">disablehistory</a></code></dt> <dd>Type: <em>boolean</em></dd> <dd>Disables both session and global history for the docshell attached to the browser.</dd>
+</dl>
+</div> <div id="a-disablesecurity">
+
+
+<dl>
+ <dt><code id="a-disablesecurity"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/disablesecurity">disablesecurity</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>Set this attribute to <code>true</code> to disable the security UI for this browser. Omit this attribute off to enable it.</dd>
+</dl>
+</div> <div id="a-homepage">
+
+
+<dl>
+ <dt><code id="a-homepage"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/homepage">homepage</a></code></dt>
+ <dd>Type: <em>URL</em></dd>
+ <dd>This attribute allows you to set a homepage for the browser element. It does not have any correlation with the user's browser homepage; instead it is a convenient property to hold a home page. You can switch to this home page using the <span id="m-goHome"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/goHome">goHome</a></code></span> method.</dd>
+</dl>
+</div> <div id="a-showcaret">
+
+
+<dl>
+ <dt><code id="a-showcaret"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/showcaret">showcaret</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>Whether or not to cause a typing caret to be visible in the content area. Default is <code>false</code>.</dd>
+</dl>
+
+
+</div> <div id="a-src">
+
+<dl>
+ <dt>
+ <code id="a-src"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/src">src</a></code></dt>
+ <dd>
+ Type: <em>URI</em></dd>
+ <dd>
+ The URI of the content to appear in the element.</dd>
+</dl>
+
+
+</div> <div id="a-browser.type">
+
+
+<dl>
+ <dt><code id="a-browser.type"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/browser.type">type</a></code></dt>
+ <dd><span class="seoSummary">Type: <em>one of the values below</em>.</span></dd>
+ <dd><span class="seoSummary">The type of browser, which can be used to set access of the document loaded inside the browser.</span> If this is not set, the loaded document has the same access as the window containing the <code><code><a href="/en-US/docs/Mozilla/Tech/XUL/browser" title="browser">browser</a></code></code>. More precisely: The document loaded into a chrome window is always of chrome type. Subdocuments of chrome documents are of chrome type, unless the container element (one of iframe, browser or editor) has one of the special type attribute values (the common ones are content, content-targetable and content-primary) indicating that the subdocument is of content type. This boundary has a number of special effects, such as making window.top == window (unless the <code><code><a href="/en-US/docs/Mozilla/Tech/XUL/browser" title="browser">browser</a></code></code> is added to a chrome document), and preventing documents from inheriting the principal of the parent document. The type attribute on all frames in content documents is ignored; subdocuments of content documents are always content documents.</dd>
+ <dt>
+ <div class="warning"><strong>Warning: </strong>The type attribute must be set before the element is inserted into the document.</div>
+ </dt>
+ <dd>
+ <dl>
+ <dt><code>content</code></dt>
+ <dd>A browser for content. The content that is loaded inside the browser is not allowed to access the chrome above it.</dd>
+ <dt><code>content-primary</code></dt>
+ <dd>The primary browser for content. The content that is loaded inside the browser is not allowed to access the chrome above it. For instance, in a web browser, this would be the element that displays the web page. The window for the primary content can be retrieved more conveniently using <a href="/en/DOM/window.content" title="en/DOM/window.content">window.content</a>.</dd>
+ <dt><code>content-targetable</code></dt>
+ <dd>One browser among many for content. The content that is loaded inside the browser is not allowed to access the chrome above it. This is the preferred value for any <code><code><a href="/en-US/docs/Mozilla/Tech/XUL/browser" title="browser">browser</a></code></code> element in an application, which will use multiple browsers of equal privileges, and is unselected at the moment.</dd>
+ <dt><code>chrome</code></dt>
+ <dd>(default behaviour): A browser, intended to be used for loading privileged content using a chrome:// URI. Don't use for content from web, as this may cause serious security problems!</dd>
+ </dl>
+ </dd>
+</dl>
+
+
+</div><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p></p>
+<p></p><div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-canGoBack">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/canGoBack">canGoBack</a></span></code></dt>
+ <dd>
+ Type: <em>boolean</em></dd>
+ <dd>
+ This read-only property is <code>true</code> if there is a page to go back to in the session history and the Back button should be enabled.</dd>
+</dl></div> <div id="p-canGoForward">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/canGoForward">canGoForward</a></span></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>This read-only property is <code>true</code> if there is a page to go forward to in the session history and the Forward button should be enabled.</dd>
+</dl></div> <div id="p-contentDocument">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/contentDocument">contentDocument</a></span></code></dt>
+ <dd>
+ Type: <em>document</em></dd>
+ <dd>
+ This read-only property contains the document object in the element.</dd>
+</dl></div> <div id="p-contentPrincipal">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/contentPrincipal">contentPrincipal</a></span></code></dt>
+ <dd>Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPrincipal" title="">nsIPrincipal</a></code></em></dd>
+ <dd>This read-only property contains the principal for the content loaded in the browser, which provides security context information.</dd>
+</dl></div> <div id="p-contentTitle">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/contentTitle">contentTitle</a></span></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ This read-only property contains the title of the document object in the browser.</dd>
+</dl></div> <div id="p-contentViewerEdit">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/contentViewerEdit">contentViewerEdit</a></span></code></dt>
+ <dd>
+ Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentViewerEdit" title="">nsIContentViewerEdit</a></code></em></dd>
+ <dd>
+ This read-only property contains the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentViewerEdit" title="">nsIContentViewerEdit</a></code> which handles clipboard operations on the document.</dd>
+</dl></div> <div id="p-contentViewerFile">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/contentViewerFile">contentViewerFile</a></span></code></dt>
+ <dd>
+ Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentViewerFile" title="">nsIContentViewerFile</a></code></em></dd>
+ <dd>
+ Reference to the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentViewerFile" title="">nsIContentViewerFile</a></code> interface for the document.</dd>
+</dl></div> <div id="p-contentWindow">
+<dl> <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/contentWindow">contentWindow</a></span></code></dt> <dd>Type: <em>TODO</em></dd> <dd>Use the contentWindow.wrappedJSObject to obtain a DOM(html) window object</dd>
+</dl></div> <div id="p-currentURI">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/currentURI">currentURI</a></span></code></dt>
+ <dd>
+ Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIURI" title="">nsIURI</a></code></em></dd>
+ <dd>
+ This read-only property contains the currently loaded URL. To change the URL, use the <span id="m-loadURI"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/loadURI">loadURI</a></code></span> method.</dd>
+</dl></div> <div id="p-docShell">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/docShell">docShell</a></span></code></dt>
+ <dd>
+ Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDocShell" title="">nsIDocShell</a></code></em></dd>
+ <dd>
+ This read-only property contains the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDocShell" title="">nsIDocShell</a></code> object for the document.</dd>
+</dl></div> <div id="p-documentCharsetInfo">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/documentCharsetInfo">documentCharsetInfo</a></span></code> <span class="inlineIndicator obsolete obsoleteInline" title="(Firefox 12.0 / Thunderbird 12.0 / SeaMonkey 2.9)">Obsolete since Gecko 12.0</span></dt>
+ <dd>
+ Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDocumentCharsetInfo" title="">nsIDocumentCharsetInfo</a></code></em></dd>
+ <dd>
+ This read-only property contains the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDocumentCharsetInfo" title="">nsIDocumentCharsetInfo</a></code> object for the document which is used to handle which character set should be used to display the document. The properties of the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDocumentCharsetInfo" title="">nsIDocumentCharsetInfo</a></code> object were merged into the docshell in Gecko 12.0 (Firefox 12.0 / Thunderbird 12.0 / SeaMonkey 2.9).</dd>
+</dl></div> <div id="p-homePage">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/homePage">homePage</a></span></code></dt>
+ <dd>
+ Type: <em>string home page URL</em></dd>
+ <dd>
+ This property holds the value of the user's home page setting.</dd>
+</dl></div> <div id="p-markupDocumentViewer">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/markupDocumentViewer">markupDocumentViewer</a></span></code></dt>
+ <dd>
+ 类型: <em><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMarkupDocumentViewer" title="">nsIMarkupDocumentViewer</a></code></em></dd>
+ <dd>
+ 这个只读的属性包含 <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMarkupDocumentViewer" title="">nsIMarkupDocumentViewer</a></code> 接口,负责document文档的绘制。</dd>
+</dl></div> <div id="p-messageManager">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/messageManager">messageManager</a></span></code> </dt>
+ <dd>
+ Type: <em>message manager object</em></dd>
+ <dd>
+ This read-only property returns the <a href="/en/The_message_manager" title="en/The message manager">message manager</a> object for the <code><a href="/en-US/docs/Mozilla/Tech/XUL/browser" title="browser">browser</a></code> element.</dd>
+</dl></div> <div id="p-browser.preferences">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/browser.preferences">preferences</a></span></code></dt>
+ <dd>
+ 类型: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPrefService" title="">nsIPrefService</a></code></dd>
+ <dd>
+ 这是一个只读属性,其值为一个<code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPref" title="">nsIPref</a></code>对象,可以用来读取或设置用户的首选项.</dd>
+</dl></div> <div id="p-securityUI">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/securityUI">securityUI</a></span></code></dt>
+ <dd>
+ Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISecureBrowserUI" title="">nsISecureBrowserUI</a></code></em></dd>
+ <dd>
+ The read-only property holds an object which may be used to determine the security level of the loaded document.</dd>
+</dl></div> <div id="p-sessionHistory">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/sessionHistory">sessionHistory</a></span></code></dt>
+ <dd>
+ Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISHistory" title="">nsISHistory</a></code></em></dd>
+ <dd>
+ This read-only property contains the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISHistory" title="">nsISHistory</a></code> object which holds the session history.</dd>
+</dl></div> <div id="p-webBrowserFind">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/webBrowserFind">webBrowserFind</a></span></code></dt>
+ <dd>
+ Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWebBrowserFind" title="">nsIWebBrowserFind</a></code></em></dd>
+ <dd>
+ This read-only property contains an <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWebBrowserFind" title="">nsIWebBrowserFind</a></code> object which can be used to search for text in the document.</dd>
+</dl></div> <div id="p-webNavigation">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/webNavigation">webNavigation</a></span></code></dt>
+ <dd>
+ Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWebNavigation" title="">nsIWebNavigation</a></code></em></dd>
+ <dd>
+ This read-only property contains the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWebNavigation" title="">nsIWebNavigation</a></code> object for the document. Most of its methods are callable directly on the element itself, such as <span id="m-goBack"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/goBack">goBack</a></code></span> and <span id="m-goForward"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/goForward">goForward</a></code></span>. It also contains the load constants used by <span id="m-reloadWithFlags"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/reloadWithFlags">reloadWithFlags</a></code></span> and <span id="m-loadURIWithFlags"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/loadURIWithFlags">loadURIWithFlags</a></code></span>.</dd>
+</dl></div> <div id="p-webProgress">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/webProgress">webProgress</a></span></code></dt>
+ <dd>
+ Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWebProgress" title="">nsIWebProgress</a></code></em></dd>
+ <dd>
+ This read-only property contains an <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWebProgress" title="">nsIWebProgress</a></code> object which is used to monitor the progress of a document loading.</dd>
+</dl></div><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0 0 10px 10px; padding: 0 10px; background: rgb(238, 238, 238); float: right; width: 250px;">
+<tbody>
+<tr>
+<td>
+<p><strong>Inherited Methods</strong><br>
+<small><code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.cloneNode">cloneNode()</a></code>, <a href="/En/DOM/Node.compareDocumentPosition" title="En/DOM/Node.compareDocumentPosition">compareDocumentPosition</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getBoundingClientRect">getBoundingClientRect()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getClientRects">getClientRects()</a></code>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span>, <span id="m-getElementsByAttributeNS"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttributeNS">getElementsByAttributeNS</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByClassName">getElementsByClassName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getFeature">getFeature()</a></code>, <a href="/En/DOM/Node.getUserData" title="En/DOM/Node.getUserData">getUserData</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isDefaultNamespace">isDefaultNamespace()</a></code>, <a href="/En/DOM/Node.isEqualNode" title="En/DOM/Node.isEqualNode">isEqualNode</a>, <a href="/En/DOM/Node.isSameNode" title="En/DOM/Node.isSameNode">isSameNode</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <a href="/En/DOM/Node.lookupNamespaceURI" title="En/DOM/Node.lookupNamespaceURI">lookupNamespaceURI</a>, <a href="/En/DOM/Node.lookupPrefix" title="En/DOM/Node.lookupPrefix">lookupPrefix</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.querySelector">querySelector()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.querySelectorAll">querySelectorAll()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code>, <a href="/En/DOM/Node.setUserData" title="En/DOM/Node.setUserData">setUserData</a></small></p>
+
+</td>
+</tr>
+</tbody>
+</table><p></p>
+<p></p><dl>
+ <dt>
+ <span id="m-addProgressListener"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/addProgressListener">addProgressListener( listener )</a></code></span></dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+ <dd>
+ Add a progress listener to the browser which will monitor loaded documents. The progress listener should implement the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWebProgressListener" title="">nsIWebProgressListener</a></code> interface.</dd>
+</dl> <dl>
+ <dt><span id="m-goBack"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/goBack">goBack()</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Go back one page in the history.</dd>
+</dl> <dl>
+ <dt><span id="m-goForward"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/goForward">goForward()</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Go forward one page in the history.</dd>
+</dl> <dl>
+ <dt><span id="m-goHome"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/goHome">goHome()</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Load the user's home page into the browser.</dd>
+</dl> <dl>
+ <dt><span id="m-gotoIndex"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/gotoIndex">gotoIndex( index )</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Navigate to the page in the history with the given index. Use a positive number to go forward and a negative number to go back.</dd>
+</dl> <p><span class="comment">NOTE: This is the XUL method on &lt;browser&gt; / &lt;tabbrowser&gt;, not the global function in <a class="external" rel="freelink">chrome://browser/content/browser.js</a>. Please check which one you're documenting! (This one has no post data parameter, see loadURIWithFlags for a version that does)</span></p>
+<dl>
+ <dt>
+ <span id="m-loadURI"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/loadURI">loadURI( uri, referrer, charset )</a></code></span></dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+ <dd>
+ Load a URL into the document, with the given referrer and character set.</dd>
+ <dd>
+ The first argument should be a string, not a <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIURI" title="">nsIURI</a></code> object. To get a string from an <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIURI" title="">nsIURI</a></code>, use <code>nsIURI.spec</code> or <code>nsIURI.asciiSpec</code></dd>
+</dl> <dl>
+ <dt><span id="m-loadURIWithFlags"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/loadURIWithFlags">loadURIWithFlags( uri, flags, referrer, charset, postData )</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Load a URL into the document, with the specified load flags, the given referrer, character set, and POST data. In addition to the flags allowed for the <span id="m-reloadWithFlags"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/reloadWithFlags">reloadWithFlags</a></code></span> method, the following flags are also valid:
+ <ul>
+ <li><code>LOAD_FLAGS_IS_REFRESH</code>: This flag is used when the URL is loaded because of a meta tag refresh or redirect.</li>
+ <li><code>LOAD_FLAGS_IS_LINK</code>: This flag is used when the URL is loaded because a user clicked on a link. The HTTP Referer header is set accordingly.</li>
+ <li><code>LOAD_FLAGS_BYPASS_HISTORY</code>: Do not add the URL to the session history.</li>
+ <li><code>LOAD_FLAGS_REPLACE_HISTORY</code>: Replace the current URL in the session history with a new one. This flag might be used for a redirect.</li>
+ </ul>
+ </dd>
+</dl>
+
+<p>(See <code><a href="https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIWebNavigation#loadURI()">nsIWebNavigation.loadURI()</a></code> for details on the <code>referrer</code> and <code>postData</code> parameters.)</p> <dl>
+ <dt><span id="m-reload"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/reload">reload()</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Reloads the document in the <code><a href="/en-US/docs/Mozilla/Tech/XUL/browser" title="browser">browser</a></code> element on which you call this method.</dd>
+</dl> <dl>
+ <dt><span id="m-reloadWithFlags"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/reloadWithFlags">reloadWithFlags( flags )</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Reloads the document in the browser with the given load flags. The flags listed below may be used, which are all constants of the <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/webNavigation">webNavigation</a></span></code> property (or the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWebNavigation" title="">nsIWebNavigation</a></code> interface). You may combine flags using a or symbol ( <code>|</code> ).
+ <ul>
+ <li><code>LOAD_FLAGS_NONE</code>: No special flags. The document is loaded normally.</li>
+ <li><code>LOAD_FLAGS_BYPASS_CACHE</code>: Reload the page, ignoring if it is already in the cache. This is the flag used when the reload button is pressed while the Shift key is held down.</li>
+ <li><code>LOAD_FLAGS_BYPASS_PROXY</code>: Reload the page, ignoring the proxy server.</li>
+ <li><code>LOAD_FLAGS_CHARSET_CHANGE</code>: This flag is used if the document needs to be reloaded because the character set changed.</li>
+ </ul>
+ </dd>
+</dl> <dl>
+ <dt><span id="m-removeProgressListener"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/removeProgressListener">removeProgressListener( listener )</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Remove a <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWebProgressListener" title="">nsIWebProgressListener</a></code> from the browser.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-stop"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/stop">stop()</a></code></span></dt>
+ <dd>
+ 返回值: 无返回值</dd>
+ <dd>
+ 效果等同于按下了停止按钮,停止当前页面中文档的加载.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-swapDocShells"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/swapDocShells">swapDocShells( otherBrowser )</a></code></span></dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+ <dd>
+ Swaps the content, history and current state of this <code><a href="/en-US/docs/Mozilla/Tech/XUL/browser" title="browser">browser</a></code> with another browser. During the swap, pagehide and pageshow events are fired on both browsers. This method can be used to move browser between windows or tear off a browser into a new window.</dd>
+</dl>
+
+<div class="note">
+<p><strong>Note:</strong> Both browsers must be either standalone browsers or embedded in a <a href="/en-US/docs/XUL/tabbrowser"><code>tabbrowser</code></a>. You can't mix them.</p></div><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<dl>
+ <dt>
+ Interfaces</dt>
+ <dd>
+ <a href="/en/XPCOM_Interface_Reference/nsIAccessibleProvider" title="en/nsIAccessibleProvider">nsIAccessibleProvider</a></dd>
+</dl>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/button/index.html b/files/zh-cn/mozilla/tech/xul/button/index.html
new file mode 100644
index 0000000000..a3bcf45284
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/button/index.html
@@ -0,0 +1,528 @@
+---
+title: button
+slug: Mozilla/Tech/XUL/button
+tags:
+ - XUL Elements
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/button
+---
+<div class="noinclude"><span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+
+<p>按钮就是可以点击的东西。事件处理程序可以用来捕获鼠标、键盘和其他事件。它通常呈现为一个灰色开始长方形。您可以指定按钮的<code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> 属性来将按钮的文字设置好,或者直接写在标签中间也行。</p>
+
+<p>更多信息请参阅 <a href="cn/XUL_Tutorial/Adding_Buttons">XUL tutorial</a>.</p>
+
+<dl>
+ <dt>Attributes</dt>
+ <dd><a href="#a-accesskey">accesskey</a>, <a href="#a-autocheck">autocheck</a>, <a href="#a-checkState">checkState</a>, <a href="#a-checked">checked</a>, <a href="#a-command">command</a>, <a href="#a-crop">crop</a>, <a href="#a-dir">dir</a>, <a href="#a-disabled">disabled</a>, <a href="#a-dlgtype">dlgtype</a>, <a href="#a-group">group</a>, <a href="#a-icon">icon</a>, <a href="#a-image">image</a>, <a href="#a-label">label</a>, <a href="#a-open">open</a>, <a href="#a-orient">orient</a>, <a href="#a-tabindex">tabindex</a>, <a href="#a-button.type">type</a></dd>
+</dl>
+
+<dl>
+ <dt>Properties</dt>
+ <dd><a href="#p-accessKey">accessKey</a>, <a href="#p-accessibleType">accessibleType</a>, <a href="#p-autoCheck">autoCheck</a>, <a href="#p-checkState">checkState</a>, <a href="#p-checked">checked</a>, <a href="#p-command">command</a>, <a href="#p-crop">crop</a>, <a href="#p-dir">dir</a>, <a href="#p-disabled">disabled</a>, <a href="#p-dlgType">dlgType</a>, <a href="#p-group">group</a>, <a href="#p-image">image</a>, <a href="#p-label">label</a>, <a href="#p-open">open</a>, <a href="#p-orient">orient</a>, <a href="#p-tabIndex">tabIndex</a>, <a href="#p-type">type</a></dd>
+</dl>
+
+<h3 id="Examples" name="Examples">Examples</h3>
+
+<div class="float-right"><img alt="Image:XUL_ref_button.png"></div>
+
+<pre class="eval">&lt;button label="Press Me"
+ oncommand="alert('You pressed me!');"/&gt;
+</pre>
+
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+
+<p> </p><div id="a-accesskey">
+
+
+
+
+<dl>
+ <dt><code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code></dt>
+ <dd>类型:
+ <i>character【字符】</i>
+ </dd>
+ <dd>本属性允许为控件(元素)设定一个字符作为快捷键,这个字符应该是 <code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code> 属性文本中的一个字符。该字符将会被加下划线以重点强调,平台和主体的变换并不影响这一表现行为。 当用户点击 ALT (在其他平台上具有类似功能的键) 和这个字符对应的按键时, 控件(元素)将立刻被从窗口中的某处激活或/并且获得焦点 <b>。虽说字符不分大小写,但是当label中存在大写字符和小写字符时,快捷键的字符将首先选择与之完全匹配的那一个,如果label中存在两个或更多的与accesskey字符相同的字符,其中的第一个字符将被加下划线。</b></dd>
+ <dt>      *(有些键在监听按键事件时,分别对应event.ctrlKey和event.metaKey。)</dt>
+</dl>
+
+<p> </p>
+
+<h4 id="Example" name="Example">Example</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_accesskey_attr.png"></div>
+
+<pre>&lt;vbox&gt;
+ &lt;label value="Enter Name" accesskey="e" control="myName"/&gt;
+ &lt;textbox id="myName"/&gt;
+ &lt;button label="Cancel" accesskey="n"/&gt;
+ &lt;button label="Ok" accesskey="O"/&gt;
+&lt;/vbox&gt;
+</pre>
+
+<h4 id="See_also" name="See_also">See also</h4>
+
+<p><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute, <code id="a-acceltext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/acceltext">acceltext</a></code> attribute</p>
+
+<p></p>
+</div> <div id="a-autoCheck">
+
+
+<dl>
+ <dt><code id="a-autocheck"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/autocheck">autocheck</a></code></dt>
+ <dd>类型:
+ <i>boolean</i>
+ </dd>
+ <dd>如果此属性为 <code>true</code>,或空白, 每次点击按钮时,此按钮的状态检查都会被执行一次。如果此属性为<code>false</code>, 检查会手动的被拒绝。当autocheck值为true的时候,按钮将会变为多选框或者单选框。</dd>
+</dl>
+
+
+
+<p></p>
+</div> <div id="a-checkState">
+
+
+<dl>
+ <dt><code id="a-checkState"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/checkState">checkState</a></code></dt>
+ <dd>Type: <em>integer</em>, values <code>0</code>, <code>1</code>, or <code>2</code></dd>
+ <dd>This attribute may be used to create three state buttons, numbered 0, 1 and 2. When in state 0 or 1, pressing the button will switch to the opposite state. When in state 2, pressing the button will switch to state 0. This means that the button acts like a checkbox except that there is a third state which must be set manually by adjusting the check state. If you wish to have different behavior for how the states are adjusted, set the <code id="a-autoCheck"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/autoCheck">autoCheck</a></code> attribute to <code>false</code> and adjust the state with a script. The <code id="a-type"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/type">type</a></code> attribute must be set to <code>checkbox</code> for buttons with a check state. Constants for the possible values for this attribute are in the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMXULButtonElement" title="">nsIDOMXULButtonElement</a></code> interface.</dd>
+</dl>
+</div> <div id="a-checked">
+
+<dl>
+ <dt>
+ <code id="a-checked"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/checked">checked</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Indicates whether the element is checked or not.</dd>
+ <dd>
+ Use <code>hasAttribute()</code> to determine whether this attribute is set instead of <code>getAttribute()</code>.</dd>
+ <dd>
+ For buttons, the <code>type</code> attribute must be set to <code>checkbox</code> or <code>radio</code> for this attribute to have any effect.&lt;magic name="\"PAGENAME\"/"&gt;&lt;/magic&gt;</dd>
+</dl>
+</div> <div id="a-command">
+
+<dl>
+ <dt>
+ <code id="a-command"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/command">command</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ element id</i>
+ </dd>
+ <dd>
+ Set to the <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> of a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/command" title="command">command</a></code> element that is being observed by the element.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-crop">
+
+<dl>
+ <dt>
+ <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ one of the values below</i>
+ </dd>
+ <dd>
+ If the label of the element is too big to fit in its given space, the text will be cropped on the side specified by the <code>crop</code> attribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.</dd>
+</dl>
+<ul>
+ <li><code>start</code>: The text will be cropped on its left side.</li>
+ <li><code>end</code>: The text will be cropped on its right side.</li>
+ <li><code>left</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its left side.</li>
+ <li><code>right</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its right side.</li>
+ <li><code>center</code>: The text will be cropped in the middle, showing both the start and end of the text normally.</li>
+ <li><code>none</code>: The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.</li>
+</ul>
+
+<p></p>
+</div> <div id="a-dir">
+
+<dl>
+ <dt>
+ <code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ one of the values below</i>
+ </dd>
+ <dd>
+ The direction in which the child elements of the element are placed.</dd>
+</dl>
+<dl>
+ <dt>
+ <code>normal</code></dt>
+ <dd>
+ For scales, the scale's values are ordered from left to right (for horizontal scales) or from top to bottom (for vertical scales)  For other elements, the elements are placed left to right or top to bottom in the order they appear in the XUL code</dd>
+ <dt>
+ <code>reverse</code></dt>
+ <dd>
+ For scales, the scale's values are ordered from right to left (for horizontal scales) or from bottom to top (for vertical scales). For other elements, they are placed right to left or bottom to top. This is reverse of the order in which they appear in the XUL code.</dd>
+</dl>
+<ul>
+</ul>
+
+<p> </p>
+</div> <div id="a-disabled">
+
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd> </dd>
+ <dd>
+ <h5 id="类型boolean">类型:<em>boolean</em></h5>
+ </dd>
+ <dd>
+ <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>
+
+ <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>
+
+ <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
+ </dd>
+</dl>
+
+<h4 id="示例:">示例:</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>
+
+<pre><code>// Disabling an element
+document.getElementById('buttonRemove').setAttribute("disabled", "true");
+
+// Enabling back an element by removing the "disabled" attribute
+document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>
+
+<p></p><div class="blockIndicator standardNote">
+ <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
+ <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
+</div><p></p>
+</div> <div id="a-dlgtype">
+
+
+<dl>
+ <dt><code id="a-dlgtype"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/dlgtype">dlgtype</a></code></dt>
+ <dd>Type: <em>one of the values below</em></dd>
+ <dd>The dialog type of the button, used only when the button is in a dialog box. You can use this feature to replace the standard dialog box buttons with custom buttons, yet the dialog event methods will still function. For example, if the <code>dlgType</code> is set to <code>accept</code>, the button will replace the dialog box's accept button, which is usually labeled <code>OK</code>. Using this attribute on a button that is not in a dialog box has no effect. The following values can be used as the dialog type:</dd>
+ <dd>
+ <dl>
+ <dt><code>accept</code></dt>
+ <dd>The OK button, which will accept the changes when pressed.</dd>
+ <dt><code>cancel</code></dt>
+ <dd>The cancel button which will cancel the operation.</dd>
+ <dt><code>help</code></dt>
+ <dd>A help button for displaying help about the dialog.</dd>
+ <dt><code>disclosure</code></dt>
+ <dd>A button to show more information. This might be a button or a disclosure triangle.</dd>
+ <dt><code>extra1</code></dt>
+ <dd>An optional additional button.</dd>
+ <dt><code>extra2</code></dt>
+ <dd>A second optional additional button.</dd>
+ </dl>
+ </dd>
+</dl>
+</div> <div id="a-group">
+
+
+<dl>
+ <dt><code id="a-group"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/group">group</a></code></dt>
+ <dd>Type: <em>string group name</em> </dd>
+ <dd>Buttons with type="radio" and the same value for their group attribute are put into the same group. Only one button from each group can be checked at a time. If the user selects one the buttons, the others in the group are unchecked.</dd>
+</dl>
+</div> <div id="a-icon">
+
+
+<dl>
+ <dt><code id="a-icon"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/icon">icon</a></code></dt>
+ <dd><strong><span class="highlightgreen">Mozilla 1.8</span></strong></dd>
+ <dd>Type: <em>string</em></dd>
+ <dd>This attribute should be used to set the usage for common buttons. Some platforms display these buttons with a small icon indicating their usage. This should be used in place of the <code id="a-image"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code> attribute. Possible values include: <code>accept</code>, <code>cancel</code>, <code>help</code>, <code>open</code>, <code>save</code>, <code>find</code>, <code>clear</code>, <code>yes</code>, <code>no</code>, <code>apply</code>, <code>close</code>, <code>print</code>, <code>add</code>, <code>remove</code>, <code>refresh</code>, <code>go-forward</code>, <code>go-back</code>, <code>properties</code>, <code>select-font</code>, <code>select-color</code>, <code>network</code>. If you are using a button that matches one of these common usages, use the <code>icon</code> attribute to indicate this. See <a href="/en/XUL/button#pageFiles" title="https://developer.mozilla.org/en/XUL/button#pageFiles">the appearance of the different icons on some available platforms</a>.</dd>
+</dl>
+</div> <div id="a-image">
+
+<dl>
+ <dt>
+ <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ image URL</i>
+ </dd>
+ <dd>
+ The URL of the image to appear on the element. If this attribute is empty or left out, no image appears. The position of the image is determined by the <code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code> and <code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code> attributes.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-label">
+
+<dl>
+ <dt>
+ <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The label that will appear on the element. If this is left out, no text appears.<br>
+ label 在元素上显示。如果左侧出界,则不显示任何文字。</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-open">
+
+
+<dl>
+ <dt><code id="a-open"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/open">open</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>For the <code>menu</code> <code id="a-type"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/type">type</a></code> buttons, the <code>open</code> attribute is set to <code>true</code> when the menu is open. The <code>open</code> attribute is not present if the menu is closed.</dd>
+</dl>
+</div> <div id="a-orient">
+<p><strong>布局(orient)</strong></p>
+<dl>
+ <dd>
+ 值类型:可以是下面值中的一种。<br>
+ 指定了子控件的布局(orient)为水平分布的(horizontally)或者是垂直分布的(vertically)。默认值依赖于控件本身。你也可以使用<a href="cn/-moz-box-orient">-moz-box-orient</a>中的样式属性。
+ <ul>
+ <li><strong>horizontally</strong>: 子控件会被按照在xul源文件中出现的位置依次布置在一行中。</li>
+ <li><strong>vertically</strong>: 子控件会被按照在xul源文件中出现的位置依次布置在一列中。</li>
+ </ul>
+ </dd>
+</dl>
+</div> <div id="a-tabindex">
+
+
+<dl>
+ <dt><code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code></dt>
+ <dd>Type:<em>integer</em></dd>
+ <dd>当用户按下 "<kbd>tab</kbd>" 键时焦点移动到元素上的顺序。<code>tabindex</code> 数字越大,顺序越靠后。</dd>
+</dl>
+
+
+
+<p></p>
+</div> <div id="a-button.type">
+
+
+<dl>
+ <dt><code id="a-button.type"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/button.type">type</a></code></dt>
+ <dd>Type: <em>one of the values below</em></dd>
+ <dd>The type of button. If this attribute is not present, a normal button is created. Leave the attribute out for a normal button.</dd>
+ <dd>
+ <dl>
+ <dt><code>checkbox</code></dt>
+ <dd>This type of button can be in two states. The user can click the button to switch between the states. This is not the same as a checkbox because it looks like a button.</dd>
+ <dt><code>menu</code></dt>
+ <dd>Set the <code>type</code> attribute to the value <code>menu</code> to create a button with a menu popup. Place a <code><a href="/en-US/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code> element inside the button in this case. The user may click anywhere on the button to open and close the menu.</dd>
+ <dt><code>menu-button</code></dt>
+ <dd>You can also use the value <code>menu-button</code> to create a button with a menu. Unlike the <code>menu</code> type, this type requires the user to press the arrow to open the menu, but a different command may be invoked when the main part of the button is pressed.</dd>
+ <dt><code>panel</code></dt>
+ <dd>Similar to the <code>menu</code> type, this opens a popup. Place a <code><a href="/en-US/docs/Mozilla/Tech/XUL/panel" title="panel">panel</a></code> element inside the button. <code><a href="/en-US/docs/Mozilla/Tech/XUL/panel" title="panel">panel</a></code> elements are popups that support any type of content.</dd>
+ <dt><code>radio</code></dt>
+ <dd>The button acts like a radio button. Only one button in the group can be on a once.</dd>
+ <dt><code>repeat</code></dt>
+ <dd>This button will fire its command event repeatedly while the mouse button is held down. </dd>
+ </dl>
+ </dd>
+</dl>
+</div><p></p>
+
+<h3 id="Properties" name="Properties">Properties</h3>
+
+<p> </p><div id="p-accessKey">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessKey">accessKey</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ character</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-autoCheck">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/autoCheck">autoCheck</a></span></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>Gets and sets the value of the <code id="a-autoCheck"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/autoCheck">autoCheck</a></code> attribute.</dd>
+</dl></div> <div id="p-checkState">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/checkState">checkState</a></span></code></dt>
+ <dd>
+ Type: <em>integer</em>, values <code>0</code>, <code>1</code>, or <code>2</code></dd>
+ <dd>
+ Gets and sets the value of the <code id="a-checkState"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/checkState">checkState</a></code> attribute.</dd>
+</dl></div> <div id="p-checked">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/checked">checked</a></span></code></dt>
+ <dd>
+ Type: <em>boolean</em></dd>
+ <dd>
+ Gets and sets the value of the <code id="a-checked"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/checked">checked</a></code> attribute.</dd>
+</dl></div> <div id="p-command">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/command">command</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ element id</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-command"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/command">command</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-crop">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/crop">crop</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-dir">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/dir">dir</a></span></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ Gets and sets the value of the <code id="a-dir"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code> attribute.</dd>
+</dl></div> <div id="p-disabled">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/disabled">disabled</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-dlgType">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/dlgType">dlgType</a></span></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>Gets and sets the value of the <code id="a-dlgType"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/dlgType">dlgType</a></code> attribute.</dd>
+</dl></div> <div id="p-group">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/group">group</a></span></code></dt>
+ <dd>Type: <em>string group name</em></dd>
+ <dd>Gets and sets the value of the <code id="a-group"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/group">group</a></code> attribute.</dd>
+</dl></div> <div id="p-image">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/image">image</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ image URL</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-label">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/label">label</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-open">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/open">open</a></span></code></dt>
+ <dd>
+ Type: <em>boolean</em></dd>
+ <dd>
+ Gets and sets the value of the <code id="a-open"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/open">open</a></code> attribute.</dd>
+</dl>
+</div> <div id="p-orient">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/orient">orient</a></span></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ Gets and sets the value of the <code id="a-orient"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code> attribute.</dd>
+</dl></div> <div id="p-tabIndex">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tabIndex">tabIndex</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-type">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/type">type</a></span></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ Gets and sets the value of the <code id="a-type"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/type">type</a></code> attribute.</dd>
+</dl>
+</div><p></p>
+
+<h3 id="Methods" name="Methods">Methods</h3>
+
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+
+<h3 id="Related" name="Related">Related</h3>
+
+<dl>
+ <dt>Interfaces</dt>
+ <dd><a href="cn/NsIAccessibleProvider">nsIAccessibleProvider</a>, <a href="cn/NsIDOMXULButtonElement">nsIDOMXULButtonElement</a></dd>
+</dl>
+
+<div class="noinclude"> </div>
+
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/checkbox/index.html b/files/zh-cn/mozilla/tech/xul/checkbox/index.html
new file mode 100644
index 0000000000..ea2eef19ba
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/checkbox/index.html
@@ -0,0 +1,329 @@
+---
+title: checkbox
+slug: Mozilla/Tech/XUL/checkbox
+tags:
+ - 中文
+translation_of: Archive/Mozilla/XUL/checkbox
+---
+<div class="noinclude"><span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+
+<p>An element that can be turned on and off. This is most commonly rendered as a box when the element is off and a box with a check when the element is on. The user can switch the state of the check box by selecting it with the mouse. A label, specified with the <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute, may be added beside the check box.</p>
+
+<p>More information is available in the <a href="/en/XUL_Tutorial/Input_Controls" title="en/XUL_Tutorial/Input_Controls">XUL tutorial</a>.</p>
+
+<dl>
+ <dt>Attributes</dt>
+ <dd><a href="#a-accesskey">accesskey</a>, <a href="#a-checked">checked</a>, <a href="#a-command">command</a>, <a href="#a-crop">crop</a>, <a href="#a-disabled">disabled</a>, <a href="#a-checkbox.src">src</a>, <a href="#a-label">label</a>, <a href="#a-preference">preference</a>, <a href="#a-tabindex">tabindex</a></dd>
+</dl>
+
+<dl>
+ <dt>Properties</dt>
+ <dd><a href="#p-accessKey">accessKey</a>, <a href="#p-accessibleType">accessibleType</a>, <a href="#p-checked">checked</a>, <a href="#p-command">command</a>, <a href="#p-crop">crop</a>, <a href="#p-disabled">disabled</a>, <a href="#p-src">src</a>, <a href="#p-label">label</a>, <a href="#p-tabIndex">tabIndex</a></dd>
+</dl>
+
+<h3 id="Examples" name="Examples">Examples</h3>
+
+<div class="float-right"><img alt="Image:XUL_ref_checkbox.png" class="internal" src="/@api/deki/files/451/=XUL_ref_checkbox.png"></div>
+
+<pre class="eval">&lt;checkbox label="Enable JavaScript" checked="true"/&gt;
+&lt;checkbox label="Enable Java" checked="false"/&gt;
+</pre>
+
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+
+<p></p>
+
+<p></p><div id="a-accesskey">
+
+
+
+
+<dl>
+ <dt><code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code></dt>
+ <dd>类型:
+ <i>character【字符】</i>
+ </dd>
+ <dd>本属性允许为控件(元素)设定一个字符作为快捷键,这个字符应该是 <code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code> 属性文本中的一个字符。该字符将会被加下划线以重点强调,平台和主体的变换并不影响这一表现行为。 当用户点击 ALT (在其他平台上具有类似功能的键) 和这个字符对应的按键时, 控件(元素)将立刻被从窗口中的某处激活或/并且获得焦点 <b>。虽说字符不分大小写,但是当label中存在大写字符和小写字符时,快捷键的字符将首先选择与之完全匹配的那一个,如果label中存在两个或更多的与accesskey字符相同的字符,其中的第一个字符将被加下划线。</b></dd>
+ <dt>      *(有些键在监听按键事件时,分别对应event.ctrlKey和event.metaKey。)</dt>
+</dl>
+
+<p> </p>
+
+<h4 id="Example" name="Example">Example</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_accesskey_attr.png"></div>
+
+<pre>&lt;vbox&gt;
+ &lt;label value="Enter Name" accesskey="e" control="myName"/&gt;
+ &lt;textbox id="myName"/&gt;
+ &lt;button label="Cancel" accesskey="n"/&gt;
+ &lt;button label="Ok" accesskey="O"/&gt;
+&lt;/vbox&gt;
+</pre>
+
+<h4 id="See_also" name="See_also">See also</h4>
+
+<p><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute, <code id="a-acceltext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/acceltext">acceltext</a></code> attribute</p>
+
+<p></p>
+</div> <div id="a-checked">
+
+<dl>
+ <dt>
+ <code id="a-checked"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/checked">checked</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Indicates whether the element is checked or not.</dd>
+ <dd>
+ Use <code>hasAttribute()</code> to determine whether this attribute is set instead of <code>getAttribute()</code>.</dd>
+ <dd>
+ For buttons, the <code>type</code> attribute must be set to <code>checkbox</code> or <code>radio</code> for this attribute to have any effect.&lt;magic name="\"PAGENAME\"/"&gt;&lt;/magic&gt;</dd>
+</dl>
+</div> <div id="a-command">
+
+<dl>
+ <dt>
+ <code id="a-command"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/command">command</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ element id</i>
+ </dd>
+ <dd>
+ Set to the <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> of a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/command" title="command">command</a></code> element that is being observed by the element.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-crop">
+
+<dl>
+ <dt>
+ <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ one of the values below</i>
+ </dd>
+ <dd>
+ If the label of the element is too big to fit in its given space, the text will be cropped on the side specified by the <code>crop</code> attribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.</dd>
+</dl>
+<ul>
+ <li><code>start</code>: The text will be cropped on its left side.</li>
+ <li><code>end</code>: The text will be cropped on its right side.</li>
+ <li><code>left</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its left side.</li>
+ <li><code>right</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its right side.</li>
+ <li><code>center</code>: The text will be cropped in the middle, showing both the start and end of the text normally.</li>
+ <li><code>none</code>: The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.</li>
+</ul>
+
+<p></p>
+</div> <div id="a-disabled">
+
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd> </dd>
+ <dd>
+ <h5 id="类型boolean">类型:<em>boolean</em></h5>
+ </dd>
+ <dd>
+ <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>
+
+ <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>
+
+ <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
+ </dd>
+</dl>
+
+<h4 id="示例:">示例:</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>
+
+<pre><code>// Disabling an element
+document.getElementById('buttonRemove').setAttribute("disabled", "true");
+
+// Enabling back an element by removing the "disabled" attribute
+document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>
+
+<p></p><div class="blockIndicator standardNote">
+ <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
+ <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
+</div><p></p>
+</div> <div id="a-checkbox.src">
+
+
+<dl>
+ <dt><code id="a-checkbox.src"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/checkbox.src">src</a></code></dt>
+ <dd>Type: <em>URI</em></dd>
+ <dd>Set this to an URI pointing to an image to appear in the checkbox. If this attribute is left out, no image appears. You can have both an image and a label.</dd>
+</dl>
+
+
+</div> <div id="a-label">
+
+<dl>
+ <dt>
+ <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The label that will appear on the element. If this is left out, no text appears.<br>
+ label 在元素上显示。如果左侧出界,则不显示任何文字。</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-preference">
+
+
+<dl>
+ <dt><code id="a-preference"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/preference">preference</a></code></dt>
+ <dd>Type: <em>id</em></dd>
+ <dd>Connects the element to a corresponding <code><a href="/en-US/docs/Mozilla/Tech/XUL/preference" title="preference">preference</a></code>. This attribute only has any effect when used inside a <code><a href="/en-US/docs/Mozilla/Tech/XUL/prefwindow" title="prefwindow">prefwindow</a></code>. More information is available in the <a href="../../../../en/Preferences_System" rel="internal">Preferences System</a> article.</dd>
+</dl>
+</div> <div id="a-tabindex">
+
+
+<dl>
+ <dt><code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code></dt>
+ <dd>Type:<em>integer</em></dd>
+ <dd>当用户按下 "<kbd>tab</kbd>" 键时焦点移动到元素上的顺序。<code>tabindex</code> 数字越大,顺序越靠后。</dd>
+</dl>
+
+
+
+<p></p>
+</div><p></p>
+
+<h3 id="Properties" name="Properties">Properties</h3>
+
+<p></p>
+
+<p></p><div id="p-accessKey">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessKey">accessKey</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ character</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-checked">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/checked">checked</a></span></code></dt>
+ <dd>
+ Type: <em>boolean</em></dd>
+ <dd>
+ Gets and sets the value of the <code id="a-checked"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/checked">checked</a></code> attribute.</dd>
+</dl></div> <div id="p-command">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/command">command</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ element id</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-command"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/command">command</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-crop">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/crop">crop</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-disabled">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/disabled">disabled</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-src">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/src">src</a></span></code></dt>
+ <dd>Type: <em>URL</em></dd>
+ <dd>Gets and sets the value of the <code id="a-src"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/src">src</a></code> attribute.</dd>
+</dl></div> <div id="p-label">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/label">label</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-tabIndex">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tabIndex">tabIndex</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code> attribute.</dd>
+</dl>
+
+<p></p></div><p></p>
+
+<h3 id="Methods" name="Methods">Methods</h3>
+
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+
+<h3 id="Related" name="Related">Related</h3>
+
+<dl>
+ <dt>Interfaces</dt>
+ <dd><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIAccessibleProvider" title="">nsIAccessibleProvider</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMXULCheckboxElement" title="">nsIDOMXULCheckboxElement</a></code></dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/command/index.html b/files/zh-cn/mozilla/tech/xul/command/index.html
new file mode 100644
index 0000000000..7a9a8916f9
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/command/index.html
@@ -0,0 +1,105 @@
+---
+title: command
+slug: Mozilla/Tech/XUL/command
+tags:
+ - XUL Elements
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/command
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span><br>
+ <code>command </code>元素响应不同来源的、对于同一操作的操作请求。比如,剪贴板的粘贴操作,可以来自 “编辑”菜单,可以来自鼠标右键的上下文菜单,也可以来自键盘快捷键。你可以通过 command 的 <code id="a-oncommand"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/oncommand">oncommand</a></code> 属性调用代码。对于用户来说,从什么地方触发了这个操作并不重要。另外,关闭 command 将自动关闭菜单中的项目和对键盘快捷键的响应。</div>
+<p>Commands are identified by their <code><code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code></code>. If you include the script <code><a class="external" rel="freelink">chrome://global/content/globalOverlay.js</a></code> in your window, you can use the function <code>goDoCommand</code> function to invoke the command. Using this function has the advantage that the command will be sent to the part of the UI which will respond to it. Typically, this will be the currently focused element.</p>
+<p>Like a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/broadcaster" title="broadcaster">broadcaster</a></code>, commands forward attributes to other elements.</p>
+<p>More information is available in the <a href="/cn/XUL_Tutorial/Commands" title="cn/XUL_Tutorial/Commands">XUL tutorial</a>. See also: <code id="a-command"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/command">command</a></code> attribute, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/commandset" title="commandset">commandset</a></code> element</p>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-disabled">disabled</a>, <a href="#a-label">label</a>, <a href="#a-oncommand">oncommand</a></dd>
+</dl>
+<h3 id="Examples" name="Examples">Examples</h3>
+<p>The following code will send a paste command (<code>cmd_paste</code>) to the currently focused element:</p>
+<pre class="eval"> // First include <a class="external" rel="freelink">chrome://global/content/globalOverlay.js</a>
+ goDoCommand("cmd_paste");
+</pre>
+<p>Example with two buttons</p>
+<pre>&lt;command id="cmd_openhelp" oncommand="alert('Help');"/&gt;
+&lt;button label="Help" command="cmd_openhelp"/&gt;
+&lt;button label="More Help" command="cmd_openhelp"/&gt;
+</pre>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p> </p><div id="a-disabled">
+
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd> </dd>
+ <dd>
+ <h5 id="类型boolean">类型:<em>boolean</em></h5>
+ </dd>
+ <dd>
+ <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>
+
+ <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>
+
+ <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
+ </dd>
+</dl>
+
+<h4 id="示例:">示例:</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>
+
+<pre><code>// Disabling an element
+document.getElementById('buttonRemove').setAttribute("disabled", "true");
+
+// Enabling back an element by removing the "disabled" attribute
+document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>
+
+<p></p><div class="blockIndicator standardNote standardNoteBlock">
+ <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
+ <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
+</div><p></p>
+</div> <div id="a-label">
+
+<dl>
+ <dt>
+ <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The label that will appear on the element. If this is left out, no text appears.<br>
+ label 在元素上显示。如果左侧出界,则不显示任何文字。</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-oncommand">
+
+
+<dl>
+ <dt><code id="a-oncommand"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/oncommand">oncommand</a></code></dt>
+ <dd>Type: <em>script code</em></dd>
+ <dd>This event handler is called when the command is activated. This occurs when a user selects a menu item or presses a keyboard shortcut attached to the command.</dd>
+</dl>
+
+
+</div><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited Properties</strong><br> <small> <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/align">align</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/allowEvents">allowEvents</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/boxObject">boxObject</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/builder">builder</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/className">className</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/collapsed">collapsed</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/contextMenu">contextMenu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/controllers">controllers</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/database">database</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/datasources">datasources</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/dir">dir</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/flex">flex</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/height">height</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/hidden">hidden</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/id">id</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/left">left</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxHeight">maxHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxWidth">maxWidth</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menu">menu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minHeight">minHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minWidth">minWidth</a></span></code>, , , , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/observes">observes</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ordinal">ordinal</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/orient">orient</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/pack">pack</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/persist">persist</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ref">ref</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/resource">resource</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/statusText">statusText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/style">style</a></span></code>, ,, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltip">tooltip</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltipText">tooltipText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/top">top</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/width">width</a></span></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<ul>
+ <li><a href="/cn/XUL/List_of_commands" title="cn/XUL/List_of_commands">XUL:List of commands</a></li>
+</ul>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/deprecated_defunct_markup/index.html b/files/zh-cn/mozilla/tech/xul/deprecated_defunct_markup/index.html
new file mode 100644
index 0000000000..6ae3102b4f
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/deprecated_defunct_markup/index.html
@@ -0,0 +1,50 @@
+---
+title: Deprecated/Defunct Markup
+slug: Mozilla/Tech/XUL/Deprecated_Defunct_Markup
+translation_of: Archive/Mozilla/XUL/Deprecated_and_defunct_markup
+---
+<p>The following XUL tags and attribute should be considered deprecated, if not defunct.</p>
+<p>The list below may include a few elements which are actually in use, but at a deeper level in the code. Even some of the information on the tags below may be out of date, but is provided here for historical reference and to help anyone who comes across them in old code or documentation.</p>
+<h3 id="Elements" name="Elements">Elements</h3>
+<ul>
+ <li>&lt;actions&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (listed <a class="external" href="http://www.ar-ent.net/dar/arlib32/out/html/man/xul/elemref/mxdref.html">here</a> (by mistake or was it a container tag?)</li>
+ <li>&lt;autorepeatbutton&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (action occurs repeatedly on mouse hover--used to construct other elements; used in &lt;arrowscrollbox&gt; and large drop-down menus)</li>
+ <li>&lt;bulletinboard&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (made to support left/top styles, but &lt;stack&gt; can now do as well)</li>
+ <li>&lt;gripper&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (inside of &lt;scrollbar&gt;&lt;thumb&gt;; not to be used by itself)</li>
+ <li>&lt;listboxbody&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (internal use only; part of XBL for &lt;listbox&gt;)</li>
+ <li>&lt;menubutton&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (experiment in combining buttons and menus; use &lt;button type&gt; instead)</li>
+ <li>&lt;nativescrollbar&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (displayed a native scrollbar; had been for Mac only with native themes on)</li>
+ <li>&lt;outliner&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (former name for &lt;tree&gt;; &lt;listbox&gt; had been "&lt;tree&gt;")</li>
+ <li>&lt;package&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (no longer present but in older documentation)</li>
+ <li>&lt;scrollbarbutton&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (button at end of scrollbar; had been only within larger &lt;scrollbar&gt;)</li>
+ <li>&lt;sidebarheader&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span></li>
+ <li>&lt;slider&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (clickable tray in &lt;scrollbar&gt; which holds &lt;thumb&gt;; do not use alone)</li>
+ <li>&lt;spinner&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (spinbox; &lt;spinbuttons&gt; with a textbox whereby spinning affects value in textbox; not usable)</li>
+ <li>&lt;spring&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (use @flex instead)</li>
+ <li>&lt;strut&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (replaced by @debug?)</li>
+ <li>&lt;tabcontrol&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (contained tabbox and tabpanel)</li>
+ <li>&lt;text&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (like &lt;label&gt; or &lt;description&gt; but does not wrap; like &lt;label crop="end"&gt;; had been used in menus/toolbars)</li>
+ <li>&lt;textfield&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (like &lt;textbox&gt;)</li>
+ <li>&lt;thumb&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (&lt;button&gt; with deprecated &lt;gripper&gt;; implements sliding box in center of scrolbar)</li>
+ <li>&lt;title&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (to add a caption on a &lt;titledbox&gt;</li>
+ <li>&lt;titledbox&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (box with a frame)</li>
+ <li>&lt;titledbutton&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (attempt to combine text and images before &lt;button&gt;)</li>
+ <li>&lt;toolbarpaletteitem&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span></li>
+ <li>&lt;treebody&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (old/experimental and unsupported XUL tags)</li>
+ <li>&lt;treecaption&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (old/experimental and unsupported XUL tags)</li>
+ <li>&lt;treecolgroup&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (former name for &lt;treecols&gt;</li>
+ <li>&lt;treecolpicker&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (internal use only; part of XBL for &lt;tree&gt;)</li>
+ <li>&lt;treefoot&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (old/experimental and unsupported XUL tags)</li>
+ <li>&lt;treeindentation&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (old/experimental and unsupported XUL tags)</li>
+ <li>&lt;treeicon&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (old/experimental and unsupported XUL tags)</li>
+ <li>&lt;treerows&gt; <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> (internal use only; part of XBL for &lt;tree&gt;)</li>
+</ul>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<ul>
+ <li>@debug="true" <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> provided struts and springs around boxes to facilitate identification of flex issues but does not seem to work now</li>
+</ul>
+<h3 id="References" name="References">References</h3>
+<ul>
+ <li><a class="external" href="http://www.ar-ent.net/dar/arlib32/out/html/man/xul/elemref/mxdref.html">XUL Element Reference</a> by Neal Deakin</li>
+ <li>Rapid Application Development With Mozilla, by Nigel McFarlane</li>
+</ul>
diff --git a/files/zh-cn/mozilla/tech/xul/dialog/index.html b/files/zh-cn/mozilla/tech/xul/dialog/index.html
new file mode 100644
index 0000000000..b4e3680bf3
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/dialog/index.html
@@ -0,0 +1,364 @@
+---
+title: dialog
+slug: Mozilla/Tech/XUL/dialog
+translation_of: Archive/Mozilla/XUL/dialog
+---
+<div class="noinclude"><span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>在 <a href="/zh-cn/XUL/window" title="zh-cn/XUL/window">window</a> 元素调用对话框时应使用此元素。<code id="a-buttons"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/buttons">buttons</a></code> 属性可以用于设置哪些按钮应该出现在对话框中。这些按钮将被放置在用户平台指定的位置。</p>
+<p>更多有用信息可以查看 <a href="/en/XUL_Tutorial/Creating_Dialogs" title="en/XUL_Tutorial/Creating_Dialogs">XUL tutorial</a> 和 <a href="/en/Code_snippets/Dialogs_and_Prompts" title="en/Code_snippets/Dialogs_and_Prompts">Dialogs and prompts</a> (代码片段)。</p>
+<dl> <dt>属性</dt> <dd><a href="#a-buttonaccesskeyaccept">buttonaccesskeyaccept</a>, <a href="#a-buttonaccesskeycancel">buttonaccesskeycancel</a>, <a href="#a-buttonaccesskeydisclosure">buttonaccesskeydisclosure</a>, <a href="#a-buttonaccesskeyextra1">buttonaccesskeyextra1</a>, <a href="#a-buttonaccesskeyextra2">buttonaccesskeyextra2</a>, <a href="#a-buttonaccesskeyhelp">buttonaccesskeyhelp</a>, <a href="#a-buttonalign">buttonalign</a>, <a href="#a-buttondir">buttondir</a>, <a href="#a-buttondisabledaccept">buttondisabledaccept</a>, <a href="#a-buttonlabelaccept">buttonlabelaccept</a>, <a href="#a-buttonlabelcancel">buttonlabelcancel</a>, <a href="#a-buttonlabeldisclosure">buttonlabeldisclosure</a>, <a href="#a-buttonlabelextra1">buttonlabelextra1</a>, <a href="#a-buttonlabelextra2">buttonlabelextra2</a>, <a href="#a-buttonlabelhelp">buttonlabelhelp</a>, <a href="#a-buttonorient">buttonorient</a>, <a href="#a-buttonpack">buttonpack</a>, <a href="#a-buttons">buttons</a>, <a href="#a-defaultButton">defaultButton</a>, <a href="#a-ondialogaccept">ondialogaccept</a>, <a href="#a-ondialogcancel">ondialogcancel</a>, <a href="#a-ondialogdisclosure">ondialogdisclosure</a>, <a href="#a-ondialogextra1">ondialogextra1</a>, <a href="#a-ondialogextra2">ondialogextra2</a>, <a href="#a-ondialoghelp">ondialoghelp</a>, <a href="#a-title">title</a></dd>
+</dl>
+<dl> <dt>特性</dt> <dd><a href="#p-buttons">buttons</a>, <a href="#p-defaultButton">defaultButton</a></dd>
+</dl>
+<dl> <dt>方法</dt> <dd><a href="#m-acceptDialog">acceptDialog</a>, <a href="#m-cancelDialog">cancelDialog</a>, <a href="#m-centerWindowOnScreen">centerWindowOnScreen</a>, <a href="#m-getButton">getButton</a>, <a href="#m-moveToAlertPosition">moveToAlertPosition</a></dd>
+</dl>
+<h3 id="Examples" name="Examples">示例</h3>
+<div class="float-right"><img alt="Image:XUL_ref_dialog.png" class="internal" src="/@api/deki/files/453/=XUL_ref_dialog.png"></div>
+<pre>&lt;?xml version="1.0"?&gt;
+&lt;?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?&gt;
+&lt;dialog id="donothing" title="Dialog example"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ buttons="accept,cancel"
+ buttonlabelcancel="Cancel"
+ buttonlabelaccept="Save"
+ ondialogaccept="return doOK();"
+ ondialogcancel="return doCancel();"&gt;
+
+ &lt;dialogheader title="Options" description="My preferences"/&gt;
+ &lt;groupbox&gt;
+ &lt;caption label="Colour"/&gt;
+ &lt;radiogroup&gt;
+ &lt;radio label="Red"/&gt;
+ &lt;radio label="Green" selected="true"/&gt;
+ &lt;radio label="Blue"/&gt;
+ &lt;/radiogroup&gt;
+ &lt;label value="Nickname"/&gt;
+ &lt;textbox /&gt;
+ &lt;/groupbox&gt;
+&lt;/dialog&gt;
+</pre>
+<h3 id="Attributes" name="Attributes">属性</h3>
+<p> </p><div id="a-activetitlebarcolor">
+
+<dl>
+ <dt>
+ <code id="a-activetitlebarcolor"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/activetitlebarcolor">activetitlebarcolor</a></code> </dt>
+ <dd>
+ Type: <em>color string</em></dd>
+ <dd>
+ Specify background color of the window's titlebar when it is active (foreground). Moreover this hides separator between titlebar and window contents. <em>This only affects Mac OS X.</em></dd>
+</dl>
+
+<p> </p>
+</div> <div id="a-buttonaccesskeyaccept">
+
+<dl>
+ <dt>
+ <code id="a-buttonaccesskeyaccept"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/buttonaccesskeyaccept">buttonaccesskeyaccept</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The access key to use for the "accept" button.</dd>
+</dl>
+<p> </p>
+
+<p> </p>
+</div> <div id="a-buttonaccesskeycancel">
+
+<dl>
+ <dt>
+ <code id="a-buttonaccesskeycancel"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/buttonaccesskeycancel">buttonaccesskeycancel</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The access key to use for the "cancel" button.</dd>
+</dl>
+</div> <div id="a-buttonaccesskeydisclosure">
+
+<dl>
+ <dt>
+ <code id="a-buttonaccesskeydisclosure"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/buttonaccesskeydisclosure">buttonaccesskeydisclosure</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The access key to use for the "disclosure" button.</dd>
+</dl>
+</div> <div id="a-buttonaccesskeyextra1">
+
+<dl>
+ <dt>
+ <code id="a-buttonaccesskeyextra1"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/buttonaccesskeyextra1">buttonaccesskeyextra1</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The access key to use for the first extra button.</dd>
+</dl>
+</div> <div id="a-buttonaccesskeyextra2">
+
+
+<dl>
+ <dt><code id="a-buttonaccesskeyextra2"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/buttonaccesskeyextra2">buttonaccesskeyextra2</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>The access key to use for the second extra button.</dd>
+</dl>
+</div> <div id="a-buttonaccesskeyhelp">
+
+<dl>
+ <dt>
+ <code id="a-buttonaccesskeyhelp"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/buttonaccesskeyhelp">buttonaccesskeyhelp</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The access key to use for the "help" button.</dd>
+</dl>
+</div> <div id="a-buttonalign">
+
+<dl>
+ <dt>
+ <code id="a-buttonalign"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/buttonalign">buttonalign</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The value of the <code id="a-align"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/align">align</a></code> attribute for the box containing the buttons.</dd>
+</dl>
+</div> <div id="a-buttondir">
+
+
+<dl>
+ <dt><code id="a-buttondir"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/buttondir">buttondir</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>The value of the <code id="a-dir"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code> attribute for the box containing the buttons.</dd>
+</dl>
+</div> <div id="a-buttondisabledaccept">
+
+
+<dl>
+ <dt><code id="a-buttondisabledaccept"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/buttondisabledaccept">buttondisabledaccept</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>If <code>true</code>, the accept button is disabled.</dd>
+</dl>
+</div> <div id="a-buttonlabelaccept">
+
+
+<dl>
+ <dt><code id="a-buttonlabelaccept"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/buttonlabelaccept">buttonlabelaccept</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>The label to appear on the "accept" button.</dd>
+</dl>
+</div> <div id="a-buttonlabelcancel">
+
+
+<dl>
+ <dt><code id="a-buttonlabelcancel"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/buttonlabelcancel">buttonlabelcancel</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>The label to appear on the "cancel" button.</dd>
+</dl>
+</div> <div id="a-buttonlabeldisclosure">
+
+
+<dl>
+ <dt><code id="a-buttonlabeldisclosure"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/buttonlabeldisclosure">buttonlabeldisclosure</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>The label to appear on the "disclosure" button.</dd>
+</dl>
+</div> <div id="a-buttonlabelextra1">
+
+<dl>
+ <dt>
+ <code id="a-buttonlabelextra1"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/buttonlabelextra1">buttonlabelextra1</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The label to appear on the first extra button.</dd>
+</dl>
+
+<p> </p>
+</div> <div id="a-buttonlabelextra2">
+
+<dl>
+ <dt>
+ <code id="a-buttonlabelextra2"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/buttonlabelextra2">buttonlabelextra2</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The label to appear on the second extra button.</dd>
+</dl>
+
+<p> </p>
+</div> <div id="a-buttonlabelhelp">
+
+
+<dl>
+ <dt><code id="a-buttonlabelhelp"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/buttonlabelhelp">buttonlabelhelp</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>The label to appear on the "help" button.</dd>
+</dl>
+</div> <div id="a-buttonorient">
+
+
+<dl>
+ <dt><code id="a-buttonorient"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/buttonorient">buttonorient</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>The value of the <code id="a-orient"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code> attribute for the box containing the buttons.</dd>
+</dl>
+</div> <div id="a-buttonpack">
+
+
+<dl>
+ <dt><code id="a-buttonpack"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/buttonpack">buttonpack</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>The value of the <code id="a-pack"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/pack">pack</a></code> attribute for the box containing the buttons.</dd>
+</dl>
+</div> <div id="a-buttons">
+
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/buttons">buttons</a></span></code></dt>
+ <dd>
+ 类型: 列表,下面的值用逗号分隔</dd>
+ <dd>
+ 需要显示在对话框上的按钮的一个列表,使用逗号分隔。将按钮放置在合适的位置,将根据用户平台自动执行基本的事件处理。在列表中可以使用以下值:
+ <ul>
+ <li><code>accept</code>:“确定”按钮,按下按钮时将接受更改。此按钮为默认按钮。</li>
+ <li><code>cancel</code>:“取消”按钮,将取消操作。</li>
+ <li><code>help</code>:“帮助”按钮,在对话框显示一个“帮助”按钮。</li>
+ <li><code>disclosure</code>:“更多信息”按钮,显示一个“more info”按钮。该按钮可能是一个按钮或一个三角形。</li>
+ <li><code>extra1</code>:一个可选的额外的按钮。你可以通过<code><code id="a-buttonlabelextra1"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/buttonlabelextra1">buttonlabelextra1</a></code></code> 属性设置它的label。</li>
+ <li><code>extra2</code>:第二个可选的额外的按钮。你可以通过 <code><code id="a-buttonlabelextra2"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/buttonlabelextra2">buttonlabelextra2</a></code></code> 属性设置它的label。</li>
+ </ul>
+ </dd>
+</dl>
+
+<p> </p>
+</div> <div id="a-defaultButton">
+
+
+<dl>
+ <dt><code id="a-defaultButton"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/defaultButton">defaultButton</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>Normally this attribute should not be set, but if it is, it specifies the default button in the dialog. Typically, this means that the button will be activated when the Enter key is pressed. This should be set to one of the same values as those for the <code id="a-buttons"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/buttons">buttons</a></code> attribute.</dd>
+</dl>
+</div> <div id="a-inactivetitlebarcolor">
+
+
+<dl>
+ <dt><code id="a-inactivetitlebarcolor"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/inactivetitlebarcolor">inactivetitlebarcolor</a></code> </dt>
+ <dd>Type: <em>color string</em></dd>
+ <dd>Specify background color of the window's titlebar when it is inactive (background). Moreover this hides separator between titlebar and window contents. <em>This affects only on Mac OS X.</em></dd>
+</dl>
+</div> <div id="a-ondialogaccept">
+
+
+<dl>
+ <dt><code id="a-ondialogaccept"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/ondialogaccept">ondialogaccept</a></code></dt>
+ <dd>Type: <em>script code</em></dd>
+ <dd>The code in this attribute is called when the accept button is pressed, or when the <span id="m-acceptDialog"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/acceptDialog">acceptDialog</a></code></span> method is called. If the handler returns <code>true</code>, the dialog will indeed go away, but if it returns <code>false</code> it will not.</dd>
+</dl>
+</div> <div id="a-ondialogcancel">
+
+
+<dl>
+ <dt><code id="a-ondialogcancel"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/ondialogcancel">ondialogcancel</a></code></dt>
+ <dd>Type: <em>script code</em></dd>
+ <dd>The code in this attribute is called when the "cancel" button is pressed or when the <span id="m-cancelDialog"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/cancelDialog">cancelDialog</a></code></span> method is called. If the routine returns true, the dialog will indeed go away, but if it returns false it will not.</dd>
+</dl>
+</div> <div id="a-ondialogdisclosure">
+
+
+<dl>
+ <dt><code id="a-ondialogdisclosure"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/ondialogdisclosure">ondialogdisclosure</a></code></dt>
+ <dd>Type: <em>script code</em></dd>
+ <dd>The code in this attribute is called when the "disclosure" button is pressed.</dd>
+</dl>
+</div> <div id="a-ondialogextra1">
+
+
+<dl>
+ <dt><code id="a-ondialogextra1"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/ondialogextra1">ondialogextra1</a></code></dt>
+ <dd>Type: <em>script code</em></dd>
+ <dd>The code in this attribute is called when the first extra button is pressed.</dd>
+</dl>
+</div> <div id="a-ondialogextra2">
+
+
+<dl>
+ <dt><code id="a-ondialogextra2"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/ondialogextra2">ondialogextra2</a></code></dt>
+ <dd>Type: <em>script code</em></dd>
+ <dd>The code in this attribute is called when the second extra button is pressed.</dd>
+</dl>
+</div> <div id="a-ondialoghelp">
+
+
+<dl>
+ <dt><code id="a-ondialoghelp"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/ondialoghelp">ondialoghelp</a></code></dt>
+ <dd>Type: <em>script code</em></dd>
+ <dd>The code in this attribute is called when the "help" button is pressed.</dd>
+</dl>
+</div> <div id="a-title">
+
+
+<dl>
+ <dt><code id="a-title"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/title">title</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>The text to appear in the title bar of the window.</dd>
+</dl>
+</div><p></p>
+<h3 id="Properties" name="Properties">特性</h3>
+<p> </p><div id="p-buttons">
+<dl> <dt><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/buttons">buttons</a></span></code></dt> <dd>类型: 列表,下面的值用逗号分隔</dd> <dd>需要显示在对话框上的按钮的一个列表,使用逗号分隔。将按钮放置在合适的位置,将根据用户平台自动执行基本的事件处理。在列表中可以使用以下值: <ul> <li><code>accept</code>:“确定”按钮,按下按钮时将接受更改。此按钮为默认按钮。</li> <li><code>cancel</code>:“取消”按钮,将取消操作。</li> <li><code>help</code>:“帮助”按钮,在对话框显示一个“帮助”按钮。</li> <li><code>disclosure</code>:“更多信息”按钮,显示一个“more info”按钮。该按钮可能是一个按钮或一个三角形。</li> <li><code>extra1</code>:一个可选的额外的按钮。你可以通过<code><code id="a-buttonlabelextra1"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/buttonlabelextra1">buttonlabelextra1</a></code></code> 属性设置它的label。</li> <li><code>extra2</code>:第二个可选的额外的按钮。你可以通过 <code><code id="a-buttonlabelextra2"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/buttonlabelextra2">buttonlabelextra2</a></code></code> 属性设置它的label。</li> </ul> </dd>
+</dl>
+</div> <div id="p-defaultButton">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/defaultButton">defaultButton</a></span></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>Normally this attribute should not be set, but if it is, it specifies the default button in the dialog. Typically, this means that the button will be activated when the Enter key is pressed. This should be set to one of the same values as those for the <code id="a-buttons"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/buttons">buttons</a></code> attribute.</dd>
+</dl></div><p></p><h3 id="Methods" name="Methods">方法</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0 0 10px 10px; padding: 0 10px; background: rgb(238, 238, 238); float: right; width: 250px;">
+<tbody>
+<tr>
+<td>
+<p><strong>Inherited Methods</strong><br>
+<small><code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.cloneNode">cloneNode()</a></code>, <a href="/En/DOM/Node.compareDocumentPosition" title="En/DOM/Node.compareDocumentPosition">compareDocumentPosition</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getBoundingClientRect">getBoundingClientRect()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getClientRects">getClientRects()</a></code>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span>, <span id="m-getElementsByAttributeNS"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttributeNS">getElementsByAttributeNS</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByClassName">getElementsByClassName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getFeature">getFeature()</a></code>, <a href="/En/DOM/Node.getUserData" title="En/DOM/Node.getUserData">getUserData</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isDefaultNamespace">isDefaultNamespace()</a></code>, <a href="/En/DOM/Node.isEqualNode" title="En/DOM/Node.isEqualNode">isEqualNode</a>, <a href="/En/DOM/Node.isSameNode" title="En/DOM/Node.isSameNode">isSameNode</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <a href="/En/DOM/Node.lookupNamespaceURI" title="En/DOM/Node.lookupNamespaceURI">lookupNamespaceURI</a>, <a href="/En/DOM/Node.lookupPrefix" title="En/DOM/Node.lookupPrefix">lookupPrefix</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.querySelector">querySelector()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.querySelectorAll">querySelectorAll()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code>, <a href="/En/DOM/Node.setUserData" title="En/DOM/Node.setUserData">setUserData</a></small></p>
+
+</td>
+</tr>
+</tbody>
+</table> <dl>
+ <dt>
+ <span id="m-acceptDialog"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/acceptDialog">acceptDialog()</a></code></span></dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+ <dd>
+ Accepts the dialog and closes it, similar to pressing the OK button.</dd>
+</dl> <dl>
+ <dt><span id="m-cancelDialog"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/cancelDialog">cancelDialog()</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Cancels the dialog and closes it, similar to pressing the Cancel button.</dd>
+</dl> <dl>
+ <dt><span id="m-centerWindowOnScreen"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/centerWindowOnScreen">centerWindowOnScreen()</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Centers the dialog on the screen.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-getButton"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getButton">getButton( type )</a></code></span></dt>
+ <dd>
+ 返回值类型: <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/button" title="button">button</a></code>元素</dd>
+ <dd>
+ 返回当前对话框中指定类型的<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/button" title="button">button</a></code>元素.</dd>
+</dl> <dl>
+ <dt><span id="m-moveToAlertPosition"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/moveToAlertPosition">moveToAlertPosition()</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Moves and resizes the dialog to a position and size suitable for an alert box.</dd>
+</dl><p></p>
+<h3 id="Related" name="Related">相关</h3>
+<dl> <dt>Elements</dt> <dd><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/dialogheader" title="dialogheader">dialogheader</a></code></dd>
+</dl>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/events/index.html b/files/zh-cn/mozilla/tech/xul/events/index.html
new file mode 100644
index 0000000000..02cf21976d
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/events/index.html
@@ -0,0 +1,497 @@
+---
+title: Events
+slug: Mozilla/Tech/XUL/Events
+translation_of: Archive/Mozilla/XUL/Events
+---
+<div class="boxed translate-display">
+<p> </p>
+
+<p><a href="https://developer.mozilla.org/zh-CN/docs/XUL_Reference" title="« XUL Reference">« XUL Reference</a></p>
+
+<p> </p>
+
+<p>下列表格描述了对大部分 XUL 元素有效的事件句柄(Event Handler)。您可以使用 <a href="https://developer.mozilla.org/en/DOM/element.addEventListener" title="en/DOM/element.addEventListener">addEventListener</a> 添加事件的监听器(Listener),并使用 <a href="https://developer.mozilla.org/en/DOM/element.removeEventListener" title="en/DOM/element.removeEventListener">removeEventListener</a> 以移除这些监听器。</p>
+
+<p>其中一些事件同样可以使用属性值绑定。当使用属性值绑定事件时,您要注意这样做始终只能绑定一个监听器——后一次绑定会覆盖掉前面一次的绑定。对应的属性名是事件名前加上“on”前缀。</p>
+
+<h3 id="继承的文档树事件">继承的文档树事件</h3>
+
+<p>继承的文档树事件(Inherited DOM Events)</p>
+
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>事件</th>
+ <th>描述</th>
+ </tr>
+ <tr>
+ <td>
+ <p>blur</p>
+ </td>
+ <td>
+ <p>与 focus 事件相对,当一个元素失去焦点时会触发 blur 事件。<br>
+ <strong>属性:</strong>onblur</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>change</p>
+ </td>
+ <td>
+ <p>当文本框的值被修改且失去焦点后,会触发 change 事件。<br>
+ <strong>属性:</strong> onchange</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>click</p>
+ </td>
+ <td>
+ <p>当鼠标键被按下并松开后会触发 click 事件。您可以通过事件对象的 <code>button</code> 属性判断按下的是哪个按键。用户双击时同样会触发这个事件,您可以通过 <code>detail</code> 属性检查有多少次点击发生,用它来检查双击或者三击。在 XUL 中,您应当使用 command 事件响应用户操作,而不应使用 click 事件。</p>
+
+ <p><strong>属性:</strong> onclick</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>dblclick</p>
+ </td>
+ <td>
+ <p>这个事件和 click 事件类似,但是仅当用户双击鼠标的时候触发。这是另一种检查 click 事件中 detail 属性的方法。<br>
+ <strong>属性:</strong> ondblclick</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>DOMMouseScroll</p>
+ </td>
+ <td>
+ <p>当用户滑动鼠标滚轮时会触发这个事件。不论鼠标滚轮的滑动是否造成了页面内容的滚动。事件的 target 属性是滑动滚轮时在鼠标指针下的对象,这与 click 事件相似。</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>focus</p>
+ </td>
+ <td>
+ <p>当一个元素收到焦点的时候,会触发 focus 属性。一旦某个元素获得了焦点,那么键盘事件将会被发送到这个元素上。焦点可以通过鼠标点击、按 Tab 键、按 back Tab 键切换到其他的元素上。<br>
+ <strong>属性:</strong> onfocus</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>keydown</p>
+ </td>
+ <td>
+ <p>当键盘按键被按下但是并未抬起时,会触发当前具有焦点的元素的 keydown 事件。<br>
+ <strong>属性:</strong> onkeydown</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>keypress</p>
+ </td>
+ <td>
+ <p>当键盘按键被按下并松开后,会触发当前具有焦点的元素的 keypress 事件。当用户按下并松开一个键时,会依次触发 keydown 事件、 keypress 事件和 keyup 事件。在一个文本框里,用户可以按住一个键来发送多个对应的字符,这时会像用户重复按了对应键多次一样触发多组按键事件。<br>
+ <strong>属性:</strong> onkeypress</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>keyup</p>
+ </td>
+ <td>
+ <p>当键盘按键被松开后,会触发当前具有焦点的元素的 keyup 事件。<br>
+ <strong>属性:</strong> onkeyup</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>load</p>
+ </td>
+ <td>
+ <p>当一个窗口(window)被完整加载后,会触发他的 load 事件。这个事件被用在窗口元素上和图片(image)元素或其他支持图片属性的上。用在图片元素上时,当图片元素被加载时会触发这个事件。图片元素的 load 事件不会起泡(bubble up),换句话说,不会因此触发窗口的 load 事件。<br>
+ <strong>属性:</strong> onload</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>mousedown</p>
+ </td>
+ <td>
+ <p>当鼠标点击了某个元素但尚未松开时,会触发 mousedown 事件。<br>
+ <strong>属性:</strong> onmousedown</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>mousemove</p>
+ </td>
+ <td>
+ <p>当鼠标在一个元素上移动时,会反复地发送 mousemove 事件。<br>
+ <strong>属性:</strong> onmousemove</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>mouseout</p>
+ </td>
+ <td>
+ <p>与 mouseover 事件相对,当用户将鼠标移出某个元素时,会触发这个元素的 mouseout 事件。<br>
+ <strong>属性:</strong> onmouseout</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>mouseover</p>
+ </td>
+ <td>
+ <p>当鼠标首次移动到某个元素上时,会触发这个元素的 mouseover 事件。<span class="short_text" id="result_box" lang="zh-CN"><span class="alt-edited">您可以使用此事件来提供给用户反馈。</span></span><br>
+ <strong>属性:</strong> onmouseover</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>mouseup</p>
+ </td>
+ <td>
+ <p>当鼠标在某个元素上松开时,会触发 mouseup 事件。<br>
+ <strong>属性:</strong> onmouseup</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>select</p>
+ </td>
+ <td>
+ <p>This event is sent to a listbox or tree when an item is selected.<br>
+ <strong>属性:</strong> onselect</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>unload</p>
+ </td>
+ <td>
+ <p>This event is sent to a window when the window has closed. This is done after the close event. You should place this event handler on the window element.<br>
+ <strong>属性:</strong>onunload</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Mutation_DOM_events" name="Mutation_DOM_events">Mutation 文档树事件</h3>
+
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>事件</th>
+ <th>描述</th>
+ </tr>
+ <tr>
+ <td>
+ <p>DOMAttrModified</p>
+ </td>
+ <td>
+ <p>当一个元素的属性被修改时,会触发 DOMAttrModified 事件。您可以通过 <code>attrName</code> 属性查看哪个属性被修改了,并通过 <code>prevValue</code> 和 <code>newValue</code> 属性查看对应属性的旧值和新值。</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>DOMNodeInserted</p>
+ </td>
+ <td>
+ <p>当一个节点作为一个元素的子节点被添加时,会触发 DOMNodeInsterted 事件。如果您在 document 层捕获这个事件,您可以收到所有对文档修改的动作。</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>DOMNodeRemoved</p>
+ </td>
+ <td>
+ <p>当一个节点被移除时,会触发 DOMNodeRemoved 事件。如果您在 document 层捕获这个事件,您可以收到所有对文档修改的动作。</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<div class="warning">
+<p>请注意,向文档中添加任何 mutation 事件监听器会降低后续文档树操作的性能。而且在后续操作中移除这些监听器并不会使之好转。要了解详细信息,请参考  <a href="https://developer.mozilla.org/en-US/docs/DOM/Mutation_events" title="en-US/docs/DOM/Mutation_events">Mutation events</a> ,并且参考 <a href="https://developer.mozilla.org/en-US/docs/DOM/DOM_Mutation_Observers" title="en-US/docs/DOM/DOM_Mutation_Observers">Mutation observers</a> 考虑使用其他效率更好的方式。</p>
+</div>
+
+<h3 id="Common_XUL_events" name="Common_XUL_events">通用 XUL 事件</h3>
+
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>事件</th>
+ <th>描述</th>
+ </tr>
+ <tr>
+ <td>
+ <p>broadcast</p>
+ </td>
+ <td>
+ <p>您应当将这个事件句柄置于观察者上。当对应元素(如广播者)的属性被改变时,会触发 boardcast 事件。<br>
+ <strong>属性:</strong> onbroadcast</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Events/close_event">close</a></p>
+ </td>
+ <td>
+ <p>当用户按下关闭按钮以要求关闭窗口时,会触发 close 事件。如果您在一个窗口元素上放置该事件的句柄,您可以陷入(trap)窗口的关闭。如果您在监听器中调用 event.preventDefault() ,可以阻止窗口的关闭。注意, close 事件仅针对用户按了标题栏上的关闭按钮,而不针对诸如点击了菜单中的文件—退出的操作。您可以考虑使用窗口的 unload 事件来处理所有关闭窗口的事件。<br>
+ <strong>属性:</strong> onclose</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>command</p>
+ </td>
+ <td>
+ <p>当一个元素被激活时,会触发 command 事件。对于不同的元素,这个事件触发的方式也不尽相同。例如,点击按钮可以触发这个事件,在按钮获得焦点时按回车键也可以触发这个事件,用鼠标选择菜单项时可以触发这个事件,用键盘快捷键选择某个菜单项时同样会触发这个事件。您应当考虑使用 command 事件,而非使用 click 事件,因为 command 事件可以在所有上面说的情况下被调用。<br>
+ <strong>属性:</strong> oncommand</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>commandupdate</p>
+ </td>
+ <td>
+ <p>This event occurs when a command update occurs on a &lt;commandset&gt; element. You would use this to update the disabled status of its commands.<br>
+ <strong>属性:</strong> oncommandupdate</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>contextmenu</p>
+ </td>
+ <td>
+ <p>当用户试图显示某个元素的菜单时,会触发 contextmenu 事件。因平台不同,这个事件的触发方式也有所不同,通常来说是通过右键单击来触发的。这个事件可以用来在用户点击时动态地设置菜单的内容。您还可以使用 popupshowing 事件。在事件句柄中返回 false 可以阻止菜单弹出。<br>
+ <strong>属性:</strong> oncontextmenu</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>drag </p>
+ </td>
+ <td>
+ <p>当拖拽一个节点时,会每秒数次地触发被拖拽节点的 drag 事件。<br>
+ <strong>属性:</strong> ondrag</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>dragdrop</p>
+ </td>
+ <td>
+ <p>当用户松开鼠标以释放一个被拖拽的对象时,会触发 dragdrop 事件。The element, if it accepts the drop, should respond in some manner such inserting the dragged object into itself.<br>
+ <strong>属性:</strong> ondragdrop</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>dragend </p>
+ </td>
+ <td>
+ <p>当拖拽事件结束时,会触发被拖拽的节点的 dragend 事件。<br>
+ <strong>属性:</strong> ondragend</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>dragenter</p>
+ </td>
+ <td>
+ <p>在拖拽过程中,当鼠标节点第一次进入某个对象的范围内时,会触发 dragenter 事件。这个事件与 mouseover 事件相似,不同点在于在拖拽的过程中触发。<br>
+ <strong>属性:</strong> ondragenter</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>dragexit</p>
+ </td>
+ <td>
+ <p>在拖拽的过程中,当鼠标指针从一个元素上移出的时候,会触发 dragexit 事件。这个事件同样会在释放元素后触发。这个事件与 mouseout 事件相似,不同点在于在拖拽的过程中触发。<br>
+ <strong>属性:</strong> ondragexit</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>draggesture</p>
+ </td>
+ <td>
+ <p>当用户开始拖拽一个元素时,会触发 draggesture 事件。一般来说,拖拽是由按住鼠标移动产生的。<br>
+ <strong>属性:</strong> ondraggesture</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>dragover</p>
+ </td>
+ <td>
+ <p>类似于 mouseover 事件,当有东西被拖拽到某个元素之上时,会触发 dragover 事件。这个事件应当判断被拖拽的对象是否可以释放。<br>
+ <strong>属性:</strong> ondragover</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>input</p>
+ </td>
+ <td>
+ <p>当用户在文本框输入的时候,会触发 input 事件。仅当显示的文本被修改时会触发这个事件,因此如果用户按了不会显示出来的按键时,这个事件是不会被触发的。<br>
+ <strong>属性:</strong> oninput</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>overflow</p>
+ </td>
+ <td>
+ <p>仅当 CSS 的 overflow 属性被设置为 visible 以外的值时才会触发 overflow 。当没有足够的空间显示某个元素当内容时,会触发 overflow 事件。例如,一个最大尺寸为 100 像素的盒,但是可用的空间只有 80 像素,那么就会触发 overflow 事件。如果因为用户修改窗口大小等因素导致大小被改变了,因此有了足够的空间时,会触发相应的 underflow 事件。<br>
+ <strong>属性:</strong> onoverflow</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>popuphidden</p>
+ </td>
+ <td>
+ <p>当一个弹出的元素被隐藏了时,会触发 popuphidden 事件。<br>
+ <strong>属性:</strong> onpopuphidden</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>popuphiding</p>
+ </td>
+ <td>
+ <p>当一个弹出的元素将被隐藏时,会触发 popuphiding 事件。<br>
+ <strong>属性:</strong> onpopuphiding</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>popupshowing</p>
+ </td>
+ <td>
+ <p>当一个弹出元素将被显示时,会触发 popupshowing 事件。这个事件经常被用来在用户需要显示弹出元素时动态地设置它的内容。在句柄中返回 false 可以阻止元素弹出。<br>
+ <strong>属性:</strong> onpopupshowing</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>popupshown</p>
+ </td>
+ <td>
+ <p>当一个弹出元素被显示了时,会触发 popupshown 事件。这类似于窗口上的 load 事件。<br>
+ <strong>属性:</strong> onpopupshown</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>syncfrompreference</p>
+ </td>
+ <td>
+ <p>因为选项的修改而导致元素改变时,会调用 syncfrompreference 事件。这个事件只会对 <a href="https://developer.mozilla.org/en/XUL/prefwindow" title="en/XUL/prefwindow">prefwindow</a> 中的元素生效。这不是实际意义上的事件而仅仅是一个函数调用,所以这个事件必须使用属性形式的语法定义。函数可以返回不同于选项的特定的值。这个事件通常被用于为了让选项值更适合显式在用户界面中而调整选项值。<br>
+ <strong>属性:</strong> onsyncfrompreference</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>synctopreference</p>
+ </td>
+ <td>
+ <p>当与对象连接的属性值被修改时,会调用 synctopreference 事件。这不是实际意义上的事件而仅仅是一个函数调用,所以这个事件必须使用属性形式的语法定义。函数可以返回不同于选项的特定的值,以设置属性的值,而非使用元素的 value 。<br>
+ <strong>属性:</strong> onsynctopreference</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>underflow</p>
+ </td>
+ <td>
+ <p>当有了足够的空间完整地显示某个元素时,会触发这个元素的 underflow 事件。这个事件对所有 CSS 的 overflow 属性不为 visible 的盒或其他布局元素生效。这个事件说明滚动条已经没必要了。<br>
+ <strong>属性:</strong> onunderflow</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>DOMMenuItemActive</p>
+ </td>
+ <td>
+ <p>当鼠标在菜单或菜单项上时或某个菜单项没高亮时,会触发 DOMMenuItemActive 事件。这个事件是起泡的(bubbles)。</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>DOMMenuItemInactive</p>
+ </td>
+ <td>
+ <p>当鼠标移出菜单或菜单项或某个菜单项不再被高亮时,会触发 DOMMenuItemInactive 事件。这个事件是起泡的。</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="窗口事件">窗口事件</h3>
+
+<p>下列事件被绑定在顶级文档树窗口上,可以使用 window.addEventListener 监听。</p>
+
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>Event</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>activate </td>
+ <td>当窗口变为活动窗口时触发。</td>
+ </tr>
+ <tr>
+ <td>deactivate </td>
+ <td>当窗口变为非活动窗口时触发。</td>
+ </tr>
+ <tr>
+ <td>sizemodechange </td>
+ <td>
+ <p>当某个窗口被最小化,取消最小化,切换到全屏模式,或切换到窗口模式时触发。注意,这个事件可能被调用多次,或者因为修改窗口大小而被调用,(见 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=715867" title="FIXED: sizemodechange event fires during resizing on mac, even when sizemode/windowState doesn't change">bug 715867</a> )。所以应当在事件中查看 <a href="/zh-CN/docs/Web/API/Window/windowState" title="此页面仍未被本地化, 期待您的翻译!"><code>window.windowState</code></a> 检查窗口的状态。</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Accessibility_events" name="Accessibility_events">可访问性事件</h3>
+
+<p>这些事件被用来通知可访问性系统。一般来说你不应该自行使用这些事件。</p>
+
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>Event</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>
+ <p>CheckboxStateChange</p>
+ </td>
+ <td>
+ <p>当一个 <a href="https://developer.mozilla.org/en/XUL/checkbox" title="en/XUL/checkbox">checkbox</a> 被选中或取消选中时,会触发 CheckboxStateChange 事件。这个事件可能由于用户动作触发,也可能由于脚本改变了选框的值。相比之下, command 事件只会因为用户的动作而触发,这时 CheckboxStateChange 事件在 command 事件之前触发。 CheckboxStateChange 事件是不起泡的。</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>RadioStateChange</p>
+ </td>
+ <td>
+ <p>当一个 <a href="https://developer.mozilla.org/en/XUL/radio" title="en/XUL/radio"> radio</a> 被选中时,会触发 RadioStateChange 事件。这个事件可能时由于用户动作触发,也可能时因为脚本修改了对应的值。相比之下, command 事件只会因为用户的动作而触发,这时 RadioStateChange 事件在 command 事件之前触发。 RadioStateChange 事件是起泡的,因此你可以在 <a href="https://developer.mozilla.org/en/XUL/radiogroup" title="en/XUL/radiogroup"> radiogroup</a> 绑定事件句柄。</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p></p>
+</div>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/image/index.html b/files/zh-cn/mozilla/tech/xul/image/index.html
new file mode 100644
index 0000000000..f70f4a5f7d
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/image/index.html
@@ -0,0 +1,145 @@
+---
+title: image
+slug: Mozilla/Tech/XUL/image
+translation_of: Archive/Mozilla/XUL/image
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<h3 id="Summary">Summary</h3>
+<p>用于图片显示的元素,与HTML中的img相似.使用 <code id="a-src"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/src">src</a></code>可以指定图片的URL.</p>
+<p>More information is available in the <a href="/en/XUL_Tutorial/Adding_Labels_and_Images" title="en/XUL_Tutorial/Adding_Labels_and_Images">XUL tutorial</a>.</p>
+<div class="noinclude">
+ <div class="note">
+ <p><strong>Note:</strong> Prior to <span title="(Firefox 8.0 / Thunderbird 8.0 / SeaMonkey 2.5)">Gecko 8.0</span>, images did not shrink down with the same ratio in both directions when specifying maximum sizes using <code>maxheight</code> or <code>maxwidth</code>. The new behavior aligns more with the HTML <a href="/zh-CN/docs/Web/HTML/Element/img" title="HTML Image 元素( &lt;img> )代表文档中的一个图像。"><code>&lt;img&gt;</code></a> element and shrinks both the width and height down proportionally.</p>
+ </div>
+</div>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-onerror">onerror</a>, <a href="#a-onload">onload</a>, <a href="#a-src">src</a>, <a href="#a-validate">validate</a></dd>
+</dl>
+<dl>
+ <dt>
+ Properties</dt>
+ <dd>
+ <a href="#p-accessibleType">accessibleType</a>, <a href="#p-src">src</a></dd>
+</dl>
+<dl>
+ <dt>
+ Style classes</dt>
+ <dd>
+ <a href="#s-alert-icon">alert-icon</a>, <a href="#s-error-icon">error-icon</a>, <a href="#s-message-icon">message-icon</a>, <a href="#s-question-icon">question-icon</a></dd>
+</dl>
+<h3 id="Examples">Examples</h3>
+<div class="float-right">
+ <img alt="Image:Firefoxlogo2.png" class="internal" src="/@api/deki/files/220/=Firefoxlogo2.png"></div>
+<pre class="eval">&lt;image src='Firefoxlogo.png' width='135' height='130'/&gt;
+</pre>
+<h3 id="Attributes">Attributes</h3>
+<p> </p><div id="a-onerror">
+
+
+<dl>
+ <dt><code id="a-onerror"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/onerror">onerror</a></code></dt>
+ <dd>Type: <em>script code</em></dd>
+ <dd>This event is sent to an <code><a href="/en-US/docs/Mozilla/Tech/XUL/image" title="image">image</a></code> element when an error occurs loading the image.</dd>
+</dl>
+</div> <div id="a-onload">
+
+<h3 id="See" name="See">See</h3>
+
+<ul>
+ <li><code id="a-image.onload"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/image.onload">image.onload</a></code></li>
+ <li><code id="a-prefwindow.onload"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/prefwindow.onload">prefwindow.onload</a></code></li>
+</ul>
+
+</div> <div id="a-src">
+
+<dl>
+ <dt>
+ <code id="a-src"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/src">src</a></code></dt>
+ <dd>
+ Type: <em>URI</em></dd>
+ <dd>
+ The URI of the content to appear in the element.</dd>
+</dl>
+
+
+</div> <div id="a-validate">
+
+<dl>
+ <dt>
+ <code id="a-validate"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/validate">validate</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ one of the values below</i>
+ </dd>
+ <dd>
+ This attribute indicates whether to load the image from the cache or not. This would be useful if the images are stored remotely or you plan on swapping the image frequently. The following values are accepted, or leave out the attribute entirely for default handling:</dd>
+</dl>
+<ul>
+ <li><code>always</code>: The image is always checked to see whether it should be reloaded.</li>
+ <li><code>never</code>: The image will be loaded from the cache if possible.</li>
+</ul>
+
+<p></p>
+</div><p></p>
+<h3 id="Properties">Properties</h3>
+<p></p><div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-src">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/src">src</a></span></code></dt>
+ <dd>Type: <em>URL</em></dd>
+ <dd>Gets and sets the value of the <code id="a-src"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/src">src</a></code> attribute.</dd>
+</dl></div> <table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited Properties</strong><br> <small> <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/align">align</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/allowEvents">allowEvents</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/boxObject">boxObject</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/builder">builder</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/className">className</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/collapsed">collapsed</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/contextMenu">contextMenu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/controllers">controllers</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/database">database</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/datasources">datasources</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/dir">dir</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/flex">flex</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/height">height</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/hidden">hidden</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/id">id</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/left">left</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxHeight">maxHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxWidth">maxWidth</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menu">menu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minHeight">minHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minWidth">minWidth</a></span></code>, , , , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/observes">observes</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ordinal">ordinal</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/orient">orient</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/pack">pack</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/persist">persist</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ref">ref</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/resource">resource</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/statusText">statusText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/style">style</a></span></code>, ,, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltip">tooltip</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltipText">tooltipText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/top">top</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/width">width</a></span></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Style_classes">Style classes</h3>
+<p></p><dl>
+ <dt>
+ <code><a href="https://developer.mozilla.org/en-US/docs/XUL/Style/alert-icon">alert-icon</a></code></dt>
+ <dd>
+ Class that adds an alert icon. This typically looks like an exclamation mark. This and the other icon classes may be used by <code><a href="/en-US/docs/Mozilla/Tech/XUL/image" title="image">image</a></code> elements or other elements which can have an image.</dd>
+</dl> <dl>
+ <dt><code><a href="https://developer.mozilla.org/en-US/docs/XUL/Style/error-icon">error-icon</a></code></dt>
+ <dd>Class that adds an error icon. This will typically be a red "X" icon.</dd>
+</dl> <dl>
+ <dt><code><a href="https://developer.mozilla.org/en-US/docs/XUL/Style/message-icon">message-icon</a></code></dt>
+ <dd>Class that adds a message box icon.</dd>
+</dl> <dl>
+ <dt><code><a href="https://developer.mozilla.org/en-US/docs/XUL/Style/question-icon">question-icon</a></code></dt>
+ <dd>Class that adds a question icon, which usually looks like a question mark.</dd>
+</dl><p></p>
+<h3 id="Related">Related</h3>
+<p>See also the <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code> and <code id="a-icon"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/icon">icon</a></code> attributes.</p>
+<h3 id="Interfaces">Interfaces</h3>
+<ul>
+ <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIAccessibleProvider" title="">nsIAccessibleProvider</a></code></li>
+ <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMXULImageElement" title="">nsIDOMXULImageElement</a></code></li>
+</ul>
+<div class="noinclude">
+ </div>
diff --git a/files/zh-cn/mozilla/tech/xul/index.html b/files/zh-cn/mozilla/tech/xul/index.html
new file mode 100644
index 0000000000..ac0e9697f5
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/index.html
@@ -0,0 +1,79 @@
+---
+title: XUL
+slug: Mozilla/Tech/XUL
+tags:
+ - XUL
+translation_of: Archive/Mozilla/XUL
+---
+<div class="callout-box">
+ <strong><a href="/cn/XUL_%E6%95%99%E7%A8%8B" title="cn/XUL_教程">从这里开始</a></strong><br>
+   帮助你对XUL有一个比较直观的理解(该教程首发于 XULPlanet)</div>
+<div>
+ <p><strong>XUL</strong> 是一个Mozilla使用XML来描述用户界面的一种技术,使用XUL你可以快速的创建出跨平台,基于因特网的应用程序。基于XUL技术的应用程序可以很方便的使用好看的字体、图形以及方便的界面布局,而且也更容易部署和定制。如果程序员已经熟悉了Dynamic HTML (<a href="/cn/DHTML" title="cn/DHTML">DHTML</a>),那学习XUL将是更容易的事,也可以更快的开发基于XUL的应用程序.</p>
+</div>
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h4 id=".E6.8E.A8.E8.8D.90.E7.9A.84.E6.96.87.E7.AB.A0" name=".E6.8E.A8.E8.8D.90.E7.9A.84.E6.96.87.E7.AB.A0">推荐的文章</h4>
+ <dl>
+ <dt>
+ <a href="/cn/XUL_Reference" title="cn/XUL Reference">XUL模板手册</a></dt>
+ <dd>
+ <small>XUL模板是用于提供来自查询或是类似于结果集的内容块的一种方法.一个比较好的例子像数据库查询集.对于每个查询结果集,生成相关的内容块.XUL模板允许使用不的规则来生成基于特定要求的不同内容块,也允许给返回结果集设置属性.</small></dd>
+ </dl>
+ <dl>
+ <dt>
+ <a class="internal" href="/cn/XUL/XUL_教程" title="cn/XUL/XUL 教程">XUL 教程</a></dt>
+ <dd>
+ <small>这份教程教你如何进入XUL (XML User Interface Language,Mozilla的平台无关界面描述语言)神奇世界.设计一个简单的"查找文件"的界面, 对XUL的各种特性进行了解和学习.</small></dd>
+ </dl>
+ <dl>
+ <dt>
+ <a href="/Cn/XUL/用XUL做你意想不到的事" title="cn/XUL/用XUL做你意想不到的事">XUL:用XUL做你意想不到的事</a></dt>
+ <dd>
+ <small>Vlad Vukicevic 写完了这个大杂烩式的 FAQ, 列出了在 XUL 中可以做的事情 (hopefully with bug numbers), 不可以做的事情 (hopefully with explanations), 以及如何解决它们的办法. 欢迎各位添加自己的 XUL 体验到文章里.</small></dd>
+ </dl>
+ <dl>
+ <dt>
+ <a href="/cn/XTech_2005_Presentations/XUL_-_Mozilla's_XML_User_Interface_Language" title="cn/XTech_2005_Presentations/XUL_-_Mozilla's_XML_User_Interface_Language">Mozilla's XML 用户接口语言</a> (表现层)</dt>
+ <dd>
+ <small>Ben Goodger 在阿姆斯特丹(</small><small>Amsterdam</small><small>)的</small><small> XTech 2005 大会上给出了这份关于 XUL 的表现层</small><small>.</small></dd>
+ </dl>
+ <dl>
+ <dt>
+ <span class="exlink"><a href="/cn/XUL应用程序教程" title="cn/XUL应用程序教程">XUL应用程序教程</a></span></dt>
+ <dd>
+ <small>这个教程被设计用来教你学会如何创建一个基于 XUL 的简单程序, 通过循序渐进地开发一个 XUL 程序来演示要讨论的概念.</small></dd>
+ </dl>
+ <p><br>
+ <span class="alllinks"><a href="/Special:Tags?tag=XUL:Articles&amp;language=zh-cn" title="Special:Tags?tag=XUL:Articles&amp;language=zh-cn">显示所有...</a></span></p>
+ </td>
+ <td>
+ <p> </p>
+ <h4 id=".E7.89.B9.E8.89.B2.E4.B8.BB.E9.A2.98" name=".E7.89.B9.E8.89.B2.E4.B8.BB.E9.A2.98">特色主题</h4>
+ <ul>
+ <li><a href="/cn/XUL_%E6%95%99%E7%A8%8B" title="cn/XUL_教程">XUL 教程</a></li>
+ <li><a href="/cn/Preferences_System" title="cn/Preferences_System">Preferences System</a></li>
+ <li><a href="/cn/XUL/Template_Guide" title="cn/XUL/Template_Guide">模板手册</a></li>
+ <li><a href="/cn/Adapting_XUL_Applications_for_Firefox_1.5" title="cn/Adapting_XUL_Applications_for_Firefox_1.5">Adapting XUL Applications for Firefox 1.5</a></li>
+ </ul>
+ <h4 id=".E5.85.B6.E4.BB.96.E9.A1.B5.E9.9D.A2" name=".E5.85.B6.E4.BB.96.E9.A1.B5.E9.9D.A2">其他页面</h4>
+ <ul>
+ <li><a href="/Special:Tags?tag=XUL:References&amp;language=zh-cn" title="Special:Tags?tag=XUL:References&amp;language=zh-cn">XUL 手册</a></li>
+ <li><a href="/Special:Tags?tag=XUL:Articles&amp;language=zh-cn" title="Special:Tags?tag=XUL:Articles&amp;language=zh-cn">XUL 文章</a></li>
+ <li><a href="/Special:Tags?tag=XUL:Tools&amp;language=zh-cn" title="Special:Tags?tag=XUL:Tools&amp;language=zh-cn">工具</a></li>
+ <li><a href="/Special:Tags?tag=XUL:Examples&amp;language=zh-cn" title="Special:Tags?tag=XUL:Examples&amp;language=zh-cn">示例</a></li>
+ <li><a href="/cn/XUL/Community" title="cn/XUL/Community">社区</a></li>
+ <li><a href="/cn/XUL/Other_Resources" title="cn/XUL/Other_Resources">其他资源</a></li>
+ </ul>
+ <h4 id=".E5.85.B3.E8.81.94.E4.B8.BB.E9.A2.98" name=".E5.85.B3.E8.81.94.E4.B8.BB.E9.A2.98">关联主题</h4>
+ <dl>
+ <dd>
+ <a href="/cn/JavaScript" title="cn/JavaScript">JavaScript</a>, <a href="/cn/xbl" title="cn/xbl">XBL</a>, <a href="/cn/CSS" title="cn/CSS">CSS</a>, <a href="/cn/RDF" title="cn/RDF">RDF</a><span class="alllinks"><a class="external" href="http://developer.mozilla.org/webwatch/?cat=23">显示所有...</a></span></dd>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/key/index.html b/files/zh-cn/mozilla/tech/xul/key/index.html
new file mode 100644
index 0000000000..13fabfbd2d
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/key/index.html
@@ -0,0 +1,166 @@
+---
+title: key
+slug: Mozilla/Tech/XUL/key
+tags:
+ - XUL Elements
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/key
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>The <code>key</code> element defines a keyboard shortcut. Event handlers can be used to respond when the appropriate keys are pressed. A <code>key</code> element must be placed inside a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/keyset" title="keyset">keyset</a></code> element.</p>
+<p>When a key matching the attributes on the key element is pressed, the command will be fired on the key element. The key pressed must match the key attribute (or keycode attribute) as well as the modifiers attribute in order for the key element to be activated and fire a command event.</p>
+<p>For example, consider the following key:</p>
+<pre class="eval">&lt;key key="r" modifiers="shift"/&gt;
+</pre>
+<p>This key will only match when the Shift key is pressed as well as the R key, and no other keys. For instance, if the Shift, Control and R keys are all pressed, the key will not match.</p>
+<p>To indiciate that a modifier key may optionally be pressed, place the word 'any' after listing the optional modifier key. For example:</p>
+<pre class="eval">&lt;key key="r" modifiers="shift any control"/&gt;
+</pre>
+<p>In this example, the shift key may or may not be pressed, while the control key must be pressed. This allows keys to match more loosely for modifier keys that aren't relevant, yet still allows specific modifiers to be required.</p>
+<p>If the modifiers attribute is not specified, then no modifiers may be pressed for the key to match.</p>
+<p>If neither the key or keycode attribute are used, the key element will handle all key events. However, if one of the attributes is set to an empty string, the element doesn't handle any key events. For example:</p>
+<pre class="eval">&lt;!-- This element handles all key events --&gt;
+&lt;key/&gt;
+
+&lt;!-- These elements don't handle any key events --&gt;
+&lt;key key="" modifiers="control"/&gt;
+&lt;key keycode="" modifiers="control"/&gt;
+</pre>
+<p>More information is available in the <a href="cn/XUL_Tutorial/Keyboard_Shortcuts">XUL tutorial</a>.</p>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-command">command</a>, <a href="#a-disabled">disabled</a>, <a href="#a-key">key</a>, <a href="#a-keycode">keycode</a>, <a href="#a-keytext">keytext</a>, <a href="#a-modifiers">modifiers</a>, <a href="#a-oncommand">oncommand</a>, <a href="#a-phase">phase</a></dd>
+</dl>
+<h3 id="Examples" name="Examples">Examples</h3>
+<p>(example needed)</p>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p> </p><div id="a-command">
+
+<dl>
+ <dt>
+ <code id="a-command"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/command">command</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ element id</i>
+ </dd>
+ <dd>
+ Set to the <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> of a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/command" title="command">command</a></code> element that is being observed by the element.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-disabled">
+
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd> </dd>
+ <dd>
+ <h5 id="类型boolean">类型:<em>boolean</em></h5>
+ </dd>
+ <dd>
+ <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>
+
+ <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>
+
+ <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
+ </dd>
+</dl>
+
+<h4 id="示例:">示例:</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>
+
+<pre><code>// Disabling an element
+document.getElementById('buttonRemove').setAttribute("disabled", "true");
+
+// Enabling back an element by removing the "disabled" attribute
+document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>
+
+<p></p><div class="blockIndicator standardNote standardNoteBlock">
+ <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
+ <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
+</div><p></p>
+</div> <div id="a-key">
+
+
+<dl>
+ <dt><code id="a-key"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/key">key</a></code></dt>
+ <dd>Type: <em>character</em></dd>
+ <dd>The character that must be pressed. This should be set to a displayable character.</dd>
+</dl>
+</div> <div id="a-keycode">
+
+
+<dl>
+ <dt><code id="a-keycode"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/keycode">keycode</a></code></dt>
+ <dd>Type: <em>string key code</em></dd>
+ <dd>For keys that do not have displayable characters, such as the Enter key or function keys, use this attribute instead of the <code id="a-key"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/key">key</a></code> attribute. Valid keys are listed at <a class="internal" href="/en/XUL_Tutorial/Keyboard_Shortcuts" title="en/XUL Tutorial/Keyboard Shortcuts">Keyboard Shortcuts</a>.</dd>
+</dl>
+</div> <div id="a-keytext">
+
+
+<dl>
+ <dt><code id="a-keytext"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/keytext">keytext</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>A label for the keyboard shortcut. This text would appear next to a <code><a href="/en-US/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> label if that <code><a href="/en-US/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> is associated with the <code><a href="/en-US/docs/Mozilla/Tech/XUL/key" title="key">key</a></code> element via its <code id="a-key"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/key">key</a></code> attribute.</dd>
+</dl>
+</div> <div id="a-modifiers">
+
+
+<dl>
+ <dt><code id="a-modifiers"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/modifiers">modifiers</a></code></dt>
+ <dd>Type: <em>space-separated list of the values below</em></dd>
+ <dd>A list of modifier keys that should be pressed to invoke the keyboard shortcut. Multiple keys may be separated by spaces or commas. Keys will map to other keys on platforms that do not have them.</dd>
+</dl>
+
+<ul>
+ <li><code>shift</code>: The Shift key.</li>
+ <li><code>alt</code>: 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.</li>
+ <li><code>meta</code>: The Meta key. On the Macintosh, this is the Command key.</li>
+ <li><code>control</code>: The Control key.</li>
+ <li><code>os</code>: Windows logo key on Windows, Super or Hyper key on Linux. This shouldn't be specified directly because it may conflict with system wide shortcut key. </li>
+ <li><code>accel</code>: 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.</li>
+ <li><code>access</code>: The access key for activating menus and other elements. On Windows, this is the Alt key, used in conjuction with an element's accesskey.</li>
+ <li><code>any</code>: Indicates that all modifiers preceding it are optional.</li>
+</ul>
+</div> <div id="a-oncommand">
+
+
+<dl>
+ <dt><code id="a-oncommand"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/oncommand">oncommand</a></code></dt>
+ <dd>Type: <em>script code</em></dd>
+ <dd>This event handler is called when the command is activated. This occurs when a user selects a menu item or presses a keyboard shortcut attached to the command.</dd>
+</dl>
+
+
+</div> <div id="a-phase">
+
+
+<dl>
+ <dt><code id="a-phase"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/phase">phase</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>The event phase where the handler is invoked. This should be set to the value <code>capturing</code> to indicate during the event capturing phase or <code>target</code> to indicate at the target element or left out entirely for the bubbling phase.</dd>
+</dl>
+</div><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited Properties</strong><br> <small> <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/align">align</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/allowEvents">allowEvents</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/boxObject">boxObject</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/builder">builder</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/className">className</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/collapsed">collapsed</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/contextMenu">contextMenu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/controllers">controllers</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/database">database</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/datasources">datasources</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/dir">dir</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/flex">flex</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/height">height</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/hidden">hidden</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/id">id</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/left">left</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxHeight">maxHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxWidth">maxWidth</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menu">menu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minHeight">minHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minWidth">minWidth</a></span></code>, , , , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/observes">observes</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ordinal">ordinal</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/orient">orient</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/pack">pack</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/persist">persist</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ref">ref</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/resource">resource</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/statusText">statusText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/style">style</a></span></code>, ,, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltip">tooltip</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltipText">tooltipText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/top">top</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/width">width</a></span></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<p>TBD</p>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/label/index.html b/files/zh-cn/mozilla/tech/xul/label/index.html
new file mode 100644
index 0000000000..f6201f62c0
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/label/index.html
@@ -0,0 +1,298 @@
+---
+title: label
+slug: Mozilla/Tech/XUL/label
+tags:
+ - XUL Elements
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/label
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>This element is used to provide a label for a control element. If the user clicks the label, it will move the focus to the associated control, specified with the <code id="a-control"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/control">control</a></code> attribute.</p>
+<p>More information is available in the <a href="cn/XUL_Tutorial/Adding_Labels_and_Images">XUL tutorial</a>.</p>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-accesskey">accesskey</a>, <a href="#a-control">control</a>, <a href="#a-crop">crop</a>, <a href="#a-disabled">disabled</a>, <a href="#a-href">href</a>, <a href="#a-label.value">value</a></dd>
+</dl>
+<dl>
+ <dt>
+ Properties</dt>
+ <dd>
+ <a href="#p-accessKey">accessKey</a>, <a href="#p-accessibleType">accessibleType</a>, <a href="#p-control">control</a>, <a href="#p-crop">crop</a>, <a href="#p-disabled">disabled</a>, <a href="#p-value">value</a></dd>
+</dl>
+<dl>
+ <dt>
+ Style classes</dt>
+ <dd>
+ <a href="#s-header">header</a>, <a href="#s-indent">indent</a>, <a href="#s-monospace">monospace</a>, <a href="#s-plain">plain</a>, <a href="#s-small-margin">small-margin</a>, <a href="#s-text-link">text-link</a></dd>
+</dl>
+<h3 id="Examples" name="Examples">Examples</h3>
+<div class="float-right">
+ <img alt="Image:XUL_ref_label.png"></div>
+<pre class="eval">&lt;label value="Email address" control="email"/&gt;
+&lt;textbox id="email"/&gt;
+</pre>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p> </p><div id="a-accesskey">
+
+
+
+
+<dl>
+ <dt><code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code></dt>
+ <dd>类型:
+ <i>character【字符】</i>
+ </dd>
+ <dd>本属性允许为控件(元素)设定一个字符作为快捷键,这个字符应该是 <code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code> 属性文本中的一个字符。该字符将会被加下划线以重点强调,平台和主体的变换并不影响这一表现行为。 当用户点击 ALT (在其他平台上具有类似功能的键) 和这个字符对应的按键时, 控件(元素)将立刻被从窗口中的某处激活或/并且获得焦点 <b>。虽说字符不分大小写,但是当label中存在大写字符和小写字符时,快捷键的字符将首先选择与之完全匹配的那一个,如果label中存在两个或更多的与accesskey字符相同的字符,其中的第一个字符将被加下划线。</b></dd>
+ <dt>      *(有些键在监听按键事件时,分别对应event.ctrlKey和event.metaKey。)</dt>
+</dl>
+
+<p> </p>
+
+<h4 id="Example" name="Example">Example</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_accesskey_attr.png"></div>
+
+<pre>&lt;vbox&gt;
+ &lt;label value="Enter Name" accesskey="e" control="myName"/&gt;
+ &lt;textbox id="myName"/&gt;
+ &lt;button label="Cancel" accesskey="n"/&gt;
+ &lt;button label="Ok" accesskey="O"/&gt;
+&lt;/vbox&gt;
+</pre>
+
+<h4 id="See_also" name="See_also">See also</h4>
+
+<p><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute, <code id="a-acceltext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/acceltext">acceltext</a></code> attribute</p>
+
+<p></p>
+</div> <div id="a-control">
+
+<dl>
+ <dt>
+ <code id="a-control"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/control">control</a></code></dt>
+ <dd>
+ Type: <em>element id</em></dd>
+ <dd>
+ This attribute specifies the <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> of the element with which the label is associated. When the user clicks on the label, the associated element is given focus.<br>
+ 这个属性定义了元素的<code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code>,它与<code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code>相关联。当用户点击 <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> 的时候,相关联的元素将获得焦点。</dd>
+</dl>
+
+<p> </p>
+</div> <div id="a-crop">
+
+<dl>
+ <dt>
+ <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ one of the values below</i>
+ </dd>
+ <dd>
+ If the label of the element is too big to fit in its given space, the text will be cropped on the side specified by the <code>crop</code> attribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.</dd>
+</dl>
+<ul>
+ <li><code>start</code>: The text will be cropped on its left side.</li>
+ <li><code>end</code>: The text will be cropped on its right side.</li>
+ <li><code>left</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its left side.</li>
+ <li><code>right</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its right side.</li>
+ <li><code>center</code>: The text will be cropped in the middle, showing both the start and end of the text normally.</li>
+ <li><code>none</code>: The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.</li>
+</ul>
+
+<p></p>
+</div> <div id="a-disabled">
+
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd> </dd>
+ <dd>
+ <h5 id="类型boolean">类型:<em>boolean</em></h5>
+ </dd>
+ <dd>
+ <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>
+
+ <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>
+
+ <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
+ </dd>
+</dl>
+
+<h4 id="示例:">示例:</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>
+
+<pre><code>// Disabling an element
+document.getElementById('buttonRemove').setAttribute("disabled", "true");
+
+// Enabling back an element by removing the "disabled" attribute
+document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>
+
+<p></p><div class="blockIndicator standardNote">
+ <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
+ <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
+</div><p></p>
+</div> <div id="a-href">
+
+
+<dl>
+ <dt><code id="a-href"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/href">href</a></code></dt>
+ <dd>类型: <em>文本</em></dd>
+ <dd>定义一个当元素被点击时将会打开的 URL 。需要引用类 <a href="/en/XUL/Style/text-link" title="en/XUL/Style/text-link">text-link </a>。</dd>
+</dl>
+
+
+
+
+</div> <div id="a-label.value">
+
+
+<dl>
+ <dt><code id="a-label.value"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/label.value">value</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>The text to be used for the label.</dd>
+</dl>
+</div><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p> </p><div id="p-accessKey">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessKey">accessKey</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ character</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-control">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/control">control</a></span></code></dt>
+ <dd>
+ Type: <em>element id</em></dd>
+ <dd>
+ Gets and sets the value of the <code id="a-control"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/control">control</a></code> attribute.</dd>
+</dl>
+</div> <div id="p-crop">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/crop">crop</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-disabled">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/disabled">disabled</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-value">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/value">value</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code> attribute.</dd>
+</dl>
+
+<p></p></div><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Style_classes" name="Style_classes">Style classes</h3>
+<p>The following classes may be used to style the element. These classes should be used instead of changing the style of the element directly since they will fit more naturally with the user's selected theme.</p>
+<p></p><dl>
+ <dt><code><a href="https://developer.mozilla.org/en-US/docs/XUL/Style/header">header</a></code></dt>
+ <dd>A class used for headings. Typically, this will cause the text to appear bold.</dd>
+</dl> <dl>
+ <dt><code><a href="https://developer.mozilla.org/en-US/docs/XUL/Style/indent">indent</a></code></dt>
+ <dd>This class causes the text to be indented on its left side.</dd>
+</dl> <dl>
+ <dt><code><a href="https://developer.mozilla.org/en-US/docs/XUL/Style/monospace">monospace</a></code></dt>
+ <dd>This class causes the text to be displayed in a monospace font.</dd>
+</dl> <dl>
+ <dt><code><a href="https://developer.mozilla.org/en-US/docs/XUL/Style/plain">plain</a></code></dt>
+ <dd>This class causes the element to be displayed with no border or margin.</dd>
+</dl> <dl>
+ <dt><code><a href="https://developer.mozilla.org/en-US/docs/XUL/Style/small-margin">small-margin</a></code></dt>
+ <dd>This class causes the text to be displayed with a smaller margin.</dd>
+</dl> <dl>
+ <dt><code><a href="https://developer.mozilla.org/en-US/docs/XUL/Style/text-link">text-link</a></code></dt>
+ <dd>Labels with this class may be focused and the click handler run or the address in the <a href="/en/XUL/Attribute/href" title="en/XUL/Attribute/href">href attribute</a> opened on a mouse click or Enter key press. Labels will appear like a link (blue and underlined).</dd>
+</dl><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<dl>
+ <dt>
+ Elements</dt>
+ <dd>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/description" title="description">description</a></code></dd>
+</dl>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></dd>
+</dl>
+<dl>
+ <dt>
+ Interfaces</dt>
+ <dd>
+ <a href="cn/NsIAccessibleProvider">nsIAccessibleProvider</a>, <a href="cn/NsIDOMXULLabelElement">nsIDOMXULLabelElement</a></dd>
+</dl>
+<h3 id="User_notes" name="User_notes">User notes</h3>
+<p>Remember that the label element has a "value" attribute, unlike value in HTML whereas buttons, checkboxes use label="foo" as the attribute</p>
+<pre>&lt;label label="A Caption"/&gt; &lt;-- wrong --&gt;
+&lt;label value="A Caption"/&gt;
+
+&lt;label value="Click the button"/&gt;
+&lt;button label="A Button"/&gt;
+&lt;checkbox label="A Decision" value="1"/&gt;
+</pre>
+<p> </p>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/list_of_commands/index.html b/files/zh-cn/mozilla/tech/xul/list_of_commands/index.html
new file mode 100644
index 0000000000..54ff23cabf
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/list_of_commands/index.html
@@ -0,0 +1,196 @@
+---
+title: List of commands
+slug: Mozilla/Tech/XUL/List_of_commands
+translation_of: Archive/Mozilla/XUL/List_of_commands
+---
+<p>The following lists <a href="/en/XUL_Tutorial/Commands" title="en/XUL_Tutorial/Commands">commands</a> which might be usable by &lt;command&gt; or command dispatchers/controllers.</p>
+<h3 id="List_of_Commands_.28grouped_by_type.29" name="List_of_Commands_.28grouped_by_type.29">List of Commands (grouped by type)</h3>
+<h4 id="nsDomWindowController_commands_.28generally_legal_when_there_is_a_selection.29:" name="nsDomWindowController_commands_.28generally_legal_when_there_is_a_selection.29:">nsDomWindowController commands (generally legal when there is a selection):</h4>
+<ul>
+ <li>cmd_copy - copy a selection to the clipboard</li>
+ <li>cmd_cut - cut a selection into the clipboard</li>
+ <li>cmd_paste - paste a selection from the clipboard</li>
+ <li>cmd_selectAll</li>
+ <li>cmd_selectNone</li>
+ <li>cmd_copyLink</li>
+ <li>cmd_copyImageLocation</li>
+ <li>cmd_copyImageContents</li>
+ <li>cmd_scrollTop</li>
+ <li>cmd_scrollBottom</li>
+ <li>cmd_scrollPageUp</li>
+ <li>cmd_scrollPageDown</li>
+ <li>cmd_scrollLineUp</li>
+ <li>cmd_scrollLineDown</li>
+ <li>cmd_scrollLeft</li>
+ <li>cmd_scrollRight</li>
+ <li>cmd_selectCharPrevious</li>
+ <li>cmd_selectCharNext</li>
+ <li>cmd_wordPrevious</li>
+ <li>cmd_wordNext</li>
+ <li>cmd_selectWordPrevious</li>
+ <li>cmd_selectWordNext</li>
+ <li>cmd_beginLine</li>
+ <li>cmd_endLine</li>
+ <li>cmd_selectBeginLine</li>
+ <li>cmd_selectEndLine</li>
+ <li>cmd_selectLinePrevious</li>
+ <li>cmd_selectLineNext</li>
+ <li>cmd_selectPagePrevious</li>
+ <li>cmd_selectPageNext</li>
+ <li>cmd_selectMoveTop</li>
+ <li>cmd_selectMoveBottom</li>
+</ul>
+<h4 id="Editor_commands_.28legal_when_the_focus_is_anywhere_where_you_can_type_text.29:" name="Editor_commands_.28legal_when_the_focus_is_anywhere_where_you_can_type_text.29:">Editor commands (legal when the focus is anywhere where you can type text):</h4>
+<ul>
+ <li>cmd_paste - paste a selection from the clipboard</li>
+ <li>cmd_pasteQuote</li>
+ <li>cmd_delete</li>
+ <li>cmd_deleteCharBackward</li>
+ <li>cmd_deleteCharForward</li>
+ <li>cmd_deleteWordBackward</li>
+ <li>cmd_deleteWordForward</li>
+ <li>cmd_deleteToBeginningOfLine</li>
+ <li>cmd_deleteToEndOfLine</li>
+ <li>cmd_scrollTop</li>
+ <li>cmd_scrollBottom</li>
+ <li>cmd_moveTop</li>
+ <li>cmd_moveBottom</li>
+ <li>cmd_selectTop</li>
+ <li>cmd_selectBottom</li>
+ <li>cmd_lineNext</li>
+ <li>cmd_linePrevious</li>
+ <li>cmd_selectLineNext</li>
+ <li>cmd_selectLinePrevious</li>
+ <li>cmd_charPrevious</li>
+ <li>cmd_charNext</li>
+ <li>cmd_selectCharPrevious</li>
+ <li>cmd_selectCharNext</li>
+ <li>cmd_beginLine</li>
+ <li>cmd_endLine</li>
+ <li>cmd_selectBeginLine</li>
+ <li>cmd_selectEndLine</li>
+ <li>cmd_wordPrevious</li>
+ <li>cmd_wordNext</li>
+ <li>cmd_selectWordPrevious</li>
+ <li>cmd_selectWordNext</li>
+ <li>cmd_scrollPageUp</li>
+ <li>cmd_scrollPageDown</li>
+ <li>cmd_scrollLineUp</li>
+ <li>cmd_scrollLineDown</li>
+ <li>cmd_movePageUp</li>
+ <li>cmd_movePageDown</li>
+ <li>cmd_selectPageUp</li>
+ <li>cmd_selectPageDown</li>
+</ul>
+<h4 id="Other_commands" name="Other_commands">Other commands</h4>
+<p>The following list other commands (prefixed by cmd_ or Browser:) which have not been categorized here yet (though they are in the alphabetical list below):</p>
+<ul>
+ <li><a class="external" href="http://lxr.mozilla.org/seamonkey/source/xpfe/browser/resources/content/linkToolbarOverlay.xul" rel="freelink">http://lxr.mozilla.org/seamonkey/sou...barOverlay.xul</a></li>
+ <li><a class="external" href="http://lxr.mozilla.org/seamonkey/source/xpfe/browser/resources/content/navigator.js" rel="freelink">http://lxr.mozilla.org/seamonkey/sou...t/navigator.js</a></li>
+ <li><a class="external" href="http://lxr.mozilla.org/seamonkey/source/xpfe/browser/resources/content/navigatorOverlay.xul" rel="freelink">http://lxr.mozilla.org/seamonkey/sou...torOverlay.xul</a></li>
+ <li><a class="external" href="http://lxr.mozilla.org/seamonkey/source/xpfe/browser/resources/content/personalToolbar.js" rel="freelink">http://lxr.mozilla.org/seamonkey/sou...onalToolbar.js</a></li>
+ <li><a class="external" href="http://lxr.mozilla.org/seamonkey/source/xpfe/browser/resources/content/viewSourceOverlay.xul" rel="freelink">http://lxr.mozilla.org/seamonkey/sou...rceOverlay.xul</a></li>
+ <li><a class="external" href="http://lxr.mozilla.org/seamonkey/source/xpfe/communicator/resources/content/contentAreaContextOverlay.xul" rel="freelink">http://lxr.mozilla.org/seamonkey/sou...extOverlay.xul</a></li>
+ <li><a class="external" href="http://lxr.mozilla.org/seamonkey/source/xpfe/communicator/resources/content/utilityOverlay.js" rel="freelink">http://lxr.mozilla.org/seamonkey/sou...lityOverlay.js</a></li>
+ <li><a class="external" href="http://lxr.mozilla.org/seamonkey/source/xpfe/communicator/resources/content/viewZoomOverlay.xul" rel="freelink">http://lxr.mozilla.org/seamonkey/sou...oomOverlay.xul</a></li>
+ <li><a class="external" href="http://lxr.mozilla.org/seamonkey/source/xpfe/communicator/resources/content/unix/platformCommunicatorOverlay.xul" rel="freelink">http://lxr.mozilla.org/seamonkey/sou...torOverlay.xul</a></li>
+ <li><a class="external" href="http://lxr.mozilla.org/seamonkey/source/xpfe/components/bookmarks/resources/locale/en-US/bookmark.properties" rel="freelink">http://lxr.mozilla.org/seamonkey/sou...ark.properties</a></li>
+ <li><a class="external" href="http://lxr.mozilla.org/seamonkey/source/xpfe/components/bookmarks/resources/bookmarks-temp.js" rel="freelink">http://lxr.mozilla.org/seamonkey/sou...kmarks-temp.js</a></li>
+ <li><a class="external" href="http://lxr.mozilla.org/seamonkey/source/xpfe/components/bookmarks/resources/bookmarks.xml" rel="freelink">http://lxr.mozilla.org/seamonkey/sou.../bookmarks.xml</a></li>
+ <li><a class="external" href="http://lxr.mozilla.org/seamonkey/source/xpfe/components/bookmarks/resources/bookmarksOverlay.xul" rel="freelink">http://lxr.mozilla.org/seamonkey/sou...rksOverlay.xul</a></li>
+ <li><a class="external" href="http://lxr.mozilla.org/seamonkey/source/xpfe/components/bookmarks/resources/bookmarksTree.js" rel="freelink">http://lxr.mozilla.org/seamonkey/sou...okmarksTree.js</a></li>
+</ul>
+<p> </p>
+<h3 id="List_of_commands_.28listed_alphabetically.29" name="List_of_commands_.28listed_alphabetically.29">List of commands (listed alphabetically)</h3>
+<ul>
+ <li>Browser:AddBookmark</li>
+ <li>Browser:AddBookmarkAs</li>
+ <li>Browser:AddGroupmarkAs</li>
+ <li>Browser:Back</li>
+ <li>Browser:EditPage</li>
+ <li>Browser:Find</li>
+ <li>Browser:FindAgain</li>
+ <li>Browser:FindPrev</li>
+ <li>Browser:Forward</li>
+ <li>Browser:Home</li>
+ <li>Browser:ManageBookmark</li>
+ <li>Browser:Open</li>
+ <li>Browser:OpenFile</li>
+ <li>Browser:Print</li>
+ <li>Browser:PrintPreview</li>
+ <li>Browser:SavePage</li>
+ <li>Browser:SearchInternet</li>
+ <li>Browser:SendPage</li>
+ <li>Browser:UploadFile</li>
+ <li>cmd_bm_copy</li>
+ <li>cmd_bm_cut</li>
+ <li>cmd_bm_delete</li>
+ <li>cmd_bm_expandfolder</li>
+ <li>cmd_bm_export</li>
+ <li>cmd_bm_find</li>
+ <li>cmd_bm_import</li>
+ <li>cmd_bm_managefolder</li>
+ <li>cmd_bm_movebookmark</li>
+ <li>cmd_bm_newbookmark</li>
+ <li>cmd_bm_newfolder</li>
+ <li>cmd_bm_newseparator</li>
+ <li>cmd_bm_open</li>
+ <li>cmd_bm_openinnewtab</li>
+ <li>cmd_bm_openinnewwindow</li>
+ <li>cmd_bm_paste</li>
+ <li>cmd_bm_properties</li>
+ <li>cmd_bm_rename</li>
+ <li>cmd_bm_selectAll</li>
+ <li>cmd_bm_setnewbookmarkfolder</li>
+ <li>cmd_bm_setnewsearchfolder</li>
+ <li>cmd_bm_setpersonaltoolbarfolder</li>
+ <li>cmd_bm_sortfolder</li>
+ <li>cmd_bm_sortfolderbyname</li>
+ <li>cmd_close</li>
+ <li>cmd_closeOtherTabs</li>
+ <li>cmd_closeWindow</li>
+ <li>cmd_copy</li>
+ <li>cmd_copyImage</li>
+ <li>cmd_copyLink</li>
+ <li>cmd_cut</li>
+ <li>cmd_delete</li>
+ <li>cmd_editPage</li>
+ <li>cmd_findTypeLinks</li>
+ <li>cmd_findTypeText</li>
+ <li>cmd_goToLine</li>
+ <li>cmd_handleBackspace</li>
+ <li>cmd_handleShiftBackspace</li>
+ <li>cmd_minimizeWindow</li>
+ <li>cmd_newEditor</li>
+ <li>cmd_newEditorDraft</li>
+ <li>cmd_newEditorTemplate</li>
+ <li>cmd_newNavigator</li>
+ <li>cmd_newNavigatorTab</li>
+ <li>cmd_newTabWithTarget</li>
+ <li>cmd_openHelp</li>
+ <li>cmd_paste - paste a selection from the clipboard</li>
+ <li>cmd_printSetup</li>
+ <li>cmd_quit</li>
+ <li>cmd_redo</li>
+ <li>cmd_savePage</li>
+ <li>cmd_scrollPageDown</li>
+ <li>cmd_scrollPageUp</li>
+ <li>cmd_selectAll</li>
+ <li>cmd_SwitchDocumentDirection</li>
+ <li>cmd_switchTextDirection</li>
+ <li>cmd_textZoomEnlarge</li>
+ <li>cmd_textZoomReduce</li>
+ <li>cmd_textZoomReset</li>
+ <li>cmd_undo</li>
+ <li>cmd_viewcomponentbar</li>
+ <li>cmd_viewlinktoolbar</li>
+ <li>cmd_viewlinktoolbar_false</li>
+ <li>cmd_viewlinktoolbar_maybe</li>
+ <li>cmd_viewlinktoolbar_true</li>
+ <li>cmd_viewnavbar</li>
+ <li>cmd_viewpersonaltoolbar</li>
+ <li>cmd_viewtaskbar</li>
+ <li>cmd_zoomWindow</li>
+</ul>
+<p>Thanks for help of joe.user0 in compiling: <a class="external" href="http://readlist.com/lists/mozilla.org/mozilla-general/3/15261.html" rel="freelink">http://readlist.com/lists/mozilla.or...l/3/15261.html</a> . Also obtained from <a class="external" href="http://www.mozilla.org/unix/customizing.html" rel="freelink">http://www.mozilla.org/unix/customizing.html</a></p>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/listbox/index.html b/files/zh-cn/mozilla/tech/xul/listbox/index.html
new file mode 100644
index 0000000000..04489bf06d
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/listbox/index.html
@@ -0,0 +1,480 @@
+---
+title: listbox
+slug: Mozilla/Tech/XUL/listbox
+translation_of: Archive/Mozilla/XUL/listbox
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>This element is used to create a list of items where one or more of the items may be selected. A listbox may contain multiple columns. There are numerous methods which allow the items in the listbox to be retrieved and modified.</p>
+<p>You may specify the number of rows to display in the list using the <code id="a-rows"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/rows">rows</a></code> attribute. Additional rows can be viewed using a scroll bar. A listbox is expected to contain <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listitem" title="listitem">listitem</a></code> elements. All the rows in the listbox are the same height, which is the height of the tallest item in the list. If you wish to create a list with variable height rows, or with non-text content, you should instead use the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/richlistbox" title="richlistbox">richlistbox</a></code> element.</p>
+<p>See <a href="/en/XUL_Tutorial/List_Controls" title="en/XUL_Tutorial/List_Controls">List Controls</a> for more information.</p>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-disabled">disabled</a>, <a href="#a-disableKeyNavigation">disableKeyNavigation</a>, <a href="#a-preference">preference</a>, <a href="#a-rows">rows</a>, <a href="#a-seltype">seltype</a>, <a href="#a-suppressonselect">suppressonselect</a>, <a href="#a-tabindex">tabindex</a>, <a href="#a-value">value</a></dd>
+</dl>
+<dl>
+ <dt>
+ Properties</dt>
+ <dd>
+ <a href="#p-accessibleType">accessibleType</a>, <a href="#p-listbox.currentIndex">currentIndex</a>, <a href="#p-currentItem">currentItem</a>, <a href="#p-disabled">disabled</a>, <a href="#p-disableKeyNavigation">disableKeyNavigation</a>, <a href="#p-itemCount">itemCount</a>, <a href="#p-listBoxObject">listBoxObject</a>, <a href="#p-selectedCount">selectedCount</a>, <a href="#p-selectedIndex">selectedIndex</a>, <a href="#p-selectedItem">selectedItem</a>, <a href="#p-selectedItems">selectedItems</a>, <a href="#p-selType">selType</a>, <a href="#p-suppressOnSelect">suppressOnSelect</a>, <a href="#p-tabIndex">tabIndex</a>, <a href="#p-value">value</a></dd>
+</dl>
+<dl>
+ <dt>
+ Methods</dt>
+ <dd>
+ <a href="#m-addItemToSelection">addItemToSelection</a>, <a href="#m-appendItem">appendItem</a>, <a href="#m-clearSelection">clearSelection</a>, <a href="#m-ensureElementIsVisible">ensureElementIsVisible</a>, <a href="#m-ensureIndexIsVisible">ensureIndexIsVisible</a>, <a href="#m-getIndexOfFirstVisibleRow">getIndexOfFirstVisibleRow</a>, <a href="#m-getIndexOfItem">getIndexOfItem</a>, <a href="#m-getItemAtIndex">getItemAtIndex</a>, <a href="#m-getNumberofVisibleRows">getNumberofVisibleRows</a>, <a href="#m-getRowCount">getRowCount</a>, <a href="#m-getSelectedItem">getSelectedItem</a>, <a href="#m-insertItemAt">insertItemAt</a>, <a href="#m-invertSelection">invertSelection</a>, <a href="#m-moveByOffset">moveByOffset</a>, <a href="#m-removeItemAt">removeItemAt</a>, <a href="#m-removeItemFromSelection">removeItemFromSelection</a>, <a href="#m-scrollToIndex">scrollToIndex</a>, <a href="#m-selectAll">selectAll</a>, <a href="#m-selectItem">selectItem</a>, <a href="#m-selectItemRange">selectItemRange</a>, <a href="#m-timedSelect">timedSelect</a>, <a href="#m-toggleItemSelection">toggleItemSelection</a></dd>
+</dl>
+<h3 id="Examples" name="Examples">Examples</h3>
+<div class="float-right">
+ <img alt="Image:XUL_ref_listbox.png" class="internal" src="/@api/deki/files/461/=XUL_ref_listbox.png"></div>
+<pre> &lt;listbox id="theList"&gt;
+ &lt;listitem label="Ruby"/&gt;
+ &lt;listitem label="Emerald"/&gt;
+ &lt;listitem label="Sapphire" selected="true"/&gt;
+ &lt;listitem label="Diamond"/&gt;
+ &lt;/listbox&gt;
+
+</pre>
+<p><img alt="XulListBoxMultiColumn.PNG" class="internal default" src="/@api/deki/files/4189/=XulListBoxMultiColumn.PNG"></p>
+<pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; font: normal normal normal 12px/normal 'Courier New', 'Andale Mono', monospace; color: rgb(37, 34, 29);">&lt;listbox id="theList" rows="10" width="400"&gt;
+ &lt;listhead&gt;
+ &lt;listheader label="1ct Gem" width="240"/&gt;
+ &lt;listheader label="Price" width="150"/&gt;
+ &lt;/listhead&gt;
+ &lt;listcols&gt;
+ &lt;listcol/&gt;
+ &lt;listcol flex="1"/&gt;
+ &lt;/listcols&gt;
+&lt;/listbox&gt;
+
+var theList = document.getElementById('theList ');
+ gems = [ {gem: "Ruby", Price: "$3,500 - $4,600"},
+ {gem: "Emerald", Price: "$700 - 4,250"},
+ {gem: "Blue Sapphire", Price: "$3,400 - $4,500"},
+ {gem: "Diamond", Price: "$5,600 - $16,000"} ];
+for (var i = 0; i &lt; gems.length; i++)
+ {
+ var row = document.createElement('listitem');
+ var cell = document.createElement('listcell');
+ cell.setAttribute('label', gems[i].gem);
+ row.appendChild(cell);
+
+ cell = document.createElement('listcell');
+ cell.setAttribute('label', gems[i].Price );
+ row.appendChild(cell);
+
+ theList.appendChild(row);
+ }
+</pre>
+<pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.7em; margin-left: 0px; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; font: normal normal normal 12px/normal 'Courier New', 'Andale Mono', monospace; color: rgb(37, 34, 29);"> </pre>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p> </p><div id="a-disabled">
+
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd> </dd>
+ <dd>
+ <h5 id="类型boolean">类型:<em>boolean</em></h5>
+ </dd>
+ <dd>
+ <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>
+
+ <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>
+
+ <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
+ </dd>
+</dl>
+
+<h4 id="示例:">示例:</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>
+
+<pre><code>// Disabling an element
+document.getElementById('buttonRemove').setAttribute("disabled", "true");
+
+// Enabling back an element by removing the "disabled" attribute
+document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>
+
+<p></p><div class="blockIndicator standardNote standardNoteBlock">
+ <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
+ <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
+</div><p></p>
+</div> <div id="a-disableKeyNavigation">
+
+
+<dl>
+ <dt><code id="a-disableKeyNavigation"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/disableKeyNavigation">disableKeyNavigation</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>If this attribute is not used, the user can navigate to specific items within the element by pressing keys corresponding to letters in the item's label. This is done incrementally, so typing more letters with select more specific items. This feature may be disabled by setting this attribute to <code>true</code>.</dd>
+</dl>
+</div> <div id="a-preference">
+
+
+<dl>
+ <dt><code id="a-preference"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/preference">preference</a></code></dt>
+ <dd>Type: <em>id</em></dd>
+ <dd>Connects the element to a corresponding <code><a href="/en-US/docs/Mozilla/Tech/XUL/preference" title="preference">preference</a></code>. This attribute only has any effect when used inside a <code><a href="/en-US/docs/Mozilla/Tech/XUL/prefwindow" title="prefwindow">prefwindow</a></code>. More information is available in the <a href="../../../../en/Preferences_System" rel="internal">Preferences System</a> article.</dd>
+</dl>
+</div> <div id="a-rows">
+
+<dl>
+ <dt>
+ <code id="a-rows"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/rows">rows</a></code></dt>
+ <dd>
+ Type: <em>integer</em></dd>
+ <dd>
+ The number of rows to display in the element. If the element contains more than this number of rows, a scrollbar will appear which the user can use to scroll to the other rows. To get the actual number of rows in the element, use the <span id="m-getRowCount"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/getRowCount">getRowCount</a></code></span> method.</dd>
+</dl>
+</div> <div id="a-seltype">
+
+
+<dl>
+ <dt><code id="a-seltype"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/seltype">seltype</a></code></dt>
+ <dd>Type: <em>one of the values below</em></dd>
+ <dd>Used to indicate whether multiple selection is allowed.</dd>
+ <dd>
+ <dl>
+ <dt><code>single</code></dt>
+ <dd>Only one row may be selected at a time. (Default in <code>listbox</code> and <code>richlistbox</code>.)</dd>
+ <dt><code>multiple</code></dt>
+ <dd>Multiple rows may be selected at once. (Default in <code>tree</code>.)</dd>
+ </dl>
+ </dd>
+ <dd>
+ <p>For trees, you can also use the following values:</p>
+
+ <dl>
+ <dt><code>cell</code></dt>
+ <dd>Individual cells can be selected </dd>
+ <dt><code>text</code></dt>
+ <dd>Rows are selected; however, the selection highlight appears only over the text of the primary column.</dd>
+ </dl>
+
+ <p>For <code>richlistbox</code>, this is new in Firefox 3.5.</p>
+ </dd>
+</dl>
+</div> <div id="a-suppressonselect">
+
+
+<dl>
+ <dt><code id="a-suppressonselect"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/suppressonselect">suppressonselect</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>If this attribute is not specified, a select event is fired whenever an item is selected, either by the user or by calling one of the select methods. If set to <code>true</code>, the select event is never fired.</dd>
+</dl>
+</div> <div id="a-tabindex">
+
+
+<dl>
+ <dt><code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code></dt>
+ <dd>Type:<em>integer</em></dd>
+ <dd>当用户按下 "<kbd>tab</kbd>" 键时焦点移动到元素上的顺序。<code>tabindex</code> 数字越大,顺序越靠后。</dd>
+</dl>
+
+
+
+<p></p>
+</div> <div id="a-value">
+
+<dl>
+ <dt>
+ <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ The string attribute allows you to associate a data value with an element. It is not used for any specific purpose, but you can access it with a script for your own use.</dd>
+</dl>
+
+<p></p>
+</div><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p> </p><div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-listbox.currentIndex">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/listbox.currentIndex">currentIndex</a></span></code></dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>Set to the index of the currently focused item in the list. If no item is focused, the value will be <code>-1</code>. (or, on some platforms, <code>typeof(listboxcurrentIndex)</code> will be <code>undefined</code>) In a single selection list, the current index will always be the same as the selected index. In a multiple selection list, the currently focused row may be modified by the user without changing the selection by pressing the Control key and pressing the cursor keys to navigate.</dd>
+</dl></div> <div id="p-currentItem">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/currentItem">currentItem</a></span></code></dt>
+ <dd>Type: <em>listitem element</em></dd>
+ <dd>Returns the currently focused item in the list box, which is only useful in a multiple selection list box.</dd>
+</dl></div> <div id="p-disabled">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/disabled">disabled</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-disableKeyNavigation">
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/disableKeyNavigation">disableKeyNavigation</a></span></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>Gets or sets the value of the <code id="a-disableKeyNavigation"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/disableKeyNavigation">disableKeyNavigation</a></code> attribute.</dd>
+</dl></div> <div id="p-itemCount">
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/itemCount">itemCount</a></span></code> </dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>Read only property holding the number of child items.</dd>
+</dl>
+</div> <div id="p-listBoxObject">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/listBoxObject">listBoxObject</a></span></code></dt>
+ <dd>
+ Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIListBoxObject" title="">nsIListBoxObject</a></code></em></dd>
+ <dd>
+ The <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIListBoxObject" title="">nsIListBoxObject</a></code> behind the list box. This property is read-only. Most of the features of the list box are already available directly in the <code><a href="/en-US/docs/Mozilla/Tech/XUL/listbox" title="listbox">listbox</a></code>, so you will rarely have need to use this box object directly.</dd>
+</dl></div> <div id="p-selectedCount">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/selectedCount">selectedCount</a></span></code></dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>Returns the number of items that are currently selected.</dd>
+</dl></div> <div id="p-selectedIndex">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ Returns the index of the currently selected item. You may select an item by assigning its index to this property. By assigning <code>-1</code> to this property, all items will be deselected.</dd>
+</dl>
+
+<p></p></div> <div id="p-selectedItem">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedItem">selectedItem</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ element</i>
+ </dd>
+ <dd>
+ Holds the currently selected item. If no item is currently selected, this value will be <code>null</code>. You can select an item by setting this value. A select event will be sent to the element when it is changed either via this property, the <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code> property, or changed by the user.</dd>
+</dl>
+
+<p></p></div> <div id="p-selectedItems">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/selectedItems">selectedItems</a></span></code></dt>
+ <dd>Type: <em>array of listitems</em></dd>
+ <dd>Returns an array of the selected items in the list.</dd>
+</dl></div> <div id="p-selType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/selType">selType</a></span></code> </dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ Gets and sets the value of the <code id="a-seltype"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/seltype">seltype</a></code> attribute.</dd>
+</dl>
+<p> </p></div> <div id="p-suppressOnSelect">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/suppressOnSelect">suppressOnSelect</a></span></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>Gets and sets the value of the <code id="a-suppressonselect"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/suppressonselect">suppressonselect</a></code> attribute.</dd>
+</dl></div> <div id="p-tabIndex">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tabIndex">tabIndex</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-value">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/value">value</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code> attribute.</dd>
+</dl>
+
+<p></p></div><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0 0 10px 10px; padding: 0 10px; background: rgb(238, 238, 238); float: right; width: 250px;">
+<tbody>
+<tr>
+<td>
+<p><strong>Inherited Methods</strong><br>
+<small><code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.cloneNode">cloneNode()</a></code>, <a href="/En/DOM/Node.compareDocumentPosition" title="En/DOM/Node.compareDocumentPosition">compareDocumentPosition</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getBoundingClientRect">getBoundingClientRect()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getClientRects">getClientRects()</a></code>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span>, <span id="m-getElementsByAttributeNS"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttributeNS">getElementsByAttributeNS</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByClassName">getElementsByClassName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getFeature">getFeature()</a></code>, <a href="/En/DOM/Node.getUserData" title="En/DOM/Node.getUserData">getUserData</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isDefaultNamespace">isDefaultNamespace()</a></code>, <a href="/En/DOM/Node.isEqualNode" title="En/DOM/Node.isEqualNode">isEqualNode</a>, <a href="/En/DOM/Node.isSameNode" title="En/DOM/Node.isSameNode">isSameNode</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <a href="/En/DOM/Node.lookupNamespaceURI" title="En/DOM/Node.lookupNamespaceURI">lookupNamespaceURI</a>, <a href="/En/DOM/Node.lookupPrefix" title="En/DOM/Node.lookupPrefix">lookupPrefix</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.querySelector">querySelector()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.querySelectorAll">querySelectorAll()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code>, <a href="/En/DOM/Node.setUserData" title="En/DOM/Node.setUserData">setUserData</a></small></p>
+
+</td>
+</tr>
+</tbody>
+</table> <dl>
+ <dt><span id="m-addItemToSelection"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/addItemToSelection">addItemToSelection( item )</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Selects the given <var>item</var>, without deselecting any other items that are already selected.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-appendItem"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/appendItem">appendItem( label, value )</a></code></span></dt>
+ <dd>
+ Return type: <em>element</em></dd>
+ <dd>
+ Creates a new item and adds it to the end of the existing list of items. You may optionally set a value. The function returns the newly created element.</dd>
+</dl> <dl>
+ <dt><span id="m-clearSelection"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/clearSelection">clearSelection()</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Deselects all of the items.  A select event is sent before the items are deselected.</dd>
+</dl> <dl>
+ <dt><span id="m-ensureElementIsVisible"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/ensureElementIsVisible">ensureElementIsVisible( element )</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>If the specified element is not currently visible to the user, the displayed items are scrolled so that it is. If the item is already visible, no scrolling occurs.</dd>
+</dl> <dl>
+ <dt><span id="m-ensureIndexIsVisible"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/ensureIndexIsVisible">ensureIndexIsVisible( index )</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>If the item at the specified index is not currently visible to the user the displayed items are scrolled so that it is. If the item is already visible, no scrolling occurs.</dd>
+</dl> <dl>
+ <dt><span id="m-getIndexOfFirstVisibleRow"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/getIndexOfFirstVisibleRow">getIndexOfFirstVisibleRow()</a></code></span></dt>
+ <dd>Return type: <em>integer</em></dd>
+ <dd>Returns the index of the first displayed row. Note that this is not the same as the first row -- if the displayed items have been scrolled down, this function will retrieve the index of the first row that the user can see.</dd>
+</dl> <dl>
+ <dt><span id="m-getIndexOfItem"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/getIndexOfItem">getIndexOfItem( item )</a></code></span></dt>
+ <dd>Return type: <em>integer</em></dd>
+ <dd>Returns the zero-based position of the specified item. Items are numbered starting at the first item displayed in the list.</dd>
+</dl> <dl>
+ <dt><span id="m-getItemAtIndex"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/getItemAtIndex">getItemAtIndex( index )</a></code></span></dt>
+ <dd>Return type: <em>element</em></dd>
+ <dd>Returns the element that is at the specified index.</dd>
+</dl> <dl>
+ <dt><span id="m-getNumberOfVisibleRows"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/getNumberOfVisibleRows">getNumberOfVisibleRows()</a></code></span></dt>
+ <dd>Return type: <em>integer</em></dd>
+ <dd>Returns the number of rows that are currently visible to the user.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-getRowCount"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/getRowCount">getRowCount()</a></code></span></dt>
+ <dd>
+ Return type: <em>integer</em></dd>
+ <dd>
+ Returns the total number of rows in the element, regardless of how many rows are displayed.</dd>
+</dl> <dl>
+ <dt><span id="m-getSelectedItem"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/getSelectedItem">getSelectedItem( index )</a></code></span></dt>
+ <dd>Return type: <em>element</em></dd>
+ <dd>When multiple items are selected, you can retrieve each selected item using this method. The argument <var>index</var> specifies the index in the list of the selected items, not the row number of the item. The item index is zero-based, thus this example will return the first selected item: <code>getSelectedItem(0)</code>.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-insertItemAt"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/insertItemAt">insertItemAt( index, label, value )</a></code></span></dt>
+ <dd>
+ Return type: <em>element</em></dd>
+ <dd>
+ This method creates a new item and inserts it at the specified position. You may optionally set a value. The new item element is returned.</dd>
+</dl> <dl>
+ <dt><span id="m-invertSelection"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/invertSelection">invertSelection()</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Reverses the selected state of all items. Selected items become deselected, and deselected items become selected.</dd>
+</dl> <dl>
+ <dt><span id="m-moveByOffset"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/moveByOffset">moveByOffset( offset , isSelecting, isSelectingRange)</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>If <code>offset</code> is positive, adjusts the focused item forward by that many items. If <code>offset</code> is negative, adjusts the focused item backward by that many items. If <code>isSelecting</code> is <code>true</code>, then the selection is also adjusted. If <code>isSelectingRange</code> is also <code>true</code>, then the new item is selected in addition to any currently selected items. If <code>isSelectingRange</code> is <code>false</code>, any existing selection is cleared. Items that are hidden are skipped.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-removeItemAt"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/removeItemAt">removeItemAt( index )</a></code></span></dt>
+ <dd>
+ Return type: <em>element</em></dd>
+ <dd>
+ Removes the child item in the element at the specified index. The method returns the removed item.</dd>
+</dl> <dl>
+ <dt><span id="m-removeItemFromSelection"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/removeItemFromSelection">removeItemFromSelection( item )</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Deselects the specified item without deselecting other items.</dd>
+</dl> <dl>
+ <dt><span id="m-scrollToIndex"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/scrollToIndex">scrollToIndex( index )</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Scrolls the element to the specified index. This is different than <span id="m-ensureIndexIsVisible"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/ensureIndexIsVisible">ensureIndexIsVisible</a></code></span> because the view is always scrolled.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-selectAll"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/selectAll">selectAll()</a></code></span></dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+ <dd>
+ Selects all of the items. A select event is sent after the selection is made.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-selectItem"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/selectItem">selectItem( item )</a></code></span></dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+ <dd>
+ Deselects all of the currently selected items and selects the given item. A select event is sent after the selection is made.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-selectItemRange"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/selectItemRange">selectItemRange( startItem, endItem )</a></code></span></dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+ <dd>
+ Selects the items between the two items given as arguments, including the start and end items. All other items are deselected. This method does nothing for single-selection list boxes. A select event is sent after the selection is made.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-timedSelect"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/timedSelect">timedSelect( item, timeout )</a></code></span></dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+ <dd>
+ Selects the item specified by the argument item after the number of milliseconds given by the timeout argument. All other items are deselected.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-toggleItemSelection"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/toggleItemSelection">toggleItemSelection( item )</a></code></span></dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+ <dd>
+ If the specified item is selected, it is deselected. If it is not selected, it is selected. Other items in the list box that are selected are not affected, and retain their selected state.</dd>
+</dl><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<dl>
+ <dt>
+ Elements</dt>
+ <dd>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listcell" title="listcell">listcell</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listcol" title="listcol">listcol</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listcols" title="listcols">listcols</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listhead" title="listhead">listhead</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listheader" title="listheader">listheader</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listitem" title="listitem">listitem</a></code></dd>
+</dl>
+<dl>
+ <dt>
+ Interfaces</dt>
+ <dd>
+ <a href="/en/XPCOM_Interface_Reference/nsIAccessibleProvider" title="en/nsIAccessibleProvider">nsIAccessibleProvider</a>, <a href="/en/NsIDOMXULMultiSelectControlElement" title="en/NsIDOMXULMultiSelectControlElement">nsIDOMXULMultiSelectControlElement</a></dd>
+</dl>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/listheader/index.html b/files/zh-cn/mozilla/tech/xul/listheader/index.html
new file mode 100644
index 0000000000..d71bcb6e83
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/listheader/index.html
@@ -0,0 +1,180 @@
+---
+title: listheader
+slug: Mozilla/Tech/XUL/listheader
+translation_of: Archive/Mozilla/XUL/listheader
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>A header for a single column in a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listbox" title="listbox">listbox</a></code>.</p>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-disabled">disabled</a></dd>
+</dl>
+<dl>
+ <dt>
+ Properties</dt>
+ <dd>
+ <a href="#p-acesssibleType">acesssibleType</a></dd>
+</dl>
+<h3 id="Examples" name="Examples">Examples</h3>
+<div class="float-right">
+ <img alt="Image:XUL_ref_listheader.png" class="internal" src="/@api/deki/files/463/=XUL_ref_listheader.png"></div>
+<pre>&lt;listbox&gt;
+ &lt;listhead&gt;
+ &lt;listheader label="Name"/&gt;
+ &lt;listheader label="Occupation"/&gt;
+ &lt;/listhead&gt;
+ &lt;listitem&gt;
+ &lt;listcell label="George"/&gt;
+ &lt;listcell label="House Painter"/&gt;
+ &lt;/listitem&gt;
+ &lt;listitem&gt;
+ &lt;listcell label="Mary Ellen"/&gt;
+ &lt;listcell label="Candle Maker"/&gt;
+ &lt;/listitem&gt;
+ &lt;listitem&gt;
+ &lt;listcell label="Roger"/&gt;
+ &lt;listcell label="Swashbuckler"/&gt;
+ &lt;/listitem&gt;
+&lt;/listbox&gt;
+</pre>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p></p><div id="a-disabled">
+
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd> </dd>
+ <dd>
+ <h5 id="类型boolean">类型:<em>boolean</em></h5>
+ </dd>
+ <dd>
+ <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>
+
+ <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>
+
+ <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
+ </dd>
+</dl>
+
+<h4 id="示例:">示例:</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>
+
+<pre><code>// Disabling an element
+document.getElementById('buttonRemove').setAttribute("disabled", "true");
+
+// Enabling back an element by removing the "disabled" attribute
+document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>
+
+<p></p><div class="blockIndicator standardNote standardNoteBlock">
+ <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
+ <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
+</div><p></p>
+</div> <div id="a-label">
+
+<dl>
+ <dt>
+ <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The label that will appear on the element. If this is left out, no text appears.<br>
+ label 在元素上显示。如果左侧出界,则不显示任何文字。</dd>
+</dl>
+
+<p></p>
+</div> <table style="border: 1px solid rgb(204, 204, 204); margin: 0 0 10px 10px; padding: 0 10px; background: rgb(238, 238, 238);">
+<tbody>
+<tr>
+<td><p><strong>Inherited from XUL element</strong><br> <small>
+<code id="a-align"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/align">align</a></code>,
+<code id="a-allowevents"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allowevents">allowevents</a></code>,
+<code id="a-allownegativeassertions"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allownegativeassertions">allownegativeassertions</a></code>,
+<code id="a-class"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/class">class</a></code>,
+<code id="a-coalesceduplicatearcs"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/coalesceduplicatearcs">coalesceduplicatearcs</a></code>,
+<code id="a-collapsed"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/collapsed">collapsed</a></code>,
+<code id="a-container"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/container">container</a></code>,
+<code id="a-containment"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/containment">containment</a></code>,
+<code id="a-context"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/context">context</a></code>,
+<code id="a-contextmenu"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/contextmenu">contextmenu</a></code>,
+<code id="a-datasources"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/datasources">datasources</a></code>,
+<code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code>,
+<code id="a-empty"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/empty">empty</a></code>,
+<code id="a-equalsize"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/equalsize">equalsize</a></code>,
+<code id="a-flags"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flags">flags</a></code>,
+<code id="a-flex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flex">flex</a></code>,
+<code id="a-height"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/height">height</a></code>,
+<code id="a-hidden"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/hidden">hidden</a></code>,
+<code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code>,
+<code id="a-insertafter"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/insertafter">insertafter</a></code>,
+<code id="a-insertbefore"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/insertbefore">insertbefore</a></code>,
+<code id="a-left"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/left">left</a></code>,
+<code id="a-maxheight"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/maxheight">maxheight</a></code>,
+<code id="a-maxwidth"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/maxwidth">maxwidth</a></code>,
+<code id="a-menu"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/menu">menu</a></code>,
+<code id="a-minheight"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/minheight">minheight</a></code>,
+<code id="a-minwidth"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/minwidth">minwidth</a></code>,
+<code id="a-mousethrough"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/mousethrough">mousethrough</a></code>,
+<code id="a-observes"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/observes">observes</a></code>,
+<code id="a-ordinal"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/ordinal">ordinal</a></code>,
+<code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code>,
+<code id="a-pack"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/pack">pack</a></code>,
+<code id="a-persist"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/persist">persist</a></code>,
+<code id="a-popup"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/popup">popup</a></code>,
+<code id="a-position"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/position">position</a></code>,
+<code id="a-preference-editable"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/preference-editable">preference-editable</a></code>,
+<code id="a-querytype"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/querytype">querytype</a></code>,
+<code id="a-ref"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/ref">ref</a></code>,
+<code id="a-removeelement"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/removeelement">removeelement</a></code>,
+<code id="a-sortDirection"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortDirection">sortDirection</a></code>,
+<code id="a-sortResource"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortResource">sortResource</a></code>,
+<code id="a-sortResource2"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortResource2">sortResource2</a></code>,
+<code id="a-statustext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/statustext">statustext</a></code>,
+<code id="a-style"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/style">style</a></code>,
+<code id="a-template"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/template">template</a></code>,
+<code id="a-tooltip"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tooltip">tooltip</a></code>,
+<code id="a-tooltiptext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tooltiptext">tooltiptext</a></code>,
+<code id="a-top"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/top">top</a></code>,
+<code id="a-uri"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/uri">uri</a></code>,
+<code id="a-wait-cursor"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/wait-cursor">wait-cursor</a></code>,
+<code id="a-width"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/width">width</a></code> </small></p>
+</td>
+</tr>
+</tbody>
+</table><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p></p><div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited Properties</strong><br> <small> <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/align">align</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/allowEvents">allowEvents</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/boxObject">boxObject</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/builder">builder</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/className">className</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/collapsed">collapsed</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/contextMenu">contextMenu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/controllers">controllers</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/database">database</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/datasources">datasources</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/dir">dir</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/flex">flex</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/height">height</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/hidden">hidden</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/id">id</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/left">left</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxHeight">maxHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxWidth">maxWidth</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menu">menu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minHeight">minHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minWidth">minWidth</a></span></code>, , , , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/observes">observes</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ordinal">ordinal</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/orient">orient</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/pack">pack</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/persist">persist</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ref">ref</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/resource">resource</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/statusText">statusText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/style">style</a></span></code>, ,, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltip">tooltip</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltipText">tooltipText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/top">top</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/width">width</a></span></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<dl>
+ <dt>
+ Elements</dt>
+ <dd>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listbox" title="listbox">listbox</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listcell" title="listcell">listcell</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listcol" title="listcol">listcol</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listcols" title="listcols">listcols</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listhead" title="listhead">listhead</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listitem" title="listitem">listitem</a></code></dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/menu/index.html b/files/zh-cn/mozilla/tech/xul/menu/index.html
new file mode 100644
index 0000000000..b204dcf14b
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/menu/index.html
@@ -0,0 +1,370 @@
+---
+title: menu
+slug: Mozilla/Tech/XUL/menu
+tags:
+ - XUL Elements
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/menu
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>An element, much like a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/button" title="button">button</a></code>, that is placed on a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menubar" title="menubar">menubar</a></code>. When the user clicks the <code>menu</code> element, the child <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code> of the menu will be displayed. This element is also used to create submenus.</p>
+<p>More information is available in the <a href="cn/XUL_Tutorial/Simple_Menu_Bars">XUL tutorial</a>.</p>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-acceltext">acceltext</a>, <a href="#a-accesskey">accesskey</a>, <a href="#a-allowevents">allowevents</a>, <a href="#a-command">command</a>, <a href="#a-crop">crop</a>, <a href="#a-disabled">disabled</a>, <a href="#a-image">image</a>, <a href="#a-label">label</a>, <a href="#a-menuactive">menuactive</a>, <a href="#a-open">open</a>, <a href="#a-sizetopopup">sizetopopup</a>, <a href="#a-tabindex">tabindex</a>, <a href="#a-value">value</a></dd>
+</dl>
+<dl>
+ <dt>
+ Properties</dt>
+ <dd>
+ <a href="#p-accessibleType">accessibleType</a>, <a href="#p-accessKey">accessKey</a>, <a href="#p-command">command</a>, <a href="#p-menuitem.control">control</a>, <a href="#p-crop">crop</a>, <a href="#p-disabled">disabled</a>, <a href="#p-image">image</a>, <a href="#p-itemCount">itemCount</a>, <a href="#p-label">label</a>, <a href="#p-labelElement">labelElement</a>, <a href="#p-menupopup">menupopup</a>, <a href="#p-menu.open">open</a>, <a href="#p-parentContainer">parentContainer</a>, <a href="#p-selected">selected</a>, <a href="#p-tabIndex">tabIndex</a>, <a href="#p-value">value</a></dd>
+</dl>
+<dl>
+ <dt>
+ Methods</dt>
+ <dd>
+ <a href="#m-appendItem">appendItem</a>, <a href="#m-getIndexOfItem">getIndexOfItem</a>, <a href="#m-getItemAtIndex">getItemAtIndex</a>, <a href="#m-insertItemAt">insertItemAt</a>, <a href="#m-removeItemAt">removeItemAt</a></dd>
+</dl>
+<h3 id="Example" name="Example">Example</h3>
+<pre> &lt;menubar id="sample-menubar"&gt;
+ &lt;menu id="file-menu" label="File"&gt;
+ &lt;menupopup id="file-popup"&gt;
+ &lt;menuitem label="New"/&gt;
+ &lt;menuitem label="Open"/&gt;
+ &lt;menuitem label="Save"/&gt;
+ &lt;menuseparator/&gt;
+ &lt;menuitem label="Exit"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menu&gt;
+ &lt;menu id="edit-menu" label="Edit"&gt;
+ &lt;menupopup id="edit-popup"&gt;
+ &lt;menuitem label="Undo"/&gt;
+ &lt;menuitem label="Redo"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menu&gt;
+ &lt;/menubar&gt;
+</pre>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p> </p><div id="a-acceltext">
+
+<dl>
+ <dt>
+ <code id="a-acceltext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/acceltext">acceltext</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Text that appears beside beside the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> label to indicate the shortcut key (accelerator key) to use to invoke the command. If this value is set, it overrides an assigned key set in the key attribute. This attribute does not apply to menus directly on the menubar.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-accesskey">
+
+
+
+
+<dl>
+ <dt><code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code></dt>
+ <dd>类型:
+ <i>character【字符】</i>
+ </dd>
+ <dd>本属性允许为控件(元素)设定一个字符作为快捷键,这个字符应该是 <code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code> 属性文本中的一个字符。该字符将会被加下划线以重点强调,平台和主体的变换并不影响这一表现行为。 当用户点击 ALT (在其他平台上具有类似功能的键) 和这个字符对应的按键时, 控件(元素)将立刻被从窗口中的某处激活或/并且获得焦点 <b>。虽说字符不分大小写,但是当label中存在大写字符和小写字符时,快捷键的字符将首先选择与之完全匹配的那一个,如果label中存在两个或更多的与accesskey字符相同的字符,其中的第一个字符将被加下划线。</b></dd>
+ <dt>      *(有些键在监听按键事件时,分别对应event.ctrlKey和event.metaKey。)</dt>
+</dl>
+
+<p> </p>
+
+<h4 id="Example" name="Example">Example</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_accesskey_attr.png"></div>
+
+<pre>&lt;vbox&gt;
+ &lt;label value="Enter Name" accesskey="e" control="myName"/&gt;
+ &lt;textbox id="myName"/&gt;
+ &lt;button label="Cancel" accesskey="n"/&gt;
+ &lt;button label="Ok" accesskey="O"/&gt;
+&lt;/vbox&gt;
+</pre>
+
+<h4 id="See_also" name="See_also">See also</h4>
+
+<p><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute, <code id="a-acceltext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/acceltext">acceltext</a></code> attribute</p>
+
+<p></p>
+</div> <div id="a-allowevents">
+
+
+<dl>
+ <dt><code id="a-allowevents"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allowevents">allowevents</a></code></dt>
+ <dd>Type:
+ <i>boolean<br>
+ </i>
+ 类型:boolean</dd>
+ <dd>If true, events are passed to children of the element. Otherwise, events are passed to the element only.<br>
+ 如果为真,事件向子元素传递。否则,事件只传递到当前元素。</dd>
+</dl>
+
+
+
+<p></p>
+</div> <div id="a-crop">
+
+<dl>
+ <dt>
+ <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ one of the values below</i>
+ </dd>
+ <dd>
+ If the label of the element is too big to fit in its given space, the text will be cropped on the side specified by the <code>crop</code> attribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.</dd>
+</dl>
+<ul>
+ <li><code>start</code>: The text will be cropped on its left side.</li>
+ <li><code>end</code>: The text will be cropped on its right side.</li>
+ <li><code>left</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its left side.</li>
+ <li><code>right</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its right side.</li>
+ <li><code>center</code>: The text will be cropped in the middle, showing both the start and end of the text normally.</li>
+ <li><code>none</code>: The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.</li>
+</ul>
+
+<p></p>
+</div> <div id="a-disabled">
+
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd> </dd>
+ <dd>
+ <h5 id="类型boolean">类型:<em>boolean</em></h5>
+ </dd>
+ <dd>
+ <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>
+
+ <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>
+
+ <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
+ </dd>
+</dl>
+
+<h4 id="示例:">示例:</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>
+
+<pre><code>// Disabling an element
+document.getElementById('buttonRemove').setAttribute("disabled", "true");
+
+// Enabling back an element by removing the "disabled" attribute
+document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>
+
+<p></p><div class="blockIndicator standardNote standardNoteBlock">
+ <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
+ <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
+</div><p></p>
+</div> <div id="a-label">
+
+<dl>
+ <dt>
+ <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The label that will appear on the element. If this is left out, no text appears.<br>
+ label 在元素上显示。如果左侧出界,则不显示任何文字。</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-menuactive">
+
+
+<dl>
+ <dt><code id="a-menuactive"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/menuactive">menuactive</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>This attribute is set on an item in a menu when it is being hovered over. Typcially, the theme will use this to highlight the item. A <code>DOMMenuItemActive</code> event will be sent to the item when the item is hovered over, and a <code>DOMMenuItemInactive</code> event will be sent to the item when the selection moves away.</dd>
+</dl>
+</div> <div id="a-open">
+
+
+<dl>
+ <dt><code id="a-open"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/open">open</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>For the <code>menu</code> <code id="a-type"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/type">type</a></code> buttons, the <code>open</code> attribute is set to <code>true</code> when the menu is open. The <code>open</code> attribute is not present if the menu is closed.</dd>
+</dl>
+</div> <div id="a-sizetopopup">
+
+
+<dl>
+ <dt><code id="a-sizetopopup"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/sizetopopup">sizetopopup</a></code></dt>
+ <dd>Type: <em>one of the values below</em></dd>
+ <dd>Indicates how the menu width and the <code><a href="/en-US/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code> width are determined. If the <code>sizetopopup</code> attribute is left out or set to <code>none</code>, the menu will be its preferred width and the popup may extend outside of this width, unaffected by the maximum width of the menu itself. Otherwise, the menu will size itself to at least the size of the popup. If the menu has a maximum width, the popup will also be this width.</dd>
+ <dd>
+ <dl>
+ <dt><code>none</code></dt>
+ <dd>The width of the popup will not be constrained to the size of the menu.</dd>
+ <dt><code>pref</code></dt>
+ <dd>The preferred width of the menu label or button will be the size needed for the popup contents. This is the default value for menulists.</dd>
+ <dt><code>always</code></dt>
+ <dd>Both the preferred and minimum width of the menu label or button will be the same as that necessary for the <code><a href="/en-US/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code>.</dd>
+ </dl>
+ </dd>
+</dl>
+</div> <div id="a-value">
+
+<dl>
+ <dt>
+ <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ The string attribute allows you to associate a data value with an element. It is not used for any specific purpose, but you can access it with a script for your own use.</dd>
+</dl>
+
+<p></p>
+</div><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p> </p><div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-menuitem.control">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menuitem.control">control</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> element</i>
+ </dd>
+ <dd>
+ Returns the enclosing <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> that the item is inside, if any, or <code>null</code> if there is no enclosing menu.</dd>
+</dl>
+
+<p></p></div> <div id="p-itemCount">
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/itemCount">itemCount</a></span></code> </dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>Read only property holding the number of child items.</dd>
+</dl>
+</div> <div id="p-menupopup">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/menupopup">menupopup</a></span></code></dt>
+ <dd>Type: <em>menupopup element</em></dd>
+ <dd>A reference to the <code><a href="/en-US/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code> used by the <code><a href="/en-US/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> or <code><a href="/en-US/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code>. This property is read-only.</dd>
+</dl></div> <div id="p-menu.open">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/menu.open">open</a></span></code> </dt>
+ <dd>
+ Type: <em>boolean</em></dd>
+ <dd>
+ This property will be set to true when the menu is open. The menu may be opened by setting the open property to true and closed by setting it to false.</dd>
+</dl></div> <div id="p-parentContainer">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/parentContainer">parentContainer</a></span></code> </dt>
+ <dd>
+ Type:
+ <i>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> element</i>
+ </dd>
+ <dd>
+ Read only property that returns the containing <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> element, or <code>null</code> if there isn't a containing menu.</dd>
+</dl>
+
+<p></p></div> <div id="p-value">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/value">value</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code> attribute.</dd>
+</dl>
+
+<p></p></div><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0 0 10px 10px; padding: 0 10px; background: rgb(238, 238, 238); float: right; width: 250px;">
+<tbody>
+<tr>
+<td>
+<p><strong>Inherited Methods</strong><br>
+<small><code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.cloneNode">cloneNode()</a></code>, <a href="/En/DOM/Node.compareDocumentPosition" title="En/DOM/Node.compareDocumentPosition">compareDocumentPosition</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getBoundingClientRect">getBoundingClientRect()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getClientRects">getClientRects()</a></code>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span>, <span id="m-getElementsByAttributeNS"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttributeNS">getElementsByAttributeNS</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByClassName">getElementsByClassName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getFeature">getFeature()</a></code>, <a href="/En/DOM/Node.getUserData" title="En/DOM/Node.getUserData">getUserData</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isDefaultNamespace">isDefaultNamespace()</a></code>, <a href="/En/DOM/Node.isEqualNode" title="En/DOM/Node.isEqualNode">isEqualNode</a>, <a href="/En/DOM/Node.isSameNode" title="En/DOM/Node.isSameNode">isSameNode</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <a href="/En/DOM/Node.lookupNamespaceURI" title="En/DOM/Node.lookupNamespaceURI">lookupNamespaceURI</a>, <a href="/En/DOM/Node.lookupPrefix" title="En/DOM/Node.lookupPrefix">lookupPrefix</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.querySelector">querySelector()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.querySelectorAll">querySelectorAll()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code>, <a href="/En/DOM/Node.setUserData" title="En/DOM/Node.setUserData">setUserData</a></small></p>
+
+</td>
+</tr>
+</tbody>
+</table> <dl>
+ <dt>
+ <span id="m-appendItem"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/appendItem">appendItem( label, value )</a></code></span></dt>
+ <dd>
+ Return type: <em>element</em></dd>
+ <dd>
+ Creates a new item and adds it to the end of the existing list of items. You may optionally set a value. The function returns the newly created element.</dd>
+</dl> <dl>
+ <dt><span id="m-getIndexOfItem"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/getIndexOfItem">getIndexOfItem( item )</a></code></span></dt>
+ <dd>Return type: <em>integer</em></dd>
+ <dd>Returns the zero-based position of the specified item. Items are numbered starting at the first item displayed in the list.</dd>
+</dl> <dl>
+ <dt><span id="m-getItemAtIndex"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/getItemAtIndex">getItemAtIndex( index )</a></code></span></dt>
+ <dd>Return type: <em>element</em></dd>
+ <dd>Returns the element that is at the specified index.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-insertItemAt"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/insertItemAt">insertItemAt( index, label, value )</a></code></span></dt>
+ <dd>
+ Return type: <em>element</em></dd>
+ <dd>
+ This method creates a new item and inserts it at the specified position. You may optionally set a value. The new item element is returned.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-removeItemAt"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/removeItemAt">removeItemAt( index )</a></code></span></dt>
+ <dd>
+ Return type: <em>element</em></dd>
+ <dd>
+ Removes the child item in the element at the specified index. The method returns the removed item.</dd>
+</dl><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<dl>
+ <dt>
+ Elements</dt>
+ <dd>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menubar" title="menubar">menubar</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuseparator" title="menuseparator">menuseparator</a></code></dd>
+</dl>
+<dl>
+ <dt>
+ Interfaces</dt>
+ <dd>
+ <a href="cn/NsIAccessibleProvider">nsIAccessibleProvider</a>, <a href="cn/NsIDOMXULContainerElement">nsIDOMXULContainerElement</a>, <a href="cn/NsIDOMXULContainerItemElement">nsIDOMXULContainerItemElement</a>, <a href="cn/NsIDOMXULSelectControlItemElement">nsIDOMXULSelectControlItemElement</a></dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/menubar/index.html b/files/zh-cn/mozilla/tech/xul/menubar/index.html
new file mode 100644
index 0000000000..d7946debf9
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/menubar/index.html
@@ -0,0 +1,113 @@
+---
+title: menubar
+slug: Mozilla/Tech/XUL/menubar
+tags:
+ - XUL Elements
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/menubar
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>A container that usually contains <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> elements. On the Macintosh, the menubar is displayed along the top of the screen, and all non-menu related elements inside the menubar will be ignored.</p>
+<p>More information is available in the <a href="cn/XUL_Tutorial/Simple_Menu_Bars">XUL tutorial</a>.</p>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-grippyhidden">grippyhidden</a>, <a href="#a-statusbar">statusbar</a></dd>
+</dl>
+<dl>
+ <dt>
+ Properties</dt>
+ <dd>
+ <a href="#p-accessibleType">accessibleType</a>, <a href="#p-statusbar">statusbar</a></dd>
+</dl>
+<h3 id="Examples" name="Examples">Examples</h3>
+<div class="float-right">
+ <img alt="Image:XUL_ref_menu.png"></div>
+<pre>&lt;menubar id="sample-menubar"&gt;
+ &lt;menu id="action-menu" label="Action"&gt;
+ &lt;menupopup id="action-popup"&gt;
+ &lt;menuitem label="New"/&gt;
+ &lt;menuitem label="Save" disabled="true"/&gt;
+ &lt;menuitem label="Close"/&gt;
+ &lt;menuseparator/&gt;
+ &lt;menuitem label="Quit"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menu&gt;
+ &lt;menu id="edit-menu" label="Edit"&gt;
+ &lt;menupopup id="edit-popup"&gt;
+ &lt;menuitem label="Undo"/&gt;
+ &lt;menuitem label="Redo"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menu&gt;
+&lt;/menubar&gt;
+</pre>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p> </p><div id="a-grippyhidden">
+
+
+<dl>
+ <dt><code id="a-grippyhidden"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/grippyhidden">grippyhidden</a></code></dt>
+ <dd><strong><span class="highlightred">SeaMonkey only</span></strong></dd>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>When set to <code>true</code>, the grippy will be hidden. When set to <code>false</code>, the default, the grippy will be shown.</dd>
+</dl>
+</div> <div id="a-statusbar">
+
+
+<dl>
+ <dt><code id="a-statusbar"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/statusbar">statusbar</a></code></dt>
+ <dd>Type: <em>id</em></dd>
+ <dd>If you set this attribute to the <code id="a-id"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> of a <code><a href="/en-US/docs/Mozilla/Tech/XUL/statusbar" title="statusbar">statusbar</a></code> element, the label on the statusbar will update to the <code id="a-statustext"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/statustext">statustext</a></code> of the items on the menu as the user moves the mouse over them.</dd>
+</dl>
+</div><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p></p><div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-statusbar">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/statusbar">statusbar</a></span></code></dt>
+ <dd>Type: <em>id of statusbar element</em></dd>
+ <dd>Gets and sets the value of the <code id="a-statusbar"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/statusbar">statusbar</a></code> attribute.</dd>
+</dl></div> <table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited Properties</strong><br> <small> <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/align">align</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/allowEvents">allowEvents</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/boxObject">boxObject</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/builder">builder</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/className">className</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/collapsed">collapsed</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/contextMenu">contextMenu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/controllers">controllers</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/database">database</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/datasources">datasources</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/dir">dir</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/flex">flex</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/height">height</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/hidden">hidden</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/id">id</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/left">left</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxHeight">maxHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxWidth">maxWidth</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menu">menu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minHeight">minHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minWidth">minWidth</a></span></code>, , , , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/observes">observes</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ordinal">ordinal</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/orient">orient</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/pack">pack</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/persist">persist</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ref">ref</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/resource">resource</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/statusText">statusText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/style">style</a></span></code>, ,, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltip">tooltip</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltipText">tooltipText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/top">top</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/width">width</a></span></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<dl>
+ <dt>
+ Elements</dt>
+ <dd>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuseparator" title="menuseparator">menuseparator</a></code></dd>
+</dl>
+<dl>
+ <dt>
+ Interfaces</dt>
+ <dd>
+ <a href="cn/NsIAccessibleProvider">nsIAccessibleProvider</a></dd>
+</dl>
+<p> </p>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/menuitem/index.html b/files/zh-cn/mozilla/tech/xul/menuitem/index.html
new file mode 100644
index 0000000000..a231f6a348
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/menuitem/index.html
@@ -0,0 +1,575 @@
+---
+title: menuitem
+slug: Mozilla/Tech/XUL/menuitem
+tags:
+ - XUL Elements
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/menuitem
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>A single choice in a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code> element. It acts much like a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/button" title="button">button</a></code> but it is rendered on a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code>.</p>
+<p>More information is available in the <a href="cn/XUL_Tutorial/Simple_Menu_Bars">XUL tutorial</a>.</p>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-acceltext">acceltext</a>, <a href="#a-accesskey">accesskey</a>, <a href="#a-allowevents">allowevents</a>, <a href="#a-autocheck">autocheck</a>, <a href="#a-checked">checked</a>, <a href="#a-command">command</a>, <a href="#a-crop">crop</a>, <a href="#a-description">description</a>, <a href="#a-disabled">disabled</a>, <a href="#a-image">image</a>, <a href="#a-menuitem.key">key</a>, <a href="#a-label">label</a>, <a href="#a-menuitem.name">name</a>, <a href="#a-selected">selected</a>, <a href="#a-tabindex">tabindex</a>, <a href="#a-menuitem.type">type</a>, <a href="#a-validate">validate</a>, <a href="#a-value">value</a></dd>
+</dl>
+<dl>
+ <dt>
+ Properties</dt>
+ <dd>
+ <a href="#p-accessibleType">accessibleType</a>, <a href="#p-accessKey">accessKey</a>, <a href="#p-command">command</a>, <a href="#p-menuitem.control">control</a>, <a href="#p-crop">crop</a>, <a href="#p-disabled">disabled</a>, <a href="#p-image">image</a>, <a href="#p-label">label</a>, <a href="#p-labelElement">labelElement</a>, <a href="#p-parentContainer">parentContainer</a>, <a href="#p-selected">selected</a>, <a href="#p-tabIndex">tabIndex</a>, <a href="#p-value">value</a></dd>
+</dl>
+<dl>
+ <dt>
+ Style classes</dt>
+ <dd>
+ <a href="#s-menuitem-iconic">menuitem-iconic</a>, <a href="#s-menuitem-non-iconic">menuitem-non-iconic</a></dd>
+</dl>
+<h3 id="Example" name="Example">Example</h3>
+<pre>&lt;menu id="edit-menu" label="Edit"&gt;
+ &lt;menupopup id="edit-popup"&gt;
+ &lt;menuitem label="Undo"/&gt;
+ &lt;menuitem label="Redo"/&gt;
+ &lt;/menupopup&gt;
+&lt;/menu&gt;
+</pre>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p> </p><div id="a-acceltext">
+
+<dl>
+ <dt>
+ <code id="a-acceltext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/acceltext">acceltext</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Text that appears beside beside the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> label to indicate the shortcut key (accelerator key) to use to invoke the command. If this value is set, it overrides an assigned key set in the key attribute. This attribute does not apply to menus directly on the menubar.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-accesskey">
+
+
+
+
+<dl>
+ <dt><code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code></dt>
+ <dd>类型:
+ <i>character【字符】</i>
+ </dd>
+ <dd>本属性允许为控件(元素)设定一个字符作为快捷键,这个字符应该是 <code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code> 属性文本中的一个字符。该字符将会被加下划线以重点强调,平台和主体的变换并不影响这一表现行为。 当用户点击 ALT (在其他平台上具有类似功能的键) 和这个字符对应的按键时, 控件(元素)将立刻被从窗口中的某处激活或/并且获得焦点 <b>。虽说字符不分大小写,但是当label中存在大写字符和小写字符时,快捷键的字符将首先选择与之完全匹配的那一个,如果label中存在两个或更多的与accesskey字符相同的字符,其中的第一个字符将被加下划线。</b></dd>
+ <dt>      *(有些键在监听按键事件时,分别对应event.ctrlKey和event.metaKey。)</dt>
+</dl>
+
+<p> </p>
+
+<h4 id="Example" name="Example">Example</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_accesskey_attr.png"></div>
+
+<pre>&lt;vbox&gt;
+ &lt;label value="Enter Name" accesskey="e" control="myName"/&gt;
+ &lt;textbox id="myName"/&gt;
+ &lt;button label="Cancel" accesskey="n"/&gt;
+ &lt;button label="Ok" accesskey="O"/&gt;
+&lt;/vbox&gt;
+</pre>
+
+<h4 id="See_also" name="See_also">See also</h4>
+
+<p><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute, <code id="a-acceltext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/acceltext">acceltext</a></code> attribute</p>
+
+<p></p>
+</div> <div id="a-allowevents">
+
+
+<dl>
+ <dt><code id="a-allowevents"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allowevents">allowevents</a></code></dt>
+ <dd>Type:
+ <i>boolean<br>
+ </i>
+ 类型:boolean</dd>
+ <dd>If true, events are passed to children of the element. Otherwise, events are passed to the element only.<br>
+ 如果为真,事件向子元素传递。否则,事件只传递到当前元素。</dd>
+</dl>
+
+
+
+<p></p>
+</div> <div id="a-autocheck">
+
+
+<dl>
+ <dt><code id="a-autocheck"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/autocheck">autocheck</a></code></dt>
+ <dd>类型:
+ <i>boolean</i>
+ </dd>
+ <dd>如果此属性为 <code>true</code>,或空白, 每次点击按钮时,此按钮的状态检查都会被执行一次。如果此属性为<code>false</code>, 检查会手动的被拒绝。当autocheck值为true的时候,按钮将会变为多选框或者单选框。</dd>
+</dl>
+
+
+
+<p></p>
+</div> <div id="a-checked">
+
+<dl>
+ <dt>
+ <code id="a-checked"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/checked">checked</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Indicates whether the element is checked or not.</dd>
+ <dd>
+ Use <code>hasAttribute()</code> to determine whether this attribute is set instead of <code>getAttribute()</code>.</dd>
+ <dd>
+ For buttons, the <code>type</code> attribute must be set to <code>checkbox</code> or <code>radio</code> for this attribute to have any effect.&lt;magic name="\"PAGENAME\"/"&gt;&lt;/magic&gt;</dd>
+</dl>
+</div><p></p>
+<div class="note">
+ <b>Note:</b> if the <code id="a-checked"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/checked">checked</a></code> attribute is set to <code>true</code>, and you persist its value via the <code id="a-persist"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/persist">persist</a></code> attribute, Mozilla will fail to persist its value when the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> is unchecked because of <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=15232" title="persist should be able to remove an attribute from an element">bug 15232</a>. A workaround is to set the <code id="a-autocheck"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/autocheck">autocheck</a></code> attribute to <code>false</code>, then programmatically set the <code id="a-checked"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/checked">checked</a></code> attribute when the user selects the item, and set it to <code>false</code> instead of removing the attribute (i.e. do <code>menuitem.setAttribute("checked", "false")</code> instead of <code>menuitem.removeAttribute("checked"))</code> when the user unchecks the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>, as a value of <code>false</code> will both correctly hide the checkmark and persist its hidden state.</div>
+<p></p><div id="a-command">
+
+<dl>
+ <dt>
+ <code id="a-command"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/command">command</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ element id</i>
+ </dd>
+ <dd>
+ Set to the <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> of a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/command" title="command">command</a></code> element that is being observed by the element.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-crop">
+
+<dl>
+ <dt>
+ <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ one of the values below</i>
+ </dd>
+ <dd>
+ If the label of the element is too big to fit in its given space, the text will be cropped on the side specified by the <code>crop</code> attribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.</dd>
+</dl>
+<ul>
+ <li><code>start</code>: The text will be cropped on its left side.</li>
+ <li><code>end</code>: The text will be cropped on its right side.</li>
+ <li><code>left</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its left side.</li>
+ <li><code>right</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its right side.</li>
+ <li><code>center</code>: The text will be cropped in the middle, showing both the start and end of the text normally.</li>
+ <li><code>none</code>: The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.</li>
+</ul>
+
+<p></p>
+</div> <div id="a-description">
+
+<dl>
+ <dt>
+ <code id="a-description"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/description">description</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Descriptive text to appear in addition to the dialog title.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-disabled">
+
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd> </dd>
+ <dd>
+ <h5 id="类型boolean">类型:<em>boolean</em></h5>
+ </dd>
+ <dd>
+ <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>
+
+ <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>
+
+ <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
+ </dd>
+</dl>
+
+<h4 id="示例:">示例:</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>
+
+<pre><code>// Disabling an element
+document.getElementById('buttonRemove').setAttribute("disabled", "true");
+
+// Enabling back an element by removing the "disabled" attribute
+document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>
+
+<p></p><div class="blockIndicator standardNote">
+ <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
+ <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
+</div><p></p>
+</div> <div id="a-image">
+
+<dl>
+ <dt>
+ <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ image URL</i>
+ </dd>
+ <dd>
+ The URL of the image to appear on the element. If this attribute is empty or left out, no image appears. The position of the image is determined by the <code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code> and <code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code> attributes.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-menuitem.key">
+
+<dl>
+ <dt>
+ <code id="a-menuitem.key"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/menuitem.key">key</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ element id</i>
+ </dd>
+ <dd>
+ Set to the <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> of a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/key" title="key">key</a></code> element whose key shortcut is displayed in the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-label">
+
+<dl>
+ <dt>
+ <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The label that will appear on the element. If this is left out, no text appears.<br>
+ label 在元素上显示。如果左侧出界,则不显示任何文字。</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-menuitem.name">
+
+<dl>
+ <dt>
+ <code id="a-menuitem.name"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/menuitem.name">name</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ string name</i>
+ </dd>
+ <dd>
+ Radio <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>s with the same name as put into a group. Only one <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> in each radio group can be checked at a time.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-selected">
+
+<dl>
+ <dt>
+ <code id="a-selected"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/selected">selected</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Indicates whether the element is selected or not. This value is read-only. To change the selection, set either the <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code> or <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedItem">selectedItem</a></span></code> property of the containing element.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-tabindex">
+
+
+<dl>
+ <dt><code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code></dt>
+ <dd>Type:<em>integer</em></dd>
+ <dd>当用户按下 "<kbd>tab</kbd>" 键时焦点移动到元素上的顺序。<code>tabindex</code> 数字越大,顺序越靠后。</dd>
+</dl>
+
+
+
+<p></p>
+</div> <div id="a-menuitem.type">
+
+<dl>
+ <dt>
+ <code id="a-menuitem.type"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/menuitem.type">type</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ one of the values below</i>
+ </dd>
+ <dd>
+ Can be used to create checkable menuitems or for radio button menuitems.</dd>
+</dl>
+<ul>
+ <li><code>checkbox</code>: The <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> is checked. The <code id="a-checked"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/checked">checked</a></code> attribute determines whether the menuitem is checked or not.</li>
+ <li><code>radio</code>: The <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> becomes part of a radio group. Other menuitems that have the same value for their <code id="a-name"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/name">name</a></code> attributes are part of the same <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/radio" title="radio">radio</a></code> group. Only one menuitem in the same radio group can be checked at once.</li>
+</ul>
+<p>More information on adding checkmarks to menus in the <a href="cn/XUL_Tutorial/More_Menu_Features#Adding_Checkmarks_to_Menus">XUL tutorial</a></p>
+
+<p></p>
+</div> <div id="a-validate">
+
+<dl>
+ <dt>
+ <code id="a-validate"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/validate">validate</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ one of the values below</i>
+ </dd>
+ <dd>
+ This attribute indicates whether to load the image from the cache or not. This would be useful if the images are stored remotely or you plan on swapping the image frequently. The following values are accepted, or leave out the attribute entirely for default handling:</dd>
+</dl>
+<ul>
+ <li><code>always</code>: The image is always checked to see whether it should be reloaded.</li>
+ <li><code>never</code>: The image will be loaded from the cache if possible.</li>
+</ul>
+
+<p></p>
+</div> <div id="a-value">
+
+<dl>
+ <dt>
+ <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ The string attribute allows you to associate a data value with an element. It is not used for any specific purpose, but you can access it with a script for your own use.</dd>
+</dl>
+
+<p></p>
+</div><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p></p><div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-accessKey">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessKey">accessKey</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ character</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-command">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/command">command</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ element id</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-command"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/command">command</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-menuitem.control">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menuitem.control">control</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> element</i>
+ </dd>
+ <dd>
+ Returns the enclosing <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> that the item is inside, if any, or <code>null</code> if there is no enclosing menu.</dd>
+</dl>
+
+<p></p></div> <div id="p-crop">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/crop">crop</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-disabled">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/disabled">disabled</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-image">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/image">image</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ image URL</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-label">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/label">label</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-labelElement">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/labelElement">labelElement</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/label" title="label">label</a></code> element</i>
+ </dd>
+ <dd>
+ The <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/label" title="label">label</a></code> element associated with the control. This is set when a label has a <code id="a-control"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/control">control</a></code> attribute pointing to this element. This property will be <code>null</code> when no label is associated with the control.</dd>
+</dl>
+
+<p></p></div> <div id="p-parentContainer">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/parentContainer">parentContainer</a></span></code> </dt>
+ <dd>
+ Type:
+ <i>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> element</i>
+ </dd>
+ <dd>
+ Read only property that returns the containing <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> element, or <code>null</code> if there isn't a containing menu.</dd>
+</dl>
+
+<p></p></div> <div id="p-selected">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selected">selected</a></span></code>&lt;magic name="\"PAGENAME\"/"&gt;&lt;/magic&gt;</dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ This property's value is <code>true</code> if this element is selected, or <code>false</code> if it is not. This property is read only.</dd>
+</dl></div> <div id="p-tabIndex">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tabIndex">tabIndex</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-value">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/value">value</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited Properties</strong><br> <small> <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/align">align</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/allowEvents">allowEvents</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/boxObject">boxObject</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/builder">builder</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/className">className</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/collapsed">collapsed</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/contextMenu">contextMenu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/controllers">controllers</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/database">database</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/datasources">datasources</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/dir">dir</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/flex">flex</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/height">height</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/hidden">hidden</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/id">id</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/left">left</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxHeight">maxHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxWidth">maxWidth</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menu">menu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minHeight">minHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minWidth">minWidth</a></span></code>, , , , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/observes">observes</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ordinal">ordinal</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/orient">orient</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/pack">pack</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/persist">persist</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ref">ref</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/resource">resource</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/statusText">statusText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/style">style</a></span></code>, ,, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltip">tooltip</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltipText">tooltipText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/top">top</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/width">width</a></span></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Style_classes" name="Style_classes">Style classes</h3>
+<p></p><dl>
+ <dt>
+ <code><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Style/menuitem-iconic">menuitem-iconic</a></code></dt>
+ <dd>
+ Use this class to have an image appear on the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>. Specify the image using the <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code> attribute.</dd>
+</dl>
+
+<p></p> <dl>
+ <dt>
+ <code><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Style/menuitem-non-iconic">menuitem-non-iconic</a></code></dt>
+ <dd>
+ Normally, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>s have a margin to the left for an image or checkmark. This class may be used to remove this margin so that the menuitem appears on the left edge of the menupopup.</dd>
+</dl>
+
+<p></p><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<dl>
+ <dt>
+ Elements</dt>
+ <dd>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menubar" title="menubar">menubar</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuseparator" title="menuseparator">menuseparator</a></code></dd>
+</dl>
+<dl>
+ <dt>
+ Interfaces</dt>
+ <dd>
+ <a href="cn/NsIAccessibleProvider">nsIAccessibleProvider</a>, <a href="cn/NsIDOMXULContainerItemElement">nsIDOMXULContainerItemElement</a>, <a href="cn/NsIDOMXULSelectControlItemElement">nsIDOMXULSelectControlItemElement</a></dd>
+</dl>
+<p> </p>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/menulist/index.html b/files/zh-cn/mozilla/tech/xul/menulist/index.html
new file mode 100644
index 0000000000..7273d413e7
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/menulist/index.html
@@ -0,0 +1,509 @@
+---
+title: menulist
+slug: Mozilla/Tech/XUL/menulist
+tags:
+ - XUL Elements
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/menulist
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>An element that can be used for drop-down choice lists. The user may select one of the elements displayed in the <code>menulist</code>. The currently selected choice is displayed on the <code>menulist</code> element. To create the drop-down, put a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code> inside the <code>menulist</code> containing the choices as <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> elements. The command event may be used to execute code when the menulist selection changes.</p>
+<p>More information is available in the <a href="cn/XUL_Tutorial/List_Controls">XUL tutorial</a>.</p>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-accesskey">accesskey</a>, <a href="#a-crop">crop</a>, <a href="#a-disableautoselect">disableautoselect</a>, <a href="#a-disabled">disabled</a>, <a href="#a-editable">editable</a>, <a href="#a-focused">focused</a>, <a href="#a-image">image</a>, <a href="#a-label">label</a>, <a href="#a-oncommand">oncommand</a>, <a href="#a-open">open</a>, <a href="#a-preference">preference</a>, <a href="#a-readonly">readonly</a>, <a href="#a-sizetopopup">sizetopopup</a>, <a href="#a-tabindex">tabindex</a>, <a href="#a-value">value</a></dd>
+</dl>
+<dl>
+ <dt>
+ Properties</dt>
+ <dd>
+ <a href="#p-accessibleType">accessibleType</a>, <a href="#p-crop">crop</a>, <a href="#p-description">description</a>, <a href="#p-disableautoselect">disableautoselect</a>, <a href="#p-disabled">disabled</a>, <a href="#p-editable">editable</a>, <a href="#p-editor">editor</a>, <a href="#p-menulist.image">image</a>, <a href="#p-menulist.inputField">inputField</a>, <a href="#p-itemCount">itemCount</a>, <a href="#p-label">label</a>, <a href="#p-menuBoxObject">menuBoxObject</a>, <a href="#p-menupopup">menupopup</a>, <a href="#p-open">open</a>, <a href="#p-selectedIndex">selectedIndex</a>, <a href="#p-selectedItem">selectedItem</a>, <a href="#p-tabIndex">tabIndex</a>, <a href="#p-value">value</a></dd>
+</dl>
+<dl>
+ <dt>
+ Methods</dt>
+ <dd>
+ <a href="#m-menulist.appendItem">appendItem</a>, <a href="#m-contains">contains</a>, <a href="#m-getIndexOfItem">getIndexOfItem</a>, <a href="#m-getItemAtIndex">getItemAtIndex</a>, <a href="#m-insertItemAt">insertItemAt</a>, <a href="#m-removeAllItems">removeAllItems</a>, <a href="#m-removeItemAt">removeItemAt</a>, <a href="#m-menulist.select">select</a></dd>
+</dl>
+<h3 id="Examples" name="Examples">Examples</h3>
+<pre> &lt;menulist&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem label="option 1" value="1"/&gt;
+ &lt;menuitem label="option 2" value="2"/&gt;
+ &lt;menuitem label="option 3" value="3"/&gt;
+ &lt;menuitem label="option 4" value="4"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menulist&gt;
+</pre>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p> </p><div id="a-accesskey">
+
+
+
+
+<dl>
+ <dt><code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code></dt>
+ <dd>类型:
+ <i>character【字符】</i>
+ </dd>
+ <dd>本属性允许为控件(元素)设定一个字符作为快捷键,这个字符应该是 <code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code> 属性文本中的一个字符。该字符将会被加下划线以重点强调,平台和主体的变换并不影响这一表现行为。 当用户点击 ALT (在其他平台上具有类似功能的键) 和这个字符对应的按键时, 控件(元素)将立刻被从窗口中的某处激活或/并且获得焦点 <b>。虽说字符不分大小写,但是当label中存在大写字符和小写字符时,快捷键的字符将首先选择与之完全匹配的那一个,如果label中存在两个或更多的与accesskey字符相同的字符,其中的第一个字符将被加下划线。</b></dd>
+ <dt>      *(有些键在监听按键事件时,分别对应event.ctrlKey和event.metaKey。)</dt>
+</dl>
+
+<p> </p>
+
+<h4 id="Example" name="Example">Example</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_accesskey_attr.png"></div>
+
+<pre>&lt;vbox&gt;
+ &lt;label value="Enter Name" accesskey="e" control="myName"/&gt;
+ &lt;textbox id="myName"/&gt;
+ &lt;button label="Cancel" accesskey="n"/&gt;
+ &lt;button label="Ok" accesskey="O"/&gt;
+&lt;/vbox&gt;
+</pre>
+
+<h4 id="See_also" name="See_also">See also</h4>
+
+<p><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute, <code id="a-acceltext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/acceltext">acceltext</a></code> attribute</p>
+
+<p></p>
+</div> <div id="a-crop">
+
+<dl>
+ <dt>
+ <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ one of the values below</i>
+ </dd>
+ <dd>
+ If the label of the element is too big to fit in its given space, the text will be cropped on the side specified by the <code>crop</code> attribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.</dd>
+</dl>
+<ul>
+ <li><code>start</code>: The text will be cropped on its left side.</li>
+ <li><code>end</code>: The text will be cropped on its right side.</li>
+ <li><code>left</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its left side.</li>
+ <li><code>right</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its right side.</li>
+ <li><code>center</code>: The text will be cropped in the middle, showing both the start and end of the text normally.</li>
+ <li><code>none</code>: The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.</li>
+</ul>
+
+<p></p>
+</div> <div id="a-disableautoselect">
+
+
+<dl>
+ <dt><code id="a-disableautoselect"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/disableautoselect">disableautoselect</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>If this attribute is <code>true</code> or omitted, the selected item on the menu will update to match what the user entered in the textbox. If the text does not match any of the items in the list, the menu selection is cleared. If this attribute is <code>false</code>, the selection is never updated to match the text box. This attribute applies only to editable <code><a href="/en-US/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code>s.</dd>
+</dl>
+</div> <div id="a-disabled">
+
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd> </dd>
+ <dd>
+ <h5 id="类型boolean">类型:<em>boolean</em></h5>
+ </dd>
+ <dd>
+ <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>
+
+ <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>
+
+ <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
+ </dd>
+</dl>
+
+<h4 id="示例:">示例:</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>
+
+<pre><code>// Disabling an element
+document.getElementById('buttonRemove').setAttribute("disabled", "true");
+
+// Enabling back an element by removing the "disabled" attribute
+document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>
+
+<p></p><div class="blockIndicator standardNote">
+ <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
+ <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
+</div><p></p>
+</div> <div id="a-editable">
+
+
+<dl>
+ <dt><code id="a-editable"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/editable">editable</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>Indicates that the value of the <code><a href="/en-US/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code> can be modified by typing directly into the value field. This is rendered as a textbox with a drop-down arrow beside it. The user may enter text into the textbox or select one of the choices by clicking from the drop-down.</dd>
+</dl>
+</div> <div id="a-focused">
+
+
+<dl>
+ <dt><code id="a-focused"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/focused">focused</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>This attribute is <code>true</code> if the element is focused.</dd>
+</dl>
+</div> <div id="a-image">
+
+<dl>
+ <dt>
+ <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ image URL</i>
+ </dd>
+ <dd>
+ The URL of the image to appear on the element. If this attribute is empty or left out, no image appears. The position of the image is determined by the <code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code> and <code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code> attributes.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-label">
+
+<dl>
+ <dt>
+ <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The label that will appear on the element. If this is left out, no text appears.<br>
+ label 在元素上显示。如果左侧出界,则不显示任何文字。</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-oncommand">
+
+
+<dl>
+ <dt><code id="a-oncommand"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/oncommand">oncommand</a></code></dt>
+ <dd>Type: <em>script code</em></dd>
+ <dd>This event handler is called when the command is activated. This occurs when a user selects a menu item or presses a keyboard shortcut attached to the command.</dd>
+</dl>
+
+
+</div> <div id="a-open">
+
+
+<dl>
+ <dt><code id="a-open"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/open">open</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>For the <code>menu</code> <code id="a-type"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/type">type</a></code> buttons, the <code>open</code> attribute is set to <code>true</code> when the menu is open. The <code>open</code> attribute is not present if the menu is closed.</dd>
+</dl>
+</div> <div id="a-preference">
+
+
+<dl>
+ <dt><code id="a-preference"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/preference">preference</a></code></dt>
+ <dd>Type: <em>id</em></dd>
+ <dd>Connects the element to a corresponding <code><a href="/en-US/docs/Mozilla/Tech/XUL/preference" title="preference">preference</a></code>. This attribute only has any effect when used inside a <code><a href="/en-US/docs/Mozilla/Tech/XUL/prefwindow" title="prefwindow">prefwindow</a></code>. More information is available in the <a href="../../../../en/Preferences_System" rel="internal">Preferences System</a> article.</dd>
+</dl>
+</div> <div id="a-readonly">
+
+
+<dl>
+ <dt><code id="a-readonly"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/readonly">readonly</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>If set to <code>true</code>, then the user cannot change the value of the element. However, the value may still be modified by a script.</dd>
+</dl>
+</div> <div id="a-sizetopopup">
+
+
+<dl>
+ <dt><code id="a-sizetopopup"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/sizetopopup">sizetopopup</a></code></dt>
+ <dd>Type: <em>one of the values below</em></dd>
+ <dd>Indicates how the menu width and the <code><a href="/en-US/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code> width are determined. If the <code>sizetopopup</code> attribute is left out or set to <code>none</code>, the menu will be its preferred width and the popup may extend outside of this width, unaffected by the maximum width of the menu itself. Otherwise, the menu will size itself to at least the size of the popup. If the menu has a maximum width, the popup will also be this width.</dd>
+ <dd>
+ <dl>
+ <dt><code>none</code></dt>
+ <dd>The width of the popup will not be constrained to the size of the menu.</dd>
+ <dt><code>pref</code></dt>
+ <dd>The preferred width of the menu label or button will be the size needed for the popup contents. This is the default value for menulists.</dd>
+ <dt><code>always</code></dt>
+ <dd>Both the preferred and minimum width of the menu label or button will be the same as that necessary for the <code><a href="/en-US/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code>.</dd>
+ </dl>
+ </dd>
+</dl>
+</div> <div id="a-tabindex">
+
+
+<dl>
+ <dt><code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code></dt>
+ <dd>Type:<em>integer</em></dd>
+ <dd>当用户按下 "<kbd>tab</kbd>" 键时焦点移动到元素上的顺序。<code>tabindex</code> 数字越大,顺序越靠后。</dd>
+</dl>
+
+
+
+<p></p>
+</div> <div id="a-value">
+
+<dl>
+ <dt>
+ <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ The string attribute allows you to associate a data value with an element. It is not used for any specific purpose, but you can access it with a script for your own use.</dd>
+</dl>
+
+<p></p>
+</div><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p> </p><div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-crop">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/crop">crop</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-description">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/description">description</a></span></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>Set to the description of the currently selected <code><a href="/en-US/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>.</dd>
+</dl></div> <div id="p-disableautoselect">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/disableautoselect">disableautoselect</a></span></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>Gets and sets the value of the <code id="a-disableautoselect"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/disableautoselect">disableautoselect</a></code> attribute.</dd>
+</dl></div> <div id="p-disabled">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/disabled">disabled</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-editable">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/editable">editable</a></span></code> </dt>
+ <dd>
+ Type: <em>boolean</em></dd>
+ <dd>
+ Returns <code>true</code> if the element is editable. Autocomplete fields are editable so this property always returns <code>true</code> for those.</dd>
+</dl>
+<p> </p></div> <div id="p-editor">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/editor">editor</a></span></code></dt>
+ <dd>Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIEditor" title="">nsIEditor</a></code></em></dd>
+ <dd>A reference to the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIEditor" title="">nsIEditor</a></code> for editable text. This property is read only.</dd>
+</dl></div> <div id="p-menulist.image">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/menulist.image">image</a></span></code></dt>
+ <dd>Type: <em>image URL</em></dd>
+ <dd>The image associated with the currently selected item.</dd>
+</dl></div> <div id="p-menulist.inputField">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/menulist.inputField">inputField</a></span></code></dt>
+ <dd>Type: <em>textbox element</em></dd>
+ <dd>A reference to the <code><a href="/en-US/docs/Mozilla/Tech/XUL/textbox" title="textbox">textbox</a></code> element used for editable menu lists. This property is read only and applies to editable <code><a href="/en-US/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code>s only.</dd>
+</dl>
+
+</div> <div id="p-itemCount">
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/itemCount">itemCount</a></span></code> </dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>Read only property holding the number of child items.</dd>
+</dl>
+</div> <div id="p-label">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/label">label</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-menuBoxObject">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/menuBoxObject">menuBoxObject</a></span></code></dt>
+ <dd>Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMenuBoxObject" title="">nsIMenuBoxObject</a></code></em></dd>
+ <dd>A reference to the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMenuBoxObject" title="">nsIMenuBoxObject</a></code> which implements the menu.</dd>
+</dl></div> <div id="p-menupopup">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/menupopup">menupopup</a></span></code></dt>
+ <dd>Type: <em>menupopup element</em></dd>
+ <dd>A reference to the <code><a href="/en-US/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code> used by the <code><a href="/en-US/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> or <code><a href="/en-US/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code>. This property is read-only.</dd>
+</dl></div> <div id="p-open">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/open">open</a></span></code></dt>
+ <dd>
+ Type: <em>boolean</em></dd>
+ <dd>
+ Gets and sets the value of the <code id="a-open"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/open">open</a></code> attribute.</dd>
+</dl>
+</div> <div id="p-selectedIndex">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ Returns the index of the currently selected item. You may select an item by assigning its index to this property. By assigning <code>-1</code> to this property, all items will be deselected.</dd>
+</dl>
+
+<p></p></div> <div id="p-selectedItem">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedItem">selectedItem</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ element</i>
+ </dd>
+ <dd>
+ Holds the currently selected item. If no item is currently selected, this value will be <code>null</code>. You can select an item by setting this value. A select event will be sent to the element when it is changed either via this property, the <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code> property, or changed by the user.</dd>
+</dl>
+
+<p></p></div> <div id="p-tabIndex">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tabIndex">tabIndex</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-value">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/value">value</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code> attribute.</dd>
+</dl>
+
+<p></p></div><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0 0 10px 10px; padding: 0 10px; background: rgb(238, 238, 238); float: right; width: 250px;">
+<tbody>
+<tr>
+<td>
+<p><strong>Inherited Methods</strong><br>
+<small><code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.cloneNode">cloneNode()</a></code>, <a href="/En/DOM/Node.compareDocumentPosition" title="En/DOM/Node.compareDocumentPosition">compareDocumentPosition</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getBoundingClientRect">getBoundingClientRect()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getClientRects">getClientRects()</a></code>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span>, <span id="m-getElementsByAttributeNS"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttributeNS">getElementsByAttributeNS</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByClassName">getElementsByClassName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getFeature">getFeature()</a></code>, <a href="/En/DOM/Node.getUserData" title="En/DOM/Node.getUserData">getUserData</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isDefaultNamespace">isDefaultNamespace()</a></code>, <a href="/En/DOM/Node.isEqualNode" title="En/DOM/Node.isEqualNode">isEqualNode</a>, <a href="/En/DOM/Node.isSameNode" title="En/DOM/Node.isSameNode">isSameNode</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <a href="/En/DOM/Node.lookupNamespaceURI" title="En/DOM/Node.lookupNamespaceURI">lookupNamespaceURI</a>, <a href="/En/DOM/Node.lookupPrefix" title="En/DOM/Node.lookupPrefix">lookupPrefix</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.querySelector">querySelector()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.querySelectorAll">querySelectorAll()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code>, <a href="/En/DOM/Node.setUserData" title="En/DOM/Node.setUserData">setUserData</a></small></p>
+
+</td>
+</tr>
+</tbody>
+</table> <dl>
+ <dt><span id="m-menulist.appendItem"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/menulist.appendItem">appendItem( label, value, description )</a></code></span></dt>
+ <dd>Return type: <em>element</em></dd>
+ <dd>Creates a new <code><a href="/en-US/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> element and adds it to the end of the menulist. You may optionally set a value and description. The function returns the new item.</dd>
+</dl> <dl>
+ <dt><span id="m-contains"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/contains">contains( item )</a></code></span> </dt>
+ <dd>Return type: <em>boolean</em></dd>
+ <dd>Returns <code>true</code> if the <code><a href="/en-US/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code> contains the specified <code><a href="/en-US/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> as one of its items.</dd>
+</dl> <dl>
+ <dt><span id="m-getIndexOfItem"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/getIndexOfItem">getIndexOfItem( item )</a></code></span></dt>
+ <dd>Return type: <em>integer</em></dd>
+ <dd>Returns the zero-based position of the specified item. Items are numbered starting at the first item displayed in the list.</dd>
+</dl> <dl>
+ <dt><span id="m-getItemAtIndex"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/getItemAtIndex">getItemAtIndex( index )</a></code></span></dt>
+ <dd>Return type: <em>element</em></dd>
+ <dd>Returns the element that is at the specified index.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-insertItemAt"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/insertItemAt">insertItemAt( index, label, value )</a></code></span></dt>
+ <dd>
+ Return type: <em>element</em></dd>
+ <dd>
+ This method creates a new item and inserts it at the specified position. You may optionally set a value. The new item element is returned.</dd>
+</dl> <dl>
+ <dt><span id="m-removeAllItems"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/removeAllItems">removeAllItems()</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Removes all of the items in the <a href="/en/XUL/menu" title="en/XUL/menu">menu</a>.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-removeItemAt"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/removeItemAt">removeItemAt( index )</a></code></span></dt>
+ <dd>
+ Return type: <em>element</em></dd>
+ <dd>
+ Removes the child item in the element at the specified index. The method returns the removed item.</dd>
+</dl> <dl>
+ <dt><span id="m-menulist.select"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/menulist.select">select()</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Select all the text in the <code><a href="/en-US/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code>'s textbox. This method applies to <code id="a-editable"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/editable">editable</a></code> menulists only.</dd>
+</dl><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<dl>
+ <dt>
+ Elements</dt>
+ <dd>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menubar" title="menubar">menubar</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuseparator" title="menuseparator">menuseparator</a></code></dd>
+</dl>
+<dl>
+ <dt>
+ Interfaces</dt>
+ <dd>
+ <a href="cn/NsIAccessibleProvider">nsIAccessibleProvider</a>, <a href="cn/NsIDOMXULMenuListElement">nsIDOMXULMenuListElement</a></dd>
+</dl>
+<p> </p>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/menupopup/index.html b/files/zh-cn/mozilla/tech/xul/menupopup/index.html
new file mode 100644
index 0000000000..23b103ebb9
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/menupopup/index.html
@@ -0,0 +1,324 @@
+---
+title: menupopup
+slug: Mozilla/Tech/XUL/menupopup
+tags:
+ - XUL Elements
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/menupopup
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>A container used to display the contents of a popup menu. When a menupopup is open, it floats above the window and may extend outside the window border. There are several ways in which a menupopup may be used:</p>
+<ol>
+ <li>It may be placed inside a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbarbutton" title="toolbarbutton">toolbarbutton</a></code>, or a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/button" title="button">button</a></code> with the <a href="#a-type">type</a> attribute set to "menu" to create a popup that will open when the menu or button is pressed.</li>
+ <li>It may be attached to any element using the <code id="a-popup"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/popup">popup</a></code> attribute. When the element is clicked with the left mouse button, the menupopup will be displayed.</li>
+ <li>It may be attached to any element using the <code id="a-context"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/context">context</a></code> attribute. When a context menu is opened, the menupopup will be displayed. A context menu may be opened by right-clicking the element, or by pressing the menu key on the keyboard.</li>
+</ol>
+<p>More information is available in the <a href="cn/XUL_Tutorial/Simple_Menu_Bars">XUL tutorial</a>.</p>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-ignorekeys">ignorekeys</a>, <a href="#a-popup.left">left</a>, <a href="#a-onpopuphidden">onpopuphidden</a>, <a href="#a-onpopuphiding">onpopuphiding</a>, <a href="#a-onpopupshowing">onpopupshowing</a>, <a href="#a-onpopupshown">onpopupshown</a>, <a href="#a-popup.position">position</a>, <a href="#a-popup.top">top</a></dd>
+</dl>
+<dl>
+ <dt>
+ Properties</dt>
+ <dd>
+ <a href="#p-accessibleType">accessibleType</a>, <a href="#p-popupBoxObject">popupBoxObject</a>, <a href="#p-popup">popup</a>, <a href="#p-state">state</a></dd>
+</dl>
+<dl>
+ <dt>
+ Methods</dt>
+ <dd>
+ <a href="#m-hidePopup">hidePopup</a>, <a href="#m-moveTo">moveTo</a>, <a href="#m-openPopup">openPopup</a>, <a href="#m-openPopupAtScreen">openPopupAtScreen</a>, <a href="#m-showPopup">showPopup</a>, <a href="#m-sizeTo">sizeTo</a></dd>
+</dl>
+<h3 id="Examples" name="Examples">Examples</h3>
+<p>The following example shows how a menupopup may be attached to a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code>.</p>
+<pre>&lt;menulist&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem label="Mozilla" value="http://mozilla.org"/&gt;
+ &lt;menuitem label="Slashdot" value="http://slashdot.org"/&gt;
+ &lt;menuitem label="Sourceforge" value="http://sf.net"/&gt;
+ &lt;menuitem label="Freshmeat" value="http://freshmeat.net"/&gt;
+ &lt;/menupopup&gt;
+&lt;/menulist&gt;
+</pre>
+<p>The following example shows how a menupopup can be used a context menu for an element. When the label is right-clicked, the menu will be displayed.</p>
+<div class="float-right">
+ <img alt="Image:XUL_ref_popup.png"></div>
+<pre>&lt;menupopup id="clipmenu"&gt;
+ &lt;menuitem label="Cut"/&gt;
+ &lt;menuitem label="Copy"/&gt;
+ &lt;menuitem label="Paste"/&gt;
+&lt;/menupopup&gt;
+&lt;label value="Right click for popup" context="clipmenu"/&gt;
+</pre>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p> </p><div id="a-ignorekeys">
+
+
+<dl>
+ <dt><code id="a-ignorekeys"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/ignorekeys">ignorekeys</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>If <code>true</code>, keyboard navigation between items in the popup is disabled.</dd>
+</dl>
+</div> <div id="a-popup.left">
+
+
+<dl>
+ <dt><code id="a-popup.left"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/popup.left">left</a></code></dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>Overrides the horizontal position of the popup specified by the <span id="m-showPopup"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/showPopup">showPopup</a></code></span> method.</dd>
+</dl>
+</div> <div id="a-onpopuphidden">
+
+
+<dl>
+ <dt><code id="a-onpopuphidden"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/onpopuphidden">onpopuphidden</a></code></dt>
+ <dd>Type: <em>script code</em></dd>
+ <dd>This event is sent to a popup after it has been hidden.</dd>
+ <dd>This event may also be received while the popup is still open, but when sub-menus contained within this popup are hidden.</dd>
+ <dt>
+ <h4 id="Example">Example:</h4>
+ </dt>
+</dl>
+
+<pre>&lt;menupopup id="top" onpopuphidden="console.log('The onpopuphidden method of id=top was called.');"&gt;
+    &lt;menuitem label="item 1"/&gt;
+    &lt;menuitem label="item 2"/&gt;
+    &lt;menu id="submenu1" label="submenu 1"&gt;
+        &lt;menupopup id="submenu1-popup"&gt;
+            &lt;menuitem label="submenu1 item 1"/&gt;
+            &lt;menuitem label="submenu1 item 2"/&gt;
+        &lt;/menupopup&gt;
+    &lt;/menu&gt;
+    &lt;menu id="submenu2" label="submenu 1"&gt;
+        &lt;menupopup id="submenu2-popup"&gt;
+            &lt;menuitem label="submenu2 item 1"/&gt;
+            &lt;menuitem label="submenu2 item 2"/&gt;
+        &lt;/menupopup&gt;
+    &lt;/menu&gt;
+&lt;menupopup/&gt;
+</pre>
+
+
+</div> <div id="a-onpopuphiding">
+
+
+<dl>
+ <dt><code id="a-onpopuphiding"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/onpopuphiding">onpopuphiding</a></code></dt>
+ <dd>Type: <em>script code</em></dd>
+ <dd>This event is sent to a popup when it is about to be hidden.</dd>
+</dl>
+</div> <div id="a-onpopupshowing">
+
+<dl>
+ <dt>
+ <code id="a-onpopupshowing"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/onpopupshowing">onpopupshowing</a></code></dt>
+ <dd>
+ Type: <em>script code</em></dd>
+ <dd>
+ This event is sent to a popup just before it is opened. This handler is usually used to dynamically set the contents when the user requests to display it. Returning <code>false</code> from this event handler prevents the popup from appearing.</dd>
+ <dd>
+ 该事件在 popup 打开之前传给它。它用于动态生成菜单项。如果返回 false 值,则 popup 将不会显示菜单项。</dd>
+</dl>
+
+<p> </p>
+</div> <div id="a-onpopupshown">
+
+<dl>
+ <dt>
+ <code id="a-onpopupshown"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/onpopupshown">onpopupshown</a></code></dt>
+ <dd>
+ Type: <em>script code</em></dd>
+ <dd>
+ This event is sent to a popup after it has been opened, much like the <code>onload</code> event is sent to a window when it is opened.</dd>
+ <dd>
+ 该事件在 popup 打开之后触发,与 window 的 onload 事件比较类似。</dd>
+</dl>
+
+<p> </p>
+</div> <div id="a-popup.position">
+
+
+<dl>
+ <dt><code id="a-popup.position"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/popup.position">position</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>The <code>position</code> attribute determines where the popup appears relative to the element the user clicked to invoke the popup. This allows you to place the popup on one side of a button.  Note that a context menu will never respect this attribute, always appearing relative to the mouse cursor.</dd>
+ <dd><br>
+ This value can be specified either as a single word offering pre-defined alignment positions, or as 2 words specifying exactly which part of the anchor and popup should be aligned.</dd>
+ <dd><br>
+ If specified as 2 words, the value indicates which corner or edge of the anchor (the first word) is aligned which which corner of the popup (the second word).  The anchor value (ie, the first word) can be one of <code>topleft</code>, <code>topright</code>, <code>bottomleft</code>, <code>bottomright</code>, <code>leftcenter</code>, <code>rightcenter</code>, <code>topcenter</code> or <code>bottomcenter</code>.  The popup value (ie, the second word) can be one of <code>topleft</code>, <code>topright</code>, <code>bottomleft</code> or <code>bottomright</code>.</dd>
+ <dd><br>
+ Positions specified as a single word string are shortcuts for the values above.  Valid single-word values are <code>after_start</code>, <code>after_end</code>, <code>before_start</code>, <code>before_end</code>, <code>end_after</code>, <code>end_before</code>, <code>start_after</code>, <code>start_before</code>, <code>overlap</code>, <code>at_pointer</code> or <code>after_pointer</code>.</dd>
+ <dd>For more details, including examples, please see <a href="/en-US/docs/XUL/PopupGuide/Positioning" title="/en-US/docs/XUL/PopupGuide/Positioning">popup positioning</a></dd>
+</dl>
+
+
+</div> <div id="a-popup.top">
+
+
+<dl>
+ <dt><code id="a-popup.top"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/popup.top">top</a></code></dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>Overrides the vertical position of the popup specified by the <span id="m-showPopup"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/showPopup">showPopup</a></code></span> method.</dd>
+</dl>
+</div><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p> </p><div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-popupBoxObject">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/popupBoxObject">popupBoxObject</a></span></code></dt>
+ <dd>
+ Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPopupBoxObject" title="">nsIPopupBoxObject</a></code></em></dd>
+ <dd>
+ This read-only property holds the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPopupBoxObject" title="">nsIPopupBoxObject</a></code> that implements the popup. You wouldn't normally need to use this property as all of its functions are available via the popup itself.</dd>
+</dl></div> <div id="p-position">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/position">position</a></span></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ Gets and sets the value of the <a href="/en/XUL/Attribute/popup.position" title="en/XUL/Attribute/popup.position">position</a> attribute.</dd>
+</dl></div> <div id="p-state">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/state">state</a></span></code> </dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ This read only property indicates whether the popup is open or not. Four values are possible:
+ <ul>
+ <li><code>closed</code>: The popup is closed and not visible.</li>
+ <li><code>open</code>: The popup is open and visible on screen.</li>
+ <li><code>showing</code>: A request has been made to open the popup, but it has not yet been shown. This state will occur during the popupshowing event.</li>
+ <li><code>hiding</code>: The popup is about to be hidden. This state will occur during the popuphiding event.</li>
+ </ul>
+ </dd>
+</dl></div><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0 0 10px 10px; padding: 0 10px; background: rgb(238, 238, 238); float: right; width: 250px;">
+<tbody>
+<tr>
+<td>
+<p><strong>Inherited Methods</strong><br>
+<small><code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.cloneNode">cloneNode()</a></code>, <a href="/En/DOM/Node.compareDocumentPosition" title="En/DOM/Node.compareDocumentPosition">compareDocumentPosition</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getBoundingClientRect">getBoundingClientRect()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getClientRects">getClientRects()</a></code>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span>, <span id="m-getElementsByAttributeNS"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttributeNS">getElementsByAttributeNS</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByClassName">getElementsByClassName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getFeature">getFeature()</a></code>, <a href="/En/DOM/Node.getUserData" title="En/DOM/Node.getUserData">getUserData</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isDefaultNamespace">isDefaultNamespace()</a></code>, <a href="/En/DOM/Node.isEqualNode" title="En/DOM/Node.isEqualNode">isEqualNode</a>, <a href="/En/DOM/Node.isSameNode" title="En/DOM/Node.isSameNode">isSameNode</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <a href="/En/DOM/Node.lookupNamespaceURI" title="En/DOM/Node.lookupNamespaceURI">lookupNamespaceURI</a>, <a href="/En/DOM/Node.lookupPrefix" title="En/DOM/Node.lookupPrefix">lookupPrefix</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.querySelector">querySelector()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.querySelectorAll">querySelectorAll()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code>, <a href="/En/DOM/Node.setUserData" title="En/DOM/Node.setUserData">setUserData</a></small></p>
+
+</td>
+</tr>
+</tbody>
+</table> <dl>
+ <dt>
+ <span id="m-hidePopup"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/hidePopup">hidePopup()</a></code></span></dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+ <dd>
+ Closes the popup immediately.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-moveTo"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/moveTo">moveTo( x, y )</a></code></span></dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+ <dd>
+ Moves the popup to a new location defined by screen coordinates (and not client coordinates).</dd>
+ <dd>
+ If both x and y have the value -1 the call will realign the popup with its anchor node.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-openPopup"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/openPopup">openPopup( anchor , position , x , y , isContextMenu, attributesOverride, triggerEvent )</a></code></span> </dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+</dl>
+<p>Opens the popup relative to a specified node at a specific location.</p>
+<dl>
+ <dt>
+ anchor</dt>
+ <dd>
+ The popup may be either anchored to another node or opened freely. To anchor a popup to a node, supply an anchor node and set the position to a string indicating the manner in which the popup should be anchored. The anchor node does not need to be in the same document as the popup. Unanchored popups may be created by supplying <code>null</code> as the anchor node. The direction in which the popup is oriented depends on the direction of the anchor.</dd>
+ <dt>
+ position</dt>
+ <dd>
+ Possible values for position are: <code>before_start</code>, <code>before_end</code>, <code>after_start</code>, <code>after_end</code>, <code>start_before</code>, <code>start_after</code>, <code>end_before</code>, <code>end_after</code>, <code>overlap</code>, and <code>after_pointer</code>. Check <a href="/en/XUL/PopupGuide/Positioning" title="https://developer.mozilla.org/en/XUL/PopupGuide/Positioning">Positioning of the Popup Guide</a> for a precise description of the effect of the different values.</dd>
+ <dt>
+ x, y</dt>
+ <dd>
+ For an anchored popup, the <code>x</code> and <code>y</code> arguments may be used to offset the popup from its anchored position by some number, measured in CSS pixels. An unanchored popup appears at the position specified by x and y, relative to the viewport of the document containing the popup node. In this case, the <code>position</code> and <code>attributesOverride</code> arguments are ignored.</dd>
+ <dt>
+ isContextMenu</dt>
+ <dd>
+ The <code>isContextMenu</code> argument should be <code>true</code> for context menus and <code>false</code> for all other types of popups. It affects menu item highlighting; that is, while a context menu is open, menus opened earlier do not highlight or execute their items.</dd>
+ <dt>
+ attributesOverride</dt>
+ <dd>
+ If the <code>attributesOverride</code> argument is <code>true</code>, the position attribute on the popup node overrides the <code>position</code> value argument. If <code>attributesOverride</code> is <code>false</code>, the attribute is only used if the <code>position</code> argument is empty.</dd>
+ <dt>
+ triggerEvent</dt>
+ <dd>
+ The event that triggered the popup (such as a mouse click, if the user clicked something to open the popup).</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-openPopupAtScreen"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/openPopupAtScreen">openPopupAtScreen( x, y, isContextMenu )</a></code></span> </dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+ <dd>
+ Open the popup at a specific screen position specified by x and y. This position may be adjusted if it would cause the popup to be off of the screen. The x and y coordinates are measured in CSS pixels.</dd>
+</dl> <dl>
+ <dt><span id="m-showPopup"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/showPopup">showPopup( element, x, y, popupType, anchor, align )</a></code></span> <span class="inlineIndicator deprecated deprecatedInline" title="(Firefox 3)">Deprecated since Gecko 1.9</span></dt>
+ <dd>Return type: <em>no return value</em><br>
+ <em>Deprecated in favor of openPopup and <span>openPopupAtScreen</span></em></dd>
+ <dd>Opens a popup element. There are two ways of specifying where the popup appears, either at a specific screen position, or relative to some element in the window. If either <var>x</var> or <var>y</var> are set to values, the popup will appear at the screen coordinate (<var>x</var>,<var>y</var>). If <var>x</var> and <var>y</var> are <code>-1</code>, the popup will be positioned relative to the <var>element</var> specified as the first argument. This is what you might do to show a popup below a button, for example. In this latter case, the <var>anchor</var> and <var>align</var> arguments may be used to further control where the popup appears relative to the element. The <var>anchor</var> argument corresponds to the <code id="a-popupanchor"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/popupanchor">popupanchor</a></code> attribute on the element. The <var>align</var> argument corresponds to the <code id="a-popupalign"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/popupalign">popupalign</a></code> attribute on the element. The <var>anchor</var> and <var>align</var> arguments are ignored if either <var>x</var> or <var>y</var> are not <code>-1</code>.</dd>
+</dl>
+
+<dl>
+ <dd>To have a popup appear relative to another element yet still offset by some number of pixels, determine the actual screen position of the element using the <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/boxObject">boxObject</a></span></code>.screenX and <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/boxObject">boxObject</a></span></code>.screenY properties of the element, and use those as the <var>x</var> and <var>y</var> arguments offset by the desired values.</dd>
+</dl>
+
+<dl>
+ <dd>The <var>popupType</var> should be one of the strings <code>popup</code>, <code>context</code>, or <code>tooltip</code>. Each type of popup is intended to be displayed only temporarily; they are not expected to be displayed permanently.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-sizeTo"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/sizeTo">sizeTo( width, height )</a></code></span></dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+ <dd>
+ Changes the current size of the popup to the new <var>width</var> and <var>height</var>.</dd>
+</dl><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<dl>
+ <dt>
+ Elements</dt>
+ <dd>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menubar" title="menubar">menubar</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuseparator" title="menuseparator">menuseparator</a></code></dd>
+</dl>
+<dl>
+ <dt>
+ Interfaces</dt>
+ <dd>
+ <a href="cn/NsIAccessibleProvider">nsIAccessibleProvider</a>, <a href="cn/NsIDOMXULPopupElement">nsIDOMXULPopupElement</a></dd>
+</dl>
+<p> </p>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/menuseparator/index.html b/files/zh-cn/mozilla/tech/xul/menuseparator/index.html
new file mode 100644
index 0000000000..5b00451c60
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/menuseparator/index.html
@@ -0,0 +1,435 @@
+---
+title: menuseparator
+slug: Mozilla/Tech/XUL/menuseparator
+tags:
+ - XUL Elements
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/menuseparator
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>Used to create a separator between menu items. Typically drawn as a thin line.</p>
+<p>More information is available in the <a href="cn/XUL_Tutorial/Simple_Menu_Bars">XUL tutorial</a>.</p>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-acceltext">acceltext</a>, <a href="#a-accesskey">accesskey</a>, <a href="#a-allowevents">allowevents</a>, <a href="#a-command">command</a>, <a href="#a-crop">crop</a>, <a href="#a-disabled">disabled</a>, <a href="#a-image">image</a>, <a href="#a-label">label</a>, <a href="#a-selected">selected</a>, <a href="#a-tabindex">tabindex</a>, <a href="#a-value">value</a></dd>
+</dl>
+<dl>
+ <dt>
+ Properties</dt>
+ <dd>
+ <a href="#p-accessibleType">accessibleType</a>, <a href="#p-accessKey">accessKey</a>, <a href="#p-command">command</a>, <a href="#p-menuitem.control">control</a>, <a href="#p-crop">crop</a>, <a href="#p-disabled">disabled</a>, <a href="#p-image">image</a>, <a href="#p-label">label</a>, <a href="#p-labelElement">labelElement</a>, <a href="#p-parentContainer">parentContainer</a>, <a href="#p-selected">selected</a>, <a href="#p-tabIndex">tabIndex</a>, <a href="#p-value">value</a></dd>
+</dl>
+<h3 id="Examples" name="Examples">Examples</h3>
+<pre>&lt;menu label="Help"&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem label="Contents"/&gt;
+ &lt;menuseparator/&gt;
+ &lt;menuitem label="Release Notes"/&gt;
+ &lt;/menupopup&gt;
+&lt;/menu&gt;
+</pre>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p> </p><div id="a-acceltext">
+
+<dl>
+ <dt>
+ <code id="a-acceltext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/acceltext">acceltext</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Text that appears beside beside the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> label to indicate the shortcut key (accelerator key) to use to invoke the command. If this value is set, it overrides an assigned key set in the key attribute. This attribute does not apply to menus directly on the menubar.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-accesskey">
+
+
+
+
+<dl>
+ <dt><code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code></dt>
+ <dd>类型:
+ <i>character【字符】</i>
+ </dd>
+ <dd>本属性允许为控件(元素)设定一个字符作为快捷键,这个字符应该是 <code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code> 属性文本中的一个字符。该字符将会被加下划线以重点强调,平台和主体的变换并不影响这一表现行为。 当用户点击 ALT (在其他平台上具有类似功能的键) 和这个字符对应的按键时, 控件(元素)将立刻被从窗口中的某处激活或/并且获得焦点 <b>。虽说字符不分大小写,但是当label中存在大写字符和小写字符时,快捷键的字符将首先选择与之完全匹配的那一个,如果label中存在两个或更多的与accesskey字符相同的字符,其中的第一个字符将被加下划线。</b></dd>
+ <dt>      *(有些键在监听按键事件时,分别对应event.ctrlKey和event.metaKey。)</dt>
+</dl>
+
+<p> </p>
+
+<h4 id="Example" name="Example">Example</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_accesskey_attr.png"></div>
+
+<pre>&lt;vbox&gt;
+ &lt;label value="Enter Name" accesskey="e" control="myName"/&gt;
+ &lt;textbox id="myName"/&gt;
+ &lt;button label="Cancel" accesskey="n"/&gt;
+ &lt;button label="Ok" accesskey="O"/&gt;
+&lt;/vbox&gt;
+</pre>
+
+<h4 id="See_also" name="See_also">See also</h4>
+
+<p><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute, <code id="a-acceltext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/acceltext">acceltext</a></code> attribute</p>
+
+<p></p>
+</div> <div id="a-allowevents">
+
+
+<dl>
+ <dt><code id="a-allowevents"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allowevents">allowevents</a></code></dt>
+ <dd>Type:
+ <i>boolean<br>
+ </i>
+ 类型:boolean</dd>
+ <dd>If true, events are passed to children of the element. Otherwise, events are passed to the element only.<br>
+ 如果为真,事件向子元素传递。否则,事件只传递到当前元素。</dd>
+</dl>
+
+
+
+<p></p>
+</div> <div id="a-command">
+
+<dl>
+ <dt>
+ <code id="a-command"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/command">command</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ element id</i>
+ </dd>
+ <dd>
+ Set to the <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> of a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/command" title="command">command</a></code> element that is being observed by the element.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-crop">
+
+<dl>
+ <dt>
+ <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ one of the values below</i>
+ </dd>
+ <dd>
+ If the label of the element is too big to fit in its given space, the text will be cropped on the side specified by the <code>crop</code> attribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.</dd>
+</dl>
+<ul>
+ <li><code>start</code>: The text will be cropped on its left side.</li>
+ <li><code>end</code>: The text will be cropped on its right side.</li>
+ <li><code>left</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its left side.</li>
+ <li><code>right</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its right side.</li>
+ <li><code>center</code>: The text will be cropped in the middle, showing both the start and end of the text normally.</li>
+ <li><code>none</code>: The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.</li>
+</ul>
+
+<p></p>
+</div> <div id="a-disabled">
+
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd> </dd>
+ <dd>
+ <h5 id="类型boolean">类型:<em>boolean</em></h5>
+ </dd>
+ <dd>
+ <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>
+
+ <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>
+
+ <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
+ </dd>
+</dl>
+
+<h4 id="示例:">示例:</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>
+
+<pre><code>// Disabling an element
+document.getElementById('buttonRemove').setAttribute("disabled", "true");
+
+// Enabling back an element by removing the "disabled" attribute
+document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>
+
+<p></p><div class="blockIndicator standardNote">
+ <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
+ <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
+</div><p></p>
+</div> <div id="a-image">
+
+<dl>
+ <dt>
+ <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ image URL</i>
+ </dd>
+ <dd>
+ The URL of the image to appear on the element. If this attribute is empty or left out, no image appears. The position of the image is determined by the <code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code> and <code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code> attributes.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-label">
+
+<dl>
+ <dt>
+ <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The label that will appear on the element. If this is left out, no text appears.<br>
+ label 在元素上显示。如果左侧出界,则不显示任何文字。</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-selected">
+
+<dl>
+ <dt>
+ <code id="a-selected"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/selected">selected</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Indicates whether the element is selected or not. This value is read-only. To change the selection, set either the <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code> or <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedItem">selectedItem</a></span></code> property of the containing element.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-tabindex">
+
+
+<dl>
+ <dt><code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code></dt>
+ <dd>Type:<em>integer</em></dd>
+ <dd>当用户按下 "<kbd>tab</kbd>" 键时焦点移动到元素上的顺序。<code>tabindex</code> 数字越大,顺序越靠后。</dd>
+</dl>
+
+
+
+<p></p>
+</div> <div id="a-value">
+
+<dl>
+ <dt>
+ <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ The string attribute allows you to associate a data value with an element. It is not used for any specific purpose, but you can access it with a script for your own use.</dd>
+</dl>
+
+<p></p>
+</div><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p> </p><div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-accessKey">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessKey">accessKey</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ character</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-command">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/command">command</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ element id</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-command"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/command">command</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-menuitem.control">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menuitem.control">control</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> element</i>
+ </dd>
+ <dd>
+ Returns the enclosing <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> that the item is inside, if any, or <code>null</code> if there is no enclosing menu.</dd>
+</dl>
+
+<p></p></div> <div id="p-crop">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/crop">crop</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-disabled">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/disabled">disabled</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-image">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/image">image</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ image URL</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-label">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/label">label</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-labelElement">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/labelElement">labelElement</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/label" title="label">label</a></code> element</i>
+ </dd>
+ <dd>
+ The <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/label" title="label">label</a></code> element associated with the control. This is set when a label has a <code id="a-control"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/control">control</a></code> attribute pointing to this element. This property will be <code>null</code> when no label is associated with the control.</dd>
+</dl>
+
+<p></p></div> <div id="p-parentContainer">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/parentContainer">parentContainer</a></span></code> </dt>
+ <dd>
+ Type:
+ <i>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> element</i>
+ </dd>
+ <dd>
+ Read only property that returns the containing <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> element, or <code>null</code> if there isn't a containing menu.</dd>
+</dl>
+
+<p></p></div> <div id="p-selected">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selected">selected</a></span></code>&lt;magic name="\"PAGENAME\"/"&gt;&lt;/magic&gt;</dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ This property's value is <code>true</code> if this element is selected, or <code>false</code> if it is not. This property is read only.</dd>
+</dl></div> <div id="p-tabIndex">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tabIndex">tabIndex</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-value">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/value">value</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code> attribute.</dd>
+</dl>
+
+<p></p></div><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<dl>
+ <dt>
+ Elements</dt>
+ <dd>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menubar" title="menubar">menubar</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code></dd>
+</dl>
+<dl>
+ <dt>
+ Interfaces</dt>
+ <dd>
+ <a href="cn/NsIAccessibleProvider">nsIAccessibleProvider</a>, <a href="cn/NsIDOMXULContainerItemElement">nsIDOMXULContainerItemElement</a>, <a href="cn/NsIDOMXULSelectControlItemElement">nsIDOMXULSelectControlItemElement</a></dd>
+</dl>
+<p> </p>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/method/extra1/index.html b/files/zh-cn/mozilla/tech/xul/method/extra1/index.html
new file mode 100644
index 0000000000..33546b4a30
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/method/extra1/index.html
@@ -0,0 +1,15 @@
+---
+title: extra1
+slug: Mozilla/Tech/XUL/Method/extra1
+translation_of: Archive/Mozilla/XUL/Method/extra1
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefMeth_breadcrumbs">« <a href="/en-US/docs/XUL_Reference" title="/en-US/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <span id="m-extra1"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/extra1">extra1()</a></code></span></dt>
+ <dd>
+ 返回值类型:无返回值</dd>
+ <dd>
+ 调用该方法可以模拟对extra1按钮的点击,同时也会触发并执行该元素的<code id="a-onextra1"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/onextra1">onextra1</a></code>属性上设置的代码.</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/method/focus/index.html b/files/zh-cn/mozilla/tech/xul/method/focus/index.html
new file mode 100644
index 0000000000..690ba10358
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/method/focus/index.html
@@ -0,0 +1,15 @@
+---
+title: focus
+slug: Mozilla/Tech/XUL/Method/focus
+translation_of: Archive/Mozilla/XUL/Method/focus
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefMeth_breadcrumbs">« <a href="/en-US/docs/XUL_Reference" title="/en-US/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus()</a></code></span></dt>
+ <dd>
+ 返回值类型: 无返回值</dd>
+ <dd>
+ 让指定的元素获得键盘焦点.</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/method/getbrowserfortab/index.html b/files/zh-cn/mozilla/tech/xul/method/getbrowserfortab/index.html
new file mode 100644
index 0000000000..483579d074
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/method/getbrowserfortab/index.html
@@ -0,0 +1,15 @@
+---
+title: getBrowserForTab
+slug: Mozilla/Tech/XUL/Method/getBrowserForTab
+translation_of: Archive/Mozilla/XUL/Method/getBrowserForTab
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefMeth_breadcrumbs">« <a href="/en-US/docs/XUL_Reference" title="/en-US/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <span id="m-getBrowserForTab"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getBrowserForTab">getBrowserForTab( tab )</a></code></span></dt>
+ <dd>
+ 返回值类型: <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/browser" title="browser">browser</a></code>元素</dd>
+ <dd>
+ 返回于指定的<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/tab" title="tab">tab</a></code>元素相关联的<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/browser" title="browser">browser</a></code>元素.</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/method/getbutton/index.html b/files/zh-cn/mozilla/tech/xul/method/getbutton/index.html
new file mode 100644
index 0000000000..11b4f91e6d
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/method/getbutton/index.html
@@ -0,0 +1,15 @@
+---
+title: getButton
+slug: Mozilla/Tech/XUL/Method/getButton
+translation_of: Archive/Mozilla/XUL/Method/getButton
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefMeth_breadcrumbs">« <a href="/en-US/docs/XUL_Reference" title="/en-US/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <span id="m-getButton"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getButton">getButton( type )</a></code></span></dt>
+ <dd>
+ 返回值类型: <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/button" title="button">button</a></code>元素</dd>
+ <dd>
+ 返回当前对话框中指定类型的<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/button" title="button">button</a></code>元素.</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/method/increase/index.html b/files/zh-cn/mozilla/tech/xul/method/increase/index.html
new file mode 100644
index 0000000000..b7431b355b
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/method/increase/index.html
@@ -0,0 +1,21 @@
+---
+title: increase
+slug: Mozilla/Tech/XUL/Method/increase
+translation_of: Archive/Mozilla/XUL/Method/increase
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefMeth_breadcrumbs">« <a href="/en-US/docs/XUL_Reference" title="/en-US/docs/XUL_Reference">XUL Reference home</a></span></div>
+<div class="noinclude">
+ <dl>
+ <dd>
+ 拥有该方法的元素类型: <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/scale" title="scale">scale</a></code> <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/textbox" title="textbox">textbox</a></code></dd>
+ </dl>
+</div>
+<dl>
+ <dt>
+ <span id="m-increase"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/increase">increase()</a></code></span></dt>
+ <dd>
+ 返回值类型: 无返回值</dd>
+ <dd>
+ 增大刻度条控件(scale元素)或者数字输入框控件(type属性为number的textbox元素)中的数字值(按照其<code id="a-increment"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/increment">increment</a></code>属性指定的值).</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/method/index.html b/files/zh-cn/mozilla/tech/xul/method/index.html
new file mode 100644
index 0000000000..e5d7d023c0
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/method/index.html
@@ -0,0 +1,170 @@
+---
+title: Methods
+slug: Mozilla/Tech/XUL/Method
+tags:
+ - XUL Methods
+translation_of: Archive/Mozilla/XUL/Method
+---
+<p><span class="breadcrumbs XULRefMeth_breadcrumbs">« <a href="/en-US/docs/XUL_Reference" title="/en-US/docs/XUL_Reference">XUL Reference home</a></span> </p>
+<ul><li> <a href="cn/XUL/Method/acceptDialog">acceptDialog</a>
+</li><li> <a href="cn/XUL/Method/addItemToSelection">addItemToSelection</a>
+</li><li> <a href="cn/XUL/Method/addPane">addPane</a>
+</li><li> <a href="cn/XUL/Method/addProgressListener">addProgressListener</a>
+</li><li> <a href="cn/XUL/Method/addSession">addSession</a>
+</li><li> <a href="cn/XUL/Method/addTab">addTab</a>
+</li><li> <a href="cn/XUL/Method/advance">advance</a>
+</li><li> <a href="cn/XUL/Method/advanceSelectedTab">advanceSelectedTab</a>
+</li><li> <a href="cn/XUL/Method/appendCustomToolbar">appendCustomToolbar</a>
+</li><li> <a href="cn/XUL/Method/appendGroup">appendGroup</a>
+</li><li> <a href="cn/XUL/Method/appendItem">appendItem</a>
+</li><li> <a href="cn/XUL/Method/appendNotification">appendNotification</a>
+</li><li> <a href="cn/XUL/Method/blur">blur</a>
+</li><li> <a href="cn/XUL/Method/cancel">cancel</a>
+</li><li> <a href="cn/XUL/Method/cancelDialog">cancelDialog</a>
+</li><li> <a href="cn/XUL/Method/centerWindowOnScreen">centerWindowOnScreen</a>
+</li><li> <a href="cn/XUL/Method/checkAdjacentElement">checkAdjacentElement</a>
+</li><li> <a href="cn/XUL/Method/clearResults">clearResults</a>
+</li><li> <a href="cn/XUL/Method/clearSelection">clearSelection</a>
+</li><li> <a href="cn/XUL/Method/click">click</a>
+</li><li> <a href="cn/XUL/Method/close">close</a>
+</li><li> <a href="cn/XUL/Method/collapseToolbar">collapseToolbar</a>
+</li><li> <a href="cn/XUL/Method/contains">contains</a>
+</li><li> <a href="cn/XUL/Method/decrease">decrease</a>
+</li><li> <a href="cn/XUL/Method/decreasePage">decreasePage</a>
+</li><li> <a href="cn/XUL/Method/doCommand">doCommand</a>
+</li><li> <a href="cn/XUL/Method/ensureElementIsVisible">ensureElementIsVisible</a>
+</li><li> <a href="cn/XUL/Method/ensureIndexIsVisible">ensureIndexIsVisible</a>
+</li><li> <a href="cn/XUL/Method/ensureSelectedElementIsVisible">ensureSelectedElementIsVisible</a>
+</li><li> <a href="cn/XUL/Method/expandToolbar">expandToolbar</a>
+</li><li> <a href="cn/XUL/Method/extra1">extra1</a>
+</li><li> <a href="cn/XUL/Method/extra2">extra2</a>
+</li><li> <a href="cn/XUL/Method/focus">focus</a>
+</li><li> <a href="cn/XUL/Method/getBrowserAtIndex">getBrowserAtIndex</a>
+</li><li> <a href="cn/XUL/Method/getBrowserForDocument">getBrowserForDocument</a>
+</li><li> <a href="cn/XUL/Method/getBrowserForTab">getBrowserForTab</a>
+</li><li> <a href="cn/XUL/Method/getBrowserIndexForDocument">getBrowserIndexForDocument</a>
+</li><li> <a href="cn/XUL/Method/getButton">getButton</a>
+</li><li> <a href="cn/XUL/Method/getDefaultSession">getDefaultSession</a>
+</li><li> <a href="cn/XUL/Method/getEditor">getEditor</a>
+</li><li> <a href="cn/XUL/Method/getElementsByAttribute">getElementsByAttribute</a>
+</li><li> <a href="cn/XUL/Method/getFormattedString">getFormattedString</a>
+</li><li> <a href="cn/XUL/Method/getHTMLEditor">getHTMLEditor</a>
+</li><li> <a href="cn/XUL/Method/getIndexOfFirstVisibleRow">getIndexOfFirstVisibleRow</a>
+</li><li> <a href="cn/XUL/Method/getIndexOfItem">getIndexOfItem</a>
+</li><li> <a href="cn/XUL/Method/getItemAtIndex">getItemAtIndex</a>
+</li><li> <a href="cn/XUL/Method/getNextItem">getNextItem</a>
+</li><li> <a href="cn/XUL/Method/getNotificationBox">getNotificationBox</a>
+</li><li> <a href="cn/XUL/Method/getNotificationWithValue">getNotificationWithValue</a>
+</li><li> <a href="cn/XUL/Method/getNumberOfVisibleRows">getNumberOfVisibleRows</a>
+</li><li> <a href="cn/XUL/Method/getPageById">getPageById</a>
+</li><li> <a href="cn/XUL/Method/getPreviousItem">getPreviousItem</a>
+</li><li> <a href="cn/XUL/Method/getResultAt">getResultAt</a>
+</li><li> <a href="cn/XUL/Method/getResultCount">getResultCount</a>
+</li><li> <a href="cn/XUL/Method/getResultValueAt">getResultValueAt</a>
+</li><li> <a href="cn/XUL/Method/getRowCount">getRowCount</a>
+</li><li> <a href="cn/XUL/Method/getSearchAt">getSearchAt</a>
+</li><li> <a href="cn/XUL/Method/getSelectedItem">getSelectedItem</a>
+</li><li> <a href="cn/XUL/Method/getSession">getSession</a>
+</li><li> <a href="cn/XUL/Method/getSessionByName">getSessionByName</a>
+</li><li> <a href="cn/XUL/Method/getSessionResultAt">getSessionResultAt</a>
+</li><li> <a href="cn/XUL/Method/getSessionStatusAt">getSessionStatusAt</a>
+</li><li> <a href="cn/XUL/Method/getSessionValueAt">getSessionValueAt</a>
+</li><li> <a href="cn/XUL/Method/getString">getString</a>
+</li><li> <a href="cn/XUL/Method/goBack">goBack</a>
+</li><li> <a href="cn/XUL/Method/goBackGroup">goBackGroup</a>
+</li><li> <a href="cn/XUL/Method/goDown">goDown</a>
+</li><li> <a href="cn/XUL/Method/goForward">goForward</a>
+</li><li> <a href="cn/XUL/Method/goForwardGroup">goForwardGroup</a>
+</li><li> <a href="cn/XUL/Method/goHome">goHome</a>
+</li><li> <a href="cn/XUL/Method/goTo">goTo</a>
+</li><li> <a href="cn/XUL/Method/gotoIndex">gotoIndex</a>
+</li><li> <a href="cn/XUL/Method/goUp">goUp</a>
+</li><li> <a href="cn/XUL/Method/hasUserValue">hasUserValue</a>
+</li><li> <a href="cn/XUL/Method/hidePopup">hidePopup</a>
+</li><li> <a href="cn/XUL/Method/increase">increase</a>
+</li><li> <a href="cn/XUL/Method/increasePage">increasePage</a>
+</li><li> <a href="cn/XUL/Method/insertItem">insertItem</a>
+</li><li> <a href="cn/XUL/Method/insertItemAt">insertItemAt</a>
+</li><li> <a href="cn/XUL/Method/invertSelection">invertSelection</a>
+</li><li> <a href="cn/XUL/Method/loadGroup">loadGroup</a>
+</li><li> <a href="cn/XUL/Method/loadOneTab">loadOneTab</a>
+</li><li> <a href="cn/XUL/Method/loadTabs">loadTabs</a>
+</li><li> <a href="cn/XUL/Method/loadURI">loadURI</a>
+</li><li> <a href="cn/XUL/Method/loadURIWithFlags">loadURIWithFlags</a>
+</li><li> <a href="cn/XUL/Method/makeEditable">makeEditable</a>
+</li><li> <a href="cn/XUL/Method/moveByOffset">moveByOffset</a>
+</li><li> <a href="cn/XUL/Method/moveTo">moveTo</a>
+</li><li> <a href="cn/XUL/Method/moveToAlertPosition">moveToAlertPosition</a>
+</li><li> <a href="cn/XUL/Method/onSearchComplete">onSearchComplete</a>
+</li><li> <a href="cn/XUL/Method/onTextEntered">onTextEntered</a>
+</li><li> <a href="cn/XUL/Method/onTextReverted">onTextReverted</a>
+</li><li> <a href="cn/XUL/Method/openPopup">openPopup</a>
+</li><li> <a href="cn/XUL/Method/openPopupAtScreen">openPopupAtScreen</a>
+</li><li> <a href="cn/XUL/Method/openSubDialog">openSubDialog</a>
+</li><li> <a href="cn/XUL/Method/openWindow">openWindow</a>
+</li><li> <a href="cn/XUL/Method/preferenceForElement">preferenceForElement</a>
+</li><li> <a href="cn/XUL/Method/reload">reload</a>
+</li><li> <a href="cn/XUL/Method/reloadAllTabs">reloadAllTabs</a>
+</li><li> <a href="cn/XUL/Method/reloadTab">reloadTab</a>
+</li><li> <a href="cn/XUL/Method/reloadWithFlags">reloadWithFlags</a>
+</li><li> <a href="cn/XUL/Method/removeAllItems">removeAllItems</a>
+</li><li> <a href="cn/XUL/Method/removeAllNotifications">removeAllNotifications</a>
+</li><li> <a href="cn/XUL/Method/removeAllTabsBut">removeAllTabsBut</a>
+</li><li> <a href="cn/XUL/Method/removeCurrentNotification">removeCurrentNotification</a>
+</li><li> <a href="cn/XUL/Method/removeCurrentTab">removeCurrentTab</a>
+</li><li> <a href="cn/XUL/Method/removeItemAt">removeItemAt</a>
+</li><li> <a href="cn/XUL/Method/removeItemFromSelection">removeItemFromSelection</a>
+</li><li> <a href="cn/XUL/Method/removeNotification">removeNotification</a>
+</li><li> <a href="cn/XUL/Method/removeProgressListener">removeProgressListener</a>
+</li><li> <a href="cn/XUL/Method/removeSession">removeSession</a>
+</li><li> <a href="cn/XUL/Method/removeTab">removeTab</a>
+</li><li> <a href="cn/XUL/Method/removeTransientNotifications">removeTransientNotifications</a>
+</li><li> <a href="cn/XUL/Method/replaceGroup">replaceGroup</a>
+</li><li> <a href="cn/XUL/Method/reset">reset</a>
+</li><li> <a href="cn/XUL/Method/rewind">rewind</a>
+</li><li> <a href="cn/XUL/Method/scrollByIndex">scrollByIndex</a>
+</li><li> <a href="cn/XUL/Method/scrollByPixels">scrollByPixels</a>
+</li><li> <a href="cn/XUL/Method/scrollToIndex">scrollToIndex</a>
+</li><li> <a href="cn/XUL/Method/select">select</a>
+</li><li> <a href="cn/XUL/Method/selectAll">selectAll</a>
+</li><li> <a href="cn/XUL/Method/selectItem">selectItem</a>
+</li><li> <a href="cn/XUL/Method/selectItemRange">selectItemRange</a>
+</li><li> <a href="cn/XUL/Method/setSelectionRange">setSelectionRange</a>
+</li><li> <a href="cn/XUL/Method/showPane">showPane</a>
+</li><li> <a href="cn/XUL/Method/showPopup">showPopup</a>
+</li><li> <a href="cn/XUL/Method/sizeTo">sizeTo</a>
+</li><li> <a href="cn/XUL/Method/startEditing">startEditing</a>
+</li><li> <a href="cn/XUL/Method/stop">stop</a>
+</li><li> <a href="cn/XUL/Method/stopEditing">stopEditing</a>
+</li><li> <a href="cn/XUL/Method/syncSessions">syncSessions</a>
+</li><li> <a href="cn/XUL/Method/timedSelect">timedSelect</a>
+</li><li> <a href="cn/XUL/Method/toggleItemSelection">toggleItemSelection</a>
+</li></ul>
+<h3 id="Related_DOM_element_methods" name="Related_DOM_element_methods"> Related DOM element methods </h3>
+<ul><li> <a href="cn/DOM/element.addEventListener">DOM:element.addEventListener</a>
+</li><li> <a href="cn/DOM/element.appendChild">DOM:element.appendChild</a>
+</li><li> <a href="cn/DOM/element.dispatchEvent">DOM:element.dispatchEvent</a>
+</li><li> <a href="cn/DOM/element.getAttribute">DOM:element.getAttribute</a>
+</li><li> <a href="cn/DOM/element.getAttributeNode">DOM:element.getAttributeNode</a>
+</li><li> <a href="cn/DOM/element.getAttributeNodeNS">DOM:element.getAttributeNodeNS</a>
+</li><li> <a href="cn/DOM/element.getAttributeNS">DOM:element.getAttributeNS</a>
+</li><li> <a href="cn/DOM/element.getElementsByTagName">DOM:element.getElementsByTagName</a>
+</li><li> <a href="cn/DOM/element.getElementsByTagNameNS">DOM:element.getElementsByTagNameNS</a>
+</li><li> <a href="cn/DOM/element.hasAttribute">DOM:element.hasAttribute</a>
+</li><li> <a href="cn/DOM/element.hasAttributeNS">DOM:element.hasAttributeNS</a>
+</li><li> <a href="cn/DOM/element.hasAttributes">DOM:element.hasAttributes</a>
+</li><li> <a href="cn/DOM/element.hasChildNodes">DOM:element.hasChildNodes</a>
+</li><li> <a href="cn/DOM/element.insertBefore">DOM:element.insertBefore</a>
+</li><li> <a href="cn/DOM/element.isSupported">DOM:element.isSupported</a>
+</li><li> <a href="cn/DOM/element.normalize">DOM:element.normalize</a>
+</li><li> <a href="cn/DOM/element.removeAttribute">DOM:element.removeAttribute</a>
+</li><li> <a href="cn/DOM/element.removeAttributeNode">DOM:element.removeAttributeNode</a>
+</li><li> <a href="cn/DOM/element.removeAttributeNS">DOM:element.removeAttributeNS</a>
+</li><li> <a href="cn/DOM/element.removeChild">DOM:element.removeChild</a>
+</li><li> <a href="cn/DOM/element.removeEventListener">DOM:element.removeEventListener</a>
+</li><li> <a href="cn/DOM/element.replaceChild">DOM:element.replaceChild</a>
+</li><li> <a href="cn/DOM/element.setAttribute">DOM:element.setAttribute</a>
+</li><li> <a href="cn/DOM/element.setAttributeNode">DOM:element.setAttributeNode</a>
+</li><li> <a href="cn/DOM/element.setAttributeNodeNS">DOM:element.setAttributeNodeNS</a>
+</li><li> <a href="cn/DOM/element.setAttributeNS">DOM:element.setAttributeNS</a>
+</li></ul>
diff --git a/files/zh-cn/mozilla/tech/xul/method/reset/index.html b/files/zh-cn/mozilla/tech/xul/method/reset/index.html
new file mode 100644
index 0000000000..258f4d53df
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/method/reset/index.html
@@ -0,0 +1,15 @@
+---
+title: reset
+slug: Mozilla/Tech/XUL/Method/reset
+translation_of: Archive/Mozilla/XUL/Method/reset
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefMeth_breadcrumbs">« <a href="/en-US/docs/XUL_Reference" title="/en-US/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <span id="m-reset"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/reset">reset()</a></code></span></dt>
+ <dd>
+ 返回值:无返回值</dd>
+ <dd>
+ 将用户偏好重置为默认值.</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/method/stop/index.html b/files/zh-cn/mozilla/tech/xul/method/stop/index.html
new file mode 100644
index 0000000000..181a6123ae
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/method/stop/index.html
@@ -0,0 +1,15 @@
+---
+title: stop
+slug: Mozilla/Tech/XUL/Method/stop
+translation_of: Archive/Mozilla/XUL/Method/stop
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefMeth_breadcrumbs">« <a href="/en-US/docs/XUL_Reference" title="/en-US/docs/XUL_Reference">XUL Reference home</a></span></div>
+<dl>
+ <dt>
+ <span id="m-stop"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/stop">stop()</a></code></span></dt>
+ <dd>
+ 返回值: 无返回值</dd>
+ <dd>
+ 效果等同于按下了停止按钮,停止当前页面中文档的加载.</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/namespaces/index.html b/files/zh-cn/mozilla/tech/xul/namespaces/index.html
new file mode 100644
index 0000000000..73a5099ae6
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/namespaces/index.html
@@ -0,0 +1,73 @@
+---
+title: Namespaces
+slug: Mozilla/Tech/XUL/Namespaces
+translation_of: Archive/Mozilla/XUL/Namespaces
+---
+<p> </p>
+
+<p>除此文档外,请参阅<a href="/en/SVG/Namespaces_Crash_Course" title="en/SVG/Namespaces_Crash_Course">Namespaces Crash Course</a>。</p>
+
+<p><strong>XML namespaces</strong> 提供了区分重复元素和属性名称的方法。当XML文档包含来自两个或多个不同的XML模式 (或者DTD)的元素和属性时,可能会出现重复元素和属性名称。引用 <a class="external" href="http://en.wikipedia.org/wiki/Namespace">Wikipedia</a>: "一般来说,namespaces是一个抽象的容器,为项目提供上下文... 它拥有并且允许消除具有相同名称的项目的消歧。"</p>
+
+<p>如果你熟悉C++命名空间、Java包、Perl包或者Python模块导入,那么你已经熟悉了namespaces概念。</p>
+
+<p>XML namespace 由唯一的名称 (称为URI, 而不是URL, 即使它看起来像URL)标识。URI 可以是任何字符串,虽然大多数人选择基于URL的URI,因为URL是实现我们期望的唯一性的一种简单的方法。虽然没有任何理由去阻止其他人使用这个namespaces <code>http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul</code>, 但是不太可能有人会不小心选择这个namespaces。即使他们意外的选择了这个namespaces,他们也不可能在他们的模式/DTD中定义与XUL相同的元素 。</p>
+
+<p>XML namespace中的任何元素类型或者属性名称都可以通过其XML  namespace和其“local name”来唯一标识。 这两个项目一起定义了一个限定名称,或者 <a class="external" href="http://www.w3.org/TR/REC-xml-names/#dt-qualname">QName</a>.</p>
+
+<p>例如: <code>&lt;xul:textbox/&gt;</code> 使用名为"xul"的namespace和本地名称 "textbox"。它不同于例子所示,例如: <code>&lt;foobar:textbox/&gt;</code> 可能出现在同一个文档中。<strong>xul</strong>和<strong>foobar</strong> namespaces必须定义在它们所使用的XML文档的顶部, 如下:</p>
+
+<pre> &lt;foobar:some-element
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:foobar="the-foobar-namespace"&gt;
+ &lt;xul:textbox id="foo" value="bar"/&gt;
+ &lt;foobar:textbox favorite-food="pancakes"/&gt;
+ &lt;/foobar:some-element&gt;
+</pre>
+
+<p>注意我已经在同一个文档中混合了两个<code>&lt;textboxes/&gt;</code> 。区分他们的唯一的方法是他们有不同含义的namespaces.</p>
+
+<p>还有一个事情需要了解:“default namespace(默认namespace)”。每个XML元素有一个 "default namespace", 而且它总是和XUL 元素一起使用。在XUL 文档中,您通常会看到:</p>
+
+<pre> &lt;window
+ id="foo"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;
+ ...
+ ...
+ &lt;/window&gt;
+</pre>
+
+<p>在XHTML 文档中,您会看到:</p>
+
+<pre> &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
+ ...
+ ...
+ &lt;/html&gt;
+</pre>
+
+<p>与之前相比,这里有一个非常微妙的差别。 我之前写过<code>xmlns<strong>:xul</strong>="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"</code> ,但是这儿的:<strong>xul</strong> 部分被省略。这意味着对XML解析器来说,<code>http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul</code> 是元素及其后代元素的 <strong>default namespace</strong> (除非在后代元素上被default namespace覆盖),并且,如果没有namespace 的任何元素(即,没有前缀和colon)属于default namespace。这就是为什么我们可以使用简写<code>&lt;textbox/&gt;</code>来代替XUL中的 <code>&lt;xul:textbox/&gt;</code> (即使后者在没有使用<code>http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul</code> 作为default namespace是正确的) -- XUL namespace被定义为最顶层元素的默认值。换句话说,default namespace允许一种简短的概括被用于一个元素的所有后代元素。</p>
+
+<p>这里有一个问题:在下面的XML文档中,什么namespace包含了foo元素?</p>
+
+<pre> &lt;foo/&gt;
+</pre>
+
+<p>答案是它不在namespace, 或者它在namespace中由空字符串表示:</p>
+
+<pre> &lt;foo xmlns=""/&gt;
+</pre>
+
+<p>第二个例子在语义上等同于第一个例子。</p>
+
+<p>那么第二个问题是:  <code>bar</code>、 <code>baz</code> 和 <code>quux</code> 是什么名称空间中的属性?</p>
+
+<p> </p>
+
+<pre> &lt;foo bar="value"&gt;
+ &lt;element xmlns="namespace!" baz="value"&gt;
+ &lt;element quux="value"/&gt;
+ &lt;/element&gt;
+ &lt;/foo&gt;
+</pre>
+
+<p><code>bar</code> 显然不在namespace中。那么 <code>baz<font face="Open Sans, arial, x-locale-body, sans-serif"><span style="background-color: #ffffff;">和</span></font></code><code>quux</code>怎么样呢?答案是他们也不在namespace中。实际上,在namespace中没有任何前缀不确定的属性,主要是因为XML最初没有namespaces,而且从那时起,所有的XML必须保持在无namespace.这是XML namespaces常年混乱的根源。</p>
diff --git a/files/zh-cn/mozilla/tech/xul/popup/index.html b/files/zh-cn/mozilla/tech/xul/popup/index.html
new file mode 100644
index 0000000000..05ce34c3bc
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/popup/index.html
@@ -0,0 +1,23 @@
+---
+title: popup
+slug: Mozilla/Tech/XUL/popup
+tags:
+ - XUL Elements
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/popup
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>The popup element is equivalent to the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code> element which should be used instead. See the documentation on the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code> element for more information.</p>
+<p>popup元素和<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code>元素在功能上是等价的,具体用法可以参考<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code>的说明文档。</p>
+<p> </p>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/property/accessibletype/index.html b/files/zh-cn/mozilla/tech/xul/property/accessibletype/index.html
new file mode 100644
index 0000000000..ae445e8bdb
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/accessibletype/index.html
@@ -0,0 +1,183 @@
+---
+title: accessibleType
+slug: Mozilla/Tech/XUL/Property/accessibleType
+translation_of: Archive/Mozilla/XUL/Property/accessibleType
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+<div class="noinclude">
+ <p>Possible values are:</p>
+ <table>
+ <tbody>
+ <tr>
+ <th>Constant</th>
+ <th>Value</th>
+ </tr>
+ <tr>
+ <td>XULAlert</td>
+ <td>1001</td>
+ </tr>
+ <tr>
+ <td>XULButton</td>
+ <td>1002</td>
+ </tr>
+ <tr>
+ <td>XULCheckbox</td>
+ <td>1003</td>
+ </tr>
+ <tr>
+ <td>XULColorPicker</td>
+ <td>1004</td>
+ </tr>
+ <tr>
+ <td>XULColorPickerTile</td>
+ <td>1005</td>
+ </tr>
+ <tr>
+ <td>XULCombobox</td>
+ <td>1006</td>
+ </tr>
+ <tr>
+ <td>XULDropmarker</td>
+ <td>1007</td>
+ </tr>
+ <tr>
+ <td>XULGroupbox</td>
+ <td>1008</td>
+ </tr>
+ <tr>
+ <td>XULImage</td>
+ <td>1009</td>
+ </tr>
+ <tr>
+ <td>XULLink</td>
+ <td>100A</td>
+ </tr>
+ <tr>
+ <td>XULListbox</td>
+ <td>100B</td>
+ </tr>
+ <tr>
+ <td>XULListCell</td>
+ <td>1026</td>
+ </tr>
+ <tr>
+ <td>XULListHead</td>
+ <td>1024</td>
+ </tr>
+ <tr>
+ <td>XULListHeader</td>
+ <td>1025</td>
+ </tr>
+ <tr>
+ <td>XULListitem</td>
+ <td>100C</td>
+ </tr>
+ <tr>
+ <td>XULMenubar</td>
+ <td>100D</td>
+ </tr>
+ <tr>
+ <td>XULMenuitem</td>
+ <td>100E</td>
+ </tr>
+ <tr>
+ <td>XULMenupopup</td>
+ <td>100F</td>
+ </tr>
+ <tr>
+ <td>XULMenuSeparator</td>
+ <td>1010</td>
+ </tr>
+ <tr>
+ <td>XULPane</td>
+ <td>1011</td>
+ </tr>
+ <tr>
+ <td>XULProgressMeter</td>
+ <td>1012</td>
+ </tr>
+ <tr>
+ <td>XULScale</td>
+ <td>1013</td>
+ </tr>
+ <tr>
+ <td>XULStatusBar</td>
+ <td>1014</td>
+ </tr>
+ <tr>
+ <td>XULRadioButton</td>
+ <td>1015</td>
+ </tr>
+ <tr>
+ <td>XULRadioGroup</td>
+ <td>1016</td>
+ </tr>
+ <tr>
+ <td>XULTab</td>
+ <td>1017</td>
+ </tr>
+ <tr>
+ <td>XULTabBox</td>
+ <td>1018</td>
+ </tr>
+ <tr>
+ <td>XULTabs</td>
+ <td>1019</td>
+ </tr>
+ <tr>
+ <td>XULText</td>
+ <td>101A</td>
+ </tr>
+ <tr>
+ <td>XULTextBox</td>
+ <td>101B</td>
+ </tr>
+ <tr>
+ <td>XULThumb</td>
+ <td>101C</td>
+ </tr>
+ <tr>
+ <td>XULTree</td>
+ <td>101D</td>
+ </tr>
+ <tr>
+ <td>XULTreeColumns</td>
+ <td>101E</td>
+ </tr>
+ <tr>
+ <td>XULTreeColumnItem</td>
+ <td>101F</td>
+ </tr>
+ <tr>
+ <td>XULToolbar</td>
+ <td>1020</td>
+ </tr>
+ <tr>
+ <td>XULToolbarSeparator</td>
+ <td>1021</td>
+ </tr>
+ <tr>
+ <td>XULTooltip</td>
+ <td>1022</td>
+ </tr>
+ <tr>
+ <td>XULToolbarButton</td>
+ <td>1023</td>
+ </tr>
+ </tbody>
+ </table>
+ <p>&lt;/div&gt;</p>
+</div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/property/accesskey/index.html b/files/zh-cn/mozilla/tech/xul/property/accesskey/index.html
new file mode 100644
index 0000000000..7b49328080
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/accesskey/index.html
@@ -0,0 +1,21 @@
+---
+title: accessKey
+slug: Mozilla/Tech/XUL/Property/accessKey
+translation_of: Archive/Mozilla/XUL/Property/accessKey
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessKey">accessKey</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ character</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code> attribute.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/property/browser.preferences/index.html b/files/zh-cn/mozilla/tech/xul/property/browser.preferences/index.html
new file mode 100644
index 0000000000..7a0bd25201
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/browser.preferences/index.html
@@ -0,0 +1,15 @@
+---
+title: browser.preferences
+slug: Mozilla/Tech/XUL/Property/browser.preferences
+translation_of: Archive/Mozilla/XUL/Property/browser.preferences
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/browser.preferences">preferences</a></span></code></dt>
+ <dd>
+ 类型: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPrefService" title="">nsIPrefService</a></code></dd>
+ <dd>
+ 这是一个只读属性,其值为一个<code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPref" title="">nsIPref</a></code>对象,可以用来读取或设置用户的首选项.</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/property/buttons/index.html b/files/zh-cn/mozilla/tech/xul/property/buttons/index.html
new file mode 100644
index 0000000000..67304e8fa1
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/buttons/index.html
@@ -0,0 +1,10 @@
+---
+title: buttons
+slug: Mozilla/Tech/XUL/Property/buttons
+translation_of: Archive/Mozilla/XUL/Property/buttons
+---
+<div class="noinclude"><span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl> <dt><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/buttons">buttons</a></span></code></dt> <dd>类型: 列表,下面的值用逗号分隔</dd> <dd>需要显示在对话框上的按钮的一个列表,使用逗号分隔。将按钮放置在合适的位置,将根据用户平台自动执行基本的事件处理。在列表中可以使用以下值: <ul> <li><code>accept</code>:“确定”按钮,按下按钮时将接受更改。此按钮为默认按钮。</li> <li><code>cancel</code>:“取消”按钮,将取消操作。</li> <li><code>help</code>:“帮助”按钮,在对话框显示一个“帮助”按钮。</li> <li><code>disclosure</code>:“更多信息”按钮,显示一个“more info”按钮。该按钮可能是一个按钮或一个三角形。</li> <li><code>extra1</code>:一个可选的额外的按钮。你可以通过<code><code id="a-buttonlabelextra1"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/buttonlabelextra1">buttonlabelextra1</a></code></code> 属性设置它的label。</li> <li><code>extra2</code>:第二个可选的额外的按钮。你可以通过 <code><code id="a-buttonlabelextra2"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/buttonlabelextra2">buttonlabelextra2</a></code></code> 属性设置它的label。</li> </ul> </dd>
+</dl>
+<div class="noinclude"> <p></p><div class="blockIndicator note"><strong>Note:</strong> If you don't want to display any buttons in the dialog box, set the value of this attribute to "," (a single comma).</div><p></p> <p></p>
+</div>
diff --git a/files/zh-cn/mozilla/tech/xul/property/command/index.html b/files/zh-cn/mozilla/tech/xul/property/command/index.html
new file mode 100644
index 0000000000..10993a17e6
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/command/index.html
@@ -0,0 +1,21 @@
+---
+title: command
+slug: Mozilla/Tech/XUL/Property/command
+translation_of: Archive/Mozilla/XUL/Property/command
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/command">command</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ element id</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-command"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/command">command</a></code> attribute.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/property/crop/index.html b/files/zh-cn/mozilla/tech/xul/property/crop/index.html
new file mode 100644
index 0000000000..54a99a746b
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/crop/index.html
@@ -0,0 +1,21 @@
+---
+title: crop
+slug: Mozilla/Tech/XUL/Property/crop
+translation_of: Archive/Mozilla/XUL/Property/crop
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/crop">crop</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code> attribute.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/property/defaultvalue/index.html b/files/zh-cn/mozilla/tech/xul/property/defaultvalue/index.html
new file mode 100644
index 0000000000..7aca9067cb
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/defaultvalue/index.html
@@ -0,0 +1,15 @@
+---
+title: defaultValue
+slug: Mozilla/Tech/XUL/Property/defaultValue
+translation_of: Archive/Mozilla/XUL/Property/defaultValue
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/defaultValue">defaultValue</a></span></code> </dt>
+ <dd>
+ 类型: 字符串</dd>
+ <dd>
+ 获取或设置一个<code>textbox</code>元素中显示的默认值.</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/property/disabled/index.html b/files/zh-cn/mozilla/tech/xul/property/disabled/index.html
new file mode 100644
index 0000000000..500640dc2a
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/disabled/index.html
@@ -0,0 +1,21 @@
+---
+title: disabled
+slug: Mozilla/Tech/XUL/Property/disabled
+translation_of: Archive/Mozilla/XUL/Property/disabled
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/disabled">disabled</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> attribute.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/property/image/index.html b/files/zh-cn/mozilla/tech/xul/property/image/index.html
new file mode 100644
index 0000000000..5079e489cd
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/image/index.html
@@ -0,0 +1,21 @@
+---
+title: image
+slug: Mozilla/Tech/XUL/Property/image
+translation_of: Archive/Mozilla/XUL/Property/image
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/image">image</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ image URL</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code> attribute.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/property/index.html b/files/zh-cn/mozilla/tech/xul/property/index.html
new file mode 100644
index 0000000000..caec3163d8
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/index.html
@@ -0,0 +1,266 @@
+---
+title: Property
+slug: Mozilla/Tech/XUL/Property
+tags:
+ - XUL Properties
+translation_of: Archive/Mozilla/XUL/Property
+---
+<p><span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span>
+</p>
+<ul><li> <a href="cn/XUL/Property/accessible">accessible</a>
+</li><li> <a href="cn/XUL/Property/accessKey">accessKey</a>
+</li><li> <a href="cn/XUL/Property/align">align</a>
+</li><li> <a href="cn/XUL/Property/allNotifications">allNotifications</a>
+</li><li> <a href="cn/XUL/Property/allowEvents">allowEvents</a>
+</li><li> <a href="cn/XUL/Property/alwaysOpenPopup">alwaysOpenPopup</a>
+</li><li> <a href="cn/XUL/Property/amIndicator">amIndicator</a>
+</li><li> <a href="cn/XUL/Property/appLocale">appLocale</a>
+</li><li> <a href="cn/XUL/Property/autoCheck">autoCheck</a>
+</li><li> <a href="cn/XUL/Property/autoFill">autoFill</a>
+</li><li> <a href="cn/XUL/Property/autoFillAfterMatch">autoFillAfterMatch</a>
+</li><li> <a href="cn/XUL/Property/boxObject">boxObject</a>
+</li><li> <a href="cn/XUL/Property/browsers">browsers</a>
+</li><li> <a href="cn/XUL/Property/builder">builder</a>
+</li><li> <a href="cn/XUL/Property/builderView">builderView</a>
+</li><li> <a href="cn/XUL/Property/buttons">buttons</a>
+</li><li> <a href="cn/XUL/Property/canAdvance">canAdvance</a>
+</li><li> <a href="cn/XUL/Property/canGoBack">canGoBack</a>
+</li><li> <a href="cn/XUL/Property/canGoForward">canGoForward</a>
+</li><li> <a href="cn/XUL/Property/canRewind">canRewind</a>
+</li><li> <a href="cn/XUL/Property/checked">checked</a>
+</li><li> <a href="cn/XUL/Property/checkState">checkState</a>
+</li><li> <a href="cn/XUL/Property/child">child</a>
+</li><li> <a href="cn/XUL/Property/children">children</a>
+</li><li> <a href="cn/XUL/Property/className">className</a>
+</li><li> <a href="cn/XUL/Property/clickSelectsAll">clickSelectsAll</a>
+</li><li> <a href="cn/XUL/Property/collapsed">collapsed</a>
+</li><li> <a href="cn/XUL/Property/color">color</a>
+</li><li> <a href="cn/XUL/Property/columns">columns</a>
+</li><li> <a href="cn/XUL/Property/command">command</a>
+</li><li> <a href="cn/XUL/Property/commandManager">commandManager</a>
+</li><li> <a href="cn/XUL/Property/completeDefaultIndex">completeDefaultIndex</a>
+</li><li> <a href="cn/XUL/Property/container">container</a>
+</li><li> <a href="cn/XUL/Property/contentDocument">contentDocument</a>
+</li><li> <a href="cn/XUL/Property/contentPrincipal">contentPrincipal</a>
+</li><li> <a href="cn/XUL/Property/contentTitle">contentTitle</a>
+</li><li> <a href="cn/XUL/Property/contentView">contentView</a>
+</li><li> <a href="cn/XUL/Property/contentViewerEdit">contentViewerEdit</a>
+</li><li> <a href="cn/XUL/Property/contentViewerFile">contentViewerFile</a>
+</li><li> <a href="cn/XUL/Property/contentWindow">contentWindow</a>
+</li><li> <a href="cn/XUL/Property/contextMenu">contextMenu</a>
+</li><li> <a href="cn/XUL/Property/control">control</a>
+</li><li> <a href="cn/XUL/Property/controller">controller</a>
+</li><li> <a href="cn/XUL/Property/controllers">controllers</a>
+</li><li> <a href="cn/XUL/Property/crop">crop</a>
+</li><li> <a href="cn/XUL/Property/current">current</a>
+</li><li> <a href="cn/XUL/Property/currentIndex">currentIndex</a>
+</li><li> <a href="cn/XUL/Property/currentItem">currentItem</a>
+</li><li> <a href="cn/XUL/Property/currentPage">currentPage</a>
+</li><li> <a href="cn/XUL/Property/currentPane">currentPane</a>
+</li><li> <a href="cn/XUL/Property/currentSet">currentSet</a>
+</li><li> <a href="cn/XUL/Property/currentURI">currentURI</a>
+</li><li> <a href="cn/XUL/Property/customToolbarCount">customToolbarCount</a>
+</li><li> <a href="cn/XUL/Property/database">database</a>
+</li><li> <a href="cn/XUL/Property/datasources">datasources</a>
+</li><li> <a href="cn/XUL/Property/date">date</a>
+</li><li> <a href="cn/XUL/Property/dateLeadingZero">dateLeadingZero</a>
+</li><li> <a href="cn/XUL/Property/dateValue">dateValue</a>
+</li><li> <a href="cn/XUL/Property/decimalPlaces">decimalPlaces</a>
+</li><li> <a href="cn/XUL/Property/decimalSymbol">decimalSymbol</a>
+</li><li> <a href="cn/XUL/Property/defaultButton">defaultButton</a>
+</li><li> <a href="cn/XUL/Property/description">description</a>
+</li><li> <a href="cn/XUL/Property/dir">dir</a>
+</li><li> <a href="cn/XUL/Property/disableAutocomplete">disableAutocomplete</a>
+</li><li> <a href="cn/XUL/Property/disableAutoComplete">disableAutoComplete</a>
+</li><li> <a href="cn/XUL/Property/disableKeyNavigation">disableKeyNavigation</a>
+</li><li> <a href="cn/XUL/Property/disableautoselect">disableautoselect</a>
+</li><li> <a href="cn/XUL/Property/disabled">disabled</a>
+</li><li> <a href="cn/XUL/Property/disableKeyNavigation">disableKeyNavigation</a>
+</li><li> <a href="cn/XUL/Property/dlgType">dlgType</a>
+</li><li> <a href="cn/XUL/Property/docShell">docShell</a>
+</li><li> <a href="cn/XUL/Property/documentCharsetInfo">documentCharsetInfo</a>
+</li><li> <a href="cn/XUL/Property/editable">editable</a>
+</li><li> <a href="cn/XUL/Property/editingColumn">editingColumn</a>
+</li><li> <a href="cn/XUL/Property/editingRow">editingRow</a>
+</li><li> <a href="cn/XUL/Property/editingSession">editingSession</a>
+</li><li> <a href="cn/XUL/Property/editor">editor</a>
+</li><li> <a href="cn/XUL/Property/editortype">editortype</a>
+</li><li> <a href="cn/XUL/Property/emptyText">emptyText</a>
+</li><li> <a href="cn/XUL/Property/enableColumnDrag">enableColumnDrag</a>
+</li><li> <a href="cn/XUL/Property/eventNode">eventNode</a>
+</li><li> <a href="cn/XUL/Property/firstOrdinalColumn">firstOrdinalColumn</a>
+</li><li> <a href="cn/XUL/Property/firstPermanentChild">firstPermanentChild</a>
+</li><li> <a href="cn/XUL/Property/flex">flex</a>
+</li><li> <a href="cn/XUL/Property/focused">focused</a>
+</li><li> <a href="cn/XUL/Property/focusedItem">focusedItem</a>
+</li><li> <a href="cn/XUL/Property/forceComplete">forceComplete</a>
+</li><li> <a href="cn/XUL/Property/group">group</a>
+</li><li> <a href="cn/XUL/Property/handleCtrlPageUpDown">handleCtrlPageUpDown</a>
+</li><li> <a href="cn/XUL/Property/handleCtrlTab">handleCtrlTab</a>
+</li><li> <a href="cn/XUL/Property/height">height</a>
+</li><li> <a href="cn/XUL/Property/hidden">hidden</a>
+</li><li> <a href="cn/XUL/Property/hideSeconds">hideSeconds</a>
+</li><li> <a href="cn/XUL/Property/homePage">homePage</a>
+</li><li> <a href="cn/XUL/Property/hour">hour</a>
+</li><li> <a href="cn/XUL/Property/hourLeadingZero">hourLeadingZero</a>
+</li><li> <a href="cn/XUL/Property/id">id</a>
+</li><li> <a href="cn/XUL/Property/ignoreBlurWhileSearching">ignoreBlurWhileSearching</a>
+</li><li> <a href="cn/XUL/Property/image">image</a>
+</li><li> <a href="cn/XUL/Property/increment">increment</a>
+</li><li> <a href="cn/XUL/Property/inputField">inputField</a>
+</li><li> <a href="cn/XUL/Property/inverted">inverted</a>
+</li><li> <a href="cn/XUL/Property/is24HourClock">is24HourClock</a>
+</li><li> <a href="cn/XUL/Property/isPM">isPM</a>
+</li><li> <a href="cn/XUL/Property/isSearching">isSearching</a>
+</li><li> <a href="cn/XUL/Property/isWaiting">isWaiting</a>
+</li><li> <a href="cn/XUL/Property/itemCount">itemCount</a>
+</li><li> <a href="cn/XUL/Property/label">label</a>
+</li><li> <a href="cn/XUL/Property/labelElement">labelElement</a>
+</li><li> <a href="cn/XUL/Property/lastPermanentChild">lastPermanentChild</a>
+</li><li> <a href="cn/XUL/Property/lastSelected">lastSelected</a>
+</li><li> <a href="cn/XUL/Property/left">left</a>
+</li><li> <a href="cn/XUL/Property/linkedPanel">linkedPanel</a>
+</li><li> <a href="cn/XUL/Property/listBoxObject">listBoxObject</a>
+</li><li> <a href="cn/XUL/Property/locked">locked</a>
+</li><li> <a href="cn/XUL/Property/markupDocumentViewer">markupDocumentViewer</a>
+</li><li> <a href="cn/XUL/Property/max">max</a>
+</li><li> <a href="cn/XUL/Property/maxHeight">maxHeight</a>
+</li><li> <a href="cn/XUL/Property/maxLength">maxLength</a>
+</li><li> <a href="cn/XUL/Property/maxRows">maxRows</a>
+</li><li> <a href="cn/XUL/Property/maxWidth">maxWidth</a>
+</li><li> <a href="cn/XUL/Property/menu">menu</a>
+</li><li> <a href="cn/XUL/Property/menuBoxObject">menuBoxObject</a>
+</li><li> <a href="cn/XUL/Property/menupopup">menupopup</a>
+</li><li> <a href="cn/XUL/Property/min">min</a>
+</li><li> <a href="cn/XUL/Property/minHeight">minHeight</a>
+</li><li> <a href="cn/XUL/Property/minResultsForPopup">minResultsForPopup</a>
+</li><li> <a href="cn/XUL/Property/minWidth">minWidth</a>
+</li><li> <a href="cn/XUL/Property/minute">minute</a>
+</li><li> <a href="cn/XUL/Property/minuteLeadingZero">minuteLeadingZero</a>
+</li><li> <a href="cn/XUL/Property/mode">mode</a>
+</li><li> <a href="cn/XUL/Property/month">month</a>
+</li><li> <a href="cn/XUL/Property/monthLeadingZero">monthLeadingZero</a>
+</li><li> <a href="cn/XUL/Property/name">name</a>
+</li><li> <a href="cn/XUL/Property/next">next</a>
+</li><li> <a href="cn/XUL/Property/noMatch">noMatch</a>
+</li><li> <a href="cn/XUL/Property/notificationsHidden">notificationsHidden</a>
+</li><li> <a href="cn/XUL/Property/object">object</a>
+</li><li> <a href="cn/XUL/Property/observes">observes</a>
+</li><li> <a href="cn/XUL/Property/onFirstPage">onFirstPage</a>
+</li><li> <a href="cn/XUL/Property/onLastPage">onLastPage</a>
+</li><li> <a href="cn/XUL/Property/open">open</a>
+</li><li> <a href="cn/XUL/Property/ordinal">ordinal</a>
+</li><li> <a href="cn/XUL/Property/orient">orient</a>
+</li><li> <a href="cn/XUL/Property/pack">pack</a>
+</li><li> <a href="cn/XUL/Property/pageCount">pageCount</a>
+</li><li> <a href="cn/XUL/Property/pageid">pageid</a>
+</li><li> <a href="cn/XUL/Property/pageIncrement">pageIncrement</a>
+</li><li> <a href="cn/XUL/Property/pageIndex">pageIndex</a>
+</li><li> <a href="cn/XUL/Property/pageStep">pageStep</a>
+</li><li> <a href="cn/XUL/Property/parentContainer">parentContainer</a>
+</li><li> <a href="cn/XUL/Property/palette">palette</a>
+</li><li> <a href="cn/XUL/Property/persist">persist</a>
+</li><li> <a href="cn/XUL/Property/persistence">persistence</a>
+</li><li> <a href="cn/XUL/Property/popup">popup</a>
+</li><li> <a href="cn/XUL/Property/popupBoxObject">popupBoxObject</a>
+</li><li> <a href="cn/XUL/Property/popupOpen">popupOpen</a>
+</li><li> <a href="cn/XUL/Property/position">position</a>
+</li><li> <a href="cn/XUL/Property/predicate">predicate</a>
+</li><li> <a href="cn/XUL/Property/preferenceElements">preferenceElements</a>
+</li><li> <a href="cn/XUL/Property/preferencePanes">preferencePanes</a>
+</li><li> <a href="cn/XUL/Property/preferences">preferences</a>
+</li><li> <a href="cn/XUL/Property/priority">priority</a>
+</li><li> <a href="cn/XUL/Property/radioGroup">radioGroup</a>
+</li><li> <a href="cn/XUL/Property/readonly">readonly</a>
+</li><li> <a href="cn/XUL/Property/readonly">readOnly</a>
+</li><li> <a href="cn/XUL/Property/ref">ref</a>
+</li><li> <a href="cn/XUL/Property/resource">resource</a>
+</li><li> <a href="cn/XUL/Property/resultsPopup">resultsPopup</a>
+</li><li> <a href="cn/XUL/Property/scrollBoxObject">scrollBoxObject</a>
+</li><li> <a href="cn/XUL/Property/scrollIncrement">scrollIncrement</a>
+</li><li> <a href="cn/XUL/Property/searchCount">searchCount</a>
+</li><li> <a href="cn/XUL/Property/searchLabel">searchLabel</a>
+</li><li> <a href="cn/XUL/Property/searchParam">searchParam</a>
+</li><li> <a href="cn/XUL/Property/searchSessions">searchSessions</a>
+</li><li> <a href="cn/XUL/Property/second">second</a>
+</li><li> <a href="cn/XUL/Property/secondLeadingZero">secondLeadingZero</a>
+</li><li> <a href="cn/XUL/Property/securityUI">securityUI</a>
+</li><li> <a href="cn/XUL/Property/selected">selected</a>
+</li><li> <a href="cn/XUL/Property/selectedBrowser">selectedBrowser</a>
+</li><li> <a href="cn/XUL/Property/selectedCount">selectedCount</a>
+</li><li> <a href="cn/XUL/Property/selectedIndex">selectedIndex</a>
+</li><li> <a href="cn/XUL/Property/selectedItem">selectedItem</a>
+</li><li> <a href="cn/XUL/Property/selectedItems">selectedItems</a>
+</li><li> <a href="cn/XUL/Property/selectedPanel">selectedPanel</a>
+</li><li> <a href="cn/XUL/Property/selectedTab">selectedTab</a>
+</li><li> <a href="cn/XUL/Property/selectionEnd">selectionEnd</a>
+</li><li> <a href="cn/XUL/Property/selectionStart">selectionStart</a>
+</li><li> <a href="cn/XUL/Property/selstyle">selstyle</a>
+</li><li> <a href="cn/XUL/Property/selType">selType</a>
+</li><li> <a href="cn/XUL/Property/sessionCount">sessionCount</a>
+</li><li> <a href="cn/XUL/Property/sessionHistory">sessionHistory</a>
+</li><li> <a href="cn/XUL/Property/showCommentColumn">showCommentColumn</a>
+</li><li> <a href="cn/XUL/Property/showPopup">showPopup</a>
+</li><li> <a href="cn/XUL/Property/size">size</a>
+</li><li> <a href="cn/XUL/Property/smoothScroll">smoothScroll</a>
+</li><li> <a href="cn/XUL/Property/spinButtons">spinButtons</a>
+</li><li> <a href="cn/XUL/Property/src">src</a>
+</li><li> <a href="cn/XUL/Property/state">state</a>
+</li><li> <a href="cn/XUL/Property/statusbar">statusbar</a>
+</li><li> <a href="cn/XUL/Property/statusText">statusText</a>
+</li><li> <a href="cn/XUL/Property/stringBundle">stringBundle</a>
+</li><li> <a href="cn/XUL/Property/strings">strings</a>
+</li><li> <a href="cn/XUL/Property/style">style</a>
+</li><li> <a href="cn/XUL/Property/subject">subject</a>
+</li><li> <a href="cn/XUL/Property/suppressOnSelect">suppressOnSelect</a>
+</li><li> <a href="cn/XUL/Property/tabContainer">tabContainer</a>
+</li><li> <a href="cn/XUL/Property/tabIndex">tabIndex</a>
+</li><li> <a href="cn/XUL/Property/tabs">tabs</a>
+</li><li> <a href="cn/XUL/Property/tabScrolling">tabScrolling</a>
+</li><li> <a href="cn/XUL/Property/tabpanels">tabpanels</a>
+</li><li> <a href="cn/XUL/Property/tag">tag</a>
+</li><li> <a href="cn/XUL/Property/textLength">textLength</a>
+</li><li> <a href="cn/XUL/Property/textValue">textValue</a>
+</li><li> <a href="cn/XUL/Property/timeout">timeout</a>
+</li><li> <a href="cn/XUL/Property/title">title</a>
+</li><li> <a href="cn/XUL/Property/toolbarName">toolbarName</a>
+</li><li> <a href="cn/XUL/Property/toolbarset">toolbarset</a>
+</li><li> <a href="cn/XUL/Property/tooltip">tooltip</a>
+</li><li> <a href="cn/XUL/Property/tooltipText">tooltipText</a>
+</li><li> <a href="cn/XUL/Property/top">top</a>
+</li><li> <a href="cn/XUL/Property/treeBoxObject">treeBoxObject</a>
+</li><li> <a href="cn/XUL/Property/type">type</a>
+</li><li> <a href="cn/XUL/Property/uri">uri</a>
+</li><li> <a href="cn/XUL/Property/userAction">userAction</a>
+</li><li> <a href="cn/XUL/Property/value">value</a>
+</li><li> <a href="cn/XUL/Property/valueNumber">valueNumber</a>
+</li><li> <a href="cn/XUL/Property/view">view</a>
+</li><li> <a href="cn/XUL/Property/webBrowserFind">webBrowsereFind</a>
+</li><li> <a href="cn/XUL/Property/webNavigation">webNavigation</a>
+</li><li> <a href="cn/XUL/Property/webProgress">webProgress</a>
+</li><li> <a href="cn/XUL/Property/width">width</a>
+</li><li> <a href="cn/XUL/Property/wizardPages">wizardPages</a>
+</li><li> <a href="cn/XUL/Property/wrapAround">wrapAround</a>
+</li><li> <a href="cn/XUL/Property/year">year</a>
+</li><li> <a href="cn/XUL/Property/yearLeadingZero">yearLeadingZero</a>
+</li></ul>
+<h3 id="Related_DOM_element_properties" name="Related_DOM_element_properties"> Related DOM element properties </h3>
+<ul><li> <a href="cn/DOM/element.attributes">DOM:element.attributes</a>
+</li><li> <a href="cn/DOM/element.childNodes">DOM:element.childNodes</a>
+</li><li> <a href="cn/DOM/element.cloneNode">DOM:element.cloneNode</a>
+</li><li> <a href="cn/DOM/element.firstChild">DOM:element.firstChild</a>
+</li><li> <a href="cn/DOM/element.lastChild">DOM:element.lastChild</a>
+</li><li> <a href="cn/DOM/element.localName">DOM:element.localName</a>
+</li><li> <a href="cn/DOM/element.namespaceURI">DOM:element.namespaceURI</a>
+</li><li> <a href="cn/DOM/element.nextSibling">DOM:element.nextSibling</a>
+</li><li> <a href="cn/DOM/element.nodeName">DOM:element.nodeName</a>
+</li><li> <a href="cn/DOM/element.nodeType">DOM:element.nodeType</a>
+</li><li> <a href="cn/DOM/element.nodeValue">DOM:element.nodeValue</a>
+</li><li> <a href="cn/DOM/element.ownerDocument">DOM:element.ownerDocument</a>
+</li><li> <a href="cn/DOM/element.parentNode">DOM:element.parentNode</a>
+</li><li> <a href="cn/DOM/element.prefix">DOM:element.prefix</a>
+</li><li> <a href="cn/DOM/element.previousSibling">DOM:element.previousSibling</a>
+</li><li> <a href="cn/DOM/element.tagName">DOM:element.tagName</a>
+</li></ul>
+<div class="noinclude">
+</div>
diff --git a/files/zh-cn/mozilla/tech/xul/property/label/index.html b/files/zh-cn/mozilla/tech/xul/property/label/index.html
new file mode 100644
index 0000000000..83f85cc1e3
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/label/index.html
@@ -0,0 +1,21 @@
+---
+title: label
+slug: Mozilla/Tech/XUL/Property/label
+translation_of: Archive/Mozilla/XUL/Property/label
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/label">label</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/property/labelelement/index.html b/files/zh-cn/mozilla/tech/xul/property/labelelement/index.html
new file mode 100644
index 0000000000..6baead11d3
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/labelelement/index.html
@@ -0,0 +1,21 @@
+---
+title: labelElement
+slug: Mozilla/Tech/XUL/Property/labelElement
+translation_of: Archive/Mozilla/XUL/Property/labelElement
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/labelElement">labelElement</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/label" title="label">label</a></code> element</i>
+ </dd>
+ <dd>
+ The <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/label" title="label">label</a></code> element associated with the control. This is set when a label has a <code id="a-control"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/control">control</a></code> attribute pointing to this element. This property will be <code>null</code> when no label is associated with the control.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/property/markupdocumentviewer/index.html b/files/zh-cn/mozilla/tech/xul/property/markupdocumentviewer/index.html
new file mode 100644
index 0000000000..8719292f2d
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/markupdocumentviewer/index.html
@@ -0,0 +1,15 @@
+---
+title: markupDocumentViewer
+slug: Mozilla/Tech/XUL/Property/markupDocumentViewer
+translation_of: Archive/Mozilla/XUL/Property/markupDocumentViewer
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/markupDocumentViewer">markupDocumentViewer</a></span></code></dt>
+ <dd>
+ 类型: <em><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMarkupDocumentViewer" title="">nsIMarkupDocumentViewer</a></code></em></dd>
+ <dd>
+ 这个只读的属性包含 <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMarkupDocumentViewer" title="">nsIMarkupDocumentViewer</a></code> 接口,负责document文档的绘制。</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/property/max/index.html b/files/zh-cn/mozilla/tech/xul/property/max/index.html
new file mode 100644
index 0000000000..3d20dae617
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/max/index.html
@@ -0,0 +1,15 @@
+---
+title: max
+slug: Mozilla/Tech/XUL/Property/max
+translation_of: Archive/Mozilla/XUL/Property/max
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/max">max</a></span></code></dt>
+ <dd>
+ 类型:整数</dd>
+ <dd>
+ 获取或设置<code id="a-max"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/max">max</a></code>特性(attribute)的值.</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/property/menuitem.control/index.html b/files/zh-cn/mozilla/tech/xul/property/menuitem.control/index.html
new file mode 100644
index 0000000000..a8cd738934
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/menuitem.control/index.html
@@ -0,0 +1,21 @@
+---
+title: menuitem.control
+slug: Mozilla/Tech/XUL/Property/menuitem.control
+translation_of: Archive/Mozilla/XUL/Property/menuitem.control
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menuitem.control">control</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> element</i>
+ </dd>
+ <dd>
+ Returns the enclosing <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> that the item is inside, if any, or <code>null</code> if there is no enclosing menu.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/property/parentcontainer/index.html b/files/zh-cn/mozilla/tech/xul/property/parentcontainer/index.html
new file mode 100644
index 0000000000..f8a29d42ae
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/parentcontainer/index.html
@@ -0,0 +1,21 @@
+---
+title: parentContainer
+slug: Mozilla/Tech/XUL/Property/parentContainer
+translation_of: Archive/Mozilla/XUL/Property/parentContainer
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/parentContainer">parentContainer</a></span></code> </dt>
+ <dd>
+ Type:
+ <i>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> element</i>
+ </dd>
+ <dd>
+ Read only property that returns the containing <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> element, or <code>null</code> if there isn't a containing menu.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/property/selected/index.html b/files/zh-cn/mozilla/tech/xul/property/selected/index.html
new file mode 100644
index 0000000000..eee4b31285
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/selected/index.html
@@ -0,0 +1,18 @@
+---
+title: selected
+slug: Mozilla/Tech/XUL/Property/selected
+translation_of: Archive/Mozilla/XUL/Property/selected
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selected">selected</a></span></code>&lt;magic name="\"PAGENAME\"/"&gt;&lt;/magic&gt;</dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ This property's value is <code>true</code> if this element is selected, or <code>false</code> if it is not. This property is read only.</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/property/selectedindex/index.html b/files/zh-cn/mozilla/tech/xul/property/selectedindex/index.html
new file mode 100644
index 0000000000..22d1a4fba1
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/selectedindex/index.html
@@ -0,0 +1,21 @@
+---
+title: selectedIndex
+slug: Mozilla/Tech/XUL/Property/selectedIndex
+translation_of: Archive/Mozilla/XUL/Property/selectedIndex
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ Returns the index of the currently selected item. You may select an item by assigning its index to this property. By assigning <code>-1</code> to this property, all items will be deselected.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/property/selecteditem/index.html b/files/zh-cn/mozilla/tech/xul/property/selecteditem/index.html
new file mode 100644
index 0000000000..1583c5f526
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/selecteditem/index.html
@@ -0,0 +1,21 @@
+---
+title: selectedItem
+slug: Mozilla/Tech/XUL/Property/selectedItem
+translation_of: Archive/Mozilla/XUL/Property/selectedItem
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedItem">selectedItem</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ element</i>
+ </dd>
+ <dd>
+ Holds the currently selected item. If no item is currently selected, this value will be <code>null</code>. You can select an item by setting this value. A select event will be sent to the element when it is changed either via this property, the <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code> property, or changed by the user.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/property/selectionstart/index.html b/files/zh-cn/mozilla/tech/xul/property/selectionstart/index.html
new file mode 100644
index 0000000000..27ecd267c6
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/selectionstart/index.html
@@ -0,0 +1,16 @@
+---
+title: selectionStart
+slug: Mozilla/Tech/XUL/Property/selectionStart
+translation_of: Archive/Mozilla/XUL/Property/selectionStart
+---
+<div class="noinclude"><span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectionStart">selectionStart</a></span></code></dt>
+ <dd>类型: <em>integer</em></dd>
+ <dd>获取或设置字段文本的选定部分的开始。 与<code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectionEnd">selectionEnd</a></span></code> 属性结合使用。 该值指定第一个选定字符的索引。</dd>
+</dl>
+
+<div class="noinclude">
+<p></p>
+</div>
diff --git a/files/zh-cn/mozilla/tech/xul/property/spinbuttons/index.html b/files/zh-cn/mozilla/tech/xul/property/spinbuttons/index.html
new file mode 100644
index 0000000000..aadb3a3a31
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/spinbuttons/index.html
@@ -0,0 +1,15 @@
+---
+title: spinButtons
+slug: Mozilla/Tech/XUL/Property/spinButtons
+translation_of: Archive/Mozilla/XUL/Property/spinButtons
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/spinButtons">spinButtons</a></span></code></dt>
+ <dd>
+ 类型:<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/spinbuttons" title="spinbuttons">spinbuttons</a></code>元素</dd>
+ <dd>
+ 一个只读属性,返回了数字输入框元素(<code>type</code>属性为<code>number的textbox元素</code>)中包含的<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/spinbuttons" title="spinbuttons">spinbuttons</a></code>元素(也就是右侧调整数字大小的上下小箭头).</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/property/tabindex/index.html b/files/zh-cn/mozilla/tech/xul/property/tabindex/index.html
new file mode 100644
index 0000000000..5e41049910
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/tabindex/index.html
@@ -0,0 +1,21 @@
+---
+title: tabIndex
+slug: Mozilla/Tech/XUL/Property/tabIndex
+translation_of: Archive/Mozilla/XUL/Property/tabIndex
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tabIndex">tabIndex</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code> attribute.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/property/textbox.value/index.html b/files/zh-cn/mozilla/tech/xul/property/textbox.value/index.html
new file mode 100644
index 0000000000..860ed2fd39
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/textbox.value/index.html
@@ -0,0 +1,15 @@
+---
+title: textbox.value
+slug: Mozilla/Tech/XUL/Property/textbox.value
+translation_of: Archive/Mozilla/XUL/Property/textbox.value
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/textbox.value">value</a></span></code></dt>
+ <dd>
+ 类型:字符串</dd>
+ <dd>
+ 读取或设置该<code>textbox</code>元素中的文本内容.</dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/property/value/index.html b/files/zh-cn/mozilla/tech/xul/property/value/index.html
new file mode 100644
index 0000000000..b56deb5fc4
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/property/value/index.html
@@ -0,0 +1,21 @@
+---
+title: value
+slug: Mozilla/Tech/XUL/Property/value
+translation_of: Archive/Mozilla/XUL/Property/value
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRefProp_breadcrumbs">« <a href="/zh-CN/docs/XUL_Reference" title="XUL_Reference">XUL Reference</a></span></div>
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/value">value</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code> attribute.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/radio/index.html b/files/zh-cn/mozilla/tech/xul/radio/index.html
new file mode 100644
index 0000000000..ecadeea308
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/radio/index.html
@@ -0,0 +1,379 @@
+---
+title: radio
+slug: Mozilla/Tech/XUL/radio
+tags:
+ - XUL Elements
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/radio
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>An element that can be turned on and off. Radio buttons are almost always grouped together in groups. Only one radio button within the same <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/radiogroup" title="radiogroup">radiogroup</a></code> may be selected at a time. The user can switch which radio button is turned on by selecting it with the mouse or keyboard. Other radio buttons in the same group are turned off. A label, specified with the <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute may be added beside the radio button.</p>
+<p>More information is available in the <a href="cn/XUL_Tutorial/Input_Controls">XUL tutorial</a>.</p>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-accesskey">accesskey</a>, <a href="#a-command">command</a>, <a href="#a-crop">crop</a>, <a href="#a-disabled">disabled</a>, <a href="#a-focused">focused</a>, <a href="#a-group">group</a>, <a href="#a-image">image</a>, <a href="#a-label">label</a>, <a href="#a-selected">selected</a>, <a href="#a-tabindex">tabindex</a>, <a href="#a-value">value</a></dd>
+</dl>
+<dl>
+ <dt>
+ Properties</dt>
+ <dd>
+ <a href="#p-accessKey">accessKey</a>, <a href="#p-accessibleType">accessibleType</a>, <a href="#p-radio.control">control</a>, <a href="#p-crop">crop</a>, <a href="#p-disabled">disabled</a>, <a href="#p-image">image</a>, <a href="#p-label">label</a>, <a href="#p-radioGroup">radioGroup</a>, <a href="#p-selected">selected</a>, <a href="#p-tabIndex">tabIndex</a>, <a href="#p-value">value</a></dd>
+</dl>
+<h3 id="Examples" name="Examples">Examples</h3>
+<div class="float-right">
+ <img alt="Image:XUL_ref_radio.png"></div>
+<pre>&lt;radiogroup&gt;
+ &lt;radio id="orange" label="Red" accesskey="R"/&gt;
+ &lt;radio id="violet" label="Green" accesskey="G" selected="true"/&gt;
+ &lt;radio id="yellow" label="Blue" accesskey="B" disabled="true"/&gt;
+&lt;/radiogroup&gt;
+</pre>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p> </p><div id="a-accesskey">
+
+
+
+
+<dl>
+ <dt><code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code></dt>
+ <dd>类型:
+ <i>character【字符】</i>
+ </dd>
+ <dd>本属性允许为控件(元素)设定一个字符作为快捷键,这个字符应该是 <code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code> 属性文本中的一个字符。该字符将会被加下划线以重点强调,平台和主体的变换并不影响这一表现行为。 当用户点击 ALT (在其他平台上具有类似功能的键) 和这个字符对应的按键时, 控件(元素)将立刻被从窗口中的某处激活或/并且获得焦点 <b>。虽说字符不分大小写,但是当label中存在大写字符和小写字符时,快捷键的字符将首先选择与之完全匹配的那一个,如果label中存在两个或更多的与accesskey字符相同的字符,其中的第一个字符将被加下划线。</b></dd>
+ <dt>      *(有些键在监听按键事件时,分别对应event.ctrlKey和event.metaKey。)</dt>
+</dl>
+
+<p> </p>
+
+<h4 id="Example" name="Example">Example</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_accesskey_attr.png"></div>
+
+<pre>&lt;vbox&gt;
+ &lt;label value="Enter Name" accesskey="e" control="myName"/&gt;
+ &lt;textbox id="myName"/&gt;
+ &lt;button label="Cancel" accesskey="n"/&gt;
+ &lt;button label="Ok" accesskey="O"/&gt;
+&lt;/vbox&gt;
+</pre>
+
+<h4 id="See_also" name="See_also">See also</h4>
+
+<p><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute, <code id="a-acceltext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/acceltext">acceltext</a></code> attribute</p>
+
+<p></p>
+</div> <div id="a-command">
+
+<dl>
+ <dt>
+ <code id="a-command"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/command">command</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ element id</i>
+ </dd>
+ <dd>
+ Set to the <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> of a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/command" title="command">command</a></code> element that is being observed by the element.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-crop">
+
+<dl>
+ <dt>
+ <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ one of the values below</i>
+ </dd>
+ <dd>
+ If the label of the element is too big to fit in its given space, the text will be cropped on the side specified by the <code>crop</code> attribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.</dd>
+</dl>
+<ul>
+ <li><code>start</code>: The text will be cropped on its left side.</li>
+ <li><code>end</code>: The text will be cropped on its right side.</li>
+ <li><code>left</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its left side.</li>
+ <li><code>right</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its right side.</li>
+ <li><code>center</code>: The text will be cropped in the middle, showing both the start and end of the text normally.</li>
+ <li><code>none</code>: The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.</li>
+</ul>
+
+<p></p>
+</div> <div id="a-disabled">
+
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd> </dd>
+ <dd>
+ <h5 id="类型boolean">类型:<em>boolean</em></h5>
+ </dd>
+ <dd>
+ <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>
+
+ <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>
+
+ <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
+ </dd>
+</dl>
+
+<h4 id="示例:">示例:</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>
+
+<pre><code>// Disabling an element
+document.getElementById('buttonRemove').setAttribute("disabled", "true");
+
+// Enabling back an element by removing the "disabled" attribute
+document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>
+
+<p></p><div class="blockIndicator standardNote standardNoteBlock">
+ <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
+ <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
+</div><p></p>
+</div> <div id="a-focused">
+
+
+<dl>
+ <dt><code id="a-focused"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/focused">focused</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>This attribute is <code>true</code> if the element is focused.</dd>
+</dl>
+</div> <div id="a-group">
+
+
+<dl>
+ <dt><code id="a-group"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/group">group</a></code></dt>
+ <dd>Type: <em>string group name</em> </dd>
+ <dd>Buttons with type="radio" and the same value for their group attribute are put into the same group. Only one button from each group can be checked at a time. If the user selects one the buttons, the others in the group are unchecked.</dd>
+</dl>
+</div> <div id="a-image">
+
+<dl>
+ <dt>
+ <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ image URL</i>
+ </dd>
+ <dd>
+ The URL of the image to appear on the element. If this attribute is empty or left out, no image appears. The position of the image is determined by the <code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code> and <code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code> attributes.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-label">
+
+<dl>
+ <dt>
+ <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The label that will appear on the element. If this is left out, no text appears.<br>
+ label 在元素上显示。如果左侧出界,则不显示任何文字。</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-selected">
+
+<dl>
+ <dt>
+ <code id="a-selected"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/selected">selected</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Indicates whether the element is selected or not. This value is read-only. To change the selection, set either the <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code> or <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedItem">selectedItem</a></span></code> property of the containing element.</dd>
+</dl>
+
+<p></p>
+</div> <div id="a-tabindex">
+
+
+<dl>
+ <dt><code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code></dt>
+ <dd>Type:<em>integer</em></dd>
+ <dd>当用户按下 "<kbd>tab</kbd>" 键时焦点移动到元素上的顺序。<code>tabindex</code> 数字越大,顺序越靠后。</dd>
+</dl>
+
+
+
+<p></p>
+</div> <div id="a-value">
+
+<dl>
+ <dt>
+ <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ The string attribute allows you to associate a data value with an element. It is not used for any specific purpose, but you can access it with a script for your own use.</dd>
+</dl>
+
+<p></p>
+</div><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p> </p><div id="p-accessKey">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessKey">accessKey</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ character</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-radio.control">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/radio.control">control</a></span></code></dt>
+ <dd>Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XUL/radiogroup" title="radiogroup">radiogroup</a></code> element</em></dd>
+ <dd>Returns the enclosing <code><a href="/en-US/docs/Mozilla/Tech/XUL/radiogroup" title="radiogroup">radiogroup</a></code> that the <code><a href="/en-US/docs/Mozilla/Tech/XUL/radio" title="radio">radio</a></code> element is contained within, which may or may not be its direct parent.</dd>
+</dl></div> <div id="p-crop">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/crop">crop</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-disabled">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/disabled">disabled</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-image">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/image">image</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ image URL</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-label">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/label">label</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-radioGroup">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/radioGroup">radioGroup</a></span></code></dt>
+ <dd>Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XUL/radiogroup" title="radiogroup">radiogroup</a></code> element</em></dd>
+ <dd>Equivalent to the <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/control">control</a></span></code> property.</dd>
+</dl></div> <div id="p-selected">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selected">selected</a></span></code>&lt;magic name="\"PAGENAME\"/"&gt;&lt;/magic&gt;</dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ This property's value is <code>true</code> if this element is selected, or <code>false</code> if it is not. This property is read only.</dd>
+</dl></div> <div id="p-tabIndex">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tabIndex">tabIndex</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-value">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/value">value</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code> attribute.</dd>
+</dl>
+
+<p></p></div><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<dl>
+ <dt>
+ Elements</dt>
+ <dd>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/radiogroup" title="radiogroup">radiogroup</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/checkbox" title="checkbox">checkbox</a></code></dd>
+</dl>
+<dl>
+ <dt>
+ Interfaces</dt>
+ <dd>
+ <a href="cn/NsIAccessibleProvider">nsIAccessibleProvider</a>, <a href="cn/NsIDOMXULSelectControlItemElement">nsIDOMXULSelectControlItemElement</a>, <a href="cn/NsIDOMXULLabeledControlElement">nsIDOMXULLabeledControlElement</a></dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/radiogroup/index.html b/files/zh-cn/mozilla/tech/xul/radiogroup/index.html
new file mode 100644
index 0000000000..a91c7aa8e0
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/radiogroup/index.html
@@ -0,0 +1,275 @@
+---
+title: radiogroup
+slug: Mozilla/Tech/XUL/radiogroup
+tags:
+ - radiogroup
+ - 单选按钮组
+translation_of: Archive/Mozilla/XUL/radiogroup
+---
+<div class="noinclude"><span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+
+<p>一组单选按钮。在单选按钮组内一次只能选择一个单选按钮。<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/radio" title="radio">radio</a></code> 按钮可以指示单选按钮组或后代的子节点。 如果您想要一个边框或 <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/caption" title="caption">caption</a></code> ,请将Radiogroup放在一个 <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/groupbox" title="groupbox">groupbox</a></code>内。<strong>radiogroup </strong>默认为垂直方向。</p>
+
+<p>更多信息可以在 <a href="/en/XUL_Tutorial/Input_Controls" title="en/XUL_Tutorial/Input_Controls">XUL 教程</a> 中找到。</p>
+
+<dl>
+ <dt>Attributes</dt>
+ <dd><a href="#a-disabled">disabled</a>, <a href="#a-focused">focused</a>, <a href="#a-preference">preference</a>, <a href="#a-tabindex">tabindex</a>, <a href="#a-value">value</a></dd>
+</dl>
+
+<dl>
+ <dt>Properties</dt>
+ <dd><a href="#p-accessibleType">accessibleType</a>, <a href="#p-disabled">disabled</a>, <a href="#p-focusedItem">focusedItem</a>, <a href="#p-itemCount">itemCount</a>, <a href="#p-selectedIndex">selectedIndex</a>, <a href="#p-selectedItem">selectedItem</a>, <a href="#p-tabIndex">tabIndex</a>, <a href="#p-value">value</a></dd>
+</dl>
+
+<dl>
+ <dt>Methods</dt>
+ <dd><a href="#m-appendItem">appendItem</a>, <a href="#m-checkAdjacentElement">checkAdjacentElement</a>, <a href="#m-getIndexOfItem">getIndexOfItem</a>, <a href="#m-getItemAtIndex">getItemAtIndex</a>, <a href="#m-insertItemAt">insertItemAt</a>, <a href="#m-removeItemAt">removeItemAt</a></dd>
+</dl>
+
+<h3 id="Examples" name="Examples">范例</h3>
+
+<div class="float-right"><img alt="Image:XUL_ref_radios.png" class="internal" src="/@api/deki/files/469/=XUL_ref_radios.png"></div>
+
+<pre>&lt;radiogroup&gt;
+ &lt;radio id="orange" label="Red"/&gt;
+ &lt;radio id="violet" label="Green" selected="true"/&gt;
+ &lt;radio id="yellow" label="Blue"/&gt;
+&lt;/radiogroup&gt;
+</pre>
+
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+
+<p> </p><div id="a-disabled">
+
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd> </dd>
+ <dd>
+ <h5 id="类型boolean">类型:<em>boolean</em></h5>
+ </dd>
+ <dd>
+ <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>
+
+ <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>
+
+ <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
+ </dd>
+</dl>
+
+<h4 id="示例:">示例:</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>
+
+<pre><code>// Disabling an element
+document.getElementById('buttonRemove').setAttribute("disabled", "true");
+
+// Enabling back an element by removing the "disabled" attribute
+document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>
+
+<p></p><div class="blockIndicator standardNote">
+ <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
+ <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
+</div><p></p>
+</div> <div id="a-focused">
+
+
+<dl>
+ <dt><code id="a-focused"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/focused">focused</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>This attribute is <code>true</code> if the element is focused.</dd>
+</dl>
+</div> <div id="a-preference">
+
+
+<dl>
+ <dt><code id="a-preference"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/preference">preference</a></code></dt>
+ <dd>Type: <em>id</em></dd>
+ <dd>Connects the element to a corresponding <code><a href="/en-US/docs/Mozilla/Tech/XUL/preference" title="preference">preference</a></code>. This attribute only has any effect when used inside a <code><a href="/en-US/docs/Mozilla/Tech/XUL/prefwindow" title="prefwindow">prefwindow</a></code>. More information is available in the <a href="../../../../en/Preferences_System" rel="internal">Preferences System</a> article.</dd>
+</dl>
+</div> <div id="a-tabindex">
+
+
+<dl>
+ <dt><code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code></dt>
+ <dd>Type:<em>integer</em></dd>
+ <dd>当用户按下 "<kbd>tab</kbd>" 键时焦点移动到元素上的顺序。<code>tabindex</code> 数字越大,顺序越靠后。</dd>
+</dl>
+
+
+
+<p></p>
+</div> <div id="a-value">
+
+<dl>
+ <dt>
+ <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ The string attribute allows you to associate a data value with an element. It is not used for any specific purpose, but you can access it with a script for your own use.</dd>
+</dl>
+
+<p></p>
+</div><p></p>
+
+<h3 id="Properties" name="Properties">Properties</h3>
+
+<p> </p><div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-disabled">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/disabled">disabled</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-focusedItem">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/focusedItem">focusedItem</a></span></code></dt>
+ <dd>Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XUL/radio" title="radio">radio</a></code> element</em></dd>
+ <dd>Holds the currently focused item in the <code><a href="/en-US/docs/Mozilla/Tech/XUL/radiogroup" title="radiogroup">radiogroup</a></code>, which may or may not be the same as the selected item. You can change the focused item by setting this property.</dd>
+</dl></div> <div id="p-itemCount">
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/itemCount">itemCount</a></span></code> </dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>Read only property holding the number of child items.</dd>
+</dl>
+</div> <div id="p-selectedIndex">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ Returns the index of the currently selected item. You may select an item by assigning its index to this property. By assigning <code>-1</code> to this property, all items will be deselected.</dd>
+</dl>
+
+<p></p></div> <div id="p-selectedItem">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedItem">selectedItem</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ element</i>
+ </dd>
+ <dd>
+ Holds the currently selected item. If no item is currently selected, this value will be <code>null</code>. You can select an item by setting this value. A select event will be sent to the element when it is changed either via this property, the <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code> property, or changed by the user.</dd>
+</dl>
+
+<p></p></div> <div id="p-tabIndex">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tabIndex">tabIndex</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-value">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/value">value</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ string</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code> attribute.</dd>
+</dl>
+
+<p></p></div><p></p>
+
+<h3 id="Methods" name="Methods">Methods</h3>
+
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0 0 10px 10px; padding: 0 10px; background: rgb(238, 238, 238); float: right; width: 250px;">
+<tbody>
+<tr>
+<td>
+<p><strong>Inherited Methods</strong><br>
+<small><code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.cloneNode">cloneNode()</a></code>, <a href="/En/DOM/Node.compareDocumentPosition" title="En/DOM/Node.compareDocumentPosition">compareDocumentPosition</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getBoundingClientRect">getBoundingClientRect()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getClientRects">getClientRects()</a></code>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span>, <span id="m-getElementsByAttributeNS"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttributeNS">getElementsByAttributeNS</a></code></span>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByClassName">getElementsByClassName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getFeature">getFeature()</a></code>, <a href="/En/DOM/Node.getUserData" title="En/DOM/Node.getUserData">getUserData</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isDefaultNamespace">isDefaultNamespace()</a></code>, <a href="/En/DOM/Node.isEqualNode" title="En/DOM/Node.isEqualNode">isEqualNode</a>, <a href="/En/DOM/Node.isSameNode" title="En/DOM/Node.isSameNode">isSameNode</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <a href="/En/DOM/Node.lookupNamespaceURI" title="En/DOM/Node.lookupNamespaceURI">lookupNamespaceURI</a>, <a href="/En/DOM/Node.lookupPrefix" title="En/DOM/Node.lookupPrefix">lookupPrefix</a>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.querySelector">querySelector()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.querySelectorAll">querySelectorAll()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code>, <a href="/En/DOM/Node.setUserData" title="En/DOM/Node.setUserData">setUserData</a></small></p>
+
+</td>
+</tr>
+</tbody>
+</table> <dl>
+ <dt>
+ <span id="m-appendItem"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/appendItem">appendItem( label, value )</a></code></span></dt>
+ <dd>
+ Return type: <em>element</em></dd>
+ <dd>
+ Creates a new item and adds it to the end of the existing list of items. You may optionally set a value. The function returns the newly created element.</dd>
+</dl> <dl>
+ <dt><span id="m-checkAdjacentElement"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/checkAdjacentElement">checkAdjacentElement( dir )</a></code></span></dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Deselects the currently selected <code><a href="/en-US/docs/Mozilla/Tech/XUL/radio" title="radio">radio</a></code> button in the group and selects the one adjacent to it. If the argument <var>dir</var> is <code>true</code>, the next radio button is selected. If it is <code>false</code>, the previous radio button is selected.</dd>
+</dl> <dl>
+ <dt><span id="m-getIndexOfItem"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/getIndexOfItem">getIndexOfItem( item )</a></code></span></dt>
+ <dd>Return type: <em>integer</em></dd>
+ <dd>Returns the zero-based position of the specified item. Items are numbered starting at the first item displayed in the list.</dd>
+</dl> <dl>
+ <dt><span id="m-getItemAtIndex"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/getItemAtIndex">getItemAtIndex( index )</a></code></span></dt>
+ <dd>Return type: <em>element</em></dd>
+ <dd>Returns the element that is at the specified index.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-insertItemAt"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/insertItemAt">insertItemAt( index, label, value )</a></code></span></dt>
+ <dd>
+ Return type: <em>element</em></dd>
+ <dd>
+ This method creates a new item and inserts it at the specified position. You may optionally set a value. The new item element is returned.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-removeItemAt"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/removeItemAt">removeItemAt( index )</a></code></span></dt>
+ <dd>
+ Return type: <em>element</em></dd>
+ <dd>
+ Removes the child item in the element at the specified index. The method returns the removed item.</dd>
+</dl><p></p>
+
+<h3 id="Related" name="Related">Related</h3>
+
+<dl>
+ <dt>Interfaces</dt>
+ <dd><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIAccessibleProvider" title="">nsIAccessibleProvider</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMXULSelectControlElement" title="">nsIDOMXULSelectControlElement</a></code></dd>
+</dl>
+
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/script/index.html b/files/zh-cn/mozilla/tech/xul/script/index.html
new file mode 100644
index 0000000000..6006a33298
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/script/index.html
@@ -0,0 +1,117 @@
+---
+title: script
+slug: Mozilla/Tech/XUL/script
+translation_of: Archive/Mozilla/XUL/script
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>Much like the HTML <code>script</code> element, this is used to declare a script to be used by the XUL window. You should usually put scripts in a separate file pointed to by the <code id="a-src"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/src">src</a></code> attribute, but you may also place the script inline inside the opening and closing <code>script</code> tags.</p>
+<p>More information is available in the <a href="/en/XUL_Tutorial/Adding_Event_Handlers" title="en/XUL_Tutorial/Adding_Event_Handlers">XUL tutorial</a>.</p>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-script.src">src</a>, <a href="#a-script.type">type</a></dd>
+</dl>
+<h3 id="Examples" name="Examples">Examples</h3>
+<pre> &lt;script src="test.js"/&gt;
+ &lt;script src="http://example.com/js/test.js"/&gt;
+ &lt;script&gt;
+ function foo(){
+ // code
+ }
+ &lt;/script&gt;
+</pre>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p></p><div id="a-script.src">
+
+
+<dl>
+ <dt><code id="a-script.src"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/script.src">src</a></code></dt>
+ <dd>Type: <em>URI</em></dd>
+ <dd>The URI of the script.</dd>
+</dl>
+</div> <div id="a-script.type">
+
+
+<dl>
+ <dt><code id="a-script.type"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/script.type">type</a></code></dt>
+ <dd>Type: <em>language content type</em></dd>
+ <dd>The language of the script. Usually, you would set this to <code>application/javascript</code>.<br>
+ <br>
+ <strong>Note: </strong>If the JavaScript file is in chrome://, setting this attribute to <code>application/javascript</code> will always use the latest available JavaScript version. If you omit this attribute, the default (and older) JavaScript version is used (like you get when including a JavaScript file from web content without specifying a version number).</dd>
+</dl>
+</div> <table style="border: 1px solid rgb(204, 204, 204); margin: 0 0 10px 10px; padding: 0 10px; background: rgb(238, 238, 238);">
+<tbody>
+<tr>
+<td><p><strong>Inherited from XUL element</strong><br> <small>
+<code id="a-align"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/align">align</a></code>,
+<code id="a-allowevents"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allowevents">allowevents</a></code>,
+<code id="a-allownegativeassertions"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allownegativeassertions">allownegativeassertions</a></code>,
+<code id="a-class"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/class">class</a></code>,
+<code id="a-coalesceduplicatearcs"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/coalesceduplicatearcs">coalesceduplicatearcs</a></code>,
+<code id="a-collapsed"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/collapsed">collapsed</a></code>,
+<code id="a-container"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/container">container</a></code>,
+<code id="a-containment"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/containment">containment</a></code>,
+<code id="a-context"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/context">context</a></code>,
+<code id="a-contextmenu"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/contextmenu">contextmenu</a></code>,
+<code id="a-datasources"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/datasources">datasources</a></code>,
+<code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code>,
+<code id="a-empty"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/empty">empty</a></code>,
+<code id="a-equalsize"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/equalsize">equalsize</a></code>,
+<code id="a-flags"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flags">flags</a></code>,
+<code id="a-flex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flex">flex</a></code>,
+<code id="a-height"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/height">height</a></code>,
+<code id="a-hidden"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/hidden">hidden</a></code>,
+<code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code>,
+<code id="a-insertafter"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/insertafter">insertafter</a></code>,
+<code id="a-insertbefore"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/insertbefore">insertbefore</a></code>,
+<code id="a-left"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/left">left</a></code>,
+<code id="a-maxheight"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/maxheight">maxheight</a></code>,
+<code id="a-maxwidth"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/maxwidth">maxwidth</a></code>,
+<code id="a-menu"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/menu">menu</a></code>,
+<code id="a-minheight"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/minheight">minheight</a></code>,
+<code id="a-minwidth"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/minwidth">minwidth</a></code>,
+<code id="a-mousethrough"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/mousethrough">mousethrough</a></code>,
+<code id="a-observes"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/observes">observes</a></code>,
+<code id="a-ordinal"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/ordinal">ordinal</a></code>,
+<code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code>,
+<code id="a-pack"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/pack">pack</a></code>,
+<code id="a-persist"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/persist">persist</a></code>,
+<code id="a-popup"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/popup">popup</a></code>,
+<code id="a-position"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/position">position</a></code>,
+<code id="a-preference-editable"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/preference-editable">preference-editable</a></code>,
+<code id="a-querytype"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/querytype">querytype</a></code>,
+<code id="a-ref"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/ref">ref</a></code>,
+<code id="a-removeelement"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/removeelement">removeelement</a></code>,
+<code id="a-sortDirection"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortDirection">sortDirection</a></code>,
+<code id="a-sortResource"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortResource">sortResource</a></code>,
+<code id="a-sortResource2"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortResource2">sortResource2</a></code>,
+<code id="a-statustext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/statustext">statustext</a></code>,
+<code id="a-style"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/style">style</a></code>,
+<code id="a-template"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/template">template</a></code>,
+<code id="a-tooltip"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tooltip">tooltip</a></code>,
+<code id="a-tooltiptext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tooltiptext">tooltiptext</a></code>,
+<code id="a-top"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/top">top</a></code>,
+<code id="a-uri"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/uri">uri</a></code>,
+<code id="a-wait-cursor"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/wait-cursor">wait-cursor</a></code>,
+<code id="a-width"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/width">width</a></code> </small></p>
+</td>
+</tr>
+</tbody>
+</table><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited Properties</strong><br> <small> <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/align">align</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/allowEvents">allowEvents</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/boxObject">boxObject</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/builder">builder</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/className">className</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/collapsed">collapsed</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/contextMenu">contextMenu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/controllers">controllers</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/database">database</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/datasources">datasources</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/dir">dir</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/flex">flex</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/height">height</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/hidden">hidden</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/id">id</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/left">left</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxHeight">maxHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxWidth">maxWidth</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menu">menu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minHeight">minHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minWidth">minWidth</a></span></code>, , , , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/observes">observes</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ordinal">ordinal</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/orient">orient</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/pack">pack</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/persist">persist</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ref">ref</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/resource">resource</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/statusText">statusText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/style">style</a></span></code>, ,, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltip">tooltip</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltipText">tooltipText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/top">top</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/width">width</a></span></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/statusbar/index.html b/files/zh-cn/mozilla/tech/xul/statusbar/index.html
new file mode 100644
index 0000000000..dec688952e
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/statusbar/index.html
@@ -0,0 +1,131 @@
+---
+title: statusbar
+slug: Mozilla/Tech/XUL/statusbar
+translation_of: Archive/Mozilla/XUL/statusbar
+---
+<p></p><div class="blockIndicator deprecated deprecatedHeader">
+ <p><strong><span class="icon-only-inline" title="This is an obsolete API and is no longer guaranteed to work."><i class="icon-trash"> </i></span> 已废弃</strong><br>该特性已经从 Web 标准中删除,虽然一些浏览器目前仍然支持它,但也许会在未来的某个时间停止支持,请尽量不要使用该特性。</p>
+ </div><p></p>
+<div class="noinclude">
+ 我建议使用<a href="/en-US/docs/The_add-on_bar" title="/en-US/docs/The_add-on_bar">附加组件栏</a>来代替.</div>
+<div class="noinclude">
+  </div>
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<div class="noinclude">
+  </div>
+<p>用来创建状态栏的元素,通常位于窗口底部.可以包含多个<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/statusbarpanel" title="statusbarpanel">statusbarpanel</a></code>元素.</p>
+<dl>
+ <dt>
+ 属性</dt>
+ <dd>
+ <a href="#p-accessibleType">accessibleType</a></dd>
+</dl>
+<h3 id="Examples" name="Examples">示例</h3>
+<pre>&lt;statusbar&gt;
+ &lt;statusbarpanel label="Left panel"/&gt;
+ &lt;spacer flex="1"/&gt;
+ &lt;progressmeter mode="determined" value="82"/&gt;
+ &lt;statusbarpanel label="Right panel"/&gt;
+&lt;/statusbar&gt;
+</pre>
+<p><img alt="Image:XUL_ref_statusbar.png" class="internal" src="/@api/deki/files/470/=XUL_ref_statusbar.png"></p>
+<h3 id="Attributes" name="Attributes">XUL属性(Attribute)</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0 0 10px 10px; padding: 0 10px; background: rgb(238, 238, 238);">
+<tbody>
+<tr>
+<td><p><strong>Inherited from XUL element</strong><br> <small>
+<code id="a-align"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/align">align</a></code>,
+<code id="a-allowevents"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allowevents">allowevents</a></code>,
+<code id="a-allownegativeassertions"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allownegativeassertions">allownegativeassertions</a></code>,
+<code id="a-class"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/class">class</a></code>,
+<code id="a-coalesceduplicatearcs"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/coalesceduplicatearcs">coalesceduplicatearcs</a></code>,
+<code id="a-collapsed"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/collapsed">collapsed</a></code>,
+<code id="a-container"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/container">container</a></code>,
+<code id="a-containment"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/containment">containment</a></code>,
+<code id="a-context"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/context">context</a></code>,
+<code id="a-contextmenu"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/contextmenu">contextmenu</a></code>,
+<code id="a-datasources"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/datasources">datasources</a></code>,
+<code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code>,
+<code id="a-empty"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/empty">empty</a></code>,
+<code id="a-equalsize"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/equalsize">equalsize</a></code>,
+<code id="a-flags"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flags">flags</a></code>,
+<code id="a-flex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flex">flex</a></code>,
+<code id="a-height"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/height">height</a></code>,
+<code id="a-hidden"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/hidden">hidden</a></code>,
+<code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code>,
+<code id="a-insertafter"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/insertafter">insertafter</a></code>,
+<code id="a-insertbefore"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/insertbefore">insertbefore</a></code>,
+<code id="a-left"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/left">left</a></code>,
+<code id="a-maxheight"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/maxheight">maxheight</a></code>,
+<code id="a-maxwidth"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/maxwidth">maxwidth</a></code>,
+<code id="a-menu"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/menu">menu</a></code>,
+<code id="a-minheight"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/minheight">minheight</a></code>,
+<code id="a-minwidth"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/minwidth">minwidth</a></code>,
+<code id="a-mousethrough"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/mousethrough">mousethrough</a></code>,
+<code id="a-observes"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/observes">observes</a></code>,
+<code id="a-ordinal"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/ordinal">ordinal</a></code>,
+<code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code>,
+<code id="a-pack"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/pack">pack</a></code>,
+<code id="a-persist"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/persist">persist</a></code>,
+<code id="a-popup"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/popup">popup</a></code>,
+<code id="a-position"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/position">position</a></code>,
+<code id="a-preference-editable"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/preference-editable">preference-editable</a></code>,
+<code id="a-querytype"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/querytype">querytype</a></code>,
+<code id="a-ref"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/ref">ref</a></code>,
+<code id="a-removeelement"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/removeelement">removeelement</a></code>,
+<code id="a-sortDirection"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortDirection">sortDirection</a></code>,
+<code id="a-sortResource"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortResource">sortResource</a></code>,
+<code id="a-sortResource2"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortResource2">sortResource2</a></code>,
+<code id="a-statustext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/statustext">statustext</a></code>,
+<code id="a-style"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/style">style</a></code>,
+<code id="a-template"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/template">template</a></code>,
+<code id="a-tooltip"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tooltip">tooltip</a></code>,
+<code id="a-tooltiptext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tooltiptext">tooltiptext</a></code>,
+<code id="a-top"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/top">top</a></code>,
+<code id="a-uri"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/uri">uri</a></code>,
+<code id="a-wait-cursor"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/wait-cursor">wait-cursor</a></code>,
+<code id="a-width"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/width">width</a></code> </small></p>
+</td>
+</tr>
+</tbody>
+</table><p></p>
+<h3 id="Properties" name="Properties">DOM属性(Propertie)</h3>
+<p></p><div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited Properties</strong><br> <small> <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/align">align</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/allowEvents">allowEvents</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/boxObject">boxObject</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/builder">builder</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/className">className</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/collapsed">collapsed</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/contextMenu">contextMenu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/controllers">controllers</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/database">database</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/datasources">datasources</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/dir">dir</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/flex">flex</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/height">height</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/hidden">hidden</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/id">id</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/left">left</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxHeight">maxHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxWidth">maxWidth</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menu">menu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minHeight">minHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minWidth">minWidth</a></span></code>, , , , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/observes">observes</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ordinal">ordinal</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/orient">orient</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/pack">pack</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/persist">persist</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ref">ref</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/resource">resource</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/statusText">statusText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/style">style</a></span></code>, ,, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltip">tooltip</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltipText">tooltipText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/top">top</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/width">width</a></span></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Methods" name="Methods">方法</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Related" name="Related">相关</h3>
+<dl>
+ <dt>
+ 元素</dt>
+ <dd>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/statusbarpanel" title="statusbarpanel">statusbarpanel</a></code></dd>
+</dl>
+<dl>
+ <dt>
+ 接口</dt>
+ <dd>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIAccessibleProvider" title="">nsIAccessibleProvider</a></code></dd>
+</dl>
diff --git a/files/zh-cn/mozilla/tech/xul/style/index.html b/files/zh-cn/mozilla/tech/xul/style/index.html
new file mode 100644
index 0000000000..173c741e34
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/style/index.html
@@ -0,0 +1,6 @@
+---
+title: Style classes
+slug: Mozilla/Tech/XUL/Style
+translation_of: Archive/Mozilla/XUL/Style
+---
+<p>This page was auto-generated because a user created a sub-page to this page.</p>
diff --git a/files/zh-cn/mozilla/tech/xul/style/menuitem-iconic/index.html b/files/zh-cn/mozilla/tech/xul/style/menuitem-iconic/index.html
new file mode 100644
index 0000000000..8b41b0497e
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/style/menuitem-iconic/index.html
@@ -0,0 +1,16 @@
+---
+title: menuitem-iconic
+slug: Mozilla/Tech/XUL/Style/menuitem-iconic
+translation_of: Archive/Mozilla/XUL/Style/menuitem-iconic
+---
+<div class="noinclude">
+ <a href="/zh-CN/docs/XUL_Reference" title="« XUL Reference">« XUL Reference</a></div>
+<dl>
+ <dt>
+ <code><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Style/menuitem-iconic">menuitem-iconic</a></code></dt>
+ <dd>
+ Use this class to have an image appear on the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>. Specify the image using the <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code> attribute.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/style/menuitem-non-iconic/index.html b/files/zh-cn/mozilla/tech/xul/style/menuitem-non-iconic/index.html
new file mode 100644
index 0000000000..c9873b5c31
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/style/menuitem-non-iconic/index.html
@@ -0,0 +1,16 @@
+---
+title: menuitem-non-iconic
+slug: Mozilla/Tech/XUL/Style/menuitem-non-iconic
+translation_of: Archive/Mozilla/XUL/Style/menuitem-non-iconic
+---
+<div class="noinclude">
+ <a href="/zh-CN/docs/XUL_Reference" title="« XUL Reference">« XUL Reference</a></div>
+<dl>
+ <dt>
+ <code><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Style/menuitem-non-iconic">menuitem-non-iconic</a></code></dt>
+ <dd>
+ Normally, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>s have a margin to the left for an image or checkmark. This class may be used to remove this margin so that the menuitem appears on the left edge of the menupopup.</dd>
+</dl>
+<div class="noinclude">
+  </div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tabbox/index.html b/files/zh-cn/mozilla/tech/xul/tabbox/index.html
new file mode 100644
index 0000000000..c0decfea4f
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tabbox/index.html
@@ -0,0 +1,156 @@
+---
+title: tabbox
+slug: Mozilla/Tech/XUL/tabbox
+translation_of: Archive/Mozilla/XUL/tabbox
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>A container used to display a set of tabbed pages of elements. A row of tabs is displayed at the top of tabbox which may be used to switch between each page. The <code>tabbox</code> should contain two children, the first a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/tabs" title="tabs">tabs</a></code> element which contains the tabs and the second a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/tabpanels" title="tabpanels">tabpanels</a></code> element which contains the contents of the pages.</p>
+<p>More information is available in the <a href="/en/XUL_Tutorial/Tabboxes" title="en/XUL_Tutorial/Tabboxes">XUL tutorial</a>.</p>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-eventnode">eventnode</a>, <a href="#a-handleCtrlPageUpDown">handleCtrlPageUpDown</a>, <a href="#a-handleCtrlTab">handleCtrlTab</a></dd>
+</dl>
+<dl>
+ <dt>
+ Properties</dt>
+ <dd>
+ <a href="#p-accessibleType">accessibleType</a>, <a href="#p-eventNode">eventNode</a>, <a href="#p-handleCtrlPageUpDown">handleCtrlPageUpDown</a>, <a href="#p-handleCtrlTab">handleCtrlTab</a>, <a href="#p-selectedIndex">selectedIndex</a>, <a href="#p-selectedPanel">selectedPanel</a>, <a href="#p-selectedTab">selectedTab</a>, <a href="#p-tabbox.tabs">tabs</a>, <a href="#p-tabpanels">tabpanels</a></dd>
+</dl>
+<h3 id="Examples" name="Examples">Examples</h3>
+<pre>&lt;tabbox id="myTabList" selectedIndex="2"&gt;
+ &lt;tabs&gt;
+ &lt;tab label="A First tab"/&gt;
+ &lt;tab label="Second tab"/&gt;
+ &lt;tab label="Another tab"/&gt;
+ &lt;tab label="Last tab"/&gt;
+ &lt;/tabs&gt;
+ &lt;tabpanels&gt;
+ &lt;tabpanel&gt;&lt;!-- tabpanel First elements go here --&gt;&lt;/tabpanel&gt;
+ &lt;tabpanel&gt;&lt;!-- tabpanel Second elements go here --&gt;&lt;/tabpanel&gt;
+ &lt;tabpanel&gt;&lt;button label="Click me"/&gt;&lt;/tabpanel&gt;
+ &lt;tabpanel&gt;&lt;!-- tabpanel Fourth elements go here --&gt;&lt;/tabpanel&gt;
+ &lt;/tabpanels&gt;
+&lt;/tabbox&gt;
+</pre>
+<p><img alt="Image:XUL_REF_tabboxes.gif" class="internal" src="/@api/deki/files/434/=XUL_REF_tabboxes.gif"></p>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p> </p><div id="a-eventnode">
+
+
+<dl>
+ <dt><code id="a-eventnode"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/eventnode">eventnode</a></code></dt>
+ <dd>Type: <em>one of the values below</em></dd>
+ <dd>Indicates where keyboard navigation events are listened to. If this attribute is not specified, events are listened to from the <code><a href="/en-US/docs/Mozilla/Tech/XUL/tabbox" title="tabbox">tabbox</a></code>. Thus, if this attribute is not used, the <code><a href="/en-US/docs/Mozilla/Tech/XUL/tabbox" title="tabbox">tabbox</a></code> or an element inside it must have the focus for the keyboard navigation to apply.</dd>
+ <dd>
+ <dl>
+ <dt><code>parent</code></dt>
+ <dd>Keyboard navigation is captured at the parent of the <code><a href="/en-US/docs/Mozilla/Tech/XUL/tabbox" title="tabbox">tabbox</a></code>.</dd>
+ <dt><code>window</code></dt>
+ <dd>Keyboard navigation is captured at the window level. Tab navigation will occur as long as any element in the window is focused.</dd>
+ <dt><code>document</code></dt>
+ <dd>Keyboard navigation is captured at the document level. Tab navigation will occur as long as any element in the document is focused.</dd>
+ </dl>
+ </dd>
+</dl>
+</div> <div id="a-handleCtrlPageUpDown">
+
+</div> <div id="a-handleCtrlTab">
+
+
+<dl>
+ <dt><code id="a-handleCtrlTab"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/handleCtrlTab">handleCtrlTab</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>If set to <code>true</code> or omitted, the <code><a href="/en-US/docs/Mozilla/Tech/XUL/tabbox" title="tabbox">tabbox</a></code> will switch to the next tab when the Control and Tab keys are pressed. If the Shift key is also held down, the previous tab will be displayed. If this attribute is set to <code>false</code>, these keys do not navigate between tabs.</dd>
+</dl>
+</div><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p> </p><div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-eventNode">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/eventNode">eventNode</a></span></code></dt>
+ <dd>Type: <em>EventTarget</em></dd>
+ <dd>Indicates the node where keyboard navigation events listener is set up. The initial value for this property is determined by the value of the <code id="a-eventnode"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/eventnode">eventnode</a></code> attribute.</dd>
+</dl></div> <div id="p-handleCtrlPageUpDown">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/handleCtrlPageUpDown">handleCtrlPageUpDown</a></span></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>Gets and sets the value of the <code id="a-handleCtrlPageUpDown"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/handleCtrlPageUpDown">handleCtrlPageUpDown</a></code> attribute.</dd>
+</dl></div> <div id="p-handleCtrlTab">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/handleCtrlTab">handleCtrlTab</a></span></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>Gets and sets the value of the <code id="a-handleCtrlTab"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/handleCtrlTab">handleCtrlTab</a></code> attibute.</dd>
+</dl></div> <div id="p-selectedIndex">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ Returns the index of the currently selected item. You may select an item by assigning its index to this property. By assigning <code>-1</code> to this property, all items will be deselected.</dd>
+</dl>
+
+<p></p></div> <div id="p-selectedPanel">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/selectedPanel">selectedPanel</a></span></code></dt>
+ <dd>Type: <em>element</em></dd>
+ <dd>Holds a reference to the currently selected panel within a <code>&lt;tabbox&gt;</code> element. Assigning a value to this property will modify the selected panel. A select event will be sent when the selected panel is changed.</dd>
+</dl></div> <div id="p-selectedTab">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/selectedTab">selectedTab</a></span></code></dt>
+ <dd>Type: <em>tab element</em></dd>
+ <dd>A reference to the currently selected tab, which will always be one of the <code><a href="/en-US/docs/Mozilla/Tech/XUL/tab" title="tab">tab</a></code> elements in the <code><a href="/en-US/docs/Mozilla/Tech/XUL/tabs" title="tabs">tabs</a></code> element. Assign a value to this property to modify the currently selected tab.</dd>
+</dl></div> <div id="p-tabbox.tabs">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/tabbox.tabs">tabs</a></span></code></dt>
+ <dd>Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XUL/tabs" title="tabs">tabs</a></code> element</em></dd>
+ <dd>The <code><a href="/en-US/docs/Mozilla/Tech/XUL/tabs" title="tabs">tabs</a></code> element contained within the tabbox.</dd>
+</dl></div> <div id="p-tabpanels">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/tabpanels">tabpanels</a></span></code></dt>
+ <dd>Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XUL/tabpanels" title="tabpanels">tabpanels</a></code> element</em></dd>
+ <dd>The <code><a href="/en-US/docs/Mozilla/Tech/XUL/tabpanels" title="tabpanels">tabpanels</a></code> element contained within the tabbox.</dd>
+</dl></div><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<dl>
+ <dt>
+ Elements</dt>
+ <dd>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/tabs" title="tabs">tabs</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/tab" title="tab">tab</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/tabpanels" title="tabpanels">tabpanels</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/tabpanel" title="tabpanel">tabpanel</a></code>.</dd>
+</dl>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/template_guide/index.html b/files/zh-cn/mozilla/tech/xul/template_guide/index.html
new file mode 100644
index 0000000000..9a6ac79352
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/template_guide/index.html
@@ -0,0 +1,68 @@
+---
+title: Template Guide
+slug: Mozilla/Tech/XUL/Template_Guide
+translation_of: Archive/Mozilla/XUL/Template_Guide
+---
+<p>Basics of XUL Templates</p>
+<ul>
+ <li><a href="/en/XUL/Template_Guide/Introduction" title="en/XUL/Template_Guide/Introduction">Introduction</a></li>
+ <li><a href="/en/XUL/Template_Guide/Rule_Compilation" title="en/XUL/Template_Guide/Rule_Compilation">Rule Compilation</a></li>
+</ul>
+<h2 id="RDF_Template_Syntax" name="RDF_Template_Syntax">RDF Template Syntax</h2>
+<ul>
+ <li><a href="/en/XUL/Template_Guide/Result_Generation" title="en/XUL/Template_Guide/Result_Generation">Result Generation</a></li>
+ <li><a href="/en/XUL/Template_Guide/RDF_Query_Syntax" title="en/XUL/Template_Guide/RDF_Query_Syntax">RDF Query Syntax</a></li>
+ <li><a href="/en/XUL/Template_Guide/Actions" title="en/XUL/Template_Guide/Actions">Actions</a></li>
+ <li><a href="/en/XUL/Template_Guide/Recursive_Generation" title="en/XUL/Template_Guide/Recursive_Generation">Recursive Generation</a></li>
+ <li><a href="/en/XUL/Template_Guide/Simple_Example" title="en/XUL/Template_Guide/Simple_Example">Simple Example</a></li>
+ <li><a href="/en/XUL/Template_Guide/Bindings" title="en/XUL/Template_Guide/Bindings">Bindings</a></li>
+ <li><a href="/en/XUL/Template_Guide/Additional_Navigation" title="en/XUL/Template_Guide/Additional_Navigation">Additional Navigation</a></li>
+ <li><a href="/en/XUL/Template_Guide/Filtering" title="en/XUL/Template_Guide/Filtering">Filtering</a></li>
+ <li><a href="/en/XUL/Template_Guide/Static_Content" title="en/XUL/Template_Guide/Static_Content">Static Content</a></li>
+ <li><a href="/en/XUL/Template_Guide/Simple_Query_Syntax" title="en/XUL/Template_Guide/Simple_Query_Syntax">Simple Query Syntax</a></li>
+ <li><a href="/en/XUL/Template_Guide/Containment_Properties" title="en/XUL/Template_Guide/Containment_Properties">Containment Properties</a></li>
+</ul>
+<h2 id="XML_Template_Syntax" name="XML_Template_Syntax">XML Template Syntax</h2>
+<ul>
+ <li><a href="/en/XUL/Template_Guide/XML_Templates" title="en/XUL/Template_Guide/XML_Templates">XML Templates</a></li>
+ <li><a href="/en/XUL/Template_Guide/XML_Assignments" title="en/XUL/Template_Guide/XML_Assignments">XML Assignments</a></li>
+</ul>
+<h2 id="SQL_Template_Syntax" name="SQL_Template_Syntax">SQL Template Syntax</h2>
+<ul>
+ <li><a href="/en/XUL/Template_Guide/SQLite_Templates" title="en/XUL/Template_Guide/SQLite_Templates">SQLite Templates</a></li>
+</ul>
+<h2 id="Common_Template_Syntax" name="Common_Template_Syntax">Common Template Syntax</h2>
+<ul>
+ <li><a href="/en/XUL/Template_Guide/Attribute_Substitution" title="en/XUL/Template_Guide/Attribute_Substitution">Attribute Substitution</a></li>
+ <li><a href="/en/XUL/Template_Guide/Multiple_Rules" title="en/XUL/Template_Guide/Multiple_Rules">Multiple Rules</a></li>
+ <li><a href="/en/XUL/Template_Guide/Using_Recursive_Templates" title="en/XUL/Template_Guide/Using_Recursive_Templates">Using Recursive Templates</a></li>
+ <li><a href="/en/XUL/Template_Guide/Building_Menus_With_Templates" title="en/XUL/Template_Guide/Building_Menus_With_Templates">Building Menus With Templates</a></li>
+ <li><a href="/en/XUL/Template_Guide/Special_Condition_Tests" title="en/XUL/Template_Guide/Special_Condition_Tests">Special Condition Tests</a></li>
+ <li><a href="/en/XUL/Template_Guide/Multiple_Queries" title="en/XUL/Template_Guide/Multiple_Queries">Multiple Queries</a></li>
+ <li><a href="/en/XUL/Template_Guide/Using_Multiple_Queries_to_Generate_More_Results" title="en/XUL/Template_Guide/Using_Multiple_Queries_to_Generate_More_Results">Using Multiple Queries to Generate More Results</a></li>
+</ul>
+<h2 id="Building_Trees_with_Templates" name="Building_Trees_with_Templates">Building Trees with Templates</h2>
+<ul>
+ <li><a href="/en/XUL/Template_Guide/Building_Trees" title="en/XUL/Template_Guide/Building_Trees">Building Trees</a></li>
+ <li><a href="/en/XUL/Template_Guide/Building_Hierarchical_Trees" title="en/XUL/Template_Guide/Building_Hierarchical_Trees">Building Hierarchical Trees</a></li>
+</ul>
+<h2 id="Template_Modifications" name="Template_Modifications">Template Modifications</h2>
+<ul>
+ <li><a href="/en/XUL/Template_Guide/Template_Builder_Interface" title="en/XUL/Template_Guide/Template_Builder_Interface">Template Builder Interface</a></li>
+ <li><a href="/en/XUL/Template_Guide/Template_and_Tree_Listeners" title="en/XUL/Template_Guide/Template_and_Tree_Listeners">Template and Tree Listeners</a></li>
+ <li><a href="/en/XUL/Template_Guide/RDF_Modifications" title="en/XUL/Template_Guide/RDF_Modifications">RDF Modifications</a></li>
+</ul>
+<h2 id="Additional_Topics" name="Additional_Topics">Additional Topics</h2>
+<ul>
+ <li><a href="/en/XUL/Template_Guide/Sorting_Results" title="en/XUL/Template_Guide/Sorting_Results">Sorting Results</a></li>
+ <li><a href="/en/XUL/Template_Guide/Additional_Template_Attributes" title="en/XUL/Template_Guide/Additional_Template_Attributes">Additional Template Attributes</a></li>
+ <li><a href="/en/XUL/Template_Guide/Template_Logging" title="en/XUL/Template_Guide/Template_Logging">Template Logging</a></li>
+ <li><a href="/en/XUL/Template_Guide/Namespaces" title="en/XUL/Template Guide/Namespaces">XML Namespaces</a></li>
+</ul>
+<h2 id="Alternative_Approaches" name="Alternative_Approaches">Alternative Approaches</h2>
+<ul>
+ <li><a href="/en/JavaScript_templates" title="en/JavaScript_templates">JavaScript templates</a></li>
+ <li><a class="link-https" href="https://github.com/laurentj/XulJsDatasource" title="https://github.com/laurentj/XulJsDatasource">XulJsDatasource</a>: a component for extensions, which bring a "JavaScript Template syntax". It allows to use JavaScript objects as a data source for XUL templates.</li>
+</ul>
+<p><span class="comment">Interwiki Language Links</span></p>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/textbox/index.html b/files/zh-cn/mozilla/tech/xul/textbox/index.html
new file mode 100644
index 0000000000..4d032ca259
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/textbox/index.html
@@ -0,0 +1,653 @@
+---
+title: textbox
+slug: Mozilla/Tech/XUL/textbox
+translation_of: Archive/Mozilla/XUL/textbox
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p>An input field where the user can enter text. It is similar to the HTML <code>input</code> element. Only one line of text is displayed by default. The <code id="a-multiline"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/multiline">multiline</a></code> attribute can be specified to display a field with multiple rows.</p>
+<p>More information is available in the <a href="/en/XUL_Tutorial/Input_Controls" title="en/XUL_Tutorial/Input_Controls">XUL tutorial</a>.</p>
+<dl>
+ <dt>
+ Attributes</dt>
+ <dd>
+ <a href="#a-cols">cols</a>, <a href="#a-decimalplaces">decimalplaces</a>, <a href="#a-disabled">disabled</a>, , <a href="#a-emptytext">emptytext</a>, <a href="#a-hidespinbuttons">hidespinbuttons</a>, <a href="#a-increment">increment</a>, <a href="#a-textbox.label">label</a>, <a href="#a-max">max</a>, <a href="#a-maxlength">maxlength</a>, <a href="#a-min">min</a>, <a href="#a-multiline">multiline</a>, <a href="#a-newlines">newlines</a>, <a href="#a-textbox.onchange">onchange</a>, <a href="#a-oninput">oninput</a>, <a href="#a-placeholder">placeholder</a>, <a href="#a-preference">preference</a>, <a href="#a-readonly">readonly</a>, <a href="#a-rows">rows</a>, <a href="#a-searchbutton">searchbutton</a>, <a href="#a-size">size</a>, <a href="#a-spellcheck">spellcheck</a>, <a href="#a-tabindex">tabindex</a>, <a href="#a-timeout">timeout</a>, <a href="#a-textbox.type">type</a>, <a href="#a-textbox.value">value</a>, <a href="#a-wrap">wrap</a>, <a href="#a-wraparound">wraparound</a></dd>
+</dl>
+<dl>
+ <dt>
+ Properties</dt>
+ <dd>
+ <a href="#p-accessibleType">accessibleType</a>, <a href="#p-clickSelectsAll">clickSelectsAll</a>, <a href="#p-decimalPlaces">decimalPlaces</a>, <a href="#p-decimalSymbol">decimalSymbol</a>, <a href="#p-defaultValue">defaultValue</a>, <a href="#p-disabled">disabled</a>, <a href="#p-editor">editor</a>, <a href="#p-emptyText">emptyText</a>, <a href="#p-increment">increment</a>, <a href="#p-inputField">inputField</a>, <a href="#p-textbox.label">label</a>, <a href="#p-max">max</a>, <a href="#p-maxLength">maxLength</a>, <a href="#p-min">min</a>, <a href="#p-placeholder">placeholder</a>, <a href="#p-readOnly">readOnly</a>, <a href="#p-searchButton">searchButton</a>, <a href="#p-selectionEnd">selectionEnd</a>, <a href="#p-selectionStart">selectionStart</a>, <a href="#p-size">size</a>, <a href="#p-spinButtons">spinButtons</a>, <a href="#p-tabIndex">tabIndex</a>, <a href="#p-textLength">textLength</a>, <a href="#p-timeout">timeout</a>, <a href="#p-type">type</a>, <a href="#p-textbox.value">value</a>, <a href="#p-valueNumber">valueNumber</a>, <a href="#p-wrapAround">wrapAround</a></dd>
+</dl>
+<dl>
+ <dt>
+ Methods</dt>
+ <dd>
+ <a href="#m-decrease">decrease</a>, <a href="#m-increase">increase</a>, <a href="#m-reset">reset</a>, <a href="#m-select">select</a>, <a href="#m-setSelectionRange">setSelectionRange</a></dd>
+</dl>
+<dl>
+ <dt>
+ Style classes</dt>
+ <dd>
+ <a href="#s-plain">plain</a></dd>
+</dl>
+<h3 id="Examples" name="Examples">Examples</h3>
+<div class="float-right">
+ <img alt="Image:XUL_ref_textbox.png" class="internal" src="/@api/deki/files/471/=XUL_ref_textbox.png"></div>
+<pre>&lt;vbox&gt;
+&lt;label control="your-name" value="Enter your name:"/&gt;
+&lt;textbox id="your-name" value="John"/&gt;
+&lt;/vbox&gt;
+</pre>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p> </p><div id="a-cols">
+
+
+<dl>
+ <dt><code id="a-cols"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/cols">cols</a></code></dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>For multiline textboxes, the number of columns to display.</dd>
+</dl>
+</div> <div id="a-decimalplaces">
+
+
+<dl>
+ <dt><code id="a-decimalplaces"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/decimalplaces">decimalplaces</a></code> </dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>The number of decimal places to display. The default is 0, which doesn't show any decimal places. The value <code>Infinity</code> may be used if you want no limit on the number of decimal places. Note that decimal numbers are stored as floats.</dd>
+</dl>
+</div> <div id="a-disabled">
+
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd> </dd>
+ <dd>
+ <h5 id="类型boolean">类型:<em>boolean</em></h5>
+ </dd>
+ <dd>
+ <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>
+
+ <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>
+
+ <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
+ </dd>
+</dl>
+
+<h4 id="示例:">示例:</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>
+
+<pre><code>// Disabling an element
+document.getElementById('buttonRemove').setAttribute("disabled", "true");
+
+// Enabling back an element by removing the "disabled" attribute
+document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>
+
+<p></p><div class="blockIndicator standardNote standardNoteBlock">
+ <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
+ <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
+</div><p></p>
+</div> <div id="a-emptytext">
+
+
+<dl>
+ <dt><code id="a-emptytext"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/emptytext">emptytext</a></code> <span class="inlineIndicator deprecated deprecatedInline" title="(Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)">Deprecated since Gecko 2</span></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>A string that appears in the textbox when it has no value. This is superseded by the <code id="a-placeholder"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/placeholder">placeholder</a></code> attribute in Gecko 2.0. The old name is retained for compatibility, but you should update your code.</dd>
+</dl>
+</div> <div id="a-hidespinbuttons">
+
+
+<dl>
+ <dt><code id="a-hidespinbuttons"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/hidespinbuttons">hidespinbuttons</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>If <code>true</code>, the number box does not have arrow buttons next to it to allow the user to adjust the value. The value may still be adjusted with the keyboard. The default value is <code>false</code>.</dd>
+</dl>
+</div> <div id="a-increment">
+
+<dl>
+ <dt>
+ <code id="a-increment"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/increment">increment</a></code></dt>
+ <dd>
+ 类型:整数</dd>
+ <dd>
+ 拖动刻度条控件(<code>scale</code>元素)中的拉杆,点击滚动条控件(<code>scrollbar</code>元素)中的箭头(拖动拉杆也可以),点击数字输入框(<code>type</code>属性为<code>number</code>的<code>textbox</code>元素)中的箭头时,其<code id="a-curpos"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/curpos">curpos</a></code>属性或者value属性每次改变的数字值,默认值为1.</dd>
+</dl>
+</div> <div id="a-textbox.label">
+
+
+<dl>
+ <dt><code id="a-textbox.label"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/textbox.label">label</a></code> </dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>If present and not empty, this will be exposed to screen readers through the <a href="/en/XUL/Property/textbox.label" title="en/XUL/Property/textbox.label">label</a> property.</dd>
+</dl>
+</div> <div id="a-max">
+
+<dl>
+ <dd>
+ 类型:整数</dd>
+ <dd>
+ 设置刻度条控件(scale元素)或者数字输入框控件(type属性为number的textbox元素)中能输入的最大数字.刻度条控件中,该属性的默认值为100,数字输入框中,该属性的默认值为无穷大.</dd>
+</dl>
+
+<p> </p>
+</div> <div id="a-maxlength">
+
+
+<dl>
+ <dt><code id="a-maxlength"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/maxlength">maxlength</a></code></dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>The maximum number of characters that the textbox allows to be entered.</dd>
+</dl>
+</div> <div id="a-min">
+
+<dl>
+ <dt>
+ <code id="a-min"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/min">min</a></code></dt>
+ <dd>
+ 类型:整数</dd>
+ <dd>
+ 该控件可以有的最小的整数值,默认值为0.</dd>
+</dl>
+<p> </p>
+</div> <div id="a-multiline">
+
+
+<dl>
+ <dt><code id="a-multiline"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/multiline">multiline</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>If <code>true</code>, the textbox displays multiple lines. If the user presses Enter, a new line is started. If <code>false</code>, the textbox only allows entry of one line.</dd>
+</dl>
+</div> <div id="a-newlines">
+
+
+<dl>
+ <dt><code id="a-newlines"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/newlines">newlines</a></code></dt>
+ <dd>Type: <em>one of the values below</em></dd>
+ <dd>How the text box handles pastes with newlines in them.</dd>
+ <dd>Possible values:
+ <dl>
+ <dt><code>pasteintact</code></dt>
+ <dd>Paste newlines unchanged</dd>
+ <dt><code>pastetofirst</code></dt>
+ <dd>Paste text up to the first newline, dropping the rest of the text</dd>
+ <dt><code>replacewithcommas</code></dt>
+ <dd>Pastes the text with the newlines replaced with commas</dd>
+ <dt><code>replacewithspaces</code></dt>
+ <dd>Pastes the text with newlines replaced with spaces</dd>
+ <dt><code>strip</code></dt>
+ <dd>Pastes the text with the newlines removed</dd>
+ <dt><code>stripsurroundingwhitespace</code></dt>
+ <dd>Pastes the text with newlines and adjacent whitespace removed</dd>
+ </dl>
+ </dd>
+</dl>
+</div> <div id="a-textbox.onchange">
+
+
+<dl>
+ <dt><code id="a-textbox.onchange"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/textbox.onchange">onchange</a></code></dt>
+ <dd>Type: <em>script code</em></dd>
+ <dd>This event is sent when the value of the textbox is changed. The event is not sent until the focus is moved to another element.</dd>
+</dl>
+
+
+</div> <div id="a-oninput">
+
+
+<dl>
+ <dt><code id="a-oninput"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/oninput">oninput</a></code></dt>
+ <dd>Type: <em>script code</em></dd>
+ <dd>This event is sent when a user enters text in a <code><a href="/en-US/docs/Mozilla/Tech/XUL/textbox" title="textbox">textbox</a></code>. This event is only called when the text displayed would change, thus it is not called when the user presses non-displayable keys.</dd>
+</dl>
+
+
+</div> <div id="a-placeholder">
+
+
+<dl>
+ <dt><code id="a-placeholder"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/placeholder">placeholder</a></code> </dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>A string that appears in the textbox when it has no value.</dd>
+</dl>
+</div> <div id="a-preference">
+
+
+<dl>
+ <dt><code id="a-preference"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/preference">preference</a></code></dt>
+ <dd>Type: <em>id</em></dd>
+ <dd>Connects the element to a corresponding <code><a href="/en-US/docs/Mozilla/Tech/XUL/preference" title="preference">preference</a></code>. This attribute only has any effect when used inside a <code><a href="/en-US/docs/Mozilla/Tech/XUL/prefwindow" title="prefwindow">prefwindow</a></code>. More information is available in the <a href="../../../../en/Preferences_System" rel="internal">Preferences System</a> article.</dd>
+</dl>
+</div> <div id="a-readonly">
+
+
+<dl>
+ <dt><code id="a-readonly"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/readonly">readonly</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>If set to <code>true</code>, then the user cannot change the value of the element. However, the value may still be modified by a script.</dd>
+</dl>
+</div> <div id="a-rows">
+
+<dl>
+ <dt>
+ <code id="a-rows"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/rows">rows</a></code></dt>
+ <dd>
+ Type: <em>integer</em></dd>
+ <dd>
+ The number of rows to display in the element. If the element contains more than this number of rows, a scrollbar will appear which the user can use to scroll to the other rows. To get the actual number of rows in the element, use the <span id="m-getRowCount"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/getRowCount">getRowCount</a></code></span> method.</dd>
+</dl>
+</div> <div id="a-searchbutton">
+
+
+<dl>
+ <dt><code id="a-searchbutton"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/searchbutton">searchbutton</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>If <code>true</code>, the search field will only fire a command event when the user presses the search button or presses the <code>Enter</code> key. Otherwise, the command event is fired whenever the user modifies the value. This attribute only applies to textboxes with the type <code>search</code>.</dd>
+</dl>
+</div><div id="a-size">
+
+
+<dl>
+ <dt><code id="a-size"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/size">size</a></code></dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>The number of characters that can be displayed in the textbox.</dd>
+</dl>
+</div> <div id="a-spellcheck">
+
+
+<dl>
+ <dt><code id="a-spellcheck"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/spellcheck">spellcheck</a></code> </dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>If <code>true</code>, spell checking is enabled by default for the text box; if <code>false</code>, spell checking is disabled by default.</dd>
+ <dd>If not specified, this defaults to <code>false</code></dd>
+</dl>
+
+<p><span style="font-family: Georgia,Times,'Times New Roman',serif; font-size: 1.628em; font-style: inherit; font-variant: inherit; line-height: 1.1em;">The HTML</span></p>
+
+<article style="margin: 0px; padding: 0px; border: 0px; font-family: 'Open Sans', Arial, sans-serif; line-height: 16px; font-size: 16px; vertical-align: baseline; position: relative;">
+<p style="margin: 0px 0px 0.8em; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: 1.6em; vertical-align: baseline;">The <code style="margin: 0px; padding: 2px 7px; border: 0px; font-family: monospace, sans-serif; font-style: inherit; font-variant: inherit; font-weight: bold; line-height: inherit; font-size: 16px; vertical-align: baseline; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px;">spellcheck</code> attribute uses values of true or false (you cannot simply add the spellcheck attribute to a given element):</p>
+
+<pre class="html language-html" style="margin-top: 0.5em; margin-bottom: 0.5em; padding: 1em; border: 0px; font-family: Consolas, Monaco, 'Andale Mono', monospace; font-style: inherit; font-variant: inherit; line-height: 1.6em; font-size: 0.8em; vertical-align: baseline; background-color: rgb(245, 242, 240); color: black; text-shadow: white 0px 1px; direction: ltr;"><code class="language-html" style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Monaco, 'Andale Mono', monospace; font-style: inherit; font-variant: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; text-shadow: white 0px 1px; direction: ltr;"><span class="comment token" style="border: 0px; color: #708090; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;!-- spellcheck everything! --&gt;</span>
+<span class="tag token" style="border: 0px; color: #990055; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="tag token" style="border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;</span>input</span> <span class="attr-name token" style="border: 0px; color: #669900; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">type</span><span class="attr-value token" style="border: 0px; color: #0077aa; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span>text<span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span></span> <span class="attr-name token" style="border: 0px; color: #669900; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">spellcheck</span><span class="attr-value token" style="border: 0px; color: #0077aa; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span>true<span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span></span> <span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">/&gt;</span></span><span class="tag token" style="border: 0px; color: #990055; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="tag token" style="border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;</span>br</span> <span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">/&gt;</span></span>
+<span class="tag token" style="border: 0px; color: #990055; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="tag token" style="border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;</span>textarea</span> <span class="attr-name token" style="border: 0px; color: #669900; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">spellcheck</span><span class="attr-value token" style="border: 0px; color: #0077aa; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span>true<span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span></span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&gt;</span></span><span class="tag token" style="border: 0px; color: #990055; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="tag token" style="border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;/</span>textarea</span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&gt;</span></span>
+<span class="tag token" style="border: 0px; color: #990055; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="tag token" style="border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;</span>div</span> <span class="attr-name token" style="border: 0px; color: #669900; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">contenteditable</span><span class="attr-value token" style="border: 0px; color: #0077aa; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span>true<span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span></span> <span class="attr-name token" style="border: 0px; color: #669900; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">spellcheck</span><span class="attr-value token" style="border: 0px; color: #0077aa; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span>true<span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span></span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&gt;</span></span>I am some content<span class="tag token" style="border: 0px; color: #990055; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="tag token" style="border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;/</span>div</span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&gt;</span></span>
+
+<span class="comment token" style="border: 0px; color: #708090; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;!-- spellcheck nothing! --&gt;</span>
+<span class="tag token" style="border: 0px; color: #990055; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="tag token" style="border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;</span>input</span> <span class="attr-name token" style="border: 0px; color: #669900; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">type</span><span class="attr-value token" style="border: 0px; color: #0077aa; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span>text<span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span></span> <span class="attr-name token" style="border: 0px; color: #669900; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">spellcheck</span><span class="attr-value token" style="border: 0px; color: #0077aa; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span>false<span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span></span> <span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">/&gt;</span></span><span class="tag token" style="border: 0px; color: #990055; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="tag token" style="border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;</span>br</span> <span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">/&gt;</span></span>
+<span class="tag token" style="border: 0px; color: #990055; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="tag token" style="border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;</span>textarea</span> <span class="attr-name token" style="border: 0px; color: #669900; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">spellcheck</span><span class="attr-value token" style="border: 0px; color: #0077aa; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span>false<span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span></span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&gt;</span></span><span class="tag token" style="border: 0px; color: #990055; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="tag token" style="border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;/</span>textarea</span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&gt;</span></span>
+<span class="tag token" style="border: 0px; color: #990055; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="tag token" style="border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;</span>div</span> <span class="attr-name token" style="border: 0px; color: #669900; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">contenteditable</span><span class="attr-value token" style="border: 0px; color: #0077aa; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span>true<span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span></span> <span class="attr-name token" style="border: 0px; color: #669900; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">spellcheck</span><span class="attr-value token" style="border: 0px; color: #0077aa; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span>false<span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"</span></span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&gt;</span></span>I am some content<span class="tag token" style="border: 0px; color: #990055; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="tag token" style="border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;/</span>div</span><span class="punctuation token" style="border: 0px; color: #999999; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">&gt;</span></span></code></pre>
+
+<p style="margin: 0px 0px 0.8em; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: 1.6em; vertical-align: baseline;">You can use spellcheck on <code style="margin: 0px; padding: 2px 7px; border: 0px; font-family: monospace, sans-serif; font-style: inherit; font-variant: inherit; font-weight: bold; line-height: inherit; font-size: 16px; vertical-align: baseline; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px;">INPUT</code>, <code style="margin: 0px; padding: 2px 7px; border: 0px; font-family: monospace, sans-serif; font-style: inherit; font-variant: inherit; font-weight: bold; line-height: inherit; font-size: 16px; vertical-align: baseline; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px;">TEXTAREA</code>, and <code style="margin: 0px; padding: 2px 7px; border: 0px; font-family: monospace, sans-serif; font-style: inherit; font-variant: inherit; font-weight: bold; line-height: inherit; font-size: 16px; vertical-align: baseline; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px;">contenteditable</code> elements.  The<code style="margin: 0px; padding: 2px 7px; border: 0px; font-family: monospace, sans-serif; font-style: inherit; font-variant: inherit; font-weight: bold; line-height: inherit; font-size: 16px; vertical-align: baseline; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px;">spellcheck</code> attribute works well paired with the <font face="inherit"><span style="font-style: inherit; font-variant: inherit; line-height: inherit;">autocomplete, autocapitalize, and autocorrect attributes</span></font> too!</p>
+
+<p style="margin: 0px 0px 0.8em; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: 1.6em; vertical-align: baseline;">Added from David Walsh's article on <a href="http://davidwalsh.name/spellcheck">Spell Check</a>.</p>
+</article>
+</div> <div id="a-tabindex">
+
+
+<dl>
+ <dt><code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code></dt>
+ <dd>Type:<em>integer</em></dd>
+ <dd>当用户按下 "<kbd>tab</kbd>" 键时焦点移动到元素上的顺序。<code>tabindex</code> 数字越大,顺序越靠后。</dd>
+</dl>
+
+
+
+<p></p>
+</div> <div id="a-timeout">
+
+
+<dl>
+ <dt><code id="a-timeout"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/timeout">timeout</a></code></dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>For autocomplete textboxes, the number of milliseconds before the textbox starts searching for completions. The default is 50 milliseconds. For search textboxes, the number of milliseconds before the timer fires a command event. The default is 500 milliseconds. For timed textboxes, the number of milliseconds before the timer fires a command event. There is no default. The timer starts after the user types a character. If the user types another character, the timer resets.</dd>
+</dl>
+</div> <div id="a-textbox.type">
+
+
+<dl>
+ <dt><code id="a-textbox.type"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/textbox.type">type</a></code></dt>
+ <dd>Type: <em>one of the values below</em></dd>
+ <dd>You can set the type attribute to one of the values below for a more specialized type of textbox. Don't set the type if you wish to use a regular textbox.</dd>
+ <dd>
+ <dl>
+ <dt><code>autocomplete</code></dt>
+ <dd>A textbox that supports autocomplete. For more information about autocomplete textboxes, see the autocomplete documentation (<a href="/En/XUL/Textbox_(XPFE_autocomplete)" title="En/XUL/Textbox (XPFE autocomplete)">XPFE</a> [Thunderbird/SeaMonkey]) (<a href="/En/XUL/Textbox_(Toolkit_autocomplete)" title="en/XUL/textbox_(Firefox_autocomplete)">Firefox</a>)</dd>
+ <dt><code>number</code></dt>
+ <dd> A textbox that only allows the user to enter numbers. In addition, arrow buttons appear next to the textbox to let the user step through values. There are several attributes that allow the number textbox to be configured, including <code id="a-decimalplaces"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/decimalplaces">decimalplaces</a></code>, <code id="a-min"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/min">min</a></code>, <code id="a-max"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/max">max</a></code>, <code id="a-increment"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/increment">increment</a></code>, <code id="a-wraparound"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/wraparound">wraparound</a></code>, <code id="a-hidespinbuttons"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/hidespinbuttons">hidespinbuttons</a></code>, and <code id="a-textbox.value"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/textbox.value">textbox.value</a></code>.</dd>
+ <dt><code>password</code></dt>
+ <dd>A textbox that hides what is typed, used for entering passwords.</dd>
+ <dt><code>search</code></dt>
+ <dd> A textbox intended for searching. The command event will fire as the user modifies the value. A listener for the command event should update search results. If the <code id="a-searchbutton"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/searchbutton">searchbutton</a></code> attribute is set to <code>true</code>, the command event is only fired if the user presses the search button or presses the <code>Enter </code>key. You may specify grey text to appear when the search box is empty using the <code id="a-emptytext"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/emptytext">emptytext</a></code> attribute, and a timeout may be set for the command event using the <code id="a-timeout"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/timeout">timeout</a></code> attribute (defaults to 500).</dd>
+ <dt><code>timed</code></dt>
+ <dd><span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> This textbox will fire a command event after the user types characters and a certain time has passed. The delay is set with the <code id="a-timeout"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/timeout">timeout</a></code> attribute. The command event will fire if the user presses the <code>Enter </code>key. The <code>timed</code> type is deprecated in Gecko 1.9.1 and the <code>search</code> textbox may be used instead.</dd>
+ </dl>
+ </dd>
+</dl>
+
+
+</div> <div id="a-textbox.value">
+
+
+<dl>
+ <dt><code id="a-textbox.value"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/textbox.value">value</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>The default value entered in a textbox. The attribute only holds the default value and is never modified when the user enters text. To get the updated value, use the <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/value">value</a></span></code> property. For number boxes, the default is 0 or the minimum value returned by the <code>min</code> property, whichever is higher.</dd>
+</dl>
+
+
+</div> <div id="a-wrap">
+
+
+<dl>
+ <dt><code id="a-wrap"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/wrap">wrap</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>Set this attribute to the value <code>off</code> to disable word wrapping in the textbox. If this attribute is not specified, word wrapping is enabled.</dd>
+</dl>
+</div> <div id="a-wraparound">
+
+
+<dl>
+ <dt><code id="a-wraparound"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/wraparound">wraparound</a></code> </dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>If <code>true</code>, the value of the number box will wrap around when the maximum or minimum value is exceeded. The minimum and maximum values must both not be infinity.</dd>
+</dl>
+</div><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p> </p><div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-clickSelectsAll">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/clickSelectsAll">clickSelectsAll</a></span></code></dt>
+ <dd>
+ Type: <em>boolean</em></dd>
+ <dd>
+ If set to <code>true</code>, the contents of the textbox are selected when focused; otherwise, the cursor is left unchanged.</dd>
+</dl></div> <div id="p-decimalPlaces">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/decimalPlaces">decimalPlaces</a></span></code></dt>
+ <dd>
+ Type: <em>integer</em></dd>
+ <dd>
+ Gets and sets the value of the <code id="a-decimalplaces"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/decimalplaces">decimalplaces</a></code> attribute.</dd>
+</dl></div> <div id="p-decimalSymbol">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/decimalSymbol">decimalSymbol</a></span></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ The character used for the decimal place indicator. The default value is a period (.)</dd>
+</dl></div> <div id="p-defaultValue">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/defaultValue">defaultValue</a></span></code> </dt>
+ <dd>
+ 类型: 字符串</dd>
+ <dd>
+ 获取或设置一个<code>textbox</code>元素中显示的默认值.</dd>
+</dl></div> <div id="p-disabled">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/disabled">disabled</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-editor">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/editor">editor</a></span></code></dt>
+ <dd>Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIEditor" title="">nsIEditor</a></code></em></dd>
+ <dd>A reference to the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIEditor" title="">nsIEditor</a></code> for editable text. This property is read only.</dd>
+</dl></div> <div id="p-emptyText">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/emptyText">emptyText</a></span></code> <span class="inlineIndicator deprecated deprecatedInline" title="(Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)">Deprecated since Gecko 2</span></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>Gets and sets a string that appears in the textbox when it has no value. This is superseded by the  <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/placeholder">placeholder</a></span></code> property in Gecko 2.0. The old name is retained for compatibility, but you should update your code.</dd>
+</dl></div> <div id="p-increment">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/increment">increment</a></span></code></dt>
+ <dd>
+ Type: <em>integer</em></dd>
+ <dd>
+ Gets and sets the value of the <code id="a-increment"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/increment">increment</a></code> attribute.</dd>
+</dl></div> <div id="p-inputField">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/inputField">inputField</a></span></code></dt>
+ <dd>Type: <em>textbox element</em></dd>
+ <dd>In Mozilla, the XUL textbox is implemented as a wrapper around an HTML input element. This read only property holds a reference to this inner input element.</dd>
+</dl></div> <div id="p-textbox.label">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/textbox.label">label</a></span></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>Sets the <code id="a-textbox.label"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/textbox.label">label</a></code> attribute. Gets the <code id="a-textbox.label"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/textbox.label">label</a></code> attribute if it is present and not empty. Otherwise it returns the <code id="a-label.value"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/label.value">value</a></code> of the associated <code><a href="/en-US/docs/Mozilla/Tech/XUL/label" title="label">label</a></code> element, if applicable. Otherwise it returns the <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/placeholder">placeholder</a></span></code> or <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/emptyText">emptyText</a></span></code> property. The getter is mostly useful for screen readers.
+ <div class="blockIndicator note">
+ <p><strong>Note:</strong> Prior to Firefox 3, and always in Thunderbird and SeaMonkey, the label property of an autocomplete textbox returns its value, for compatibility with the <code><a href="/en-US/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code> element.</p>
+ </div>
+ </dd>
+</dl></div> <div id="p-max">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/max">max</a></span></code></dt>
+ <dd>
+ 类型:整数</dd>
+ <dd>
+ 获取或设置<code id="a-max"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/max">max</a></code>特性(attribute)的值.</dd>
+</dl></div> <div id="p-maxLength">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/maxLength">maxLength</a></span></code></dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>The maximum number of characters that the textbox allows to be entered.</dd>
+</dl></div> <div id="p-min">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/min">min</a></span></code></dt>
+ <dd>
+ Type: <em>integer</em></dd>
+ <dd>
+ Gets and sets the value of the <code id="a-min"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/min">min</a></code> attribute.</dd>
+</dl></div> <div id="p-placeholder">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/placeholder">placeholder</a></span></code> </dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>Gets and sets a string that appears in the textbox when it has no value.</dd>
+</dl></div> <div id="p-readOnly">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/readOnly">readOnly</a></span></code></dt>
+ <dd>
+ Type: <em>boolean</em></dd>
+ <dd>
+ If set to <code>true</code>, then the user cannot modify the value of the element.</dd>
+</dl></div> <div id="p-searchButton">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/searchButton">searchButton</a></span></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>Gets and sets the value of the <code id="a-searchbutton"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/searchbutton">searchbutton</a></code> attribute.</dd>
+</dl></div> <div id="p-selectionEnd">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/selectionEnd">selectionEnd</a></span></code></dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>Get or set the end of the selected portion of the field's text. Use in conjuction with the <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/selectionStart">selectionStart</a></span></code> property. The value specifies the index of the character after the selection. If this value is equal to the value of the <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/selectionStart">selectionStart</a></span></code> property, no text is selected, but the value indicates the position of the caret (cursor) within the textbox.</dd>
+</dl></div> <div id="p-selectionStart">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/selectionStart">selectionStart</a></span></code></dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>Get or set the beginning of the selected portion of the field's text. Use in conjuction with the <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/selectionEnd">selectionEnd</a></span></code> property. The value specifies the index of the first selected character.</dd>
+</dl></div> <div id="p-size">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/size">size</a></span></code></dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>Gets and sets the value of the <code id="a-size"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/size">size</a></code> attribute.</dd>
+</dl></div> <div id="p-spinButtons">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/spinButtons">spinButtons</a></span></code></dt>
+ <dd>
+ 类型:<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/spinbuttons" title="spinbuttons">spinbuttons</a></code>元素</dd>
+ <dd>
+ 一个只读属性,返回了数字输入框元素(<code>type</code>属性为<code>number的textbox元素</code>)中包含的<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/spinbuttons" title="spinbuttons">spinbuttons</a></code>元素(也就是右侧调整数字大小的上下小箭头).</dd>
+</dl></div> <div id="p-tabIndex">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tabIndex">tabIndex</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-textLength">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/textLength">textLength</a></span></code></dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>Holds the length of the text entered in the textbox. This property is read-only.</dd>
+</dl></div> <div id="p-timeout">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/timeout">timeout</a></span></code></dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>Gets and sets the value of the <code id="a-timeout"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/timeout">timeout</a></code> attribute.</dd>
+</dl></div> <div id="p-type">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/type">type</a></span></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ Gets and sets the value of the <code id="a-type"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/type">type</a></code> attribute.</dd>
+</dl>
+</div> <div id="p-textbox.value">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/textbox.value">value</a></span></code></dt>
+ <dd>
+ 类型:字符串</dd>
+ <dd>
+ 读取或设置该<code>textbox</code>元素中的文本内容.</dd>
+</dl></div> <div id="p-valueNumber">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/valueNumber">valueNumber</a></span></code></dt>
+ <dd>
+ Type: <em>number</em></dd>
+ <dd>
+ In contrast to the <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/value">value</a></span></code> property which holds a string representation, the <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/valueNumber">valueNumber</a></span></code> property is a number containing the current value of the number box.</dd>
+</dl></div> <div id="p-wrapAround">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/wrapAround">wrapAround</a></span></code></dt>
+ <dd>
+ Type: <em>boolean</em></dd>
+ <dd>
+ Gets and sets the value of the <code id="a-wraparound"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/wraparound">wraparound</a></code> attribute.</dd>
+</dl></div><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><dl>
+ <dt>
+ <span id="m-decrease"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/decrease">decrease()</a></code></span></dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+ <dd>
+ Decreases the value of the scale or number box by the <code id="a-increment"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/increment">increment</a></code>.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-increase"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/increase">increase()</a></code></span></dt>
+ <dd>
+ 返回值类型: 无返回值</dd>
+ <dd>
+ 增大刻度条控件(scale元素)或者数字输入框控件(type属性为number的textbox元素)中的数字值(按照其<code id="a-increment"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/increment">increment</a></code>属性指定的值).</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-reset"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/reset">reset()</a></code></span></dt>
+ <dd>
+ 返回值:无返回值</dd>
+ <dd>
+ 将用户偏好重置为默认值.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-select"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/select">select()</a></code></span></dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+ <dd>
+ Selects all the text in the textbox.</dd>
+</dl> <dl>
+ <dt>
+ <span id="m-setSelectionRange"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/setSelectionRange">setSelectionRange( start, end )</a></code></span></dt>
+ <dd>
+ Return type: <em>no return value</em></dd>
+ <dd>
+ Sets the selected portion of the textbox, where the <var>start</var> argument is the index of the first character to select and the <var>end</var> argument is the index of the character after the selection. Set both arguments to the same value to move the cursor to the corresponding position without selecting text.</dd>
+</dl> <table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Style_classes" name="Style_classes">Style classes</h3>
+<p>The following classes may be used to style the element. These classes should be used instead of changing the style of the element directly since they will fit more naturally with the user's selected theme.</p>
+<p></p><dl>
+ <dt><code><a href="https://developer.mozilla.org/en-US/docs/XUL/Style/plain">plain</a></code></dt>
+ <dd>This class causes the element to be displayed with no border or margin.</dd>
+</dl><p></p>
+<h3 id="Notes">Notes</h3>
+<p>The <code>maxlength</code> attribute does not work when in multiline mode. A workaround using JavaScript and the <code>onkeypress</code> event handler as shown in abstract below may be your solution.</p>
+<p>The XUL script:</p>
+<pre class="deki-transform">&lt;textbox id="pnNote" multiline="true" rows="2" cols="70" onkeypress="return pnCountNoteChars(event);"/&gt;
+</pre>
+<p>The Javascript:</p>
+<pre class="deki-transform">function pnCountNoteChars(evt) {
+    //allow non character keys (delete, backspace and and etc.)
+    if ((evt.charCode == 0) &amp;&amp; (evt.keyCode != 13))
+      return true;
+
+    if(evt.target.value.length &lt; 10) {
+        return true;
+    } else {
+        return false;
+    }
+}</pre>
+<h3 id="Related" name="Related">Related</h3>
+<dl>
+ <dt>
+ Interfaces</dt>
+ <dd>
+ <a href="/en/XPCOM_Interface_Reference/nsIAccessibleProvider" title="en/nsIAccessibleProvider">nsIAccessibleProvider</a>, <a href="/en/NsIDOMXULTextboxElement" title="en/NsIDOMXULTextboxElement">nsIDOMXULTextboxElement</a></dd>
+</dl>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/toolbarpalette/index.html b/files/zh-cn/mozilla/tech/xul/toolbarpalette/index.html
new file mode 100644
index 0000000000..7df0ea3483
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/toolbarpalette/index.html
@@ -0,0 +1,103 @@
+---
+title: toolbarpalette
+slug: Mozilla/Tech/XUL/toolbarpalette
+translation_of: Archive/Mozilla/XUL/toolbarpalette
+---
+<div class="noinclude">
+ <span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+<p><strong><span class="highlightred">Firefox only</span></strong></p>
+<p>The item is a palette of available <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbar" title="toolbar">toolbar</a></code> items. It is not displayed, but is used by the toolbar customization dialog to display the list of items. The children of the <code>toolbarpalette</code> should be the complete list of <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbarbutton" title="toolbarbutton">toolbarbutton</a></code>s and <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbaritem" title="toolbaritem">toolbaritem</a></code>s that can be added to the toolbar. Do not add the various spacing items, as those are added automatically.</p>
+<p>这个控件(item不知道是不是这个意思,下同)是一个调色板控件,它不会显示出来,但是是被工具栏用来个性化对话框从而显示控件列表的。toolbarpalette的子类应该是一个可以被添加入工具栏toolbarbutton和toolbaritem的完整列表。不要加入spacing items,因为它们是被自动添加的。</p>
+<p>You can add your own custom buttons to the Firefox browser by using an <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/overlay" title="overlay">overlay</a></code> that overlays the <code>toolbarpalette</code> with the <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code><code>BrowserToolbarPalette</code>.</p>
+<p>你可以通过overlay来向火狐浏览器添加个性化的按钮,这是通过用BrowserToolbarPalette覆盖toolbarpalette实现的</p>
+<p>不过个人感觉这个palette好像不怎么用</p>
+<h3 id="Examples" name="Examples">Examples(实例)</h3>
+<pre class="eval">&lt;toolbarpalette id="BrowserToolbarPalette"&gt;
+ &lt;toolbarbutton id="toolbarpalette-button"
+ class="toolbarbutton-class"
+ label="&amp;mylabel;"
+ tooltiptext="&amp;mytiptext;"
+ oncommand="somefunction()"/&gt;
+&lt;/toolbarpalette&gt;
+</pre>
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0 0 10px 10px; padding: 0 10px; background: rgb(238, 238, 238);">
+<tbody>
+<tr>
+<td><p><strong>Inherited from XUL element</strong><br> <small>
+<code id="a-align"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/align">align</a></code>,
+<code id="a-allowevents"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allowevents">allowevents</a></code>,
+<code id="a-allownegativeassertions"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allownegativeassertions">allownegativeassertions</a></code>,
+<code id="a-class"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/class">class</a></code>,
+<code id="a-coalesceduplicatearcs"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/coalesceduplicatearcs">coalesceduplicatearcs</a></code>,
+<code id="a-collapsed"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/collapsed">collapsed</a></code>,
+<code id="a-container"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/container">container</a></code>,
+<code id="a-containment"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/containment">containment</a></code>,
+<code id="a-context"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/context">context</a></code>,
+<code id="a-contextmenu"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/contextmenu">contextmenu</a></code>,
+<code id="a-datasources"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/datasources">datasources</a></code>,
+<code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code>,
+<code id="a-empty"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/empty">empty</a></code>,
+<code id="a-equalsize"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/equalsize">equalsize</a></code>,
+<code id="a-flags"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flags">flags</a></code>,
+<code id="a-flex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flex">flex</a></code>,
+<code id="a-height"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/height">height</a></code>,
+<code id="a-hidden"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/hidden">hidden</a></code>,
+<code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code>,
+<code id="a-insertafter"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/insertafter">insertafter</a></code>,
+<code id="a-insertbefore"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/insertbefore">insertbefore</a></code>,
+<code id="a-left"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/left">left</a></code>,
+<code id="a-maxheight"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/maxheight">maxheight</a></code>,
+<code id="a-maxwidth"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/maxwidth">maxwidth</a></code>,
+<code id="a-menu"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/menu">menu</a></code>,
+<code id="a-minheight"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/minheight">minheight</a></code>,
+<code id="a-minwidth"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/minwidth">minwidth</a></code>,
+<code id="a-mousethrough"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/mousethrough">mousethrough</a></code>,
+<code id="a-observes"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/observes">observes</a></code>,
+<code id="a-ordinal"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/ordinal">ordinal</a></code>,
+<code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code>,
+<code id="a-pack"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/pack">pack</a></code>,
+<code id="a-persist"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/persist">persist</a></code>,
+<code id="a-popup"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/popup">popup</a></code>,
+<code id="a-position"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/position">position</a></code>,
+<code id="a-preference-editable"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/preference-editable">preference-editable</a></code>,
+<code id="a-querytype"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/querytype">querytype</a></code>,
+<code id="a-ref"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/ref">ref</a></code>,
+<code id="a-removeelement"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/removeelement">removeelement</a></code>,
+<code id="a-sortDirection"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortDirection">sortDirection</a></code>,
+<code id="a-sortResource"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortResource">sortResource</a></code>,
+<code id="a-sortResource2"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortResource2">sortResource2</a></code>,
+<code id="a-statustext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/statustext">statustext</a></code>,
+<code id="a-style"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/style">style</a></code>,
+<code id="a-template"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/template">template</a></code>,
+<code id="a-tooltip"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tooltip">tooltip</a></code>,
+<code id="a-tooltiptext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tooltiptext">tooltiptext</a></code>,
+<code id="a-top"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/top">top</a></code>,
+<code id="a-uri"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/uri">uri</a></code>,
+<code id="a-wait-cursor"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/wait-cursor">wait-cursor</a></code>,
+<code id="a-width"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/width">width</a></code> </small></p>
+</td>
+</tr>
+</tbody>
+</table><p></p>
+<h3 id="Properties" name="Properties">Properties</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited Properties</strong><br> <small> <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/align">align</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/allowEvents">allowEvents</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/boxObject">boxObject</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/builder">builder</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/className">className</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/collapsed">collapsed</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/contextMenu">contextMenu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/controllers">controllers</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/database">database</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/datasources">datasources</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/dir">dir</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/flex">flex</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/height">height</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/hidden">hidden</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/id">id</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/left">left</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxHeight">maxHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxWidth">maxWidth</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menu">menu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minHeight">minHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minWidth">minWidth</a></span></code>, , , , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/observes">observes</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ordinal">ordinal</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/orient">orient</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/pack">pack</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/persist">persist</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ref">ref</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/resource">resource</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/statusText">statusText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/style">style</a></span></code>, ,, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltip">tooltip</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltipText">tooltipText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/top">top</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/width">width</a></span></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Methods" name="Methods">Methods</h3>
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+<h3 id="Related" name="Related">Related</h3>
+<dl>
+ <dt>
+ Elements(意思应该是这里面含有的元素吧,看样子既然toolbox都在里面说明这个item还是挺大的)</dt>
+ <dd>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbar" title="toolbar">toolbar</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbarbutton" title="toolbarbutton">toolbarbutton</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbargrippy" title="toolbargrippy">toolbargrippy</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbaritem" title="toolbaritem">toolbaritem</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbarseparator" title="toolbarseparator">toolbarseparator</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbarset" title="toolbarset">toolbarset</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbarspacer" title="toolbarspacer">toolbarspacer</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbarspring" title="toolbarspring">toolbarspring</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbox" title="toolbox">toolbox</a></code></dd>
+</dl>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/toolbars/creating_toolbar_buttons/index.html b/files/zh-cn/mozilla/tech/xul/toolbars/creating_toolbar_buttons/index.html
new file mode 100644
index 0000000000..363a3b9e2b
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/toolbars/creating_toolbar_buttons/index.html
@@ -0,0 +1,183 @@
+---
+title: 添加工具栏按钮 (定制工具栏)
+slug: Mozilla/Tech/XUL/Toolbars/Creating_toolbar_buttons
+translation_of: Archive/Mozilla/XUL/Toolbars/Creating_toolbar_buttons
+---
+<p>此文章解释如何使用 <a href="/en/XUL_Overlays" title="en/XUL_Overlays">overlays</a> 为工具包(firefox,Thunderbird 或 Kompozer) 添加工具栏按钮(就是浏览器右上方一系列按钮,home,下载之类的)。适用用户是拥有 <a href="/en/XUL" title="en/XUL">XUL</a> 和 <a href="/en/CSS" title="en/CSS">CSS</a> 基础知识的 <a href="/en/Extensions" title="en/Extensions">扩展</a> 开发人员。</p>
+<p>我们假设您已经会创建基础的火狐插件,并且已经成功创建了 <a href="/en/Building_an_Extension" title="en/Building_an_Extension">Hello World extension</a> ,另外,还有一份更加完全的初学者示例指南,请查看 <a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Toolbars/Custom_toolbar_button" title="en/Custom_Toolbar_Button">自定义工具栏按钮。</a></p>
+<h3 id="Creating_an_overlay" name="Creating_an_overlay">创建一个 overlay</h3>
+<p>The first step is to create an <a href="/en/XUL_Overlays" title="en/XUL_Overlays">overlay</a> for the document containing the toolbar you wish to enhance. Explaining overlays is beyond the scope of this tutorial -- you can read about them in the <a href="/en/XUL_Tutorial/Cross_Package_Overlays" title="en/XUL_Tutorial/Cross_Package_Overlays">XUL Tutorial</a>.</p>
+<p>To overlay a document, you need to know its URI. You can find a list of URIs for the most commonly overlaid documents at the <a href="#A_list_of_commonly_overlayed_windows_with_toolbars">bottom of this page</a>.</p>
+<div class="note">
+ <strong>Note:</strong> Some people overlay <span class="nowiki"><code>chrome://messenger/content/mailWindowOverlay.xul</code></span>. That should cause the button to appear on all windows that <code>mailWindowOverlay.xul</code> is applied to (i.e. Main window and View Message window). This needs to be looked into.</div>
+<h3 id="Adding_the_toolbar_button" name="Adding_the_toolbar_button">在工具栏添加按钮</h3>
+<p>Toolkit applications have customizable toolbars; therefore, it's common practice for extensions to add their toolbar buttons to the toolbar palette, rather than adding them directly to the toolbar. The latter is possible but is not recommended and is harder to implement.</p>
+<p>Adding a button to the toolbar palette is very easy. Just add code like this to your overlay:</p>
+<pre>&lt;toolbarpalette id="BrowserToolbarPalette"&gt;
+ &lt;toolbarbutton id="myextension-button" class="toolbarbutton-1"
+ label="&amp;toolbarbutton.label;" tooltiptext="&amp;toolbarbutton.tooltip;"
+ oncommand="MyExtension.onToolbarButtonCommand(event);"/&gt;
+&lt;/toolbarpalette&gt;
+</pre>
+<p>注意:</p>
+<ul>
+ <li>The <code>id</code> of the palette (<code>BrowserToolbarPalette</code> in the example) depends on the window whose toolbar you wish to insert a button into. See <a href="#A_list_of_commonly_overlayed_windows_with_toolbars"> below</a> for the list of common palette IDs.</li>
+ <li><code>class="toolbarbutton-1"</code> makes the toolbar button appear correctly in Icons and Text mode; it also adjusts padding.</li>
+ <li>If you need to handle middle-click, add this line after the oncommand line.</li>
+</ul>
+<pre class="prettyprint language-html"><span class="pln">onclick</span><span class="pun">=</span><span class="str">"checkForMiddleClick(this, event)"</span></pre>
+<ul>
+ <li>you can also handle middle-lick and right-click using <code>onclick</code> handler and check <code>event.button</code> in it. like this:</li>
+</ul>
+<pre class="language-html">&lt;toolbarpalette id="BrowserToolbarPalette"&gt;
+ &lt;toolbarbutton id="myextension-button" class="toolbarbutton-1"
+ label="&amp;toolbarbutton.label;" tooltiptext="&amp;toolbarbutton.tooltip;"
+ onclick="MyExtension.onclick(event);"/&gt;
+&lt;/toolbarpalette&gt;</pre>
+<pre>onclick: function(event) {
+ switch(event.button) {
+ case 0:
+ // Left click
+ break;
+ case 1:
+ // Middle click
+ break;
+ case 2:
+ // Right click
+ break;
+ }
+}
+</pre>
+<p>To add more buttons, put more <code>&lt;toolbarbutton&gt;</code> elements inside the <code>&lt;toolbarpalette&gt;</code> element. Wrap elements other than <code>&lt;toolbarbutton&gt;</code> in <code>&lt;toolbaritem&gt;</code>.</p>
+<h3 id="Styling_the_button" name="Styling_the_button">为按键应用风格</h3>
+<p>Most toolbar buttons have an icon. To attach an image to the button we use standard Mozilla skinning facilities. If you're unfamiliar with how that works, read the <a class="external" href="http://www.borngeek.com/firefox/toolbar-tutorial/" title="http://www.borngeek.com/firefox/toolbar-tutorial/">skinning section of Jonah Bishop's excellent Toolbar Tutorial</a>. Although the article covers creating an entire toolbar, rather than just a button, it has a great explanation of the techniques we'll use here.</p>
+<h4 id="Icon_size" name="Icon_size">图标大小</h4>
+<p>Toolbar buttons can have two different sizes -- big and small. This means you'll need to provide two icons for each of your toolbar buttons. The dimensions of the icons in various applications for both modes are summarized in the following table (feel free to add information about other applications):</p>
+<table>
+ <tbody>
+ <tr>
+ <th>Application (Theme name)</th>
+ <th>Big icon size</th>
+ <th>Small icon size</th>
+ </tr>
+ <tr>
+ <td>Firefox 1.0 (Winstripe)</td>
+ <td>24x24</td>
+ <td>16x16</td>
+ </tr>
+ <tr>
+ <td>Thunderbird 1.0 (Qute)</td>
+ <td>24x24</td>
+ <td>16x16</td>
+ </tr>
+ </tbody>
+</table>
+<h4 id="The_stylesheet" name="The_stylesheet">CSS 样式表</h4>
+<p>To set the image for your toolbar button, use the following CSS rules:</p>
+<pre>/* skin/toolbar-button.css */
+
+#myextension-button {
+ list-style-image: url("chrome://myextension/skin/btn_large.png");
+}
+
+toolbar[iconsize="small"] #myextension-button {
+ list-style-image: url("chrome://myextension/skin/btn_small.png");
+}
+</pre>
+<h4 id="Applying_the_stylesheet" name="Applying_the_stylesheet">应用样式表</h4>
+<p>Remember to attach the stylesheet you created to both the overlay file and the Customize Toolbar window. To attach it to the overlay, put this processing instruction (PI) at the top of the overlay file:</p>
+<pre class="eval">&lt;?xml-stylesheet href="<a class="external" rel="freelink">chrome://myextension/skin/toolbar-button.css</a>" type="text/css"?&gt;
+</pre>
+<div class="note">
+ <strong>Note:</strong> The CSS file with your toolbar styles needs to be included in the overlay file, as you would expect, but also in the <code>chrome.manifest</code> file. This is very important because the toolbar customization dialog won't work correctly without this.</div>
+<p>To include the style on your chrome.manifest file:</p>
+<pre class="eval">style <a class="external" rel="freelink">chrome://global/content/customizeToolbar.xul</a> <a class="external" rel="freelink">chrome://myextension/skin/toolbar-button.css</a>
+</pre>
+<p>If you are developing for Firefox 1.0, attach it to the Customize Toolbar window (<code><a class="external" rel="freelink">chrome://global/content/customizeToolbar.xul</a></code>) using <code>skin/contents.rdf</code>. The code looks like this:</p>
+<pre>&lt;?xml version="1.0"?&gt;
+&lt;RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:chrome="http://www.mozilla.org/rdf/chrome#"&gt;
+
+ &lt;Seq about="urn:mozilla:skin:root"&gt;
+ &lt;li resource="urn:mozilla:skin:classic/1.0"/&gt;
+ &lt;/Seq&gt;
+
+ &lt;Description about="urn:mozilla:skin:classic/1.0"&gt;
+ &lt;chrome:packages&gt;
+ &lt;Seq about="urn:mozilla:skin:classic/1.0:packages"&gt;
+ &lt;li resource="urn:mozilla:skin:classic/1.0:myextension"/&gt;
+ &lt;/Seq&gt;
+ &lt;/chrome:packages&gt;
+ &lt;/Description&gt;
+
+ &lt;Seq about="urn:mozilla:stylesheets"&gt;
+ &lt;li resource="chrome://global/content/customizeToolbar.xul"/&gt;
+ &lt;/Seq&gt;
+
+ &lt;Seq about="chrome://global/content/customizeToolbar.xul"&gt;
+ &lt;li&gt;chrome://myextension/skin/toolbar-button.css&lt;/li&gt;
+ &lt;/Seq&gt;
+&lt;/RDF&gt;
+</pre>
+<p>The <code>skin/contents.rdf</code> file is denigrated in developing for later releases of Firefox. Extensions for Firefox/Thunderbird 1.5 and above should instead use something like this in their <a href="/en/Chrome_Registration" title="en/Chrome_Registration">chrome.manifest</a>:</p>
+<pre class="eval">skin myextension classic/1.0 chrome/skin/
+style <a class="external" rel="freelink">chrome://global/content/customizeToolbar.xul</a> <a class="external" rel="freelink">chrome://myextension/skin/toolbar-button.css</a>
+ia</pre>
+<p>Take note of the <a class="external" href="http://kb.mozillazine.org/Getting_started_with_extension_development#Packaging">Packaging section</a> in this article; you may need to include .jar references if you are delivering your extension as a .xpi file.</p>
+<h3 id="Common_mistakes" name="Common_mistakes">常见错误</h3>
+<p>This is a list of the most common mistakes made by extension authors, including both symptoms and solutions.</p>
+<p><strong>Problem:</strong> The whole set of default buttons is painted on the toolbar or in the Customize Toolbars window, instead of your own icon.</p>
+<p><strong>Caused by:</strong> Malformed or not applied stylesheet.</p>
+<p><strong>Solution:</strong> Check to be sure your stylesheet is correct, make sure your <code>contents.rdf</code> (or <code>chrome.manifest</code>) is correct, and be sure you didn't forget to <a href="#Applying_the_stylesheet">apply the stylesheet</a> to <code>customizeToolbar.xul</code>.</p>
+<h3 id="A_list_of_commonly_overlayed_windows_with_toolbars" name="A_list_of_commonly_overlayed_windows_with_toolbars">常见工具栏的 overlayed windows</h3>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>URL</th>
+ <th>Application and affected window(s)</th>
+ <th>Palette id</th>
+ </tr>
+ <tr>
+ <td><small><a class="external" rel="freelink">chrome://browser/content/browser.xul</a></small></td>
+ <td>Firefox - Main window</td>
+ <td>BrowserToolbarPalette</td>
+ </tr>
+ <tr>
+ <td><small><a class="external" rel="freelink">chrome://navigator/content/navigator.xul</a></small></td>
+ <td>SeaMonkey 2.0 - Browser window</td>
+ <td>BrowserToolbarPalette</td>
+ </tr>
+ <tr>
+ <td><small><a class="external" rel="freelink">chrome://messenger/content/messenger.xul</a></small></td>
+ <td>Thunderbird - Main window</td>
+ <td>MailToolbarPalette</td>
+ </tr>
+ <tr>
+ <td><small><a class="external" rel="freelink">chrome://messenger/content/messenger...gercompose.xul</a></small></td>
+ <td>Thunderbird - Compose window</td>
+ <td>MsgComposeToolbarPalette</td>
+ </tr>
+ <tr>
+ <td><small><a class="external" rel="freelink">chrome://messenger/content/addressbo...ddressbook.xul</a></small></td>
+ <td>Thunderbird - Address book</td>
+ <td>AddressBookToolbarPalette</td>
+ </tr>
+ <tr>
+ <td><small><a class="external" rel="freelink">chrome://editor/content/editor.xul</a></small></td>
+ <td>Kompozer - Main window</td>
+ <td>NvuToolbarPalette</td>
+ </tr>
+ <tr>
+ <td><small><a class="external" rel="freelink">chrome://calendar/content/calendar.xul</a></small></td>
+ <td>Sunbird - Main window</td>
+ <td>calendarToolbarPalette</td>
+ </tr>
+ </tbody>
+</table>
+<h3 id="More_information" name="More_information">更多信息</h3>
+<ul>
+ <li>XulPlanet.com references: <a class="external" href="/en/XUL/toolbarbutton" title="https://developer.mozilla.org/en/XUL/toolbarbutton"><code>&lt;toolbarbutton&gt;</code></a>, <a class="external" href="/en/XUL/toolbaritem" title="https://developer.mozilla.org/en/XUL/toolbaritem"><code>&lt;toolbaritem&gt;</code></a>.</li>
+ <li><a class="external" href="http://forums.mozillazine.org/viewtopic.php?t=220220">How to adjust toolbarbutton's label position</a></li>
+ <li><a class="external" href="http://forums.mozillazine.org/viewtopic.php?t=189667">A forum thread</a> about adding an item to the toolbar (instead of just adding it to palette) right after an extension is installed. Note that doing this is not recommended.</li>
+ <li>There is <a href="/en/XUL/Toolbars/Custom_toolbar_button/SeaMonkey" title="en/Custom_Toolbar_Button/SeaMonkey">another page</a> on mdc with information about adding buttons to various windows in SeaMonkey. Includes useful information about overlays for ChatZilla.</li>
+</ul>
diff --git a/files/zh-cn/mozilla/tech/xul/toolbars/custom_toolbar_button/index.html b/files/zh-cn/mozilla/tech/xul/toolbars/custom_toolbar_button/index.html
new file mode 100644
index 0000000000..9030e502a8
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/toolbars/custom_toolbar_button/index.html
@@ -0,0 +1,332 @@
+---
+title: 自定义工具栏按钮
+slug: Mozilla/Tech/XUL/Toolbars/Custom_toolbar_button
+translation_of: Archive/Mozilla/XUL/Toolbars/Custom_toolbar_button
+---
+<p>此教程教您一步步为 Firefox, SeaMonkey 2.0, Thunderbird 或 Sunbird 制作工具栏按钮 (对于 SeaMonkey 1.x,请查看 <a href="/en/XUL/Toolbars/Custom_toolbar_button/SeaMonkey" title="en/Custom_Toolbar_Button/SeaMonkey">Custom Toolbar Button:SeaMonkey</a>.)</p>
+<p>你不需要任何技巧和工具,所以需要的信息全部在本页。</p>
+<p> </p>
+<h3 id="Introduction" name="Introduction">介绍</h3>
+<p>本页所述技术不包括任何黑科技。你可以自己定制属于自己的扩展。</p>
+<p>适用示例上的代码可以制作出很多很有用的按钮,如果你懂得 JS 编程,你可以自己编代码,实现更多其他功能。</p>
+<p>如果你需要创建一个具某项功能的按钮,那么你来对地方了</p>
+<p>在此页你也能学到扩展程序的基础知识,有利于将来写更复杂的插件。注意,扩展程序非常简单,你或许得查看其他教程,那么-主 <a href="/en/Extensions" title="en/Extensions">扩展</a> 页就是您该去的地方。另外, <a href="/en/XUL/Toolbars/Creating_toolbar_buttons" title="en/Creating_toolbar_buttons">创建工具栏按钮</a> 这篇文章(译注:建议先看本文再看这个,那里面有几句没说清楚该放哪去)和 <a href="/en/Building_an_Extension" title="en/Building_an_Extension">创建一个扩展</a> 更好的展示了创建过程。</p>
+<h4 id="Supported_applications" name="Supported_applications">支持的程序</h4>
+<p>本文中步骤适用于下列 Mozilla 应用:</p>
+<ul>
+ <li>Firefox 1.5 以后</li>
+ <li>SeaMonkey 2.0 以后</li>
+ <li>Thunderbird 1.5 以后</li>
+ <li>Sunbird 0.3 以后</li>
+</ul>
+<p>提前发行版一般都支持 (alphas, betas 和 release candidates) 。</p>
+<p><strong>译注:本文的例子适用于很多Mozilla 开发的应用程序,原文用Application 代表这些程序,所以我按照原文翻译成了应用/程序,所以如果将来遇到应用/程序等字样,就是指Firefox 等。</strong></p>
+<div class="note">
+ <p><strong>Note: </strong> There is a similar tutorial for SeaMonkey 1.x on the page: <a href="/en/XUL/Toolbars/Custom_toolbar_button/SeaMonkey" title="en/Custom_Toolbar_Button/SeaMonkey">Custom Toolbar Button:SeaMonkey</a></p>
+ <p>Earlier versions and other Mozilla applications also support extensions, but some parts of this tutorial are not appropriate for them.</p>
+</div>
+<h4 id="Required_tools" name="Required_tools">所需工具</h4>
+<p>需要两个工具,系统一般都默认提供了:</p>
+<ul>
+ <li>能操作文件,文件夹的环境</li>
+ <li>纯文本编辑器</li>
+</ul>
+<h5 id="Character_encoding" name="Character_encoding">字符编码</h5>
+<p>有些文本编辑器有调整字符编码的选项。</p>
+<p>如果你使用拉丁 (ASCII) 字符,那就将你的文本编辑器设为除 Unicode 外的任意编码</p>
+<p>如果你的语言包含非拉丁字符,那保存文件时请选择 UTF-8 编码。</p>
+<p>要想测试编辑器,新建一个文件<code>test.txt</code>。在文件中输入属于您语言的文字,然后保存。</p>
+<p>使用火狐打开此文件,(例如,直接将文件拖动到火狐上,或在菜单中选择 文件 – 打开文件)。</p>
+<p>在火狐的菜单栏中,选择 查看– 字符编码 – Unicode (UTF-8)。然后看在此设置下,文本中的文字是否能正常显示。</p>
+<p>如果你的文本编辑器不支持 UTF-8,自己上网搜索装一个。</p>
+<h4 id="Optional_tools" name="Optional_tools">可选工具</h4>
+<p>可以使用任意图像编辑器编辑图片。</p>
+<p>可以使用 jar 工具或 zip 工具将此按钮项目压缩成跨平台的安装文件 (XPI),方便别人安装使用。</p>
+<h3 id="Making_a_button" name="Making_a_button">制作一个按钮</h3>
+<p>按照下面10步完成</p>
+<p>完成所有步骤后,文件夹结构应该如下图所示:</p>
+<dl>
+ <dd>
+ <img alt="Directory and file structure" class="internal" src="/@api/deki/files/633/=Custom-button-structure.png"></dd>
+</dl>
+<p> profile 和 <code>extensions</code> 文件夹已存在,需要添加图中其他的文件和文件夹(当然此目录下可能还会有其他文件,只是没显示.)</p>
+<div style="margin-left: 4ex;">
+ <div style="margin-left: -4ex; width: 4ex; float: left;">
+ 1.</div>
+ 前往应用程序的配置文件夹,然后找到<code>extensions</code> 文件夹。
+ <p><strong>注意: </strong> 至于如何找到配置文件夹,请查看:<a class="external" href="http://kb.mozillazine.org/Profile_folder">配置文件夹</a></p>
+ <p><em>说明: </em> 配置文件夹包含用户指定的设置,和主程序分开存放。所以程序重装或升级之后,这些信息不受影响。</p>
+ <div style="margin-left: -4ex; width: 4ex; float: left;">
+ 2.</div>
+ 在 <code>extensions</code> 文件夹中,创建一个文件夹,名称如下:
+ <p>建议直接复制粘贴,以免出错</p>
+ <dl>
+ <dd>
+ <code><a class="link-mailto" href="mailto:custom-toolbar-button@example.com" rel="freelink">custom-toolbar-button@example.com</a></code></dd>
+ </dl>
+ <p>按照后面的步骤,创建两个文件和一个文件夹。</p>
+ <p><em>说明: </em> 此文件夹名称是用于区分不同扩展程序的唯一标识符。在稍后的部分会有详细的标识符。</p>
+ <div style="margin-left: -4ex; width: 4ex; float: left;">
+ 3.</div>
+ 创建一个文本文档,名称为 <code>install.rdf</code>.
+ <p>完整复制下面内容,粘贴到文档中:</p>
+ <pre>&lt;?xml version="1.0"?&gt;
+
+&lt;RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:em="http://www.mozilla.org/2004/em-rdf#"&gt;
+
+ &lt;Description
+ about="urn:mozilla:install-manifest"
+
+ em:name="Custom Button"
+ em:description="My custom toolbar button"
+ em:creator="My name"
+
+ em:id="custom-toolbar-button@example.com"
+ em:version="1.0"
+ em:homepageURL="http://developer.mozilla.org/en/docs/Custom_Toolbar_Button"
+
+ em:iconURL="chrome://custombutton/content/icon.png" &gt;
+
+ &lt;em:targetApplication&gt;&lt;!-- Firefox --&gt;
+ &lt;Description
+ em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
+ em:minVersion="1.4"
+ em:maxVersion="99" /&gt;
+ &lt;/em:targetApplication&gt;
+
+ &lt;em:targetApplication&gt;&lt;!-- Thunderbird --&gt;
+ &lt;Description
+ em:id="{3550f703-e582-4d05-9a08-453d09bdfdc6}"
+ em:minVersion="1.4"
+ em:maxVersion="99" /&gt;
+ &lt;/em:targetApplication&gt;
+
+ &lt;em:targetApplication&gt;&lt;!-- Sunbird --&gt;
+ &lt;Description
+ em:id="{718e30fb-e89b-41dd-9da7-e25a45638b28}"
+ em:minVersion="0.2.9"
+ em:maxVersion="99" /&gt;
+ &lt;/em:targetApplication&gt;
+
+ &lt;em:file&gt;
+ &lt;Description
+ about="urn:mozilla:extension:custombutton"
+ em:package="content/custombutton/" /&gt;
+ &lt;/em:file&gt;
+
+ &lt;/Description&gt;
+
+&lt;/RDF&gt;
+</pre>
+ <p>可选:改变 name, description 和 creator。改变这三行中双引号间的文字即可</p>
+ <p>根据需求,移除不需要的软件说明部分(译注:假如你只想给firefox创建插件,那么就可以删掉别的部分)。</p>
+ <p>保存文件</p>
+ <p><em>说明: </em> 此文件包含应用程序扩展管理器需要的信息。target applications这一大段表示能运行扩展程序的应用以及版本号。 最后一段描述此插件会添加内容到应用程序。</p>
+ <div style="margin-left: -4ex; width: 4ex; float: left;">
+ 4.</div>
+ 创建一个文本文档,名称为 <code>chrome.manifest</code>.
+ <p>完整复制下面内容,粘贴到文档中:</p>
+ <pre>content custombutton chrome/
+style chrome://global/content/customizeToolbar.xul chrome://custombutton/content/button.css
+
+# Firefox
+overlay chrome://browser/content/browser.xul chrome://custombutton/content/button.xul
+
+# Thunderbird mail
+overlay chrome://messenger/content/messenger.xul chrome://custombutton/content/button.xul
+
+# Thunderbird compose
+overlay chrome://messenger/content/messengercompose/messengercompose.xul chrome://custombutton/content/button.xul
+
+# Thunderbird address book
+overlay chrome://messenger/content/addressbook/addressbook.xul chrome://custombutton/content/button.xul
+
+# Sunbird
+overlay chrome://calendar/content/calendar.xul chrome://custombutton/content/button.xul
+</pre>
+ <p>移除不需要的部分(同上段说明)。</p>
+ <p>保存文件</p>
+ <p><em>说明: </em> 此文件定义扩展的内容结构。先给工具栏窗口应用一个样式表。然后给每个工具栏都指定一个 overlay 。</p>
+ <div style="margin-left: -4ex; width: 4ex; float: left;">
+ 5.</div>
+ 创建文件夹: <code>chrome</code>.
+ <p>按照下放说明,创建 5 个文件。</p>
+ <p><em>说明: </em>  <code>chrome</code> 文件夹包含扩展的可执行部分,即扩展是干什的。</p>
+ <div style="margin-left: -4ex; width: 4ex; float: left;">
+ 6.</div>
+ 创建一个文本文档,名称为 <code>button.xul</code>.
+ <p>完整复制下面内容,粘贴到文档中:</p>
+ <pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+&lt;?xml-stylesheet type="text/css"
+ href="chrome://custombutton/content/button.css"?&gt;
+
+&lt;!DOCTYPE overlay &gt;
+&lt;overlay id="custombutton-overlay"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;
+
+&lt;script type="application/javascript"
+ src="chrome://custombutton/content/button.js"/&gt;
+
+&lt;!-- Firefox --&gt;
+&lt;toolbarpalette id="BrowserToolbarPalette"&gt;
+ &lt;toolbarbutton id="custom-button-1"/&gt;
+ &lt;/toolbarpalette&gt;
+
+&lt;!-- Thunderbird mail --&gt;
+&lt;toolbarpalette id="MailToolbarPalette"&gt;
+ &lt;toolbarbutton id="custom-button-1"/&gt;
+ &lt;/toolbarpalette&gt;
+
+&lt;!-- Thunderbird compose --&gt;
+&lt;toolbarpalette id="MsgComposeToolbarPalette"&gt;
+ &lt;toolbarbutton id="custom-button-1"/&gt;
+ &lt;/toolbarpalette&gt;
+
+&lt;!-- Thunderbird address book --&gt;
+&lt;toolbarpalette id="AddressBookToolbarPalette"&gt;
+ &lt;toolbarbutton id="custom-button-1"/&gt;
+ &lt;/toolbarpalette&gt;
+
+&lt;!-- Sunbird --&gt;
+&lt;toolbarpalette id="calendarToolbarPalette"&gt;
+ &lt;toolbarbutton id="custom-button-1"/&gt;
+ &lt;/toolbarpalette&gt;
+
+
+&lt;!-- button details --&gt;
+&lt;toolbarbutton id="custom-button-1"
+ label="Custom"
+ tooltiptext="My custom toolbar button"
+ oncommand="CustomButton[1]()"
+ class="toolbarbutton-1 chromeclass-toolbar-additional custombutton"
+ /&gt;
+
+&lt;/overlay&gt;
+</pre>
+ <p>可选:你可以自定义最后一块中的 label 和 tooltiptext 。更改双括号间的内容即可。</p>
+ <p>可选地,移除不需要的部分。。</p>
+ <p>保存文件。</p>
+ <p><em>说明: </em> 此 <a href="/en/XUL" title="en/XUL">XUL</a> 文件会添加一个按钮到应用程序的 toolbar customization palette。此文件还链接了CSS样式表 和 JavaScript 脚本。最后一部分描述按钮的信息(译注;就是按钮名+鼠标放上面会提示什么文字)</p>
+ <div style="margin-left: -4ex; width: 4ex; float: left;">
+ 7.</div>
+ 创建一个文本文档,名称为: <code>button.css</code>.
+ <p>完整复制下面内容,粘贴到文档中:</p>
+ <pre>#custom-button-1,
+#wrapper-custom-button-1
+ {list-style-image: url("chrome://custombutton/content/button-1.png");}
+
+/* common style for all custom buttons */
+.custombutton
+ {-moz-image-region: rect( 0px 24px 24px 0px);}
+
+.custombutton:hover
+ {-moz-image-region: rect(24px 24px 48px 0px);}
+
+[iconsize="small"] .custombutton
+ {-moz-image-region: rect( 0px 40px 16px 24px);}
+
+[iconsize="small"] .custombutton:hover
+ {-moz-image-region: rect(24px 40px 40px 24px);}
+</pre>
+ <p>没有什么能优化的,保存文件即可</p>
+ <p><em>说明: </em> 此 <a href="/en/CSS" title="en/CSS">CSS</a> 样式表定义按钮如何显示。它链接到了按钮图片,指定了图片四个部分的尺寸。(译注;这里你就可以看文章开头提到的文章了,比这里举的例子更好实现,你只需在css中指定一大一小两个图片即可)</p>
+ <div style="margin-left: -4ex; width: 4ex; float: left;">
+ 8.</div>
+ 创建一个文本文档,名称为: <code>button.js</code>.
+ <p>完整复制下面内容,粘贴到文档中:</p>
+ <div style="width: 40em;">
+ <pre>CustomButton = {
+
+1: function () {
+ alert("Just testing")
+ },
+
+}
+</pre>
+ </div>
+ <p>没有什么能优化的,保存文件即可</p>
+ <p>接下来一部分的教程包含几个实例代码,你可以用他们来实现有用的功能。</p>
+ <p><em>说明: </em> 此文件指定当按钮按下时执行什么操作。它使用  <a href="/en/JavaScript" title="en/JavaScript">JavaScript</a> 语言,加应用自己提供的一些特性。</p>
+ <div style="margin-left: -4ex; width: 4ex; float: left;">
+ 9.</div>
+ 下载按钮图片。
+ <p>右击图片,另存为,保存到 <code>chrome</code> 目录下。请确保文件名为: <code>button-1.png</code></p>
+ <div style="margin: 0 0 1em 4ex; border: 6px solid #ddd; float: left;">
+ <img alt="button-1.png" class="internal" src="/@api/deki/files/576/=Button-1.png"></div>
+ <p style=""><em>说明: </em> 此图片包含四个部分。左上方是常用的图标。左下是深色的,按下按钮后显示,右侧的是小图标,工具栏设置成使用小图标时需要用。</p>
+ <div style="margin-left: -4ex; width: 4ex; float: left;">
+ 10.</div>
+ 下载扩展的图片。
+ <p>右击图片,另存为,保存到 <code>chrome</code> 目录下。请确保文件名为:<code>icon.png</code></p>
+ <div style="margin: 0 0 1em 4ex; border: 6px solid #ddd; float: left;">
+ <img alt="icon.png" class="internal" src="/@api/deki/files/717/=Icon.png"></div>
+ <p style=""><em>说明: </em> 此图片显示在应用扩展管理窗口中。</p>
+</div>
+<h4 id="Testing_your_new_button" name="Testing_your_new_button">测试您的按钮</h4>
+<p>重启应用程序(firefox)</p>
+<p>右击工具栏,选中定制,或者在菜单中,依次选择:查看 – 工具栏 – 定制</p>
+<p>将刚才的新按钮拖动到工具栏,点击“退出定制”保存设置。</p>
+<p>点击按钮,应该能看到弹出信息了。</p>
+<h3 id="Further_development" name="Further_development">进一步开发</h3>
+<p>此部分描述如何进一步开发按钮。</p>
+<h4 id="Uninstalling_the_button" name="Uninstalling_the_button">卸载按钮</h4>
+<p>如果想卸载按钮,删掉步骤 2 创建的文件夹即可。</p>
+<p>或者,使用程序自己的 扩展管理窗口 正常卸载应用,在下次重启时应用就会删掉此文件夹。</p>
+<p>重启程序</p>
+<h4 id="Troubleshooting" name="Troubleshooting">排错</h4>
+<p>如果按钮没在工具栏中显示,或是其他问题,可以按照下列步骤排查。</p>
+<p>如果有必要,卸载按钮,重头开始,这次不要修改任何内容</p>
+<p>在能成功让按钮工作后,小心的修改文件。</p>
+<p>要想看到修改后的结果,需要重启应用。</p>
+<h5 id="Advanced_troubleshooting" name="Advanced_troubleshooting">高级排错</h5>
+<p>如果你有一定的技术只是,那么你可以使用应用程序的 JavaScript console 查看错误信息。但是不一定都有用,而且易混淆,或是看到了其他程序的执行结果。</p>
+<p>在 工具栏 - 开发者(web developer) - Browser Console 中开启 JS 选项。或使用快捷键"Ctrl + Shift + J"</p>
+<p> JavaScript console 里会显示 JavaScript, XUL 或 CSS 文件的信息。</p>
+<div class="note">
+ <strong>Note</strong>: The preference setting <a class="external" href="http://kb.mozillazine.org/Javascript.options.strict">javascript.options.strict</a> imposes restrictions that are not appropriate for the simple scripts in this tutorial. If you choose to use this setting, either ignore the warnings that it generates, or change the coding style to keep it quiet.</div>
+<h4 id="Programming_the_button" name="Programming_the_button">为按钮编程</h4>
+<p>要想改变按钮功能,去修改步骤 8 里的 <code>button.js</code> 。</p>
+<p>移除行: <code>alert("Just testing")</code> ,替换成其他 js 语句。</p>
+<p>可以在 <a href="/en/XUL/Toolbars/Custom_toolbar_button/Code_Samples" title="en/Custom_Toolbar_Button/Code_Samples">Code Samples</a> 查看很多代码示例,不用知道编程知识就能修改并使用。</p>
+<p>需要重启才能生效变更。</p>
+<h4 id="Adding_more_buttons" name="Adding_more_buttons">添加更多的按钮</h4>
+<p>要想添加更多的按钮,请编辑 <code>button.xul 文件,对于每个应用,复制指定</code> <code>custom-button-1 的那行</code>,然后将新行指定成 <code>custom-button-2</code>。</p>
+<p>重复最后一部分。在 <code>id</code> 和 <code>oncommand</code> 参数中,将 1 改为 2。然后改变 <code>label</code> 和 <code>tooltiptext</code> 。<strong>不要</strong>改变 <code>class</code> 参数。</p>
+<p>然后编辑 <code>button.css</code>。复制前三行,改变新行成为 <code>button-2</code>.</p>
+<p>编辑 <code>button.js</code> 为新按钮添加 js 语句。请确保<strong>添加的语句在最后一个花括号的前面</strong>,例如,这么添加命令:</p>
+<pre class="eval">2: function () {
+ alert("Just testing again")
+ },
+</pre>
+<p>为新按钮创建图标,命名为 <code>button-2.png</code>。下面提供的文件有40 像素宽,48像素高,256色,透明背景,PNG格式,其他格式也能工作。</p>
+<p>你可以下载使用下列图片:</p>
+<div style="margin: 0 0 1em 4ex; border: 6px solid #ddd; float: left;">
+ <img alt="button-2.png" class="internal" src="/@api/deki/files/580/=Button-2.png"></div>
+<div style="margin: 0 0 1em 4ex; border: 6px solid #ddd; float: left;">
+ <img alt="button-3.png" class="internal" src="/@api/deki/files/583/=Button-3.png"></div>
+<div style="margin: 0 0 1em 4ex; border: 6px solid #ddd; float: left;">
+ <img alt="button-4.png" class="internal" src="/@api/deki/files/586/=Button-4.png"></div>
+<div style="margin: 0 0 1em 4ex; border: 6px solid #ddd; float: left;">
+ <img alt="button-5.png" class="internal" src="/@api/deki/files/589/=Button-5.png"></div>
+<p style="">重启程序,并将新按钮添加到工具栏。</p>
+<p>你可以重复这些步骤,创建更多按钮</p>
+<h3 id="Distributing_your_button_to_other_users" name="Distributing_your_button_to_other_users">将您的按钮分发给其他用户</h3>
+<p>如果你想将按钮程序分发给他人,那就必须做些修改以和其他扩展程序做区分。</p>
+<p>创建一个扩展 ID,格式为:</p>
+<dl>
+ <dd>
+ <code><em>something</em>@<em>domain-name</em></code></dd>
+</dl>
+<p>必须包含at符号 (<code>@</code>),格式和邮箱地址挺像,但不必是真实邮箱地址。@符号的前后,只能使用字符 : A-Z, a-z, 0-9, 英文句号( . ), 连字符(-)和下划线(_)。如果您没有域名(domain-name),可以自己编个,如果你想让这域名看着不像真正的域名,那就在结尾加个 <code>.invalid</code> 。</p>
+<p>使用你的 扩展ID (extension ID)重命名文件夹,然后在 <code>install.rdf</code> 文件中指定相同的 ID。</p>
+<p><code>在 install.rdf</code> 文件中,移除您扩展不能正常工作的应用项。例如,如果您的按钮只能在 Thunderbird 上运行,就删除 Firefox 和 Sunbird 的部分。同样道理,修改 <code>button.xul</code> 和 <code>chrome.manifest</code>.</p>
+<p>改变所有文件中的 "custombutton", "custom-button" 和 "CustomButton" 字样。</p>
+<p>可以自己更改的:</p>
+<ul>
+ <li>按钮的图片</li>
+ <li>扩展的图片: <code>icon.png</code></li>
+ <li> <code>install.rdf</code> 中的版本号和主页</li>
+</ul>
+<p>使用 jar 工具或 zip 工具打包整个文件夹的内容命名为 <code>.xpi</code> 文件。方便用于其他程序。</p>
+<p>用户可在应用程序的扩展管理窗口中安装此 XPI 文件。</p>
diff --git a/files/zh-cn/mozilla/tech/xul/toolbars/index.html b/files/zh-cn/mozilla/tech/xul/toolbars/index.html
new file mode 100644
index 0000000000..b028d9cd69
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/toolbars/index.html
@@ -0,0 +1,65 @@
+---
+title: Toolbars
+slug: Mozilla/Tech/XUL/Toolbars
+tags:
+ - NeedsTranslation
+ - TopicStub
+translation_of: Archive/Mozilla/XUL/Toolbars
+---
+<p>Toolbars, implemented using the XUL <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbar" title="toolbar">toolbar</a></code> element, are containers for toolbar buttons and other user interface objects. The following articles provide details about implementing and working with toolbars.</p>
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h2 class="Documentation" id="Documentation" name="Documentation">Documentation</h2>
+ <dl>
+ <dt><a href="/en-US/docs/XUL/School_tutorial/Adding_Toolbars_and_Toolbar_Buttons" title="XUL/School_tutorial/Adding Toolbars and Toolbar Buttons">XUL School: Adding Toolbars and Toolbar Buttons</a></dt>
+ <dd>A helpful tutorial to creating toolbars and toolbar buttons.</dd>
+ <dt><a href="/en-US/docs/XUL/Toolbars/Toolbar_customization_events" title="XUL/Toolbars/Toolbar customization events">Toolbar customization events</a></dt>
+ <dd>A look at the events that are sent during toolbar customization; you can use these to be kept aware of changes to toolbars.</dd>
+ <dt><a href="/en-US/docs/XUL/Toolbars/Creating_toolbar_buttons" title="XUL/Toolbars/Creating toolbar buttons">Creating toolbar buttons</a></dt>
+ <dd>How to use overlays to add toolbar buttons to Mozilla applications.</dd>
+ <dt><a href="/en-US/docs/XUL/Toolbars/Custom_toolbar_button" title="XUL/Toolbars/Custom toolbar button">Custom toolbar button</a></dt>
+ <dd>Another example of how to create a toolbar button, complete with a sample extension you can download and try.</dd>
+ <dt><a href="/en-US/docs/Code_snippets/Toolbar" title="Code snippets/Toolbar">Code snippets: Toolbar</a></dt>
+ <dd>Code snippets that are helpful when working with toolbars.</dd>
+ <dt></dt>
+ </dl>
+ <p><span class="alllinks"><a href="/en-US/docs/tag/Extensions" title="Tags:Toolbars">View all pages tagged with "Toolbars"...</a></span></p>
+ </td>
+ <td>
+ <h2 class="Community" id="Community" name="Community">Community</h2>
+ <ul>
+ <li>View Mozilla extension development forums... <ul>
+ <li><a href="https://lists.mozilla.org/listinfo/dev-extensions"> 邮件列表</a></li>
+
+
+ <li><a href="http://groups.google.com/group/mozilla.dev.extensions"> 新闻组</a></li>
+ <li><a href="http://groups.google.com/group/mozilla.dev.extensions/feeds"> Web feed</a></li>
+</ul></li>
+ <li><a class="link-irc" href="irc://irc.mozilla.org/extdev">#extdev IRC channel</a></li>
+ <li><a href="http://forums.mozillazine.org/?c=11">MozillaZine forum</a></li>
+ <li><a href="/devnews/index.php/categories/about-addons" title="https://developer.mozilla.org/editor/fckeditor/core/editor/devnews/index.php/categories/about-addons/">about:addons newsletter</a></li>
+ <li><a href="/web-tech" title="https://developer.mozilla.org/editor/fckeditor/core/editor/web-tech/">Mozilla's Web-Tech blog</a></li>
+ <li><a href="http://mozdev.org/mailman/listinfo/project_owners">mozdev project owners</a></li>
+ <li><a href="http://planet.mozilla.org/" title="http://planet.mozilla.org/">Planet Mozilla</a></li>
+ <li><a href="/en-US/docs/Extensions/Community" title="Extensions/Community">Other community links...</a></li>
+ </ul>
+ <h2 class="Tools" id="Tools" name="Tools">Tools</h2>
+ <ul>
+ <li><a class="link-https" href="https://addons.mozilla.org/en-US/firefox/addon/6622" rel="external nofollow" title="https://addons.mozilla.org/en-US/firefox/addon/6622">DOM Inspector</a> edit the live DOM (Firefox and Thunderbird)</li>
+ <li><a class="link-https" href="https://builder.mozillalabs.com/" title="https://builder.mozillalabs.com/">Mozilla Labs Add-on Builder</a></li>
+ <li><a class="link-https" href="https://addons.mozilla.org/en-US/firefox/addon/7434/" rel="external nofollow" title="https://addons.mozilla.org/en-US/firefox/addon/7434/">Extension Developer's Extension</a> a suite of development tools</li>
+ <li><a href="http://www.gijsk.com/" rel="external nofollow" title="http://www.gijsk.com/">Chrome List</a> view files in chrome:// (<a href="http://addons.mozilla.org/en-US/firefox/addon/4453" rel="external nofollow" title="http://addons.mozilla.org/en-US/firefox/addon/4453">Firefox</a>, <a href="http://addons.mozilla.org/en-US/thunderbird/addon/4453" rel="external nofollow" title="http://addons.mozilla.org/en-US/thunderbird/addon/4453">Thunderbird</a>)</li>
+ <li><a href="http://ted.mielczarek.org/code/mozilla/extensionwiz/" rel="external nofollow" title="http://ted.mielczarek.org/code/mozilla/extensionwiz/">Extension Wizard</a> a web-based extension skeleton generator (Firefox and Thunderbird)</li>
+ </ul>
+ <p>... <a href="/en-US/docs/Setting_up_extension_development_environment#Development_extensions" title="Setting up extension development environment#Development extensions">more tools</a> ...</p>
+
+ <h2 class="Related_Topics" id="Related_Topics" name="Related_Topics">Related Topics</h2>
+ <ul>
+ <li><a href="/en-US/docs/XUL" title="XUL">XUL</a>, <a href="/en-US/docs/Themes" title="Themes">Themes</a>, <a href="/en-US/docs/Developer_Guide" title="Developing_Mozilla">Developing Mozilla</a></li>
+ </ul>
+ </td>
+ </tr>
+ </tbody>
+</table>
diff --git a/files/zh-cn/mozilla/tech/xul/toolbox/index.html b/files/zh-cn/mozilla/tech/xul/toolbox/index.html
new file mode 100644
index 0000000000..4417170b3e
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/toolbox/index.html
@@ -0,0 +1,6 @@
+---
+title: toolbox
+slug: Mozilla/Tech/XUL/toolbox
+translation_of: Archive/Mozilla/XUL/toolbox
+---
+<p>This page has no content. Enrich MDC by contributing.</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tree/index.html b/files/zh-cn/mozilla/tech/xul/tree/index.html
new file mode 100644
index 0000000000..7e2de0b669
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tree/index.html
@@ -0,0 +1,512 @@
+---
+title: tree
+slug: Mozilla/Tech/XUL/tree
+translation_of: Archive/Mozilla/XUL/tree
+---
+<div class="noinclude"><span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+
+<p>tree是用来显示表格或层级行元素的容器。 包含若干行 (rows )和列(columns)。树的每行包含若干缩进显示的子行(child rows)。 和其他元素不同的是,用来显示的数据不是通过标签(tags),而是通过一个显示对象(view object)来确定的。这个显示对象(view object)实现了接口 <a href="/en/XPCOM_Interface_Reference/nsITreeView" title="en/nsITreeView">nsITreeView</a> . The view is queried for the data to appear in the tree. 树的使用有以下几种方法, 第二列列出了通过树的 <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/view">view</a></span></code>属性(property)的可用的接口. 第三列指示<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/treeitem" title="treeitem">treeitem</a></code> 元素是否使用.</p>
+
+<p>If you would like to allow the tree to be horizontally scrolled, simply set the <code id="a-width"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/width">width</a></code> attributes for each column to make the tree wider than its containing object.</p>
+
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th>Tree type</th>
+ <th>View interfaces</th>
+ <th>Has DOM nodes?</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>Content tree</td>
+ <td><a href="/en/XPCOM_Interface_Reference/nsITreeView" title="en/nsITreeView">nsITreeView</a>, <a href="/en/XPCOM_Interface_Reference/NsITreeContentView" title="en/NsITreeContentView">nsITreeContentView</a></td>
+ <td>Yes</td>
+ <td>This tree has <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/treeitem" title="treeitem">treeitem</a></code> elements placed within the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/treechildren" title="treechildren">treechildren</a></code> element. In this situation, a content view (which implements the interface <a href="/en/XPCOM_Interface_Reference/NsITreeContentView" title="en/NsITreeContentView">nsITreeContentView</a>) which is a more specialized type of view, uses the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/treeitem" title="treeitem">treeitem</a></code> elements and their descendants to determine the data to display in the tree. However, the treeitems are not displayed directly; they are used only as data to the content view. However, the content view will automatically update the tree if treeitems are changed.</td>
+ </tr>
+ <tr>
+ <td>RDF tree</td>
+ <td><a href="/en/XPCOM_Interface_Reference/nsITreeView" title="en/nsITreeView">nsITreeView</a>, <a href="/en/NsIXULTreeBuilder" title="en/NsIXULTreeBuilder">nsIXULTreeBuilder</a></td>
+ <td>No</td>
+ <td>This tree is generated from an RDF datasource. It is used when a tree has a <code id="a-datasources"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/datasources">datasources</a></code> attribute, and has <code>dont-build-content</code> in its <code id="a-flags"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flags">flags</a></code> attribute. For this tree, the data comes directly from the RDF datasource. DOM <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/treeitem" title="treeitem">treeitem</a></code>s are not created. Even though the template uses treeitem elements to define the content, DOM nodes for these elements are not created. This is the type that should be used for RDF generated trees with lots of rows.</td>
+ </tr>
+ <tr>
+ <td>RDF content tree</td>
+ <td><a href="/en/XPCOM_Interface_Reference/nsITreeView" title="en/nsITreeView">nsITreeView</a>, <a href="/en/NsIXULTreeBuilder" title="en/NsIXULTreeBuilder">nsIXULTreeBuilder</a>, <a href="/en/XPCOM_Interface_Reference/NsITreeContentView" title="en/NsITreeContentView">nsITreeContentView</a></td>
+ <td>Yes</td>
+ <td>This tree is generated from an RDF datasource. It is similar to the previous type but is used when the tree does not have <code>dont-build-content</code> in its <code id="a-flags"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flags">flags</a></code> attribute. DOM <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/treeitem" title="treeitem">treeitem</a></code>s are created, so you can access the data using RDF functions or DOM functions. This type is suitable for RDF generated trees with a fairly small number of rows.</td>
+ </tr>
+ <tr>
+ <td>Custom tree view</td>
+ <td><a href="/en/XPCOM_Interface_Reference/nsITreeView" title="en/nsITreeView">nsITreeView</a></td>
+ <td>No</td>
+ <td>For this tree you implement the <a href="/en/XPCOM_Interface_Reference/nsITreeView" title="en/nsITreeView">nsITreeView</a> interface yourself. The tree's data is retrieved from this custom view. The custom view should be attached to the tree by setting its <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/view">view</a></span></code> property.</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>More information is available in the <a href="/en/XUL_Tutorial/Trees" title="en/XUL_Tutorial/Trees">XUL tutorial</a>. Also <a href="/en/Tree_Widget_Changes" title="en/Tree_Widget_Changes">Tree Widget Changes</a>.</p>
+
+<table style="background: #eeeeee none repeat scroll 0% 0%; border: 1px solid #cccccc; margin: 0px 0px 10px 10px; padding: 0px 10px;">
+ <tbody>
+ <tr>
+ <td><strong><a href="/en/XUL_accessibility_guidelines#Trees" title="en/XUL_accessibility_guidelines#Trees">Relevant accessbility guidelines</a></strong><small> </small>
+
+ <ul>
+ <li><small>Provide alternative access (e.g., via menus) to column picker and for header behaviors like sorting (these have no default keyboard access).</small></li>
+ </ul>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<dl>
+ <dt>Attributes</dt>
+ <dd><a href="#a-disableKeyNavigation">disableKeyNavigation</a>, <a href="#a-disabled">disabled</a>, <a href="#a-tree.editable">editable</a>, <a href="#a-enableColumnDrag">enableColumnDrag</a>, <a href="#a-flags">flags</a>, <a href="#a-hidecolumnpicker">hidecolumnpicker</a>, <a href="#a-tree.onselect">onselect</a>, <a href="#a-rows">rows</a>, <a href="#a-seltype">seltype</a>, <a href="#a-statedatasource">statedatasource</a>, <a href="#a-tabindex">tabindex</a>, <a href="#a-treelines">treelines</a></dd>
+</dl>
+
+<dl>
+ <dt>Properties</dt>
+ <dd><a href="#p-accessibleType">accessibleType</a>, <a href="#p-builderView">builderView</a>, <a href="#p-columns">columns</a>, <a href="#p-contentView">contentView</a>, <a href="#p-currentIndex">currentIndex</a>, <a href="#p-disableKeyNavigation">disableKeyNavigation</a>, <a href="#p-disabled">disabled</a>, <a href="#p-editingColumn">editingColumn</a>, <a href="#p-editingRow">editingRow</a>, <a href="#p-enableColumnDrag">enableColumnDrag</a>, <a href="#p-firstOrdinalColumn">firstOrdinalColumn</a>, <a href="#p-tree.inputField">inputField</a>, <a href="#p-selType">selType</a>, <a href="#p-selstyle">selstyle</a>, <a href="#p-tabIndex">tabIndex</a>, <a href="#p-treeBoxObject">treeBoxObject</a>, <a href="#p-view">view</a></dd>
+</dl>
+
+<h3 id="Examples" name="Examples">Examples</h3>
+
+<h4 id="A_tree_with_several_columns">A tree with several columns</h4>
+
+<pre class="script">&lt;tree flex="1" rows="2"&gt;
+
+ &lt;treecols&gt;
+ &lt;treecol id="sender" label="Sender" flex="1"/&gt;
+ &lt;treecol id="subject" label="Subject" flex="2"/&gt;
+ &lt;/treecols&gt;
+
+ &lt;treechildren&gt;
+ &lt;treeitem&gt;
+ &lt;treerow&gt;
+ &lt;treecell label="joe@somewhere.com"/&gt;
+ &lt;treecell label="Top secret plans"/&gt;
+ &lt;/treerow&gt;
+ &lt;/treeitem&gt;
+ &lt;treeitem&gt;
+ &lt;treerow&gt;
+ &lt;treecell label="mel@whereever.com"/&gt;
+ &lt;treecell label="Let's do lunch"/&gt;
+ &lt;/treerow&gt;
+ &lt;/treeitem&gt;
+ &lt;/treechildren&gt;
+
+&lt;/tree&gt;
+</pre>
+
+<div><img alt="Image:trees1.png" class="internal" src="/@api/deki/files/899/=Trees1.png"></div>
+
+<h4 id="A_tree_with_several_columns_and_nested_items">A tree with several columns and nested items</h4>
+
+<pre class="script">&lt;tree id="myTree" flex="1" hidecolumnpicker="false" seltype="single" class="tree"
+ rows="5"&gt;
+ &lt;treecols id="myTree2-treeCols"&gt;
+ &lt;treecol id="myTree2-treeCol0" primary="true" flex="2" label="Column A"
+ persist="width" ordinal="1"/&gt;
+ &lt;splitter class="tree-splitter" ordinal="2"/&gt;
+ &lt;treecol id="myTree2-treeCol1" flex="1" label="Column B"
+ persist="width" ordinal="3"/&gt;
+ &lt;/treecols&gt;
+ &lt;treechildren&gt;
+ &lt;treeitem&gt;
+ &lt;treerow&gt;
+ &lt;treecell label="1"/&gt;
+ &lt;treecell label="a"/&gt;
+ &lt;/treerow&gt;
+ &lt;/treeitem&gt;
+ &lt;!-- Make sure to set container="true" --&gt;
+ &lt;treeitem container="true" open="true"&gt;
+ &lt;treerow&gt;
+ &lt;treecell label="2"/&gt;
+ &lt;treecell label="b"/&gt;
+ &lt;/treerow&gt;
+ &lt;treechildren&gt;
+ &lt;treeitem&gt;
+ &lt;treerow&gt;
+ &lt;treecell label="2a"/&gt;
+ &lt;treecell label="ba"/&gt;
+ &lt;/treerow&gt;
+ &lt;/treeitem&gt;
+ &lt;/treechildren&gt;
+ &lt;/treeitem&gt;
+ &lt;/treechildren&gt;
+&lt;/tree&gt;
+</pre>
+
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+
+<p> </p><div id="a-disabled">
+
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd> </dd>
+ <dd>
+ <h5 id="类型boolean">类型:<em>boolean</em></h5>
+ </dd>
+ <dd>
+ <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>
+
+ <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>
+
+ <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
+ </dd>
+</dl>
+
+<h4 id="示例:">示例:</h4>
+
+<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>
+
+<pre><code>// Disabling an element
+document.getElementById('buttonRemove').setAttribute("disabled", "true");
+
+// Enabling back an element by removing the "disabled" attribute
+document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>
+
+<p></p><div class="blockIndicator standardNote standardNoteBlock">
+ <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
+ <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
+</div><p></p>
+</div> <div id="a-disableKeyNavigation">
+
+
+<dl>
+ <dt><code id="a-disableKeyNavigation"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/disableKeyNavigation">disableKeyNavigation</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>If this attribute is not used, the user can navigate to specific items within the element by pressing keys corresponding to letters in the item's label. This is done incrementally, so typing more letters with select more specific items. This feature may be disabled by setting this attribute to <code>true</code>.</dd>
+</dl>
+</div> <div id="a-tree.editable">
+
+
+<dl>
+ <dt><code id="a-tree.editable"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/tree.editable">editable</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>Indicates that the cells of the <code><a href="/en-US/docs/Mozilla/Tech/XUL/tree" title="tree">tree</a></code> may be edited.</dd>
+</dl>
+</div> <div id="a-enableColumnDrag">
+
+
+<dl>
+ <dt><code id="a-enableColumnDrag"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/enableColumnDrag">enableColumnDrag</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>When set to <code>true</code>, the user may drag the column headers around to change the order in which they are displayed.</dd>
+</dl>
+</div> <div id="a-flags">
+
+
+<dl>
+ <dt><code id="a-flags"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/flags">flags</a></code></dt>
+ <dd>Type: <em>space-separated list of the values below</em></dd>
+ <dd>A set of flags used for miscellaneous purposes. Two flags are defined, which may be the value of this attribute.
+ <ul>
+ <li><code>dont-test-empty</code>: For template generated content, the builder will not check that a container is empty.</li>
+ <li><code>dont-build-content</code>: This flag may be used on a tree to indicate that content elements should not be generated. This results in a performance enhancement, but you will not be able to use the DOM functions to retrieve the tree rows.</li>
+ </ul>
+ </dd>
+</dl>
+</div> <div id="a-hidecolumnpicker">
+
+
+<dl>
+ <dt><code id="a-hidecolumnpicker"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/hidecolumnpicker">hidecolumnpicker</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>When set to <code>false</code>, a drop-down will appear in the upper right corner of the <code><a href="/en-US/docs/Mozilla/Tech/XUL/tree" title="tree">tree</a></code>, which the user may use to show and hide columns. When set to <code>true</code>, the column picker will be hidden. The default value is <code>false</code>.</dd>
+</dl>
+</div> <div id="a-tree.onselect">
+
+
+<dl>
+ <dt><code id="a-tree.onselect"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/tree.onselect">onselect</a></code></dt>
+ <dd>Type: <em>script code</em></dd>
+ <dd>This event is sent to a <code><a href="/en-US/docs/Mozilla/Tech/XUL/tree" title="tree">tree</a></code> when a row is selected, or whenever the selection changes. The user can select multiple rows by holding down Shift or Control and clicking on a row. The <code>onselect</code> event will be sent for each item added to or removed from the selection.</dd>
+</dl>
+
+
+</div> <div id="a-rows">
+
+<dl>
+ <dt>
+ <code id="a-rows"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/rows">rows</a></code></dt>
+ <dd>
+ Type: <em>integer</em></dd>
+ <dd>
+ The number of rows to display in the element. If the element contains more than this number of rows, a scrollbar will appear which the user can use to scroll to the other rows. To get the actual number of rows in the element, use the <span id="m-getRowCount"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/getRowCount">getRowCount</a></code></span> method.</dd>
+</dl>
+</div> <div id="a-seltype">
+
+
+<dl>
+ <dt><code id="a-seltype"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/seltype">seltype</a></code></dt>
+ <dd>Type: <em>one of the values below</em></dd>
+ <dd>Used to indicate whether multiple selection is allowed.</dd>
+ <dd>
+ <dl>
+ <dt><code>single</code></dt>
+ <dd>Only one row may be selected at a time. (Default in <code>listbox</code> and <code>richlistbox</code>.)</dd>
+ <dt><code>multiple</code></dt>
+ <dd>Multiple rows may be selected at once. (Default in <code>tree</code>.)</dd>
+ </dl>
+ </dd>
+ <dd>
+ <p>For trees, you can also use the following values:</p>
+
+ <dl>
+ <dt><code>cell</code></dt>
+ <dd>Individual cells can be selected </dd>
+ <dt><code>text</code></dt>
+ <dd>Rows are selected; however, the selection highlight appears only over the text of the primary column.</dd>
+ </dl>
+
+ <p>For <code>richlistbox</code>, this is new in Firefox 3.5.</p>
+ </dd>
+</dl>
+</div> <div id="a-statedatasource">
+
+
+<dl>
+ <dt><code id="a-statedatasource"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/statedatasource">statedatasource</a></code></dt>
+ <dd>Type: <em>URI</em></dd>
+ <dd>Chrome XUL may specify an RDF datasource to use to store <code><a href="/en-US/docs/Mozilla/Tech/XUL/tree" title="tree">tree</a></code> state information. This is used to hold which tree items are open and which items are collapsed. This information will be remembered for the next time the XUL file is opened. If you do not specify this attribute, state information will be stored in the local store (<code>rdf:local-store</code>).</dd>
+</dl>
+</div> <div id="a-tabindex">
+
+
+<dl>
+ <dt><code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code></dt>
+ <dd>Type:<em>integer</em></dd>
+ <dd>当用户按下 "<kbd>tab</kbd>" 键时焦点移动到元素上的顺序。<code>tabindex</code> 数字越大,顺序越靠后。</dd>
+</dl>
+
+
+
+<p></p>
+</div> <div id="a-treelines">
+
+<dl><dt> <code id="a-treelines"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/treelines">treelines</a></code> <br>
+</dt><dd> Type: <em>boolean</em> </dd><dd> When set to <code>true</code>, lines are drawn connecting the lines in the tree; when <code>false</code>, the lines are not drawn. This is <code>false</code> by default.<br>
+</dd></dl>
+</div><p></p>
+
+<h3 id="Properties" name="Properties">Properties</h3>
+
+<p> </p><div id="p-accessibleType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ A value indicating the type of accessibility object for the element.</dd>
+</dl>
+
+<p></p></div> <div id="p-builderView">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/builderView">builderView</a></span></code></dt>
+ <dd>Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIXULTreeBuilder" title="">nsIXULTreeBuilder</a></code></em></dd>
+ <dd>A reference to the tree builder which constructed the <code><a href="/en-US/docs/Mozilla/Tech/XUL/tree" title="tree">tree</a></code> data. The builder provides access to the RDF resources for each row in the tree, and allows sorting the data by column. In newer versions of Mozilla, the <code>builderView</code> property is actually a synonym for the <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/view">view</a></span></code> property, since the two interfaces are flattened together into a single interface in <a href="/en/JavaScript" title="en/JavaScript">JavaScript</a>. This property is read-only.</dd>
+</dl></div> <div id="p-columns">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/columns">columns</a></span></code></dt>
+ <dd>
+ Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeColumns" title="">nsITreeColumns</a></code></em></dd>
+ <dd>
+ Returns the columns for the tree as an <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeColumns" title="">nsITreeColumns</a></code> object.</dd>
+</dl></div> <div id="p-contentView">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/contentView">contentView</a></span></code></dt>
+ <dd>
+ Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeContentView" title="">nsITreeContentView</a></code></em></dd>
+ <dd>
+ For trees built with a content builder - that is, those that do not have <code id="a-flags"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/flags">flags</a></code> set -- the <code>contentView</code> will be a reference to the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeContentView" title="">nsITreeContentView</a></code> for the tree. This interface lets you retrieve the DOM element corresponding to a given a row index and vice versa. For trees that are not built with a content builder, the functions of <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeContentView" title="">nsITreeContentView</a></code> will not be available, since there are no DOM nodes to retrieve. In newer versions of Mozilla, the <code>contentView</code> property is actually a synonym for the <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/view">view</a></span></code> property, since the two interfaces are flattened together into a single interface in <a href="/en-US/docs/JavaScript" title="JavaScript">JavaScript</a>. This property is read-only.</dd>
+</dl></div> <div id="p-currentIndex">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/currentIndex">currentIndex</a></span></code></dt>
+ <dd>
+ Type: <em>integer</em></dd>
+ <dd>
+ <p>Set to the row index of the tree caret in the <code><a href="/en-US/docs/Mozilla/Tech/XUL/tree" title="tree">tree</a></code>. For trees with focus, the caret's position is indicated by the focus ring, but unfocused trees won't show  a focus ring, naturally. For unfocused trees, the (undrawn) caret's position can still be obtained by this property. If the caret isn't present for any row (for example, because the tree has never been focused), the value will be <code>-1</code>.</p>
+ <p><strong>You cannot rely on this property to change or determine a tree selection</strong>, except for trees with <code><code id="a-seltype"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/seltype">seltype</a></code>="single"</code>. (All trees have <code>seltype="multiple"</code> by default.) To reliably change or determine a selection, instead use the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeSelection" title="">nsITreeSelection</a></code> interface methods available via <code>tree.view.selection</code>.</p>
+ </dd>
+</dl>
+</div> <div id="p-disabled">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/disabled">disabled</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ boolean</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-disableKeyNavigation">
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/disableKeyNavigation">disableKeyNavigation</a></span></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>Gets or sets the value of the <code id="a-disableKeyNavigation"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/disableKeyNavigation">disableKeyNavigation</a></code> attribute.</dd>
+</dl></div> <div id="p-editingColumn">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/editingColumn">editingColumn</a></span></code> </dt>
+ <dd>Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeColumn" title="">nsITreeColumn</a></code></em></dd>
+ <dd>The column of the <code><a href="/en-US/docs/Mozilla/Tech/XUL/tree" title="tree">tree</a></code> cell currently being edited, or <code>null</code> if there is no cell being edited.</dd>
+</dl></div> <div id="p-editingRow">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/editingRow">editingRow</a></span></code> </dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>The row index of the <a href="/en/XUL/tree" title="en/XUL/tree">tree</a> cell currently being edited, or <code>-1</code> if there is no cell currently being edited.</dd>
+</dl></div> <div id="p-enableColumnDrag">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/enableColumnDrag">enableColumnDrag</a></span></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>When set to <code>true</code>, the user may drag the column headers around to change the order in which they are displayed.</dd>
+</dl></div> <div id="p-firstOrdinalColumn">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/firstOrdinalColumn">firstOrdinalColumn</a></span></code></dt>
+ <dd>Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XUL/treecol" title="treecol">treecol</a></code> element</em></dd>
+ <dd>A reference to the first <code><a href="/en-US/docs/Mozilla/Tech/XUL/treecol" title="treecol">treecol</a></code> element, which or may not be the first column displayed in the tree.</dd>
+</dl></div> <div id="p-tree.inputField">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/tree.inputField">inputField</a></span></code></dt>
+ <dd>Type: <em>textbox element</em></dd>
+ <dd>Read-only property that holds the <code><a href="/en-US/docs/Mozilla/Tech/XUL/textbox" title="textbox">textbox</a></code> that is used for editing.</dd>
+</dl></div> <div id="p-selType">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/selType">selType</a></span></code> </dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ Gets and sets the value of the <code id="a-seltype"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/seltype">seltype</a></code> attribute.</dd>
+</dl>
+<p> </p></div> <div id="p-selstyle">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/selstyle">selstyle</a></span></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ If set to the value <code>primary</code>, only the label of the primary column will be highlighted when an item in the tree is selected. Otherwise, the entire row will be highlighted. To see the difference, compare the selection style in the folder list and the message list in Mozilla mail.</dd>
+</dl></div> <div id="p-tabIndex">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tabIndex">tabIndex</a></span></code></dt>
+ <dd>
+ Type:
+ <i>
+ integer</i>
+ </dd>
+ <dd>
+ Gets and sets the value of the <code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code> attribute.</dd>
+</dl>
+
+<p></p></div> <div id="p-treeBoxObject">
+
+<dl>
+ <dt><code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/treeBoxObject">treeBoxObject</a></span></code></dt>
+ <dd>Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeBoxObject" title="">nsITreeBoxObject</a></code></em></dd>
+ <dd>The box object is responsible for rendering the <code><a href="/en-US/docs/Mozilla/Tech/XUL/tree" title="tree">tree</a></code> on the window. This object implements the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeBoxObject" title="">nsITreeBoxObject</a></code> interface and contains functions for retrieving the cells at certain coordinates, redrawing cells and scrolling the tree. This property is equivalent to the <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/boxObject">boxObject</a></span></code> property.</dd>
+</dl></div> <div id="p-view">
+<dl>
+ <dt>
+ <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/view">view</a></span></code></dt>
+ <dd>
+ Type: <em><code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeView" title="">nsITreeView</a></code></em></dd>
+ <dd>
+ The view for the <code><a href="/en-US/docs/Mozilla/Tech/XUL/tree" title="tree">tree</a></code>, which is the object which generates the data to be displayed. You can assign an object which implements <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeView" title="">nsITreeView</a></code> to this property. Trees built from RDF or those which use <code><a href="/en-US/docs/Mozilla/Tech/XUL/treeitem" title="treeitem">treeitem</a></code>s directly will already have a view. Functions available in the view allow one to retrieve the data within the cells, and determine which rows are nested within others. For a complete list of view functions, see the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeView" title="">nsITreeView</a></code> interface.</dd>
+</dl></div><p></p>
+
+<h3 id="Methods" name="Methods">Methods</h3>
+
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table> <dl>
+ <dt><span id="m-startEditing"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/startEditing">startEditing( row, column )</a></code></span> </dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Activates user editing of the given cell, which is specified by row index number and the <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeColumn" title="">nsITreeColumn</a></code> in which it is located. The tree view's <code><a href="https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsITreeView#getCellText()">nsITreeView.getCellText()</a></code> method is called to obtain the cell contents.</dd>
+</dl> <dl>
+ <dt><span id="m-stopEditing"><code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/stopEditing">stopEditing( shouldaccept )</a></code></span> </dt>
+ <dd>Return type: <em>no return value</em></dd>
+ <dd>Stops editing the cell currently being edited. If the <code>shouldAccept</code> parameter is <code>true</code>, the cell's label is changed to the edited value (the tree view's <code><a href="https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsITreeView#setCellText()">nsITreeView.setCellText()</a></code> method is called to change the cell contents). Otherwise the cell label is reverted to the value it had prior to editing.</dd>
+</dl><p></p>
+
+<h3 id="Related" name="Related">Related</h3>
+
+<dl>
+ <dt>Elements</dt>
+ <dd><a href="/en/XUL/treecols" title="en/XUL/treecols">treecols</a>, <a href="/en/XUL/treecol" title="en/XUL/treecol">treecol</a>, <a href="/en/XUL/treechildren" title="en/XUL/treechildren">treechildren</a>, <a href="/en/XUL/treeitem" title="en/XUL/treeitem">treeitem</a>, <a href="/en/XUL/treerow" title="en/XUL/treerow">treerow</a>, <a href="/en/XUL/treecell" title="en/XUL/treecell">treecell</a> and <a href="/en/XUL/treeseparator" title="en/XUL/treeseparator">treeseparator</a>.</dd>
+ <dt>Interfaces</dt>
+ <dd><a href="/en/XPCOM_Interface_Reference/nsIAccessibleProvider" title="en/nsIAccessibleProvider">nsIAccessibleProvider</a>, <a href="/en/NsIDOMXULTreeElement" title="en/NsIDOMXULTreeElement">nsIDOMXULTreeElement</a>, <a href="/en/NsIDOMXULMultiSelectControlElement" title="en/NsIDOMXULMultiSelectControlElement">nsIDOMXULMultiSelectControlElement</a></dd>
+</dl>
+
+<h3 id="Script_Examples" name="Script_Examples">Script Examples</h3>
+
+<p>To have alternating colors for each row, use the style rules like the following: <small>pma at daffodil dot uk dot com</small></p>
+
+<pre class="script">treechildren::-moz-tree-row(selected) { background-color: #FFFFAA; }
+treechildren::-moz-tree-row(odd) { background-color: #EEEEEE; }
+treechildren::-moz-tree-row(odd, selected) { background-color: #FFFFAA; }
+treechildren::-moz-tree-cell-text(selected) { color: #000000; }
+treechildren::-moz-tree-cell-text(odd, selected) { color: #000000; }
+</pre>
+
+<p>If using a content tree view, use the following to get the value of the id attribute for each of the selected rows of a tree: <small>tcooper_mont at yahoo dot com</small></p>
+
+<pre class="script">var idList = [];
+var rangeCount = tree.view.selection.getRangeCount();
+for (var i = 0; i &lt; rangeCount; i++)
+{
+ var start = {};
+ var end = {};
+ tree.view.selection.getRangeAt(i, start, end);
+ for(var c = start.value; c &lt;= end.value; c++)
+ {
+ idList.push(tree.view.getItemAtIndex(c).firstChild.id);
+ }
+}
+</pre>
+
+<p>The following returns a array of the indicies of the rows where the value is checked in a checkbox type column: <small>jfabre at ismans dot fr</small></p>
+
+<pre class="script">function getCellChecked(tree, columnid)
+{
+ var arr = [];
+ var column = tree.columns.getNamedColumn(columnid);
+ for (var i = 0; i &lt; tree.view.rowCount; i++){
+ if (tree.view.getCellValue(i, column) == 'true')
+ arr.push(i);
+ }
+ return arr;
+}
+</pre>
+
+<p>To get the text value for a specific column (e.g. column 'age') from the currently focused row in the tree:</p>
+
+<pre class="script">var t = document.getElementById('mytree');
+document.title = t.view.getCellText(t.currentIndex,t.columns.getNamedColumn('age'));
+</pre>
+
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/adding_buttons/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/adding_buttons/index.html
new file mode 100644
index 0000000000..607e4d0abc
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/adding_buttons/index.html
@@ -0,0 +1,98 @@
+---
+title: XUL_教程/增加一些按钮
+slug: Mozilla/Tech/XUL/Tutorial/Adding_Buttons
+tags:
+ - XUL_教程
+translation_of: Archive/Mozilla/XUL/Tutorial/Adding_Buttons
+---
+<p> </p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Creating_a_Window" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Adding_Labels_and_Images">下一页 »</a></p>
+</div><p></p>
+<p> </p>
+<p>在本章,我们将学习如何向window添加button。</p>
+<h3 id=".E6.B7.BB.E5.8A.A0.E5.A4.9A.E4.B8.AA.E6.8C.89.E9.92.AE.E5.88.B0.E4.B8.80.E4.B8.AA.E7.AA.97.E5.8F.A3" name=".E6.B7.BB.E5.8A.A0.E5.A4.9A.E4.B8.AA.E6.8C.89.E9.92.AE.E5.88.B0.E4.B8.80.E4.B8.AA.E7.AA.97.E5.8F.A3">添加多个按钮到一个窗口</h3>
+<p>到目前为止我们创建的这个窗口里面什么也没有,因此还不算非常有趣. 在这一节中,我们将添加两个按钮, 一个“查找”按钮和一个“取消”按钮.我们还将学到一个简单的方法在窗口上来定位它们.</p>
+<p>像HTML, XUL也有许多标记,它们被用来当作创建用户接口的元素. 最基本的一个 <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/button" title="button">button</a></code></code> 标记. 这个元素被用来创建简单的按钮。</p>
+<p>按钮元素有两个主要的属性,一个<code>label</code>和一个<code>image</code>。你可以要一个或两个都要。因此,按钮可以只有一个标签,一个图片或标签和图片都有。通常在对话框中会使用“确定”和“取消”按钮。</p>
+<h4 id=".E6.8C.89.E9.92.AE.E7.9A.84.E8.AF.AD.E6.B3.95" name=".E6.8C.89.E9.92.AE.E7.9A.84.E8.AF.AD.E6.B3.95">按钮的语法</h4>
+<p><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/button" title="button">button</a></code></code>标签有下面的语法要求:</p>
+<pre>&lt;button
+ id="identifier"
+ class="dialog"
+ label="OK"
+ image="images/image.jpg"
+ disabled="true"
+ accesskey="t"/&gt;
+</pre>
+<p>可用的属性如下,有一些是可选的:</p>
+<dl>
+ <dt>
+ <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> </dt>
+ <dd>
+ 你用来标识按钮的唯一标识。你会在所有的元素中看到此属性。你可以在样式表(style)或脚本(script)中通过它来引用按钮。因此,你几乎可以在所有的元素中添加这个属性。在这个教程中它不是一直都出现在元素中(It isn't always placed on elements in this tutorial for simplicity)。</dd>
+ <dt>
+ <code id="a-class"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/class">class</a></code> </dt>
+ <dd>
+ 按钮的样式表。在这里的用法和在HTML中是一样的。它是使用在显示按钮里面的样式。在这节中的<code>dialog</code>值就使用了。多数情况下,你不用在按钮上使用此属性。</dd>
+ <dt>
+ <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> </dt>
+ <dd>
+ 标签会显示在按钮上。例如,“确定”或者“取消”。如果没人设置这个参数,在按钮上就不会显示文字。</dd>
+ <dt>
+ <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code> </dt>
+ <dd>
+ 在按钮上显示指定路径的图片。如果没有给出此属性,则不会显示图片。你通常可以使用如下的样式表属性<code><a href="/cn/CSS/list-style-image" title="cn/CSS/list-style-image">list-style-image</a></code>来指定要显示的图片。</dd>
+ <dt>
+ <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> </dt>
+ <dd>
+ 如果这个属性被设置为<code>true</code>,按钮就会被禁用。这样通常按钮上的文字将会显示为灰色(grey)。如果按钮被禁用,按钮上的功能就不可以被执行。如果这个属性没有设置,按钮就是启用的。你可以用<a href="/cn/JavaScript" title="cn/JavaScript">JavaScript</a>来对按钮的可用状态进行控制。</dd>
+ <dt>
+ <code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code> </dt>
+ <dd>
+ 这个属性让你可以设置一个字母它的功能就像是一个快捷键。这个字母会被划上下划线并显示在标签里。当用户按ALT键(或者在每个平台中一个功能类似的键)的同时按下这里设置的键时,不论按钮在窗口的任何地方都能取得到焦点。</dd>
+</dl>
+<p>注释:按钮支持比上面列出的更多的属性。其他的属性可以参考 <a href="/cn/XUL_教程/More_Button_Features" title="cn/XUL_教程/More_Button_Features">discussed later</a>.</p>
+<h4 id=".E6.9B.B4.E5.A4.9A.E7.9A.84.E6.8C.89.E9.92.AE.E4.BE.8B.E5.AD.90" name=".E6.9B.B4.E5.A4.9A.E7.9A.84.E6.8C.89.E9.92.AE.E4.BE.8B.E5.AD.90">更多的按钮例子</h4>
+<p><span id="Example_1"><a id="Example_1"></a><strong>Example 1</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_buttons_1.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_buttons_1.xul">View</a></p>
+<div class="float-right">
+ <img alt="image:Buttons1.png" class="internal" src="/@api/deki/files/2609/=Buttons1.png"></div>
+<pre>&lt;button label="Normal"/&gt;
+&lt;button label="Disabled" disabled="true"/&gt;
+</pre>
+<p>上面的这些例子是在图片里面生成按钮。第一个按钮是一个标准的按钮。第二个按钮是禁用的,所以它整个显示为灰色。</p>
+<p>注:label属性不应该指定中文名称,否则解析xul时会报错。对于本地化,应该通过locale包来完成。</p>
+<p>我们将从为查找文件工具创建一个简单的查找按钮开始。下面这个例子的源码显示怎么去做这件事。</p>
+<pre>&lt;button id="find-button" label="Find"/&gt;
+</pre>
+<div class="note">
+ 注释:Firefox不允许你从网页上打开chrome,因此查看教程中的链接时会显示在一个标准的浏览器窗口中。至此,按钮会显示在窗口中间并自动伸展。你可以增加align="start"到window标签阻止其自动伸展。</div>
+<div class="highlight">
+ <h5 id=".E4.BE.8B.E5.AD.90_findfile.xul" name=".E4.BE.8B.E5.AD.90_findfile.xul">例子 findfile.xul</h5>
+ <p>请添加我们在前面章节创建的这些代码到findfile.xul文件。这些代码必须插入到 <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/window" title="window">window</a></code></code> 标签里面。代码是下面红色显示的部份:</p>
+ <pre class="eval">&lt;?xml version="1.0"?&gt;
+&lt;?xml-stylesheet href="<a class="external" rel="freelink">chrome://global/skin/</a>" type="text/css"?&gt;
+&lt;window
+ id="findfile-window"
+ title="Find Files"
+ orient="horizontal"
+ xmlns="<span class="nowiki">http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul</span>"&gt;
+
+ <span class="highlightred">&lt;button id="find-button" label="Find"/&gt;</span>
+ <span class="highlightred">&lt;button id="cancel-button" label="Cancel"/&gt;</span>
+
+&lt;/window&gt;
+</pre>
+ <div class="float-right">
+ <img alt="Image:buttons2.png" class="internal" src="/@api/deki/files/2652/=Buttons2.png"></div>
+ <p>你也可以注释掉“取消”按钮。窗口提供水平对齐地显示两个按钮。如果你在Mozilla中打开这个文件,你就可以获得和这里显示的图片一样的效果。</p>
+</div>
+<p> </p>
+<div class="note">
+ 注解:我们不能直接在XUL文件中写文本标签。我们可以使用 <a href="/Cn/XUL_教程/本地化" title="Cn/XUL_教程/本地化">实体替换这样文本可以很容易地进行翻译</a>.</div>
+<p>在下一节,我们将会学会怎么<a href="/cn/XUL_教程/增加标签和图像" title="cn/XUL_教程/增加标签和图像">向窗口中增加标签和图片</a>。</p>
+<p><small>查看更多参考 <a href="/cn/XUL_教程/更多的按钮特性" title="cn/XUL_教程/更多的按钮特性">更多按钮特性</a></small></p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Creating_a_Window" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Adding_Labels_and_Images">下一页 »</a></p>
+</div><p></p>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/adding_event_handlers/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/adding_event_handlers/index.html
new file mode 100644
index 0000000000..ef85e01bd1
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/adding_event_handlers/index.html
@@ -0,0 +1,161 @@
+---
+title: 添加事件处理函数
+slug: Mozilla/Tech/XUL/Tutorial/Adding_Event_Handlers
+translation_of: Archive/Mozilla/XUL/Tutorial/Adding_Event_Handlers
+---
+<p><span style="float: left;">« <a href="../../../../en/XUL_Tutorial/Scrolling_Menus" rel="internal">Previous</a></span> <span style="float: right;"><a href="../../../../en/XUL_Tutorial/More_Event_Handlers" rel="internal">Next</a> »</span></p>
+
+<p> </p>
+
+<p>  </p>
+
+<p> </p>
+
+<p>    到此为止我们的 findfile 看起来很棒。我们还没有搞定它,因为到此为止我们仅只是建立了一个简单的用户界面。接下来我们将给他添加脚本。</p>
+
+<div id="section_1">
+<h3 class="editable" id="使用脚本"><span>使用脚本</span></h3>
+
+<div class="editIcon"><a href="/../../../../en/XUL_Tutorial/Adding_Event_Handlers#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+
+<p>    为了使 find files 对话框工作,我们需要添加一些脚本来完成与用户的交互。我们想要为查找按钮、取消按钮以及各级菜单项添加脚本。我们会像在 <a href="../../../../en/HTML" rel="internal">HTML</a> 中一样使用 <a href="../../../../en/JavaScript" rel="internal">JavaScript</a> 来写一些函数。</p>
+
+<p>    你可以使用 <code><span class="lang lang-en"><a href="../../../../en/XUL/script" rel="internal">script</a> <span style="font-family: verdana,tahoma,sans-serif;">元素为</span></span></code> XUL 文件引入脚本。你可以直接在<code> &lt;script&gt;</code>  <code>&lt;/</code><code>script&gt;</code>标签之间嵌入脚本,但是最好是使用独立的文件来包含脚本,这样 XUL 窗口加载会快一些。 <code><span class="lang lang-en"><a href="../../../../en/XUL/Attribute/src" rel="internal">src</a> <span style="font-family: verdana,tahoma,sans-serif;">属性用于引入外部脚本文件。</span></span></code></p>
+
+<div class="highlight">
+<div id="section_2">
+<h5 class="editable" id="find_files_的例子"><span> find files 的例子</span></h5>
+
+<div class="editIcon"><a href="/../../../../en/XUL_Tutorial/Adding_Event_Handlers#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+
+<p>    让我们为 find file 对话框添加脚本。尽管脚本文件的文件名无关紧要,但通常的它采用与 XUL 文件相同的文件名并以 .js 作为后缀。我们建立一个 findfile.js 文件。把下面的一行加到 <code><span class="lang lang-en"><a href="../../../../en/XUL/window" rel="internal">window</a> 开标记之后,所有元素<strong>之前</strong>。</span></code></p>
+
+<pre class="eval"><span class="highlightred">&lt;script src="findfile.js"/&gt;</span>
+</pre>
+
+<p>    当我们知道改在脚本文件里添加什么之后,我们再建立这个文件。我们会在这个文件中定义一些函数,并且我们把这些函数称为事件处理函数。</p>
+</div>
+</div>
+
+<p>    你可以通过使用多个 <code>script</code> 标记向 XUL 文件添加多个脚本文件,此时你可以使用相对或绝对 URLs。比如下面的例子:</p>
+
+<pre class="eval">&lt;script src="findfile.js"/&gt;
+&lt;script src="<a class="external" rel="freelink">chrome://findfiles/content/help.js</a>"/&gt;
+&lt;script src="<a class="external" href="http://www.example.com/js/items.js" rel="freelink">http://www.example.com/js/items.js</a>"/&gt;
+</pre>
+
+<p>    本教程不涉及与事件处理无关的 JavaScript 的使用。因为这实在有太多的内容需要讲述,而且也可以从很多其他其他的资料获得所需的知识。</p>
+
+<div class="note">默认的 JavaScript 仅在页面上显示错误。为了显示在 chrome JavaScript 中的错误,有必要更改以下设置: <code>javascript.options.showInConsole = true</code><br>
+如果设置<code> javascript.options.strict = true</code> 那么任何不标准的,写法不良的,有语法上导致逻辑错误的,都将会写到日志中。</div>
+</div>
+
+<div id="section_3">
+<h3 class="editable" id="响应事件"><span>响应事件</span></h3>
+
+<div class="editIcon"><a href="/../../../../en/XUL_Tutorial/Adding_Event_Handlers#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+
+<p>    脚本需要响应一系列的事件包括用户触发的或是其他状态引起的。起码有三种不同的事件需要用不同的方法来处理。一种是用户按下鼠标键或是按下一个键盘按键。每一个 XUL 元素都有能力在不同的状态触发特定事件。一些事件仅由特定元素触发。</p>
+
+<p>    每一个事件都有一个名字,如 'mousemove' 是用户在一个 UI 元素上移动鼠标所触发的事件。XUL 与 <a class="external" href="http://www.w3.org/TR/DOM-Level-2-Events/" rel="external nofollow" title="http://www.w3.org/TR/DOM-Level-2-Events/">DOM Events</a>使用同样的机制来处理事件。当一个动作发生就会触发一个事件,比如用户移动鼠标,就会由一个相应类型的事件对象产生。 事件对象中包含一系列的属性包括:鼠标位置,哪个键被按下等。</p>
+
+<p>    事件按阶段被发送到 XUL。</p>
+
+<ul>
+ <li>路由阶段,事件先发送到窗口,然后是文件,沿着继承关系向下传递直到到达触发元素。</li>
+ <li>目标阶段,事件被发送的目标元素。</li>
+ <li>返回阶段,事件被逐级上传直到回到窗口。</li>
+</ul>
+
+<p>    可以在路由及返回阶段响应事件。一旦事件完成以上传播过程而为得以处理将使用默认的动作来处理该事件。</p>
+
+<p>    比如,当鼠标在一个包含在 box 中的按钮上移动时,产生一个 'mousemove' 事件,这个事件先被发送到窗口,紧接着是文件,然后是这个 box ,这样就完成了路由过程。然后事件被发送给按钮。最后,返回阶段,事件被发给 box、文件及窗口。返回阶段本质上是路由过程的逆过程。需要说明的是,有些事件没有返回阶段。</p>
+
+<p>    在事件传播的每一个阶段你都可以在任何元素上监听。由于事件会传递给所有祖先你可以在继承关系的更高层来添加监听器。当然,一个高层收到事件会通知它的全部子元素,而对于按钮的事件仅属于这个按钮。这一点对与你希望使用同样的代码控制一些元素是有用的。</p>
+
+<p>    大多数公共事件使用 'command' 事件。 当使用者启动一个元素 command 事件会被触发,例如按按钮,选择菜单项等。对与不同的触发元素 command 会自动的按照不同的方式进行处理,比如,无论用户是使用鼠标点击按钮还是通过快捷键都会触发 command 事件。</p>
+
+<p>    有两种办法来为一个元素添加事件监听器。其一,把脚本本身作为其属性;其二,使用元素的 <code>addEventListener</code> 方法。 前者只处理返回事件但写起来更方便。后者可以控制事件的任何阶段,并且对同一个元素、事件可以使用多个监听器。对大多数元素来说,更多的使用属性的方式。</p>
+</div>
+
+<div id="section_4">
+<h3 class="editable" id="事件监听器属性"><span>事件监听器属性</span></h3>
+
+<div class="editIcon"><a href="/../../../../en/XUL_Tutorial/Adding_Event_Handlers#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+
+<p>    使用属性形式,在你希望监听的元素上加一个属性,名字是待监听的事件名前加'on'。如,为了响应事件  'command' 属性名为 'oncommand'。属性值是处理此事件的一段脚本。通常代码短小,或者就是调用独立脚本文件中的函数。下面的例子响应按钮按下。</p>
+
+<p><span class="lang lang-en"><span id="Example_1"><strong>Example 1</strong></span> </span> : <span class="lang lang-en"><a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_events_1.xul.txt" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_events_1.xul.txt">Source</a> <a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_events_1.xul" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_events_1.xul">View</a> </span></p>
+
+<pre class="eval">&lt;button label="OK" oncommand="alert('Button was pressed!');"/&gt;
+</pre>
+
+<p>    由于 'command' 事件会返回,也可以把事件监听器添加到封装元素中。下面的例子监听器会响应全部两元素。</p>
+
+<p><span class="lang lang-en"><span id="Example_2"><strong>Example 2</strong></span> </span> : <span class="lang lang-en"><a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_events_2.xul.txt" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_events_2.xul.txt">Source</a> <a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_events_2.xul" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_events_2.xul">View</a> </span></p>
+
+<pre class="eval">&lt;vbox oncommand="alert(event.target.tagName);"&gt;
+ &lt;button label="OK"/&gt;
+ &lt;checkbox label="Show images"/&gt;
+&lt;/vbox&gt;
+</pre>
+
+<p>    在这个例子中,command 事件会有 button 或 checkbox 返回到设置了事件处理的 vbox 上。如果在按钮上在加一个监听器 (<code>oncommand</code> 属性) ,按钮上的代码会先调用,然后是 vbox 的。事件处理函数会传递一个隐含参数 'event',这参数可以获得事件的额外信息。一个常用的属性是 'target' ,它保存着事件是由谁产生的。这个例子里,显示事件产生者的标签名。target 很有用,因为你可以在一段代码里为一系列按钮作响应。</p>
+
+<p>    你可能注意到这里使用的语法与 HTML 中的一样。事实上, HTML 和 XUL 共用统计的事件机制。一个重要的不同是 'click' 事件 (或  <code>onclick</code> 属性) 在 HTML 中它仅用于响应按钮,而在 XUL 中 command 事件被用于替代它。XUL 有一个 click 事件,但是仅响应鼠标点击,不响应键盘。因此点击事件在XUL中应避免使用,除非你希望一个元素仅可以通过鼠标触发。补充一下,如果元素的 disable 属性为 true 时 command 事件不会被发送,而 click 事件则不然。</p>
+
+<div class="highlight">
+<div id="section_5">
+<h5 class="editable" id="find_files_的例子_2"><span>find files 的例子</span></h5>
+
+<div class="editIcon"><a href="/../../../../en/XUL_Tutorial/Adding_Event_Handlers#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+
+<p>     command 处理器可以用于响应查找和取消按钮,按查找按钮开始查找,当然由于我们没有实现这部分,我们现在还不能,这部分我们以后再完成,按取消按钮关闭窗口,下面的代码显示怎么做。并且我们也为关闭菜单也写了相同的代码。</p>
+
+<pre class="eval">&lt;menuitem label="Close" accesskey="c" <span class="highlightred">oncommand="window.close();"</span>/&gt;
+...
+
+&lt;button id="cancel-button" label="Cancel"
+ <span class="highlightred">oncommand="window.close();</span>"/&gt;
+</pre>
+
+<p>      这里加了两个处理器。<code>oncommand</code> 被加到关闭菜单项中了。通过使用这个处理器,用户可以使用鼠标点击菜单或使用键盘来选择此菜单来关闭窗口。<code>oncommand</code> 处理器也加到了取消按钮上。</p>
+</div>
+</div>
+</div>
+
+<h3 class="editable" id="DOM_事件监听器"><span>DOM 事件监听器</span></h3>
+
+<div class="editIcon"><a href="/../../../../en/XUL_Tutorial/Adding_Event_Handlers#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+
+<p>    为一个元素添加事件处理的另一种方法是使用元素的 addEventListener 方法,这允许你动态的监听事件或在路由阶段处理事件。语法如下。</p>
+
+<p><span class="lang lang-en"><span id="Example_3"><strong>Example 3</strong></span> </span> : <span class="lang lang-en"><a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_events_3.xul.txt" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_events_3.xul.txt">Source</a> <a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_events_3.xul" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_events_3.xul">View</a> </span></p>
+
+<pre>&lt;button id="okbutton" label="OK"/&gt;
+
+&lt;script&gt;
+function buttonPressed(event){
+ alert('Button was pressed!');
+}
+
+var button = document.getElementById("okbutton");
+button.addEventListener('command', buttonPressed, true);
+&lt;/script&gt;
+</pre>
+
+<p>     <code><a href="../../../../en/DOM/document.getElementById" rel="internal">getElementById()</a></code> 函数返回给定 id 的元素,这里返回这个按钮。<code><a href="../../../../en/DOM/element.addEventListener" rel="internal">addEventListener()</a></code> 函数新建一个路由阶段的事件监听器。第一个参数是待监听的事件名,第而个参数是事件发生时要调用的函数名,最后一个参数如是 <code>true</code> 表示这是一个路由阶段的监听器,设为 false 则监听返回阶段。作为事件处理函数的第二个参数需要带一个参数(这个事件对象),就像上面定义的 <code>buttonPressed</code> 函数一样。</p>
+
+<div class="highlight"><span class="lang lang-en"><span id="Find_files_example_so_far"><strong>Find files example so far</strong></span> </span> : <span class="lang lang-en"><a class="external" href="http://developer.mozilla.org/samples/xultu/examples//findfile/findfile-events.xul.txt" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples//findfile/findfile-events.xul.txt">Source</a> <a class="external" href="http://developer.mozilla.org/samples/xultu/examples//findfile/findfile-events.xul" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples//findfile/findfile-events.xul">View</a> </span></div>
+
+<p> </p>
+
+<p>    接下来,我们详细的看看 <a href="../../../../en/XUL_Tutorial/More_Event_Handlers" rel="internal">事件对象</a>(<a href="../../../../en/XUL_Tutorial/More_Event_Handlers" rel="internal">event object</a>)。</p>
+
+<p> </p>
+
+<div class="prevnext">
+<p><span style="float: left;">« <a href="../../../../en/XUL_Tutorial/Scrolling_Menus" rel="internal">Previous</a></span> <span style="float: right;"><a href="../../../../en/XUL_Tutorial/More_Event_Handlers" rel="internal">Next</a> »</span></p>
+</div>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/adding_html_elements/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/adding_html_elements/index.html
new file mode 100644
index 0000000000..6e1f8c38c6
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/adding_html_elements/index.html
@@ -0,0 +1,113 @@
+---
+title: XUL_教程/增加HTML元素
+slug: Mozilla/Tech/XUL/Tutorial/Adding_HTML_Elements
+tags:
+ - XUL_教程
+translation_of: Archive/Mozilla/XUL/Tutorial/Adding_HTML_Elements
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Progress_Meters" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Using_Spacers">下一页 »</a></p>
+</div><p></p>
+<p> </p>
+<h3 id=".E5.A2.9E.E5.8A.A0HTML.E5.85.83.E7.B4.A0.E5.88.B0.E7.AA.97.E5.8F.A3" name=".E5.A2.9E.E5.8A.A0HTML.E5.85.83.E7.B4.A0.E5.88.B0.E7.AA.97.E5.8F.A3">增加HTML元素到窗口</h3>
+<p>除了可以使用XUL的所有元素,你也可以直接将HTML元素添加到XUL文件的内部。现在你可以在XUL文件中使用任意的HTML元素,意思是说可以在窗口中布置JAVA小应用程序(applet)和表格。如果可以你应该避免在XUL文件中使用HTML元素。(这是有原因的,主要涉及<a href="/cn/XUL_教程/Box_Model_Details" title="cn/XUL_教程/Box_Model_Details">版面的控制</a>这将在后面进行描述)。然而,不管怎样这节将描述如何使用它们。记住XML是大小写敏感的,因此你必须用小写输入标签和属性。</p>
+<h4 id="XHTML.E5.91.BD.E5.90.8D.E7.A9.BA.E9.97.B4.28namespace.29" name="XHTML.E5.91.BD.E5.90.8D.E7.A9.BA.E9.97.B4.28namespace.29">XHTML命名空间(namespace)</h4>
+<p>为了在XUL文件中使用HTML元素,你必须声明你要用到的XHTML命令空间。这个方法是Mozilla从XUL中区分HTML标签的。 下面的属性应该加在XUL文件的<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/window" title="window">window</a></code></code> 标签中,或者放到HTML元素的最外面。</p>
+<pre class="eval"><span class="nowiki">xmlns:html="http://www.w3.org/1999/xhtml"</span>
+</pre>
+<p>这个HTML的声明很像我们用过的XUL声明。要正常显示必须正确地输入这句,否则它不能正常运行。注意:Mozilla不会去下载这个URL的内容,但它会在运行HTML时对它进行验证。</p>
+<p>这是一个可以加到文件查找窗口的例子:</p>
+<pre class="eval"> &lt;?xml version="1.0"?&gt;
+ &lt;?xml-stylesheet href="<a class="external" rel="freelink">chrome://global/skin/</a>" type="text/css"?&gt;
+ &lt;window
+ id="findfile-window"
+ title="Find Files"
+ orient="horizontal"
+ <span class="highlightred"><span class="nowiki">xmlns:html="http://www.w3.org/1999/xhtml"</span></span>
+ xmlns="<span class="nowiki">http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul</span>"&gt;
+</pre>
+<p>因此,你可以像平常一样使用HTML,下面列出需注意的守则:</p>
+<ul>
+ <li>你必须在每个标检的开始增加一个<code>html:</code>的前缀,像上面一样声明的HTML命名空间。</li>
+ <li>标签<em>必须用小写输入</em>.</li>
+ <li>"双引号" 必须完全把所有的属性值括起来。</li>
+ <li>在没有内容的XML标签的末端(&gt;)前一定要加上结束符(/),下面的例子很清楚地进行了示范。</li>
+</ul>
+<h4 id=".E4.BD.BF.E7.94.A8HTML.E5.85.83.E7.B4.A0" name=".E4.BD.BF.E7.94.A8HTML.E5.85.83.E7.B4.A0">使用HTML元素</h4>
+<p>你可以像<code>head</code> 和 <code>body</code>使用所有的HTML标签,不是真的有益。下面演示一些使用HTML元素的例子。</p>
+<pre>&lt;html:img src="banner.jpg"/&gt;
+
+&lt;html:input type="checkbox" value="true"/&gt;
+
+&lt;html:table&gt;
+ &lt;html:tr&gt;
+ &lt;html:td&gt;
+ A simple table
+ &lt;/html:td&gt;
+ &lt;/html:tr&gt;
+&lt;/html:table&gt;
+</pre>
+<p>这些示例将从banner.jpg创建一个图像,一个多选项和一个只有一个单元格的表。如果XUL的特性是可用的你应该总是使用它们并且你不应该在XUL中使用表格作为布局。(XUL有自己的布局元素可以用)。注意<code>html:</code>前缀需要添加到每个标签的前面。这是Mozilla为什么会知道它是一个HTML标签而不是一个XUL标签。如果你没有加上<code>html:</code>部份,浏览器就会认为元素是一个XUL元素并且它们不能被正常显示,因为 img, input, table, 等都不是有效的XUL标签。</p>
+<p>在XUL,你可以使用<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/description" title="description">description</a></code></code>或<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/label" title="label">label</a></code></code>元素添加文本标签。当你要用时应该使用这些元素。你也可以使用HTML的<code>label</code>元素添加文本标签的操作或者你可以像下面的例子一样简单地将文本放在不同的HTML元素之间(就像<code>p</code>或<code>div</code>)。</p>
+<p><span id="%E4%BE%8B1"><a id="%E4%BE%8B1"></a><strong>例1</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_htmlelem_1.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_htmlelem_1.xul">View</a></p>
+<pre>&lt;html:p&gt;
+ 搜索:
+ &lt;html:input id="find-text"/&gt;
+ &lt;button id="okbutton" label="确定"/&gt;
+&lt;/html:p&gt;
+</pre>
+<p>这段代码的目的是显示'搜索:',接着显示一个文本输入框元素和一个确定按钮。注意XUL按钮可以显示在HTML元素之间,在这里它可以正常使用。在HTML元素之间的纯文本仅仅用来显示通常用来显示文字(就像<code>p</code>标签)。放在外面的文本是不能被显示的,除非XUL元素允许将文本放在里面(例如:<code>description</code>元素)。下面的例子可以帮助你理解。</p>
+<h3 id="HTML.E5.85.83.E7.B4.A0.E7.9A.84.E5.AE.9E.E4.BE.8B" name="HTML.E5.85.83.E7.B4.A0.E7.9A.84.E5.AE.9E.E4.BE.8B">HTML元素的实例</h3>
+<p>下面是在窗口在添加HTML元素的一些例子。在每个例子的窗口边都能找到简单的说明信息。</p>
+<h4 id=".E5.B8.A6.E5.A4.9A.E9.80.89.E6.A1.86.E7.9A.84.E5.AF.B9.E8.AF.9D.E6.A1.86" name=".E5.B8.A6.E5.A4.9A.E9.80.89.E6.A1.86.E7.9A.84.E5.AF.B9.E8.AF.9D.E6.A1.86">带多选框的对话框</h4>
+<p><span id="%E4%BE%8B2"><a id="%E4%BE%8B2"></a><strong>例2</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_htmlelem_2.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_htmlelem_2.xul">View</a></p>
+<div class="float-right">
+ <img alt="Image:htmlelem-ex1.png" class="internal" src="/@api/deki/files/2661/=Htmlelem-ex1.png"></div>
+<pre>&lt;html:p&gt;
+ 点击下面方框会记住这个结果。
+ &lt;html:p&gt;
+ &lt;html:input id="rtd" type="checkbox"/&gt;
+ &lt;html:label for="rtd"&gt;记住这个结果&lt;/html:label&gt;
+ &lt;/html:p&gt;
+&lt;/html:p&gt;
+</pre>
+<p>在这个例子,一个 <code>p</code> 标签用来放置文本,另外一人用来放置分离的多行文本。</p>
+<h4 id=".E5.9C.A8HTML.E5.9D.97.E5.A4.96.E9.9D.A2.E7.9A.84.E6.96.87.E6.9C.AC" name=".E5.9C.A8HTML.E5.9D.97.E5.A4.96.E9.9D.A2.E7.9A.84.E6.96.87.E6.9C.AC">在HTML块外面的文本</h4>
+<p><span id="%E4%BE%8B3"><a id="%E4%BE%8B3"></a><strong>例3</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_htmlelem_3.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_htmlelem_3.xul">View</a></p>
+<div class="float-right">
+ <img alt="Image:htmlelem-ex2.png" class="internal" src="/@api/deki/files/2662/=Htmlelem-ex2.png"></div>
+<pre>&lt;html:div&gt;
+ 你想保存下面的文档吗?
+ &lt;html:hr/&gt;
+&lt;/html:div&gt;
+Expense Report 1
+What I Did Last Summer
+&lt;button id="yes" label="Yes"/&gt;
+&lt;button id="no" label="No"/&gt;
+</pre>
+<p>从图像上可以看到,在<code>div</code>标签里面的文本可以显示出来但其它的文本没有显示(Expense Report 1 和 What I Did Last Summer)。这是因为要显示的文本没有被HTML或XUL元素围绕起来。要显示这些文本,你必须将它放在<code>div</code>标签里面,或者用<code>description</code> 标签将它围起来。</p>
+<h4 id=".E6.97.A0.E6.95.88.E7.9A.84HTML.E5.85.83.E7.B4.A0" name=".E6.97.A0.E6.95.88.E7.9A.84HTML.E5.85.83.E7.B4.A0">无效的HTML元素</h4>
+<pre>&lt;html:po&gt;Case 1&lt;/html:po&gt;
+&lt;div&gt;Case 2&lt;/div&gt;
+&lt;html:description value="Case 3"/&gt;
+</pre>
+<p>上面这三个样例不能被显示,每个都有一个不同的原因。</p>
+<dl>
+ <dt>
+ 样例1 </dt>
+ <dd>
+ <code>po</code>不是一个正确的HTML标签,所以Mozilla不知怎么去处理它。</dd>
+ <dt>
+ 样例2 </dt>
+ <dd>
+ <code>div</code>是有效的,但是只能用在HTML中。如果要在这里使用,你必须为它添加html:限定符。</dd>
+ <dt>
+ 样例3 </dt>
+ <dd>
+ <code>description</code>元素仅仅在XUL中是有效的,而不是在HTML中。它不可以有html:限定符。</dd>
+</dl>
+<p>接下来,我们将要学习如何用 <a href="/cn/XUL_教程/使用定位格" title="cn/XUL_教程/使用定位格">在元素间添加定位格</a>.</p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Progress_Meters" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Using_Spacers">下一页 »</a></p>
+</div><p></p>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/adding_labels_and_images/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/adding_labels_and_images/index.html
new file mode 100644
index 0000000000..e3850373fc
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/adding_labels_and_images/index.html
@@ -0,0 +1,40 @@
+---
+title: XUL_教程/增加标签和图像
+slug: Mozilla/Tech/XUL/Tutorial/Adding_Labels_and_Images
+translation_of: Archive/Mozilla/XUL/Tutorial/Adding_Labels_and_Images
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Adding_Buttons" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Input_Controls">下一页 »</a></p>
+</div> <p></p>
+<p> </p>
+<p>这一章描述了向窗口中加入标签和图像的方法。另外,我们将看到如何将一些元素包含到一个组中。</p>
+<h3 id=".E6.96.87.E6.9C.AC.E5.85.83.E7.B4.A0" name=".E6.96.87.E6.9C.AC.E5.85.83.E7.B4.A0">文本元素</h3>
+<p>在不使用标记的情况下,你不能直接向XUL文件中插入文本,它也不会做任何显示。为了达到这个目的你使用如下两个XUL元素来完成。</p>
+<h4 id=".E6.A0.87.E7.AD.BE.E5.85.83.E7.B4.A0" name=".E6.A0.87.E7.AD.BE.E5.85.83.E7.B4.A0">标签元素</h4>
+<p>将文本加入到将文本加入到窗体中的一个最基本的方法就是使用<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/label" title="label">label</a></code>元素。请看下面的例子:</p>
+<p><span id="Example_1"><a id="Example_1"></a><strong>Example 1</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_textimage_1.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_textimage_1.xul">View</a></p>
+<pre>&lt;label value="This is some text"/&gt;
+</pre>
+<p><code><code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code></code>属性被用于指定要显示的文本。这样设置的文本在显示的时候不会换行,所以适合于较短的文本。这种语法适用于多数情况中使用的标签。</p>
+<p>如果文本需要换行,你可以如下例所示将文本放在开启和关闭元素之间:</p>
+<p><span id="Example_2"><a id="Example_2"></a><strong>Example 2</strong></span> :</p>
+<pre>&lt;label&gt;This is some longer text that will wrap onto several lines.&lt;/label&gt;
+</pre>
+<p>就像HTML,换行和多余的空格将被压缩为一个空格。 接下来, 我们可以在 <a href="/cn/XUL_Tutorial/Element_Positioning" title="cn/XUL_Tutorial/Element_Positioning">找到怎么去控制元素的宽度</a> 这样我们就可以很容易地控制换行。</p>
+<h5 id=".E6.93.8D.E4.BD.9C.28Control.29.E5.B1.9E.E6.80.A7" name=".E6.93.8D.E4.BD.9C.28Control.29.E5.B1.9E.E6.80.A7">操作(Control)属性</h5>
+<p>你可以使用 <code><code id="a-control"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/control">control</a></code></code> 属性去设置关联的标签。当用户在标签上进行点击操作时,已关联的控件就会被触发。<a href="/cn/Accessibility" title="cn/Accessibility">accessibility</a>这种关联的辅助操作很重要,这样屏幕阅读器就可以对选中的文本进行语音提示。设置<code>control</code>属性的值会触发与这个值对应的<code><code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code></code>的元素。 <span id="Example_3"><a id="Example_3"></a><strong>Example 3</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_textimage_3.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_textimage_3.xul">View</a></p>
+<pre>&lt;label value="Click here:" control="open-button"/&gt;
+&lt;button id="open-button" label="Open"/&gt;
+</pre>
+<p>在上面这个例子中,在标签上点击会使得按钮被触发。</p>
+<h4 id=".E6.8F.8F.E8.BF.B0.28Descriptive.29.E5.85.83.E7.B4.A0" name=".E6.8F.8F.E8.BF.B0.28Descriptive.29.E5.85.83.E7.B4.A0">描述(Descriptive)元素</h4>
+<p>在没有一些特定的关联操作的文本时你可以使用 <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/description" title="description">description</a></code> 标签。 这个元素使用于在对话框的上面或实例的一组控制的文本提示信息. 与 <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/label" title="label">label</a></code> 元素一样, 你既可以在 <code>value</code> 属性中指定单行的文本也可以在开合标签之间填充一大块的文本。在描述元素的大多数属性和文本内容的语法是与标签元素(label)是一样的。</p>
+<p><span id="%E4%BE%8B4"><a id="%E4%BE%8B4"></a><strong>例4</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_textimage_2.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_textimage_2.xul">View</a></p>
+<pre>&lt;description&gt;
+ This longer section of text is displayed.
+&lt;/description&gt;
+</pre>
+<p>从内部看, 标签元素(<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/label" title="label">label</a></code></code>)和描述元素( <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/description" title="description">description</a></code></code>)是相同的。标签元素(<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/label" title="label">label</a></code></code>)用于有操作的标签,就像一个文本框(text field)。 操作属性仅仅为标签提供支持。 描述元素(<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/description" title="description">description</a></code></code>)用于其他描述性的情况,如对话框(<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/dialog" title="dialog">dialog</a></code></code>)上面的提示信息文本。</p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Adding_Buttons" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Input_Controls">下一页 »</a></p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/adding_more_elements/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/adding_more_elements/index.html
new file mode 100644
index 0000000000..9af4cc954f
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/adding_more_elements/index.html
@@ -0,0 +1,115 @@
+---
+title: 增加更多的元素
+slug: Mozilla/Tech/XUL/Tutorial/Adding_More_Elements
+translation_of: Archive/Mozilla/XUL/Tutorial/Adding_More_Elements
+---
+<div class="pageTitle">
+ <h1 id="添加元素">添加元素</h1>
+</div>
+<div id="page-top">
+ <div class="pageText" id="pageText">
+ <p> </p>
+ <p> </p>
+ <div class="prevnext">
+ <p><span style="float: left;">« <a href="../../../../en/XUL_Tutorial/Groupboxes" rel="internal">Previous</a></span> <span style="float: right;"><a href="../../../../en/XUL_Tutorial/Stacks_and_Decks" rel="internal">Next</a> »</span></p>
+ </div>
+ <p>  </p>
+ <p> </p>
+ <p>    我们继续通过为findfile对话框添加一些box来讨论box。</p>
+ <div class="highlight">
+ <div id="section_1">
+ <h3 class="editable" id="为_find_files_的例子添加元素"><span>为 find files 的例子添加元素</span></h3>
+ <div class="editIcon">
+ <a href="../../../../en/XUL_Tutorial/Adding_More_Elements#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    现在我们将为findfile对话框添加一些元素,首先添加选择其他检索信息的能力(如尺寸和数据):</p>
+ <pre class="eval">&lt;hbox&gt;
+ <span class="highlightred">&lt;menulist id="searchtype"&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem label="Name"/&gt;
+ &lt;menuitem label="Size"/&gt;
+ &lt;menuitem label="Date Modified"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menulist&gt;
+ &lt;spacer style="width: 10px;"/&gt;
+ &lt;menulist id="searchmode"&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem label="Is"/&gt;
+ &lt;menuitem label="Is Not"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menulist&gt;
+ &lt;spacer style="width: 10px;"/&gt;</span>
+ &lt;textbox id="find-text" flex="1" style="min-width: 15em;"/&gt;
+&lt;/hbox&gt;
+</pre>
+ <div class="float-right">
+ <img alt="Image:boxfinal1.png" class="internal" src="../../../../@api/deki/files/567/=Boxfinal1.png"></div>
+ <p>    加了两个 <a href="../../../../en/XUL_Tutorial/List_Controls#_Drop-down_Lists" rel="internal">drop down boxes</a> 。一个 <a href="../../../../en/XUL_Tutorial/Using_Spacers" rel="internal">spacer</a> 加进来用于分割各元素,每个空白有10像素,你会看到当窗口尺寸改变时,文本框会改变尺寸而其他元素不会 ,也会看到标签被移除了。</p>
+ <p>    如果垂直的改变窗口尺寸,元素不会改变尺寸,这是因为他们在水平的box中。 Find 和 Cancel 按钮总在春光看的底部是合适的。这很容易通过在两个水平box间添加空白实现。</p>
+ <pre class="eval"><span class="highlightred">&lt;spacer style="height: 10px"/&gt;</span>
+&lt;hbox&gt;
+ &lt;menulist id="searchtype"&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem label="Name"/&gt;
+ &lt;menuitem label="Size"/&gt;
+ &lt;menuitem label="Date Modified"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menulist&gt;
+ &lt;spacer style="width: 10px;"/&gt;
+ &lt;menulist id="searchmode"&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem label="Is"/&gt;
+ &lt;menuitem label="Is Not"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menulist&gt;
+ &lt;spacer style="width: 10px;"/&gt;
+ &lt;textbox id="find-text" flex="1" style="min-width: 15em;"/&gt;
+&lt;/hbox&gt;
+
+<span class="highlightred">&lt;spacer style="height: 10px" flex="1"/&gt;</span>
+
+&lt;hbox&gt;
+</pre>
+ <p>    现在当窗口改变尺寸,这两个按钮会移动以确保总在窗口的底部。 <span class="lang lang-en"><a href="../../../../en/XUL/spacer" rel="internal">spacer</a> 被添加在标题和检索条件之间。</span></p>
+ <p>    在检索条件上画上边框可能会更好看。可以使用 CSS <code>border</code> 属性或使用 <code><span class="lang lang-en"><a href="../../../../en/XUL/groupbox" rel="internal">groupbox</a> <span style="font-family: Verdana,Tahoma,sans-serif;">元素</span></span></code>,第一种方法需要设置box的样式。我们使用后一种方法。  <a href="../../../../en/XUL_Tutorial/Groupboxes" rel="internal">groupbox</a> 可以画出适合当前主题的漂亮的边框。</p>
+ <p>    把box改为 <code>groupbox</code>:</p>
+ <pre class="eval"><span class="highlightred">&lt;groupbox orient="horizontal"&gt;</span>
+ <span class="highlightred">&lt;caption label="Search Criteria"/&gt;</span>
+ &lt;menulist id="searchtype"&gt;
+ .
+ .
+ .
+ &lt;spacer style="width: 10px;"/&gt;
+ &lt;textbox id="find-text" flex="1" style="min-width: 15em;"/&gt;
+<span class="highlightred">&lt;/groupbox&gt;</span>
+</pre>
+ <div class="float-right">
+ <img alt="Image:boxfinal2.png" class="internal" src="../../../../@api/deki/files/568/=Boxfinal2.png"></div>
+ <p>   当然还有其他的美化方案,比如让组框延伸到窗口底边。也可以修饰一下边界让他们看起来更漂亮。</p>
+ <p>    我们会在这个教程中看到更多关于box的例子及其功能因为我们还有在findfile对话框中添加新的元素。</p>
+ <p>Find files example so far <span class="lang lang-en"><a class="external" href="http://developer.mozilla.org/samples/xultu/examples//findfile/findfile-boxfinal.xul.txt" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples//findfile/findfile-boxfinal.xul.txt">Source</a> <a class="external" href="http://developer.mozilla.org/samples/xultu/examples//findfile/findfile-boxfinal.xul" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples//findfile/findfile-boxfinal.xul">View</a> </span></p>
+ </div>
+ </div>
+ <p><br>
+      下一章,<a href="../../../../en/XUL_Tutorial/Stacks_and_Decks" rel="internal">create stacks</a>.</p>
+ <p> </p>
+ <div class="prevnext">
+ <p><span style="float: left;">« <a href="../../../../en/XUL_Tutorial/Groupboxes" rel="internal">Previous</a></span> <span style="float: right;"><a href="../../../../en/XUL_Tutorial/Stacks_and_Decks" rel="internal">Next</a> »</span></p>
+ </div>
+ <p>  </p>
+ <p> </p>
+ </div>
+</div>
+<div class="printfooter" id="printfooter">
+ <hr>
+ <p>Retrieved from "<a href="../../../../En/XUL_Tutorial/Adding_More_Elements">https://developer.mozilla.org/En/XUL_Tutorial/Adding_More_Elements</a>"</p>
+</div>
+<div class="collapsed" id="languages">
+ <h5 id="Languages">Languages</h5>
+ <ul style="display: none;">
+ <li><a href="../../../../es/Tutorial_de_XUL/A%c3%b1adiendo_m%c3%a1s_elementos" rel="internal">Español</a></li>
+ <li><a href="../../../../fr/Tutoriel_XUL/Ajouter_plus_d%27%c3%a9l%c3%a9ments" rel="internal">Français</a></li>
+ <li><a href="../../../../pl/Kurs_XUL/Dodawanie_innych_element%c3%b3w" rel="internal">Polski</a></li>
+ <li><a href="../../../../ja/XUL_Tutorial/Adding_More_Elements" rel="internal">日本語</a></li>
+ </ul>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/adding_style_sheets/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/adding_style_sheets/index.html
new file mode 100644
index 0000000000..630627f941
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/adding_style_sheets/index.html
@@ -0,0 +1,10 @@
+---
+title: 添加样式表
+slug: Mozilla/Tech/XUL/Tutorial/Adding_Style_Sheets
+translation_of: Archive/Mozilla/XUL/Tutorial/Adding_Style_Sheets
+---
+<pre id="line1"><span class="pi">&lt;?xml version="1.0"?&gt;</span>
+<span class="pi">&lt;?xml-stylesheet href="css/ued.css" type="text/css"?&gt;</span>
+
+</pre>
+<p>用xml-stylesheet引入CSS文件!可以是本地或来自网络的文件。使用http或chrome协议均可。</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/anonymous_content/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/anonymous_content/index.html
new file mode 100644
index 0000000000..6362be89f6
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/anonymous_content/index.html
@@ -0,0 +1,166 @@
+---
+title: XUL_教程/匿名内容
+slug: Mozilla/Tech/XUL/Tutorial/Anonymous_Content
+translation_of: Archive/Mozilla/XUL/Tutorial/Anonymous_Content
+---
+<p> </p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Introduction_to_XBL" style="float: left;">« 上一页</a><a href="/zh-CN/docs/&lt;a_href=">Anonymous_Content</a>"&gt;下一页 »</p>
+</div><p></p>
+<p>在这一节,我们将讲解用XBL创建content。</p>
+<h3 id="XBL_Content" name="XBL_Content">XBL Content</h3>
+<p>XBL被用来自动在另一个元素中添加一组元素。当内部元素用XBL描述时,XUL文件只需要指定外部元素。对于创建由其它控件构成的单独的控件来说这是很有用的,但只被认为是单独的控件。这里讲解了向由外部元素指定的内部元素添加属性的机理。</p>
+<h4 id="Declaring_Scrollbar_Example" name="Declaring_Scrollbar_Example">Declaring Scrollbar Example</h4>
+<p>以下的例子指出了滚动条是怎么声明的(从实例简化1bit)</p>
+<pre>&lt;bindings xmlns="http://www.mozilla.org/xbl"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;
+ &lt;binding id="scrollbarBinding"&gt;
+ &lt;content&gt;
+ &lt;xul:scrollbarbutton type="decrement"/&gt;
+ &lt;xul:slider flex="1"&gt;
+ &lt;xul:thumb/&gt;
+ &lt;/xul:slider&gt;
+ &lt;xul:scrollbarbutton type="increment"/&gt;
+ &lt;/content&gt;
+ &lt;/binding&gt;
+&lt;/bindings&gt;
+</pre>
+<p>这个文件包含一个用binding元素声明的单独的binding。ID属性应该设置为binding的标识符。这会在css文件中设置-moz-binding属性时用到。</p>
+<p>content标签被用来声明将被增进滚动条的anonymous content。content标签里的所有元素将被添加进被绑定界面元素内部。这种 binding将被绑定到滚动条,虽然没必要这样。将CSS -moz-binding 属性的设置为binding的URI的任何元素都将使用它。</p>
+<p>使用上述 binding会导致下面的XUL的行会如下扩展,假设滚动条与上述的XBL相关联:</p>
+<pre class="eval">&lt;scrollbar/&gt;
+
+<strong>expands to:</strong>
+
+&lt;scrollbar&gt;
+ &lt;xul:scrollbarbutton type="decrement"/&gt;
+ &lt;xul:slider flex="1"&gt;
+ &lt;xul:thumb/&gt;
+ &lt;/xul:slider&gt;
+ &lt;xul:scrollbarbutton type="increment"/&gt;
+&lt;/scrollbar&gt;
+</pre>
+<p>含有content标签的元素被无记录的添加到滚动条。虽然无记录内容被显示在屏幕上,但在正常方式下,不能通过脚本得到它。对于XUL,就像只有一个元素,尽管它实际上由大量元素构成。</p>
+<p>检查 Mozilla窗口中的滚动条,就会发现它由一个arrow按钮、一个slider、内部thumb和一个末尾的second arrow 按钮组成。它们都是XBL上面出现过的元素。这些元素将依次绑定在运用基础XUL元素的其它bindings上。请注意 content元素需要XUL姓名空间(他们出现在XUL之前:),因为他们是XUL元素,而且在XBL中无效。这个命名空间声明在bindings标签内。如果您不想使用XUL元素的命名空间, Mozilla将假定元素都是XBL,不理解这里,您的元素可能不会正常工作。</p>
+<h4 id="Filename_Input_Field_Example" name="Filename_Input_Field_Example">Filename Input Field Example</h4>
+<p>另一个例子是关于输入一个文件名的域:</p>
+<pre>&lt;binding id="fileentry"&gt;
+ &lt;content&gt;
+ &lt;textbox/&gt;
+ &lt;button label="Browse..."/&gt;
+ &lt;/content&gt;
+&lt;/binding&gt;
+</pre>
+<p>连接这个元素的binding将会导致输入浏览按钮之后的文本时它包含一个域。这个内部内容被匿名的创建了,而且用DOM不能查看到。</p>
+<h3 id="Override_the_Bound_Element" name="Override_the_Bound_Element">Override the Bound Element</h3>
+<p>Anonymous content被匿名的创建在 binding连接到一个元素的任何地方。如果您在XUL里放置子元素,他们将覆盖由binding提供的元素。例如XUL段,假设它早期与滚动条XBL绑定:(如果在xul文件中,给被绑定界面元素添加子元素,那么会覆盖掉binding中的元素。例如下面的xul片断,假设它被绑定到了前面的scrollbar的binding上)</p>
+<pre>&lt;scrollbar/&gt;
+
+&lt;scrollbar&gt;
+ &lt;button label="Overridden"/&gt;
+&lt;/scrollbar&gt;
+</pre>
+<p>第一个滚动条,因为它没有自己的内容,它将从在XBL文件里声明的binding来生成它的内容。第二个滚动条有它自己的内容,因此它将不会运用XBL内容,这产生了不完全是滚动条的产品。请注意比如滚动条这样的内建元素,从toolkit包的bindings目录得到它们的XBL。</p>
+<p>这只应用于在content标签内定义的元素。不论content是否从XBL而来或不论XUL是否提供自己的content,XBL的属性、方法和其它方面仍然可用。</p>
+<h3 id="Using_the_Children_Element" name="Using_the_Children_Element">Using the Children Element</h3>
+<p>当您想将XBL的内容和由XUL文件提供的内容一起都显示出来,可能需要重复几次。您能运用children元素来实现。在XUL中添加的子元素被添加来替代children元素。当创建自定义菜单控件时,这是很容易操作的。例如,一个简单的可编辑的menulist元素,可能如下创建:</p>
+<pre class="eval"><strong>XUL:</strong>
+
+&lt;menu class="dropbox"&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem label="1000"/&gt;
+ &lt;menuitem label="2000"/&gt;
+ &lt;/menupopup&gt;
+&lt;/menu&gt;
+
+<strong>CSS:</strong>
+
+menu.dropbox {
+ -moz-binding: url('<a class="external" rel="freelink">chrome://example/skin/example.xml#dropbox'</a>);
+}
+
+<strong>XBL:</strong>
+
+&lt;binding id="dropbox"&gt;
+ &lt;content&gt;
+ &lt;children/&gt;
+ &lt;xul:textbox flex="1"/&gt;
+ &lt;xul:button src="<a class="external" rel="freelink">chrome://global/skin/images/dropbox.jpg</a>"/&gt;
+ &lt;/content&gt;
+&lt;/binding&gt;
+</pre>
+<p>这个例子用旁边的按钮创建了一个输入域,menupopup将添加到由children元素指定位置。请注意对DOM结构来说,这些内容将与在XUL文件中显示的一样,因此menupopup将成为menu的一个子元素。对于开发者来说xbl的内容是看不到的,所以也没必要知道它的位置。</p>
+<p>结果内容应该是:</p>
+<pre>&lt;menu class="dropbox"&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem label="1000"/&gt;
+ &lt;menuitem label="2000"/&gt;
+ &lt;/menupopup&gt;
+ &lt;textbox flex="1"/&gt;
+ &lt;button src="chrome://global/skin/images/dropbox.jpg"/&gt;
+&lt;/menu&gt;
+</pre>
+<h4 id="includes_Attribute" name="includes_Attribute"><code>includes</code> Attribute</h4>
+<p>某些情况下,您可能希望只包括特定类型的内容。或者您只希望在不同的位置放置不同类型的内容。includes属性能够用来使只有某些元素才能在children的内容里出现。它的值应该设定到一个单独的标签名。或者到一个由“|”分隔的标签列表</p>
+<pre>&lt;children includes="button"/&gt;
+</pre>
+<p>所有的button将会被添加到被绑定元素的children所指明的位置。其它元素将不会与这个标签匹配。您能够放置多个children 元素到一个binding中,来在不同的地方放置不同类型的内容。如果XUL中一个元素没有匹配任何children元素,那个元素(和其他任何不匹配的元素)将会被用来替代这个绑定的内容。</p>
+<p>这里有另一个例子。让我们来介绍一下创建一个控件,并用两边的zoom in 和zoom out 按钮显示图象的方法。这将用一个box来创建,它包含图象和两个按钮。因为每个用法不同,这个图象元素得放置在XBL外部。</p>
+<pre class="eval"><strong>XUL:</strong>
+
+&lt;box class="zoombox"&gt;
+ &lt;image src="images/happy.jpg"/&gt;
+ &lt;image src="images/angry.jpg"/&gt;
+&lt;/box&gt;
+
+<strong>XBL:</strong>
+
+&lt;binding id="zoombox"&gt;
+ &lt;content&gt;
+ &lt;xul:box flex="1"&gt;
+ &lt;xul:button label="Zoom In"/&gt;
+ &lt;xul:box flex="1" style="border: 1px solid black"&gt;
+ &lt;children includes="image"/&gt;
+ &lt;/xul:box&gt;
+ &lt;xul:button label="Zoom Out"/&gt;
+ &lt;/xul:box&gt;
+ &lt;/content&gt;
+&lt;/binding&gt;
+</pre>
+<p>XUL文件中详述的子元素将放置在children标签位置。有两幅图象,因此两个都将被添加到彼此的旁边。显示结果等价如下:</p>
+<pre>&lt;binding id="zoombox"&gt;
+ &lt;content&gt;
+ &lt;xul:box flex="1"&gt;
+ &lt;xul:button label="Zoom In"/&gt;
+ &lt;xul:box flex="1" style="border: 1px solid black"&gt;
+ &lt;xul:image src="images/happy.jpg"/&gt;
+ &lt;xul:image src="images/angry.jpg"/&gt;
+ &lt;/xul:box&gt;
+ &lt;xul:button label="Zoom Out"/&gt;
+ &lt;/xul:box&gt;
+ &lt;/content&gt;
+&lt;/binding&gt;
+</pre>
+<p>从 DOM的观点来看,子元素仍然在初始的存储单元。这就是说,外部的XUL box有两个子元素,它们是这两幅图像。里边带边框的box有一个子元素,就是children 标签。当使用带XBL的DOM时,这是一个重要的区别。这也可以应用于CSS选择器规则。</p>
+<h4 id="Multiple_Children_Elements" name="Multiple_Children_Elements">多个子元素</h4>
+<p>您也能够使用多个children元素而且可以把某些元素放置在一个地方,其它元素放置在其它地方,通过添加一个includes属性和将它设置成标签的垂直的bar-separated列表,您能够使得只有在那个列表里的元素被放置在那个地方。例如,下面的XBL将导致文本标签和按钮出现在与其他元素不同的地方。</p>
+<p><a href="https://developer.mozilla.org/samples/xultu/examples/ex_xblcontent_1.xml.txt">Source</a></p>
+<pre>&lt;binding id="navbox"&gt;
+ &lt;content&gt;
+ &lt;xul:vbox&gt;
+ &lt;xul:label value="Labels and Buttons"/&gt;
+ &lt;children includes="label|button"/&gt;
+ &lt;/xul:vbox&gt;
+ &lt;xul:vbox&gt;
+ &lt;xul:label value="Other Elements"/&gt;
+ &lt;children/&gt;
+ &lt;/xul:vbox&gt;
+ &lt;/content&gt;
+&lt;/binding&gt;
+</pre>
+<p>第一个children元素只含有标签和按钮元素,正如它的includes属性指示的一样。第二个children元素因为它没有includes属性,它将包含所有的剩余的元素。</p>
+<p>See also <a href="/en/XBL/XBL_1.0_Reference/Anonymous_Content" title="en/XBL/XBL_1.0_Reference/Anonymous_Content">Anonymous Content</a> section of the XBL reference.</p>
+<p>(Next)在下一节,我们将研究属性如何被继承到 anonymous  content中.</p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/Introduction_to_XBL" style="float: left;">« 上一页</a><a href="/zh-CN/docs/&lt;a_href=">Anonymous_Content</a>"&gt;下一页 »</p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/box_model_details/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/box_model_details/index.html
new file mode 100644
index 0000000000..7b647957ba
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/box_model_details/index.html
@@ -0,0 +1,6 @@
+---
+title: 分组细节
+slug: Mozilla/Tech/XUL/Tutorial/Box_Model_Details
+translation_of: Archive/Mozilla/XUL/Tutorial/Box_Model_Details
+---
+<p>This page has no content. Enrich MDC by contributing.</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/content_panels/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/content_panels/index.html
new file mode 100644
index 0000000000..b2909f9a05
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/content_panels/index.html
@@ -0,0 +1,63 @@
+---
+title: 内容面板
+slug: Mozilla/Tech/XUL/Tutorial/Content_Panels
+translation_of: Archive/Mozilla/XUL/Tutorial/Content_Panels
+---
+<p>这一节我们来看看如何向HTML页面或者其他XUL文件中添加面板。</p>
+<h3 id="添加子面板">添加子面板</h3>
+<p>你可能经常想要使用不同页面的文件中的一部分。有时候你或许想将一个窗口中的一部分进行改变。一个很好的例子是一个一步接一步的向导,可以通过很多页面、询问一系列问题来指导你。每当用户点击下一步按钮的时候,向导就会显示下一个画面。</p>
+<p>你可以通过为每个不同的画面打开一个新的窗口来创建向导。但这样有三个问题。首先,每个窗口会出现在不同的位置。第二,后退和下一步按钮都是一样的,如果这是内容区域变化将会更好。第三,当在不同的窗口中运行的时候使用脚本会非常困难。</p>
+<p>注意,XUL有一个wizard元素可以用来创建向导接口。这将会在后面的章节中进行描述。</p>
+<p>另一种方法是使用iframe元素。这与HTML中有相同的名字。它可以在一个窗口中创建独立的文档。其优点是可以在任何需要内容的地方加载不同的文件。将文档的URL设置这个框架的src属性。这个URL可以指向任意类型的文件,尽管通常是指向一个HTML文件或者其他XUL文件。你可以使用脚本来控制iframe中的内容而不需要影响主窗口。</p>
+<p>在mozilla浏览器中,网页显示的区域就是用iframe创建的。当用户输入一个URL或者点击一个文档的链接的时候,这个frame的资源就变化了。</p>
+<h4 id="Iframe例子">Iframe例子</h4>
+<p>例子1:</p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;toolbox&gt;</p>
+ <p>  &lt;toolbar id="nav-toolbar"&gt;</p>
+ <p>    &lt;toolbarbutton label="Back"/&gt;</p>
+ <p>    &lt;toolbarbutton label="Forward"/&gt;</p>
+ <p>    &lt;textbox id="urlfield"/&gt;</p>
+ <p>  &lt;/toolbar&gt;</p>
+ <p>&lt;/toolbox&gt;</p>
+ <p> </p>
+ <p>&lt;iframe id="content-body" src="<a class="external" href="http://www.mozilla.org/index.html" rel="freelink">http://www.mozilla.org/index.html</a>" flex="1"/&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>这个例子为浏览器创建了一个非常简单的接口。创建了一个格子来容纳两个元素,一个是工具栏一个是iframe。一个后退按钮,一个前进按钮,以及一个用来输入URL的输入区。在iframe里面将会出现一个网页。这里会默认的出现index.html文件。</p>
+<p>这个例子功能并不完全。下面我们将会添加一个脚本在需要的时候来改变src属性,例如当用户按回车键的时候。</p>
+<h3 id="browser"> browser</h3>
+<p>还有一种内容面板,使用browser标签。如果你想创建一个像浏览器一样显示内容的框架就可以使用这个元素。事实上iframe也可以完成这样的功能,但是browser又很多附加特性。例如browser可以保持历史页面用来进行前进和后退。Browser还可以加载带有参照页和其他标志的页面。需要的时候,你可以使用browser标签来常见一个像浏览器一样的接口,但是如果只需要一个简单的面板的话可以使用iframe来实现。</p>
+<p>一个类似的元素tabbrowser,可以提供browser的全部功能而且还提供一个tab标签来在多个页面中切换。这是用在mozilla浏览器中的标签页浏览的小工具。元素tabbrowser事实上提供了一个含有一系列browser的tabbox元素。两种类型的browser都提供了相同的页面显示控制方式。</p>
+<h4 id="Browser实例">Browser实例</h4>
+<p>例子2:</p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;browser src="<a class="external" href="http://www.mozilla.org" rel="freelink">http://www.mozilla.org</a>" flex="1"/&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>与iframe一样,你可以使用src属性来指定browser的URL。对tabbrowser,你不可以设置直接像这样设置URL,因为他不会仅仅显示一个URL,相反的,你必须使用脚本调用loadURL函数来实现。</p>
+<p>有三种类型的browser,基于你想要显示的内容的内部机制。可以使用type属性来指定其类型。</p>
+<p>第一种类型如果不指定的话是默认的类型。这种情况,加载内容的内部browser就是与应用程序相同的,而且可以在外部窗口中访问。这意味着当一个脚本在browser内部加载文件的时候会获取最顶层的窗口。,会获得XUL窗口中的最外部的窗口。</p>
+<p>这可能对于一个应用程序的子XUL面板比较合适,但是当你想要用browser来加载网页的时候,就不是你想要的了。相反的,你可能想现限制网页仅仅获取网页的内容,你可能注意到mozilla浏览器窗口的工具条和状态条有一个XUL内容以及更高级的tabbrowser组成了主要的区域。这个内部的区域显示了一个网页,但是网页无法访问其周围的XUL。这是因为使用的是第二种类型的browser,指定type属性为content。这可以阻止内容穿越到XUL窗口中,示例如下:</p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;browser src="<a class="external" href="http://www.mozilla.org" rel="freelink">http://www.mozilla.org</a>" type="content" flex="1"/&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>元素tabbrowser的每个标签页在创建的时候默认类型都设置为content。因此你不需要明确的为它指定类型。</p>
+<p>第三种类型在你的程序中包含多个browser元素的时候使用的,例如,你有一个侧边栏来显示额外的内容,将主browser元素的type属性设置为content-primary来表明其内容是窗口中的主内容。这与content值一样,只是里面的内容只有使用XUL窗口的content属性才可以访问。这使得用脚本访问主窗口的内容时变得容易。对tabbrowser自动将可见的browser设置为content-primary,也就是说,这样你总是可以在当前可见的窗口中看到内容。</p>
+<p>下一节,我们看看如何创建分隔线</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/creating_a_skin/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/creating_a_skin/index.html
new file mode 100644
index 0000000000..4fabb4c388
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/creating_a_skin/index.html
@@ -0,0 +1,177 @@
+---
+title: 创建一个皮肤
+slug: Mozilla/Tech/XUL/Tutorial/Creating_a_Skin
+translation_of: Archive/Mozilla/XUL/Tutorial/Creating_a_Skin
+---
+<p>本节讲述如何创建一个简单的皮肤,简单起见,我们只将其应用于查找文件对话框。</p>
+
+<h3 id="A_Simple_Skin" name="A_Simple_Skin">一个简单的皮肤。</h3>
+
+<p>下图是当前的查找文件对话框的样子。我们将创建一个应用于其上的皮肤。当然,一个皮肤可以应用于任何程序,但是当我们只关注于文件查找对话框时,事情就回简单些。因此我们只修改findfile.css 而 不修改global.css 文件。本节假设你正在使用经典的皮肤。你可能希望再工作之前留有一个原来皮肤的备份。</p>
+
+<p><img alt="Image:cskin1.jpg"></p>
+
+<p>你需要再用户皮肤中创建文件'findfile.css' 。或者你可以临时把他放在内容目录中并用样式表指令引用。你也可以直接修改当前的findfile.css文件,看看他会变的怎样,或者你可以创建一个用户皮肤并连接到其上。</p>
+
+<h4 id="Creating_a_Custom_Skin_Package" name="Creating_a_Custom_Skin_Package">创建用户皮肤包</h4>
+
+<p>创建皮肤,步骤如下:(如果使用火狐1.5或以上,参见 <a href="/en/XUL_Tutorial/Manifest_Files" title="en/XUL_Tutorial/Manifest_Files">配置文件</a> 代替以下步骤)</p>
+
+<ol>
+ <li>创建一个放置皮肤文件的文件夹。</li>
+ <li>从经典或现代皮肤文件夹中复制配置文件 (contents.rdf) 到这个新建的文件夹。</li>
+ <li>修改配置文件引用你的皮肤。比如:将 'classic/1.0' 改为 'blueswayedshoes/1.0'.</li>
+ <li>在文件‘chrome/installed-chrome.txt’ 中增加如下一行: <code><a class="external" href="skin,install,url,file:///stuff/blueswayedshoes/" rel="freelink">skin,install,url,file:///stuff/blueswayedshoes/</a></code> 其中最后一部分是你现在创建的目录。务必在最后加一个斜杠。</li>
+</ol>
+
+<p>把文件findfile.css 复制到新目录。我们将使用它作为新皮肤的基础。我们可以使用 '<a class="external" rel="freelink">chrome://findfile/skin/findfile.css'来引用它</a>。</p>
+
+<h4 id="Adding_Style_Rules" name="Adding_Style_Rules">添加样式规则</h4>
+
+<p>首先决定要做怎样的改变。我们会修改颜色、改变按钮样式、稍微改变间隔,让我们从菜单、工具栏、标签面板开始。</p>
+
+<p>把下面的内容加到findfile.css 就会产生如下图的改变。</p>
+
+<pre>window &gt; box {
+ background-color: #0088CC;
+}
+
+menubar,menupopup,toolbar,tabpanels {
+ background-color: lightblue;
+ border-top: 1px solid white;
+ border-bottom: 1px solid #666666;
+ border-left: 1px solid white;
+ border-right: 1px solid #666666;
+}
+
+caption {
+ background-color: lightblue;
+}
+</pre>
+
+<p><img alt="Image:cskin2.jpg" class="internal" src="/@api/deki/files/627/=Cskin2.jpg"></p>
+
+<ul>
+ <li>窗口的内框 (包围窗口全部内容的box)被改为蓝色。</li>
+ <li>你可以在标签的间隙和窗口的底部看到这种蓝色。</li>
+ <li>四个元素 <code>:<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menubar" title="menubar">menubar</a></code></code>、 <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code><span style="font-family: Verdana,Tahoma,sans-serif;">、</span></code><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbar" title="toolbar">toolbar</a></code></code>、<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/tabpanels" title="tabpanels">tabpanels</a></code></code> 是浅蓝色</li>
+ <li>边框改为3D样式,仔细看就会发现。</li>
+ <li><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/caption" title="caption">caption</a></code></code> 的底色也被改变用以适应背景色的改变。</li>
+</ul>
+
+<p>上面的第一条规则(用于 'window &gt; box') 制定窗口的内框使用不同的颜色,这可能不是最好的办法,我们可以使用样式类来做出这样的改变。那样做的话,我们可以修改XUL文件,不必要求box是窗口的第一个子元素。</p>
+
+<pre class="eval"><strong>CSS:</strong>
+.findfilesbox {
+ background-color: #0088CC;
+}
+
+<strong>XUL:</strong>
+&lt;vbox <span class="highlightred">class="findfilesbox"</span> orient="vertical" flex="100%"&gt;
+&lt;toolbox&gt;
+</pre>
+
+<h4 id="Rounding_on_the_Tabs" name="Rounding_on_the_Tabs">把标签修圆</h4>
+
+<p>下面,修改标签。我们将要使选中的标签变为粗体,并且修圆标签。</p>
+
+<pre>tab:first-child {
+ -moz-border-radius: 4px 0px 0px 0px;
+}
+
+tab:last-child {
+ -moz-border-radius: 0px 4px 0px 0px;
+}
+
+tab[selected="true"] {
+ color: #000066;
+ font-weight: bold;
+ text-decoration: underline;
+}
+</pre>
+
+<div class="float-right"><img alt="Image:cskin3.jpg" class="internal" src="/@api/deki/files/628/=Cskin3.jpg"></div>
+
+<p>这里添加了两条规则,第一条将第一个标签修圆,第二条将最后一个标签修圆。这里使用了一个特殊的样式规则, <code><a href="/en/CSS/-moz-border-radius" title="en/CSS/-moz-border-radius">-moz-border-radius</a></code>, 他再边框的角上创建一个圆弧。第一个标签的左上角,第二个标签的右上角用4个像素修圆而其他的角都设为0,这相当于没有修圆,值越大就越接近圆,值越小就越接近矩形。</p>
+
+<p>最后的规则只有当标签的属性 <code><code id="a-selected"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/selected">selected</a></code></code> 设为 <code>true</code>时才有效,他是使选中的标签的文字以粗体,下划线、深蓝色显示,注意图中只有第一个标签这样显示,第二个不会,因为他没有被选中。</p>
+
+<h4 id="Adding_Toolbar_Icons" name="Adding_Toolbar_Icons">添加工具栏按钮</h4>
+
+<p>有时候我们很难区分工具栏上的按钮和菜单栏的命令,如果我们为工具栏的按钮添加图标就会更清楚。火狐的创造者为例如打开保存等按钮创建了图标,我们直接用再这里可以节省时间。我们可以使用 <code><a href="/en/CSS/list-style-image" title="en/CSS/list-style-image">list-style-image</a></code> CSS 属性为按钮添加图标。</p>
+
+<pre>#opensearch {
+ list-style-image: url("chrome://editor/skin/icons/btn1.gif");
+ -moz-image-region: rect(48px 16px 64px 0);
+ -moz-box-orient: vertical;
+}
+
+#savesearch {
+ list-style-image: url("chrome://editor/skin/icons/btn1.gif");
+ -moz-image-region: rect(80px 16px 96px 0);
+ -moz-box-orient: vertical;
+}
+</pre>
+
+<div class="float-right"><img alt="Image:cskin4.jpg" class="internal" src="/@api/deki/files/629/=Cskin4.jpg"></div>
+
+<p>Mozilla provides a custom style property <code><a href="/en/CSS/-moz-image-region" title="en/CSS/-moz-image-region">-moz-image-region</a></code> which can be used to make an element use part of an image. You can think of it as a clip region for the image. You set the property to a position and size within an image and the button will display only that section of the image. This allows you to use the same image for multiple buttons and set a different region for each one. When you have lots of buttons, with states for hover, active and disabled, this saves space that would normally be occupied by mutliple images. In the code above, we use the same image for each button, but set a different image region each one. If you look at this image (btn1.gif), you will notice that it contains a grid of smaller images, each one 16 by 16 pixels.</p>
+
+<p>The <code><a href="/en/CSS/-moz-box-orient" title="en/CSS/-moz-box-orient">-moz-box-orient</a></code> property is used to orient the button vertically, so that the image appears above the label. This property has the same meaning as the <code><code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code></code> attribute. This is convenient because the skin cannot change the XUL. Most of the box attributes have corresponding CSS properties.</p>
+
+<h4 id="Other_Changes" name="Other_Changes">其他改变</h4>
+
+<p>Next, we'll make a couple of changes to the buttons along the bottom, again reusing some icons from Mozilla to save time. If creating your own skin, you will need to create new icons or copy the icons to new files. If following the example in this section, just copy the files to your new skin and change the URLs accordingly.</p>
+
+<pre>#find-button {
+ list-style-image: url("chrome://global/skin/checkbox/images/cbox-check.jpg");
+ font-weight: bold;
+}
+
+#cancel-button {
+ list-style-image: url("chrome://global/skin/icons/images/close-button.jpg");
+}
+
+button:hover {
+ color: #000066;
+}
+</pre>
+
+<div class="float-right"><img alt="Image:cskin5.jpg" class="internal" src="/@api/deki/files/630/=Cskin5.jpg"></div>
+
+<p>We add some images to the buttons and make the Find button have bold text to indicate that it is the default button. The last rule applies to buttons when the mouse is hovering over them. We set the text color to dark blue in this case. Finally, some minor changes to the spacing around the items, by setting margins:</p>
+
+<pre>tabbox {
+ margin: 4px;
+}
+
+toolbarbutton {
+ margin-left: 3px;
+ margin-right: 3px;
+}
+</pre>
+
+<p>After those changes, the find files dialog now looks like the image.</p>
+
+<p><img alt="Image:cskin6.jpg" class="internal" src="/@api/deki/files/631/=Cskin6.jpg"></p>
+
+<p>As you can see, some simple changes to the style rules has resulted in quite a different appearance to the find files dialog. We could continue by changing the menus, the grippies on the toolbar and the input and checkbox elements.</p>
+
+<h3 id="Creating_a_Global_Skin" name="Creating_a_Global_Skin">创建全局皮肤</h3>
+
+<p>The skin created above is simple and only applies to the find files dialog. Some of the changes made to the skin could be placed in the global style sheets (those in the global directory of the skin) to be applied to all applications. For example, having different images for the check boxes in the find files dialog as other windows looks a little odd. This change should really be moved into the global style sheet.</p>
+
+<p>Try moving the CSS styles from findfile.css into global.css and then look at some of the dialogs in Mozilla. (The cookie viewer is a good example.) You will notice that it has adopted the rules that we have added. Some of the rules conflict with those already in the global stylesheets. For example, rules are already defined for buttons and tabs and so on and we defined additional rules for them. When changing the global skin, you would need to merge the changes into the existing rules.</p>
+
+<p>For the best skinnability, it is best to declare appearance related style rules in the global directory rather than in individual style files. This includes colors, fonts and general widget appearances. If you change the color of something in a local skin file (such as findfile.css), the dialog may look odd if the user changes their global skin. Don't expect the user to be using the default one.</p>
+
+<div class="highlight">
+<p>Our Find files example with this skin: <a href="https://developer.mozilla.org/samples/xultu/examples/findfile/findfile-cskin.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/findfile/findfile-cskin.xul">View</a> <a href="https://developer.mozilla.org/samples/xultu/examples/findfile/findfile-cskin.css">Stylesheet</a></p>
+</div>
+
+<h3 id="See_also"><small>See also</small></h3>
+
+<p><small><a href="/en/CSS_Reference/Mozilla_Extensions" title="en/CSS_Reference/Mozilla_Extensions">Mozilla CSS extensions</a>, and <a href="/en/CSS_Reference" title="en/CSS_Reference">CSS reference</a></small></p>
+
+<p><br>
+ 下一章讨论 <a href="/en/XUL_Tutorial/Localization" title="en/XUL_Tutorial/Localization">XUL程序的本地化</a></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/creating_a_window/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/creating_a_window/index.html
new file mode 100644
index 0000000000..5a7329bac3
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/creating_a_window/index.html
@@ -0,0 +1,116 @@
+---
+title: 创建一个窗口
+slug: Mozilla/Tech/XUL/Tutorial/Creating_a_Window
+translation_of: Archive/Mozilla/XUL/Tutorial/Creating_a_Window
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Manifest_Files" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Adding_Buttons">下一页 »</a></p>
+</div><p></p>
+
+<p> </p>
+
+<p>前面提到: 我们要在本教程中创建一个简单的查找文件工具。不过开始之前,我们得先看看XUL文件的基本语法。</p>
+
+<p> </p>
+
+<h3 id=".E5.88.9B.E5.BB.BA.E4.B8.80.E4.B8.AA_XUL_.E6.96.87.E4.BB.B6" name=".E5.88.9B.E5.BB.BA.E4.B8.80.E4.B8.AA_XUL_.E6.96.87.E4.BB.B6">创建一个 XUL 文件</h3>
+
+<p>一个 XUL 文件可以有任何名字,但它必须拥有一个 .xul 的扩展名。最简单的 XUL 文件具有下述结构:</p>
+
+<pre>&lt;?xml version="1.0"?&gt;
+&lt;?xml-stylesheet href="chrome://global/skin/" type="text/css"?&gt;
+
+&lt;window
+ id="findfile-window"
+ title="查找文件"
+ orient="horizontal"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;
+&lt;!-- Other elements go here --&gt;
+&lt;/window&gt;
+</pre>
+
+<p>这个窗口不会做任何事情,因为它没有包含任何用户界面元素。那些元素会在下面的部分中添加。这里对上面的代码进行逐行断开解释:</p>
+
+<ol>
+ <li><strong>&lt;?xml version="1.0"?&gt;</strong><br>
+ 这一行只是简单声明这是一个 XML 文件。你通常在每一个 xul 文件的顶端都会添加这一行,非常像在一个 HTML 文件的顶端添加 HTML 的标识。</li>
+ <li><strong>&lt;?xml-stylesheet href="<a class="external" rel="freelink">chrome://global/skin/</a>" type="text/css"?&gt;</strong><br>
+ 这一行是用来指定文件使用的样式表的。这是 XML 文件用以导入样式表的语法。在这种情况下,我们从一个皮肤包的全局部分导入样式。我们没有指定特定的文件,所以 Mozilla 会确定使用文件夹中的哪一个文件。在这种情况下,会选中最重要的 global.css 文件。这个文件包括了所有 XUL 元件的默认声明。因为 XML 并不知道如何显示元件,因此这个文件指出怎样去做。通常,你会将这一行放在每一个 XUL 文件的顶部。你也可以采用类似语法导入其他的样式表。需要注意的是你一般都会在你的样式表文件中导入全局样式表。</li>
+ <li><strong>&lt;window</strong><br>
+ 这一行说明你在描述一个 <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/window" title="window">window</a></code> 。每一个用户界面窗口都在一个单独的文件中进行描述。这个标记非常类似 HTML 中包围全部内容的 BODY 标记。 <a href="/cn/XUL/window#Attributes" title="cn/XUL/window#Attributes">一些属性</a>可以放到 <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/window" title="window">window</a></code> 标记中——在本例中有四个属性。在本例中,每一个属性都占一个单独的行,但并不是必须这样做。</li>
+ <li><strong>id="findfile-window"</strong><br>
+ <code><code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code></code> 属性用作标识以便窗口被脚本所引用。你通常会为所有的软件放上 <code>id</code> 属性。虽然名字可由你任起,但应该是有一定关联的。</li>
+ <li><strong>title="查找文件"</strong><br>
+ The <code><code id="a-title"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/title">title</a></code></code> Attribute 属性描述显示时将在窗口的标题栏上显现的文本。在本例中将显示'查找文件'。</li>
+ <li><strong>orient="horizontal"</strong><br>
+ <code><code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code></code> 属性确定窗口中元件的排布。值 <code>horizontal</code> 意味着元件应该横过窗口水平放置。你也可以使用值 <code>vertical</code>,这表示元件将成一列放置。这是默认值,所以如果你希望使用垂直方向的话可以将这个属性完全关闭。</li>
+ <li><strong>xmlns="<span class="nowiki">http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul</span>"&gt;</strong><br>
+ 这一行声名了 XUL 的名空间,你应该将它放到窗口元件以表示它的所有子元件都是 XUL。注意这个 URL 实际上不需要下载的。Mozilla 内部会识别这个 URL。</li>
+ <li><strong><span class="nowiki">&lt;!-- 其他元件写到这里 --&gt;</span></strong><br>
+ 将这个注释块替换成其他显示在窗口中的元件(按钮、菜单以及其他用户界面组件)。我们在接下面的部分将添加一些元件。</li>
+ <li><strong>&lt;/window&gt;</strong><br>
+ 最后,我们需要在文件的结尾关闭 <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/window" title="window">window</a></code> 标记。</li>
+</ol>
+
+<h3 id=".E6.89.93.E5.BC.80.E7.AA.97.E5.8F.A3" name=".E6.89.93.E5.BC.80.E7.AA.97.E5.8F.A3">打开窗口</h3>
+
+<p>声明完一个窗口,如果打开它呢?这里有几种方法:</p>
+
+<ul>
+ <li>如果是进行开发,你可以直接在浏览器的定位栏(location bar)中输入URL(chrome:、file:或其它形式的URL)。如果使用chrome则要按前面所讲的注册包。如果使用file:协议,可以直接打开。chrome的好处是可以获得比一般URL更多的权限。不过,现在还用不上。但建议还是把chrome配好。</li>
+ <li>如果.xul文件已经与Mozilla作了关联,在资源管理器上双击即可。这种方式与file:方式效果一样。</li>
+</ul>
+
+<p>不过,因为我们的XUL中没有定义其它元素,因此使用Mozilla打开时,什么也看不到。并且在浏览器中打开时,窗口会显示在浏览器中,这不是一个真正的应用,不过进行测试没有关系。</p>
+
+<ul>
+ <li>正确的方法是使用Javascript来打开。使用window.open()函数,同打开HTML文档一样。不过需要一个额外的参数,叫"chrome",它用来指明要打开的文档是一个chrome文档。语法描述如下:
+ <blockquote>
+ <p>window.open(url,windowname,flags);</p>
+
+ <p>其中 flags 必须包含 "chrome"。</p>
+
+ <p>例如:<br>
+ window.open("<a class="external" rel="freelink">chrome://navigator/content/navigator.xul</a>", "bmarks", "chrome,width=600,height=300");</p>
+ </blockquote>
+ </li>
+ <li>还可以在命令行下使用-chrome参数来指明Mozilla启动时打开的XUL文件。例如:
+ <blockquote>
+ <p>mozilla -chrome <a class="external" rel="freelink">chrome://findfile/content/findfile.xul</a></p>
+
+ <p>mozilla -chrome resource:/chrome/findfile/content/findfile.xul</p>
+ </blockquote>
+ </li>
+</ul>
+
+<p>-chrome参数并不会带来特殊权限,而是chrome URL备具特殊权限。</p>
+
+<p>到这里可以把已经学过的做一个测试。包的组织不一定要是content/skin/locale这种形式。象我的测试就是:</p>
+
+<blockquote>
+<p>d:\project\test\xul\findfile</p>
+</blockquote>
+
+<p>现在目录下有两个文件:</p>
+
+<blockquote>
+<p>findfile.xul和contents.rdf</p>
+</blockquote>
+
+<p>然后修改installed-chrome.txt文件。</p>
+
+<p>切换到Mozilla目录,然后在命令行下输入:</p>
+
+<blockquote>
+<p>mozilla -chrome <a class="external" rel="freelink">chrome://findfile/content/filefile.xul</a></p>
+</blockquote>
+
+<p dir="ltr">不过执行完后,什么都没有,就一个标题条。</p>
+
+<p dir="ltr">(英文原文: <a class="external" href="http://developer.mozilla.org/en/docs/XUL_Tutorial:Creating_a_Window">XUL_Tutorial:Creating_a_Window</a> ) 本篇wiki基于limodou的学习记录: <a class="external" href="http://blog.donews.com/limodou/archive/2005/01/10/233420.aspx">XUL学习:XUL Tutorial(五) -- Creating a Window</a></p>
+
+<p dir="ltr"> </p>
+
+<p dir="ltr"></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Manifest_Files" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Adding_Buttons">下一页 »</a></p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/creating_an_installer/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/creating_an_installer/index.html
new file mode 100644
index 0000000000..aef43ec39b
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/creating_an_installer/index.html
@@ -0,0 +1,98 @@
+---
+title: 创建安装程序
+slug: Mozilla/Tech/XUL/Tutorial/Creating_an_Installer
+translation_of: Archive/Mozilla/XUL/Tutorial/Creating_an_Installer
+---
+<p> <span class="lang lang-en"> </span></p>
+<div class="warning">
+ <p>Parts of this page show the use of the <a href="../../../../en/XPInstall_API_Reference" rel="internal">XPInstall API</a>. The majority of this API is now deprecated and as of Gecko 1.9 no longer available. <a href="../../../../en/Extensions" rel="internal">Extension</a>, <a href="../../../../en/Themes" rel="internal">theme</a>, and <a href="../../../../en/Plugins" rel="internal">plug-in</a> developers must switch away from <code>install.js</code> based packages to the new <a href="../../../../en/Bundles" rel="internal">packaging scheme</a> with an <code><a href="../../../../en/Install.rdf" rel="internal">install.rdf</a></code> manifest. In particular plugin developers should see <a href="../../../../en/Shipping_a_plugin_as_an_extension" rel="internal">how to package a plugin as an extension</a>.</p>
+</div>
+<p> </p>
+<p> </p>
+<div class="prevnext">
+ <p><span style="float: left;">« <a href="../../../../en/XUL_Tutorial/Cross_Package_Overlays" rel="internal">Previous</a></span> <span style="float: right;"><a href="../../../../en/XUL_Tutorial/Install_Scripts" rel="internal">Next</a> »</span></p>
+</div>
+<p>  </p>
+<p> </p>
+<p>This section will describe packaging a XUL application into an installer.</p>
+<div id="section_1">
+ <h3 class="editable" id="XPInstall_Packages"><span>XPInstall Packages </span></h3>
+ <div class="editIcon">
+ <a href="../../../../en/XUL_Tutorial/Creating_an_Installer#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>Mozilla provides a mechanism which can be used to package XUL windows, scripts, skins and other files into single file installers. You can place this installer file somewhere for users to download. A simple script can be used to have the package downloaded and installed. This mechanism is called <a href="../../../../en/XPInstall" rel="internal">XPInstall</a> (Cross platform Install).</p>
+ <p>XPInstall installers are packaged into JAR files. Inside the JAR file, you can add all the various files that you want to have installed. In addition, installers should contain an install script (a file named install.js) which can be used to script the installation process. This script has access to various install functions which can be used to install files and components.</p>
+ <p>The JAR file installers typically have the extension .xpi (pronounced zippy) to distinguish them from other archives. The installers will be usually used to install Mozilla components such as new skins, plugins and packages.</p>
+ <p>There are several steps involved in launching an installer and installing components. These are described step by step below.</p>
+ <ol>
+ <li>Create a Web page from which the user can download the software to be installed. This page will contain an install trigger which is a small piece of script which launches the install.</li>
+ <li>The user is presented with a dialog which indicates the package being installed. It is possible for the install trigger to launch multiple installers. In this case, they will be presented in a list. The user may choose to continue or cancel.</li>
+ <li>If the user chooses to continue, the installer XPI file is downloaded. A progress bar is displayed to the user during this process.</li>
+ <li>The file install.js is extracted from the install archive and executed. This script will call install functions which will indicate which files from the archive should be installed.</li>
+ <li>Once the script is complete, the new package has been installed. If multiple packages are being installed, their scripts will run in sequence.</li>
+ </ol>
+</div>
+<div id="section_2">
+ <h3 class="editable" id="Install_Triggers"><span>Install Triggers </span></h3>
+ <div class="editIcon">
+ <a href="../../../../en/XUL_Tutorial/Creating_an_Installer#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>As indicated above, the install process is started by an install trigger. This involves the use of the special global object InstallTrigger. It contains a number of methods which can be used to start an installation. You can use this object in local or remote content, meaning that it is suitable for a download from a Web site.</p>
+ <p>Let's create an example install trigger. This involves the use of the function <code>InstallTrigger.install()</code>. This function takes two arguments, the first is a list of packages to install, and the second is a callback function which will be called when the installation is complete. Here is an example:</p>
+ <pre>function doneFn ( name , result ){
+ alert("The package " + name + " was installed with a result of " + result);
+}
+
+var xpi = new Object();
+xpi["Calendar"] = "calendar.xpi";
+InstallTrigger.install(xpi,doneFn);
+</pre>
+ <p>First, we define a callback function doneFn() which will be called when the install is complete. You can name the function whatever you like of course. This function has two arguments. The first is the name of the package that was just installed. This is important if you are installing multiple components. The second argument is a result code. If the result is 0, the installation completed successfully. If the result is non-zero, an error occured and the value is an error code. The function doneFn() here just displays an alert box to the user.</p>
+ <p>Next, we create an array xpi which will hold the name (Calendar) and URL (calendar.xpi) of the installer. You can add an additional similar such line for each package you wish to have installed. Finally, we call the install function.</p>
+ <p>When this section of script is executed, the file calendar.xpi will be installed.</p>
+ <div class="highlight">
+ <div id="section_3">
+ <h4 class="editable" id="Our_find_files_example"><span>Our find files example </span></h4>
+ <div class="editIcon">
+ <a href="../../../../en/XUL_Tutorial/Creating_an_Installer#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>Let's try this with the find files dialog.</p>
+ <pre>function doneFn ( name , result ){
+ if (result) alert("An error occured: " + result);
+}
+
+var xpi = new Object();
+xpi["Find Files"] = "findfile.xpi";
+InstallTrigger.install(xpi,doneFn);
+</pre>
+ </div>
+ </div>
+</div>
+<h3 class="editable" id="The_XPI_Archive"><span>The XPI Archive </span></h3>
+<div class="editIcon">
+ <a href="../../../../en/XUL_Tutorial/Creating_an_Installer#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+<div class="note">
+ <strong>Note</strong>: If you want to create a new <a href="../../../../en/XULRunner" rel="internal">XULRunner application</a>, <a href="../../../../en/Extensions" rel="internal">extension</a>, or <a href="../../../../en/Themes" rel="internal">theme</a>, see <a href="../../../../en/Bundles" rel="internal">Bundles</a>.</div>
+<p>The installer XPI file is required to contain one file called install.js which is a <a href="../../../../en/JavaScript" rel="internal">JavaScript</a> file which is executed during the installation. The remaining files are the files to be installed. These files will typically be placed inside a directory in the archive but they do not have to be. For chrome files, they might be structured like the chrome directory.</p>
+<p>Often, the only files placed in an XPI archive will be the install script (install.js) and a JAR file. This JAR file contains all of the files used by your application. The components provided with Mozilla are stored in this manner.</p>
+<p>Because the XPI file is just a special ZIP file, you can create it and add files to it using a zip utility.</p>
+<div class="highlight">
+ <div id="section_5">
+ <h4 class="editable" id="Our_find_files_example_2"><span>Our find files example </span></h4>
+ <div class="editIcon">
+ <a href="../../../../en/XUL_Tutorial/Creating_an_Installer#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>For the find files dialog, we'll create a structure in the archive much like the following:</p>
+ <pre>install.js
+findfile
+ content
+ contents.rdf
+ findfile.xul
+ findfile.js
+ skin
+ contents.rdf
+ findfile.css
+ locale
+ contents.rdf
+ findfile.dtd
+</pre>
+ </div>
+</div>
+<p>A directory has been added for each part of the package, the content, the skin and the locale. The contents.rdf files have also been added because they will be needed to register the chrome files.</p>
+<p>Next, we'll look further at the <a href="../../../../en/XUL_Tutorial/Install_Scripts" rel="internal">install script</a>.</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/creating_dialogs/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/creating_dialogs/index.html
new file mode 100644
index 0000000000..1b3dbb2fab
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/creating_dialogs/index.html
@@ -0,0 +1,6 @@
+---
+title: Creating Dialogs
+slug: Mozilla/Tech/XUL/Tutorial/Creating_Dialogs
+translation_of: Archive/Mozilla/XUL/Tutorial/Creating_Dialogs
+---
+<p>This page has no content. Enrich MDC by contributing.</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/document_object_model/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/document_object_model/index.html
new file mode 100644
index 0000000000..15112d1cc7
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/document_object_model/index.html
@@ -0,0 +1,220 @@
+---
+title: 文档对象模型
+slug: Mozilla/Tech/XUL/Tutorial/Document_Object_Model
+tags:
+ - DOM
+ - XUL_教程_cn
+translation_of: Archive/Mozilla/XUL/Tutorial/Document_Object_Model
+---
+<div id="page-top">
+ <div class="pageText" id="pageText">
+ <p> </p>
+ <p> </p>
+ <div class="prevnext">
+ <p><span style="float: left;">« <a href="../../../../en/XUL_Tutorial/Broadcasters_and_Observers" rel="internal">Previous</a></span> <span style="float: right;"><a href="../../../../en/XUL_Tutorial/Modifying_a_XUL_Interface" rel="internal">Next</a> »</span></p>
+ </div>
+ <p>  </p>
+ <p> </p>
+ <p>    XUL元素的文档对象模型 (DOM) 可以用于获取信息或修改他们。</p>
+ <div id="section_1">
+ <h3 class="editable" id="DOM_介绍"><span>DOM 介绍</span></h3>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/Document_Object_Model#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    <a href="../../../../en/DOM" rel="internal">文档对象模型</a> (DOM) 用于储存XUL节点树。当一个XUL文件加载后,标记被解析并转换成节点的继承关系结构。每个节点包含标记及一个文本块。DOM 结构可以使用一系列方法检查并修改。特殊的XUL 元素也提供了附加的方法可供使用。</p>
+ <p>    每一个加载了的XUL 文件都有一个可以显示在窗口或框架内的文档。尽管在特定时间只有一个文档与窗口相关,也有一系列方法使你可以加载更多的文档。</p>
+ <p>    Mozilla中, <a href="../../../../en/DOM" rel="internal">DOM</a> 可以被<a href="../../../../en/JavaScript" rel="internal">JavaScript</a>访问并操作。大量的文件对象包含可以被脚本使用的函数。然而,需要了解的是 DOM 是一个可以被 JavaScript 访问的 API 。JavaScript 本身仅是一种脚本语言,它能够访问这些对象是因为 Mozilla 为他提供了这些。</p>
+ <p>    <a href="../../../../en/JavaScript" rel="internal">JavaScript</a> 中,由一个全局对象总可以被访问。你可以不使用对象就引用这个全局对象的属性及方法。比如,如果这个全局对象由一个 'name' 属性,你可以用这样的代码来改变它 'name = 7',而不用指明你所使用的对象。在浏览器环境中,window 是这个全局对象,对于XUL同样。当然对于不同的窗口这个全局对象也有所不同。每一个框架都含有一个独立的窗口对象。</p>
+ <p>    窗口经常使用 <a href="../../../../en/DOM/window.window" rel="internal"><code>window</code> property</a> 引用,尽管这是可选的。有时这仅是为了澄清你所引用的方法的范围。举例来说,下面的两行等效的打开了一个新窗口。</p>
+ <pre>window.open("test.xul","_new");
+open("test.xul","_new");
+</pre>
+ <p>    当你在脚本的顶层定义一个函数或变量时,你实际上是为全局对象定义了一个属性。在 XUL中你定义的每一个函数都会被设为窗口对象的属性,比如下面的代码会在提示框中显示 'Message' 两次。</p>
+ <pre>function getText(){
+ return "Message";
+}
+
+alert(getText());
+alert(window.getText());
+</pre>
+ <p>    如果你希望访问在另一个窗口的脚本中定义的变量或函数,你值需要使用另一个窗口的 <code><a href="../../../../en/DOM/window" rel="internal">window</a></code> 对象。比如,把上面的两个例子做成一个我们希望在另一个窗口(比如test.xul窗口)中调用getText()函数,可以这样做:</p>
+ <pre>alert(window.opener.getText());
+</pre>
+ <p>    每一个窗口都有一个 <code><a href="../../../../en/DOM/window.opener" rel="internal">opener</a></code> 属性,它保存着这个窗口对象是由谁打开的。在这个例子中,我们得到窗口的打开者,并调用这个窗口的 getText() 函数。注意,我们使用窗口属性前缀 'window' 仅为了清晰。</p>
+ <p>    窗口的 <code><a href="../../../../en/DOM/window.open" rel="internal">open()</a></code> 方法也返回一个新窗口的引用,我们也可以从 <code><a href="../../../../en/DOM/window.opener" rel="internal">opener</a></code>调用新窗口的函数。提示: <code><a href="../../../../en/DOM/window.open" rel="internal">open()</a></code> 在窗口完全加载前返回函数可能不会有效。</p>
+ <p>    窗口对象并不是有由 DOM 标准定义的,但在 Mozilla中有时把这部分称作 <a href="../../../../Special:Tags?tag=DOM_0&amp;language=en" rel="internal">DOM Level 0</a>——一个一些开发者称呼那些还未加入标准的类 DOM 功能的名字。在春光看中显示的文档可以通过窗口的 <code><a href="../../../../en/DOM/window.document" rel="internal">document</a></code> 属性获得。由于它是窗口最常用的属性 <code><a href="../../../../en/DOM/window.document" rel="internal">document</a></code> 属性经常不使用 'window.' 前缀。</p>
+ <p>     Mozilla 为不同的文档提供了一系列文档对象。三个主要的是<a class="external" href="http://www.xulplanet.com/references/objref/HTMLDocument.html" rel="external nofollow" title="http://www.xulplanet.com/references/objref/HTMLDocument.html">HTMLDocument</a>, <a class="external" href="http://www.xulplanet.com/references/objref/XMLDocument.html" rel="external nofollow" title="http://www.xulplanet.com/references/objref/XMLDocument.html">XMLDocument</a>, a及 <a class="external" href="http://www.xulplanet.com/references/objref/XULDocument.html" rel="external nofollow" title="http://www.xulplanet.com/references/objref/XULDocument.html">XULDocument</a>, 分别支持 <a href="../../../../en/HTML" rel="internal">HTML</a>, <a href="../../../../en/XML" rel="internal">XML</a> 及 <a href="../../../../en/XUL" rel="internal">XUL</a> 文档。这三种文件类型十分相似,事实上他们共享基本实现。然而,一些函数在一种或几种文档类型是特殊的。</p>
+ </div>
+ <div id="section_2">
+ <h3 class="editable" id="检索元素"><span>检索元素</span></h3>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/Document_Object_Model#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    最常用的检索元素的方法是给出待检索元素的<code><a href="../../../../en/DOM/element.id" rel="internal">id</a></code> 属性利用<code><a href="../../../../en/DOM/document.getElementById" rel="internal">getElementById()</a></code> 方法检索。在 find file 对话框中我们为不少元素都添加了id属性,比如,我们可以使用这样的代码获得check box 的状态。</p>
+ <pre>var state = document.getElementById('casecheck').checked;
+</pre>
+ <p>     <code>casecheck</code> 代表待检索 <a href="../../../../en/XUL_Tutorial/Input_Controls#Checkboxes_and_Radio_Buttons" rel="internal">checkbox</a> 的id,如果我们需要检查是否它被选中,我们只需按上面的方法检查。我们可以对其他的单选框或其他有id的元素作相同的检查。比如获得输入框中的字符。;</p>
+ <div class="highlight">
+ <div id="section_3">
+ <h4 class="editable" id="find_files_的例子"><span>find files 的例子</span></h4>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/Document_Object_Model#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    要让 <a href="../../../../en/XUL_Tutorial/Progress_Meters" rel="internal">progress bar</a> 及 <a href="../../../../en/XUL_Tutorial/Trees" rel="internal">tree data</a>在findfile对话框显示时就显示出来,这不是难题。只要加在XUL文件中就可以了。现在我们要先去掉它,然后在按下 Find 按钮后显示。 首先,应将他们初始化化为不可见。<code><span class="lang lang-en"><a href="../../../../en/XUL/Attribute/hidden" rel="internal">hidden</a> </span></code>属性用于确定元素是否显示。</p>
+ <p>    把进度条初始化为隐藏,同时为了能够用脚本引用添加一个 <code><span class="lang lang-en"><a href="../../../../en/XUL/Attribute/id" rel="internal">id</a> <span style="font-family: Verdana,Tahoma,sans-serif;">属性。同样的为了隐藏tree我们也将</span></span></code><a href="../../../../en/XUL_Tutorial/Splitters" rel="internal">splitter</a> 隐藏。</p>
+ <pre class="eval">&lt;tree <span class="highlightred">id="results" hidden="true"</span> flex="1"&gt;
+ .
+ .
+ .
+&lt;splitter <span class="highlightred">id="splitbar"</span> resizeafter="grow" <span class="highlightred">hidden="true"</span>/&gt;
+
+&lt;hbox&gt;
+
+ &lt;progressmeter <span class="highlightred">id="progmeter"</span> value="50%"
+ style="margin: 4px;" <span class="highlightred">hidden="true"</span>/&gt;
+</pre>
+ <p>    添加 <code><span class="lang lang-en"><a href="../../../../en/XUL/Attribute/hidden" rel="internal">hidden</a> </span></code>属性并设值为 <code>true</code>。这将导致窗口首次显示时该元素不可见。</p>
+ <p>    接下来,我们添加一个在Find按钮按下时调用的函数。我们把脚本写在findfile.js里,在上一章,我们已经在XUL文件中添加了脚本( <code><span class="lang lang-en"><a href="../../../../en/XUL/script" rel="internal">script</a> )<span style="font-family: Verdana,Tahoma,sans-serif;">元素,如果你还不知道如何添加,请看下面的例子。</span></span></code> <code><span class="lang lang-en"><a href="../../../../en/XUL/Attribute/oncommand" rel="internal">oncommand</a> </span></code> 控制器也被加到 Find 按钮上。</p>
+ <pre class="eval">&lt;script src="findfile.js"/&gt;
+ .
+ .
+ .
+&lt;button id="find-button" label="Find"
+ <span class="highlightred">oncommand="doFind();"</span>/&gt;
+</pre>
+ <p>    现在与findfile.xul相同的目录中创建一个叫 findfile.js 的文件,我们在文件中写一个 doFind() 函数。 script 标签允许直接编写脚本代码,但是出于包括格式在内的多种原因,脚本经常写在独立的文件里,除非它可以直接放到处理器中。</p>
+ <pre class="eval">function doFind(){
+ var meter = document.getElementById('progmeter');
+ meter.hidden = false;
+}
+</pre>
+ <p>    这个函数首先通过进度条的id引用它,然后改变的hidden属性。</p>
+ <p>    最后用一个提示框显示需要检索的文字。当然,这不是最后的版本,但现在我们需要让它发生些什么以使我们确认。</p>
+ <pre class="eval">function doFind(){
+ var meter=document.getElementById('progmeter');
+ meter.hidden = false;
+ <span class="highlightred">var searchtext=document.getElementById('find-text').value;
+ alert("Searching for \"" + searchtext + "\"");</span>
+}
+</pre>
+ <p>    现在,由于提示框的存在,我们知道当点击Find按钮时,会发生什么。同样,我们也需要为 drop-down boxes 添加代码以获得用用户选项。</p>
+ </div>
+ </div>
+ </div>
+ <div id="section_4">
+ <h3 class="editable" id="XUL_元素的_DOM"><span>XUL 元素的 DOM </span></h3>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/Document_Object_Model#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    每一个 XUL 元素都还有一系列的属性,功能及子元素。</p>
+ <ul>
+ <li>属性是在源文件中定义的,如flex="1"将 <code><span class="lang lang-en"><a href="../../../../en/XUL/Attribute/flex" rel="internal">flex</a> </span></code>属性设为 <code>1</code>。</li>
+ <li>JavaScript 中属性使用点语法。例如:element.hidden 引用延伸的hidden 属性</li>
+ <li>子元素的是指嵌在源文件标签中的元素。</li>
+ </ul>
+ <p>    使用DOM方法可以动态的处理一个元素的属性,方法及子元素。</p>
+ <p>    注意属性及方法是不一样的东西。有一个属性并不意味着有一个同名的方法,当然通常会有这样一个方法。比如说获得元素的flex属性可以使用flex方法。这种情况下方法的代码就返回这属性。对于其他的方法 XUL 会进行更复杂的处理</p>
+ <p>    你可以用以下的方法处理元素的属性:</p>
+ <dl>
+ <dt>
+ <a href="../../../../en/DOM/element.getAttribute" rel="internal">getAttribute</a> ( name )</dt>
+ <dd>
+ 返回给定元素的属性。</dd>
+ <dt>
+ <a href="../../../../en/DOM/element.hasAttribute" rel="internal">hasAttribute</a> ( name )</dt>
+ <dd>
+ 如果元素有指定名字的属性返回真。</dd>
+ <dt>
+ <a href="../../../../en/DOM/element.setAttribute" rel="internal">setAttribute</a> ( name , value )</dt>
+ <dd>
+ 将value 为给定名字为name 的属性赋值。</dd>
+ <dt>
+ <a href="../../../../en/DOM/element.removeAttribute" rel="internal">removeAttribute</a> ( name )</dt>
+ <dd>
+ 删除给定名字的属性。</dd>
+ </dl>
+ <p>    这些方法可以让你在任何时候取得或改变属性的值。比如:</p>
+ <pre> var box = document.getElementById('somebox');
+ var flex = box.getAttribute("flex");
+
+ var box2 = document.getElementById('anotherbox');
+ box2.setAttribute("flex", "2");
+</pre>
+ <p>   当然 <code><span class="lang lang-en"><a href="../../../../en/XUL/Attribute/flex" rel="internal">flex</a> 属性有</span></code><a href="../../../../en/XUL/Property/flex" rel="internal">对应的脚本方法</a> 可以用以代替。它并不更为有效,当更为简洁。下面的例子与上面的效果相同。</p>
+ <pre> var box = document.getElementById('somebox');
+ var flex = box.flex;
+
+ var box2 = document.getElementById('anotherbox');
+ box2.flex = 2;
+</pre>
+ <p>    一旦你引用了元素你就可以引用它的方法。比如,为了获得一个元素的 <code><span class="lang lang-en"><a href="../../../../en/XUL/Property/hidden" rel="internal">hidden</a> 方法可以使用</span></code><code><em>element</em>.hidden</code> 。你可能已经注意到了在方法参考中,一项会同时出现在属性及方法中,这是不一样的。比如,对于隐藏的元素 <strong><font color="green">getAttribute("hidden") 返回字符串 'true'</font></strong> ,而 hidden <strong><font color="green">方法返回‘值true’ </font></strong> 。用方法会自动完成类型转换。</p>
+ <p>    像 <a href="../../../../en/HTML" rel="internal">HTML</a> 和 <a href="../../../../en/XML" rel="internal">XML</a> 元素一样,每一个 XUL 元素实现 <a class="external" href="http://www.xulplanet.com/references/objref/XULElement.html" rel="external nofollow" title="http://www.xulplanet.com/references/objref/XULElement.html">XULElement</a> 接口。一个 XUL 元素可以是任何定义在 XUL 名空间中的元素。所以XUL有非XUL 元素没有的属性及方法。XULElement 接口有一系列属性及方法来定义XUL 元素,其中有很多继承至 DOM 元素接口。</p>
+ <p>    一个名空间用一个URI 描述元素,下面是例子。</p>
+ <pre>&lt;button xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/&gt;
+&lt;button xmlns="http://www.w3.org/1999/xhtml"/&gt;
+&lt;html:button xmlns:html="http://www.w3.org/1999/xhtml"/&gt;
+&lt;html:button xmlns:html="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/&gt;</pre>
+ <p>    名空间使用 <code>xmlns</code> 属性</p>
+ <ul>
+ <li>第一个按钮是被置于XUL名空间在的 XUL 元素。</li>
+ <li>第二个按钮是被置于XHTML名空间在的 XHTML 元素。</li>
+ <li>第三个例子,前缀 'html' 关联到 '<a class="external" href="http://www.w3.org/1999/xhtml" rel="freelink">http://www.w3.org/1999/xhtml</a>',当你的文档中需要多个名空间时,你也可以使用使用冒号语法来使用前缀名空间。本例创建一个 XHTML 按钮。</li>
+ <li>第四个按钮是XUL按钮,尽管使用的‘html’前缀,这要看前缀关联到哪个名空间。</li>
+ </ul>
+ <p>    这是一个很重要的区别,不过在真正的文档中会为不同的名空间使用不同的前缀。</p>
+ <p>    DOM 提供了与无名空间相似的名空间相关的方法。比如 <code><a href="../../../../en/DOM/element.getAttributeNS" rel="internal">getAttributeNS()</a></code> 和 <code><a href="../../../../en/DOM/element.getAttribute" rel="internal">getAttribute()</a></code> 相似除了需要一个指明名空间的参数。</p>
+ <p>    许多XUL元素有不同于其他元素的方法。参见 <a href="../../../../en/XUL_Reference" rel="internal">element reference</a> 。</p>
+ </div>
+ <div id="section_5">
+ <h3 class="editable" id="DOM遍历"><span>DOM遍历</span></h3>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/Document_Object_Model#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    DOM是一个只有一个根的树。可以使用<code><a href="../../../../en/DOM/document.documentElement" rel="internal">documentElement</a></code> 方法获取根节点。根节点只要一个,但其他节点则不一定。一个元素对应与源文件中的标签,但也有文本节点、注释节点、及其他类型的节点。在XUL文档中根节点是源文件中的<code><span class="lang lang-en"><a href="../../../../en/XUL/window" rel="internal">window</a><span style="font-family: Verdana,Tahoma,sans-serif;">标签。</span></span></code> 树中的每一个节点都可能有其子节点,每个子节点又有它字节的子节点。由于DOM是树结构所以可以用一系列方法来遍历它。常用的几个列在下面:</p>
+ <dl>
+ <dt>
+ <a href="../../../../en/DOM/element.firstChild" rel="internal">firstChild</a></dt>
+ <dd>
+ 引用元素的第一个子节点。</dd>
+ <dt>
+ <a href="../../../../en/DOM/element.lastChild" rel="internal">lastChild</a></dt>
+ <dd>
+ 引用元素的最后一个子节点。</dd>
+ <dt>
+ <a href="../../../../en/DOM/element.childNodes" rel="internal">childNodes</a></dt>
+ <dd>
+ 返回元素子节点的列表。</dd>
+ <dt>
+ <a href="../../../../en/DOM/element.parentNode" rel="internal">parentNode</a></dt>
+ <dd>
+ 返回元素的亲节点。</dd>
+ <dt>
+ <a href="../../../../en/DOM/element.nextSibling" rel="internal">nextSibling</a></dt>
+ <dd>
+ 引用下一个兄弟节点。</dd>
+ <dt>
+ <a href="../../../../en/DOM/element.previousSibling" rel="internal">previousSibling</a></dt>
+ <dd>
+ 引用前一个兄弟节点。</dd>
+ </dl>
+ <p>    这些方法允许你以多种方法遍历文件,比如,使用 <code><a href="../../../../en/DOM/element.firstChild" rel="internal">firstChild</a></code> 方法获得第一个子节点并用 <code><a href="../../../../en/DOM/element.nextSibling" rel="internal">nextSibling</a></code> 方法遍历子节点,或者可以用<code><a href="../../../../en/DOM/element.childNodes" rel="internal">childNodes</a></code> 返回子节点列表。在Mozilla中后者更有效。</p>
+ <p>    这个例子展示如何遍历根节点的全部子节点:</p>
+ <pre>var childNodes = document.documentElement.childNodes;
+for (var i = 0; i &lt; childNodes.length; i++) {
+ var child = childNodes[i];
+ // do something with child
+}
+</pre>
+ <p>    变量 <code><a href="../../../../en/DOM/element.childNodes" rel="internal">childNodes</a></code> 保存着文档根节点的全部子节点。然后像处理数组一样用一个 for 循环枚举全部元素。</p>
+ <div class="highlight">
+ Find files example so far: <span class="lang lang-en"><a class="external" href="http://developer.mozilla.org/samples/xultu/examples//findfile/findfile-dom.xul.txt" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples//findfile/findfile-dom.xul.txt">Source</a> <a class="external" href="http://developer.mozilla.org/samples/xultu/examples//findfile/findfile-dom.xul" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples//findfile/findfile-dom.xul">View</a> </span></div>
+ <p><small>See also: <a href="../../../../en/A_re-introduction_to_JavaScript" rel="internal">A re-introduction to JavaScript</a> and the <a href="../../../../en/Core_JavaScript_1.5_Reference" rel="internal">JavaScript reference</a></small></p>
+ <p>    下一章学习修改DOM <a href="../../../../en/XUL_Tutorial/Modifying_a_XUL_Interface" rel="internal">modify the DOM</a>.</p>
+ <p> </p>
+ <div class="prevnext">
+ <p><span style="float: left;">« <a href="../../../../en/XUL_Tutorial/Broadcasters_and_Observers" rel="internal">Previous</a></span> <span style="float: right;"><a href="../../../../en/XUL_Tutorial/Modifying_a_XUL_Interface" rel="internal">Next</a> »</span></p>
+ </div>
+ <p>  </p>
+ <p> </p>
+ </div>
+ </div>
+</div>
+<div class="printfooter" id="printfooter">
+ <hr>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/element_positioning/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/element_positioning/index.html
new file mode 100644
index 0000000000..df6c75dee6
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/element_positioning/index.html
@@ -0,0 +1,254 @@
+---
+title: XUL_教程/元素定位
+slug: Mozilla/Tech/XUL/Tutorial/Element_Positioning
+tags:
+ - XUL_Tutorial
+translation_of: Archive/Mozilla/XUL/Tutorial/Element_Positioning
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:The_Box_Model" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Box_Model_Details">下一页 »</a></p>
+</div><p></p>
+
+<h2 id=".E5.88.86.E7.BB.84.E5.85.83.E7.B4.A0.E5.AE.9A.E4.BD.8D" name=".E5.88.86.E7.BB.84.E5.85.83.E7.B4.A0.E5.AE.9A.E4.BD.8D">分组元素定位</h2>
+
+<p>迄今为止, 我们知道怎么在一个分组里面将元素进行水平或垂直定位。我们通常需要在分组内对元素的定位和尺寸进行更多的控制。为此,我们首先需要知道一个分组是怎么工作的。</p>
+
+<p>一个元素的定位由他所属容器的布局样式决定。例如,在水平分组中的一个按钮在前面的按钮的右边。一个元素的尺寸由两个因素决定:元素期望的大小和用户指定的大小。元素期望的大小由该元素所包含的内容决定。例如,一个按钮的宽度由按钮上所显示文本的长度决定。</p>
+
+<p>一般来说元素的大小仅够容纳它的内容。一些元素,像文本输入框会使用一个默认的尺寸。分组会分配足够的尺寸去将元素放在它里面。一个包括三个按钮的水平分组将会包含比三个按钮更多的宽度,插入一些填充。</p>
+
+<div class="float-right"><img alt="Image:boxstyle1n.png" class="internal" src="/@api/deki/files/2649/=Boxstyle1n.png"></div>
+
+<p>在图片中,开始两个按钮为它们的文本提供了合适的尺寸。第三个按钮比较长因为它包含更多的内容。分组的宽度包含按钮间的填充空间和按钮的宽度总和。按钮的高度采用能够放置它的文本的合适尺寸。</p>
+
+<h3 id=".E5.AE.BD.E5.BA.A6.E5.92.8C.E9.AB.98.E5.BA.A6.E5.B1.9E.E6.80.A7" name=".E5.AE.BD.E5.BA.A6.E5.92.8C.E9.AB.98.E5.BA.A6.E5.B1.9E.E6.80.A7">宽度和高度属性</h3>
+
+<p>在窗口中你可能需要对元素的尺寸进行更多的控制。有更多的特性允许你去控制元素的尺寸。有一个快捷的方法可以通过在元素中简单添加<code><code id="a-width"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/width">width</a></code></code> 和 <code><code id="a-height"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/height">height</a></code></code> 属性,更像你在HTML中的 <code>img</code> 标签的用法。下面展示了一个例子:</p>
+
+<p><span id="%E4%BE%8B1"><a id="%E4%BE%8B1"></a><strong>例1</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_boxstyle_1.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_boxstyle_1.xul">View</a></p>
+
+<pre>&lt;button label="确认" width="100" height="40"/&gt;
+</pre>
+
+<p>然而,不推荐这样做。这么做适用性不好且可能与某些主题不匹配。一个更好的方法是使用样式表属性,它可以像中HTML中的样式表一样工作。可以使用下面的CSS属性。</p>
+
+<dl>
+ <dt>width </dt>
+ <dd>指定元素的宽度。</dd>
+ <dt>height </dt>
+ <dd>指定元素的高度。</dd>
+</dl>
+
+<p>随便设置这两属性中的一个,元素将会创建它的宽度和高度。如果你只指定一个尺寸属性,另一个需要被算出。这些样式表属性的尺寸可以指定一个数字后面跟着一个单位。</p>
+
+<h4 id=".E5.8F.AF.E4.BC.B8.E7.BC.A9.E5.85.83.E7.B4.A0" name=".E5.8F.AF.E4.BC.B8.E7.BC.A9.E5.85.83.E7.B4.A0">可伸缩元素</h4>
+
+<p>非伸缩元素可以很简单快捷地计算尺寸。它们的宽度和高度可以直接被指定,如果没有指定尺寸,元素的默认尺寸就是刚好能放下它的内容的大小。对于可伸缩元素,计算需要一点窍门。</p>
+
+<p>可伸缩元素有一个可以设置为大于0的属性<code><code id="a-flex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flex">flex</a></code></code>。被用来设置在可伸缩性元素中可以扩展和收缩的有用填充空间。它们的默认尺寸可以像非伸缩元素一样被计算。下面的例子做了这个的演示:</p>
+
+<p><span id="%E4%BE%8B2"><a id="%E4%BE%8B2"></a><strong>例2</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_boxstyle_2.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_boxstyle_2.xul">View</a></p>
+
+<pre>&lt;window orient="horizontal"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;
+
+&lt;hbox&gt;
+ &lt;button label="Yes" flex="1"/&gt;
+ &lt;button label="No"/&gt;
+ &lt;button label="I really don't know one way or the other"/&gt;
+&lt;/hbox&gt;
+
+&lt;/window&gt;
+</pre>
+
+<p>这个窗口会像之前的图片所显示的一样。前面两个按钮将一个合适尺寸作为默认宽度,第三个按钮将会比较大因为它有一个较长的标签。第一个按钮被建成是可伸缩的,并且将所有的三元素放在一个分组里面。分组的宽度被设置成全部三个元素的总宽度(图片的宽度大约是430像素)。</p>
+
+<p>如果你增加窗口的宽度,元素会被检查清楚它们是否是可伸缩的,然后被分配到填充的空白空间。按钮只是可伸缩元素,但它不会增加宽度。这是因为按钮所在的分组不是可伸缩的。一个非伸缩元素在空间有效时也不会改变尺寸,所以按钮不会比其他情况下变得更宽。因此,按钮不会变得更宽。</p>
+
+<p>这个解决方案也用于创建可伸缩性的分组。于是,当你创建一个更宽的窗口时,因此分组会伸长以便填充多余的空间。因为分组比较大,更多的空余空间可以被放在它里面,放在它里面的可伸缩按钮可以填充有效空间而得到扩展。这会被许多内嵌的分组重复处理。</p>
+
+<h2 id=".E8.AE.BE.E7.BD.AE.E6.9C.80.E5.B0.8F.E5.92.8C.E6.9C.80.E5.A4.A7.E5.B0.BA.E5.AF.B8" name=".E8.AE.BE.E7.BD.AE.E6.9C.80.E5.B0.8F.E5.92.8C.E6.9C.80.E5.A4.A7.E5.B0.BA.E5.AF.B8">设置最小和最大尺寸</h2>
+
+<p>你可以允许一个元素能够扩展但限制它的尺寸不能比一个确定的尺寸更大。或者,你可设置一个最小尺寸。你可以通过以下四个属性来达到这个目的:</p>
+
+<dl>
+ <dt><code id="a-minwidth"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/minwidth">minwidth</a></code> </dt>
+ <dd>指定元素的最小宽度。</dd>
+ <dt><code id="a-minheight"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/minheight">minheight</a></code> </dt>
+ <dd>指定元素的最小高度。</dd>
+ <dt><code id="a-maxwidth"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/maxwidth">maxwidth</a></code> </dt>
+ <dd>指定元素的最大宽度。</dd>
+ <dt><code id="a-maxheight"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/maxheight">maxheight</a></code> </dt>
+ <dd>指定元素的最大高度。</dd>
+</dl>
+
+<p>这个值的单位是像素。你也可以使用相应的CSS属性:<code>min-width</code>, <code>min-height</code>, <code>max-width</code> 和 <code>max-height</code>。</p>
+
+<p>这些属性只可以用于可伸缩元素。例如,设置一个最大高度,一个可伸缩的按钮将只能扩展到一个 确定的最大高度。你可以更改窗口的尺寸超过这个值但按钮会在指定的尺寸停止扩展。分组中的按钮将会一直扩展到你设置的分组最大高度时止。</p>
+
+<p>如果两个按钮都具有相等的弹性值,普通情况下它们两个会共享相同的多余空间。如果一个按钮有一个最大宽度,第二个将会一直扩展直到用光所有的空间为止。</p>
+
+<p>如果一个分组有一个最大宽度或高度,子分组不会扩展超出它的最大尺寸。如果一个分组有一个最小宽度或高度,它的子分组不能缩小到比它的最小尺寸更小。</p>
+
+<h5 id=".E8.AE.BE.E7.BD.AE.E5.AE.BD.E5.BA.A6.E5.92.8C.E9.AB.98.E5.BA.A6.E7.9A.84.E4.BE.8B.E5.AD.90" name=".E8.AE.BE.E7.BD.AE.E5.AE.BD.E5.BA.A6.E5.92.8C.E9.AB.98.E5.BA.A6.E7.9A.84.E4.BE.8B.E5.AD.90">设置宽度和高度的例子</h5>
+
+<pre>&lt;button label="1" style="width: 100px;"/&gt;
+&lt;button label="2" style="width: 100em; height: 10px;"/&gt;
+&lt;button label="3" flex="1" style="min-width: 50px;"/&gt;
+&lt;button label="4" flex="1" style="min-height: 2ex; max-width: 100px"/&gt;
+&lt;textbox flex="1" style="max-width: 10em;"/&gt;
+&lt;description style="max-width: 50px"&gt;This is some boring but simple
+wrapping text.&lt;/description&gt;
+</pre>
+
+<dl>
+ <dt>例1 </dt>
+ <dd>第一个按钮将显示成宽度为100像素的(px 的意思是像素)。你必须增加单位否则宽度将被忽略。</dd>
+ <dt>例2 </dt>
+ <dd>第二个按钮将显示成高度为10像素和宽度为100em(em是当前字体一个字符的尺寸)。</dd>
+ <dt>例3 </dt>
+ <dd>第三个按钮是可伸缩的所以它可以基于包含它的分组的尺寸进行扩展。然而,按钮不能收缩到比50像素更小。其它可伸缩组件像定位格可以吸收保留空间,而不管弹性比率。</dd>
+ <dt>例4 </dt>
+ <dd>第四个按钮是可伸缩的并且不能有一个比2ex(ex是当前字体中的字母x的高度)小的高度或比100像素更大的宽度。</dd>
+ <dt>例5 </dt>
+ <dd>文本输入框是可伸缩的但不能扩展超过10em。你会经常去使用em单位作为指定文本内容它们的尺寸。这个单位用于文本输入框因此字体可以更改并且文本输入框可以一直有个合适的尺寸,如果字体非常大时也一样。</dd>
+ <dt>例6 </dt>
+ <dd><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/description" title="description">description</a></code></code> 元素包含50像素的最大宽度。在50像素后,文本会自动被截到下一行。</dd>
+</dl>
+
+<div class="highlight">
+<h5 id=".E6.88.91.E4.BB.AC.E7.9A.84.E6.96.87.E4.BB.B6.E6.9F.A5.E6.89.BE.E5.AF.B9.E8.AF.9D.E6.A1.86" name=".E6.88.91.E4.BB.AC.E7.9A.84.E6.96.87.E4.BB.B6.E6.9F.A5.E6.89.BE.E5.AF.B9.E8.AF.9D.E6.A1.86">我们的文件查找对话框</h5>
+
+<p>让我们将这些样式增加到文件查找对话框。我们将会创建它因此文本输入框可以在输入窗口中改变尺寸。</p>
+
+<pre>&lt;textbox id="find-text" flex="1" style="min-width: 15em;"/&gt;
+</pre>
+
+<div class="float-right"><img alt="Image:boxstyle1.png" class="internal" src="/@api/deki/files/2648/=Boxstyle1.png"></div>
+在这里,文本输入框被做成可伸缩的。这样,它可以在用户改变对话框的尺寸时进行扩展。这可以用于如果用户想要输入一个很长的文本字符串时。通常地,设置了一个最小宽度为15em则输入框会一直显示为至少15个字符的宽度。如果用户更改对话框的尺寸到很小,文本输入框不会缩小超过15个字符长度。在窗口里面的输入框将会被画出来,并超出窗口的范围。注解:在图片中文本输入框被扩展为充满窗口的尺寸。</div>
+
+<h2 id="Box_Packing" name="Box_Packing">Box Packing</h2>
+
+<p>Let's say you have a box with two child elements, both of which are not flexible, but the box is flexible. For example:</p>
+
+<p><span id="Example_3"><a id="Example_3"></a><strong>Example 3</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_boxstyle_3.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_boxstyle_3.xul">View</a></p>
+
+<pre>&lt;box flex="1"&gt;
+ &lt;button label="Happy"/&gt;
+ &lt;button label="Sad"/&gt;
+&lt;/box&gt;
+</pre>
+
+<p>If you resize the window, the box will stretch to fit the window size. The buttons are not flexible, so they will not change their widths. The result is extra space that will appear on the right side of the window, inside the box. You may wish, however, for the extra space to appear on the left side instead, so that the buttons stay right aligned in the window.</p>
+
+<p>You could accomplish this by placing a <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/spacer" title="spacer">spacer</a></code></code> inside the box, but that gets messy when you have to do it numerous times. A better way is to use an additional attribute <code><code id="a-pack"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/pack">pack</a></code></code> on the <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/box" title="box">box</a></code></code>. This attribute indicates how to <code><code id="a-pack"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/pack">pack</a></code></code> the child elements inside the box. For horizontally oriented boxes, it controls the horizonal positioning of the children. For vertically oriented boxes, it controls the vertical positioning of the children. You can use the following values:</p>
+
+<dl>
+ <dt>start </dt>
+ <dd>This positions elements at the left edge for horizontal boxes and at the top edge for vertical boxes. This is the default value.</dd>
+ <dt>center </dt>
+ <dd>This centers the child elements in the box.</dd>
+ <dt>end </dt>
+ <dd>This positions elements at the right edge for horizontal boxes and at the bottom edge for vertical boxes.</dd>
+</dl>
+
+<p>The <code><code id="a-pack"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/pack">pack</a></code></code> attribute applies to the box containing the elements to be packed, not to the elements themselves.</p>
+
+<p>We can change the earlier example to center the elements as follows:</p>
+
+<p><span id="Example_4"><a id="Example_4"></a><strong>Example 4</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_boxstyle_4.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_boxstyle_4.xul">View</a></p>
+
+<pre>&lt;box flex="1" pack="center"&gt;
+ &lt;button label="Happy"/&gt;
+ &lt;button label="Sad"/&gt;
+&lt;/box&gt;
+</pre>
+
+<p>Now, when the window is resized, the buttons center themselves horizontally. Compare this behavior to that of the previous example.</p>
+
+<h2 id="Box_Alignment" name="Box_Alignment">Box Alignment</h2>
+
+<p>If you resize the window in the Happy-Sad example above horizontally, the box will grow in width. If you resize the window vertically however, you will note that the buttons grow in height. This is because the flexibility is assumed by default in the other direction.</p>
+
+<p>You can control this behavior with the <code><code id="a-align"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/align">align</a></code></code> attribute. For horizontal boxes, it controls the position of the children vertically. For vertical boxes, it controls the position of the children horizontally. The possible values are similar to those for <code><code id="a-pack"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/pack">pack</a></code></code>.</p>
+
+<dl>
+ <dt>start </dt>
+ <dd>This aligns elements along the top edge for horizontal boxes and along the left edge for vertical boxes.</dd>
+ <dt>center </dt>
+ <dd>This centers the child elements in the box.</dd>
+ <dt>end </dt>
+ <dd>This aligns elements along the bottom edge for horizontal boxes and along the right edge for vertical boxes.</dd>
+ <dt>baseline </dt>
+ <dd>This aligns the elements so that the text lines up. This is only useful for horizontal boxes.</dd>
+ <dt>stretch </dt>
+ <dd>This value, the default, causes the elements to grow to fit the size of the box, much like a flexible element, but in the opposite direction.</dd>
+</dl>
+
+<p>As with the <code><code id="a-pack"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/pack">pack</a></code></code> attribute, the <code><code id="a-align"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/align">align</a></code></code> attribute applies to the box containing the elements to be aligned, not to the elements themselves.</p>
+
+<p>For example, the first box below will have its children stretch, because that is the default. The second box has an <code><code id="a-align"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/align">align</a></code></code> attribute, so its children will be placed centered.</p>
+
+<p><span id="Example_5"><a id="Example_5"></a><strong>Example 5</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_boxstyle_5.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_boxstyle_5.xul">View</a></p>
+
+<pre>&lt;?xml version="1.0"?&gt;
+&lt;?xml-stylesheet href="chrome://global/skin/" type="text/css"?&gt;
+
+&lt;window id="yesno" title="Question" orient="horizontal"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;
+
+ &lt;hbox&gt;
+ &lt;button label="Yes"/&gt;
+ &lt;button label="No"/&gt;
+ &lt;/hbox&gt;
+ &lt;hbox align="center"&gt;
+ &lt;button label="Maybe"/&gt;
+ &lt;button label="Perhaps"/&gt;
+ &lt;/hbox&gt;
+
+&lt;/window&gt;
+</pre>
+
+<div class="float-right"><img alt="Image:boxstyle2-b.png" class="internal" src="/@api/deki/files/2650/=Boxstyle2-b.png"></div>
+
+<p>You can also use the style properties <code><a href="/cn/CSS/-moz-box-pack" title="cn/CSS/-moz-box-pack">-moz-box-pack</a></code> and <code><a href="/cn/CSS/-moz-box-align" title="cn/CSS/-moz-box-align">-moz-box-align</a></code> instead of specifying attributes.</p>
+
+<div class="note">You may find the <a class="external" href="http://developer.mozilla.org/samples/xultu/examples/aligner.xul">Box Alignment Example</a> useful for trying out the various box properties.</div>
+
+<h2 id="Cropping_Text_and_Buttons" name="Cropping_Text_and_Buttons">Cropping Text and Buttons</h2>
+
+<p>You could potentially create a button element that contains a label that is larger than the maximum width of the button. Of course, a solution would be to increase the size of the button. However, buttons (and other elements with a label) have a special attribute called <code>crop</code> that allows you to specify how the text may be cropped if it is too big.</p>
+
+<p>If the text is cropped, an ellipsis (...) will appear on the button where the text was taken out. Four possible values are valid:</p>
+
+<dl>
+ <dt>left </dt>
+ <dd>The text is cropped on its left side</dd>
+ <dt>right </dt>
+ <dd>The text is cropped on its right side</dd>
+ <dt>center </dt>
+ <dd>The text is cropped in the middle.</dd>
+ <dt>none </dt>
+ <dd>The text is not cropped. This is the default value.</dd>
+</dl>
+
+<p>This attribute is really only useful when a dialog has been designed to be useful at any size. The <code>crop</code> attribute can also be used with other elements that use the <code>label</code> attribute for labels. The following shows this attribute in use:</p>
+
+<p><span id="Example_6"><a id="Example_6"></a><strong>Example 6</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_boxstyle_6.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_boxstyle_6.xul">View</a></p>
+
+<div class="float-right"><img alt="Image:boxstyle2.png" class="internal" src="/@api/deki/files/2651/=Boxstyle2.png"></div>
+
+<pre>&lt;button label="Push Me Please!" crop="right" flex="1"/&gt;
+</pre>
+
+<p>Notice how the text on the button has had the right side of it cropped after the window is made smaller.</p>
+
+<div class="highlight">
+<p><span id="Find_files_example_so_far"><a id="Find_files_example_so_far"></a><strong>Find files example so far</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/findfile/findfile-boxstyle.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/findfile/findfile-boxstyle.xul">View</a></p>
+</div>
+
+<p>Next, a summary and some <a href="/cn/XUL_Tutorial/Box_Model_Details" title="cn/XUL_Tutorial/Box_Model_Details">additional details of the box model are described</a>.</p>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:The_Box_Model" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Box_Model_Details">下一页 »</a></p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/features_of_a_window/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/features_of_a_window/index.html
new file mode 100644
index 0000000000..cae533b206
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/features_of_a_window/index.html
@@ -0,0 +1,6 @@
+---
+title: Features of a Window
+slug: Mozilla/Tech/XUL/Tutorial/Features_of_a_Window
+translation_of: Archive/Mozilla/XUL/Tutorial/Features_of_a_Window
+---
+<p>This page has no content. Enrich MDC by contributing.</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/grids/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/grids/index.html
new file mode 100644
index 0000000000..47201b797c
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/grids/index.html
@@ -0,0 +1,175 @@
+---
+title: 网格
+slug: Mozilla/Tech/XUL/Tutorial/Grids
+translation_of: Archive/Mozilla/XUL/Tutorial/Grids
+---
+<p>XUL有一系列的元素来创建表格布局</p>
+<h3 id="XUL的表格布局"> XUL的表格布局</h3>
+<p>使用grid元素可以在XUL中使用一系列的元素来进行元素的布局。这与HTML中的table有很大的相似性。网格本身不会有任何的显示,它仅仅是使用行和列的形式来定位其他元素。</p>
+<p>一个网格内部的元素排列成行。在grid里面,你需要声明两种东西,columns和rows。正如HTML的table,你可以将label和button等内容放在row里面。但是,grid只支持单独的row或者单独的column,因此你可以将内容放在rows里面或者columns里面。通常是使用rows。但是在grid中你还是可以使用column并制定其大小和显示方式。或者你可以将内容放在columns里面,然后用row来指定其显示方式。首先看看以row的方式组织元素的方法。</p>
+<h4 id="声明一个网格">声明一个网格</h4>
+<p>使用rows标签来声明一系列的row。Rows必须是grid的子元素。在rows里面你可以添加row元素,row用在每一行。在row元素中你可以放任何你想要的内容在里面。</p>
+<p>相似的,列由columns来声明。其中有单独的column元素,每个你想添加的列都是一个column元素。</p>
+<p>用一个例子更容易理解。</p>
+<p>例子1:</p>
+<p><img alt=""></p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;grid flex="1"&gt;</p>
+ <p>  &lt;columns&gt;</p>
+ <p>    &lt;column flex="2"/&gt;</p>
+ <p>    &lt;column flex="1"/&gt;</p>
+ <p>  &lt;/columns&gt;</p>
+ <p>  &lt;rows&gt;</p>
+ <p>    &lt;row&gt;</p>
+ <p>      &lt;button label="Rabbit"/&gt;</p>
+ <p>      &lt;button label="Elephant"/&gt;</p>
+ <p>    &lt;/row&gt;</p>
+ <p>    &lt;row&gt;</p>
+ <p>      &lt;button label="Koala"/&gt;</p>
+ <p>      &lt;button label="Gorilla"/&gt;</p>
+ <p>    &lt;/row&gt;</p>
+ <p>  &lt;/rows&gt;</p>
+ <p>&lt;/grid&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>添加了一个两行两列的grid。每个列由一个column标签声明。每一列都设置了flex属性。每行航油两个元素都是半年。每个单元格不需要进行声明,可以直接将内容放在row元素里面。</p>
+<h4 id="带有更多元素的网格">带有更多元素的网格</h4>
+<p>你可以使用任何元素来代替上面的button元素,。如果你想要一个详细的关于容纳多个元素的单元,你可以使用嵌套的hbox或者其他box元素。一个hbox元素是一个单一的元素,但是你可以在里面放任意多的元素。例如:</p>
+<p>例子2:</p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;grid flex="1"&gt;</p>
+ <p> </p>
+ <p>  &lt;columns&gt;</p>
+ <p>    &lt;column/&gt;</p>
+ <p>    &lt;column flex="1"/&gt;</p>
+ <p>  &lt;/columns&gt;</p>
+ <p> </p>
+ <p>  &lt;rows&gt;</p>
+ <p>    &lt;row&gt;</p>
+ <p>      &lt;label control="doctitle" value="Document Title:"/&gt;</p>
+ <p>      &lt;textbox id="doctitle" flex="1"/&gt;</p>
+ <p>    &lt;/row&gt;</p>
+ <p>    &lt;row&gt;</p>
+ <p>      &lt;label control="docpath" value="Path:"/&gt;</p>
+ <p>      &lt;hbox flex="1"&gt;</p>
+ <p>        &lt;textbox id="docpath" flex="1"/&gt;</p>
+ <p>        &lt;button label="Browse..."/&gt;</p>
+ <p>      &lt;/hbox&gt;  </p>
+ <p>    &lt;/row&gt;</p>
+ <p>  &lt;/rows&gt;</p>
+ <p> </p>
+ <p>&lt;/grid&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p><img alt=""></p>
+<p>注意第二列的第二行,含有一个box,box里面有一个文本框和一个按钮。你可以添加嵌套的box或者在里面放置另外一个grid。</p>
+<p>由于第二行和文本框都设置了flex属性,所以改变窗口尺寸的时候文本框会改变大小,而其他元素不会改变。</p>
+<p>一列的宽度由该列中最宽的元素决定。同牙膏的一行的高度由这一行中最高的元素决定。你可以使用minwidth和maxwidth以及相关的属性来对尺寸作更多的定义。</p>
+<h4 id="按列组织">按列组织</h4>
+<p>你也可以在列中添加元素,这样一来,row元素就只是用来表示有多少行了。</p>
+<p>例子3:</p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;grid&gt;</p>
+ <p>  &lt;rows&gt;</p>
+ <p>    &lt;row/&gt;</p>
+ <p>    &lt;row/&gt;</p>
+ <p>    &lt;row/&gt;</p>
+ <p>  &lt;/rows&gt;</p>
+ <p> </p>
+ <p>  &lt;columns&gt;</p>
+ <p>    &lt;column&gt;</p>
+ <p>      &lt;label control="first" value="First Name:"/&gt;</p>
+ <p>      &lt;label control="middle" value="Middle Name:"/&gt;</p>
+ <p>      &lt;label control="last" value="Last Name:"/&gt;</p>
+ <p>    &lt;/column&gt;</p>
+ <p>    &lt;column&gt;</p>
+ <p>      &lt;textbox id="first"/&gt;</p>
+ <p>      &lt;textbox id="middle"/&gt;</p>
+ <p>      &lt;textbox id="last"/&gt;</p>
+ <p>    &lt;/column&gt;</p>
+ <p>  &lt;/columns&gt;</p>
+ <p> </p>
+ <p>&lt;/grid&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>这个网格有桑航两列。元素row仅仅表示有多少行。你可以添加flex属性来使其自适应。内容在每一列中。</p>
+<p>如果你在列和行中都填内容,内容将会相互覆盖,不过他们会在grid中合适的进行排列。就像在网格中有堆元素一样。</p>
+<p>Grid中元素的顺序决定了哪一个会显示在上面,哪一个在下面。如果rows元素放在columns元素后面,在rows中的内容会显示在上面。如果columns放在rows元素后面,列中的内容会显示在上面。事件的获取也一样。</p>
+<h4 id="网格自适应">网格自适应</h4>
+<p>网格的一个优点是在一系列嵌套box中你可以创建在水平和竖直方向上都自适应的单元格。你可以通过使用flex属性在row和column元素上来实现。下面的例子说明了这一点:</p>
+<p>例子4:</p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;grid flex="1"&gt;</p>
+ <p> &lt;columns&gt;</p>
+ <p>  &lt;column flex="5"/&gt;</p>
+ <p>  &lt;column/&gt;</p>
+ <p>  &lt;column/&gt;</p>
+ <p> &lt;/columns&gt;</p>
+ <p> &lt;rows&gt;</p>
+ <p>  &lt;row flex="10"&gt;</p>
+ <p>    &lt;button label="Cherry"/&gt;</p>
+ <p>    &lt;button label="Lemon"/&gt;</p>
+ <p>    &lt;button label="Grape"/&gt;</p>
+ <p>  &lt;/row&gt;</p>
+ <p>  &lt;row flex="1"&gt;</p>
+ <p>    &lt;button label="Strawberry"/&gt;</p>
+ <p>    &lt;button label="Raspberry"/&gt;</p>
+ <p>    &lt;button label="Peach"/&gt;</p>
+ <p>  &lt;/row&gt;</p>
+ <p> &lt;/rows&gt;</p>
+ <p>&lt;/grid&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>第一列和所有两行都设置为自适应。这样的结果是第一列中的单元格在水平方向上自适应,另外每个单元格都会在竖直方向上自适应,因为两行都是自适应的,不过第一行还不止这样。第一列和第一行的单元格将会在水平方向上以5的倍率伸缩,在竖直方向上以10的倍率伸缩。</p>
+<p>元素grid也要设置flex属性,这样所有的网格才能自适应,否则就只会在一个方向上自适应。</p>
+<h3 id="列宽扩展">列宽扩展</h3>
+<p>让很多行和列中的一个单元格扩展是没有意义的。但是可以让一行或者一列整个的扩展。为了实现这一点只需要在rows元素中添加一个元素。比如可以使用一个box样式。让回将其他元素放在里面。下面是一个简单的例子:</p>
+<p>例子5:</p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;grid&gt;</p>
+ <p>  &lt;columns&gt;</p>
+ <p>    &lt;column flex="1"/&gt;</p>
+ <p>    &lt;column flex="1"/&gt;</p>
+ <p>  &lt;/columns&gt;</p>
+ <p> </p>
+ <p>  &lt;rows&gt;</p>
+ <p>    &lt;row&gt;</p>
+ <p>      &lt;label value="Northwest"/&gt;</p>
+ <p>      &lt;label value="Northeast"/&gt;</p>
+ <p>    &lt;/row&gt;</p>
+ <p>    &lt;button label="Equator"/&gt;</p>
+ <p>    &lt;row&gt;</p>
+ <p>      &lt;label value="Southwest"/&gt;</p>
+ <p>      &lt;label value="Southeast"/&gt;</p>
+ <p>    &lt;/row&gt;</p>
+ <p>  &lt;/rows&gt;</p>
+ <p>&lt;/grid&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>按钮将会扩展以适合整个grid的宽带,因为它不是一个grid的行中的元素。你也可以将相似的方式用在两个列中。这样就会扩展以一与网格的高度相适应。你可以在行和列上都使用,如果你想这样做。</p>
+<p>下一节我们来看看内容面板</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/groupboxes/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/groupboxes/index.html
new file mode 100644
index 0000000000..c62dd0f004
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/groupboxes/index.html
@@ -0,0 +1,85 @@
+---
+title: 分组框
+slug: Mozilla/Tech/XUL/Tutorial/Groupboxes
+translation_of: Archive/Mozilla/XUL/Tutorial/Groupboxes
+---
+<p>    本章介绍在组框中添加元素的方法。</p>
+<div id="section_1">
+ <h3 class="editable" id="Groupboxes"><span>Groupboxes </span></h3>
+ <div class="editIcon">
+ <a href="../../../../en/XUL_Tutorial/Groupboxes#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    HTML 通过了 <code>fieldset</code> 元素来使元素分组,一般的会在元素的边上画一个框来显示元素的关系。比如一系列单选按钮。XUL 也通过了 <code><span class="lang lang-en"><a href="../../../../en/XUL/groupbox" rel="internal">groupbox</a> </span></code>元素来完成相似的功能。</p>
+ <p>    就像名字暗示的一样 <code><span class="lang lang-en"><a href="../../../../en/XUL/groupbox" rel="internal">groupbox</a> <span style="font-family: Verdana,Tahoma,sans-serif;">是一类box,这意味着在其中的元素可以安装box指定的形式排列。与一般的box相比groupbox有两点不同。</span></span></code></p>
+ <ul>
+ <li>默认的组框会画出边界,你可以使用 CSS 来改变这种行为。</li>
+ <li>groupbox 支持在边框顶部画出标题。</li>
+ </ul>
+ <p>    因为组框是一种box,你可以使用如 <code><span class="lang lang-en"><a href="../../../../en/XUL/Attribute/orient" rel="internal">orient</a> </span></code>及 <code><span class="lang lang-en"><a href="../../../../en/XUL/Attribute/flex" rel="internal">flex</a> 等属性<span style="font-family: Verdana,Tahoma,sans-serif;">。你可以把任何你想放入box中的元素放入组框中,无论他们有什么关系。</span></span></code></p>
+ <p>    组框顶端的标签使用 <code><span class="lang lang-en"><a href="../../../../en/XUL/caption" rel="internal">caption</a> <span style="font-family: Verdana,Tahoma,sans-serif;">元素创建,类似于</span></span></code> HTML 中的<code>legend</code> 元素,请把 <code><span class="lang lang-en"><a href="../../../../en/XUL/caption" rel="internal">caption</a> </span></code>作为第一个元素放入组框。</p>
+ <div id="section_2">
+ <h4 class="editable" id="一个组框的例子"><span>一个组框的例子 </span></h4>
+ <div class="editIcon">
+ <a href="../../../../en/XUL_Tutorial/Groupboxes#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    下面的例子显示一个简单组框。</p>
+ <p><span class="lang lang-en"><span id="Example_1"><strong>Example 1</strong></span> </span> : <span class="lang lang-en"><a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_titledbox_1.xul.txt" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_titledbox_1.xul.txt">Source</a> <a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_titledbox_1.xul" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_titledbox_1.xul">View</a> </span></p>
+ <div class="float-right">
+ <img alt="Image:titledbox1.png" class="internal" src="../../../../@api/deki/files/891/=Titledbox1.png"></div>
+ <pre>&lt;groupbox&gt;
+ &lt;caption label="Answer"/&gt;
+ &lt;description value="Banana"/&gt;
+ &lt;description value="Tangerine"/&gt;
+ &lt;description value="Phone Booth"/&gt;
+ &lt;description value="Kiwi"/&gt;
+&lt;/groupbox&gt;
+</pre>
+ <p>    以上代码表示:四条文本被一个以 <em>Answer </em>为标签的box框起来,注意组框默认的定向方式为垂直定向,所以元素会排成一列。</p>
+ </div>
+ <div id="section_3">
+ <h4 class="editable" id="更复杂的标题"><span>更复杂的标题</span></h4>
+ <div class="editIcon">
+ <a href="../../../../en/XUL_Tutorial/Groupboxes#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    你可以在 <code><span class="lang lang-en"><a href="../../../../en/XUL/caption" rel="internal">caption</a> <span style="font-family: Verdana,Tahoma,sans-serif;">元素中添加子元素构造一个更复杂的标题,比如,</span></span></code>Mozilla的字体选择面板使用一个下拉菜单作为标题。尽管任何元素都可以在这里使用,通常的是使用下拉菜单和复选框。</p>
+ <p><span class="lang lang-en"><span id="Example_2"><strong>Example 2</strong></span> </span> : <span class="lang lang-en"><a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_titledbox_2.xul.txt" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_titledbox_2.xul.txt">Source</a> <a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_titledbox_2.xul" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_titledbox_2.xul">View</a> </span></p>
+ <div class="float-right">
+ <img alt="Image:groupbox2.png" class="internal" src="../../../../@api/deki/files/706/=Groupbox2.png"></div>
+ <pre>&lt;groupbox flex="1"&gt;
+ &lt;caption&gt;
+ &lt;checkbox label="Enable Backups"/&gt;
+ &lt;/caption&gt;
+ &lt;hbox&gt;
+ &lt;label control="dir" value="Directory:"/&gt;
+ &lt;textbox id="dir" flex="1"/&gt;
+ &lt;/hbox&gt;
+ &lt;checkbox label="Compress archived files"/&gt;
+&lt;/groupbox&gt;
+</pre>
+ <p><br>
+     这个例子里一个 <a href="../../../../en/XUL_Tutorial/Input_Controls#Checkboxes_and_Radio_Buttons" rel="internal">checkbox</a> 被作为标题。我看可以根据复选框是否被选中,使用脚本来控制组框中的元素是否有效。组框中包含了一个有 <span class="lang lang-en"><a href="../../../../en/XUL/label" rel="internal">label</a> 和</span> <span class="lang lang-en"><a href="../../../../en/XUL/textbox" rel="internal">textbox</a> </span>的水平框,文本框和组框均被设定为是可变的,所以元素会随着窗口延伸。复选框出现在组框底下是因为组框默认为垂直定向。下一章我们为find files 对话框添加一个组框。</p>
+ </div>
+</div>
+<div id="section_4">
+ <h3 class="editable" id="单选组"><span>单选组</span></h3>
+ <div class="editIcon">
+ <a href="../../../../en/XUL_Tutorial/Groupboxes#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    你可以使用 <code><span class="lang lang-en"><a href="../../../../en/XUL/radiogroup" rel="internal">radiogroup</a> <span style="font-family: Verdana,Tahoma,sans-serif;">把单选按钮组织在一起。</span></span></code> <code><span class="lang lang-en"><a href="../../../../en/XUL/radiogroup" rel="internal">radiogroup</a> </span></code>是一种box,你可以在其中放置任何元素,并且他对 <code><span class="lang lang-en"><a href="../../../../en/XUL/radio" rel="internal">radio</a> <span style="font-family: Verdana,Tahoma,sans-serif;">按钮具有特殊的处理。</span></span></code></p>
+ <p>    那些放在单选组里的单选按钮会被组织起来,即使它在其他的box中 。也可添加额外的元素,如下例:</p>
+ <p><span class="lang lang-en"><span id="Example_3"><strong>Example 3</strong></span> </span> : <span class="lang lang-en"><a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_titledbox_3.xul.txt" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_titledbox_3.xul.txt">Source</a> <a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_titledbox_3.xul" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_titledbox_3.xul">View</a> </span></p>
+ <pre>&lt;radiogroup&gt;
+ &lt;radio id="no" value="no" label="No Number"/&gt;
+ &lt;radio id="random" value="random" label="Random Number"/&gt;
+ &lt;hbox&gt;
+ &lt;radio id="specify" value="specify" label="Specify Number:"/&gt;
+ &lt;textbox id="specificnumber"/&gt;
+ &lt;/hbox&gt;
+&lt;/radiogroup&gt;
+</pre>
+ <p>    注意 <code><span class="lang lang-en"><a href="../../../../en/XUL/radiogroup" rel="internal">radiogroup</a> <span style="font-family: Verdana,Tahoma,sans-serif;">不会画出边框。如果需要边框及标题请放置在</span></span></code> <code><span class="lang lang-en"><a href="../../../../en/XUL/groupbox" rel="internal">groupbox</a> <span style="font-family: Verdana,Tahoma,sans-serif;">中。</span></span></code></p>
+ <p>    接下来,我们使用学到的新知识来为findfile对话框添加元素。<a href="../../../../en/XUL_Tutorial/Adding_More_Elements" rel="internal">(additional elements to the find files dialog</a>.)</p>
+ <p> </p>
+ <div class="prevnext">
+ <p><span style="float: left;">« <a href="../../../../en/XUL_Tutorial/Box_Model_Details" rel="internal">Previous</a></span> <span style="float: right;"><a href="../../../../en/XUL_Tutorial/Adding_More_Elements" rel="internal">Next</a> »</span></p>
+ </div>
+ <p>  </p>
+ <p> </p>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/index.html
new file mode 100644
index 0000000000..a164d16f7f
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/index.html
@@ -0,0 +1,171 @@
+---
+title: XUL 教程
+slug: Mozilla/Tech/XUL/Tutorial
+tags:
+ - XUL
+ - XUL_Tutorial
+translation_of: Archive/Mozilla/XUL/Tutorial
+---
+<p>
+ 这份XUL的教程是源自 <a class="external" href="http://www.xulplanet.com/ndeakin/">Neil Deakin</a>之手。很感谢他能给MDC授权使用这篇文章。</p>
+
+<p>这篇教程会教你如何开发和设计基于<a href="/cn/XUL" title="cn/XUL">XUL</a>(<a href="/cn/XML" title="cn/XML">XML</a> User-interface Language XML用户交互语言)的应用程序. XUL是Mozilla创建的并且应用在Mozilla的应用程序的界面描述语言。</p>
+
+<h5 id=".E7.AC.AC.E4.B8.80.E7.AB.A0__.E5.BC.95.E8.A8.80" name=".E7.AC.AC.E4.B8.80.E7.AB.A0__.E5.BC.95.E8.A8.80">第一章 引言</h5>
+
+<ul>
+ <li><a href="Tutorial/Introduction">引言</a></li>
+ <li><a href="Tutorial/XUL_Structure" title="cn/XUL_教程/1-2_XUL的结构">XUL的结构</a></li>
+ <li><a class="external" href="Tutorial/The_Chrome_URL" title="关于Chrome URL">关于Chrome URL</a></li>
+ <li><a href="Tutorial/Manifest_Files" title="cn/XUL_教程/1-4_关于Manifest文件">关于Manifest文件</a></li>
+</ul>
+
+<h5 id=".E7.AE.80.E5.8D.95.E7.9A.84.E7.A4.BA.E4.BE.8B" name=".E7.AE.80.E5.8D.95.E7.9A.84.E7.A4.BA.E4.BE.8B">简单的示例</h5>
+
+<ul>
+ <li><a href="Tutorial/Creating_a_Window" title="cn/XUL_教程/创建一个窗口">创建一个窗口</a></li>
+ <li><a href="/cn/XUL_教程/增加一些按钮" title="cn/XUL_教程/增加一些按钮">增加一些按钮</a></li>
+ <li><a href="/cn/XUL_教程/增加标签和图像" title="cn/XUL_教程/增加标签和图像">增加标签和图像</a></li>
+ <li><a href="/cn/XUL_教程/输入控件" title="cn/XUL_教程/输入控件">输入控件</a></li>
+ <li><a href="/cn/XUL_教程/数值控件" title="cn/XUL 教程/数值控件">数值控件</a></li>
+ <li><a href="/cn/XUL_教程/列表控件" title="cn/XUL_教程/列表控件">列表控件 </a></li>
+ <li><a href="/cn/XUL_教程/进度条" title="cn/XUL_教程/进度条">进度条</a></li>
+ <li><a href="/cn/XUL_教程/增加HTML元素" title="cn/XUL_教程/增加HTML元素">增加HTML元素</a></li>
+ <li><a href="/cn/XUL_教程/使用定位格" title="cn/XUL_教程/使用定位格">使用定位格</a></li>
+ <li><a href="/cn/XUL_教程/更多的按钮特性" title="cn/XUL_教程/更多的按钮特性">更多的按钮特性</a></li>
+</ul>
+
+<h5 id=".E7.9B.92.E6.A8.A1.E5.9E.8B" name=".E7.9B.92.E6.A8.A1.E5.9E.8B">箱模型</h5>
+
+<ul>
+ <li><a href="/cn/XUL_教程/分组方式" title="cn/XUL_教程/分组方式">分组方式</a></li>
+ <li><a href="/cn/XUL_教程/元素定位" title="cn/XUL_教程/元素定位">元素定位</a></li>
+ <li><a href="/Cn/XUL_教程/分组细节" title="cn/XUL_教程/分组细节">分组细节</a></li>
+ <li><a href="/Cn/XUL_教程/分组框" title="cn/XUL_教程/分组框">分组框</a></li>
+ <li><a href="/Cn/XUL_教程/增加更多的元素" title="cn/XUL_教程/增加更多的元素">增加更多的元素</a></li>
+</ul>
+
+<h5 id=".E6.9B.B4.E5.A4.9A.E7.9A.84.E5.B8.83.E5.B1.80.E5.85.83.E7.B4.A0" name=".E6.9B.B4.E5.A4.9A.E7.9A.84.E5.B8.83.E5.B1.80.E5.85.83.E7.B4.A0">更多的布局元素</h5>
+
+<ul>
+ <li><a href="/Cn/XUL_教程/层和卡片" title="cn/XUL_教程/层和卡片">层和卡片</a></li>
+ <li><a href="/cn/XUL_教程/定位层" title="cn/XUL_教程/定位层">定位层</a></li>
+ <li><a href="/cn/XUL_教程/分页组" title="cn/XUL_教程/分页组">分页组</a></li>
+ <li><a href="/cn/XUL_教程/表格" title="cn/XUL_教程/表格">表格</a></li>
+ <li><a href="/Cn/XUL_教程/内容面板" title="cn/XUL_教程/内容面板">内容面板</a></li>
+ <li><a href="/cn/XUL_教程/Splitters" title="cn/XUL_教程/Splitters">Splitters</a></li>
+ <li><a href="/Cn/XUL_教程/滚动栏" title="cn/XUL_教程/滚动栏">滚动栏</a></li>
+</ul>
+
+<h5 id=".E5.B7.A5.E5.85.B7.E6.A0.8F.E5.92.8C.E8.8F.9C.E5.8D.95" name=".E5.B7.A5.E5.85.B7.E6.A0.8F.E5.92.8C.E8.8F.9C.E5.8D.95">工具栏和菜单</h5>
+
+<ul>
+ <li><a href="/cn/XUL_教程/工具栏" title="cn/XUL_教程/工具栏">工具栏</a></li>
+ <li><a href="/cn/XUL_教程/简单菜单栏" title="cn/XUL_教程/简单菜单栏">简单菜单栏</a></li>
+ <li><a href="/cn/XUL_教程/更多菜单特性" title="cn/XUL_教程/更多菜单特性">更多菜单特性</a></li>
+ <li><a href="/cn/XUL_教程/弹出菜单" title="cn/XUL_教程/弹出菜单">弹出菜单</a></li>
+ <li><a href="/cn/XUL_教程/滚动菜单" title="cn/XUL_教程/滚动菜单">滚动菜单</a></li>
+</ul>
+
+<h5 id=".E4.BA.8B.E4.BB.B6.E5.92.8C.E8.84.9A.E6.9C.AC" name=".E4.BA.8B.E4.BB.B6.E5.92.8C.E8.84.9A.E6.9C.AC">事件和脚本</h5>
+
+<ul>
+ <li><a href="/cn/XUL_教程/添加事件处理器" title="cn/XUL_教程/添加事件处理器">添加事件处理器</a></li>
+ <li><a href="/Cn/XUL_教程/其他事件处理器" title="cn/XUL_教程/其他事件处理器">其他事件处理器</a></li>
+ <li><a href="/cn/XUL_教程/键盘的快捷键" title="cn/XUL_教程/键盘的快捷键">键盘的快捷键</a></li>
+ <li><a href="/cn/XUL_教程/焦点和选择" title="cn/XUL_教程/焦点和选择">焦点和选择 Focus and Selection</a></li>
+ <li><a href="/cn/XUL_教程/命令" title="cn/XUL_教程/命令">命令 Commands</a></li>
+ <li><a href="/cn/XUL_教程/更新操作" title="cn/XUL_教程/更新操作">更新操作</a></li>
+ <li><a href="/cn/XUL_教程/广播和监听器" title="cn/XUL_教程/广播和监听器">广播和监听器 Broadcasters and Observers</a></li>
+</ul>
+
+<h5 id=".E6.96.87.E6.A1.A3.E5.AF.B9.E8.B1.A1.E6.A8.A1.E5.9E.8B" name=".E6.96.87.E6.A1.A3.E5.AF.B9.E8.B1.A1.E6.A8.A1.E5.9E.8B">文档对象模型</h5>
+
+<ul>
+ <li><a href="/cn/XUL_教程/文档对象模型" title="cn/XUL_教程/文档对象模型">文档对象模型 Document Object Model</a></li>
+ <li><a href="/cn/XUL_教程/修改XUL界面" title="cn/XUL_教程/修改XUL界面">修改XUL界面 Modifying a XUL Interface</a></li>
+ <li><a href="/cn/XUL_教程/使用列表" title="cn/XUL_教程/使用列表">使用列表 Manipulating Lists</a></li>
+ <li><a href="/cn/XUL_教程/Box对象" title="cn/XUL_教程/Box对象">Box对象 Box Objects</a></li>
+ <li><a href="/Cn/XUL_教程/XPCOM_接口" title="cn/XUL_教程/XPCOM_接口">XPCOM 接口 XPCOM Interfaces</a></li>
+ <li><a href="/cn/XUL_教程/XPCOM_示例" title="cn/XUL_教程/XPCOM_示例">XPCOM 示例 XPCOM Examples</a></li>
+</ul>
+
+<h5 id=".E6.A0.91" name=".E6.A0.91">树</h5>
+
+<ul>
+ <li><a href="/cn/XUL_教程/Trees" title="cn/XUL_教程/Trees">树</a></li>
+ <li><a href="/cn/XUL_教程/More_Tree_Features" title="cn/XUL_教程/More_Tree_Features">更多树的特性</a></li>
+ <li><a href="/cn/XUL_教程/Tree_Selection" title="cn/XUL_教程/Tree_Selection">Tree Selection</a></li>
+ <li><a href="/cn/XUL_教程/Custom_Tree_Views" title="cn/XUL_教程/Custom_Tree_Views">Custom Tree Views</a></li>
+ <li><a href="/cn/XUL_教程/Tree_View_Details" title="cn/XUL_教程/Tree_View_Details">Tree View Details</a></li>
+ <li><a href="/cn/XUL_教程/Tree_Box_Objects" title="cn/XUL_教程/Tree_Box_Objects">Tree Box Objects</a></li>
+</ul>
+
+<h5 id="RDF_.E5.92.8C.E6.A8.A1.E6.9D.BF" name="RDF_.E5.92.8C.E6.A8.A1.E6.9D.BF">RDF 和模板</h5>
+
+<ul>
+ <li><a class="internal" href="/Cn/XUL_教程/RDF介绍" title="cn/XUL 教程/RDF介绍">RDF介绍</a></li>
+ <li><a href="/Cn/XUL_教程/Templates" title="cn/XUL_教程/Templates">模板</a></li>
+ <li><a href="/cn/XUL_教程/Trees_and_Templates" title="cn/XUL_教程/Trees_and_Templates">树和模板 Trees and Templates</a></li>
+ <li><a href="/cn/XUL_教程/RDF_Datasources" title="cn/XUL_教程/RDF_Datasources">RDF数据源 RDF Datasources</a></li>
+ <li><a href="/cn/XUL_教程/Advanced_Rules" title="cn/XUL_教程/Advanced_Rules">高级规则 Advanced Rules</a></li>
+ <li><a href="/cn/XUL_教程/Persistent_Data" title="cn/XUL_教程/Persistent_Data">Persistent Data</a></li>
+</ul>
+
+<h5 id=".E6.9C.AC.E5.9C.B0.E5.8C.96.E5.92.8C.E7.9A.AE.E8.82.A4" name=".E6.9C.AC.E5.9C.B0.E5.8C.96.E5.92.8C.E7.9A.AE.E8.82.A4">本地化和皮肤</h5>
+
+<ul>
+ <li><a href="/cn/XUL_教程/添加样式表" title="cn/XUL_教程/添加样式表">添加样式表</a></li>
+ <li><a href="/cn/XUL_教程/样式化树" title="cn/XUL_教程/样式化树">对树进行样式化</a></li>
+ <li><a href="/cn/XUL_教程/修改默认的皮肤" title="cn/XUL_教程/修改默认的皮肤">修改默认的皮肤</a></li>
+ <li><a href="/cn/XUL_教程/创建一个皮肤" title="cn/XUL_教程/创建一个皮肤">创建一个皮肤</a></li>
+ <li><a href="/Cn/XUL_教程/本地化" title="cn/XUL_教程/本地化">本地化</a></li>
+ <li><a href="/Cn/XUL_教程/属性文件" title="cn/XUL_教程/属性文件">属性文件</a></li>
+</ul>
+
+<h5 id=".E7.BB.91.E5.AE.9A" name=".E7.BB.91.E5.AE.9A">绑定</h5>
+
+<ul>
+ <li><a href="/Cn/XUL_教程/XBL介绍" title="cn/XUL_教程/XBL介绍">Introduction to XBL</a></li>
+ <li><a class="internal" href="/cn/XUL_教程/匿名内容" title="cn/XUL 教程/匿名内容">匿名内容</a></li>
+ <li><a href="/cn/XUL_教程/XBL_Attribute_Inheritance" title="cn/XUL_教程/XBL_Attribute_Inheritance">XBL Attribute Inheritance</a></li>
+ <li><a href="/cn/XUL_教程/Adding_Properties_to_XBL-defined_Elements" title="cn/XUL_教程/Adding_Properties_to_XBL-defined_Elements">Adding Properties</a></li>
+ <li><a href="/cn/XUL_教程/Adding_Methods_to_XBL-defined_Elements" title="cn/XUL_教程/Adding_Methods_to_XBL-defined_Elements">Adding Methods</a></li>
+ <li><a href="/cn/XUL_教程/Adding_Event_Handlers_to_XBL-defined_Elements" title="cn/XUL_教程/Adding_Event_Handlers_to_XBL-defined_Elements">Adding Event Handlers</a></li>
+ <li><a href="/cn/XUL_教程/XBL_Inheritance" title="cn/XUL_教程/XBL_Inheritance">XBL Inheritance</a></li>
+ <li><a href="/cn/XUL_教程/XBL_Example" title="cn/XUL_教程/XBL_Example">XBL示例</a></li>
+</ul>
+
+<h5 id=".E7.89.B9.E6.AE.8A.E7.9A.84.E7.AA.97.E5.8F.A3.E7.B1.BB.E5.9E.8B" name=".E7.89.B9.E6.AE.8A.E7.9A.84.E7.AA.97.E5.8F.A3.E7.B1.BB.E5.9E.8B">特殊的窗口类型</h5>
+
+<ul>
+ <li><a href="/cn/XUL_教程/Features_of_a_Window" title="cn/XUL_教程/Features_of_a_Window">窗口特征</a></li>
+ <li><a href="/Cn/XUL_教程/Creating_Dialogs" title="cn/XUL_教程/Creating_Dialogs">创建对话框 Creating Dialogs</a></li>
+ <li><a href="/cn/XUL_教程/Open_and_Save_Dialogs" title="cn/XUL_教程/Open_and_Save_Dialogs">打开并保存对话框 Open and Save Dialogs</a></li>
+ <li><a href="/cn/XUL_教程/Creating_a_Wizard" title="cn/XUL_教程/Creating_a_Wizard">创建一个向导 Creating a Wizard</a></li>
+ <li><a href="/cn/XUL_教程/More_Wizards" title="cn/XUL_教程/More_Wizards">More Wizards</a></li>
+ <li><a href="/cn/XUL_教程/Overlays" title="cn/XUL_教程/Overlays">Overlays</a></li>
+ <li><a href="/cn/XUL_教程/Cross_Package_Overlays" title="cn/XUL_教程/Cross_Package_Overlays">Cross Package Overlays</a></li>
+</ul>
+
+<h5 id=".E5.AE.89.E8.A3.85" name=".E5.AE.89.E8.A3.85">安装</h5>
+
+<ul>
+ <li><a href="/cn/XUL_教程/Creating_an_Installer" title="cn/XUL_教程/Creating_an_Installer">创建安装程序</a></li>
+ <li><a href="/cn/XUL_教程/Install_Scripts" title="cn/XUL_教程/Install_Scripts">安装脚本</a></li>
+ <li><a href="/cn/XUL_教程/Additional_Install_Features" title="cn/XUL_教程/Additional_Install_Features">其它安装功能</a></li>
+</ul>
+
+<div class="originaldocinfo">
+<h5 id=".E5.85.B3.E4.BA.8E.E5.8E.9F.E5.A7.8B.E6.96.87.E6.A1.A3.E7.9A.84.E4.BF.A1.E6.81.AF" name=".E5.85.B3.E4.BA.8E.E5.8E.9F.E5.A7.8B.E6.96.87.E6.A1.A3.E7.9A.84.E4.BF.A1.E6.81.AF">关于原始文档的信息</h5>
+
+<ul>
+ <li>作者: <a class="external" href="http://www.xulplanet.com/ndeakin/">Neil Deakin</a></li>
+ <li>最后修改时间: 2005年6月3日</li>
+ <li>版权信息: © 1999-2005 XULPlanet.com</li>
+</ul>
+</div>
+
+<p> </p>
+
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/input_controls/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/input_controls/index.html
new file mode 100644
index 0000000000..d901c50eeb
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/input_controls/index.html
@@ -0,0 +1,110 @@
+---
+title: XUL_教程/输入控件
+slug: Mozilla/Tech/XUL/Tutorial/Input_Controls
+tags:
+ - XUL_教程
+translation_of: Archive/Mozilla/XUL/Tutorial/Input_Controls
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Adding_Labels_and_Images" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Numeric_Controls">下一页 »</a></p>
+</div><p></p>
+<p> </p>
+<h3 id=".E6.96.87.E6.9C.AC.E8.BE.93.E5.85.A5.E6.A1.86" name=".E6.96.87.E6.9C.AC.E8.BE.93.E5.85.A5.E6.A1.86">文本输入框</h3>
+<p>HTML有一个输入元素可以用于文本输入操作。 XUL 有一个相似的元素, <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/textbox" title="textbox">textbox</a></code></code>, 用于文本输入。 不用任何属性, <code>textbox</code> 元素创建一个框让用户可以输入文本。文本框具有像HTML的输入操作相同的许多属性。下面列出其中一部份:</p>
+<dl>
+ <dt>
+ <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> </dt>
+ <dd>
+ 控件的唯一性标识。</dd>
+ <dt>
+ <code id="a-class"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/class">class</a></code> </dt>
+ <dd>
+ 输入框的样式。</dd>
+ <dt>
+ <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code> </dt>
+ <dd>
+ 如果你要输入框显示一个默认值,可以指定此属性。</dd>
+ <dt>
+ <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> </dt>
+ <dd>
+ 如果需要禁用文本输入框可以将这个属性设为<code>true</code>。</dd>
+ <dt>
+ <code id="a-type"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/type">type</a></code> </dt>
+ <dd>
+ 你可以将这个属性的值设为<code>password</code>, 创建一个输入框隐藏用户的输入内容。 通常用于密码输入框。</dd>
+ <dt>
+ <code id="a-maxlength"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/maxlength">maxlength</a></code> </dt>
+ <dd>
+ 输入框允许输入的字符最大数量。</dd>
+</dl>
+<p>注解:在HTML里, 使用<code>input</code>元素区分几个不同类型的字段,在XUL里用每种类型对元素进行区分。</p>
+<p>下面列出输入框的一些属性:</p>
+<p><span id="%E4%BE%8B1"><a id="%E4%BE%8B1"></a><strong>例1</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_inputs_1.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_inputs_1.xul">View</a></p>
+<pre>&lt;label control="some-text" value="Enter some text"/&gt;
+&lt;textbox id="some-text"/&gt;
+&lt;label control="some-password" value="Enter a password"/&gt;
+&lt;textbox id="some-password" type="password" maxlength="8"/&gt;
+</pre>
+<h4 id=".E5.A4.9A.E8.A1.8C.E6.96.87.E6.9C.AC.E8.BE.93.E5.85.A5.E6.A1.86" name=".E5.A4.9A.E8.A1.8C.E6.96.87.E6.9C.AC.E8.BE.93.E5.85.A5.E6.A1.86">多行文本输入框</h4>
+<p>上面的<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/textbox" title="textbox">textbox</a></code></code> 例子创建的输入框仅仅可以输入一行文本。HTML也有一个<code>textarea</code>元素用来创建一个大的文本输入区域。在XUL,你可以使用<code>textbox</code>元素达到很好的效果 -- 这两种元素都不是很常用。如果你设置<code><code id="a-multiline"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/multiline">multiline</a></code></code>属性为<code>true</code>,文本输入框将显示为多行。</p>
+<p><span id="%E4%BE%8B2"><a id="%E4%BE%8B2"></a><strong>例2</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_inputs_2.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_inputs_2.xul">View</a></p>
+<pre>&lt;textbox multiline="true"
+ value="This is some text that could wrap onto multiple lines."/&gt;
+</pre>
+<p>就像HTML中的<code>textarea</code>,你可以使用 <code>rows</code> 和<code>cols</code> 属性设置大小。这可以设置显示字符的行和列数量。</p>
+<div class="highlight">
+ <h4 id=".E6.88.91.E4.BB.AC.E6.96.87.E4.BB.B6.E6.9F.A5.E6.89.BE.E7.9A.84.E4.BE.8B.E5.AD.90" name=".E6.88.91.E4.BB.AC.E6.96.87.E4.BB.B6.E6.9F.A5.E6.89.BE.E7.9A.84.E4.BE.8B.E5.AD.90">我们文件查找的例子</h4>
+ <p>让我们给文件查找对话框添加一个搜索输入框。我们将要使用 <code>textbox</code> 元素。</p>
+ <pre class="eval"><span class="highlightred">&lt;label value="Search for:" control="find-text"/&gt;</span>
+<span class="highlightred">&lt;textbox id="find-text"/&gt;</span>
+
+&lt;button id="find-button" label="Find"/&gt;
+</pre>
+ <div class="float-right">
+ <div class="float-right">
+ <img alt="Image:inputs1.png" class="internal" src="/@api/deki/files/730/=Inputs1.png"></div>
+ </div>
+ <p>将这些行插入到在前一节最后我们创建的按钮的前面。如果你打开这个窗口,你将会看到像显示的图片一样的效果。</p>
+ <p>注解:标签和文本输入框现在已经显示在窗口里。文本输入框已具有完全的功能你可以在它里面输入文本和选中文本。使用<code><code id="a-control"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/control">control</a></code></code> 属性后因此当<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/label" title="label">label</a></code></code> 被点击后输入框被选中。</p>
+ <h3 id=".E5.A4.9A.E9.80.89.E5.92.8C.E5.8D.95.E9.80.89.E6.8C.89.E9.92.AE" name=".E5.A4.9A.E9.80.89.E5.92.8C.E5.8D.95.E9.80.89.E6.8C.89.E9.92.AE">多选和单选按钮</h3>
+ <p>另外两个元素是用于创建多选输入框和单选按钮。它们是按钮的变体。多选输入框元素(checkbox element)有多个选择项,可以被选或不选。单选按钮的用法相似,它有一个集合并且只能选择其中之一。</p>
+ <p>你可以像使用按钮的属性一样使用多选输入框和单选按钮。下面的例子向你展示一些简单的多选输入框和单选按钮。</p>
+ <pre>&lt;checkbox id="case-sensitive" checked="true" label="Case sensitive"/&gt;
+&lt;radio id="orange" label="Orange"/&gt;
+&lt;radio id="violet" selected="true" label="Violet"/&gt;
+&lt;radio id="yellow" label="Yellow"/&gt;
+</pre>
+ <p>第一行创建一个简单的 <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/checkbox" title="checkbox">checkbox</a></code></code>。当用户点击多选项,它在选中和非选中之间切换。<code><code id="a-checked"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/checked">checked</a></code></code> 属性可以用在表明它的默认状态。你可以将它的值设为<code>true</code>或者<code>false</code>。<code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code>属性可以用于设置显示在多选项旁边的文本。对于<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/radio" title="radio">radio</a></code></code> 按钮,你可以使用 <code><code id="a-selected"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/selected">selected</a></code></code> 属性代替 <code><code id="a-checked"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/checked">checked</a></code></code> 属性。设置它的值为 <code>true</code> 让默认选中其中的一个单选按钮,或者不选中其他的单选按钮。</p>
+ <h4 id=".E5.8D.95.E9.80.89.E9.A1.B9.E7.BB.84.E5.85.83.E7.B4.A0" name=".E5.8D.95.E9.80.89.E9.A1.B9.E7.BB.84.E5.85.83.E7.B4.A0">单选项组元素</h4>
+ <p>为了把单选按钮组合在一起,你需要用到<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/radiogroup" title="radiogroup">radiogroup</a></code></code> 元素。 在单选按钮组中同一时间只允许其中的一个单选按钮被选中。在其中的一个中点击将会把同一组中的其他按钮都设成关闭。下面的例子很好地示范了这一点。</p>
+ <p><span id="%E4%BE%8B3"><a id="%E4%BE%8B3"></a><strong>例3</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_inputs_3.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_inputs_3.xul">View</a></p>
+ <pre>&lt;radiogroup&gt;
+ &lt;radio id="orange" label="Orange"/&gt;
+ &lt;radio id="violet" selected="true" label="Violet"/&gt;
+ &lt;radio id="yellow" label="Yellow"/&gt;
+&lt;/radiogroup&gt;
+</pre>
+ <h4 id=".E5.B1.9E.E6.80.A7" name=".E5.B1.9E.E6.80.A7">属性</h4>
+ <p>像按钮一样,多选框和单选按钮可以用文本标签和图片进行包装,当它被按下时通过切换图片来表达选中或没选中。多选项有很多与按钮相同的属性:</p>
+ <dl>
+ <dt>
+ <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> </dt>
+ <dd>
+ 在多选项或单选按钮上的文本标签。</dd>
+ <dt>
+ <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> </dt>
+ <dd>
+ 设为<code>true</code> 或 <code>false</code> 去禁用或启用多选项或单选按钮。</dd>
+ <dt>
+ <code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code> </dt>
+ <dd>
+ 用于选中元素的快捷键。字母会在标签中以下划线显示。</dd>
+ </dl>
+ <div class="highlight">
+ <p><span id="%E5%88%B0%E7%9B%AE%E5%89%8D%E4%B8%BA%E6%AD%A2%E6%96%87%E4%BB%B6%E6%9F%A5%E6%89%BE%E7%9A%84%E4%BE%8B%E5%AD%90"><a id="%E5%88%B0%E7%9B%AE%E5%89%8D%E4%B8%BA%E6%AD%A2%E6%96%87%E4%BB%B6%E6%9F%A5%E6%89%BE%E7%9A%84%E4%BE%8B%E5%AD%90"></a><strong>到目前为止文件查找的例子</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/findfile/findfile-inputs.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/findfile/findfile-inputs.xul">View</a></p>
+ </div>
+ <p>在下一节,我们将可以看到一些适用于<a href="/XUL_Tutorial:Numeric_Controls" title="XUL Tutorial:Numeric Controls">输入和选择数值</a>的元素。</p>
+ <div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Adding_Labels_and_Images" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Numeric_Controls">下一页 »</a></p>
+</div></div>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/introduction/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/introduction/index.html
new file mode 100644
index 0000000000..5e80393d30
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/introduction/index.html
@@ -0,0 +1,70 @@
+---
+title: XUL_教程/引言
+slug: Mozilla/Tech/XUL/Tutorial/Introduction
+tags:
+ - XUL_Tutorial
+translation_of: Archive/Mozilla/XUL/Tutorial/Introduction
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_教程:XUL的结构">下一页 »</a></p>
+</div><p></p>
+
+<p>这份教程可以帮助你如何用 XUL (XML用户界面语言) 来创建跨平台的可描述界面的应用程序.</p>
+
+<p>这份教程将设计出一个"查找文件"的应用程序界面, 类似于Macintosh的Sherlock或是Windows的文件查找的窗口. 只会提供基本的界面以及一些简单的功能函数. 真正的文件查找功能并没有实现,.</p>
+
+<h2 id=".E4.BB.80.E4.B9.88.E6.98.AFXUL.EF.BC.8C.E5.8F.8A.E4.B8.BA.E4.BB.80.E4.B9.88.E8.A6.81.E5.88.9B.E5.BB.BA.E5.AE.83.EF.BC.9F" name=".E4.BB.80.E4.B9.88.E6.98.AFXUL.EF.BC.8C.E5.8F.8A.E4.B8.BA.E4.BB.80.E4.B9.88.E8.A6.81.E5.88.9B.E5.BB.BA.E5.AE.83.EF.BC.9F">什么是XUL,及为什么要创建它?</h2>
+
+<p>XUL (发音是 zool,有点像cool) 是为开发更快更简单的Mozilla浏览器而开发的. 这是一个基于 XML 可扩展描述语言 的语言 ,所以XML的所有特性都适用于XUL.</p>
+
+<p>大多数应用程序在开发的时候都需要应用某个特定平台的特性,这就使得创建一个跨平台的软件变得费时费力。而这对于某些用户或许并非重要,但是对那些想在其它设备上,比如手持设备或机顶盒上,运行一个应用程序的用户来说却,跨平台确是至关重要的。</p>
+
+<p>在过去诸多跨平台的解决方案都已被开发出来。比如Java的可移植性就是其主要卖点。XUL则是一个那样的语言,它被设计出用于创建可移植的用户界面。</p>
+
+<p>创建一个应用程序是要花费好多时间的,哪怕它只工作在某个平台下。编译和排错需要的时间可能会很多。而使用XUL,一个界面可以被快速方便地制作和修改。</p>
+
+<p>XUL具备所有其它XML语言的所有优点。举例来说,XHTML或者其它XML语言,比如MathML 数学标记语言 或 SVG 可伸缩矢量图,可以被插入到XUL当中。同样,XUL中的文本也可以很容易地被本地化,那意味着它可以稍加努力就可以被翻译成其它国家的语言。样式表可以被提供用于修改用户界面的外观(就像WinAmp的主题和皮肤或者某些窗口管理器)。</p>
+
+<h2 id=".E7.94.A8XUL.E5.8F.AF.E4.BB.A5.E5.81.9A.E4.BA.9B.E4.BB.80.E4.B9.88.E7.B1.BB.E5.9E.8B.E7.9A.84.E7.94.A8.E6.88.B7.E7.95.8C.E9.9D.A2.EF.BC.9F" name=".E7.94.A8XUL.E5.8F.AF.E4.BB.A5.E5.81.9A.E4.BA.9B.E4.BB.80.E4.B9.88.E7.B1.BB.E5.9E.8B.E7.9A.84.E7.94.A8.E6.88.B7.E7.95.8C.E9.9D.A2.EF.BC.9F">用XUL可以做些什么类型的用户界面?</h2>
+
+<p>XUL有能力创建现代图形界面中的大多数元件。它的应用广泛到可以满足特定设备特殊要求,而它的强大足以使开发者创建出复杂的界面。</p>
+
+<p>下列组件可以被创建:</p>
+
+<ul>
+ <li>输入组件,如文本框和复选框</li>
+ <li>带按钮和其它组件的工具条</li>
+ <li>带菜单和弹出菜单的菜单条</li>
+ <li>选项卡对话框</li>
+ <li>树形控件或栅格控件</li>
+ <li>快捷键</li>
+</ul>
+
+<p>显示的内容创建自XUL文件及数据源的数据,在Mozilla中,数据源包含用户邮件箱、书签、搜索结果等等,菜单、树状列表和其它元素都能从那添加,也可以从RDF文件添加自定义的数据。</p>
+
+<p>创建XUL应用程序的方法有几种:</p>
+
+<ul>
+ <li>Firefox扩展:扩展可以增强浏览器的功能,一般出现在工具栏、菜单,或自定义的界面里面。这里使用一种在XUL里称为overlay的东西完成,可以被主界面所引用,在实际使用中,Firefox将从扩展里面引入相关界面。扩展也可以被其它基于Mozilla平台的产品所使用,例如Thunderbird。</li>
+ <li>基于XULRunner的程序:XULRunner是创建基于Mozilla平台XUL程序的一个独立程序,它有自己的可执行文件,因而不需要浏览器。</li>
+ <li>XUL包:有别与前面基于Firefox扩展及XULRunner,它更像是有独立运行窗口的独立程序,一般用于不想携带大体积的XULRunner程序,但仍然需要Mozilla浏览器来允许该包。</li>
+ <li>远程XUL程序:你可以把XUL代码放在Web服务器,然后在浏览器打开访问,但基于安全方面的原因,该方法有局限性。</li>
+</ul>
+
+<p>前三种类型需要在用户电脑做安装操作,但是这样程序就没有安全限制了,可以访问本地文件和读写属性。例如扩展,所包含的XUL文件、脚本和图像将被打包成单一文件,用户下载后安装到本地。基于Mozilla的程序比如Firefox,提供了扩展管理器来对包进行安装管理,而不需要很多代码操作。 XUL也可以从远程WEB站点打开,然而这样很多类型操作会有限制,以及一些XUL外观效果会失效。如果你需要从远程站点载入XUL内容,WEB服务器必须设置XUL文件头格式为'application/vnd.mozilla.xul+xml'。通常XUL文件使用.xul为扩展名,你可以从Mozilla浏览器打开它,跟打开其它文件一样,点击菜单【打开文件】或者直接在地址栏输入URL地址。</p>
+
+<h2 id=".E5.AD.A6.E4.B9.A0.E8.BF.99.E4.BB.BD.E6.95.99.E7.A8.8B.E4.B9.8B.E5.89.8D.EF.BC.8C.E6.88.91.E9.9C.80.E8.A6.81.E5.81.9A.E4.BA.9B.E4.BB.80.E4.B9.88.E7.9F.A5.E8.AF.86.E5.87.86.E5.A4.87.EF.BC.9F" name=".E5.AD.A6.E4.B9.A0.E8.BF.99.E4.BB.BD.E6.95.99.E7.A8.8B.E4.B9.8B.E5.89.8D.EF.BC.8C.E6.88.91.E9.9C.80.E8.A6.81.E5.81.9A.E4.BA.9B.E4.BB.80.E4.B9.88.E7.9F.A5.E8.AF.86.E5.87.86.E5.A4.87.EF.BC.9F">学习这份教程之前,我需要做些什么知识准备?</h2>
+
+<p>你需要理解HTML,以及了解XML和CSS一些基础知识,下面几点建议需要注意:</p>
+
+<ul>
+ <li>XUL标签和属性全部用小写,XML是区分大小写的(不像HTML)</li>
+ <li>XUL属性值都要写在引号内,即使是数字</li>
+ <li>XUL文件一般分割为四部分,一是布局和元素,二是样式描述,三是脚本,四是语言包,另外通常还会包括一些图片和数据文件</li>
+</ul>
+
+<p>基于Mozilla和Gecko平台的程序都支持XUL,例如Mozilla Firefox和Netscape6。随着时间推移XUL在语法有些不同,你可能需要使用适当的版本来进行工作。在大多例子里使用的是Mozilla 1.0或更高版本。XUL在Firefox和其它基于Mozilla浏览器中是相似的,虽然也存在一些细微的差别,例如工具栏。 该指南将最大限度介绍XUL方方面面,然而还是无法讲述所有的特征。一旦你熟悉XUL,可以使用<a class="external" href="http://www.xulplanet.com/references/elemref/">XUL Element Reference</a>来查找其它标签的属性特征。</p>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_教程:XUL的结构">下一页 »</a></p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/introduction_to_rdf/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/introduction_to_rdf/index.html
new file mode 100644
index 0000000000..03e0c64a88
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/introduction_to_rdf/index.html
@@ -0,0 +1,109 @@
+---
+title: XUL_教程/RDF介绍
+slug: Mozilla/Tech/XUL/Tutorial/Introduction_to_RDF
+translation_of: Archive/Mozilla/XUL/Tutorial/Introduction_to_RDF
+---
+<p> </p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Tree_Box_Objects" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Templates">下一页 »</a></p>
+</div><p></p>
+<p> </p>
+<p>    本章我们关注与RDF (资源描述框架).</p>
+<h3 id="Resource_Description_Framework" name="Resource_Description_Framework">资源描述框架</h3>
+<p>    我们可以使用 <a href="/en/XUL_Tutorial/Trees" title="en/XUL_Tutorial/Trees">tree</a> 元素呈现数据集,就像书签和邮件管理器一样。然而这样却使向 <a href="/en/XUL" title="en/XUL">XUL</a> 文件中直接添加数据变得很不方便。直接在XUL文件中修改书签变得十分困难。这就需要RDF 数据结构。</p>
+<p><a href="/en/RDF" title="en/RDF">    RDF</a> (资源描述框架)是一种用于储存像书签或邮件这样的资源的格式。其他形式的数据可以被编码为RDF,也可以有RDF创建其他形式的数据。这是 Mozilla 处理像书签、邮件、历史等的方法。Mozilla 为这些常用的数据提供了数据源,使我们很容易使用他们。</p>
+<p>    你可以使用任意的RDF数据源来填充树结构,或者仅把RDF指向一个存有数据的XML文件。这使得显示含有许多行的树变得非常容易。RDF 也可以填充其他的 XUL 元素比如列表及菜单,见下一章。</p>
+<p>    这里是关于RDF的一个非常简略的概述,希望看到更为详尽的内容请访问XULPlanet上的 <a class="external" href="http://www.xulplanet.com/tutorials/mozsdk/rdfstart.php">Introduction to the RDF Model</a>。如果你刚刚接触RDF请继续向下阅读。</p>
+<p>    更多信息参见 <a class="external" href="http://www.w3.org/RDF/">RDF specification</a>.</p>
+<h4 id="RDF.2FXML" name="RDF.2FXML">RDF/XML</h4>
+<p>    RDF 包含这数据的图表示形式。 RDF/XML 时一种用于表示RDF数据的XML语言。它包含非常简单的元素集,下面的例子显示一个简单的RDF模板。</p>
+<pre>&lt;?xml version="1.0"?&gt;
+&lt;RDF:RDF
+ xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"&gt;
+ ...
+&lt;/RDF:RDF&gt;
+</pre>
+<p>    与XUL头有些相似,<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/window" title="window">window</a></code></code> 元素被 <code>RDF</code> 元素代替。同样为RDF定义了名空间,在RDF元素中将填充一些数据。可以在Mozilla文件夹中找到一些 RDF/XML 文件的例子,他们以rdf作为后缀。</p>
+<h4 id="RDF_database" name="RDF_database">RDF 数据库</h4>
+<p>    让我们来以有RDF产生的书签列表为例。书签列表包含一系列记录,每项记录都有一系列数据相关联,比如书签标题,URL,访问日期等。</p>
+<p>    把书签当作数据库来考虑,这个数据库是一个含有多个域的表格。这个列表需要分级,因为我们需要利用文件夹来分组书签。每一个域都来源与RDF数据库,都由名字相关联。名字用URI描述。</p>
+<p>    例如Mozilla书签列表的名字的RUI描述如下:</p>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <td>Name</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#Name</span></td>
+ <td>Bookmark name</td>
+ </tr>
+ <tr>
+ <td>URL</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#URL</span></td>
+ <td>URL to link to</td>
+ </tr>
+ <tr>
+ <td>Description</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#Description</span></td>
+ <td>Bookmark description</td>
+ </tr>
+ <tr>
+ <td>Last Visited</td>
+ <td><span class="nowiki">http://home.netscape.com/WEB-rdf#LastVisitDate</span></td>
+ <td>Date of last visit</td>
+ </tr>
+ </tbody>
+</table>
+<p>    这些是按照名空间加域名构造的。下一章,我们利用它来自动填充数据域。注意访问日期的名空间与其他的不同。</p>
+<h4 id="RDF.2FXML_file_example" name="RDF.2FXML_file_example">RDF/XML 文件样例</h4>
+<p>    下面是一个RDF/XML文件,有三条记录和三个域。</p>
+<pre>&lt;RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:ANIMALS="http://www.some-fictitious-zoo.com/rdf#"&gt;
+
+ &lt;RDF:Seq about="http://www.some-fictitious-zoo.com/all-animals"&gt;
+ &lt;RDF:li&gt;
+ &lt;RDF:Description about="http://www.some-fictitious-zoo.com/mammals/lion"&gt;
+ &lt;ANIMALS:name&gt;Lion&lt;/ANIMALS:name&gt;
+ &lt;ANIMALS:species&gt;Panthera leo&lt;/ANIMALS:species&gt;
+ &lt;ANIMALS:class&gt;Mammal&lt;/ANIMALS:class&gt;
+ &lt;/RDF:Description&gt;
+ &lt;/RDF:li&gt;
+ &lt;RDF:li&gt;
+ &lt;RDF:Description about="http://www.some-fictitious-zoo.com/arachnids/tarantula"&gt;
+ &lt;ANIMALS:name&gt;Tarantula&lt;/ANIMALS:name&gt;
+ &lt;ANIMALS:species&gt;Avicularia avicularia&lt;/ANIMALS:species&gt;
+ &lt;ANIMALS:class&gt;Arachnid&lt;/ANIMALS:class&gt;
+ &lt;/RDF:Description&gt;
+ &lt;/RDF:li&gt;
+ &lt;RDF:li&gt;
+ &lt;RDF:Description about="http://www.some-fictitious-zoo.com/mammals/hippopotamus"&gt;
+ &lt;ANIMALS:name&gt;Hippopotamus&lt;/ANIMALS:name&gt;
+ &lt;ANIMALS:species&gt;Hippopotamus amphibius&lt;/ANIMALS:species&gt;
+ &lt;ANIMALS:class&gt;Mammal&lt;/ANIMALS:class&gt;
+ &lt;/RDF:Description&gt;
+ &lt;/RDF:li&gt;
+ &lt;/RDF:Seq&gt;
+&lt;/RDF:RDF&gt;
+</pre>
+<p>    对每一种动物使用一条记录描述。每一个 <code>RDF:Description</code> 标签描述一条记录。每条记录定义了三个域:<code>name</code>, <code>species</code> ,<code>class</code>。虽然没有必要让每一条记录拥有相同的域,但是最好如此。</p>
+<p>    三个域都在 <code>ANIMALS</code>名空间下, <code>ANIMALS名空间在</code><code>RDF标签中定义<span style="font-family: Verdana,Tahoma,sans-serif;">。选择这个名字是因为它的意思,但完全可以选择其他名字。这里的名空间定义是有用的,因为如果使用样式表</span></code><code>class</code> 域可能发生冲突。</p>
+<p>     <code>Seq</code> 和 <code>li</code> 元素在列表中区分每一条记录,与HTML 列表中的定义很相似。 <code>Seq</code> 指明记录是有序的紧挨着的,对于无序内容使用 <code>Bag</code> 标签, <code>Alt 用于指明其中的记录只能选择其一</code>(如映射 URL)。</p>
+<p>    在XUL文件中可以通过名空间和域名来引用其中的数据,在上例中,下面的URI描述其中的数据域:</p>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <td>Name</td>
+ <td><span class="nowiki">http://www.some-fictitious-zoo.com/rdf#name</span></td>
+ </tr>
+ <tr>
+ <td>Species</td>
+ <td><span class="nowiki">http://www.some-fictitious-zoo.com/rdf#species</span></td>
+ </tr>
+ <tr>
+ <td>Class</td>
+ <td><span class="nowiki">http://www.some-fictitious-zoo.com/rdf#class</span></td>
+ </tr>
+ </tbody>
+</table>
+<p>    记下来,看看如何使用RDF来填充XUL数据。</p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Tree_Box_Objects" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Templates">下一页 »</a></p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/list_controls/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/list_controls/index.html
new file mode 100644
index 0000000000..27486e030b
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/list_controls/index.html
@@ -0,0 +1,133 @@
+---
+title: XUL_教程/列表控件
+slug: Mozilla/Tech/XUL/Tutorial/List_Controls
+tags:
+ - XUL_教程
+translation_of: Archive/Mozilla/XUL/Tutorial/List_Controls
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Numeric_Controls" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Progress_Meters">下一页 »</a></p>
+</div><p></p>
+<p> </p>
+<h3 id=".E5.88.97.E8.A1.A8.E6.8E.A7.E4.BB.B6" name=".E5.88.97.E8.A1.A8.E6.8E.A7.E4.BB.B6">列表控件</h3>
+<p>列表控件用来在列表中显示许多的项目。用户可以从列表中选择一个项。</p>
+<p>XUL提供两种类型的元素去创建列表,<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listbox" title="listbox">listbox</a></code></code>元素用于创建多行的列表框,和<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code></code>元素用于创建下拉列表框。它们的工作方法类似于在HTML中的 <code>select</code>元素,它们执行的功能相同,但XUL的元素包括更多的特性。</p>
+<p>简单列表框使用<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listbox" title="listbox">listbox</a></code></code>元素创建列表框,和使用<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listitem" title="listitem">listitem</a></code></code>元素创建每个项目。例如,这个列表框有四行,每个项目使用一行。</p>
+<p><span id="%E4%BE%8B1"><a id="%E4%BE%8B1"></a><strong>例1</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_lists_1.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_lists_1.xul">View</a></p>
+<div class="float-right">
+ <img alt="图像:lists1.png" class="internal" src="/@api/deki/files/2628/=Lists1.png"></div>
+<pre>&lt;listbox&gt;
+ &lt;listitem label="Butter Pecan"/&gt;
+ &lt;listitem label="Chocolate Chip"/&gt;
+ &lt;listitem label="Raspberry Ripple"/&gt;
+ &lt;listitem label="Squash Swirl"/&gt;
+&lt;/listbox&gt;
+</pre>
+<p>如HTML中的<code>option</code>元素,你可以使用<code><code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code></code>为每个项指定一个值。你也可以在脚本中使用这个值。列表框会默认设置一个合适的尺寸,但你可以通过<code><code id="a-rows"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/rows">rows</a></code></code>属性来控制尺寸。通过设置它来确定在列表框中显示的行数。如果列表包括的项超出这个值,在显示时将会出现滚动条。</p>
+<p>下面这个例子演示这些不同的特性:</p>
+<p><span id="%E4%BE%8B2"><a id="%E4%BE%8B2"></a><strong>例2</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_lists_2.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_lists_2.xul">View</a></p>
+<pre>&lt;listbox rows="3"&gt;
+ &lt;listitem label="Butter Pecan" value="bpecan"/&gt;
+ &lt;listitem label="Chocolate Chip" value="chocchip"/&gt;
+ &lt;listitem label="Raspberry Ripple" value="raspripple"/&gt;
+ &lt;listitem label="Squash Swirl" value="squash"/&gt;
+&lt;/listbox&gt;
+</pre>
+<p>这个例子已改成一次只显示3行。已经为列表中的每个项目添加了值。列表框还有其他的一些特性,将在后面进行描述。</p>
+<h3 id=".E5.A4.9A.E5.88.97.E5.88.97.E8.A1.A8.E6.A1.86" name=".E5.A4.9A.E5.88.97.E5.88.97.E8.A1.A8.E6.A1.86">多列列表框</h3>
+<p>列表框也支持多列。每个单元格可以有独有的内容,即使只使用文本。当用户选择列表中的一个项目时,当前的行将被选中。你不能只选中其中的一个单元格。</p>
+<p>在列表框中有两个标签可以使用。<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listcols" title="listcols">listcols</a></code></code>元素用来对列信息进行控制,每个列指定一个<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listcol" title="listcol">listcol</a></code></code>元素。在列表框中你将需要为每个列指定一个<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listcol" title="listcol">listcol</a></code></code>元素。</p>
+<p><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listcell" title="listcell">listcell</a></code></code>元素用于一行中的每个单元格。 如果你需要3列,你就需要增加3个<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listcell" title="listcell">listcell</a></code></code>元素到每个<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listitem" title="listitem">listitem</a></code></code>里面。要给单元格指定文本内容,替换<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listcell" title="listcell">listcell</a></code></code>元素里面的<code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code>属性。</p>
+<p>一个简单的例子,如果只有一个列,你也需要将 <code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code>属性直接地填充在<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listitem" title="listitem">listitem</a></code></code>元素里面的<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listcell" title="listcell">listcell</a></code></code>元素中, 看起来像前面的例子里一样。</p>
+<p>下面是一个有2列和3行的列表框的例子:</p>
+<p><span id="%E4%BE%8B3"><a id="%E4%BE%8B3"></a><strong>例3</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_lists_3.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_lists_3.xul">View</a></p>
+<pre>&lt;listbox&gt;
+ &lt;listcols&gt;
+ &lt;listcol/&gt;
+ &lt;listcol/&gt;
+ &lt;/listcols&gt;
+ &lt;listitem&gt;
+ &lt;listcell label="George"/&gt;
+ &lt;listcell label="House Painter"/&gt;
+ &lt;/listitem&gt;
+ &lt;listitem&gt;
+ &lt;listcell label="Mary Ellen"/&gt;
+ &lt;listcell label="Candle Maker"/&gt;
+ &lt;/listitem&gt;
+ &lt;listitem&gt;
+ &lt;listcell label="Roger"/&gt;
+ &lt;listcell label="Swashbuckler"/&gt;
+ &lt;/listitem&gt;
+&lt;/listbox&gt;
+</pre>
+<h3 id=".E8.A1.A8.E5.A4.B4.E8.A1.8C" name=".E8.A1.A8.E5.A4.B4.E8.A1.8C">表头行</h3>
+<p>列表框一直允许使用一个特殊的表头行。 这和正常的行显示有很大不同。你可以使用它来创建列头。有两个新的元素可以使用。</p>
+<p><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listhead" title="listhead">listhead</a></code></code>元素用于表头行,就像<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listitem" title="listitem">listitem</a></code></code>元素用于普通行。表头行不是普通行,因此使用脚本去获取列表的首行时获得的将是表头行的下一行。</p>
+<p><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listheader" title="listheader">listheader</a></code></code>元素用于表头行里的单元格。使用 <code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code>属性设置表头行单元格的标签。</p>
+<p>这是一个带表头行的简单例子:</p>
+<p><span id="%E4%BE%8B4"><a id="%E4%BE%8B4"></a><strong>例4</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_lists_4.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_lists_4.xul">View</a></p>
+<div class="float-right">
+ <img alt="Image:morelists1.png" class="internal" src="/@api/deki/files/2629/=Morelists1.png"></div>
+<pre>&lt;listbox&gt;
+
+ &lt;listhead&gt;
+ &lt;listheader label="Name"/&gt;
+ &lt;listheader label="Occupation"/&gt;
+ &lt;/listhead&gt;
+
+ &lt;listcols&gt;
+ &lt;listcol/&gt;
+ &lt;listcol flex="1"/&gt;
+ &lt;/listcols&gt;
+
+ &lt;listitem&gt;
+ &lt;listcell label="George"/&gt;
+ &lt;listcell label="House Painter"/&gt;
+ &lt;/listitem&gt;
+ &lt;listitem&gt;
+ &lt;listcell label="Mary Ellen"/&gt;
+ &lt;listcell label="Candle Maker"/&gt;
+ &lt;/listitem&gt;
+ &lt;listitem&gt;
+ &lt;listcell label="Roger"/&gt;
+ &lt;listcell label="Swashbuckler"/&gt;
+ &lt;/listitem&gt;
+
+&lt;/listbox&gt;
+</pre>
+<p>在这个例子中,<code><code id="a-flex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flex">flex</a></code></code>属性用于制作灵活的列。这个属性将在最后一节中说明,这里它允许列进行水平扩展。你可以调整窗口的大小去查看列根据窗口而进行伸缩的效果。如果你水平缩小,表格中的标签会自动截成带省略号(...)的样子。你可以在表格或项中使用<code><code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code></code>属性的值为<code>none</code>去禁止标签被截。</p>
+<h3 id=".E4.B8.8B.E6.8B.89.E5.88.97.E8.A1.A8" name=".E4.B8.8B.E6.8B.89.E5.88.97.E8.A1.A8">下拉列表</h3>
+<p>在HTML里可以使用<code>select</code>元素创建下拉列表。用户可以在文本框内看到一个单选并且点击箭头或其他类似按钮文本制做成不同的选项。其他的选择将会显示在一个弹出的窗口中。 XUL有一个<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code></code>元素可以实现这种效果。它是使用在一个文本框的旁边加一个按钮。选中这个名字是因为当它被选中时会弹出一个菜单。</p>
+<p>描述一个下拉列表需要三个元素。第一个是<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code></code> 元素, 在按钮的旁边创建一个文本输入框。第二,<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code></code>,当按钮被点击时创建并显示弹出窗口。第三,<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code></code>,创建单独的选择。</p>
+<p>下面的范例很好地描述了它的语法:</p>
+<p><span id="Example_5"><a id="Example_5"></a><strong>Example 5</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_lists_5.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_lists_5.xul">View</a></p>
+<div class="float-right">
+ <img alt="Image:inputs2.png" class="internal" src="/@api/deki/files/2627/=Inputs2.png"></div>
+<pre>&lt;menulist label="Bus"&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem label="Car"/&gt;
+ &lt;menuitem label="Taxi"/&gt;
+ &lt;menuitem label="Bus" selected="true"/&gt;
+ &lt;menuitem label="Train"/&gt;
+ &lt;/menupopup&gt;
+&lt;/menulist&gt;
+</pre>
+<p>这个菜单列表包括了四个项,全部都使用一个<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code></code> 元素。要显示菜单里的项,点击菜单列表中的箭头按钮。当一个被选中,它会在菜单列表中显示为选中。<code><code id="a-selected"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/selected">selected</a></code></code>属性用于设置哪个被默认选中。</p>
+<h4 id=".E5.8F.AF.E7.BC.96.E8.BE.91.E7.9A.84.E8.8F.9C.E5.8D.95.E5.88.97.E8.A1.A8" name=".E5.8F.AF.E7.BC.96.E8.BE.91.E7.9A.84.E8.8F.9C.E5.8D.95.E5.88.97.E8.A1.A8">可编辑的菜单列表</h4>
+<p>默认情况,你只可以从列表中进行选择。你不能在它上面输入你自己的文本。一个特别的菜单列表允许编辑文件框中的文本。例如,浏览器的地址输入框有一个下拉列表去选择以前输入过的地址,但你也可以输入你自己的地址。</p>
+<p>创建一个可编辑的菜单列表,像下面这样添加<code><code id="a-editable"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/editable">editable</a></code></code> 属性:</p>
+<p><span id="%E4%BE%8B6"><a id="%E4%BE%8B6"></a><strong>例6</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_lists_6.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_lists_6.xul">View</a></p>
+<pre>&lt;menulist editable="true"&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem label="www.mozilla.org"/&gt;
+ &lt;menuitem label="www.xulplanet.com"/&gt;
+ &lt;menuitem label="www.dmoz.org"/&gt;
+ &lt;/menupopup&gt;
+&lt;/menulist&gt;
+</pre>
+<p>这里创建的地址输入框由三个预设的选择,用户可以从中选择或者他们可以在文本框内输入一个他们自己的地址。用户输入的文本不会添加到新的选择中。因为<code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code>属性没有用在这个例子中,默认是空的。</p>
+<p>在下一节我们将会学习<a href="/cn/XUL_教程/Progress_Meters" title="cn/XUL_教程/Progress_Meters">creating progress meters</a>。</p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Numeric_Controls" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Progress_Meters">下一页 »</a></p>
+</div><p></p>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/localization/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/localization/index.html
new file mode 100644
index 0000000000..ffa7dd99de
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/localization/index.html
@@ -0,0 +1,296 @@
+---
+title: 本地化
+slug: Mozilla/Tech/XUL/Tutorial/Localization
+translation_of: Archive/Mozilla/XUL/Tutorial/Localization
+---
+<p> </p>
+<div class="prevnext">
+ <p><span style="float: left;">« <a href="../../../../en/XUL_Tutorial/Creating_a_Skin" rel="internal">Previous</a></span> <span style="float: right;"><a href="../../../../en/XUL_Tutorial/Property_Files" rel="internal">Next</a> »</span></p>
+</div>
+<p>  </p>
+<p> </p>
+<p>XUL 和 XML 提供的实体(entities)是一个本地化的好方法。</p>
+<div id="section_1">
+ <h3 class="editable" id="实体"><span>实体</span></h3>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/Localization#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    不少软件都希望将界面上的语言尽可能简单的翻译为另外的语言。通常他们会为每一种语言创建一份字符串列表,来代替在代码中进行硬编码。代码中的每一段文本都代表字符串列表中的一项, <a href="../../../../en/XML" rel="internal">XML</a> 提供的实体正好实现这一目的。</p>
+ <p>    如果你写过 <a href="../../../../en/HTML" rel="internal">HTML</a> 代码,你应该对实体很熟悉 , 像这样的代码 <code>&amp;lt;</code> 和 <code>&amp;gt;</code> 是作为“小于”和“大于”在文本中的替代出现的。XML 的语法允许你定义用户实体。你可以使用这些实体代替它实际的值,当然这个值可以是一段文本。实体可以用在任何文本应该出现的地方,包括属性。下面的例子在一个按钮中使用了实体。</p>
+ <pre>&lt;button label="&amp;findLabel;"/&gt;
+</pre>
+ <p>    出现在按钮上的文本将是 <code>&amp;findLabel;</code> 所代表的值。对每一种所要支持的语言需要创建一个文件包含对实体的定义。在英语中,<code>&amp;findLabel;</code> 实体可能代表文本 "Find"。</p>
+</div>
+<div id="section_2">
+ <h3 class="editable" id="DTD_文件"><span>DTD 文件 </span></h3>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/Localization#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    实体在 <em>Document Type Definition</em> (DTD) 文件中定义。这类文件往往用于特定 XML 文件的语法和语义的定义,当然也可以用来定义实体。在  Mozilla 的 chrome 体系中,你会在<code> locales</code> 子目录中找到 DTD 文件。对应一个XUL 文件,一般会有一个 DTD 文件 (extension <code>.dtd</code>)。</p>
+ <p>    如果你查看 chrome 目录,你会看到一个针对你所用语言的压缩包 (<code>en-US.jar</code> 默认是英语的语言包) 。你也可能会找到多种语言的语言包:美式英语 (en-US) 、法语 (fr)等。在这些压缩包中,你会发现它保存着每个窗口的本地化文本。这种压缩包的结构与 <a href="../../../../en/XUL_Tutorial/Creating_a_Skin" rel="internal">skins</a> 是很相似的。</p>
+ <p>    你可以把你定义实体的 DTD 文件放置到语言包里,一般的,你应该为每一个 XUL 文件建立一个 DTD 文件,通常使用相同的文件名但以 <code>.dtd</code> 作为后缀。因此对应我们的 findfile 对话框,我们需要一个 <code>findfile.dtd</code> 文件。</p>
+ <p>    对于非安装的 chrome 文件,你可以简单的把 DTD 文件放在与 XUL 相同的目录中。</p>
+ <div class="note">
+ <strong>注意:</strong> 你需要将含有非 ASCII 字符的 DTD 文件的字符编码设为 UTF-8。也就是说你应该按照 UTF-8 格式 (<a class="external" href="http://www.mozdev.org/notes/l10n/unicode/editors-en.html" rel="external nofollow" title="http://www.mozdev.org/notes/l10n/unicode/editors-en.html">without BOM</a>)保存。参见 <a class="external" href="http://www.mozilla.org/projects/l10n/mlp_chrome.html#text" rel="external nofollow" title="http://www.mozilla.org/projects/l10n/mlp_chrome.html#text">Mozilla Language Packs</a>.</div>
+ <p>    一旦为你的 XUL 文件创立 DTD 文件,你应该在 XUL 文件上添加一行以声明使用 DTD 文件。否则会发生找不到实体的错误,在 XUL 文件的头部加如下一行。</p>
+ <pre>&lt;!DOCTYPE window SYSTEM "chrome://findfile/locale/findfile.dtd"&gt;
+</pre>
+ <p>    这一行表示这个 URL 被当作一个 DTD 使用。在这个例子中,我们引入了我们需要的 <code>findfile.dtd</code> 文件,这一行通常放在 <code><span class="lang lang-en"><a href="../../../../en/XUL/window" rel="internal">window</a> <span style="font-family: Verdana,Tahoma,sans-serif;">元素之前。</span></span></code></p>
+ <p>    你同样需要在 <a href="../../../../en/Chrome_Registration#locale" rel="internal">chrome.manifest</a> 文件中添加本地化信息,如下:</p>
+ <pre class="eval">locale findfile en-US locale/
+</pre>
+</div>
+<div id="section_3">
+ <h3 class="editable" id="申明实体"><span>申明实体 </span></h3>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/Localization#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    实体的申明使用如下语法:</p>
+ <pre>&lt;!ENTITY findLabel "Find"&gt;
+</pre>
+ <p>    上例创建了一个名为 <code>findLabel</code> 值为 "Find" 的实体,这意味着在文本中的任意位置出现的 "&amp;findLabel;" 都将会被 "Find" 替代。注意实体申明无需反斜杠结束。在不同语言的 DTD 文件中,文件使用的不同的语言替代即可。</p>
+ <pre class="eval"><strong>日文:</strong>
+&lt;!ENTITY findLabel "検索"&gt;
+</pre>
+ <p>    例如,下面的文字:</p>
+ <pre>&lt;description value="&amp;findLabel;"/&gt;
+</pre>
+ <p>被翻译为:</p>
+ <pre class="eval"><strong>英文版:</strong>
+&lt;description value="Find"/&gt;
+
+<strong>日文版:</strong>
+&lt;description value="検索"/&gt;
+</pre>
+ <p>    你应该为你在界面中出现的每一个标签或字符串申明一个实体,在XUL文件中不应出现任何的显示文本。</p>
+ <p>    补充来说你可以在任何因语言不同而不同的的地方使用实体。以 <a href="../../../../en/XUL_Tutorial/Keyboard_Shortcuts" rel="internal">Access keys 及 keyboard shortcuts </a>为例。</p>
+ <pre class="eval"> <strong>XUL</strong>
+ &lt;menuitem label="&amp;undo.label;" accesskey="&amp;undo.key;"/&gt;
+ <strong>DTD</strong>
+ &lt;!ENTITY undo.label "Undo"&gt;
+ &lt;!ENTITY undo.key "u"&gt;
+</pre>
+ <p>    上面的例子使用了两个实体,一个由于 Undo 菜单项的标签,第二个用于快捷键。</p>
+ <div class="highlight">
+ <div id="section_4">
+ <h3 class="editable" id="改写_Find_Files_的例子"><span>改写 Find Files 的例子</span></h3>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/Localization#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    让我们看一看如何使用DTD文件修改我们的find files 对话框并将所有文本放在一起。整个文件列在下面。</p>
+ <pre class="eval">&lt;?xml version="1.0"?&gt;
+
+&lt;?xml-stylesheet href="<a class="external" rel="freelink">chrome://global/skin/global.css</a>" type="text/css"?&gt;
+&lt;?xml-stylesheet href="findfile.css" type="text/css"?&gt;
+
+<span class="highlightred">&lt;!DOCTYPE window SYSTEM "<a class="external" rel="freelink">chrome://findfile/locale/findfile.dtd</a>"&gt;</span>
+
+&lt;window
+ id="findfile-window"
+ title="<span class="highlightred">&amp;findWindow.title;</span>"
+ persist="screenX screenY width height"
+ orient="horizontal"
+ onload="initSearchList()"
+ xmlns="<a class="external" href="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" rel="freelink">http://www.mozilla.org/keymaster/gat...re.is.only.xul</a>"&gt;
+
+&lt;script src="findfile.js"/&gt;
+
+&lt;popupset&gt;
+ &lt;menupopup id="editpopup"&gt;
+ &lt;menuitem label="<span class="highlightred">&amp;cutCmd.label;</span>" accesskey="<span class="highlightred">&amp;cutCmd.accesskey;</span>"/&gt;
+ &lt;menuitem label="<span class="highlightred">&amp;copyCmd.label;</span>" accesskey="<span class="highlightred">&amp;copyCmd.accesskey;</span>"/&gt;
+ &lt;menuitem label="<span class="highlightred">&amp;pasteCmd.label;</span>" accesskey="<span class="highlightred">&amp;pasteCmd.accesskey;</span>" disabled="true"/&gt;
+ &lt;/menupopup&gt;
+&lt;/popupset&gt;
+
+&lt;keyset&gt;
+ &lt;key id="cut_cmd" modifiers="accel" key="<span class="highlightred">&amp;cutCmd.commandkey;</span>"/&gt;
+ &lt;key id="copy_cmd" modifiers="accel" key="<span class="highlightred">&amp;copyCmd.commandkey;</span>"/&gt;
+ &lt;key id="paste_cmd" modifiers="accel" key="<span class="highlightred">&amp;pasteCmd.commandkey;</span>"/&gt;
+ &lt;key id="close_cmd" keycode="VK_ESCAPE" oncommand="window.close();"/&gt;
+&lt;/keyset&gt;
+
+&lt;vbox flex="1"&gt;
+
+ &lt;toolbox&gt;
+
+ &lt;menubar id="findfiles-menubar"&gt;
+ &lt;menu id="file-menu" label="<span class="highlightred">&amp;fileMenu.label;</span>"
+ accesskey="<span class="highlightred">&amp;fileMenu.accesskey;</span>"&gt;
+ &lt;menupopup id="file-popup"&gt;
+ &lt;menuitem label="<span class="highlightred">&amp;openCmd.label;</span>"
+ accesskey="<span class="highlightred">&amp;openCmd.accesskey;</span>"/&gt;
+ &lt;menuitem label="<span class="highlightred">&amp;saveCmd.label;</span>"
+ accesskey="<span class="highlightred">&amp;saveCmd.accesskey;</span>"/&gt;
+ &lt;menuseparator/&gt;
+ &lt;menuitem label="<span class="highlightred">&amp;closeCmd.label;</span>"
+ accesskey="<span class="highlightred">&amp;closeCmd.accesskey;" key="close_cmd" oncommand="window.close();</span>"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menu&gt;
+ &lt;menu id="edit-menu" label="<span class="highlightred">&amp;editMenu.label;</span>"
+ accesskey="<span class="highlightred">&amp;editMenu.accesskey;</span>"&gt;
+ &lt;menupopup id="edit-popup"&gt;
+ &lt;menuitem label="<span class="highlightred">&amp;cutCmd.label;</span>"
+ accesskey="<span class="highlightred">&amp;cutCmd.accesskey;</span>" key="cut_cmd"/&gt;
+ &lt;menuitem label="<span class="highlightred">&amp;copyCmd.label;</span>"
+ accesskey="<span class="highlightred">&amp;copyCmd.accesskey;</span>" key="copy_cmd"/&gt;
+ &lt;menuitem label="<span class="highlightred">&amp;pasteCmd.label;</span>"
+ accesskey="<span class="highlightred">&amp;pasteCmd.accesskey;</span>" key="paste_cmd" disabled="true"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menu&gt;
+ &lt;/menubar&gt;
+
+ &lt;toolbar id="findfiles-toolbar"&gt;
+ &lt;toolbarbutton id="opensearch" label="<span class="highlightred">&amp;openCmdToolbar.label;</span>"/&gt;
+ &lt;toolbarbutton id="savesearch" label="<span class="highlightred">&amp;saveCmdToolbar.label;</span>"/&gt;
+ &lt;/toolbar&gt;
+ &lt;/toolbox&gt;
+
+ &lt;tabbox&gt;
+ &lt;tabs&gt;
+ &lt;tab label="<span class="highlightred">&amp;searchTab;</span>" selected="true"/&gt;
+ &lt;tab label="<span class="highlightred">&amp;optionsTab;</span>"/&gt;
+ &lt;/tabs&gt;
+
+ &lt;tabpanels&gt;
+
+ &lt;tabpanel id="searchpanel" orient="vertical" context="editpopup"&gt;
+
+ &lt;description&gt;
+ <span class="highlightred">&amp;findDescription;</span>
+ &lt;/description&gt;
+
+ &lt;spacer class="titlespace"/&gt;
+
+ &lt;groupbox orient="horizontal"&gt;
+ &lt;caption label="<span class="highlightred">&amp;findCriteria;</span>"/&gt;
+
+ &lt;menulist id="searchtype"&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem label="<span class="highlightred">&amp;type.name;</span>"/&gt;
+ &lt;menuitem label="<span class="highlightred">&amp;type.size;</span>"/&gt;
+ &lt;menuitem label="<span class="highlightred">&amp;type.date;</span>"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menulist&gt;
+ &lt;spacer class="springspace"/&gt;
+ &lt;menulist id="searchmode"&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem label="<span class="highlightred">&amp;mode.is;</span>"/&gt;
+ &lt;menuitem label="<span class="highlightred">&amp;mode.isnot;</span>"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menulist&gt;
+ &lt;spacer class="springspace"/&gt;
+
+ &lt;menulist id="find-text" flex="1"
+ editable="true"
+ datasources="<a class="external" rel="freelink">file:///mozilla/recents.rdf</a>"
+ ref="<a class="external" href="http://www.xulplanet.com/rdf/recent/all" rel="freelink">http://www.xulplanet.com/rdf/recent/all</a>"&gt;
+ &lt;template&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem label="rdf:<a class="external" href="http://www.xulplanet.com/rdf/recent#Label" rel="freelink">http://www.xulplanet.com/rdf/recent#Label</a>" uri="rdf:*"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/template&gt;
+ &lt;/menulist&gt;
+
+ &lt;/groupbox&gt;
+
+ &lt;/tabpanel&gt;
+
+ &lt;tabpanel id="optionspanel" orient="vertical"&gt;
+ &lt;checkbox id="casecheck" label="<span class="highlightred">&amp;casesensitive;</span>"/&gt;
+ &lt;checkbox id="wordscheck" label="<span class="highlightred">&amp;matchfilename;</span>"/&gt;
+ &lt;/tabpanel&gt;
+
+ &lt;/tabpanels&gt;
+ &lt;/tabbox&gt;
+
+ &lt;tree id="results" style="display: none;" flex="1"&gt;
+ &lt;treecols&gt;
+ &lt;treecol id="name" label="<span class="highlightred">&amp;results.filename;</span>" flex="1"/&gt;
+ &lt;treecol id="location" label="<span class="highlightred">&amp;results.location;</span>" flex="2"/&gt;
+ &lt;treecol id="size" label="<span class="highlightred">&amp;results.size;</span>" flex="1"/&gt;
+ &lt;/treecols&gt;
+
+ &lt;treechildren&gt;
+ &lt;treeitem&gt;
+ &lt;treerow&gt;
+ &lt;treecell label="mozilla"/&gt;
+ &lt;treecell label="/usr/local"/&gt;
+ &lt;treecell label="<span class="highlightred">&amp;bytes.before;</span>2520<span class="highlightred">&amp;bytes.after;</span>"/&gt;
+ &lt;/treerow&gt;
+ &lt;/treeitem&gt;
+ &lt;/treechildren&gt;
+ &lt;/tree&gt;
+
+ &lt;splitter id="splitbar" resizeafter="grow" style="display: none;"/&gt;
+
+ &lt;spacer class="titlespace"/&gt;
+
+ &lt;hbox&gt;
+ &lt;progressmeter id="progmeter" value="50%" style="display: none;"/&gt;
+ &lt;spacer flex="1"/&gt;
+ &lt;button id="find-button" label="<span class="highlightred">&amp;button.find;</span>"
+ oncommand="doFind()"/&gt;
+ &lt;button id="cancel-button" label="<span class="highlightred">&amp;button.cancel;</span>"
+ oncommand="window.close();"/&gt;
+ &lt;/hbox&gt;
+&lt;/vbox&gt;
+
+&lt;/window&gt;
+</pre>
+ <p>    每一个字符串均被实体引用代替。一个 DTD 文件被包含在XUL文件的开头。每一个被引用的实体必须在DTD文件中申明,如果发现引用的实体没有申明,则窗口不会显示。</p>
+ <p>    注意实体的名字并不重要,在上面的例子里实体的名字被分成几段来写,请你不要这样,请按照其他代码的书写习惯来写实体引用。</p>
+ <p>    你可能已经注意到里字符串 '2520 bytes' 被两个实体代替。这是因为在别的语言中可能会有不同的语法要求。比如,可能要求数字写在后面而把 'bytes' 写在前面。当然对于 KB 、MB 会有更复杂的顺序要求。</p>
+ <p>    <font>键盘访问键</font>及快捷键也被翻译为实体因为对不同的语言这些也会不同。</p>
+ <p>    下面是 DTD 文件 - findfile.dtd:</p>
+ <pre>&lt;!ENTITY findWindow.title "Find Files"&gt;
+&lt;!ENTITY fileMenu.label "File"&gt;
+&lt;!ENTITY editMenu.label "Edit"&gt;
+&lt;!ENTITY fileMenu.accesskey "f"&gt;
+&lt;!ENTITY editMenu.accesskey "e"&gt;
+&lt;!ENTITY openCmd.label "Open Search..."&gt;
+&lt;!ENTITY saveCmd.label "Save Search..."&gt;
+&lt;!ENTITY closeCmd.label "Close"&gt;
+&lt;!ENTITY openCmd.accesskey "o"&gt;
+&lt;!ENTITY saveCmd.accesskey "s"&gt;
+&lt;!ENTITY closeCmd.accesskey "c"&gt;
+&lt;!ENTITY cutCmd.label "Cut"&gt;
+&lt;!ENTITY copyCmd.label "Copy"&gt;
+&lt;!ENTITY pasteCmd.label "Paste"&gt;
+&lt;!ENTITY cutCmd.accesskey "t"&gt;
+&lt;!ENTITY copyCmd.accesskey "c"&gt;
+&lt;!ENTITY pasteCmd.accesskey "p"&gt;
+&lt;!ENTITY cutCmd.commandkey "X"&gt;
+&lt;!ENTITY copyCmd.commandkey "C"&gt;
+&lt;!ENTITY pasteCmd.commandkey "V"&gt;
+&lt;!ENTITY openCmdToolbar.label "Open"&gt;
+&lt;!ENTITY saveCmdToolbar.label "Save"&gt;
+&lt;!ENTITY searchTab "Search"&gt;
+&lt;!ENTITY optionsTab "Options"&gt;
+&lt;!ENTITY findDescription "Enter your search criteria below and select the Find button to begin the search."&gt;
+&lt;!ENTITY findCriteria "Search Criteria"&gt;
+&lt;!ENTITY type.name "Name"&gt;
+&lt;!ENTITY type.size "Size"&gt;
+&lt;!ENTITY type.date "Date Modified"&gt;
+&lt;!ENTITY mode.is "Is"&gt;
+&lt;!ENTITY mode.isnot "Is Not"&gt;
+&lt;!ENTITY casesensitive "Case Sensitive Search"&gt;
+&lt;!ENTITY matchfilename "Match Entire Filename"&gt;
+&lt;!ENTITY results.filename "Filename"&gt;
+&lt;!ENTITY results.location "Location"&gt;
+&lt;!ENTITY results.size "Size"&gt;
+&lt;!ENTITY bytes.before ""&gt;
+&lt;!ENTITY bytes.after "bytes"&gt;
+&lt;!ENTITY button.find "Find"&gt;
+&lt;!ENTITY button.cancel "Cancel"&gt;
+</pre>
+ <p>    现在,为一个新语言添加文本仅需创建一个新的DTD文件。使用 chrome 系统把 DTD 文件加到另一个 <code> locales</code> 中,这样同一个 XUL 文件就可以使用不同的语言。</p>
+ <p>Find files example so far: <span class="lang lang-en"><a class="external" href="http://developer.mozilla.org/samples/xultu/examples//findfile/findfile-locale.xul.txt" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples//findfile/findfile-locale.xul.txt">Source</a> </span></p>
+ </div>
+ </div>
+ <p> </p>
+ <p>    下一章,看看 <a href="../../../../en/XUL_Tutorial/Property_Files" rel="internal">property files</a>.</p>
+ <p> </p>
+ <div class="prevnext">
+ <p><span style="float: left;">« <a href="../../../../en/XUL_Tutorial/Creating_a_Skin" rel="internal">Previous</a></span> <span style="float: right;"><a href="../../../../en/XUL_Tutorial/Property_Files" rel="internal">Next</a> »</span></p>
+ </div>
+ <p>  </p>
+ <p> </p>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/manifest_files/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/manifest_files/index.html
new file mode 100644
index 0000000000..10dcc5a2dd
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/manifest_files/index.html
@@ -0,0 +1,113 @@
+---
+title: Manifest Files
+slug: Mozilla/Tech/XUL/Tutorial/Manifest_Files
+translation_of: Archive/Mozilla/XUL/Tutorial/Manifest_Files
+---
+<h3 id="Contents.rdf_.E6.96.87.E4.BB.B6" name="Contents.rdf_.E6.96.87.E4.BB.B6">Contents.rdf 文件</h3>
+<p>这部分内容,我们将了解如何将chrome和XUL文件打成包,以及为它们创建manifest文件。</p>
+<p>&lt;big&gt;<b>包</b>&lt;/big&gt;</p>
+<p>一个包,就是一组XUL文件和定义了用户界面功能的脚本的集合,它可以直接存成一个目录,也可以打成JAR文件。包可以被安装到Mozilla里,并且可以被chrome URL 引用。一个包里面包含了多种类型的文件,这些文件也可以划分到包内的不同的子目录里。</p>
+<p>&lt;big&gt;<b>Manifest 文件</b>&lt;/big&gt;</p>
+<p>manifest文件描述了包在硬盘上的物理存放位置与chrome URL的映射关系。当一个Mozilla应用启动时,它将检查chrome文件夹中的manifest文件,从而知道已经安装了哪些包。也就是说,当安装了一个新包时,你需要在应用程序的chrome目录下或者用户自己的chrome目录中加入一个新的manifest文件。一般情况下,当应用程序没有足够的权限向其目录中写入manifest文件时,才会将manifest文件放到用户自己的chrome目录中。</p>
+<p>如果你想在Firefox浏览器中测试一下XUL代码的效果,只要在manifest文件中加入一行,就可以轻松实现了:</p>
+<ol>
+ <li>创建一个目录. 例如, 在系统盘下创建一个目录, 就可以用 C:\testfiles</li>
+ <li>在chrome目录下创建一个新的名为 test.manifest 的文件(实际上,文件叫什么名字并不重要,只要扩展名是.manifest就可以了),则用下面一句:</li>
+</ol>
+<p><code>content tests <a class="external" rel="freelink">file:///C:/testfiles/</a></code></p>
+<blockquote>
+ 这里的文件路径是指向上面创建的目录的。如果你不知道应该怎么写这个文件路径,可以在浏览器中打开那个目录,然后将地址栏里面的URL拷贝下来,就可以了。</blockquote>
+<p>好了,现在,你只需要向上面新建的那个目录中加入一些XUL文件,然后,按照chrome://tests/content/&lt;filename&gt; 的格式键入chrome URL,就可以看到你的成果了。当然,为了你的修改能够起作用,需要重启浏览器。如果你创建的文件没有被加载,确认一下你键入的文件路径是否是正确的。</p>
+<p>manifest 文件中每一行的基本语法是:</p>
+<p><code>content &lt;packagename&gt; &lt;filepath&gt;</code></p>
+<p>第一个字段指明了包类型。主题包是'skin',语言地区包是'locale'。上面例子中,包名为'tests',也就意味着chrome URL中第一个部分是'tests',例如:<a class="external" rel="freelink">chrome://tests/content/sample.xul</a>。如果包名为'browser',那么chrome <a class="external" href="URL就变成chrome://browser/content/" rel="freelink">URL就变成chrome://browser/content/</a>。基本语法中最后一个字段为文件所在的路径。这既可以是用file URL(译者注:如file:///c:/dir/a)表示的本地文件路径,又可以是下面我们马上要说到的jar URL表示的JAR包。在manifest文件中添加多行,可以指定多个包。</p>
+<p>Firefox用到的browser.manifest文件看起来是这样的:</p>
+<pre><code>content branding jar:browser.jar!/content/branding/ xpcnativewrappers=yes
+content browser jar:browser.jar!/content/browser/ xpcnativewrappers=yes
+overlay chrome://global/content/viewSource.xul chrome://browser/content/viewSourceOverlay.xul
+overlay chrome://global/content/viewPartialSource.xul chrome://browser/content/viewSourceOverlay.xul
+overlay chrome://browser/content/pageInfo.xul chrome://pippki/content/PageInfoOverlay.xul
+</code></pre>
+<p>这里有两个包,'branding'和'browser'。此外还有三个overlay,它们使得来自不同包的内容可以组合在一起。扩展(Extension)中会大量使用overlay,因为overlay的功能是将包的用户界面与浏览器的用户界面融合在一起。</p>
+<p>由于内容被打包成jar,branding和browser包中文件的路径使用了jar URL。一个jar包可以通过ZIP工具来生成。在chrome目录中的JAR文件,语法相当简单:</p>
+<p><code>jar:&lt;filename.jar&gt;!/&lt;path_in_archive&gt;</code></p>
+<p>browser包对应的JAR包是browser.jar,与manifest文件放在同一个chrome目录中。'content/browser'指明了在JAR压缩包中XUL的路径。若压缩包里面不含任何目录,则无需指明任何路径。在我们的例子中,压缩包里面有目录,所以这里需要指明。</p>
+<p>对于上面我们建立的'tests'包,文件没有压缩到一个jar包里,所以我们用直接的文件路径来代替jar路径。这样做有利于开发——我们就不用每次在改动文件后重新打包。不过,在发布一个扩展或者应用是,为了避免安装一堆的小文件,通产都会采用打包的方式。</p>
+<p>在manifest文件的最后,<b>xpcnativewrappers=yes</b>是一个可选的标志。JavaScript可以将网页中内置的函数替换成自己的代码。如果有xpcnativewrappers标志,这就表明在特权环境(privileged context)下的脚本不运行覆盖的版本而是运行原始自带的版本。否则,如果一个扩展试图调用一个修改版的脚本,就有可能无法正常工作甚至更糟——产生安全漏洞。添加这个标志就是为了避免类似的问题,在新的扩展中应当坚持使用,而对于那些无法兼容改变的老扩展可以不用这个标志。</p>
+<h3 id=".E4.B8.BB.E9.A2.98.EF.BC.88Themes.EF.BC.89.E5.92.8C.E6.9C.AC.E5.9C.B0.E5.8C.96.EF.BC.88Locales.EF.BC.89" name=".E4.B8.BB.E9.A2.98.EF.BC.88Themes.EF.BC.89.E5.92.8C.E6.9C.AC.E5.9C.B0.E5.8C.96.EF.BC.88Locales.EF.BC.89">主题(Themes)和本地化(Locales)</h3>
+<p>主题(Themes)和本地化(Locales)的打包语法,与内容(content)打包的语法上是相似的。如果你要提供一个主题(Themes)和本地化(Locales)时,你需要了解更多细节。例如:</p>
+<p><code>skin browser classic/1.0 jar:classic.jar!/skin/classic/browser/</code><br>
+ <code>locale browser en-US jar:en-US.jar!/locale/browser/</code></p>
+<p>如上面例子, 浏览器用来表示皮肤和本地化的特殊的项被加入。皮肤的名称是 'classic/1.0'。这里, 版本号被作为主体的一部分来使用, 但如果你制作自己的主题它是可选的。 Mozilla浏览器并不是用特殊方式来处理版本号;版本号仅仅作为主体名称的一部分。本地化语言是 'en-US'。映射的chrome <a class="external" href="URL应该是chrome://browser/skin和chrome://browser/locale" rel="freelink">URL应该是chrome://browser/skin和chrome://browser/locale</a>。如果你正在创作你自己的主题或者本地化浏览器,你说要做的全部是建立一个包含着两行内容的manifest文件,再修改内容来适应你的主题(Themes)和本地化(Locales)。</p>
+<p>如果必要,也能够合并全部的三种类型内容放到一个单独文件里面。这种情况通常发生在当创建一个扩展(extension/Add on)时,你也许会把所有部分放到一个文件里面。例如,我们想做一个查找文件对话框时可以这样做。在chrome目录建立一个名称为findfiles.manifest的文件。把下面的内容加到文件里面:</p>
+<pre><code>content findfiles file:///findfiles/content/
+skin findfiles classic/1.0 file:///findfiles/skin/
+locale findfiles en-US file:///findfiles/locale/
+</code></pre>
+<p>通常, 你希望目录路径内够适应你的系统(不同的文件系统,目录的结构不同)。 这种情况下, 我们仅仅建立测试路径。如果我们在发布这个包,我们应该把全部内容打包成一个JAR文件,并且修改路径。这里只是一个例子,今后可以参照这个例子来做。注意,例子里的skinhe和 locale行的第二项被指定为'findfiles'。这意味着,skin和locale可以访问和修改在第一行定义的findfiles包。</p>
+<p>上述的三个路径每部分有自己的子路径,意味着你可以给每一部分建立和指定的特殊子路径。</p>
+<h3 id=".E5.AE.89.E8.A3.85.E5.8C.85" name=".E5.AE.89.E8.A3.85.E5.8C.85">安装包</h3>
+<p>为了安装一个应用,你将需要建立一个安装器,或者把它作为另一个应用的一部分。方式依赖于你所创建的是那种应用,一般来说不同的应用类型安装包是不同的。例如<a href="cn/%e6%89%a9%e5%b1%95">扩展</a>,你需要建立一个名为install.rdf的安装描述文件,它描述了哪些东西被安装,以及扩展的作者和兼容性(那一个版本的浏览器,与那些程序兼容等等)。 还需要一个<a href="cn/Bundles">专用的目录结构</a>,安装文件也许被安装到里面,并被限制在这个目录。一个扩展通常打包成一个 <a href="cn/XPI">XPI</a> 文件。 <a href="cn/XPI">XPI</a> 是XPInstall的缩写,被以Mozilla为基础的浏览器用来安装组件。类似于JAR文件,一个 XPI文件仅仅是一个带有不同的扩展的ZIP文件,所以你可以用ZIP格式兼容的工具来创建和察看 <a href="cn/XPI">XPI</a> 文件。</p>
+<p>Firefox的扩展管理器能够自动的安装 <a href="cn/XPI">XPI</a> 文件内部的扩展包。他建议上传你的扩展到[<a class="external" href="https://addons.mozilla.org/|Mozilla">Add-ons site</a>],用户通常在这个地址寻找扩展包来安装特殊的应用。当然他们也可以从任何网址安装,不过不是Firefox默认的网址。</p>
+<p>也可以用JavaScript写一个安装脚本来安装文件。这样你可以把文件复制到任何位置并执行文件管理任务。但是,用脚本安装的应用不能够被扩展管理器列出,意味着不能像其他应用那样自动地卸载。所以通常不使用脚本安装文件。</p>
+<p>标准的应用,可以使用<a href="cn/XULRunner">XULRunner</a>来打包。由于与执行文件分离,可以被发布成与浏览器版本无依赖的应用。</p>
+<p>创建<a href="cn/%e6%89%a9%e5%b1%95">扩展</a>的更多信息请参照<a href="cn/%e6%9e%84%e5%bb%ba%e4%b8%80%e4%b8%aa%e6%89%a9%e5%b1%95">构建一个扩展</a>。 <a href="cn/XULRunner">XULRunner</a>的更多信息请参照http://developer.mozilla.org/en/docs/XULRunner</p>
+<h3 id=".E6.97.A7.E7.89.88.E6.9C.AC.E5.BA.94.E7.94.A8.E7.A8.8B.E5.BA.8F" name=".E6.97.A7.E7.89.88.E6.9C.AC.E5.BA.94.E7.94.A8.E7.A8.8B.E5.BA.8F">旧版本应用程序</h3>
+<p>如果你为旧版本的Mozilla软件创建应用程序,比如Firefox 1.5或者Mozilla 1.8,那么这一章就很重要的。以下便是讲解怎样为先前版本建立包。如果你正在写新的扩展或者XUL应用程序的话,完全可以跳过此章。</p>
+<p>1. 在你的磁盘上创建一个目录。许多人喜欢在Mozilla的chrome目录下面创建一个子目录,这样是没有必要的。这个目录可以在任何地方建立,随你喜欢。然后将你的XUL文件放置其中。</p>
+<p>2. 创建一个名为contents.rdf,并放置在前面你所建立的目录中。将下面的文本框中的内容复制粘贴进新的contents.rdf文件中。这个文件是用来区别应用程序的id,它的名字,作者,版本等等的。</p>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td>
+ <pre class="eval">
+ &lt;?xml version="1.0"?&gt;
+</pre>
+ <pre class="eval">
+ &lt;RDF:RDF xmlns:RDF="<a class="external" href="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rel="freelink">http://www.w3.org/1999/02/22-rdf-syntax-ns#</a>"
+ xmlns:chrome="<a class="external" href="http://www.mozilla.org/rdf/chrome#" rel="freelink">http://www.mozilla.org/rdf/chrome#</a>"&gt;
+</pre>
+ <pre class="eval">
+ &lt;RDF:Seq about="urn:mozilla:package:root"&gt;
+ &lt;RDF:li resource="urn:mozilla:package:myapplication"/&gt;
+ &lt;/RDF:Seq&gt;
+</pre>
+ <pre class="eval">
+ &lt;RDF:Description about="urn:mozilla:package:myapplication"
+ chrome:displayName="Application Title"
+ chrome:author="Author Name"
+ chrome:name="myapplication"
+ chrome:extension="true"/&gt;
+</pre>
+ <pre class="eval">
+ &lt;/RDF:RDF&gt;
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>3. 将文本中的高亮显示部分改换成你自己的信息。比如红色部分“myapplication”应该是你应用程序的ID。你把它填写上,这个ID和你的应用程序名是相似的。用你的应用程序的题目和作者来替换文本中的蓝色高亮部分。</p>
+<p>4. 如果'chrome:extension'字段为真,那么这个应用程序是Mozilla Firefox Extension(即Mozilla Firefox的扩展),而且还会在浏览器相应的附加软件窗口中见到。否则,它将不会显示。</p>
+<p>5. 保存contents.rdf文件,同时确认它在你在步骤一中创建的那个文件内。</p>
+<p>6. 打开&lt;mozilla-directory&gt;/chrome/installed-chrome.txt 这个文件,&lt;mozilla-directory&gt;就是Mozilla程序所安装的那个目录。记住在此之前先退出Mozilla程序。</p>
+<p>7. 接下来,你必须在注册新的应用程序,这样Mozilla程序就可以找到它。在installed-chrome.txt中的最后添加新的一行,来指向你在步骤一中创建的那个目录。</p>
+<p> </p>
+<pre class="eval"> content,install,url,<a class="external" rel="freelink">file:///main/app/</a>
+</pre>
+<blockquote>
+ 用你的目录的URL来替换掉上面高亮的文字。并且必须在最后的保留一个斜杠再加一个回车。如果你不能确定那个URL是什么,那么就用Mozilla浏览器来打开该目录,并复制地址栏中所显示的URL。注意这一项必须是个目录的显示,而不是具体到文件的显示。</blockquote>
+<p>8. 删除 &lt;mozilla-directory&gt;/chrome/chrome.rdf 文件.</p>
+<p>9. 打开 Mozilla 程序.你将可以看到任何你放到那个目录下的XUL文件,以下面的URL:<b><a class="external" rel="freelink">chrome://</a><font color="red">applicationid</font>/content/file.xul</b>其中file.xul是文件名。主XUL文件应该是:<b>applicationid.xul</b>,你可以用以下的方式打开它<b><a class="external" rel="freelink">chrome://</a><font color="red">applicationid</font>/content/</b>。</p>
+<p>如果你要创建skin和locale这两项的话,重复以上步骤,除了contents.rdf的形式略有不同。可以参考contents.rdf为其它应用程序所设置的细节。</p>
+<p>创建一个chrome包是一件艰难的事情,诊断问题也很困难。以下是一些小小的提示,如果你遇到困难时也许用得着。</p>
+<ul>
+ <li>打开&lt;mozilla-directory&gt;/chrome/chrome.rdf。你应该能够找到,你的应用程序ID。否则说明注册存在问题。如果有的话,也许你在调用文件时用了错误的chrome URL。</li>
+ <li>当你试着删除&lt;mozilla-directory&gt;/chrome/chrome.rdf时,它会自动重新建立。甚至是删除整个&lt;mozilla-directory&gt;/chrome/overlayinfo/目录也一样,因为你用了overlays(叠加)。</li>
+ <li>确定在installed-chrome.txt中的URL最后又一个斜杠,还有这个文件的最后有一个空行。</li>
+ <li>在Windows操作系统中,文件的URLs是这样的形式:///C|/files/app/,其中C 是盘符。</li>
+ <li>确认contents.rdf在正确的目录下,并有着正确的格式。在Mozilla程序中打开contents.rdf来看是不是一个完好的XML。否则,你就会看到有带着黄色的背景的错误显示。</li>
+ <li>如果你应用Mozilla调试构建,有些信息会显示到终端,在最开始会提示哪些chrome应用程序checked(被查出问题?)。请自己清查一些那上面所列出的应用程序。</li>
+</ul>
+<hr>
+<div>
+ <a href="cn/XUL_%e6%95%99%e7%a8%8b/%e5%85%b3%e4%ba%8eChrome_URL">&lt;&lt; 前页</a> <a href="cn/XUL_%e6%95%99%e7%a8%8b/%e5%88%9b%e5%bb%ba%e4%b8%80%e4%b8%aa%e7%aa%97%e5%8f%a3">后页 &gt;&gt;</a></div>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/modifying_a_xul_interface/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/modifying_a_xul_interface/index.html
new file mode 100644
index 0000000000..3ee3d691e0
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/modifying_a_xul_interface/index.html
@@ -0,0 +1,118 @@
+---
+title: XUL_教程/修改XUL界面
+slug: Mozilla/Tech/XUL/Tutorial/Modifying_a_XUL_Interface
+tags:
+ - DOM
+ - XUL_教程
+translation_of: Archive/Mozilla/XUL/Tutorial/Modifying_a_XUL_Interface
+---
+<p> </p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_教程:文档对象模型" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Manipulating_Lists">下一页 »</a></p>
+</div><p></p>
+<p>    </p>
+<p>DOM 提供了一系列方法来修改文档。</p>
+<h3 id=".E5.88.9B.E5.BB.BA.E6.96.B0.E5.85.83.E7.B4.A0__Creating_New_Elements" name=".E5.88.9B.E5.BB.BA.E6.96.B0.E5.85.83.E7.B4.A0__Creating_New_Elements">创建新元素 </h3>
+<p>    你可以使用文档对象的 <code><a href="/cn/DOM/document.createElement" title="cn/DOM/document.createElement">createElement()</a></code> 方法创建新元素。它有一个参数,待创建元素的标签名。可以使用元素的 <code><a href="/cn/DOM/element.setAttribute" title="cn/DOM/element.setAttribute">setAttribute()</a></code> 方法设置属性,使用 <code><a href="/cn/DOM/element.appendChild" title="cn/DOM/element.appendChild">appendChild()</a></code> 方法将其加入到XUL文件之中。例如下面的例子将一个按钮加入的XUL窗口中。</p>
+<p><span id="Example_1"><a id="Example_1"></a><strong>Example 1</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_dommodify_1.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_dommodify_1.xul">View</a></p>
+<pre>&lt;script&gt;
+function addButton(){
+ var aBox = document.getElementById("aBox");
+ var button = document.createElement("button");
+ button.setAttribute("label","A new Button");
+ aBox.appendChild(button);
+}
+&lt;/script&gt;
+
+&lt;box id="aBox" width="200"&gt;
+ &lt;button label="Add" oncommand="addButton();"/&gt;
+&lt;/box&gt;
+</pre>
+<ul>
+ <li>脚本先用<code><a href="/cn/DOM/document.getElementById" title="cn/DOM/document.getElementById">getElementById()</a></code>获得 一个容纳按钮的box的引用。</li>
+ <li>用<code><a href="/cn/DOM/document.createElement" title="cn/DOM/document.createElement">createElement()</a></code>方法创建新按钮。</li>
+ <li>用 <code><a href="/cn/DOM/element.setAttribute" title="cn/DOM/element.setAttribute">setAttribute()</a></code> 方法设置按钮的标签属性。</li>
+ <li>用<code><a href="/cn/DOM/element.appendChild" title="cn/DOM/element.appendChild">box.appendChild()</a></code> 方法将按钮加入其中。</li>
+</ul>
+<p>    <code><a href="/cn/DOM/document.createElement" title="cn/DOM/document.createElement">createElement()</a></code> 方法将为文档创建一个默认类型的元素。对于XUL 文档,通常会创建一个XUL元素。对于 HTML 文档会创建一个HTML元素,它会包含HTML元素的功能及方法。 <code><a href="/cn/DOM/document.createElementNS" title="cn/DOM/document.createElementNS">createElementNS()</a></code> 方法用于在不同的名空间创建元素。</p>
+<p>     <code><a href="/cn/DOM/element.appendChild" title="cn/DOM/element.appendChild">appendChild()</a></code> 方法用于像一个元素添加另一个元素。有三个相关的方法: <code><a href="/cn/DOM/element.insertBefore" title="cn/DOM/element.insertBefore">insertBefore()</a></code>,<code><a href="/cn/DOM/element.replaceChild" title="cn/DOM/element.replaceChild">replaceChild()</a></code> , <code><a href="/cn/DOM/element.removeChild" title="cn/DOM/element.removeChild">removeChild</a></code> 语法如下。</p>
+<pre>parent.appendChild(child);
+parent.insertBefore(child, referenceChild);
+parent.replaceChild(newChild, oldChild);
+parent.removeChild(child);
+</pre>
+<p>    下面是这桑函数的简单说明。</p>
+<ul>
+ <li>  <code><a href="/cn/DOM/element.insertBefore" title="cn/DOM/element.insertBefore">insertBefore()</a></code> 方法在存在的元素之前插入一个新的子节点。它可以在一些子元素之间插入元素,而不像 <code><a href="/cn/DOM/element.appendChild" title="cn/DOM/element.appendChild">appendChild()</a></code> 只在最后插入。</li>
+ <li><code><a href="/cn/DOM/element.replaceChild" title="cn/DOM/element.replaceChild">replaceChild()</a></code> 方法移除一个旧的元素并在相同的位置插入新元素。</li>
+ <li><code><a href="/cn/DOM/element.removeChild" title="cn/DOM/element.removeChild">removeChild()</a></code> 删除一个节点。</li>
+</ul>
+<p>    注意,以上所有的方法中的 referenceChild 及 child 必须是一个已经存在的节点否则会出错。</p>
+<p>    通常你会希望移除一个现有的节点,并把它放到其他的位置。那么你没有必要先删除它。因为一个节点在同一时间只能在一个位置,插入方法总是先将节点从当前位置删除再插入新位置。这是一个在文档中移动节点的好方法。</p>
+<h4 id=".E6.8B.B7.E8.B4.9D.E8.8A.82.E7.82.B9__Copying_Nodes" name=".E6.8B.B7.E8.B4.9D.E8.8A.82.E7.82.B9__Copying_Nodes">拷贝节点</h4>
+<p>    可以使用 <code><a href="/cn/DOM/element.cloneNode" title="cn/DOM/element.cloneNode">cloneNode()</a></code> 方法复制节点。这方法复制现有的节点,你可以将新的节点放置到任何位置(原始节点不动),此方法带一个 boolean 型参数确定是否复制此元素的全部子节点。如果‘否’只复制此节点,不包含任何子节点。如果‘是’,将复制全部子节点。此函数会递归调用,如需复制树结构请传递true给函数,如下例。</p>
+<p><span id="Example_2"><a id="Example_2"></a><strong>Example 2</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_dommodify_2.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_dommodify_2.xul">View</a></p>
+<pre>&lt;hbox height="400"&gt;
+ &lt;button label="Copy"
+ oncommand="this.parentNode.appendChild(this.nextSibling.cloneNode(true));"/&gt;
+
+ &lt;vbox&gt;
+ &lt;button label="First"/&gt;
+ &lt;button label="Second"/&gt;
+ &lt;/vbox&gt;
+&lt;/hbox&gt;
+</pre>
+<p>当 Copy 按钮按下:</p>
+<ul>
+ <li><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/button" title="button">button</a></code>元素</code>的 <code><a href="/cn/DOM/element.nextSibling" title="cn/DOM/element.nextSibling">nextSibling</a></code> 是<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/vbox" title="vbox">vbox</a></code></code>元素。</li>
+ <li>用 <code><a href="/cn/DOM/element.cloneNode" title="cn/DOM/element.cloneNode">cloneNode()</a></code> 方法获得拷贝。</li>
+ <li>用 <code><a href="/cn/DOM/element.appendChild" title="cn/DOM/element.appendChild">appendChild()</a></code>加入。</li>
+</ul>
+<p>    注意:有些元素,如<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/listbox" title="listbox">listbox</a></code></code> 和 <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code></code> 提供了一些其他的修改方法,可以使用他们来代替,下一章( <a href="/cn/XUL_Tutorial/Manipulating_Lists" title="cn/XUL_Tutorial/Manipulating_Lists">next section</a>)会讨论。</p>
+<h3 id=".E5.A4.84.E7.90.86.E5.9F.BA.E6.9C.AC.E5.85.83.E7.B4.A0__Manipulating_Basic_Elements" name=".E5.A4.84.E7.90.86.E5.9F.BA.E6.9C.AC.E5.85.83.E7.B4.A0__Manipulating_Basic_Elements">处理基本元素</h3>
+<p>    像按钮,复选框,单选按钮这些XUL的注意元素可以通过脚本属性处理。这些属性列在 <a href="/cn/XUL_Reference" title="cn/XUL_Reference">element reference</a> 。一些公共的属性如 <code><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/label">label</a></span></code></code>, <code><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/value">value</a></span></code></code>, <code><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/checked">checked</a></span></code></code> 及<code><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/disabled">disabled</a></span></code></code> 。可以根据需要来设定他们。</p>
+<h4 id=".E4.BE.8B.EF.BC.9A.E6.A0.87.E7.AD.BE.E5.92.8C.E5.80.BC.E7.89.B9.E6.80.A7__Label_and_value_properties_examples" name=".E4.BE.8B.EF.BC.9A.E6.A0.87.E7.AD.BE.E5.92.8C.E5.80.BC.E7.89.B9.E6.80.A7__Label_and_value_properties_examples">例:标签和值特性</h4>
+<p>    这里有一个改变按钮标签的例子。</p>
+<p><span id="Example_3"><a id="Example_3"></a><strong>Example 3</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_dommodify_3.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_dommodify_3.xul">View</a></p>
+<pre>&lt;button label="Hello" oncommand="this.label = 'Goodbye';"/&gt;
+</pre>
+<p>    当按钮按下时<code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/label">label</a></span></code>会改变。对于有标签的元素这是通用的。比如文本框。同样的可以修改 <code><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/value">value</a></span></code></code> 属性。</p>
+<p><span id="Example_4"><a id="Example_4"></a><strong>Example 4</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_dommodify_4.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_dommodify_4.xul">View</a></p>
+<pre>&lt;button label="Add" oncommand="this.nextSibling.value += '1';"/&gt;
+&lt;textbox/&gt;
+</pre>
+<p>    当按钮按下时文本框中的内容每次加 '1' 。 <code><a href="/cn/DOM/element.nextSibling" title="cn/DOM/element.nextSibling">nextSibling</a></code> 重当前元素转移到下一个元素(textbox)。 += 用于像当前值加一个值,此处把 1 加到文本的末尾。注意此时你仍可以在文本框中输入,你也可以获取现在的标签和值属性的值,如下例。</p>
+<p><span id="Example_5"><a id="Example_5"></a><strong>Example 5</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_dommodify_5.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_dommodify_5.xul">View</a></p>
+<pre>&lt;button label="Hello" oncommand="alert(this.label);"/&gt;
+</pre>
+<h4 id="Toggling_a_checkbox" name="Toggling_a_checkbox">标记checkbox</h4>
+<p>    Checkboxes 有 <code><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/checked">checked</a></span></code></code> 属性可以是 check 或 uncheck 。很容易知道怎么样。下一个例子,当按钮按下时把<code><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/checked">checked</a></span></code>属性取反<span style="font-family: Verdana,Tahoma,sans-serif;">。</span></code> 注意 <code><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/label">label</a></span></code></code> 和<code><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/value">value</a></span></code></code> 属性是字符串,而 <code><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/checked">checked</a></span></code></code> 属性是布尔值。</p>
+<p><span id="Example_6"><a id="Example_6"></a><strong>Example 6</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_dommodify_6.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_dommodify_6.xul">View</a></p>
+<pre>&lt;button label="Change" oncommand="this.nextSibling.checked = !this.nextSibling.checked;"/&gt;
+&lt;checkbox label="Check for messages"/&gt;
+</pre>
+<p>    单选按钮也可以用属性选中或取消,注意在一个组中一次只能选中一个,这无需手工操作。单选组的 <code><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code></code>属性用在这里 <code><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code></code> 属性用于获得被选中的单选按钮的序号,同样可改变它。</p>
+<h4 id=".E6.BF.80.E6.B4.BB.E6.88.96.E6.97.A0.E6.95.88.E4.B8.80.E4.B8.AA.E5.85.83.E7.B4.A0__Changing_a_element_disabled_or_enabled" name=".E6.BF.80.E6.B4.BB.E6.88.96.E6.97.A0.E6.95.88.E4.B8.80.E4.B8.AA.E5.85.83.E7.B4.A0__Changing_a_element_disabled_or_enabled">激活或无效一个元素</h4>
+<p>    在某些情况下一些操作将不被支持,有些内容将会无效。比如,在参数选择对话框中,能选择一系列参数但只有一项允许用户改变。下面的例子创建这样的一个界面。</p>
+<p><span id="Example_7"><a id="Example_7"></a><strong>Example 7</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_dommodify_7.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_dommodify_7.xul">View</a></p>
+<pre>&lt;script&gt;
+function updateState(){
+ var name = document.getElementById("name");
+ var sindex = document.getElementById("group").selectedIndex;
+ name.disabled = sindex == 0;
+}
+&lt;/script&gt;
+
+&lt;radiogroup id="group" onselect="updateState();"&gt;
+ &lt;radio label="Random name" selected="true"/&gt;
+ &lt;hbox&gt;
+ &lt;radio label="Specify a name:"/&gt;
+ &lt;textbox id="name" value="Jim" disabled="true"/&gt;
+ &lt;/hbox&gt;
+&lt;/radiogroup&gt;
+</pre>
+<p>    当单选组中的一个选择事件发生时会调用updateState() 方法。这个函数用<code><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code></code> 属性返回当前被选中的 <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/radio" title="radio">radio</a></code></code> 元素。。注意<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/hbox" title="hbox">hbox</a></code></code>中的元素也被包含在单选组中。如果第一个按钮 (序0)被选中,通过设置文本框的 <code><code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/disabled">disabled</a></span></code> 属性,使文本框无效<span style="font-family: Verdana,Tahoma,sans-serif;">,第二个按钮被选中时,文本框又被激活了。</span></code></p>
+<p>下一章将提供关于单选框和列表的更多信息。</p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Document_Object_Model" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Manipulating_Lists">下一页 »</a></p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/modifying_the_default_skin/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/modifying_the_default_skin/index.html
new file mode 100644
index 0000000000..5bf9abae27
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/modifying_the_default_skin/index.html
@@ -0,0 +1,63 @@
+---
+title: 修改默认的皮肤
+slug: Mozilla/Tech/XUL/Tutorial/Modifying_the_Default_Skin
+translation_of: Archive/Mozilla/XUL/Tutorial/Modifying_the_Default_Skin
+---
+<p>  本章论述如何修改窗口的皮肤。</p>
+
+<div id="section_1">
+<h3 class="editable" id="关于皮肤"><span>关于皮肤</span><a href="../../../../en/XUL_Tutorial/Modifying_the_Default_Skin#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif">  </span></a></h3>
+
+<p><a href="../../../../en/Creating_a_Skin_for_Firefox/Getting_Started" rel="internal">皮肤</a> 是一组样式表,图片及应用于XUL的行为文件。 通过使用不同的皮肤,你可以再不改变窗口的功能的前提下改变其外观。火狐提供了一个默认的皮肤,并且你也可以下载到其他的一些。对于所有的皮肤来说XUL是一样的,只是,他们使用的样式表及图片不同罢了。</p>
+
+<p>  如果你想让你的火狐窗口看起来更有个性,你可以简单的改变与之关联的样式表文件。当然可以创建一个全新的皮肤来进行进一步的修改。火狐有一个主题管理器用以修改默认的皮肤(尽管在底层代码中,人们把皮肤和用户界面叫“主题”,但实际上他们就是指一个相同的东西)。</p>
+
+<p>  皮肤使用 <a href="../../../../en/CSS" rel="internal">CSS</a>描述,允许你定义绘图元素使用的颜色、边框和图片。再文件classic.jar中包含有皮肤的定义。此包中的全局目录中有一个主样式定义,他用于定义一系列XUL元素是如何显示的。通过修改这些文件,你就能改变XUL程序的外观。。</p>
+</div>
+
+<div id="section_2">
+<h3 class="editable" id="使用userChrome.css定制"><span>  使用userChrome.css定制</span><a href="../../../../en/XUL_Tutorial/Modifying_the_Default_Skin#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"> </span></a></h3>
+
+<p>  在你的profile文件夹中,'chrome'文件夹下放置一个'userChrome.css' 文件你就可以通过覆盖而不是修改主题包来改变程序外观。当你创建一个profile 是就会创建这样一个文件夹,并且其中会包含一些内容。文件'userContent.css' 定制网页, 文件'userChrome.css' 定制chrome 文件。</p>
+
+<p>  下例,把下面这行加到文件的底部,你会发现所有的菜单栏都变成了红色背景。</p>
+
+<pre>menubar {
+ background-color: red;
+}
+</pre>
+
+<p>  当你进行了以上修改之后,你会发现所有的火狐窗口都已改变,所有的菜单栏都是红色的。因为他改变了用户样式表,并且作用于所有的窗口。也就是说,浏览器菜单栏、书签菜单栏甚至是查找菜单栏都是红色的。</p>
+</div>
+
+<p> </p>
+
+<h3 class="editable" id="皮肤包"><span>皮肤包 </span></h3>
+
+<div class="editIcon"><a href="../../../../en/XUL_Tutorial/Modifying_the_Default_Skin#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+
+<p>  仅改变一个窗口,你需要修改与XUL文件相关的样式表。比如,为书签管理器的菜单命令增加一个红色的边框,把下面的内容加到classic.jar或你要用的其他主题包的 bookmarksManager.css 文件最后。</p>
+
+<pre>menuitem {
+ border: 1px solid red;
+}
+</pre>
+
+<p>  如果你观察一个皮肤包,你就会注意到其中包含有一系列的样式表及图片。样式表引用图片。当你希望你的程序可以改变皮肤时,你应该避免在XUL文件中直接引用图片。这是因为一个别的什么皮肤设计者可能不希望使用图片,但是如果在XUL文件中直接使用了图片,就会使他的工作变得复杂。请使用CSS间接引用图片,这样就很容易被移除。</p>
+
+<p>  使用<code>list-style-image属性,</code>你可以为按钮、复选框或是其他什么元素设计图形,如下例:</p>
+
+<pre>checkbox {
+ list-style-image: url("chrome://findfile/skin/images/check-off.jpg");
+}
+
+checkbox[checked="true"] {
+ list-style-image: url("chrome://findfile/skin/images/check-on.jpg");
+}
+</pre>
+
+<p>  这些代码改变了与复选框相关的图形,首先复选框有一个一般的外观,然后为选中的复选框设置了一个新的图像。修饰'checked=true' makes the style only apply to elements which have their checked attributes set to true.</p>
+
+<p><small><span class="lang lang-en"><span id="See_also"><strong>See also</strong></span> </span> : <a href="../../../../en/Creating_a_Skin_for_Firefox" rel="internal">creating a skin for Firefox</a> and <a href="../../../../en/CSS/Getting_Started" rel="internal">CSS getting started</a> </small></p>
+
+<p>下一节,创建一个新皮肤</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/more_button_features/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/more_button_features/index.html
new file mode 100644
index 0000000000..a5dc1c3a54
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/more_button_features/index.html
@@ -0,0 +1,216 @@
+---
+title: 沙盒
+slug: Mozilla/Tech/XUL/Tutorial/More_Button_Features
+tags:
+ - test
+ - 沙盒
+ - 练习
+translation_of: Sandbox
+---
+<article class="approved">
+<div class="boxed translate-rendered text-content">
+<p class="summary">{{EmbedLiveSample('Sample')}}</p>
+
+<p class="summary">How To Edit The Sandbox For Publication</p>
+
+<p>There should be a video editing add-on.</p>
+
+<h2 id="Steven" name="Steven">Another in this article section (<em>maybe</em>)</h2>
+
+<h3 id="adam" name="adam">Nesting?</h3>
+
+<p>Hmmm, maybe this works? I don't <a href="http://google.com/">know</a>.</p>
+
+<p>I will get there!</p>
+
+<p><a href="https://wiki.developer.mozilla.org/en-US/docs/MDN/Contribute/Howto/Convert_code_samples_to_be_live">link testing</a></p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">let</span> there <span class="operator token">=</span> <span class="number token">999999999</span><span class="punctuation token">;</span>
+
+<span class="keyword token">let</span> stepCount <span class="operator token">=</span> <span class="number token">1</span><span class="punctuation token">;</span>
+
+<span class="keyword token">while</span><span class="punctuation token">(</span><span class="operator token">!</span>there<span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ stepCount<span class="operator token">++</span><span class="punctuation token">;</span>
+<span class="punctuation token">}</span>
+<span class="comment token">//you cannot got there</span>
+<span class="function token">alert</span><span class="punctuation token">(</span><span class="string token">'I GOT THERE!!!!!!'</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+
+<h4 id="H4_heading">H4 heading</h4>
+
+<h5 id="h5_indicates_that_youve_dug_too_deep!">h5 indicates that you've dug too deep!</h5>
+
+<h2 id="Code_Sample">Code Sample</h2>
+
+<pre class="brush: cpp line-numbers language-cpp"><code class="language-cpp">#include <span class="operator token">&lt;</span>iostream<span class="operator token">&gt;</span>
+
+int <span class="function token">main</span><span class="punctuation token">(</span><span class="punctuation token">)</span>
+
+<span class="punctuation token">{</span>
+
+<span class="function token">print</span><span class="punctuation token">(</span><span class="string token">"This is a sample code!"</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+
+<span class="keyword token">return</span> <span class="number token">3</span><span class="punctuation token">;</span>
+
+<span class="punctuation token">}</span></code></pre>
+
+<h2 id="Alerts_in_Javascript">Alert's in Javascript</h2>
+
+<h3 id="HTML">HTML</h3>
+
+<pre class="brush: html line-numbers language-html"><code class="language-html"><span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>p</span> <span class="attr-name token">id</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">'</span>test_code<span class="punctuation token">'</span></span><span class="punctuation token">&gt;</span></span>
+ Test Sample Code
+<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>p</span><span class="punctuation token">&gt;</span></span></code></pre>
+
+<h3 id="CSS">CSS</h3>
+
+<pre class="brush: css line-numbers language-css"><code class="language-css"><span class="selector token"><span class="id token">#test_code</span></span> <span class="punctuation token">{</span>
+ <span class="property token">background-color</span><span class="punctuation token">:</span> purple<span class="punctuation token">;</span>
+<span class="punctuation token">}</span></code></pre>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js">console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Hi there !!"</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+
+<h3 id="Result">Result</h3>
+
+<p>{{EmbedLiveSample('My_Alert')}}</p>
+
+<h2 id="Hello_World">Hello World</h2>
+
+<h3 id="HTML_2">HTML</h3>
+
+<pre class="brush: html line-numbers language-html"><code class="language-html"><span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>input</span> <span class="attr-name token">type</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>date<span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span></code></pre>
+
+<h3 id="Result_2">Result</h3>
+
+<p>{{EmbedLiveSample('Hello_World')}}</p>
+
+<h2 id="sand" name="sand">结论</h2>
+
+<p>本文档提供了JavaScript中alerts---警告的基本信息</p>
+
+<h2 id="webgl" name="webgl">WebGL 基本原理</h2>
+
+<p>WebglRenderingContext的shaderSource方法非常酷!</p>
+
+<h2 id="子导航">子导航</h2>
+
+<section id="Quick_Links">
+<ol>
+ <li><strong><a href="https://wiki.developer.mozilla.org/en-US/docs/Sandbox">Sandbox</a></strong> {{ListSubpages("/en-US/docs/Sandbox", 2, 0, 1)}}</li>
+</ol>
+</section>
+</div>
+</article>
+
+<article class="localized">
+<header>
+<h3 id="中文_简体_翻译:">中文 (简体) 翻译:</h3>
+</header>
+
+<div class="guide-links"><a href="https://wiki.developer.mozilla.org/zh-CN/docs/MDN/Community" rel="noopener">需要帮助?</a> • <a href="https://wiki.developer.mozilla.org/zh-CN/docs/MDN/Contribute/Editor" rel="noopener">编者指南</a> • <a href="https://wiki.developer.mozilla.org/zh-CN/docs/MDN/Contribute/Content/Style_guide" rel="noopener">风格指南</a></div>
+
+<div class="editor-wrapper" id="editor-wrapper">
+<div class="draft-container">
+<div class="draft-old"></div>
+
+<div class="draft-status"><span id="draft-action">草稿已自动保存: <time class="time-ago" id="draft-time" title="2019-11-15T05:28:03.006Z">2019/11/15 下午1:28:03</time></span></div>
+</div>
+
+<div class="ckeditor-container editor-container dirty">
+<div class="editor">
+<div class="editor-tools"></div>
+
+<div style="height: 232px;">
+<div style="border: 1px solid rgb(182, 182, 182); width: 702px; position: relative; top: 0px;"></div>
+</div>
+</div>
+</div>
+</div>
+</article>
+
+<article class="localized">
+<div class="editor-wrapper" id="editor-wrapper">
+<div class="ckeditor-container editor-container dirty">
+<div class="editor">
+<div class="cke" dir="ltr" id="cke_id_content" lang="zh-cn">
+<div>
+<div id="cke_1_contents" style="height: 2399.9px;"></div>
+</div>
+</div>
+</div>
+</div>
+</div>
+</article>
+
+<p class="summary" id="bob">如何编辑沙盒页面的发布版本test</p>
+
+<p>这里应该有一个视频编辑插件。</p>
+
+<h2 id="vvv" name="vvv">本文的另一个小节(<em>大概</em>)</h2>
+
+<h3 id="adam" name="adam">嵌套?</h3>
+
+<p>嗯, 这样能行吧? 我也不<a href="http://google.com/">知道</a>。</p>
+
+<p>我会做到的!</p>
+
+<p><a href="/zh-CN/docs/MDN/Contribute/Howto/Convert_code_samples_to_be_live">链接测试</a></p>
+
+<pre class="brush: js">let there = 999999999;
+
+let stepCount = 1;
+
+while(!there) {
+ stepCount++;
+}
+
+alert('I GOT THERE!!!!!!');</pre>
+
+<h4 id="H4_标题">H4 标题</h4>
+
+<h5 id="h5_表明你钻研的太深奥了有么?">h5 表明你钻研的太深奥了(有么?)</h5>
+
+<h2 id="代码示例">代码示例</h2>
+
+<pre class="brush: cpp line-numbers language-cpp"><code class="language-cpp">#include <span class="operator token">&lt;</span>iostream<span class="operator token">&gt;</span>
+
+int <span class="function token">main</span><span class="punctuation token">(</span><span class="punctuation token">)</span>
+
+<span class="punctuation token">{</span>
+
+<span class="function token">print</span><span class="punctuation token">(</span><span class="string token">"This is a sample code!"</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+
+<span class="keyword token">return</span> <span class="number token">3</span><span class="punctuation token">;</span>
+
+<span class="punctuation token">}</span></code></pre>
+
+<h2 id="我的警示">我的警示</h2>
+
+<h3 id="HTML_3">HTML</h3>
+
+<pre class="brush: html">&lt;p id='test_code'&gt;
+  测试示例代码
+&lt;/p&gt;</pre>
+
+<h3 id="CSS_2">CSS</h3>
+
+<pre class="brush: css line-numbers language-css"><code class="language-css"><span class="selector token"><span class="id token">#test_code</span></span> <span class="punctuation token">{</span>
+ <span class="property token">background-color</span><span class="punctuation token">:</span> purple<span class="punctuation token">;</span>
+<span class="punctuation token">}</span></code></pre>
+
+<h3 id="JavaScript_2">JavaScript</h3>
+
+<pre class="brush: js">console.log("嗨,我在这儿 !!");</pre>
+
+<h3 id="结果">结果</h3>
+
+<p>{{EmbedLiveSample('My_Alert')}}</p>
+
+<h2 id="sand" name="sand">大家好</h2>
+
+<p>本文档旨在健全科学。</p>
+
+<h2 id="webgl" name="webgl">WebGL基本原理</h2>
+
+<p>WebglRenderingContext中的shaderSource方法非常酷炫!</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/more_event_handlers/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/more_event_handlers/index.html
new file mode 100644
index 0000000000..efb14f298f
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/more_event_handlers/index.html
@@ -0,0 +1,183 @@
+---
+title: 其他事件处理器
+slug: Mozilla/Tech/XUL/Tutorial/More_Event_Handlers
+translation_of: Archive/Mozilla/XUL/Tutorial/More_Event_Handlers
+---
+<div class="pageTitle">
+ <h1 id="更多关于事件处理">更多关于事件处理</h1>
+</div>
+<div id="page-top">
+ <div class="pageText" id="pageText">
+ <p> </p>
+ <p> </p>
+ <div class="prevnext">
+ <p><span style="float: left;">« <a href="../../../../en/XUL_Tutorial/Adding_Event_Handlers" rel="internal">Previous</a></span> <span style="float: right;"><a href="../../../../en/XUL_Tutorial/Keyboard_Shortcuts" rel="internal">Next</a> »</span></p>
+ </div>
+ <p>  </p>
+ <p> </p>
+ <p>    在这一章,详细讨论事件对象,并引入一些新事件。</p>
+ <div id="section_1">
+ <h3 class="editable" id="事件对象"><span>事件对象</span></h3>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/More_Event_Handlers#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    每一个事件处理函数都包含一个保存这事件( <a href="../../../../en/DOM/event" rel="internal">event</a> )对象的参数。在以属性的发生添加的事件监听器里也有一个隐含的事件对象(event)被当作参数传递到事件监听器中。在 <a href="../../../../en/DOM/element.addEventListener" rel="internal">addEventListener</a> 的形式中,事件监听器的第一个参数就是事件对象。实践大学有一系列的属性,完整列表参见 <a href="../../../../en/DOM/event" rel="internal"> reference</a>。</p>
+ <p>    我们已经在上一章知道了<code><a href="../../../../en/DOM/event.target" rel="internal">target</a></code> 属性,它保存这产生事件元素的一个引用。一个相似的 <code><a href="../../../../en/DOM/event.currentTarget" rel="internal">currentTarget</a></code> 属性当前处理此事件的元素,下面的例子 <code><a href="../../../../en/DOM/event.currentTarget" rel="internal">currentTarget</a></code> 总是 vbox,而 <code><a href="../../../../en/DOM/event.target" rel="internal">target</a></code> 可能是不同的元素, button 或 checkbox。</p>
+ <p><span class="lang lang-en"><span id="Example_1"><strong>Example 1</strong></span> </span> : <span class="lang lang-en"><a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_advevents_1.xul.txt" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_advevents_1.xul.txt">Source</a> <a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_advevents_1.xul" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_advevents_1.xul">View</a> </span></p>
+ <pre>&lt;vbox oncommand="alert(event.currentTarget.tagName);"&gt;
+ &lt;button label="OK"/&gt;
+ &lt;checkbox label="Show images"/&gt;
+&lt;/vbox&gt;
+</pre>
+ <div id="section_2">
+ <h4 class="editable" id="停止事件传播"><span>停止事件传播</span></h4>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/More_Event_Handlers#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    一旦你处理一个事件,无论事件传播到什么程度,你都希望停止事件继续向下传播。因为添加事件监听器的方式不同有以下两种方式停止事件传播。</p>
+ <p>    由于路由阶段先于返回阶段发生所以路由监听器会先于返回监听器触发。如果路由阶段停止事件传播,那么其后的路由监听器及所有返回监听器都不会触发。手动停止事件对象传播使用 <code><a href="../../../../en/DOM/event.stopPropagation" rel="internal">stopPropagation</a></code> 方法,如下例。</p>
+ <p><span class="lang lang-en"><span id="Example_2"><strong>Example 2</strong></span> </span> : <span class="lang lang-en"><a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_advevents_2.xul.txt" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_advevents_2.xul.txt">Source</a> <a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_advevents_2.xul" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_advevents_2.xul">View</a> </span></p>
+ <pre>&lt;hbox id="outerbox"&gt;
+ &lt;button id="okbutton" label="OK"/&gt;
+&lt;/hbox&gt;
+
+&lt;script&gt;
+function buttonPressed(event){
+ alert('Button was pressed!');
+}
+
+function boxPressed(event){
+ alert('Box was pressed!');
+ event.stopPropagation();
+}
+
+var button = document.getElementById("okbutton");
+button.addEventListener('command',buttonPressed,true);
+
+var outerbox = document.getElementById("outerbox");
+outerbox.addEventListener('command',boxPressed,true);
+&lt;/script&gt;
+</pre>
+ <p>    这里分别在按钮和box上添加事件监听器,在调用box的监听器中使用了 <code><a href="../../../../en/DOM/event.stopPropagation" rel="internal">stopPropagation</a></code> 方法,因此按钮的监听器永远不会被调用。如果去掉此命令两个监听器的显示都会出现。</p>
+ </div>
+ <div id="section_3">
+ <h4 class="editable" id="阻止默认响应"><span>阻止默认响应</span></h4>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/More_Event_Handlers#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    如果没有注册事件处理,那么当完成路由及返回后,元素会以一种默认的方式对事件作出响应。这种默认响应依赖于元素的定义。比如, 'popupshowing' 事件在快捷菜单显示之前被发送。默认的响应就是显示快捷菜单。如果默认的响应被阻止,那么快捷菜单就不会显示。默认的响应可以使用事件对象的 <code><a href="../../../../en/DOM/event.preventDefault" rel="internal">preventDefault</a></code> 方法阻止,如下例。</p>
+ <p><span class="lang lang-en"><span id="Example_3"><strong>Example 3</strong></span> </span> : <span class="lang lang-en"><a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_advevents_3.xul.txt" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_advevents_3.xul.txt">Source</a> <a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_advevents_3.xul" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_advevents_3.xul">View</a> </span></p>
+ <pre>&lt;button label="Types" type="menu"&gt;
+ &lt;menupopup onpopupshowing="event.preventDefault();"&gt;
+ &lt;menuitem label="Glass"/&gt;
+ &lt;menuitem label="Plastic"/&gt;
+ &lt;/menupopup&gt;
+&lt;/button&gt;
+</pre>
+ <p>     另一种方式, 对于以属性形式使用的可以在代码中直接返回 false 。 注意阻止默认响应不同于 <code><a href="../../../../en/DOM/event.stopPropagation" rel="internal">stopPropagation</a></code> 方法,即使默认响应被阻止,事件依然会传播下去。同样的,定义 <code><a href="../../../../en/DOM/event.stopPropagation" rel="internal">stopPropagation</a></code> 方法也不会阻止默认响应。如果需要,必须同时调用。</p>
+ <p>    注意一旦传播或默认调用被阻止,都不可恢复。</p>
+ <p>    下面的几章列出可能用到的一些事件,一个完整的列表在这里 <a class="external" href="http://www.xulplanet.com/references/elemref/ref_EventHandlers.html" rel="external nofollow" title="http://www.xulplanet.com/references/elemref/ref_EventHandlers.html">XULPlanet event reference</a>。</p>
+ </div>
+ </div>
+ <div id="section_4">
+ <h3 class="editable" id="鼠标事件"><span>鼠标事件</span></h3>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/More_Event_Handlers#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    这里的一些事件用来描述鼠标动作,简单的描述如下:</p>
+ <dl>
+ <dt>
+ click </dt>
+ <dd>
+ 当鼠标键在一个元素上按下并释放后调用。</dd>
+ </dl>
+ <dl>
+ <dt>
+ dblclick </dt>
+ <dd>
+ 当鼠标双击时调用。</dd>
+ </dl>
+ <dl>
+ <dt>
+ mousedown </dt>
+ <dd>
+ 当鼠标键在一个元素上按下时调用,事件处理会被立即调用,甚至在鼠标键释放之前。</dd>
+ </dl>
+ <dl>
+ <dt>
+ mouseup </dt>
+ <dd>
+ 当鼠标键在一个元素上释放时调用。</dd>
+ </dl>
+ <dl>
+ <dt>
+ mouseover </dt>
+ <dd>
+ 当鼠标移动到一个元素之上时调用,你可以使用它来高亮显示该元素,然而CSS提供了一个方案自动实现它,所以你可能不会使用它,当然你也可以在状态栏显示一些提示信息。</dd>
+ </dl>
+ <dl>
+ <dt>
+ mousemove </dt>
+ <dd>
+ 当鼠标在一个元素上移动时调用,在移动过程中可能会多次调用事件处理,请务必避免冗长,复杂操作。</dd>
+ </dl>
+ <dl>
+ <dt>
+ mouseout </dt>
+ <dd>
+ 当指针移除元素时调用。你可以将该元素取消高亮或移除状态栏提示。</dd>
+ </dl>
+ <p>    也有一些与拖动相关的事件,当用户按下鼠标键并移动鼠标时产生,这一部分参见 <a href="../../../../en/Drag_and_Drop" rel="internal">Drag and Drop</a>.</p>
+ <div id="section_5">
+ <h4 class="editable" id="鼠标键事件属性"><span>鼠标键事件属性</span></h4>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/More_Event_Handlers#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    当一个鼠标键事件产生,一系列附件属性也随之产生用以描述哪个鼠标键被按下及鼠标指针的位置。事件的 <code><a href="../../../../en/DOM/event.button" rel="internal">button</a></code> 可以用于确定哪个按键被按下。0 代表左键,1 代表中键 ,2代表右键。如果鼠标设置不同,值也不同。</p>
+ <p>    <code><a href="../../../../en/DOM/event.detail" rel="internal">detail</a></code> 保存着鼠标键被短时间内快速点击的次数。这允许你检查这是一次单击,双击还是三击。当然如果你希望检查双击你可以使用 dblclick 事件代替。一旦第一次点击开始 click 事件就会触发,第二次点击会再触发一次,第三次又一次。但 dblclick 事件仅在双击发生时触发。</p>
+ <p>     <code><a href="../../../../en/DOM/event.button" rel="internal">button</a></code> 及 <code><a href="../../../../en/DOM/event.detail" rel="internal">detail</a></code> 仅支持与鼠标键相关的事件,对鼠标移动事件无效。对于鼠标移动事件这两个值均为0。</p>
+ </div>
+ <div id="section_6">
+ <h4 class="editable" id="鼠标位置事件属性"><span>鼠标位置事件属性 </span></h4>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/More_Event_Handlers#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    所以的鼠标事件都提供事件发生时鼠标的坐标位置。有两个坐标系统。其一是 <code><a href="../../../../en/DOM/event.screenX" rel="internal">screenX</a></code> 、 <code><a href="../../../../en/DOM/event.screenY" rel="internal">screenY</a></code> 属性他们是基于屏幕左上角的。另一个是 <code><a href="../../../../en/DOM/event.clientX" rel="internal">clientX</a></code> 、 <code><a href="../../../../en/DOM/event.clientY" rel="internal">clientY</a></code> 他们是相对于文件左上角的。这里有一个显示当前鼠标位置的例子。</p>
+ <p><span class="lang lang-en"><span id="Example_4"><strong>Example 4</strong></span> </span> : <span class="lang lang-en"><a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_advevents_4.xul.txt" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_advevents_4.xul.txt">Source</a> <a class="external" href="http://developer.mozilla.org/samples/xultu/examples/ex_advevents_4.xul" rel="external nofollow" title="http://developer.mozilla.org/samples/xultu/examples/ex_advevents_4.xul">View</a> </span></p>
+ <pre>&lt;script&gt;
+
+function updateMouseCoordinates(e){
+ var text = "X:" + e.clientX + " Y:" + e.clientY;
+ document.getElementById("xy").value = text;
+}
+&lt;/script&gt;
+
+&lt;label id="xy"/&gt;
+&lt;hbox width="400" height="400" onmousemove="updateMouseCoordinates(event);"/&gt;
+</pre>
+ <p>    在这个例子里,box 的尺寸被准确设定,这样更容易看出结果。事件处理器得到 <code><a href="../../../../en/DOM/event.clientX" rel="internal">clientX</a></code> 和 <code><a href="../../../../en/DOM/event.clientY" rel="internal">clientY</a></code> 属性并根据他们创建一个字符串。这个字符串又被设置成为 label.value 的值。注意事件对象必须作为参数传递给<code>updateMouseCoordinates</code> 函数。如果快速的在剥削的边缘上移动鼠标,你可能会发现坐标并不会准确的停到 400。这是因为 mousemove 事件触发的间隔取决于鼠标移动的速度。因为当鼠标移动过一段距离后新的事件才触发,因为发送鼠标每一像素的移动是十分没有效率的。</p>
+ </div>
+ <div id="section_7">
+ <h4 class="editable" id="元素相关坐标"><span>元素相关坐标</span></h4>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/More_Event_Handlers#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    你经常想知道事件发生时对元素的坐标而非对于这个窗口。这时你可以使用减法来计算,示例如下。</p>
+ <pre>var element = event.target;
+var elementX = event.clientX - element.boxObject.x;
+var elementY = event.clientY - element.boxObject.y;
+</pre>
+ <p>      XUL 元素有一个 box 对象可以通过 <code><span class="lang lang-en"><a href="../../../../en/XUL/Property/boxObject" rel="internal">boxObject</a> <span style="font-family: Verdana,Tahoma,sans-serif;">属性获得。在</span></span></code><a href="../../../../en/XUL_Tutorial/Box_Objects" rel="internal"><code><span class="lang lang-en"><span style="font-family: Verdana,Tahoma,sans-serif;">后一章</span></span></code></a><code><span class="lang lang-en"><span style="font-family: Verdana,Tahoma,sans-serif;">我们会学习更多相关内容</span></span></code>,但记住它保存着如何显示元素包括元素的x,y 位置。在这个例子中,这些坐标被从事件坐标中减去,这样就得到了事件相对于元素的坐标。</p>
+ </div>
+ </div>
+ <div id="section_8">
+ <h3 class="editable" id="加载事件"><span>加载事件 </span></h3>
+ <div class="editIcon">
+ <a href="/../../../../en/XUL_Tutorial/More_Event_Handlers#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    一旦XUL文件加载完成 load 事件就会被发送到文件 ( <code><span class="lang lang-en"><a href="../../../../en/XUL/window" rel="internal">window</a> <span style="font-family: Verdana,Tahoma,sans-serif;">标记</span></span></code>),此时正是内容显示之前。这个事件通常被用于初始化操作及完成一些任务使得用户可以使用窗口。你可以通过调用一个顶层的脚本函数来使用这一事件处理以上这些事情。这是因为XUL文件为完全加载,一些事情可能会处理出错。使用 load 事件,在 <code><span class="lang lang-en"><a href="../../../../en/XUL/window" rel="internal">window</a> </span></code>标记处放置 <code><span class="lang lang-en"><a href="../../../../en/XUL/Attribute/onload" rel="internal">onload</a> <span style="font-family: Verdana,Tahoma,sans-serif;">属性,调用处理加载事件的处理器来完成必要的界面初始化。</span></span></code></p>
+ <p>    也有unload 事件,它当窗口关闭时被调用,或者作为浏览器的内容时,页面换为另一URL 时调用。你可以使用这一事件保存任何改变的信息。</p>
+ <p><br>
+      接下来我们看看如何添加键盘快捷方式( <a href="../../../../en/XUL_Tutorial/Keyboard_Shortcuts" rel="internal">keyboard shortcuts</a>).</p>
+ <p> </p>
+ <div class="prevnext">
+ <p><span style="float: left;">« <a href="../../../../en/XUL_Tutorial/Adding_Event_Handlers" rel="internal">Previous</a></span> <span style="float: right;"><a href="../../../../en/XUL_Tutorial/Keyboard_Shortcuts" rel="internal">Next</a> »</span></p>
+ </div>
+ <p>  </p>
+ <p> </p>
+ </div>
+ </div>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/more_menu_features/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/more_menu_features/index.html
new file mode 100644
index 0000000000..30cc1b3046
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/more_menu_features/index.html
@@ -0,0 +1,108 @@
+---
+title: XUL_教程/更多菜单特性
+slug: Mozilla/Tech/XUL/Tutorial/More_Menu_Features
+tags:
+ - XUL_Tutorial
+translation_of: Archive/Mozilla/XUL/Tutorial/More_Menu_Features
+---
+<p> </p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Simple_Menu_Bars" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Popup_Menus">下一页 »</a></p>
+</div><p></p>
+<p>在本节中,我们来学习如何创建子菜单和check菜单。</p>
+<h3 id=".E5.88.9B.E5.BB.BA.E5.AD.90.E8.8F.9C.E5.8D.95" name=".E5.88.9B.E5.BB.BA.E5.AD.90.E8.8F.9C.E5.8D.95">创建子菜单</h3>
+<p>使用已存在元素可以在其它菜单(递归菜单)中创建子菜单。记住可以在<code>menupopup</code>中放置任意元素。我们已经学过在<code>menuseparator</code>s中放置<code>menuitem</code>s。但是,还可以通过在<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code></code>元素中简单的放置<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code></code>元素来创建子菜单。这样也可以运行,因为菜单元素即使不直接放在菜单栏里面它也是有效的。下面的示例在 文件 菜单中创建了一个简单的子菜单:</p>
+<p><span id="Example_1"><a id="Example_1"></a><strong>Example 1</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_advmenu_1.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_advmenu_1.xul">View</a></p>
+<div class="float-right">
+ <img alt="Image:menubar-ex3.png"></div>
+<pre>&lt;toolbox flex="1"&gt;
+ &lt;menubar id="sample-menubar"&gt;
+ &lt;menu id="file-menu" label="File"&gt;
+ &lt;menupopup id="file-popup"&gt;
+ &lt;menu id="new-menu" label="New"&gt;
+ &lt;menupopup id="new-popup"&gt;
+ &lt;menuitem label="Window"/&gt;
+ &lt;menuitem label="Message"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menu&gt;
+ &lt;menuitem label="Open"/&gt;
+ &lt;menuitem label="Save"/&gt;
+ &lt;menuseparator/&gt;
+ &lt;menuitem label="Exit"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menu&gt;
+ &lt;/menubar&gt;
+&lt;/toolbox&gt;
+</pre>
+<div class="highlight">
+ <h3 id=".E5.9C.A8.E6.88.91.E4.BB.AC.E7.9A.84.E3.80.80.E6.9F.A5.E6.89.BE.E6.96.87.E4.BB.B6.E3.80.80.E7.A4.BA.E4.BE.8B.E4.B8.AD.E5.8A.A0.E5.85.A5.E8.8F.9C.E5.8D.95" name=".E5.9C.A8.E6.88.91.E4.BB.AC.E7.9A.84.E3.80.80.E6.9F.A5.E6.89.BE.E6.96.87.E4.BB.B6.E3.80.80.E7.A4.BA.E4.BE.8B.E4.B8.AD.E5.8A.A0.E5.85.A5.E8.8F.9C.E5.8D.95">在我们的 查找文件 示例中加入菜单</h3>
+ <p>让我们在查找文件对话框中加入菜单。我们仅加入少量简单的命令至 文件 菜单和 编辑 菜单中。这与上面示例类似。</p>
+ <pre class="eval">&lt;toolbox&gt;
+
+ <span class="highlightred">&lt;menubar id="findfiles-menubar"&gt;
+ &lt;menu id="file-menu" label="File" accesskey="f"&gt;
+ &lt;menupopup id="file-popup"&gt;
+ &lt;menuitem label="Open Search..." accesskey="o"/&gt;
+ &lt;menuitem label="Save Search..." accesskey="s"/&gt;
+ &lt;menuseparator/&gt;
+ &lt;menuitem label="Close" accesskey="c"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menu&gt;
+ &lt;menu id="edit-menu" label="Edit" accesskey="e"&gt;
+ &lt;menupopup id="edit-popup"&gt;
+ &lt;menuitem label="Cut" accesskey="t"/&gt;
+ &lt;menuitem label="Copy" accesskey="c"/&gt;
+ &lt;menuitem label="Paste" accesskey="p" disabled="true"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menu&gt;
+ &lt;/menubar&gt;</span>
+
+&lt;toolbar id="findfiles-toolbar&gt;
+</pre>
+ <div class="float-right">
+ <img alt="Image:menubar1.png"></div>
+ <p>在此我们已经加入了两个菜单以及一些不同的菜单命令。注意菜单栏是如何放置在toolbox内的。在 打开搜索 和 保存搜索 后面的三个点通常提示用户本命令操作会打开一个对话框。每个菜单和菜单项已经加入了访问快捷键。在图中可以看到菜单标签内的字母已经被打上了下划线。而 粘贴 命令在此被禁止。我们假定没有什么可以用来粘贴。</p>
+ <p><span id="Our_Find_files_example_so_far"><a id="Our_Find_files_example_so_far"></a><strong>Our Find files example so far</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/findfile/findfile-advmenu.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/findfile/findfile-advmenu.xul">View</a></p>
+</div>
+<h3 id=".E7.BB.99.E8.8F.9C.E5.8D.95.E5.8A.A0.E5.85.A5.E5.8B.BE.E9.80.89.28check.29.E6.A0.87.E8.AE.B0" name=".E7.BB.99.E8.8F.9C.E5.8D.95.E5.8A.A0.E5.85.A5.E5.8B.BE.E9.80.89.28check.29.E6.A0.87.E8.AE.B0">给菜单加入勾选(check)标记</h3>
+<p>许多应用程序的菜单项都有check标记。例如,许可特性在命令里面会有一个check,而禁止特征则没有check在里面。当用户选择菜单后,check状态就进行了切换。你也可以在菜单项上创建radio按钮。</p>
+<p>check创建类似于<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/checkbox" title="checkbox">checkbox</a></code>元素和<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/radio" title="radio">radio</a></code>元素。包括了两个属性的使用:<code><a href="cn/XUL/Attribute/button.type">type</a></code>标识check的类型,而<code><a href="cn/XUL/Attribute/menuitem.name">name</a></code>标识同在一起的组命令。下面的示例创建一个带有check项的菜单。</p>
+<p><span id="Example_2"><a id="Example_2"></a><strong>Example 2</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_advmenu_2.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_advmenu_2.xul">View</a></p>
+<pre>&lt;toolbox&gt;
+ &lt;menubar id="options-menubar"&gt;
+ &lt;menu id="options_menu" label="Options"&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem id="backups" label="Make Backups" type="checkbox"/&gt;
+ &lt;menuitem id="backups" label="Email Administrator" type="checkbox" checked="true"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menu&gt;
+ &lt;/menubar&gt;
+&lt;/toolbox&gt;
+</pre>
+<p>加入的<code><a href="cn/XUL/Attribute/button.type">type</a></code>属性用来标识菜单项是可以check的。通过设置<code>checkbox</code>的值,通过选择菜单项,使它被勾选或取消勾选。</p>
+<h4 id=".E5.B8.A6.E6.9C.89radio.E6.A0.87.E8.AE.B0.E7.9A.84.E8.8F.9C.E5.8D.95" name=".E5.B8.A6.E6.9C.89radio.E6.A0.87.E8.AE.B0.E7.9A.84.E8.8F.9C.E5.8D.95">带有radio标记的菜单</h4>
+<p>除标准check菜单外,还可以通过设置<code><a href="cn/XUL/Attribute/button.type">type</a></code>的值为<code>radio</code>来创建radio风格的check型菜单。radio风格的check菜单用于在一组目录项中仅选择一项的时候。例如在一个菜单中每次只能选取一个生效的情况。当选取另外一项时,前面的选择项就会自动取消选择。</p>
+<p>为了将一组菜单项放置在一起,需要将每一项的<code><a href="cn/XUL/Attribute/menuitem.name">name</a></code>属性设置为一样,就会形成一个菜单组。示例如下:</p>
+<p><span id="Example_3"><a id="Example_3"></a><strong>Example 3</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_advmenu_3.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_advmenu_3.xul">View</a></p>
+<pre>&lt;toolbox&gt;
+ &lt;menubar id="planets-menubar"&gt;
+ &lt;menu id="planet-menu" label="Planet"&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem id="jupiter" label="Jupiter" type="radio" name="ringed"/&gt;
+ &lt;menuitem id="saturn" label="Saturn" type="radio" name="ringed" checked="true"/&gt;
+ &lt;menuitem id="uranus" label="Uranus" type="radio" name="ringed"/&gt;
+ &lt;menuseparator/&gt;
+ &lt;menuitem id="earth" label="Earth" type="radio" name="inhabited" checked="true"/&gt;
+ &lt;menuitem id="moon" label="Moon" type="radio" name="inhabited"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menu&gt;
+ &lt;/menubar&gt;
+&lt;/toolbox&gt;
+</pre>
+<p>试一下这个示例,可以发现前三个菜单项只有一个可以被勾选。它们被聚为一组,因为他们的name属性值相同。最后一个菜单项--Earth,一个radio按钮,由于拥有不同的name属性值,因此不是这个菜单组的一部分。</p>
+<p>当然,聚集在一组中的项只能放置在相同的菜单中。虽然将它们相邻的放在一起比分开放要直观得多,但在菜单中并没有必要将它们放在一起。</p>
+<p>下一回,我们将学习如何<a href="cn/XUL_%e6%95%99%e7%a8%8b/%e5%bc%b9%e5%87%ba%e8%8f%9c%e5%8d%95">创建弹出菜单</a>。</p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Simple_Menu_Bars" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Popup_Menus">下一页 »</a></p>
+</div><p></p>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/more_wizards/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/more_wizards/index.html
new file mode 100644
index 0000000000..48648bb971
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/more_wizards/index.html
@@ -0,0 +1,64 @@
+---
+title: More Wizards
+slug: Mozilla/Tech/XUL/Tutorial/More_Wizards
+translation_of: Archive/Mozilla/XUL/Tutorial/More_Wizards
+---
+<div>
+ <div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial/Creating_a_Wizard" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial/Overlays">下一页 »</a></p>
+</div></div>
+<p>This section describes some additional features of wizards.</p>
+<h2 id="More_Complex_Wizard_Navigation" name="More_Complex_Wizard_Navigation">More Complex Wizard Navigation</h2>
+<p>Normally, a wizard displays each <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/wizardpage" title="wizardpage">wizardpage</a></code></code> in the order that you place them in the XUL file. In some cases however, you may want to have different pages of the wizard appear depending on what the user selects in earlier pages.</p>
+<p>In this case, place a <code>pageid</code> attribute on each of the pages. This should be set to an identifier for each page. Then, to navigate to a page, use one of two methods:</p>
+<ol>
+ <li>Set the <code>next</code> attribute on each page to the page ID of the next page to go to. You can change these attributes as needed to navigate to different pages.</li>
+ <li>Call the wizard's <code>goTo()</code> method. It takes one argument, the page ID of a page to go to. You might call this method in the <code>onpageadvanced</code> or <code>onwizardnext</code> handlers. Remember to return false in this case, because you have already changed the page yourself. Note that the <code>goTo()</code> method, because it causes a page change, will fire the events again, so you'll have to make sure you handle that case.</li>
+</ol>
+<p>For example, here are a set of wizard pages (the inner content has been omitted):</p>
+<pre class="brush:xml">&lt;wizardpage pageid="type" next="font"&gt;
+&lt;wizardpage pageid="font" next="done"&gt;
+&lt;wizardpage pageid="color" next="done"&gt;
+&lt;wizardpage pageid="done"&gt;</pre>
+<ul>
+ <li>The wizard always starts at the first page, which in this case has the page ID <code>type</code>. The next page is the one with the page ID <code>font</code>, so the wizard will navigate to that page next.</li>
+ <li>On the page with the page ID <code>font</code>, we can see that the next page is <code>done</code>, so that page will be displayed afterwards.</li>
+ <li>The page with the page ID <code>done</code> has no <code>next</code> attribute, so this will be the last page.</li>
+</ul>
+<p>A script will adjust the <code>next</code> attributes as necessary to go to the page with the page ID <code>color</code> when needed.</p>
+<h2 id="Wizard_Functions" name="Wizard_Functions">Wizard Functions</h2>
+<p>The wizard works much like a <a href="/en-US/docs/XUL_Tutorial/Tabboxes" title="XUL_Tutorial/Tabboxes">tabbed panel</a>, except that the tabs are not displayed and the user navigates between pages by using the buttons along the bottom. Because all of the pages are part of the same file, all of the values of the fields on all pages will be remembered. Thus, you do not have to load and save information between pages.</p>
+<p>However, you may want to do some validation of each field on each page. For this, use the handlers described in the previous section. If a field is invalid, you might display an alert. In some cases, it would be more convenient to disable the Next button until valid input has been entered.</p>
+<p>The wizard has a property <code>canAdvance</code>, which can be set to true to indicate that the Next button should be enabled. If set to false, the Next button is disabled. You can change the property when invalid or valid data has been entered.</p>
+<p>In the following example, the user must enter a secret code into a textbox on the first page of the wizard. The function checkCode() is called whenever the first page is shown as indicated by the <code>onpageshow</code> attribute. It is also called whenever a key is pressed in the textbox, to determine whether the Next button should be enabled again.</p>
+<h3 id="Wizard_example" name="Wizard_example">Wizard example</h3>
+<p><a href="https://developer.mozilla.org/samples/xultu/examples/ex_advwiz_1.xul.txt">Source</a></p>
+<pre class="brush:xml">&lt;?xml version="1.0"?&gt;
+&lt;?xml-stylesheet href="chrome://global/skin/" type="text/css"?&gt;
+
+&lt;wizard id="theWizard" title="Secret Code Wizard"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;
+
+&lt;script&gt;
+function checkCode(){
+ document.getElementById('theWizard').canAdvance = (document.getElementById('secretCode').value == "cabbage");
+}
+&lt;/script&gt;
+
+ &lt;wizardpage onpageshow="checkCode(); return true;"&gt;
+ &lt;label value="Enter the secret code:"/&gt;
+ &lt;textbox id="secretCode" onkeyup="checkCode();"/&gt;
+ &lt;/wizardpage&gt;
+
+ &lt;wizardpage&gt;
+ &lt;label value="That is the correct secret code."/&gt;
+ &lt;/wizardpage&gt;
+
+&lt;/wizard&gt;</pre>
+<p>There is also a corresponding <code>canRewind</code> property that you can use to enable or disable the Back button. Both properties are adjusted automatically as you switch pages. Thus, the Back button will be disabled on the first page so you don't have to set it yourself.</p>
+<p>Another useful property of the wizard is <code>currentPage</code>, which holds a reference to the currently displayed <code>wizardpage</code>. You can also modify the current page by changing this property. If you do change it, the various page change events will still be fired.</p>
+<p>Next, we'll see how to use overlays to <a href="/en-US/docs/XUL_Tutorial/Overlays" title="XUL_Tutorial/Overlays">handle common content</a>.</p>
+<div>
+ <div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial/Creating_a_Wizard" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial/Overlays">下一页 »</a></p>
+</div></div>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/numeric_controls/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/numeric_controls/index.html
new file mode 100644
index 0000000000..310abf97a4
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/numeric_controls/index.html
@@ -0,0 +1,78 @@
+---
+title: 数值控件
+slug: Mozilla/Tech/XUL/Tutorial/Numeric_Controls
+translation_of: Archive/Mozilla/XUL/Tutorial/Numeric_Controls
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Input_Controls" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:List_Controls">下一页 »</a></p>
+</div><p></p>
+<p></p>
+<p>XUL有两种输入数值或者范围的元素,两种输入日期和时间的元素。这些元素仅适用于Firefox 3以及后续版本。</p>
+<p>XUL has two elements used for the entry of numeric values or ranges, and well as two elements for entering dates and times. These elements are only available in Firefox 3 and later.</p>
+<h3 id="Number_Fields" name="Number_Fields">数值域Number Fields</h3>
+<p>textbox元素也可以用于输入数值,只要设置<code id="a-type"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/type">type</a></code>属性的值为<code>number</code>即可。这种类型的textbox可以仅用于输入数字而会忽略输入的其他类型字符。另外,textbox一侧添加了上下箭头,允许用户增减输入的值。</p>
+<p>A textbox may be used for entering numbers by setting the value of the <code id="a-type"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/type">type</a></code> attribute to the value <code>number</code>. This type of textbox may only be used to enter numbers. Other characters are not allowed and are just ignored if typed. In addition, arrow buttons appear beside the textbox to allow the user to cycle through the values.</p>
+<div class="float-right">
+ <img alt="Image:Controlguide-textbox-number.gif" class="internal" src="/@api/deki/files/137/=Controlguide-textbox-number.gif"></div>
+<p>和其他类型的textbox一样,可以通过<code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code>属性指定默认值。自然,这个值应该是一个数值。另外,可以通过<code id="a-min"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/min">min</a></code>属性和<code id="a-max"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/max">max</a></code>属性指定元素的最小和最大值。如果指定了最小和最大值,你就设定了textbox可以输入的值域。如果用户输入了一个超出上下界的值,它会自动取最大值或最小值代替。例如,下面的数值类型textbox的值域是1到20。</p>
+<p>As with other textboxes, the default value can be specified with the <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code> attribute. Naturally, this value should be a number. However, the minimum and maximum values can also be specified using the <code id="a-min"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/min">min</a></code> and <code id="a-max"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/max">max</a></code> attributes. If these are set, you can control the range of values that the textbox may be set to. If the user enters a value less or greater than this value, it will be reset to the minimum or maximum value as necessary. For instance, the following numeric textbox has a range between 1 and 20.</p>
+<pre>&lt;textbox type="number" min="1" max="20"/&gt;
+</pre>
+<p>由于没有指定默认值,元素默认取值1,即最小值。设置<code id="a-min"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/min">min</a></code>属性为1表明元素的最小可能值是1,同时设置<code id="a-max"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/max">max</a></code>属性为20表明最大可能值是20。如果没有设置最小值,那么默认是0。<code id="a-max"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/max">max</a></code>属性默认是<code>Infinity</code>,即最大值没有限制。</p>
+<p>As the default value isn't specified, it will default to 1, the minimum value. The <code id="a-min"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/min">min</a></code> attribute is set to <code>1</code> to indicate a minimum possible value of 1 and the <code id="a-max"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/max">max</a></code> attribute is set to <code>20</code> to indiciate a maximum possible value of 20. If the minimum value is not specified, it has a default value of 0. The maximum value defaults to the special value <code>Infinity</code> which means that there is no limit.</p>
+<h4 id="Other_numeric_textbox_attributes" name="Other_numeric_textbox_attributes">其他数值型textbox属性Other numeric textbox attributes</h4>
+<p><code id="a-increment"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/increment">increment</a></code>属性指定当点击箭头时数值的改变量。默认值是1,当然可以设置一个更大的值来加大改变量。例如,下面的例子设置为以10的倍数改变值。</p>
+<p>The <code id="a-increment"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/increment">increment</a></code> attribute may be used to specify by how much the value changes when the arrows are pressed. The default value is 1, but specifying a different value allows the number to change by a larger amount. For instance, the following example steps in multiples of 10.</p>
+<pre>&lt;textbox type="number" increment="10" max="100"/&gt;
+</pre>
+<p>这个textbox从0到100,依次取10的倍数。由于没有指定<code id="a-min"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/min">min</a></code>属性,默认是0。注意,用户仍然可以直接输入其他值。<code id="a-increment"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/increment">increment</a></code>属性只会影响到上下箭头。当textbox有焦点时,用户可以通过上箭头增加值,用下箭头减小值。</p>
+<p>This textbox steps in multiples of 10 from 0 to 100. Since the <code id="a-min"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/min">min</a></code> attribute was not specified, it defaults to 0. Note that the user can still enter other values if they are typed in. The <code id="a-increment"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/increment">increment</a></code> attribute only affects the arrow buttons. The user may also increment or decrement the value using this increment by using the up and down cursor keys while the textbox is focused.</p>
+<p><code id="a-decimalplaces"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/decimalplaces">decimalplaces</a></code>属性表明需要显示的小数位数。默认值是0,表明只显示整数部分。指定其他值则可用于显示小数。</p>
+<p>The <code id="a-decimalplaces"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/decimalplaces">decimalplaces</a></code> attribute indicates how many decimal places to show. The default value is 0, which means show integers only. However a different value may be used to show decimal values.</p>
+<pre>&lt;textbox type="number" decimalplaces="2"/&gt;
+</pre>
+<p>在这个例子中,textbox将显示小数点后两位数字。小数位数多于两位的数值会被舍入到两位小数。</p>
+<p>In this example, two digits right of the decimal point are shown. Values with additional fractional digits are rounded to two digits.</p>
+<h3 id="Scales" name="Scales">滑块Scales</h3>
+<p><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/scale" title="scale">scale</a></code>元素也可以用来从一个区间中选择值。和textbox不同的是滑轨代替了文本框。用户可以拖动滑轨上的滑块来调整值。</p>
+<p>A <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/scale" title="scale">scale</a></code> element may also be used to select from a range of values. Instead of a textbox however, a sliding scale is used. The user may drag the thumb of the scale to adjust the value.</p>
+<div class="float-right">
+ <img alt="Image:Controlguide-scale.gif" class="internal" src="/@api/deki/files/133/=Controlguide-scale.gif"></div>
+<p>Scale与textbox有很多相同的属性:<code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code>, <code id="a-min"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/min">min</a></code>, <code id="a-max"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/max">max</a></code> and <code id="a-increment"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/increment">increment</a></code>,使用方法也类似。Scale并不实际显示数值,但这个值可能在脚本中用到。当值改变时,Scale将触发<code>change</code>事件。</p>
+<p>Many of the same attributes as a numeric textbox may be used with a scale: <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code>, <code id="a-min"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/min">min</a></code>, <code id="a-max"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/max">max</a></code> and <code id="a-increment"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/increment">increment</a></code> may all be used in a similar fashion. The scale does not actually show the value as a number, but it may be used in a script. A scale will fire a <code>change</code> event whenever the scales's value is modified.</p>
+<pre>&lt;scale value="40" min="1" max="50"/&gt;
+</pre>
+<p>这个例子设置了一个默认值是40,值域是1到50的Scale元素。</p>
+<p>This scale defaults to a value of 40 and has a range between 1 and 50.</p>
+<p>数值型textbox一般应用于数值对用户而言很重要的情况,例如需要用户输入天数或者文件的最大大小。而Scale则应该用于实际值对用户不那么重要,只要用户能改变它就可以的情况。例如调整音量或者缩放。</p>
+<p>A numeric textbox would normally be used when the value was important to the user, for instance, a field to enter a number of days, or the maximum size of a file. A scale would be used when the actual value isn't important, just that sliding the scale decreases or increases a state. For instance, a volume slider or a zoom level.</p>
+<p>Scale元素的默认布局是小值在左,大值在右,水平放置。可以通过改变<code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code>属性和<code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code>属性修改。</p>
+<p>The default arrangement of a scale is horizontal with lower values to the left and higher values to the right. However, you can change this orientation with the <code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code> and <code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code> attributes.</p>
+<pre>&lt;scale orient="vertical" dir="reverse"/&gt;
+</pre>
+<p>这个例子设置Scale垂直显示,且小值在下,大值在上。</p>
+<p>This scale will be shown vertical with lower values at the bottom and higher values at the top.</p>
+<h3 id="Date_and_Time_Entry_Fields" name="Date_and_Time_Entry_Fields">日期时间输入域Date and Time Entry Fields</h3>
+<p><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/datepicker" title="datepicker">datepicker</a></code>元素和<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/timepicker" title="timepicker">timepicker</a></code>元素用于用户输入日期和时间。他们会显示一组数值textbox用于输入日期和时间的各部分。</p>
+<p>The <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/datepicker" title="datepicker">datepicker</a></code> and <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/timepicker" title="timepicker">timepicker</a></code> elements may be used to allow the user to enter dates and times. When used, they display a set of numeric textboxes to enter each of the components of the date or time.</p>
+<pre>&lt;datepicker value="2004-03-24"/&gt;
+&lt;timepicker value="15:30:00"/&gt;
+</pre>
+<div class="float-right">
+ <img alt="Image:Controlguide-timepicker.gif" class="internal" src="/@api/deki/files/141/=Controlguide-timepicker.gif"></div>
+<p><code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code>属性用于设置默认值;如果没有显示指定,则初始化为当前日期或时间。属性值的格式严格按照例子所示,日期为YYYY-MM-DD,时间是HH:MM:SS(也可以省去秒以及前面的冒号)。</p>
+<p>The <code>value</code> attribute is used to set the default value; if this attribute is omitted, the field will be initially set to the current date or time. The format of the attribute is exactly as above, that is dates are of the form YYYY/MM/DD and times are of the form HH:MM:SS (although the seconds and the accompanying colon may be omitted).</p>
+<p>这两个元素保证用户输入一个有效的日期或者时间,因此你就不用再自己校验用户输入的日是不是大于当月的总天数以及闰年等等。</p>
+<p>These two elements ensure that the user enters a value date or time. This way, you do not have to check for valid dates, ensure that the day isn't greater than the number of days in the month, handle leap years, and so forth.</p>
+<p><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/timepicker" title="timepicker">timepicker</a></code>元素只有一种样式,而<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/datepicker" title="datepicker">datepicker</a></code>元素有三种不同的样式。默认样式是显示三个输入域分别对应年月日。<code id="a-type"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/type">type</a></code>属性用于选择另外两种样式。<code>grid</code>样式效果如下。</p>
+<p>While the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/timepicker" title="timepicker">timepicker</a></code> only comes is one style, the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/datepicker" title="datepicker">datepicker</a></code> has three different variations. The default style shows three fields for entering the year, month and date. The <code id="a-type"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/type">type</a></code> attribute may be used to select the other two. Using a value of <code>grid</code> uses a calendar grid, as shown in the image below.</p>
+<p><img alt="Image:Controlsguide-datepicker-grid.png" class="internal" src="/@api/deki/files/156/=Controlsguide-datepicker-grid.png"></p>
+<p>你也可以使用<code>popup样式,该样式结合了另两种,也有三个输入域用于输入年月日,同时提供一个下拉按钮,用于显示日历供用户选择一天。</code></p>
+<p>You can also use the value <code>popup</code> which creates a combination of the two types. This type has three fields for entering the year, month and date, as well as a dropdown button for displaying a popup calendar grid for selecting a day.</p>
+<pre>&lt;datepicker type="popup"/&gt;
+</pre>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Input_Controls" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:List_Controls">下一页 »</a></p>
+</div><p></p>
+<p> </p>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/popup_menus/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/popup_menus/index.html
new file mode 100644
index 0000000000..026ec62f83
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/popup_menus/index.html
@@ -0,0 +1,6 @@
+---
+title: 弹出菜单
+slug: Mozilla/Tech/XUL/Tutorial/Popup_Menus
+translation_of: Archive/Mozilla/XUL/Tutorial/Popup_Menus
+---
+<p>[fd]</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/progress_meters/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/progress_meters/index.html
new file mode 100644
index 0000000000..bacf39b352
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/progress_meters/index.html
@@ -0,0 +1,58 @@
+---
+title: XUL_教程/进度条
+slug: Mozilla/Tech/XUL/Tutorial/Progress_Meters
+tags:
+ - XUL_教程
+translation_of: Archive/Mozilla/XUL/Tutorial/Progress_Meters
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:List_Controls" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Adding_HTML_Elements">下一页 »</a></p>
+</div><p></p>
+<p> </p>
+<h3 id=".E6.B7.BB.E5.8A.A0.E4.B8.80.E4.B8.AA.E8.BF.9B.E5.BA.A6.E6.9D.A1" name=".E6.B7.BB.E5.8A.A0.E4.B8.80.E4.B8.AA.E8.BF.9B.E5.BA.A6.E6.9D.A1">添加一个进度条</h3>
+<p>进度条是条状的,它用来指示一个任务完成了多少。你通常可以在当下载文件或当执行一个很长的操作时看到它。XUL有一个<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/progressmeter" title="progressmeter">progressmeter</a></code>元素可以用来创建这些。有两种类型的进度条: 确定的和不确定的。</p>
+<p>确定的进度条可以用在当你已经知道完成某个操作的时间长度时。进度条将会被往上填充,并且在充 满时,操作刚好完成。这会用在文件的长度已经知道的下载文件对话框。</p>
+<p>不确定进度条会用于当你不知道一个操作的时间长度的情况。进度条是动态的就像一个不停循环移动的杆或一个可调整的框,发生在平台和外观被使用。</p>
+<p>确定的进度条: <img alt="Image:prog-det.png" class="internal" src="/@api/deki/files/2673/=Prog-det.png"></p>
+<p>不确定的进度条: <img alt="Image:prog-udet.png" class="internal" src="/@api/deki/files/2674/=Prog-udet.png"></p>
+<p>进度条的语法如下:</p>
+<pre>&lt;progressmeter
+ id="identifier"
+ mode="determined"
+ value="50%"/&gt;
+</pre>
+<p>属性如下:</p>
+<dl>
+ <dt>
+ <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> </dt>
+ <dd>
+ 进度条的唯一标识符。</dd>
+ <dt>
+ <a href="/cn/XUL/Attribute/progressmeter.mode" title="cn/XUL/Attribute/progressmeter.mode">mode</a></dt>
+ <dd>
+ 进度条的类型。如果这里设置为<code>determined</code>,进度条就是确定型进行度,在任务完成时在填满。如果这里设置为<code>undetermined</code>,这个进度条就是不确定型进度条,用于当你不知道花费时间的长度时。如果不指定这个属性默认值为确定型。</dd>
+ <dt>
+ <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code> </dt>
+ <dd>
+ 当前进度条的尺度值。你只能在确定型进度条中使用这个属性。这个值可以设成从0%到100%的百分值。这个值可以在任务结束时由脚本来改变。</dd>
+</dl>
+<div class="highlight">
+ <h5 id=".E6.96.87.E4.BB.B6.E6.9F.A5.E6.89.BE.E7.9A.84.E4.BE.8B.E5.AD.90" name=".E6.96.87.E4.BB.B6.E6.9F.A5.E6.89.BE.E7.9A.84.E4.BE.8B.E5.AD.90">文件查找的例子</h5>
+ <p>让我们添加一个进度条到我们文件查找的对话框吧。我们应该使用不确定的进度条因为我们不知道能搜索到多少文件或者要多久才能搜索完成。然而,现在我们将要增加一个普通的因为动态的可以避免在开发期间的困恼。 进度条仅显示在搜索过程中。我们将在后面的脚本中对它进行开合控制。</p>
+ <pre class="eval">&lt;hbox&gt;
+
+ <span class="highlightred">&lt;progressmeter value="50%" style="margin: 4px;"/&gt;</span>
+
+ &lt;spacer flex="1"/&gt;
+&lt;/hbox&gt;
+</pre>
+ <p>值被设成50%因此我们能在窗口上看到尺度。边缘被设成4像素因此它会与窗口的边缘分开。最开始,我们只希望进度条被显示在搜索开始时。脚本会在需要时显示和隐藏它。</p>
+ <p>例子太长了。 <a href="https://developer.mozilla.org/samples/xultu/examples/findfile/findfile-progress.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/findfile/findfile-progress.xul">View</a></p>
+ <p><img alt="Image:progress1.png" class="internal" src="/@api/deki/files/2675/=Progress1.png"></p>
+ <p> </p>
+</div>
+<p>在下一节,我们将学习如何<a href="/cn/XUL_教程/添加HTML元素" title="cn/XUL_教程/添加HTML元素">在窗口增加HTML的附加元素</a>。</p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:List_Controls" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Adding_HTML_Elements">下一页 »</a></p>
+</div><p></p>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/property_files/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/property_files/index.html
new file mode 100644
index 0000000000..a5800e69f9
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/property_files/index.html
@@ -0,0 +1,97 @@
+---
+title: 属性文件
+slug: Mozilla/Tech/XUL/Tutorial/Property_Files
+translation_of: Archive/Mozilla/XUL/Tutorial/Property_Files
+---
+<div id="page-top">
+ <div class="pageText" id="pageText">
+ <p> </p>
+ <p>    在脚本中,不能使用实体,用属性文件代替。</p>
+ <p> </p>
+ <div id="section_1">
+ <h3 class="editable" id="属性"><span>属性</span></h3>
+ <div class="editIcon">
+ <a href="../../../../en/XUL_Tutorial/Property_Files#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    当你在XUL文件中使用DTD文件是恰当的。然而,脚本不解析实体。也就是说,如果你希望在脚本中显示信息而且你不知道到底要显示什么,请使用属性文件</p>
+ <p>    一个属性文件包含一系列字符串。你可以在DTD文件旁边找到属性文件(.properties后缀)。属性按照以下语法定义 name=value。实例如下。</p>
+ <pre>notFoundAlert=No files were found matching the criteria.
+deleteAlert=Click OK to have all your files deleted.
+resultMessage=%2$S files found in the %1$S directory.
+</pre>
+ <p>    上例中,属性文件包含桑属性,可以由脚本读取显示给用户。</p>
+ </div>
+ <div id="section_2">
+ <h3 class="editable" id="Stringbundles"><span>Stringbundles </span></h3>
+ <div class="editIcon">
+ <a href="../../../../en/XUL_Tutorial/Property_Files#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>   你可以写一段代码手动来读取属性,而在XUL中有一个 <code><span class="lang lang-en"><a href="../../../../en/XUL/stringbundle" rel="internal">stringbundle</a> </span></code>元素来帮你做。这个元素有一系列函数有属性文件中获取属性并得到本地化信息。这个元素有属性文件读取内容并为你建立一个属性列表。你可以通过名字来查找属性。</p>
+ <pre>&lt;stringbundleset id="strbundles"&gt;
+&lt;stringbundle id="strings" src="strings.properties"/&gt;
+&lt;/stringbundleset&gt;
+</pre>
+ <p>    这个元素会从与该XUL文件系统的目录中读取名为 'strings.properties'的文件。像其他非显示元素一样你可以使用一个 <code><span class="lang lang-en"><a href="../../../../en/XUL/stringbundleset" rel="internal">stringbundleset</a> <span style="font-family: Verdana,Tahoma,sans-serif;">来包含所以的</span></span></code><code><span class="lang lang-en"><a href="../../../../en/XUL/stringbundle" rel="internal">stringbundle</a> </span></code><code><span class="lang lang-en"><span style="font-family: Verdana,Tahoma,sans-serif;">。</span></span></code></p>
+ <div id="section_3">
+ <h4 class="editable" id="由_stringbundle获取字符串"><span>由 </span><code><span class="lang lang-en"><a href="../../../../en/XUL/stringbundle" rel="internal">stringbundle</a>获取字符串</span></code></h4>
+ <div class="editIcon">
+ <a href="../../../../en/XUL_Tutorial/Property_Files#" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>     <code><span class="lang lang-en"><a href="../../../../en/XUL/stringbundle" rel="internal">stringbundle</a> </span></code> 元素有一系列方法。首先是 <code>getString</code> 用于脚本读取字符串。</p>
+ <pre>var strbundle = document.getElementById("strings");
+var nofilesfound=strbundle.getString("notFoundAlert");
+
+alert(nofilesfound);
+</pre>
+ <ul>
+ <li>本例首先使用 <code>id 获得字符串束的一个引用</code></li>
+ <li>然后在属性文件中查找 'notFoundAlert' 字符串 <code>getString()</code> 函数返回字符串的值或 null (字符串不存在)。</li>
+ <li>最后把职工文本显示在提示框里。</li>
+ </ul>
+ </div>
+ <div id="section_4">
+ <h4 class="editable" id="文本格式"><span>文本格式</span></h4>
+ <div class="editIcon">
+ <a href="../../../../en/XUL_Tutorial/Property_Files#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    <code>getFormattedString()</code>方法也根据名字从文本束中查找字符串,此外会按照格式控制代码 (如 <code>%S</code>) 将其后给出的数组内容替换入字符串。</p>
+ <pre>var dir = "/usr/local/document";
+var count = 10;
+
+var strbundle = document.getElementById("strings");
+var result = strbundle.getFormattedString("resultMessage", [ dir, count ]);
+
+alert(result);
+</pre>
+ <p>    本例显示如下。</p>
+ <pre>10 files found in the /usr/local/document directory.</pre>
+ <p>    你会注意到格式化代码 <code>%1$S</code> 及 <code>%2$S</code>被使用,替换顺序也和在数组中的不同。格式化代码 %<em>n</em>$S 直接描述替换参数的位置。尽管在不同语言中词序可能不同通过 <code>getFormattedString()</code>描述的顺序可以被写入属性文件。</p>
+ </div>
+ </div>
+ <div id="section_5">
+ <h3 class="editable" id="非ASCII码的换码符"><span>非ASCII码的换码符 </span></h3>
+ <div class="editIcon">
+ <a href="../../../../en/XUL_Tutorial/Property_Files#" style="" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></div>
+ <p>    (这可能不再正确:在 <a href="../../../../en/Localizing_extension_descriptions" rel="internal">Localizing extension descriptions</a>中说 “使用 UTF-8 编码(而非 BOM) 保证外文正确显示。” UTF-8 编码文本有效, 换码符同样有用。一些新想法的引入会更有用。)</p>
+ <p>    尽管大多数语言使用非ASCII字符集。属性文件只能使用ASCII字符集编制。然而,属性文件支持其他字符的换码形式: <code>\uXXXX</code> 这里的 XXXX 是字符码,因此,你的属性文件可以包含非ASCII字符,不过你需要把他们转换为换码形式。你可以使用 Sun's Java Development Kit (JDK)的 native2ascii 命令来完成它。</p>
+ <p>Gecko 1.8.x (or later) 支持属性文件以 UTF-8编码。你可以直接写入非ASCII字符。</p>
+ <p><br>
+ 下一章,我们将讨论 XBL,它用于定义元素的行为( <a href="../../../../en/XUL_Tutorial/Introduction_to_XBL" rel="internal">behavior of an element</a>.)</p>
+ <p> </p>
+ <div class="prevnext">
+ <p><span style="float: left;">« <a href="../../../../en/XUL_Tutorial/Localization" rel="internal">Previous</a></span> <span style="float: right;"><a href="../../../../en/XUL_Tutorial/Introduction_to_XBL" rel="internal">Next</a> »</span></p>
+ </div>
+ <p>  </p>
+ <p> </p>
+ </div>
+ </div>
+</div>
+<div class="printfooter" id="printfooter">
+ <hr>
+ <p>Retrieved from "<a href="../../../../En/XUL_Tutorial/Property_Files">https://developer.mozilla.org/En/XUL_Tutorial/Property_Files</a>"</p>
+</div>
+<div class="collapsed" id="languages">
+ <h5 id="Languages">Languages</h5>
+ <ul style="display: none;">
+ <li><a href="../../../../fr/Tutoriel_XUL/Les_fichiers_de_propri%c3%a9t%c3%a9s" rel="internal">Français</a></li>
+ <li><a href="../../../../pl/Kurs_XUL/Plik_w%c5%82asno%c5%9bci" rel="internal">Polski</a></li>
+ <li><a href="../../../../ja/XUL_Tutorial/Property_Files" rel="internal">日本語</a></li>
+ </ul>
+</div>
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/rdf_datasources/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/rdf_datasources/index.html
new file mode 100644
index 0000000000..b4d4c51238
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/rdf_datasources/index.html
@@ -0,0 +1,267 @@
+---
+title: RDF Datasources
+slug: Mozilla/Tech/XUL/Tutorial/RDF_Datasources
+translation_of: Archive/Mozilla/XUL/Tutorial/RDF_Datasources
+---
+<p> </p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Trees_and_Templates" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Advanced_Rules">下一页 »</a></p>
+</div><p></p>
+<p>Here, we'll look at additional datasources and how to use your own RDF files as datasources.</p>
+<h3 id="Other_Mozilla_Datasources" name="Other_Mozilla_Datasources">Other Mozilla Datasources</h3>
+<p>Mozilla provides a number of other built-in datasources. Some of them are listed here with a few examples. They work very similarly to the bookmarks, although the fields will be different in each case.</p>
+<h3 id="The_History_List" name="The_History_List">The History List</h3>
+<p>The history datasource provides access to the user's history list which is the list of URLs the user has visited recently. The resource can be referred to using <code>rdf:history</code> as the datasource. The table below shows the resources (or fields) that you can retrieve from the history datasource. Put the URL values below where you want the value of the resource to be used.</p>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <td>Date</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#Date</span></td>
+ <td>Date of last visit</td>
+ </tr>
+ <tr>
+ <td>Name</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#Name</span></td>
+ <td>Title of the page</td>
+ </tr>
+ <tr>
+ <td>Page</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#Page</span></td>
+ <td>Page name</td>
+ </tr>
+ <tr>
+ <td>Referrer</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#Referrer</span></td>
+ <td>Referrer of the page</td>
+ </tr>
+ <tr>
+ <td>URL</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#URL</span></td>
+ <td>URL of the page</td>
+ </tr>
+ <tr>
+ <td>Visit Count</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#VisitCount</span></td>
+ <td>Number of page visits</td>
+ </tr>
+ </tbody>
+</table>
+<p>A typical history list will display a tree with a selection of these fields. To use them, just put the URL values above in the <code>label</code> attributes of the buttons or treecells. You can use <code>NC:HistoryRoot</code> as the value of the <code>ref</code> attribute. You can also use the value <code>NC:HistoryByDate</code> to get the history sorted into days.</p>
+<h4 id="Using_The_History_List_Example" name="Using_The_History_List_Example">Using The History List Example</h4>
+<p>Let's see an example of displaying the history list. We'll display the history in a tree with three columns, the Name, the URL and the Date.</p>
+<p><span id="Example_1"><a id="Example_1"></a><strong>Example 1</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_datasrc_1.xul.txt">Source</a></p>
+<pre>&lt;tree flex="1" datasources="rdf:history" ref="NC:HistoryRoot"&gt;
+
+ &lt;treecols&gt;
+ &lt;treecol id="name" label="Name" flex="1"/&gt;
+ &lt;treecol id="url" label="URL" flex="1"/&gt;
+ &lt;treecol id="date" label="Date" flex="1"/&gt;
+ &lt;/treecols&gt;
+
+ &lt;template&gt;
+
+ &lt;rule&gt;
+ &lt;treechildren&gt;
+ &lt;treeitem uri="rdf:*"&gt;
+ &lt;treerow&gt;
+ &lt;treecell label="rdf:http://home.netscape.com/NC-rdf#Name"/&gt;
+ &lt;treecell label="rdf:http://home.netscape.com/NC-rdf#URL"/&gt;
+ &lt;treecell label="rdf:http://home.netscape.com/NC-rdf#Date"/&gt;
+ &lt;/treerow&gt;
+ &lt;/treeitem&gt;
+ &lt;/treechildren&gt;
+ &lt;/rule&gt;
+
+ &lt;/template&gt;
+&lt;/tree&gt;
+</pre>
+<h3 id="Other_Datasources" name="Other_Datasources">Other Datasources</h3>
+<p>The tables below list some of the other datasources available with Mozilla. You can use any of the resources that you want.</p>
+<dl>
+ <dt>
+ Bookmarks (<span class="nowiki">rdf:bookmarks</span>)</dt>
+ <dd>
+ The bookmarks are generated from the user's bookmark list.</dd>
+</dl>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th colspan="3">Resources</th>
+ </tr>
+ <tr>
+ <td>Added Date</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#BookmarkAddDate</span></td>
+ <td>Date the bookmark was added</td>
+ </tr>
+ <tr>
+ <td>Description</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#Description</span></td>
+ <td>Bookmark description</td>
+ </tr>
+ <tr>
+ <td>Last Modified</td>
+ <td><span class="nowiki">http://home.netscape.com/WEB-rdf#LastModifiedDate</span></td>
+ <td>Date of last modification</td>
+ </tr>
+ <tr>
+ <td>Last Visited</td>
+ <td><span class="nowiki">http://home.netscape.com/WEB-rdf#LastVisitDate</span></td>
+ <td>Date of last visit</td>
+ </tr>
+ <tr>
+ <td>Name</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#Name</span></td>
+ <td>Bookmark name</td>
+ </tr>
+ <tr>
+ <td>Shortcut URL</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#ShortcutURL</span></td>
+ <td>Custom keywords field</td>
+ </tr>
+ <tr>
+ <td>URL</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#URL</span></td>
+ <td>The URL to link to</td>
+ </tr>
+ </tbody>
+</table>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th colspan="2">Possible Bookmarks Roots</th>
+ </tr>
+ <tr>
+ <td>NC:BookmarksRoot</td>
+ <td>The top level of the bookmarks hierarchy</td>
+ </tr>
+ <tr>
+ <td>NC:IEFavoritesRoot</td>
+ <td>The bookmark folder that corresponds to the user's IE favorites.</td>
+ </tr>
+ <tr>
+ <td>NC:PersonalToolbarFolder</td>
+ <td>The bookmark folder that corresponds to the personal toolbar folder.</td>
+ </tr>
+ </tbody>
+</table>
+<dl>
+ <dt>
+ Files (<span class="nowiki">rdf:files</span>)</dt>
+ <dd>
+ A view of the user's files.</dd>
+</dl>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th colspan="3">Resources</th>
+ </tr>
+ <tr>
+ <td>Name</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#Name</span></td>
+ <td>Name of the file</td>
+ </tr>
+ <tr>
+ <td>URL</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#URL</span></td>
+ <td>URL of the file</td>
+ </tr>
+ <tr>
+ <td>Content-Length</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#Content-Length</span></td>
+ <td>The length of the file.</td>
+ </tr>
+ <tr>
+ <td>LastModifiedDate</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#LastModifiedDate</span></td>
+ <td>The date that URL was last modified.</td>
+ </tr>
+ <tr>
+ <td>extension</td>
+ <td><span class="nowiki">http://home.netscape.com/NC-rdf#extension</span></td>
+ <td>The extension of the file, including the period. This property is only available on platforms that use file extensions.</td>
+ </tr>
+ </tbody>
+</table>
+<table class="fullwidth-table">
+ <tbody>
+ <tr>
+ <th colspan="2">Possible Files Roots</th>
+ </tr>
+ <tr>
+ <td>NC:FilesRoot</td>
+ <td>Top level of the filesystem (usually the list of drives)</td>
+ </tr>
+ <tr>
+ <td>A file URL</td>
+ <td>By using a file URL for the ref attribute, you can select a specific directory to be returned. For example, you might use <a class="external" rel="freelink">file:///windows</a> or <a class="external" rel="freelink">files:///usr/local</a>.</td>
+ </tr>
+ </tbody>
+</table>
+<p>The files datasource is an example of a datasource that determines its resources only when necessary. We don't want every file in the filesystem to be determined before the data is displayed. Instead, only the files and directories that the tree element (or other elements) will need to display at a given time will be determined.</p>
+<h3 id="Composite_Datasources" name="Composite_Datasources">Composite Datasources</h3>
+<p>You can specify multiple datasources in the <code>datasources</code> attribute by separating them with whitespace as in the example below. This has the effect of reading the data from all the datasources mentioned.</p>
+<pre>&lt;tree datasources="rdf:bookmarks rdf:history animals.rdf" ref="NC:BookmarksRoot"&gt;
+</pre>
+<p>This example reads the resources from the bookmarks, history and the animals.rdf file. They are combined into a single composite datasource and can be used as if they were one.</p>
+<p>The special datasource <code>rdf:null</code> corresponds to nothing. You can use this datasource if you want to dynamically set the datasource using a script, but don't want one initially or don't know its exact URL.</p>
+<h3 id="Custom_RDF_Datasources" name="Custom_RDF_Datasources">Custom RDF Datasources</h3>
+<p>You can use any of the above internal datasources if you wish. There are several others for mail, address books and searching and so on. However, you might want to use your own RDF datasource stored in an RDF file. The file can be either a local file or a remote file. Just put the URL of the RDF file in the <code><code id="a-datasources"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/datasources">datasources</a></code></code> attribute.</p>
+<p>Using RDF files provides just as much functionality as any of the internal datasources. You can use rules to match specific types of content. The attributes on the <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/rule" title="rule">rule</a></code></code> element will match if they match the attributes on an RDF <code>Description</code> element. You can also create RDF files that are hierarchical.</p>
+<h4 id="Using_RDF_file_Example" name="Using_RDF_file_Example">Using RDF file Example</h4>
+<p>The following is an example of how an RDF file can be used as a datasource. The RDF file is fairly large and can be viewed separately: <a href="https://developer.mozilla.org/samples/xultu/examples/animals.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/animals.rdf">RDF</a></p>
+<p><span id="Example_2"><a id="Example_2"></a><strong>Example 2</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_datasrc_2.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_datasrc_2.xul">View</a></p>
+<pre>&lt;tree flex="1" width="200" height="200"
+ datasources="animals.rdf" ref="http://www.some-fictitious-zoo.com/all-animals"&gt;
+
+ &lt;treecols&gt;
+ &lt;treecol id="name" label="Name" primary="true" flex="1"/&gt;
+ &lt;treecol id="species" label="Species" flex="1"/&gt;
+ &lt;/treecols&gt;
+
+ &lt;template&gt;
+ &lt;rule&gt;
+ &lt;treechildren&gt;
+ &lt;treeitem uri="rdf:*"&gt;
+ &lt;treerow&gt;
+ &lt;treecell label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/&gt;
+ &lt;treecell label="rdf:http://www.some-fictitious-zoo.com/rdf#species"/&gt;
+ &lt;/treerow&gt;
+ &lt;/treeitem&gt;
+ &lt;/treechildren&gt;
+ &lt;/rule&gt;
+
+ &lt;/template&gt;
+&lt;/tree&gt;
+</pre>
+<p><img alt="Image:datasrc1.jpg"></p>
+<p>Here, the data has been generated from the file. The <code><code id="a-ref"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/ref">ref</a></code></code> attribute has been set to the root element in the RDF file, which is the top-level <code>Seq</code>. This will give us a complete list of animals. If we wanted to, we could set the <code><code id="a-ref"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/ref">ref</a></code></code> attribute to any of the other <code>about</code> attribute values to limit the set of data that is returned. For example, to display only the reptiles, use a value of <code><span class="nowiki">http://www.some-fictitious-zoo.com/reptiles</span></code>.</p>
+<h4 id="Setting_the_ref_Attribute_Example" name="Setting_the_ref_Attribute_Example">Setting the <code>ref</code> Attribute Example</h4>
+<p>The example below shows how to display a particular piece of an RDF datasource by setting the <code><code id="a-ref"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/ref">ref</a></code></code> attribute.</p>
+<p><span id="Example_3"><a id="Example_3"></a><strong>Example 3</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_datasrc_3.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_datasrc_3.xul">View</a></p>
+<pre>&lt;window
+ id="example-window"
+ title="History List"
+ xmlns:ANIMALS="http://www.some-fictitious-zoo.com/rdf#"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;
+
+&lt;button label="Click here to see the mammals the zoo has" type="menu"
+ datasources="animals.rdf" ref="http://www.some-fictitious-zoo.com/mammals"&gt;
+ &lt;template&gt;
+ &lt;rule ANIMALS:specimens="0"&gt;&lt;/rule&gt;
+ &lt;rule&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/rule&gt;
+ &lt;/template&gt;
+&lt;/button&gt;
+
+&lt;/window&gt;
+</pre>
+<p>In this case only the mammals are desired, so we select the URI of the mammals list. You will notice that the value of the <code><code id="a-ref"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/ref">ref</a></code></code> attribute in the example is <code><span class="nowiki">http://www.some-fictitious-zoo.com/mammals</span></code> which corresponds to one of the <code>Seq</code> elements in the RDF file. This causes only the descendants of this list to be returned.</p>
+<p>Two rules have been used here. The first rule catches all the resources that have their <code>ANIMALS:specimens</code> attribute set to <code>0</code>. You can see this attribute in the RDF file on each of the <code>Description</code> elements. Some of them have a value of 0. So in these cases, rule one will match. Because rule one has no content, nothing will be displayed for these ones. This is an effective way to hide data that we don't want to display.</p>
+<p>The second rule applies to all other resources and creates a row in a popup menu. The end effect is that we get a popup menu containing all the mammals which have a specimen that is not 0.</p>
+<p>Next, we'll look at the full rule syntax.</p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Trees_and_Templates" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Advanced_Rules">下一页 »</a></p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/scroll_bars/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/scroll_bars/index.html
new file mode 100644
index 0000000000..ea21fc9535
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/scroll_bars/index.html
@@ -0,0 +1,9 @@
+---
+title: 滚动栏
+slug: Mozilla/Tech/XUL/Tutorial/Scroll_Bars
+translation_of: Archive/Mozilla/XUL/Tutorial/Scroll_Bars
+---
+<p>This page has no content. Enrich M</p><dt>DC by contributing.cxz
+<table style="width: 319px; height: 100px;"> <tbody> <tr> <td> </td> <td style="text-align: center;"> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </tbody>
+</table>
+<p> </p></dt>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/scrolling_menus/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/scrolling_menus/index.html
new file mode 100644
index 0000000000..e484aba178
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/scrolling_menus/index.html
@@ -0,0 +1,45 @@
+---
+title: XUL_教程/滚动菜单
+slug: Mozilla/Tech/XUL/Tutorial/Scrolling_Menus
+tags:
+ - XUL_Tutorial
+translation_of: Archive/Mozilla/XUL/Tutorial/Scrolling_Menus
+---
+<p> </p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Popup_Menus" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Adding_Event_Handlers">下一页 »</a></p>
+</div><p></p>
+<p>本节讲述滚动菜单并且将本机制运用到其它元素中。</p>
+<h3 id=".E5.88.9B.E5.BB.BA.E4.B8.80.E4.B8.AA.E5.A4.A7.E8.8F.9C.E5.8D.95" name=".E5.88.9B.E5.BB.BA.E4.B8.80.E4.B8.AA.E5.A4.A7.E8.8F.9C.E5.8D.95">创建一个大菜单</h3>
+<p>如果创建一个菜单,里面有很多的命令在里面,会发生什么呢?这样所有的项不会一次性在屏幕上显示完。Mozilla提供一种滚动机制允许滚动这些项。</p>
+<div class="float-right">
+ <img alt="Image:menuscroll1.png"></div>
+<p>如果可用空间太小,在每个菜单的末端会出现箭头。如果将鼠标移动到箭头上,菜单可以上翻或下翻。如果可用的空间足够大,箭头则不会显示。注意是否出现滚动行为完全依赖于当前的实际情况(theme)。</p>
+<p>该行为是完全自动的。你不必特意的去为得到滚动菜单而做些工作。它会应用于菜单栏上的菜单,滚动菜单或菜单列表中。执行它使用<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/arrowscrollbox" title="arrowscrollbox">arrowscrollbox</a></code></code>元素。该元素用来创建带箭头的滚动框。</p>
+<p><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/arrowscrollbox" title="arrowscrollbox">arrowscrollbox</a></code></code>可以被用在任何使用规范框的地方。但不能用于菜单中。通常是用于垂直的框中,并且可能包括有很多元素在里面。可以将它用于下拉列表中,当你不想要它是一个下拉框的时候。</p>
+<h4 id=".E7.A4.BA.E4.BE.8B_-_.E6.8C.89.E9.92.AE.E7.9A.84.E6.BB.9A.E5.8A.A8.E5.88.97.E8.A1.A8" name=".E7.A4.BA.E4.BE.8B_-_.E6.8C.89.E9.92.AE.E7.9A.84.E6.BB.9A.E5.8A.A8.E5.88.97.E8.A1.A8">示例 - 按钮的滚动列表</h4>
+<p>下面的示例说明了如何创建多个按钮的一个滚动列表(需要改变窗口大小以查看箭头按钮):</p>
+<p><span id="Example_1"><a id="Example_1"></a><strong>Example 1</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_menuscroll_1.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_menuscroll_1.xul">View</a></p>
+<pre>&lt;arrowscrollbox orient="vertical" flex="1"&gt;
+ &lt;button label="Red"/&gt;
+ &lt;button label="Blue"/&gt;
+ &lt;button label="Green"/&gt;
+ &lt;button label="Yellow"/&gt;
+ &lt;button label="Orange"/&gt;
+ &lt;button label="Silver"/&gt;
+ &lt;button label="Lavender"/&gt;
+ &lt;button label="Gold"/&gt;
+ &lt;button label="Turquoise"/&gt;
+ &lt;button label="Peach"/&gt;
+ &lt;button label="Maroon"/&gt;
+ &lt;button label="Black"/&gt;
+&lt;/arrowscrollbox&gt;
+</pre>
+<p>试一下这个示例,首先它会以完全大小打开。但是,如果缩小窗口的高度,滚动箭头就会出现。将窗口拉大则箭头会消失。</p>
+<p>可以设置CSS中<code>arrowscrollbox</code>的<code>max-height</code>属性来限制滚动框的大小,这样使箭头能够一直显示。</p>
+<p>因此,<code>arrowscrollbox</code>在菜单和弹出菜单中相当有用。</p>
+<p>下回,我们将学习如何添加一些<a href="cn/XUL_Tutorial/Adding_Event_Handlers">XUL元素的事件句柄</a>.</p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Popup_Menus" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Adding_Event_Handlers">下一页 »</a></p>
+</div><p></p>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/simple_menu_bars/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/simple_menu_bars/index.html
new file mode 100644
index 0000000000..a9179852f7
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/simple_menu_bars/index.html
@@ -0,0 +1,159 @@
+---
+title: XUL_教程/简单菜单栏
+slug: Mozilla/Tech/XUL/Tutorial/Simple_Menu_Bars
+tags:
+ - XUL_Tutorial
+translation_of: Archive/Mozilla/XUL/Tutorial/Simple_Menu_Bars
+---
+<p> </p>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Toolbars" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:More_Menu_Features">下一页 »</a></p>
+</div><p></p>
+
+<p>在本节中,我们来看看如何创建菜单栏及菜单项。</p>
+
+<h3 id=".E5.88.9B.E5.BB.BA.E8.8F.9C.E5.8D.95" name=".E5.88.9B.E5.BB.BA.E8.8F.9C.E5.8D.95">创建菜单</h3>
+
+<p>XUL有几种不同的方式来创建菜单。最基本的方式当然是类似大多数程序拥有一个菜单栏并附有一排菜单项在上面。也可以创建弹出式菜单。XUL的菜单特性由几种不同的元素组成,它可以让你创建菜单栏和弹出式菜单。菜单上的项可以轻松的进行自定义。我们在<a href="cn/XUL_Tutorial/List_Controls#Drop-down_Lists">part of how to make menus</a>一文中已经学习过使用<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code></code>了。本节我们就以此为基础。</p>
+
+<p>菜单栏通常像<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbar" title="toolbar">toolbar</a></code>一样创建。菜单栏也可以放置于<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbox" title="toolbox">toolbox</a></code></code>中,则菜单就像在其它类型工具栏一样。XUL拥有一些特殊元素,可以提供一些特定功能的菜单。</p>
+
+<p>有五种相关的元素用来创建菜单栏及其菜单,在此我们简单解释一下,在后面我们再详述:</p>
+
+<dl>
+ <dt><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menubar" title="menubar">menubar</a></code></dt>
+ <dd>一排菜单的窗口。</dd>
+</dl>
+
+<dl>
+ <dt><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code></dt>
+ <dd>尽管名字是菜单,但它实际上在菜单栏上仅仅体现其主题而已。该元素可以放置在菜单栏中或者独立放置。</dd>
+</dl>
+
+<dl>
+ <dt><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code></dt>
+ <dd>当点击菜单主题时,弹出框会显现。该框包括了菜单命令的列表。</dd>
+</dl>
+
+<dl>
+ <dt><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code></dt>
+ <dd>菜单上的独立命令。应放置于<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code></code>中。</dd>
+</dl>
+
+<dl>
+ <dt><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuseparator" title="menuseparator">menuseparator</a></code></dt>
+ <dd>菜单上的分割条。应放置于<code>menupopup</code>中。</dd>
+</dl>
+
+<div class="note">
+<p>你可以在除Macintosh之外的任何平台在菜单栏中自定义任何你想要的菜单。这是因为Macintosh自己特殊的菜单置于屏幕最顶端,由系统控制着。虽然你可以创建自定义菜单,但放置于菜单上的任何特殊样式的规则或非菜单元素均不能生效。在创建菜单时头脑中留意这一点。</p>
+</div>
+
+<h5 id=".E7.AE.80.E5.8D.95.E8.8F.9C.E5.8D.95.E6.A0.8F.E7.A4.BA.E4.BE.8B" name=".E7.AE.80.E5.8D.95.E8.8F.9C.E5.8D.95.E6.A0.8F.E7.A4.BA.E4.BE.8B">简单菜单栏示例</h5>
+
+<p><span id="Example_1"><a id="Example_1"></a><strong>Example 1</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_menubar_1.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_menubar_1.xul">View</a></p>
+
+<div class="float-right"><img alt="Image:menubar-ex1.png"></div>
+
+<pre>&lt;toolbox flex="1"&gt;
+ &lt;menubar id="sample-menubar"&gt;
+ &lt;menu id="file-menu" label="File"&gt;
+ &lt;menupopup id="file-popup"&gt;
+ &lt;menuitem label="New"/&gt;
+ &lt;menuitem label="Open"/&gt;
+ &lt;menuitem label="Save"/&gt;
+ &lt;menuseparator/&gt;
+ &lt;menuitem label="Exit"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menu&gt;
+ &lt;menu id="edit-menu" label="Edit"&gt;
+ &lt;menupopup id="edit-popup"&gt;
+ &lt;menuitem label="Undo"/&gt;
+ &lt;menuitem label="Redo"/&gt;
+ &lt;/menupopup&gt;
+ &lt;/menu&gt;
+ &lt;/menubar&gt;
+&lt;/toolbox&gt;
+</pre>
+
+<p>喏,使用<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menubar" title="menubar">menubar</a></code></code>元素创建了一个简单的菜单栏。上面还会创建一排菜单。<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code></code>元素在菜单顶端创建菜单主题显示于菜单栏上。使用<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code></code>元素创建弹出菜单。用户点击父菜单主题时,会弹出显示。弹出菜单框的大小会足够的大,可以容纳里面所有的菜单命令显示。菜单命令本身使用<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code></code>元素进行创建。每一个都代表菜单弹出框上的一个单独命令。</p>
+
+<p>你还可以使用<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuseparator" title="menuseparator">menuseparator</a></code></code>元素创建菜单上面的分割线。用于分割不同的菜单项组。</p>
+
+<h4 id="menubar.E5.85.83.E7.B4.A0" name="menubar.E5.85.83.E7.B4.A0"><code>menubar</code>元素</h4>
+
+<p><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menubar" title="menubar">menubar</a></code></code>是一个包括菜单的框。注意它已经被放置于一个固定的<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbox" title="toolbox">toolbox</a></code></code>中。菜单栏没有特殊的属性一,仅仅是一种类型的框。这意味着可以创建一个垂直的工具栏,通过设置<code><code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code></code>属性为vertical。</p>
+
+<h4 id="menu.E5.85.83.E7.B4.A0" name="menu.E5.85.83.E7.B4.A0"><code>menu</code>元素</h4>
+
+<p><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code></code>元素运行起来就像是<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/button" title="button">button</a></code></code>元素。可以接受与它相同的部分属性及额外的一些属性:</p>
+
+<dl>
+ <dt><code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code></dt>
+ <dd>菜单主题按钮的唯一标识符。</dd>
+</dl>
+
+<dl>
+ <dt><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></dt>
+ <dd>显示在菜单上的文字,例如 文件 或 编辑。</dd>
+</dl>
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd>该布尔属性决定菜单是否被禁用。虽然可以,但很少情况需要禁止整个菜单。该属性值可以被设置为<code>true</code>或者<code>false</code>。当然,后者是默认值。</dd>
+</dl>
+
+<dl>
+ <dt><code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code></dt>
+ <dd>该属性值是用户可以按键盘激活菜单项的键值。该字母通常在菜单主题后面以下划线方式显示。Mozilla会视标签属性根据在此指定的字符给它加上下划线。因此,需要指定一个在文本中存在的字符(尽管指定的键不在文本中也能正常工作)。</dd>
+</dl>
+
+<div class="float-right"><img alt="Image:menubar-ex2.jpg"></div>
+
+<p><code>menu</code>元素通常放置在菜单栏上,尽管这不是必需的。但是,这将出现不一样的显示结果。此处的图片展示了早期没有菜单栏的示例看起来的效果。</p>
+
+<h4 id="menupopup.E5.85.83.E7.B4.A0" name="menupopup.E5.85.83.E7.B4.A0"><code>menupopup</code>元素</h4>
+
+<p><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code></code>元素创建包括菜单命令的弹出窗口。它是一种类型的框,默认为垂直布局。如果你想要并且将<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>s</code>放置在一排中,你可以将它改为水平布局。通常仅有<code>menuitem</code>s元素和<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuseparator" title="menuseparator">menuseparator</a></code>s</code>放置在<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code></code>中。你可以放置任何元素在<code>menupopup</code>中,但是在Macintosh中它们都会被忽略。</p>
+
+<h4 id="menuitem.E5.85.83.E7.B4.A0" name="menuitem.E5.85.83.E7.B4.A0"><code>menuitem</code>元素</h4>
+
+<p><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code></code>元素与<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code></code>元素非常相似并且拥有部分相同属性。</p>
+
+<dl>
+ <dt><code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code></dt>
+ <dd>菜单项的唯一标识符。</dd>
+</dl>
+
+<dl>
+ <dt><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></dt>
+ <dd>显示在菜单项上的文本,例如打开 或 保存。</dd>
+</dl>
+
+<dl>
+ <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
+ <dd>该布尔属性值决定菜单项是否被禁止。该属性可以被设置为<code>true</code>或者<code>false</code>,但默认值是后者。</dd>
+</dl>
+
+<dl>
+ <dt><code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code></dt>
+ <dd>该值是用户可以使用键盘激活菜单项的键值。该字母通常以下划线方式显示于菜单主题后面。Mozilla将视<code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code>属性值给指定的字母加上下划线。因此,你需要指定在文本中存在的字符。</dd>
+</dl>
+
+<dl>
+ <dt><code id="a-acceltext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/acceltext">acceltext</a></code></dt>
+ <dd>该值指定显示在菜单命令末尾的快捷键文本提示。但是它还没有与<code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>进行键的关联。我们在后面再研究如何<a href="cn/XUL_Tutorial/Keyboard_Shortcuts">do this later</a>.</dd>
+</dl>
+
+<h4 id="menuseparator.E5.85.83.E7.B4.A0" name="menuseparator.E5.85.83.E7.B4.A0"><code>menuseparator</code>元素</h4>
+
+<p><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuseparator" title="menuseparator">menuseparator</a></code></code>没有特别的属性。它只是在两个相信的菜单元素之间创建一条水平的分割线。</p>
+
+<p>下一节,我们会学习一些<a href="cn/XUL_%e6%95%99%e7%a8%8b/%e6%9b%b4%e5%a4%9a%e8%8f%9c%e5%8d%95%e7%89%b9%e6%80%a7">更多菜单特性</a>.</p>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Toolbars" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:More_Menu_Features">下一页 »</a></p>
+</div><p></p>
+
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/splitters/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/splitters/index.html
new file mode 100644
index 0000000000..172190858c
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/splitters/index.html
@@ -0,0 +1,85 @@
+---
+title: 分割线
+slug: Mozilla/Tech/XUL/Tutorial/Splitters
+translation_of: Archive/Mozilla/XUL/Tutorial/Splitters
+---
+<p>我们来看看如何向一个窗口添加分隔线。</p>
+<h3 id="分隔box"> 分隔box</h3>
+<p>有时候你可能会想将一个窗口分成两节,而使用户可以改变这两节的尺寸。一个例子是mozilla的浏览器窗口,你可以通过拖动两个结构之间的小条来改变侧边栏的尺寸。你也可以点击旁边的标记隐藏这个侧边栏</p>
+<h4 id="元素splitter">元素splitter</h4>
+<p>这个特性是由一个叫做splitter的元素来实现的。它可以在两个节之间创建一个较小的条,可以让用户来改变两边的大小。你可以将splitter放在任何想要放置的地方,这样就可以改变在同一个格子里前后元素的大小了当在水平box中放置一个splitter的时候,将会水平的改变大小。当放在竖直的box中的时候,就可以改变竖直方向的大小了。</p>
+<p>元素splitter的用法如下:</p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;splitter</p>
+ <p>    id="identifier"</p>
+ <p>    state="open"</p>
+ <p>    collapse="before"</p>
+ <p>    resizebefore="closest"</p>
+ <p>    resizeafter="closest"&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>属性如下:</p>
+<p>属性id  全局唯一标识</p>
+<p>属性state 指出splitter的状态。默认设为open,将分割面板分开,否则设置为collapse,将其中一个隐藏,另一个占据整个空间</p>
+<p>属性collapse 这表明当点击隐藏标记的时候隐藏哪一边。设置为before则隐藏前面的元素,如果设置为after则隐藏分割线后面的元素。如果设置为none,也是默认的值,当点击隐藏标记的时候都不会隐藏。</p>
+<p>属性resizebefore 当分割线被拖动的时候。其左边或者上面的元素会改变大小。这一属性说明哪一个元素改变大小。设置为closest会使左边离分割线最近的立即改变大小,设置为farther则左边离分割线最远的元素将会最先改变大小。默认值为closest。</p>
+<p>属性resizeafter当分割线被拖动的时候。其右边或者下面的元素会改变大小。这一属性说明哪一个元素改变大小。设置为closest会使右边离分割线最近的立即改变大小,设置为farther则右边离分割线最远的元素会改变大小。这个属性还可以设置为grow,这种情况下分割线右边的部分不会改变大小,相反的,整个格子会改变大小。默认值为closest。</p>
+<p>如果设置了collapse属性,还可以添加一个grippy元素在splitter里面,这个元素可以用来销毁元素。</p>
+<p>分割线旁边的元素的width和height属性会在splitter拖动的时候进行调整。准确的说是根据resizebefore和resizeafter属性来调整。</p>
+<h4 id="Splitter的例子">Splitter的例子</h4>
+<p>例子1:</p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;hbox flex="1"&gt;</p>
+ <p>  &lt;iframe id="content-1" width="60" height="20" src="w1.html"/&gt;</p>
+ <p>  &lt;splitter collapse="before" resizeafter="farthest"&gt;</p>
+ <p>    &lt;grippy/&gt;</p>
+ <p>  &lt;/splitter&gt;</p>
+ <p>  &lt;iframe id="content-2" width="60" height="20" src="w2.html"/&gt;</p>
+ <p>  &lt;iframe id="content-3" width="60" height="20" src="w3.html"/&gt;</p>
+ <p>  &lt;iframe id="content-4" width="60" height="20" src="w4.html"/&gt;</p>
+ <p>&lt;/hbox&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p><img alt=""></p>
+<p>这里创建了4个iframe以及一个分割线,分割线在第一个和第二个iframe之间。属性collapse设置为before,也就是当隐藏标记点击的时候,第一个frame会消失。</p>
+<p>这个splitter的resizeafter属性设置为farther。也就是说当拖动splitter的时候,其后最远的元素会改变大小。也就是frame4会改变大小。</p>
+<p>没有对resizebefore设置值,因此其默认值是closest。这里,分割线之前只有一个splitter,因此frame1会改变大小。</p>
+<p>Frame2和frame3只有在frame4达到最小值时才会改变大小。</p>
+<p><img alt="" style="">、<img alt=""></p>
+<p>也可以在一个窗口上放置多个splitter。同样的也可以隐藏其他元素,而不仅仅是frame。</p>
+<h3 id="查找文件对话框例子"> 查找文件对话框例子</h3>
+<p>让我们看看给查找文件对话框添加一个splitter之后是个什么样子。一个可能是在对话框中添加查找结果,在搜索选项和按钮之间。分割线可以让你隐藏或者查看搜索结果。</p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;/tabbox&gt;</p>
+ <p> </p>
+ <p>  &lt;iframe src="results.html"/&gt;</p>
+ <p>  &lt;splitter collapse="before" resizeafter="grow"&gt;</p>
+ <p>   &lt;grippy/&gt;</p>
+ <p>  &lt;/splitter&gt;</p>
+ <p> </p>
+ <p> &lt;hbox&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>这里添加了一个iframe和一个splitter。这里在tabbox之后不需要spacer了,可以将其移除。Frame的内容包含在一个'<code>results.html</code>'文件里面,现在创建这个文件并将其放在任何地方。以后我们会用一个结果列表来代替它。</p>
+<p>这个splitter的collapse属性设置为before,就是说分割线之前的元素将会被隐藏。这里就是这个iframe。下面又一个隐藏标志点击之后的图。</p>
+<p>属性resizeafter设置为grow,这样分割线之后的元素将会在分割线向下拖动的时候向下移动。Frame中的内容的大小可以变到任何尺寸。注意,窗口自己不会改变大小,你也会发现这是一个水平分割线,因为是放在竖直box里面的。</p>
+<p>正常状态</p>
+<p><img alt=""></p>
+<p>隐藏后状态</p>
+<p><img alt=""></p>
+<p>接下来将会介绍如何创建工具条</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/stack_positioning/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/stack_positioning/index.html
new file mode 100644
index 0000000000..40712df82e
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/stack_positioning/index.html
@@ -0,0 +1,30 @@
+---
+title: 定位层(stack堆)
+slug: Mozilla/Tech/XUL/Tutorial/Stack_Positioning
+translation_of: Archive/Mozilla/XUL/Tutorial/Stack_Positioning
+---
+<p>这一节描述如何为堆中的元素进行定位</p>
+<h3 id="堆子元素的位置">堆子元素的位置</h3>
+<p>通常,stack的子元素为与堆的大小匹配会自动扩展。然而,你也可以将其子元素放在指定的位置。例如,如果一个堆有两个按钮子元素,一个房子左边缘20像素,距顶部50像素。第二个可以房子距离左边缘100像素而距离顶部5像素。</p>
+<p>可以通过设置两个属性来指定子元素的位置,水平方向上使用left属性,竖直方向上使用top属性。如果你在stack的子元素中不指定这些属性,就会扩展以匹配堆的尺寸。</p>
+<p>例子1:</p>
+<p><img alt="" style=""></p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;stack&gt;</p>
+ <p>  &lt;button label="Goblins" left="5" top="5"/&gt;</p>
+ <p>  &lt;button label="Trolls" left="60" top="20"/&gt;</p>
+ <p>  &lt;button label="Vampires" left="10" top="60"/&gt;</p>
+ <p>&lt;/stack&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>这个堆有三个子元素,每个元素都使用了left和top属性来定位。这里所有的子元素都是按钮,但是并不是所有的子元素必须是同一类型。可以是任意元素,包括格子或者其他堆。</p>
+<p>堆的大小由所有紫云山的位置来决定,总会将大小调整到所有子元素都可见的大小。如果你将left属性设置为400,堆将会有一个400加上元素宽度的宽度。你也可以通过各种样式的不同属性如width。Max-width等来重写这个尺寸。</p>
+<p>也可以通过脚本来调整left和top的值,这样就会使元素移动。堆的优点是当一个指定位置元素位置发生变化时,其他元素不会受到影响。如果在格子中移动子元素,其他元素可能会动态的改它们的位置。</p>
+<p>你也可以将元素重叠起来。当绘制子元素的时候,元素会按照它们出现在堆中的顺序出现。就是说,第一个子元素在最后面。最后一个元素出现在顶部。你可以使用DOM函数来改变子元素的顺序。</p>
+<p>在响应鼠标事件的时候,顶部的元素会最先获取这个事件。也就是说如果有两个按钮重叠起来了,最上面的那个按钮会捕获到鼠标点击的事件。</p>
+<p>下一节描述标签格子(tabboxes),与面板相似但有自己的外观</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/stacks_and_decks/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/stacks_and_decks/index.html
new file mode 100644
index 0000000000..39aa1762a1
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/stacks_and_decks/index.html
@@ -0,0 +1,71 @@
+---
+title: 层和卡片
+slug: Mozilla/Tech/XUL/Tutorial/Stacks_and_Decks
+translation_of: Archive/Mozilla/XUL/Tutorial/Stacks_and_Decks
+---
+<p>有时候需要将元素按照一系列重叠的卡片一样进行显示。堆和面板元素可以达到这一目的。</p>
+<h3 id="容器"> 容器</h3>
+<p>每一个XUL格子元素都是一个可以容纳其他元素的容器。有很多具有特殊样式的格子,例如工具条和标签面板。标签box可以创建不带有任何特殊属性的最简单格子。然而,具有特殊样式的格子与常规的格子一样对其内部的元素进行排列,只是他们有附加特性而已。</p>
+<p>事实上,很多组件可以容纳其他元素。我们已经看到了按钮可以容纳除了默认元素之外的其他元素。滚动条也是也是一种特殊的格子类型,如果你不提供元素的话,他们会自己创建自己的元素。它也会自己处理滑块的运动。</p>
+<p>接下来的几节,我们会介绍一些用来容纳其他元素的元素。他们都是有特殊样式的格子,可以将格子的所有属性都用在这些元素上。</p>
+<h3 id="堆">  堆</h3>
+<p>元素stack是一个简单的格子,与其他格子的工作模式一样,只是它的子元素将会处于所有其他元素的最上面。第一个子元素会在最下面。第二个紧接着第一个,接着是第三个,等等。在一个堆中可以堆上任意多的元素。</p>
+<p>属性orient没有什么意义,因为堆中的子元素都是一个在一个的上面,而不是一个紧挨一个的。堆的大小由最大的子元素的大小决定。但你可以使用CSS属性的width,height,min-width和其他相关属性来控制堆和他的子元素。</p>
+<p>元素stack可以在需要为已经存在的元素添加状态指示器时使用。例如,进度条可能会用一个直条和上面一个label来创建。</p>
+<h4 id="带有阴影的堆">带有阴影的堆</h4>
+<p>为了方便的使用stack元素,可能需要为它仿制很多CSS属性。比如像下面这样为它创建一个文字阴影的效果:</p>
+<p>例子1:</p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;stack&gt;</p>
+ <p>  &lt;description value="Shadowed" style="padding-left: 1px; padding-top: 1px; font-size: 15pt"/&gt;</p>
+ <p>  &lt;description value="Shadowed" style="color: red; font-size: 15pt;"/&gt;</p>
+ <p>&lt;/stack&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p><img alt=""></p>
+<p>两个description元素都创建了一个大小为15点的文字。首先是通过在左边和顶部添加一个1像素的偏移。这样的结果是重复绘制文字'Shadowed'但会与另一个有一点点的偏移。</p>
+<p>这种方法的比使用text-shadow有一些优势,因为你可以完全将主体文字与阴</p>
+<p>影分开进行控制。它可以有自己的字体,下划线或者大小。(你甚至可以制作阴影闪烁的效果)。这在mozilla不支持CSS的文字阴影时也很有用。缺点是阴影的存在使得堆的尺寸变大了。。阴影效果对于创建禁用的按钮的外观很有用:</p>
+<p>例子2:</p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;stack style="background-color: #C0C0C0"&gt;</p>
+ <p>  &lt;description value="Disabled" style="color: white; padding-left: 1px; padding-top: 1px;"/&gt;</p>
+ <p>  &lt;description value="Disabled" style="color: grey;"/&gt;</p>
+ <p>&lt;/stack&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>这样安排文字和阴影颜色在某些平台上会产生禁用的外观</p>
+<p>注意,鼠标点击或者按键按下的事件是在堆上顶部元素,即堆中的最后一个元素。就意味着按钮只有是堆中最后一个元素的时候才能工作。</p>
+<h3 id="面板">  面板</h3>
+<p>元素deck也是和stack一样只在顶部显示一个子元素,但是面板一次只显示一个子元素。这对向导接口非常有用,其中一系列相似的面板顺序显示。你可以通过使面板中的内容发生变化而只创建一个窗口,而不是创建多个独立的窗口和导航按钮。</p>
+<p>与堆相似,deck元素的直接子元素组成ianb的页面。面板的显示页面可以通过改变设置selectedIndex属性来控制显示出来的子元素。索引是一个数字,可以指定哪一个页面将会显示。页面索引起始值为0.因此第一个子元素的page0,第二个是page1,等等。</p>
+<p>例子3:</p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;deck selectedIndex="2"&gt;</p>
+ <p>  &lt;description value="This is the first page"/&gt;</p>
+ <p>  &lt;button label="This is the second page"/&gt;</p>
+ <p>  &lt;box&gt;</p>
+ <p>    &lt;description value="This is the third page"/&gt;</p>
+ <p>    &lt;button label="This is also the third page"/&gt;</p>
+ <p>  &lt;/box&gt;</p>
+ <p>&lt;/deck&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>这里有三个页面,默认为显示第三个。第三个页面是一个格子,里面有两个元素。格子里面的元素和格子本身组成了一个页面。面板的大小是子元素中最大的大小这里就是第三个页面。</p>
+<p>你可以在脚本中改变selectedIndex属性来对页面进行切换。更多关于这个方面的介绍在事件和DOM的章节</p>
+<p>下一节将会描述如何定位堆中的元素</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/styling_a_tree/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/styling_a_tree/index.html
new file mode 100644
index 0000000000..7574e792b7
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/styling_a_tree/index.html
@@ -0,0 +1,12 @@
+---
+title: 样式化树
+slug: Mozilla/Tech/XUL/Tutorial/Styling_a_Tree
+translation_of: Archive/Mozilla/XUL/Tutorial/Styling_a_Tree
+---
+<p>XUL:&lt;treerow properties="makeItBlue"&gt;</p>
+<p>css:<br>
+ treechildren::-moz-tree-row(makeItBlue)<br>
+ {<br>
+   background-color: blue;<br>
+ }</p>
+<p>可以参考这里 <a href="/en/XUL_Tutorial/Styling_a_Tree" name="____">点击这里</a></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/tabboxes/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/tabboxes/index.html
new file mode 100644
index 0000000000..c8c3e527c7
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/tabboxes/index.html
@@ -0,0 +1,125 @@
+---
+title: 分页组
+slug: Mozilla/Tech/XUL/Tutorial/Tabboxes
+tags:
+ - tabbox
+translation_of: Archive/Mozilla/XUL/Tutorial/Tabboxes
+---
+<p>选择对话框中经常出现标签页,这里我们将会了解如何创建它们。</p>
+<h3 id="分页组">分页组</h3>
+<p>在应用程序的选择窗口中经常出现典型的标签页。在窗口的顶部会出现一系列的标签。用户可以通过点击相应的标签来查看不同的选项集合。当你有很多选项而无法在一个屏幕中完全显示的时候非常有用。</p>
+<p>XUL也提供了一种方法来创建这样的对话框。包含五种新的元素,下面详细的介绍这几个元素。</p>
+<p><strong>tabbox</strong> 最外层的格子,含有顶部的标签和标签页。</p>
+<p><strong>tabs </strong>含有独立标签页的内部格。即这是一排标签</p>
+<p><strong>tabpanels</strong> 页面的容器</p>
+<p><strong>tabpanel </strong>一个单独的页面的主体。你可以将一个页面的内容放在里面。第一个tabpanel对应于第一个标签页,第二个对应第二个,等等。</p>
+<p>元素tabbox含有两个子元素,一个tabs元素和一个tabpanels元素。用法如下:</p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;tabbox id="tablist"&gt;</p>
+ <p>  &lt;tabs&gt;</p>
+ <p>    &lt;!-- tab elements go here --&gt;</p>
+ <p>  &lt;/tabs&gt;</p>
+ <p>  &lt;tabpanels&gt;</p>
+ <p>    &lt;!-- tabpanel elements go here --&gt;</p>
+ <p>  &lt;/tabpanels&gt;</p>
+ <p>&lt;/tabbox&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>元素tab放在tabs里面,这与常规的box很像。元素tab与box其实没有什么不同的。Tab可以容纳任何类型的元素。不同的是,tab的面板一次只显示一个页面,与deck很相像。</p>
+<p>每个标签页的内容应该放到每个tabpanel元素内部。他们不是在tab元素内部的。Tab元素的内容出现在顶部。</p>
+<p>每个tabpanel元素成为显示时的一个页面。最大的页面的尺寸用作整个tabbox的尺寸。</p>
+<h4 id="分页组实例">分页组实例</h4>
+<p>例子1:</p>
+<p><img alt=""></p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;tabbox&gt;</p>
+ <p>  &lt;tabs&gt;</p>
+ <p>    &lt;tab label="Mail"/&gt;</p>
+ <p>    &lt;tab label="News"/&gt;</p>
+ <p>  &lt;/tabs&gt;</p>
+ <p>  &lt;tabpanels&gt;</p>
+ <p>    &lt;tabpanel id="mailtab"&gt;</p>
+ <p>      &lt;checkbox label="Automatically check for mail"/&gt;</p>
+ <p>    &lt;/tabpanel&gt;</p>
+ <p>    &lt;tabpanel id="newstab"&gt;</p>
+ <p>      &lt;button label="Clear News Buffer"/&gt;</p>
+ <p>    &lt;/tabpanel&gt;</p>
+ <p>  &lt;/tabpanels&gt;</p>
+ <p>&lt;/tabbox&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>这里有两个标签页,一个mail一个news。当点击news标签的时候,带有'Clear News Buffer'按钮的页面会出现。</p>
+<p>当前选择的标签元素有一个selected属性值为true。这可以改变当前选择的标签页。一次只能有一个标签的selected属性为true。</p>
+<h4 id="标签页的位置">标签页的位置</h4>
+<p>最后,你可以改变标签页的位置以使他们出现这个页面的任意位置。没有特殊的语法。你可以简单的使用orient和dir属性来实现。注意在布局的时候记住tab元素就像一般的格子,而tabbox元素更像是常规的竖直容器,tabs元素更像是默认为水平的容器格子。</p>
+<p>例如,要将标签放到左边,可以将tabs元素的朝向改为竖直的。然后调整tabbox使其具有水平朝向。这会使得标签出现在左边而不是顶部。注意改变tabpanels元素的朝向没有影响,因为标签页是相互覆盖的。</p>
+<p>也可以通过将tabs元素放在tabpanels元素后面来实现将标签放在右边或者下面。或者,也可以将tabbox的dir属性设置为reverse来实现。但是你最好将标签放在上面,否则在某些流行的主题下可能看起来不是很好。</p>
+<h3 id="为查找文件对话框添加标签页。">为查找文件对话框添加标签页。</h3>
+<p>让我们为查找文件的对话框添加第二个panel。我们将会创建一个选项标签(并默认选择)来包含一些搜索选项。这可能不是最好的接口。但我们使用它来说明标签的使用。顶部的文字和搜索选择各种需要放在第一个标签中,我们将会添加一些选项在第二个标签中。进度条和按钮可以放在主窗口中,在标签外部。</p>
+<table>
+ <tbody>
+ <tr>
+ <td style="width: 568px;">
+ <p>&lt;vbox flex="1"&gt;</p>
+ <p> </p>
+ <p>&lt;tabbox selectedIndex="1"&gt;</p>
+ <p>  &lt;tabs&gt;</p>
+ <p>    &lt;tab label="Search"/&gt;</p>
+ <p>    &lt;tab label="Options"/&gt;</p>
+ <p>  &lt;/tabs&gt;</p>
+ <p>  &lt;tabpanels&gt;</p>
+ <p>   &lt;tabpanel id="searchpanel" orient="vertical"&gt;</p>
+ <p> </p>
+ <p>    &lt;description&gt;</p>
+ <p>     Enter your search criteria below and select the Find button to begin</p>
+ <p>     the search.</p>
+ <p>    &lt;/description&gt;</p>
+ <p> </p>
+ <p>    &lt;spacer style="height: 10px"/&gt;</p>
+ <p> </p>
+ <p>    &lt;groupbox orient="horizontal"&gt;</p>
+ <p>      &lt;caption label="Search Criteria"/&gt;</p>
+ <p> </p>
+ <p>      &lt;menulist id="searchtype"&gt;</p>
+ <p>        &lt;menupopup&gt;</p>
+ <p>          &lt;menuitem label="Name"/&gt;</p>
+ <p>          &lt;menuitem label="Size"/&gt;</p>
+ <p>          &lt;menuitem label="Date Modified"/&gt;</p>
+ <p>        &lt;/menupopup&gt;</p>
+ <p>      &lt;/menulist&gt;</p>
+ <p>      &lt;spacer style="width: 10px;"/&gt;</p>
+ <p>      &lt;menulist id="searchmode"&gt;</p>
+ <p>        &lt;menupopup&gt;</p>
+ <p>          &lt;menuitem label="Is"/&gt;</p>
+ <p>          &lt;menuitem label="Is Not"/&gt;</p>
+ <p>        &lt;/menupopup&gt;</p>
+ <p>      &lt;/menulist&gt;</p>
+ <p> </p>
+ <p>      &lt;spacer style="height: 10px"/&gt;</p>
+ <p>      &lt;textbox id="find-text" flex="1" style="min-width: 15em;"/&gt;</p>
+ <p> </p>
+ <p>    &lt;/groupbox&gt;</p>
+ <p>   &lt;/tabpanel&gt;</p>
+ <p>   &lt;tabpanel id="optionspanel" orient="vertical"&gt;</p>
+ <p>    &lt;checkbox id="casecheck" label="Case Sensitive Search"/&gt;</p>
+ <p>    &lt;checkbox id="wordscheck" label="Match Entire Filename"/&gt;</p>
+ <p>   &lt;/tabpanel&gt;</p>
+ <p> &lt;/tabpanels&gt;</p>
+ <p>&lt;/tabbox&gt;</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p><img alt=""></p>
+<p>元素tab硬件放在了窗口的主要内容外面。你可以看到两标签,search和options。点击每一个都会将相应的标签页显示出来。如图中显示,两个选项出现在第二个标签上。第一个标签看起来与之前的更像,除了有顶部的标签之外。</p>
+<p>下一节,我们来看看如何创建内容的网格(grid)</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/templates/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/templates/index.html
new file mode 100644
index 0000000000..01b1eb0cf4
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/templates/index.html
@@ -0,0 +1,77 @@
+---
+title: XUL_教程/模板(Templates)
+slug: Mozilla/Tech/XUL/Tutorial/Templates
+translation_of: Archive/Mozilla/XUL/Tutorial/Templates
+---
+<p> </p>
+<p>在这一小节,我们将学习如果使用数据填充元素。</p>
+<h3 id="填充元素(Populating_Elements)">填充元素(Populating Elements)</h3>
+<p>XUL提供了通过RDF数据建立元素的方法,来源可以是一个RDF文件,也可以是一个内部数据源。Mozilla本身提供了很多数据源,比如书签、历史记录、邮件列表等。我们在下一小节会针对这部分进行更多的讨论。</p>
+<p>我们通常会向treeitems和menuitems这类的元素填充数据。但你完全可以根据实际情况向其他元素填充数据。在这里,我们还是从这些其他元素入手开始讲解,因为实现树型和菜单需要的代码比较多。</p>
+<p>为了使用RDF数据建立元素,首先要为这些元素提供一个复制用的模板。实际上,我们只是提供了第一个元素而已,剩下的元素都是在第一个元素的基础上构造出来的。</p>
+<p>模板是通过<a class="tag external" href="http://www.xulplanet.com/references/elemref/ref_template.html">template</a>元素建立的。<a class="tag external" href="http://www.xulplanet.com/references/elemref/ref_template.html">template</a>元素里用于放置那些新构建元素的内容。<a class="tag external" href="http://www.xulplanet.com/references/elemref/ref_template.html">template</a>元素要置于包含新构建元素的容器中,比如说你要创建一个<a class="tag external" href="http://www.xulplanet.com/references/elemref/ref_tree.html">tree</a>元素,那么就要把<a class="tag external" href="http://www.xulplanet.com/references/elemref/ref_template.html">template</a>元素置于<a class="tag external" href="http://www.xulplanet.com/references/elemref/ref_tree.html">tree</a>元素中。</p>
+<p>上面这些通过一个简单的例子来说明会很直观明了,在这个例子中,我们会为每个书签都建立 一个按钮。Mozilla提供了一个书签的数据源,我们可以直接拿来使用,为了简便,我们只取最顶层的书签(也可能是文件夹)来建立按钮。对于那些子标 签,我们可能会通过树型结构或者菜单等来显示这种层叠的结构。</p>
+<p>这个例子和其他直接引用内部数据源的程序一样,只能通过chrome开头的地址来调用,处于安全考虑,Mozilla禁止从其他数据源间接调用内部数据源。</p>
+<p>为了运行这个例子,你需要建立一个chrome包并把文件都置于包中,这时就可以通过在浏览器的地址栏输入chrome地址运行了。</p>
+<p>示例 9.2.1: <a class="external" href="http://www.xulplanet.com/tutorials/xultu/examples/ex_templates_1.xul.txt">下载</a></p>
+<div class="examplec">
+ <pre>&lt;vbox datasources="<a class="bodytag" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>:bookmarks" ref="NC:BookmarksRoot" flex="1"&gt;
+ &lt;<a class="bodytag" href="http://www.yeeyan.com/articles/tag/template"><em>template</em></a>&gt;
+ &lt;button uri="<a class="bodytag" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>:*" label="rdf:http://home.netscape.com/NC-rdf#Name"/&gt;
+ &lt;/<a class="bodytag" href="http://www.yeeyan.com/articles/tag/template"><em>template</em></a>&gt;
+&lt;/vbox&gt;</pre>
+</div>
+<p><img align="right" alt="" height="166" src="http://www.xulplanet.com/tutorials/xultu/images/templates1.jpg" width="107"> 在这个例子中,建立了一个vbox,vbox里面包含一列的按钮,每个按钮都对应一个顶级的书签。你可以注意到<a class="tag external" href="http://www.xulplanet.com/references/elemref/ref_template.html">template</a>元素内只有一个<a class="tag external" href="http://www.xulplanet.com/references/elemref/ref_button.html">button</a>元素。这个唯一的按钮元素是所有按钮元素建立的基础。旁边的图片就是最后的运行结果,每个按钮对应于一个书签。</p>
+<p>你可以试着在保持这个例子打开的情况下,向浏览器添加一个书签,你会发现这个例子中会立刻添加一个按钮,对应于你刚刚添加的那个书签。(你可能需要重新激活这个窗口,这样才能看到结果)</p>
+<p>模板本身被置于vbox中,而box容器有两个特性专门是为模板服务的,可以标识数据的来源。第一个是datasource特性,用来声明用来建立元素的RDF数据源。在这个例子中,对应的是<a class="bodytag external" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>:bookmarks。你一定可以猜到这个RDF对应的就是书签数据源。这个数据源是由Mozilla提供的。如果要使用自己的数据源,只需要在datasources特性中指定自定义的RDF地址就可以,就像下面例子中的一样:</p>
+<div class="sample">
+ <pre>&lt;box datasources="chrome://zoo/content/animals.<a class="bodytag" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>"
+ ref="http://www.some-fictitious-zoo.com/all-animals"&gt;</pre>
+</div>
+<p>也还可以同时设置多个数据源,只要在不同的数据源地址间加上空格就可以。这通常用于显示多个来源的数据。</p>
+<p>ref特性用于说明你想从数据源获取哪些数据。在这个书签的例子中,使用的是NC:<span class="aval">BookmarksRoot</span>,对应的是最顶级的书签。ref具体取什么值依赖于要使用的数据源。如果你使用自己的RDF文件作为数据源,ref的value值通常被设置为Bag、Seq或者Alt元素的about特性的值。</p>
+<p>当向box容器添加了这两个特性以后,就可以使用模板来生成元素了。模板里的元素要使用不同的方式来声明。你应该注意到上面例子中,<a class="tag external" href="http://www.xulplanet.com/references/elemref/ref_button.html">button</a>元素设置了uri特性,同时为label特性设置了一个特殊含义的值。</p>
+<p>模板里的特性值如果是以“<a class="bodytag external" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>:”开头的,就表明这个值是要从数据源中读取的。在上面的例子中,label特性就是这种情况。value中除了“rdf:”的剩余部分由命名空间和属性名称组成,表明要使用数据源中的name属性。如果你对这部分感到迷糊,请重新阅读《<a class="external" href="http://cuimingda.com/2008/10/xul-tutorial-introduction-to-rdf.html">XUL教程 - 9.1 - RDF概述</a>》的最后一段。那个例子描述了RDF中的资源是怎样被指向的。在这里我们只使用name属性,当然其他属性在这里也是可以使用的。</p>
+<p>我们为这些按钮的label特性设置了特定的URI,是因为我们需要用RDF数据源中的name属性来填充label。我们可以把URI放到按钮的 任何一个特性中,放到其他元素中也是可以的。不管放到哪个特性中,都会被数据源中相应的值替换。最后的结果,就是我们用按钮label显示出了每个书签的 名字。</p>
+<p>下面的例子展示了我们如何为按钮的其他特性设置数据源。当然我们已经假设数据源中包含相应的资源。如果需要的资源在数据源中没有被找到,那么特性的value就会被设置为空字符串。</p>
+<div class="sample">
+ <pre>&lt;button class="<a class="bodytag" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>:http://www.example.com/rdf#class"
+ uri="<a class="bodytag" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>:*"
+ label="<a class="bodytag" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>:http://www.example.com/rdf#name"/&gt;
+ crop="<a class="bodytag" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>:http://www.example.com/rdf#crop"/&gt;</pre>
+</div>
+<p>如上面例子所示,你可以通过不同的数据源动态设置元素的每个特性。</p>
+<p>uri特性用定义开始生成内容的元素。之前的内容只会生成一次,而之后的内容会每次都生成。在后面通过模板建立树型元素的例子中,我们将对这点进行更加详细的阐述。</p>
+<p>当我们将这些特性添加进模板所在的容器后(在这个例子中是box),就可以使用外部数据来建立各种有趣的列表了。我们当然可以在模板中多放几个元素,也可以在任何元素的特性上添加RDF引用,下面就是一个例子:</p>
+<p>实例 9.2.2: <a class="external" href="http://www.xulplanet.com/tutorials/xultu/examples/ex_templates_2.xul.txt">下载</a></p>
+<div class="examplec">
+ <pre>&lt;vbox datasources="<a class="bodytag" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>:bookmarks" ref="NC:BookmarksRoot" flex="1"&gt;
+ &lt;<a class="bodytag" href="http://www.yeeyan.com/articles/tag/template"><em>template</em></a>&gt;
+ &lt;vbox uri="<a class="bodytag" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>:*"&gt;
+ &lt;button label="<a class="bodytag" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>:http://home.netscape.com/NC-rdf#Name"/&gt;
+ &lt;label value="<a class="bodytag" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>:http://home.netscape.com/NC-rdf#URL"/&gt;
+ &lt;/vbox&gt;
+ &lt;/<a class="bodytag" href="http://www.yeeyan.com/articles/tag/template"><em>template</em></a>&gt;
+&lt;/vbox&gt;</pre>
+</div>
+<p>这个模板建立了一个vbox,容器中每个书签都对应于一个按钮和一个标签。按钮上显示的是书签的名字,标签上显示的是书签的地址。</p>
+<p>新建立的元素从功能上来说,和直接向XUL中添加数据是没有差别的。每一个通过模板建立的元素都会被自动添加id特性,用来标识这个资源,你也可以使用这个特性对每个资源进行引用。</p>
+<p>你还可以在同一个特性的值中,定义多个不同的资源,中间用空格分隔,下面就是一个例子。可以在<a class="external" href="http://www.xulplanet.com/tutorials/xultu/templateex.html">这里</a>查看更多关于资源定义的语法。</p>
+<p>示例 9.2.3: <a class="external" href="http://www.xulplanet.com/tutorials/xultu/examples/ex_templates_3.xul.txt">源代码</a></p>
+<div class="examplec">
+ <pre>&lt;vbox datasources="<a class="bodytag" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>:bookmarks" ref="NC:BookmarksRoot"
+ flex="1"&gt;
+ &lt;<a class="bodytag" href="http://www.yeeyan.com/articles/tag/template"><em>template</em></a>&gt;
+ &lt;label uri="<a class="bodytag" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>:*" value="rdf:http://home.netscape.com/NC-rdf#Name
+<a class="bodytag" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>:http://home.netscape.com/NC-rdf#URL"/&gt;
+ &lt;/<a class="bodytag" href="http://www.yeeyan.com/articles/tag/template"><em>template</em></a>&gt;
+&lt;/vbox&gt;</pre>
+</div>
+<h3 id="建立模板(How_Templates_are_Built)">建立模板(How Templates are Built)</h3>
+<p>一旦为元素设置了datasources特性,就表明这个元素将会通过模板来生成。要明确这点,是否生成内容不是由<a class="tag external" href="http://www.xulplanet.com/references/elemref/ref_template.html">template</a>标 记决定的,而是由atasources特性来决定的。只要设置了这个特性,元素就会自动被添加一个叫做构造器的对象。这个对象的责任就是通过模板来构建内 容。在JavaSciprt中,你可以使用builder属性来访问这个构造器对象,但通常你只有在需要手动重新生成内容的时候才需要调用这个对象。</p>
+<p>构造器有两种类型,最常用的是内容构造器(content builder),另外一种是树型构造器(tree builder),当然只有在构造树型元素的时候才用的到。</p>
+<p>内容构造器从<a class="tag external" href="http://www.xulplanet.com/references/elemref/ref_template.html">template</a>元素中读取内容,并在每行都进行复制。比如在上面的例子中如果有十个书签,就会构建10个<a class="tag external" href="http://www.xulplanet.com/references/elemref/ref_label.html">label</a>元素,并都会添加到<a class="tag external" href="http://www.xulplanet.com/references/elemref/ref_vbox.html">vbox</a>元素下面。如果你使用DOM函数对树型结构进行遍历,你可以找到这些元素,并可以调用它们的属性。这些元素最终会在界面显示出来,但是<a class="tag external" href="http://www.xulplanet.com/references/elemref/ref_template.html">template</a>元素本身是不会显示的,虽然在DOM中是可以找到<a class="tag external" href="http://www.xulplanet.com/references/elemref/ref_template.html">template</a>元素的。另外,每个label的id特性将被设置为RDF资源中对应的值。</p>
+<p>内容构造器总是从uri="<a class="bodytag external" href="http://www.yeeyan.com/articles/tag/rdf"><em>rdf</em></a>:*"定义的地方开始操作。如果uri特性所在的元素不是在第一行,那么之前的元素都值将被建立一次。下面的例子中会建立一个hbox,hbox内会用一组label来填充。</p>
+<p>--------------------------------------------------------------------------------</p>
+<p>本文完整内容请参见:</p>
+<p><a class="external" href="http://cuimingda.com/2008/10/xul-tutorial-templates.html">http://cuimingda.com/2008/10/xul-tutorial-templates.html</a></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/the_box_model/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/the_box_model/index.html
new file mode 100644
index 0000000000..be0bf1832c
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/the_box_model/index.html
@@ -0,0 +1,39 @@
+---
+title: XUL_教程/分组方式
+slug: Mozilla/Tech/XUL/Tutorial/The_Box_Model
+tags:
+ - XUL_教程
+translation_of: Archive/Mozilla/XUL/Tutorial/The_Box_Model
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:More_Button_Features" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Element_Positioning">下一页 »</a></p>
+</div><p></p>
+<p> </p>
+<h3 id=".E7.AE.B1.E4.BD.93.E5.85.A5.E9.97.A8" name=".E7.AE.B1.E4.BD.93.E5.85.A5.E9.97.A8">盒模型入门</h3>
+<p>在XUL里主要的布局叫做“盒模型”。这个模型允许你把窗口分割成连续的盒子。在盒子里面元素可以按水平或垂直方向排列。通过将一系列的盒子结合在一起,使用定位格和元素的<code><code id="a-flex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flex">flex</a></code></code>属性,你可以控制窗口的布局。</p>
+<p>虽然盒模型是XUL元素布局的基础部份,但原理并不复杂,只有几条简单的规则。一个盒子可以将它的子盒布置在两个方向之一,水平或垂直。水平盒子将它的元素进行水平排列,而垂直盒子将它的元素进行垂直排列。你可以把一个盒子想像HTML表格中的一行或一列。除了可以在子元素中放置不同的属性还可以使用一些样式表属性来控制子盒的精确定位和尺寸。</p>
+<h4 id=".E7.AE.B1.E4.BD.93.E4.BE.8B.E5.AD.90" name=".E7.AE.B1.E4.BD.93.E4.BE.8B.E5.AD.90">盒的例子</h4>
+<p>下面是定义盒子的基本语法:</p>
+<pre>&lt;hbox&gt;
+ &lt;!-- horizontal elements --&gt;
+&lt;/hbox&gt;
+
+&lt;vbox&gt;
+ &lt;!-- vertical elements --&gt;
+&lt;/vbox&gt;
+</pre>
+<p><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/hbox" title="hbox">hbox</a></code></code>元素用来创建一个水平方向的盒子。每个放在<code>hbox</code>中的元素将被水平地排成一行。<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/vbox" title="vbox">vbox</a></code></code> 元素用来创建一个垂直方向的盒子。添加进来的元素将会被垂直地放在前一个的下面。</p>
+<p>同样有一个普通的<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/box" title="box">box</a></code></code>元素默认是水平方向的,和<code>hbox</code>的意思相同。然而,你可以使用<code><code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code></code> 属生去操作盒子的方向。你可以设置这个属性的值为<code>horizontal</code> 去创建一个水平的盒子和<code>vertical</code>去创建一个垂直的盒子。</p>
+<p>因此,下面两行的效果是一样的:</p>
+<pre>&lt;vbox&gt;&lt;/vbox&gt;
+
+&lt;box orient="vertical"&gt;&lt;/box&gt;
+</pre>
+<p>下面例子展示怎么垂直放置三个按钮。</p>
+<p><span id="%E4%BE%8B1"><a id="%E4%BE%8B1"></a><strong>例1</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_boxes_1.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_boxes_1.xul">View</a></p>
+<div class="float-right">
+ <img alt="Image:boxes-ex1.png" class="internal" src="/@api/deki/files/2644/=Boxes-ex1.png"></div>
+<pre>&lt;vbox&gt;
+ &lt;button id="yes" label="Yes"/&gt;
+ &lt;button id="no" label="No"/&gt;
+ &lt;</pre>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/the_chrome_url/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/the_chrome_url/index.html
new file mode 100644
index 0000000000..817869f2d2
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/the_chrome_url/index.html
@@ -0,0 +1,74 @@
+---
+title: 关于Chrome URL
+slug: Mozilla/Tech/XUL/Tutorial/The_Chrome_URL
+translation_of: Archive/Mozilla/XUL/Tutorial/The_Chrome_URL
+---
+<div>
+ <a href="cn/XUL_%e6%95%99%e7%a8%8b/XUL%e7%9a%84%e7%bb%93%e6%9e%84">&lt;&lt; 前页</a> <a href="cn">后页 &gt;&gt;</a></div>
+<h3 id="Chrome.E7.BB.9F.E4.B8.80.E8.B5.84.E6.BA.90.E5.AE.9A.E4.BD.8D.E5.99.A8.28URL.29" name="Chrome.E7.BB.9F.E4.B8.80.E8.B5.84.E6.BA.90.E5.AE.9A.E4.BD.8D.E5.99.A8.28URL.29">Chrome统一资源定位器(URL)</h3>
+<p>下面的部分将描述如何关联(引用)XUL文档和其他的chrome文件。</p>
+<p>&lt;big&gt;<strong>Chrome统一资源定位器(URL)</strong>&lt;/big&gt;</p>
+<p>XUL文件可以像HTML文件一样被一个普通的HTTP URL(或者其他任何类型的URL)关联。尽管如此,用于Mozilla的chrome系统的软件包可以用特殊的chrome URL关联。Mozilla自带的软件包伴随Mozilla已经安装好,但你可以注册自己的包。</p>
+<p>软件包安装过之后具有不受安全限制的优点——安全限制对于很多程序来说都是必须的。相对于其他类型的URL来说,另外一个好处是它们可以自动处理多个主题和语言选项。举例来说,一条chrome URL允许你关联(引用)某个主题当中的一个文件,比如说是图片,与此同时你不需要知道用户当前使用的是哪个主题。只要不同主题里面的对应文件名相同,你总是可以通过chrome URL来引用这个文件。Mozilla会找到文件的路径并返回正确的数据。这也就意味着,软件包安装的位置与是否能访问它没有关系。chrome URL与文件物理存放位置无关,这使得写含有很多文件的程序变得简单了,因为你无需关心文件位置的细节。</p>
+<p>Chrome统一资源定位器(URL)的基本语法规则如下:</p>
+<table>
+ <tbody>
+ <tr>
+ <td>
+ <pre>
+chrome://&lt;package name&gt;/&lt;part&gt;/&lt;file.xul&gt;</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>上面的<code>&lt;package name&gt;</code>是软件包的名字,比如是编辑器或聊天工具。<code>&lt;part&gt;</code>可以是'content','skin'或'locale',这取决于你的需要。'file.xul'是文件名。</p>
+<p><strong>示例</strong>:<a class="external" rel="freelink">chrome://messenger/content/messenger.xul</a></p>
+<p>这个例子关联到的是'content'中的messenger窗口。将'content'替换为'skin'并改掉文件名,就可以指向皮肤中的某个文件。同样的,用'locale'替换'content'后,我们就能指向语言中的文件。</p>
+<p>当你打开一个chrome URL,Mozilla在其已安装包列表中查找,尝试定位到与URL中包名相同的JAR文件和目录.chrome URL和JAR文件之间的对应关系由chrome目录中的'清单'(manifest)文件来指定。如果你把messenger.jar移动到别的地方,并相应地更新'清单'文件中的信息,Thunderbird(译者注:此处Thunderbird是上文中提到的messenger)仍然能够正确工作,因为它不依赖特定的安装位置。利用chrome URL我们可以脱离Mozilla中例如包的位置等细节信息。类似地,如果用户改变了主题,'skin'部分的chrome URL实际所指向的就是另外的一套文件,但XUL和脚本无需改变。</p>
+<p>下面是更多的示例。注意例子中URL是如何避免指定使用某个特定的主题或者语言,以及如何避免指定特定目录的。</p>
+<table>
+ <tbody>
+ <tr>
+ <td>
+ <pre>
+chrome://messenger/content/messenger.xul
+chrome://messenger/content/attach.js
+chrome://messenger/skin/icons/folder-inbox.png
+chrome://messenger/locale/messenger.dtd
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>要关联到子目录,你只要在chrome URL的最后加上目录名就可以。下面的这些URL关联到bookmarks窗口,这里列出来了适合Mozilla和Firefox的版本——因为两者软件包的名字有差异:</p>
+<table>
+ <tbody>
+ <tr>
+ <td>
+ <pre>
+chrome://communicator/content/bookmarks/bookmarksManager.xul (Mozilla)
+chrome://browser/content/bookmarks/bookmarksManager.xul (Firefox)
+</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>chrome URL在任何普通URL可以使用地方一样能用,甚至你可以在Mozilla的浏览器窗口(译者注:地址栏)中直接输入。当在浏览器地址栏中输入上面提到的URL之一,你会发现窗口会像网页一样显示出来,而且大多数功能和在单独的窗口一样可以正常使用。但是,有些对话框可能工作不正常,那可能是因为需要由父窗口在打开他们的时候传递一些参数。</p>
+<p>你还将会遇到不带文件名的chrome URL,比如:</p>
+<table>
+ <tbody>
+ <tr>
+ <td>
+ <pre>
+chrome://browser/content/</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p>这种情况只有给出了包名和模块名。这类的引用(关联)会自动从目录中选择一个合适的文件。对于content来说,与包同名并带有.xul后缀的文件会被选中。在上面的例子中,显示的会是'browser.xul'。对于messenger包,messenger.xul会被显示。当你创建自己的包时,你需要为你的主窗口创建一个和软件包同名的文件,这样它就能被上面这种短形式的URL关联。这样带来的便利是只要用户知道包的名字,他就能打这个应用程序。当然了,对于修改浏览器界面的扩展(extensions)来说,用户不需要知道URL,因为扩展通过用户界面来显示自身。</p>
+<p>对于皮肤而言,包名.css被选中;对于语言,选中的是包名.dtd。</p>
+<p>需要记住的是,chrome URL与它在磁盘上的位置无关。URL的第一部分两个元素是包名和模块(content,skin或locale)。将内容文件放在叫'content'的目录是很普遍的事情,这和惯例不符,这些文件会被放在一个完全不同的结构中。</p>
+<hr>
+<p>(<a href="/cn" title="cn">下一部分</a>) 在接下来的部分,我们将看看如何创建'清单'(manifest)文件和包。</p>
+<div>
+ <a href="/cn/XUL_%E6%95%99%E7%A8%8B/XUL%E7%9A%84%E7%BB%93%E6%9E%84" title="cn/XUL_教程/XUL的结构">&lt;&lt; 前页</a> <a href="/cn/XUL_%E6%95%99%E7%A8%8B/%E5%85%B3%E4%BA%8EContents.rdf" title="cn/XUL_教程/关于Contents.rdf">后页 &gt;&gt;</a></div>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/toolbars/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/toolbars/index.html
new file mode 100644
index 0000000000..4ba0a4e2e3
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/toolbars/index.html
@@ -0,0 +1,101 @@
+---
+title: XUL_教程/工具栏
+slug: Mozilla/Tech/XUL/Tutorial/Toolbars
+tags:
+ - XUL_Tutorial
+translation_of: Archive/Mozilla/XUL/Tutorial/Toolbars
+---
+<p> </p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Splitters" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Simple_Menu_Bars">下一页 »</a></p>
+</div><p></p>
+<p>工具栏通常沿着窗口顶部放置,并包含许多完成普通功能的按钮。XUL有一个创建工具栏的方法。</p>
+<p>A toolbar is usually placed along the top of a window and contains a number of buttons that perform common functions. XUL has a method to create toolbars.</p>
+<p><br>
+ 工具栏</p>
+<p>Like a number of elements, XUL toolbars are a type of box.像许多的界面要素, XUL工具栏也是一种界面框。 Usually, a row of buttons would appear in the toolbar, but any element can be placed in a toolbar.通常,工具栏里会出现一排按钮,但任何界面要素都可以放到工具栏里。 For example, the Mozilla browser window contains a textbox that displays the page URL.举例来说, mozilla浏览器窗口包含一个文本框 ,显示了该网页的url 。</p>
+<p>Toolbars may be placed on any side of the window, either horizontally or vertically.工具栏可被水平或垂直地放置在窗口的任一边。 Of course you wouldn't normally put a textbox in a vertical toolbar.当然,通常你不会把文本框放在一个垂直工具栏里。 Actually, because toolbars are just boxes they can actually go anywhere you want, even in the middle of a window.事实上,因为工具栏只是个界面框,它们能去你想要它们去的任何地方,即使是窗口的中间。 Typically however, a set of toolbars would appear along the top of a window.通常,一组工具栏会出现在窗口的顶部。 When more than one toolbar is placed next to each other, they are typically grouped together in something called a 'toolbox'.当多个工具栏一个接一个放置时,他们通常被一个叫做'工具箱'的东西集合在一起。 [ edit ] A simple toolbar inside a toolbox [编辑] 一个简单的工具栏里面一个工具箱</p>
+<p>Source View 来源 查看 形象: toolbar1.jpg</p>
+<pre class="eval">&lt;toolbox&gt; &lt;toolbar id="nav-toolbar"&gt; &lt;toolbarbutton label="Back"/&gt; &lt;toolbarbutton label="Forward"/&gt; &lt;/toolbar&gt; &lt;/toolbox&gt; &lt;工具箱&gt; &lt;toolbar id="nav-toolbar"&gt; &lt;toolbarbutton label="back"/&gt; &lt;toolbarbutton label="forward"/&gt; &lt; /工具栏&gt; &lt; /工具箱&gt;
+</pre>
+<p>This has created a toolbar containing two buttons, a Back button and a Forward button.这就造成了一种工具列载有两个按钮,有一个备份(后退)按钮和前进按钮。 The one toolbar has been placed inside the toolbox.在一个工具栏已被置于内工具箱。 This has involved four new tags, which are described here.这涉及到4个新的标签,这是形容这里。</p>
+<p>toolbox 工具箱</p>
+<pre class="eval"> A box that contains toolbars.一个方框,其中包含工具栏。
+</pre>
+<p>toolbar 工具栏</p>
+<pre class="eval"> A single toolbar that contains toolbar items such as buttons.一个单一的工具栏包含了工具栏的项目,如按钮。
+</pre>
+<p>toolbarbutton toolbarbutton</p>
+<pre class="eval"> A button on a toolbar, which has all the same features of a regular button but is usually drawn differently.一个按钮,一个工具条,其中已全部一样的特点,定期按钮,但通常是取用不同。
+</pre>
+<p>The toolbar is the main element that creates the actual toolbar. 该工具是主要因素,造成了实际的工具栏。 Inside it are placed the individual toolbar items, usually buttons, but they can be other elements.它里面放置了个人工具栏的项目,通常是按钮,但是它们可以被其他元素。</p>
+<p>In the example above, only one toolbar was created.在上面的例子中,只有一个工具栏被创建。 Multiple toolbars can be created just as easily by adding more toolbar elements after the first one.更多工具栏的创建就想在第一个工具栏中添加元素一样容易。</p>
+<p>The toolbox is a container for toolbars. 工具箱是一个容器工具栏。 In some applications, you will have several toolbars along the top of the window.在某些应用中,你将有几个工具栏沿顶部的窗口。 You can put them all inside a toolbox .你可以把它们都内一个工具箱。</p>
+<p>You do not have to put toolbar elements inside a toolbox .你不须要把工具栏的内容里面一个工具箱。 [ edit ] Our find files example [编辑] 我们找到档案为例</p>
+<p>Let's add a toolbar to the find files dialog.让我们添加一个工具栏,向找到的文件对话框。 We don't really need one but we'll add one anyway to demonstrate its use.我们并不真的需要一个,但我们将增加一个无论如何,以证明其使用。 Two buttons will be added, an Open button and a Save button.两个按钮将被增加,一个打开按钮和一个储存按钮。 Presumably, they would allow the user to save search results and re-open them later.据推测,它们将使用户能够保存搜寻结果,或重新打开。</p>
+<pre class="eval">&lt;vbox flex="1"&gt; &lt;toolbox&gt; &lt;toolbar id="findfiles-toolbar"&gt; &lt;toolbarbutton id="opensearch" label="Open"/&gt; &lt;toolbarbutton id="savesearch" label="Save"/&gt; &lt;/toolbar&gt; &lt;/toolbox&gt; &lt;tabbox&gt; &lt; vbox挠性= " 1 " &gt; &lt;toolbox&gt; &lt;toolbar id="findfiles-toolbar"&gt; &lt;toolbarbutton id="opensearch" label="open"/&gt; &lt;toolbarbutton id="savesearch" label="save"/&gt; &lt; /工具栏&gt; &lt; /工具箱&gt; &lt;tabbox&gt;
+</pre>
+<p>形象: toolbar5.png</p>
+<p>A toolbar with two buttons has been added here.工具栏上有两个按钮已被添加在这里。 In the image, you can see them appear horizontally along the top.在图像,你可以看到他们出现横向沿顶部。 Notice that the toolbar has been placed inside the vertical box just above the tabbox.公告说,该工具已被置于内垂直票房略高于tabbox 。 This is because we need the vertical orientation so that the toolbar will appear above everything else.这是因为,我们需要的垂直方向,使该工具栏将出现高于一切。</p>
+<p>The find files example so far: Source View这一发现的档案为例,目前为止:源观</p>
+<p>Next, we'll find out how to add a menu bar to a window .明年,我们将看看如何添加一个菜单栏,以一个窗口 。</p>
+<p> </p>
+<h3 id="Adding_a_Toolbar" name="Adding_a_Toolbar">Adding a Toolbar</h3>
+<p>Like a number of elements, XUL toolbars are a type of box. Usually, a row of <a href="cn/XUL_Tutorial/Adding_Buttons">buttons</a> would appear in the toolbar, but any element can be placed in a toolbar. For example, the Mozilla browser window contains a <a href="cn/XUL_Tutorial/Input_Controls#Text_Entry_Fields">textbox</a> that displays the page URL.</p>
+<p>Toolbars may be placed on any side of the window, either horizontally or vertically. Of course you wouldn't normally put a textbox in a vertical toolbar. Actually, because toolbars are just boxes they can actually go anywhere you want, even in the middle of a window. Typically however, a set of toolbars would appear along the top of a window. When more than one toolbar is placed next to each other, they are typically grouped together in something called a 'toolbox'.</p>
+<h5 id="A_simple_toolbar_inside_a_toolbox" name="A_simple_toolbar_inside_a_toolbox">A simple <code>toolbar</code> inside a <code>toolbox</code></h5>
+<p><a href="https://developer.mozilla.org/samples/xultu/examples/ex_toolbar_1.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_toolbar_1.xul">View</a></p>
+<div class="float-right">
+ <img alt="Image:toolbar1.jpg"></div>
+<pre>&lt;toolbox&gt;
+ &lt;toolbar id="nav-toolbar"&gt;
+ &lt;toolbarbutton label="Back"/&gt;
+ &lt;toolbarbutton label="Forward"/&gt;
+ &lt;/toolbar&gt;
+&lt;/toolbox&gt;
+</pre>
+<p>This has created a toolbar containing two buttons, a Back button and a Forward button. The one toolbar has been placed inside the toolbox. This has involved four new tags, which are described here.</p>
+<dl>
+ <dt>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbox" title="toolbox">toolbox</a></code></dt>
+ <dd>
+ A box that contains toolbars.</dd>
+</dl>
+<dl>
+ <dt>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbar" title="toolbar">toolbar</a></code></dt>
+ <dd>
+ A single toolbar that contains toolbar items such as buttons.</dd>
+</dl>
+<dl>
+ <dt>
+ <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbarbutton" title="toolbarbutton">toolbarbutton</a></code></dt>
+ <dd>
+ A button on a toolbar, which has all the same features of a regular button but is usually drawn differently.</dd>
+</dl>
+<p>The <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbar" title="toolbar">toolbar</a></code></code> is the main element that creates the actual toolbar. Inside it are placed the individual <code>toolbar</code> items, usually buttons, but they can be other elements.</p>
+<p>In the example above, only one toolbar was created. Multiple toolbars can be created just as easily by adding more <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbar" title="toolbar">toolbar</a></code></code> elements after the first one.</p>
+<p>The <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbox" title="toolbox">toolbox</a></code></code> is a container for toolbars. In some applications, you will have several toolbars along the top of the window. You can put them all inside a <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/toolbox" title="toolbox">toolbox</a></code></code>.</p>
+<p>You do not have to put <code>toolbar</code> elements inside a <code>toolbox</code>.</p>
+<div class="highlight">
+ <h4 id="Our_find_files_example" name="Our_find_files_example">Our find files example</h4>
+ <p>Let's add a toolbar to the find files dialog. We don't really need one but we'll add one anyway to demonstrate its use. Two buttons will be added, an Open button and a Save button. Presumably, they would allow the user to save search results and re-open them later. <code> </code></p>
+ <pre class="eval">&lt;vbox flex="1"&gt;
+ <span class="highlightblue">&lt;toolbox&gt;
+ &lt;toolbar id="findfiles-toolbar"&gt;
+ &lt;toolbarbutton id="opensearch" label="Open"/&gt;
+ &lt;toolbarbutton id="savesearch" label="Save"/&gt;
+ &lt;/toolbar&gt;
+ &lt;/toolbox&gt;</span>
+ &lt;tabbox&gt;
+</pre>
+ <p> </p>
+ <div>
+ <img alt="Image:toolbar5.png"></div>
+ <p>A toolbar with two buttons has been added here. In the image, you can see them appear horizontally along the top. Notice that the toolbar has been placed inside the vertical box just above the tabbox. This is because we need the vertical orientation so that the toolbar will appear above everything else.</p>
+ <p>The find files example so far: <a href="https://developer.mozilla.org/samples/xultu/examples/findfile/findfile-toolbar.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/findfile/findfile-toolbar.xul">View</a></p>
+</div>
+<p>Next, we'll find out how to add a <a href="cn/XUL_Tutorial/Simple_Menu_Bars">menu bar to a window</a>.</p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Splitters" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Simple_Menu_Bars">下一页 »</a></p>
+</div><p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/trees/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/trees/index.html
new file mode 100644
index 0000000000..6162b31e6a
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/trees/index.html
@@ -0,0 +1,8 @@
+---
+title: 树结构
+slug: Mozilla/Tech/XUL/Tutorial/Trees
+translation_of: Archive/Mozilla/XUL/Tutorial/Trees
+---
+<p>XUL提一种供用树的形式而创建表格或是分层结构的列表。</p>
+<h2 id="树">树</h2>
+<p>在XUL中树是个很复杂的元素。它用于有层次需求的结构来显示行列中的文本。树允许用户对某行进行排序、调整、隐藏等操作。比如火狐中的书签项和雷鸟邮箱结构都是用树做成的。</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/using_spacers/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/using_spacers/index.html
new file mode 100644
index 0000000000..7501f87216
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/using_spacers/index.html
@@ -0,0 +1,111 @@
+---
+title: XUL_教程/使用定位格
+slug: Mozilla/Tech/XUL/Tutorial/Using_Spacers
+tags:
+ - XUL_教程
+translation_of: Archive/Mozilla/XUL/Tutorial/Using_Spacers
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Adding_HTML_Elements" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:More_Button_Features">下一页 »</a></p>
+</div><p></p>
+<p> </p>
+<h3 id=".E6.B7.BB.E5.8A.A0.E5.AE.9A.E4.BD.8D.E6.A0.BC" name=".E6.B7.BB.E5.8A.A0.E5.AE.9A.E4.BD.8D.E6.A0.BC">添加定位格</h3>
+<p>开发用户界面的问题之一是每个用户都有不同的显示器。一些用户使用较高分辨率的较大显示器而另外一些用户使用的是较低分辨率的。另外,不同的平台对用户界面的也不同。如果加上多语言支持,每种语言之间用到的文字的需要的显示空间也不一样。</p>
+<p>应用程序的窗口通常需要考虑支持多平台和多语言。某些平台和用户接口工具提供组件让用户可以轻易地去调整适合他们自己的大小和位置。(例如Java平台使用布局管理器。)</p>
+<p>XUL为元素提供能力自动调整位置和大小。 就像我们看到的文件查找窗口的尺寸是刚好能将元素放在它里面。每次我们增中一些东西,窗口就会变得更大。</p>
+<p>XUL使用一个叫做“箱状模型”(Box Model)的布局系统。我们将在<a href="/cn/XUL_教程/箱状模型" title="cn/XUL_教程/箱状模型">下一节</a>中讲到。它允许你将一个窗口划分成连续的盒子存放元素。盒子可以基于你定义的规格调整位置和大小。到现在,可以知道 <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/window" title="window">window</a></code></code> 元素是属于盒子的类型。</p>
+<p>在了解什么是盒子之前,我们将引入其他用于布局的XUL元素,<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/spacer" title="spacer">spacer</a></code></code>。定位格很简单,它只需要一个属性,稍后将会说明。一个简单的定位格看起来就像下面:</p>
+<pre class="eval">&lt;spacer flex="1"/&gt;
+</pre>
+<p><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/spacer" title="spacer">spacer</a></code></code>用于在窗口中放置一片空白。它多数用于用户调整窗口大小时它可以拉伸或者收缩。 这将决定是将按钮放置在一个窗口的左边或底边还是放在右边或底边 。将要看到,你可以使用一连串的空格去创建许多布局效果。</p>
+<p>上面这个语法中,定位格有一个属性,叫做<code><code id="a-flex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flex">flex</a></code></code>。这用于定义定位格的弹性。在上面的例子中,定位格为1的弹性。这会创建一个有<em>弹力</em>的定位格。如果你直接将它放在窗口里,这个定位格会在窗口的大小被改变时自动伸缩。</p>
+<p>马上我们将会把一个定位格添加到我们的文件查找例子中。首先,让我们看一下当调整当前对话框时会发生什么。</p>
+<p><img alt="Image:springs1.jpg" class="internal" src="/@api/deki/files/2683/=Springs1.jpg"></p>
+<p>如果你改变文件查找窗口的尺寸,你会看到所有的元素都保持着它们原来的位置。它们中没有一个移动或调整了大小虽然窗口里有更多的空间。让我们再看一下当增加了一个定位格后在文本输入框和查找按钮之间发生了什么。</p>
+<p><img alt="Image:springs2.jpg" class="internal" src="/@api/deki/files/2684/=Springs2.jpg"></p>
+<p>在添加了定位格后再调整窗口的大小时,你可以看到定位格填充了空白。按钮被推到了最后面。</p>
+<div class="highlight">
+ <h5 id=".E6.88.91.E4.BB.AC.E6.96.87.E4.BB.B6.E6.9F.A5.E6.89.BE.E7.9A.84.E4.BE.8B.E5.AD.90" name=".E6.88.91.E4.BB.AC.E6.96.87.E4.BB.B6.E6.9F.A5.E6.89.BE.E7.9A.84.E4.BE.8B.E5.AD.90">我们文件查找的例子</h5>
+ <p>下面的代码增加一个定位格。把它插入到查找按钮的前面。</p>
+ <pre class="eval"><span class="highlightred">&lt;spacer flex="1"/&gt;</span>
+
+&lt;button id="find-button" label="Find"/&gt;
+</pre>
+</div>
+<h3 id=".E5.85.B3.E4.BA.8E.E5.BC.B9.E6.80.A7.E7.9A.84.E6.9B.B4.E5.A4.9A.E4.BF.A1.E6.81.AF" name=".E5.85.B3.E4.BA.8E.E5.BC.B9.E6.80.A7.E7.9A.84.E6.9B.B4.E5.A4.9A.E4.BF.A1.E6.81.AF">关于弹性的更多信息</h3>
+<p>XUL在窗口中放置有弹性元素是通过计算元素合适的宽度和高度然后再添加空间。除非你指定元素的宽度和高度信息,元素的内容就决定了它的默认大小。你需要注意在对话框中的取消按钮总是设置了宽度因此它能在它里面放文字。如果你创建一个具有非常长的标签的按钮,按钮的默认大小将会很大使得有足够的空间可以放下标签。其它的元素,像是文本输入框会选择一个合适的默认大小。</p>
+<p><code>flex</code>属性用于指定元素可以改变自身的尺寸去填充它所在的盒子 (在这个例子中的窗口)。我们已经看到了应用于定位格的弹性属性,但它是可以应用于所有的元素的。例如,你可以改成能自动调整大小的查找按钮。</p>
+<p><img alt="Image:springs3.jpg" class="internal" src="/@api/deki/files/2685/=Springs3.jpg"></p>
+<p>如图所示,在查找按钮上增中了弹性属性,在窗口进行大小调整时它也会跟着调整。定位格实际上是没有指定任何东西。它实际上就是一个隐藏的按钮。它除了不会在屏幕上显示外大部分的使用方法就是和按钮一样的。</p>
+<p>你可以从上面的图片得到更多的提示。不仅是在查找按钮的尺寸增大了,而且在主标签和按钮之间显示了更多的空间。当然,这是我们之前放进去的定位格。它也调整了自己的尺寸。如果你更深入地观察,你会注意到在定位格和按钮之间分到的尺寸改变值是相等的。定位格拿到了一半的空余空间,按钮拿到了另外一半。</p>
+<p>我们看到这个效果是因为定位格和查找按钮都使用了 <code>flex</code> 属性。因为都是可伸缩的,按钮和定位格的尺寸调整是相等的。</p>
+<p>如果你想设置一个元素是另一个的两倍大小要怎么做呢?你可以给<code>flex</code>属性设一个更高的值。弹性元素的值是一个概率。如果一个元素的弹性值为1而另一个的弹性值是2,第二个比第一个大多少倍。在效果上,一个弹性为2说的是这个元素有一个弹性是二次的元素弹性增长。</p>
+<p><code>flex</code>属性不能用来指定一个真实的尺寸。作为替换,它说明在一个盒容器的子容器中填入多少的空白空间。我们将在下节看到盒子。一旦子盒的默认尺寸被指定,弹性值就被用于在对盒子中剩余的空白空间进行分割。例如,如果一个盒子有200像素宽并且包括2个可伸缩的按钮,第一个是50像素和另外一个是90像素,在它们的外面将还会有60像素的空白空间。如果两个按钮都有弹性的值为1,空白空间将会被分配给每个按钮伸缩长度为30像素。如果第二个按钮的弹性增加到2,第一个按钮将得到20像素的扩展空间,而第二个按钮将得到40像素的扩展空间。</p>
+<p><code>flex</code>属性可以被放在任何元素,但是当它直接放在XUL元素里面时就只有一个意思。意思是说即使你可以把<code>flex</code>放在HTML元素中,如果元素不是一个非盒元素它就得不到效果。</p>
+<h5 id=".E5.BC.B9.E6.80.A7.E4.BE.8B.E5.AD.90" name=".E5.BC.B9.E6.80.A7.E4.BE.8B.E5.AD.90">弹性例子</h5>
+<pre class="eval">例1:
+ &lt;button label="Find" flex="1"/&gt;
+ &lt;button label="Cancel" flex="1"/&gt;
+
+例2:
+ &lt;button label="Find" flex="1"/&gt;
+ &lt;button label="Cancel" flex="10"/&gt;
+
+例3:
+ &lt;button label="Find" flex="2"/&gt;
+ &lt;button label="Replace"/&gt;
+ &lt;button label="Cancel" flex="4"/&gt;
+
+例4:
+ &lt;button label="Find" flex="2"/&gt;
+ &lt;button label="Replace" flex="2"/&gt;
+ &lt;button label="Cancel" flex="3"/&gt;
+
+例5:
+ &lt;html:div&gt;
+ &lt;button label="Find" flex="2"/&gt;
+ &lt;button label="Replace" flex="2"/&gt;
+ &lt;/html:div&gt;
+
+例6:
+ &lt;button label="Find" flex="145"/&gt;
+ &lt;button label="Replace" flex="145"/&gt;
+</pre>
+<dl>
+ <dt>
+ 例1 </dt>
+ <dd>
+ 在这个例子中两个按钮平均分配弹性值。两个按钮的将会被平均地改变大小。</dd>
+ <dt>
+ 例2 </dt>
+ <dd>
+ 这,两个按钮都是可伸缩的,但查找按钮的伸展率是取消按钮的十分之一,因为取消按钮的弹性值为10,可用的空间被分割成查找按钮的一份和取消按钮的十分。</dd>
+ <dt>
+ 例3 </dt>
+ <dd>
+ 这里只有其中的两个按钮设置为可弹性。替换按钮将不会改变它的尺寸而另外两个会。 取消按钮将会比查找按钮大一倍因为它的弹性值是查找按钮的弹性值的二倍。</dd>
+ <dt>
+ 例4 </dt>
+ <dd>
+ 在这个例子,三个按钮都具有可弹性。查找和替换按钮的尺寸将是相同的,但取消按钮会更大一些(多50%的扩展)。</dd>
+ <dt>
+ 例5 </dt>
+ <dd>
+ 这里,两个按钮都放在<code>div</code>元素里面。按钮不是放在盒子里所以可申缩性在这里是无意义的。效果和没有使用<code>flex</code>属性是相同的。</dd>
+ <dt>
+ 例6 </dt>
+ <dd>
+ 因为两个按钮的弹性值是一样的,他们将得到相同的弹性。这样还不如用1来代替145。在这个例子中没有什么不同。建议你使用可读性更好的低数值。</dd>
+</dl>
+<p>注意像按钮的标签和按钮的最小尺寸等其他的因素会影响到按钮的尺寸。事实上,按钮不会收缩到比它的标签还小。</p>
+<p>将弹性值设为0与没有设置<code>flex</code>属性的效果是一样的。它的意思是元素不使用弹性。你有时可以看到弹性值会指定为一个百分率。这没有特殊的意义,这已经是处理过的就算没有百分号在那里。</p>
+<p>你也许注意到在你垂直改变查找对话框的尺寸时,按钮也会调整它自己的尺寸去适应窗口的高度。这是因为所有在窗口中的按钮都有隐含的垂直弹性。在下一节我们将会学习如何去改变这个值。</p>
+<div class="highlight">
+ <h5 id=".E5.88.B0.E7.9B.AE.E5.89.8D.E4.B8.BA.E6.AD.A2.E7.9A.84.E6.96.87.E4.BB.B6.E6.9F.A5.E6.89.BE.E4.BE.8B.E5.AD.90" name=".E5.88.B0.E7.9B.AE.E5.89.8D.E4.B8.BA.E6.AD.A2.E7.9A.84.E6.96.87.E4.BB.B6.E6.9F.A5.E6.89.BE.E4.BE.8B.E5.AD.90">到目前为止的文件查找例子</h5>
+ <p><a href="https://developer.mozilla.org/samples/xultu/examples/findfile/findfile-springs.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/findfile/findfile-springs.xul">View</a></p>
+</div>
+<p>接下来,我们将要学习 <a href="/cn/XUL_教程/更多按钮特性" title="cn/XUL_教程/更多按钮特性">按钮的更多特性</a>。</p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Adding_HTML_Elements" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:More_Button_Features">下一页 »</a></p>
+</div><p></p>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/using_xbl_from_stylesheets/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/using_xbl_from_stylesheets/index.html
new file mode 100644
index 0000000000..04c8ab7123
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/using_xbl_from_stylesheets/index.html
@@ -0,0 +1,223 @@
+---
+title: 通过CSS和XBL创建可复用的内容
+slug: Mozilla/Tech/XUL/Tutorial/Using_XBL_from_stylesheets
+translation_of: Archive/Beginner_tutorials/Using_XBL_from_stylesheets
+---
+<p></p><section id="Quick_Links">
+<ol><li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/What_is_CSS">What is CSS?</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/Why_use_CSS">Why use CSS?</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/How_CSS_works">How CSS works</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/Cascading_and_inheritance">Cascading and inheritance</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/Selectors">Selectors</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/Readable_CSS">Readable CSS</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/Text_styles">Text styles</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/Color">Color</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/Content">Content</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/Lists">Lists</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/Boxes">Boxes</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/Layout">Layout</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/Tables">Tables</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/Media">Media</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/JavaScript">JavaScript and CSS</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/SVG_and_CSS">SVG and CSS</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/XML_data">XML data</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/XBL_bindings">XBL binding</a></li>
+ <li><a href="/zh-CN/docs/Web/Guide/CSS/Getting_Started/XUL_user_interfaces">XUL user interfaces</a></li>
+</ol>
+</section><p></p>
+
+<p>本页面介绍了如何在Mozilla中使用CSS来提升在复杂应用结构中的代码与资源的复用。</p>
+
+<div class="note">
+<p>提示:XBL不能通过HTTP来加载,所以XBL只能使用file:///scheme或者通过附加代码的方式进行本地访问。</p>
+</div>
+
+<p>你可以应用这项技术于一个简单的示例。</p>
+
+<h3 id="Information:_XBL_bindings" name="Information:_XBL_bindings">Information: XBL bindings</h3>
+
+<p>由标记语言和CSS提供的这个结构并不适用于组件需要自包含和复用的复杂应用。你可以将样式表(stylesheet)和脚本(script)放置在独立的文件中。但是你必须将这些文件加载到文档(html)中,最后形成一个整体。</p>
+
+<p>另一个结构上的限制则与内容有关。你可以使用CSS为选中的元素提供内容,但是内容限定在文本和图片,并且内容的位置只能是选中的元素前或者后。</p>
+
+<p>Mozilla provides a mechanism that overcomes these limitations: <em>XBL</em> (XML Bindings Language). You can use XBL to link selected elements to their own:</p>
+
+<p>Mozilla提供了一个机制来克服上述限制:XBL(XML Bindings Language)。</p>
+
+<ul>
+ <li>Stylesheets</li>
+ <li>Content</li>
+ <li>Properties and methods</li>
+ <li>Event handlers</li>
+</ul>
+
+<p>因此你可以避免在文档中链接每一个组件,你可以使用自包含的组件来方便维护和复用。</p>
+
+<table style="background-color: rgb(244, 244, 244); border: 1px solid rgb(51, 102, 187); margin-bottom: 1em; padding: 1em; width: 100%;">
+ <caption>More details</caption>
+ <tbody>
+ <tr>
+ <td>For more information about XBL bindings, see the <a href="/en-US/docs/XBL" title="en/XBL">XBL</a> page in this wiki.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Action:_An_XBL_demonstration" name="Action:_An_XBL_demonstration">Action: An XBL demonstration</h3>
+
+<p>创建一个新的html文档,doc6.html。将下面的内容拷贝到文件中:</p>
+
+<div style="width: 56em;">
+<pre class="brush: html">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"&gt;
+&lt;HTML&gt;
+
+&lt;HEAD&gt;
+&lt;TITLE&gt;Mozilla CSS Getting Started - XBL demonstration&lt;/TITLE&gt;
+&lt;LINK rel="stylesheet" type="text/css" href="style6.css"&gt;
+&lt;/HEAD&gt;
+
+&lt;BODY&gt;
+&lt;H1&gt;XBL demonstration&lt;/H1&gt;
+&lt;DIV id="square"&gt;Click Me&lt;/DIV&gt;
+&lt;/BODY&gt;
+
+&lt;/HTML&gt;
+</pre>
+</div>
+
+<p>创建一个新的CSS文件,style6.css。这个样式表包含了文档的样式。将下面的内容拷贝到CSS文件中:</p>
+
+<div style="width: 56em;">
+<pre class="brush: css">/*** XBL demonstration ***/
+#square {
+ -moz-binding: url("square.xbl#square");
+ }
+</pre>
+</div>
+
+<p>Make a new text file, <code>square.xbl</code>. This file contains the XBL binding. Copy and paste the content from here:</p>
+
+<p>创建一个新的文本文件,square.xbl。这个文件包含了XBL的绑定关系。将下面的内容拷贝到文件中。</p>
+
+<div style="">
+<pre class="brush: xml">&lt;?xml version="1.0"?&gt;
+&lt;!DOCTYPE bindings&gt;
+&lt;bindings xmlns="http://www.mozilla.org/xbl"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:html="http://www.w3.org/1999/xhtml"&gt;
+
+&lt;binding id="square"&gt;
+
+ &lt;resources&gt;
+ &lt;stylesheet src="bind6.css"/&gt;
+ &lt;/resources&gt;
+
+ &lt;content&gt;
+ &lt;html:div anonid="square"/&gt;
+ &lt;xul:button anonid="button" type="button"&gt;
+ &lt;children/&gt;
+ &lt;/xul:button&gt;
+ &lt;/content&gt;
+
+ &lt;implementation&gt;
+
+ &lt;field name="square"&gt;&lt;![CDATA[
+ document.getAnonymousElementByAttribute(this, "anonid", "square")
+ ]]&gt;&lt;/field&gt;
+
+ &lt;field name="button"&gt;&lt;![CDATA[
+ document.getAnonymousElementByAttribute(this, "anonid", "button")
+ ]]&gt;&lt;/field&gt;
+
+ &lt;method name="doDemo"&gt;
+ &lt;body&gt;&lt;![CDATA[
+ this.square.style.backgroundColor = "#cf4"
+ this.square.style.marginLeft = "20em"
+ this.button.setAttribute("disabled", "true")
+ setTimeout(this.clearDemo, 2000, this)
+ ]]&gt;&lt;/body&gt;
+ &lt;/method&gt;
+
+ &lt;method name="clearDemo"&gt;
+ &lt;parameter name="me"/&gt;
+ &lt;body&gt;&lt;![CDATA[
+ me.square.style.backgroundColor = "transparent"
+ me.square.style.marginLeft = "0"
+ me.button.removeAttribute("disabled")
+ ]]&gt;&lt;/body&gt;
+ &lt;/method&gt;
+
+ &lt;/implementation&gt;
+
+ &lt;handlers&gt;
+ &lt;handler event="click" button="0"&gt;&lt;![CDATA[
+ if (event.originalTarget == this.button) this.doDemo()
+ ]]&gt;&lt;/handler&gt;
+ &lt;/handlers&gt;
+
+ &lt;/binding&gt;
+
+&lt;/bindings&gt;
+</pre>
+</div>
+
+<p>Make a new CSS file, <code>bind6.css</code>. This separate stylesheet contains style for the binding. Copy and paste the content from here:</p>
+
+<p>创建一个新的CSS文件,bind6.css。这个独立的样式表包含了</p>
+
+<div style="width: 56em;">
+<pre class="brush: css">/*** XBL demonstration ***/
+[anonid="square"] {
+ width: 20em;
+ height: 20em;
+ border: 2px inset gray;
+ }
+
+[anonid="button"] {
+ margin-top: 1em;
+ padding: .5em 2em;
+ }
+</pre>
+</div>
+
+<p>在你的浏览器中打开文档然后按下按钮。</p>
+
+<p>这个维基页面并不支持JavaScript,所以无法再这里展示示例。示例看上去就如下面所示,分别是按下按钮之前和之后的效果。</p>
+
+<table>
+ <tbody>
+ <tr>
+ <td><img alt="xbldemo0.png" class="default internal" src="/@api/deki/files/3377/=xbldemo0.png" style="height: 224px; width: 322px;"></td>
+ <td><img alt="xbldemo1.png" class="default internal" src="/@api/deki/files/3378/=xbldemo1.png" style="height: 224px; width: 322px;"></td>
+ </tr>
+ </tbody>
+</table>
+
+<p>关于这个示例的提示:</p>
+
+<ul>
+ <li>这个html文档如通常一样链接文档样式表,但是并没有链接任何JavaScript代码。</li>
+ <li>这个文档中并没有包含任何按钮。它只包含了按钮标签的文本。这个按钮通过绑定来添加。</li>
+ <li>这个文档样式表链接了绑定文件。</li>
+ <li>这个绑定文件链接了它自己的样式表,并且提供了它自己的内容和JavaScript代码。所以绑定文件是自包含的。</li>
+</ul>
+
+<p>挑战</p>
+
+<table style="background-color: rgb(255, 255, 244); border: 1px solid rgb(51, 102, 187); margin-bottom: 0.5em; padding: 1em;">
+ <caption> </caption>
+ <tbody>
+ <tr>
+ <td>Change the XBL file so that the square doubles in width when it changes color, instead of jumping to the right.
+ <p>Use the DOM Inspector tool to inspect the document, revealing the added content.</p>
+
+ <p> </p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="What_next">What next?</h3>
+
+<p>If you had difficulty understanding this page, or if you have other comments about it, please contribute to its <a href="/Talk:en/CSS/Getting_Started/XBL_bindings" title="Talk:en/CSS/Getting_Started/XBL_bindings">Discussion</a> page.</p>
+
+<p>In this demonstration, the square and the button make a self-contained <em>widget</em> that functions within an HTML document. Mozilla has a specialized markup language for creating user interfaces. The next page demonstrates it: <strong><a href="/en/CSS/Getting_Started/XUL_user_interfaces" title="en/CSS/Getting_Started/XUL_user_interfaces">XUL user interfaces</a></strong>.</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/xbl介绍/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/xbl介绍/index.html
new file mode 100644
index 0000000000..6b6ef8288e
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/xbl介绍/index.html
@@ -0,0 +1,104 @@
+---
+title: XUL 教程
+slug: Mozilla/Tech/XUL/Tutorial/XBL介绍
+tags:
+ - XBL
+translation_of: Archive/Mozilla/XUL/Tutorial/Introduction_to_XBL
+---
+<p> </p>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Property_Files" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Anonymous_Content">下一页 »</a></p>
+</div><p></p>
+
+<p> </p>
+
+<p><a href="/en/XUL" title="en/XUL">XUL</a>有一个姐妹语言,<a href="/en/XBL" title="en/XBL">XBL</a>(可扩展绑定语言)。这种语言被用于声明 XUL 窗口控件的行为。</p>
+
+<h3 id="Bindings" name="Bindings">Bindings</h3>
+
+<p>你可以用 XUL 来为应用程序定义用户界面的外观。你可以通过 <a href="/zh-CN/XUL_Tutorial/Adding_Style_Sheets" title="zh-CN/XUL_Tutorial/Adding_Style_Sheets"> 应用样式</a>自定义元素的外观。你也可以通过改变样式以 <a href="/zh-CN/XUL_Tutorial/Creating_a_Skin" title="zh-CN/XUL_Tutorial/Creating_a_Skin">创建新皮肤</a>。所有元素的基础外观,比如 <a href="/zh-CN/XUL_Tutorial/Scroll_Bars" title="zh-CN/XUL_Tutorial/Scroll_Bars">滚动条</a> 和 <a href="/zh-CN/XUL_Tutorial/Input_Controls#Checkboxes_and_Radio_Buttons" title="zh-CN/XUL_Tutorial/Input_Controls#Checkboxes_and_Radio_Buttons">复选框</a>,都可以通过调整样式或设置元素参数来进行修改。然而,XUL 没有提供改变元素的工作方式(或添加一个可重用的新元素)的方法。例如,您可能想改变滚动条的运行方式,就需要用到 <a href="/en/XBL" title="en/XBL">XBL</a>。</p>
+
+<p>一个 XBL 文件包含一组绑定(binding)。每个绑定描述一个 XUL 控件的行为。例如,一个绑定可以和一个滚动条相关联。这个行为除却描述滚动条的属性于方法之外,还描述了组成滚动条的 XUL 元素。</p>
+
+<p>类似 XUL,XBL 是一种 XML 语言,所以它有与之相似的语法规范。下述例子展示了 XBL 文件的基础结构:</p>
+
+<pre class="brush: xml">&lt;?xml version="1.0"?&gt;
+&lt;bindings xmlns="http://www.mozilla.org/xbl"&gt;
+ &lt;binding id="binding1"&gt;
+ &lt;!-- content, property, method and event descriptions go here --&gt;
+ &lt;/binding&gt;
+ &lt;binding id="binding2"&gt;
+ &lt;!-- content, property, method and event descriptions go here --&gt;
+ &lt;/binding&gt;
+&lt;/bindings&gt;
+</pre>
+
+<p><code><code><a href="/zh-CN/docs/XBL/XBL_1.0_Reference/Elements#bindings">bindings</a></code></code> 元素是 XBL 文件的根元素,包含了一个或多个 <code><code><a href="/zh-CN/docs/XBL/XBL_1.0_Reference/Elements#bindings">bindings</a></code></code> 元素。每个 <code><code><a href="/zh-CN/docs/XBL/XBL_1.0_Reference/Elements#bindings">bindings</a></code></code> 元素都声明一个单独的 binding,<code>id</code> 属性可以用来确定 binding,就像上述的例子一样。模板有两个 binding,分别叫做 <code>binding1</code> 和 <code>binding2</code>。一个可与滚动条关联,另一个则与菜单关联。一个 binding 可以和任意 XUL 元素相关联。如果你使用 CSS 类,就能按需使用各种不同的 binding。注意上面模板中的 <code><code><a href="/zh-CN/docs/XBL/XBL_1.0_Reference/Elements#bindings">bindings</a></code></code> 元素的命名空间。它声明了我们所使用的 XBL 语法。</p>
+
+<p>将绑定文件的链接正确设为 CSS 中 <code><a href="/en/CSS/-moz-binding" title="en/CSS/-moz-binding">-moz-binding</a></code> 的值,就可以把一个 binding 绑定到元素上。例如:</p>
+
+<pre class="brush: css">scrollbar {
+ -moz-binding: url('chrome://findfile/content/findfile.xml#binding1');
+}
+</pre>
+
+<p>URL 指向了 “<a class="external" rel="freelink">chrome://findfile/content/findfile.xml</a>” 文件中的 ID“binding1”。“#binding1”语法用于指向特定的 binding,很像指向 HTML 文件中的 anchor 标签的语法。通常你会(借助此语法)把所有的 binding 放进一个单独的文件里。例中结果是“binding1”将会描述所有的滚动条元素。如果您没用-moz-binding URL中的标签,就会用到XBL文件中的第一个binding。</p>
+
+<p>binding 声明了五种类型:</p>
+
+<ol>
+ <li>内容:添加到 binding 绑定到的元素的子元素</li>
+ <li>属性:添加到 binding 绑定到的元素的属性。它们能通过脚本存取。</li>
+ <li>方法:添加到 binding 绑定到的元素的方法。它们能从脚本调用。</li>
+ <li>事件:元素将响应的例如鼠标单击和按键这类事件。 binding能添加脚本,来提供默认操作。另外,能够定义新事件。</li>
+ <li>样式:被 XBL 定义的 binding 绑定到的元素所拥有的自定义样式的属性</li>
+</ol>
+
+<h3 id="Binding_Example" name="Binding_Example">Binding 示例</h3>
+
+<p><code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/box" title="box">box</a></code></code> 很通用,您能用它来创建自定义的窗口控件(虽然您能用任何元素,甚至自己构造的)。给一个 <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/box" title="box">box</a></code></code> 标签分配一个 <code>class</code> 属性,您就可以将 binding 连接到只属于该类的 box。比如下面的例子:</p>
+
+<p><strong>XUL (example.xul):</strong></p>
+
+<pre class="brush: xml">&lt;?xml version="1.0"?&gt;
+&lt;?xml-stylesheet href="chrome://global/skin/" type="text/css"?&gt;
+&lt;?xml-stylesheet href="chrome://example/skin/example.css" type="text/css"?&gt;
+
+&lt;window
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;
+ &lt;box class="okcancelbuttons"/&gt;
+&lt;/window&gt;</pre>
+
+<p><strong>CSS (example.css):</strong></p>
+
+<pre class="brush: css">box.okcancelbuttons {
+ -moz-binding: url('chrome://example/skin/example.xml#okcancel');
+}</pre>
+
+<p><strong>XBL (example.xml):</strong></p>
+
+<pre class="brush: xml">&lt;?xml version="1.0"?&gt;
+&lt;bindings xmlns="http://www.mozilla.org/xbl"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;
+ &lt;binding id="okcancel"&gt;
+ &lt;content&gt;
+ &lt;xul:button label="OK"/&gt;
+ &lt;xul:button label="Cancel"/&gt;
+ &lt;/content&gt;
+ &lt;/binding&gt;
+&lt;/bindings&gt;</pre>
+
+<p>这个例子创建了一个有单个 box 的窗口,这个 box 已经声明过含有一个 <code>okcancelbuttons</code> 类。与文件相关的样式表阐述了含类 <code>okcancelbuttons</code> 的box有在XBL文件中定义的特定的binding。除 <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/box" title="box">box</a></code></code> 之外,可用其它元素,甚至自定义的标签。</p>
+
+<p>部分 XBL 的细节将在下一章描述。不过呢,总结来说,它使得在box里自动增加了两个按钮。一个 OK 按钮,一个 Cancel 按钮。</p>
+
+<p>在下一节中,我们将看看该如何 <a href="/en/XUL_Tutorial/Anonymous_Content" title="en/XUL_Tutorial/Anonymous_Content">使用 XBL 创建内容</a>。</p>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Property_Files" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:Anonymous_Content">下一页 »</a></p>
+</div><p></p>
+
+<p>/*以下疑似是历史残余链接…*/ </p>
+
+<p> </p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/xpcom_接口/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/xpcom_接口/index.html
new file mode 100644
index 0000000000..fb2dbb3699
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/xpcom_接口/index.html
@@ -0,0 +1,179 @@
+---
+title: XPCOM 接口
+slug: Mozilla/Tech/XUL/Tutorial/XPCOM_接口
+translation_of: Archive/Mozilla/XUL/Tutorial/XPCOM_Interfaces
+---
+<p> </p>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Box_Objects" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:XPCOM_Examples">下一页 »</a></p>
+</div><p></p>
+
+<p>    本章简单的看看 <a href="/en/XPCOM" title="en/XPCOM">XPCOM</a> (跨平台组件对象模型)——Mozilla 使用的对象系统。</p>
+
+<h3 id="Calling_Native_Objects" name="Calling_Native_Objects">调用本地对象</h3>
+
+<p>    通过XUL我们可以建立一个复杂的用户界面,我们可以通过脚本来修改界面及处理任务。然而有很多事件是不能有JavaScript直接完成的,比如,我们像创建一个邮件程序,我们需要写一个脚本来连接到服务器发送好接收邮件,而JavaScript没有这个能力。</p>
+
+<p>    处理这种事情的唯一手段就是用本地代码写一个获得邮件的模块,同时也需要一个用脚本调用本地对象的简单方法。 Mozilla 通过了这样的模型—— <a href="/en/XPCOM" title="en/XPCOM">XPCOM</a> (Cross-platform Component Object Model)。</p>
+
+<div class="note">Mozilla 提供了不少XPCOM 组件及接口,并且大多数情况下,你不需要自己完成他们。通过学习本章,你可以在 <a class="external" href="http://xulplanet.com/references/xpcomref/">XULPlanet XPCOM Reference</a> 寻找合适的。</div>
+
+<h3 id="About_XPCOM" name="About_XPCOM">关于XPCOM</h3>
+
+<p>    Mozilla 是有一系列组件构成的。每一个组件都处理特定的任务。比如,有一个处理菜单,按钮及元素的组件。组件又建立在一系列定义(接口)上。</p>
+
+<p>    Mozilla 中的接口定义了在一个组件中需要实现的功能,组件是它的代码实现,每一个组件都要实现接口描述的功能。一个组件可以时多个接口,多个组件也可以实现同一个接口。</p>
+
+<p>    让我们来以‘文件’组件为例,需要创建一个描述‘文件’属性及功能的接口文件。文件需要有文件名、数据、大小等属性;删除、移动、复制等方法。</p>
+
+<p>    文件接口用字符文件描述而无需实现。实现的工作留给组件来完成,组件需要返回文件名、数据、大小的代码,以及复制、删除等代码。</p>
+
+<p>    我们不关心组件如何实现,只要它实现了接口。当然我们有不同的实现方法,并且对于不同的平台也会不同。然而,他们必须实现同样的接口,这样我们就可以利用从接口中得到的信息使用组件。</p>
+
+<p>    Mozilla中接口通常以'nsI'或 'mozI'开头,这样就很容易找出接口。比如 <code>nsIAddressBook</code> 用于地址表, <code>nsISound</code> 用于声音文件 , <code>nsILocalFile</code> 用于本地文件,Mozilla中的接口参见 <a href="/en/Interfaces" title="en/Interfaces">Interfaces</a>.</p>
+
+<p>    XPCOM 组件是一种本地实现,也就是说他们可以做 JavaScript 不能做的事情。我们可以调用接口定义的由组件属性的任意方法,比如,如果我们有一个组件,它实现了 <code>nsISound</code> 接口我们就可以用它来放声音。</p>
+
+<h3 id="Creating_XPCOM_Objects" name="Creating_XPCOM_Objects">创建XPCOM 对象</h3>
+
+<p>调用 XPCOM 组件分三步</p>
+
+<ol>
+ <li>获取组件</li>
+ <li>获取组件实现的接口</li>
+ <li>调用所需函数</li>
+</ol>
+
+<p>    如果我们做了前两步,最后一步可以无限制的使用,例如,我们想要重命名文件,这个方法定义在nsILocalFile 接口中。第一步得到文件组件。第二步,我们获取它实现了的nsILocalFile 接口,最后,调用接口通过的方法。这个接口用于代表单个文件。</p>
+
+<p>    我们知道接口长椅 'nsI' 或 'mozI'开头。组件通常像使用URI一样来引用,Mozilla 储存了当前注册的组件列表。像插件一样,用户可以添加新的组件。</p>
+
+<p>    Mozilla 通过了一个文件组件,它实现了 <code><a href="/en/nsILocalFile" title="en/nsILocalFile">nsILocalFile</a></code>。可以通过<code><a class="link-mailto" href="mailto:'@mozilla.org" rel="freelink">'@mozilla.org</a>/file/local;1'</code>引用,这个字符串称作协议ID,语法如下:</p>
+
+<pre class="eval">@&lt;internetdomain&gt;/module[/submodule[...]];&lt;version&gt;[?&lt;name&gt;=&lt;value&gt;[&amp;&lt;name&gt;=&lt;value&gt;[...]]]
+</pre>
+
+<p>    其他组件也按相似的方法引用。</p>
+
+<p>    组件的协议 ID 用于获取组件,可以用下面的脚本得到组件。</p>
+
+<pre>var aFile = Components.classes["@mozilla.org/file/local;1"].createInstance();
+</pre>
+
+<p>    一个文件组件返回并储存在变量 <em>aFile</em> 中,上例中的 <code><a href="/en/Components_object" title="en/Components_object">Components</a></code> 引用一个提供相关功能的全局对象。 这里,使用 <code>classes</code> 方法获得组件组,<code>classes</code> 方法返回可用组件的数组。得到不同的组件只需把双引号中的需要ID换成你需要的<span style="font-family: monospace;">,最后用</span><code>createInstance()</code>方法创建实例。</p>
+
+<p>    你需要检查 <code>createInstance()</code> 的返回值以确保非空,如果为空则表示所需组件不存在。</p>
+
+<p>    当然,到此为止,我们只引用了文件组件本身,为了使用它的函数,我们需要得到它的接口,本例为 <code><a href="/en/nsILocalFile" title="en/nsILocalFile">nsILocalFile</a></code>。我们再加一行。</p>
+
+<pre>var aFile = Components.classes["@mozilla.org/file/local;1"].createInstance();
+if (aFile) aFile.QueryInterface(Components.interfaces.nsILocalFile);
+</pre>
+
+<p>     <code>QueryInterface()</code> 是一个所以组件都通过的函数来返回特定的接口。函数有一个参数,你想得到的接口<code>Components</code>的 <code>interfaces</code> 方法包含一个可用接口的数组,这里把 nsILocalFile 作为参数传给 <code>QueryInterface()。结果是</code>aFile会引用它所实现了 nsILocalFile 接口的那部分。</p>
+
+<p>    上面的两行脚本可以用于获取任何组件及接口,只需更换组件名及接口名。下例,获得一个 sound 接口。</p>
+
+<pre>var sound = Components.classes["@mozilla.org/sound;1"].createInstance();
+if (sound) sound.QueryInterface(Components.interfaces.nsISound);
+</pre>
+
+<p>    XPCOM 接口可以继承其它的接口。这种接口拥有它自己的功能及它所继承的接口的功能<span style="font-family: monospace;">所有的接口都继承自顶级接口</span><code>nsISupports,它有一个函数由于支持</code>JavaScript—— <code>QueryInterface()</code>。因为所以的组件都实现 nsISupports 接口所以<code>QueryInterface()</code>对每个组件都有效。</p>
+
+<p>    一些组件可能会实现相同的接口。他们可能是原件的子类但不是必须的。组件可能都会实现 nsILocalFile接口,另外一个组件可能会实现多个接口。因为这个原因我们在调用函数之前需要得到定义函数的接口。</p>
+
+<p>    这里有一个简写形式,不过一般的我们把它分成多行。</p>
+
+<pre>var aLocalFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
+</pre>
+
+<p>    这一行代码完成了上面两行所做的事。</p>
+
+<p>    如果你使用 <code>QueryInterface()</code> 引用一个本组件没有实现的接口,会抛出一个异常。如果不确定组件支持哪个接口请使用 <code><a href="/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/instanceof_Operator" title="en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/instanceof_Operator">instanceof</a></code> 操作符检查。</p>
+
+<pre>var aFile = Components.classes["@mozilla.org/file/local;1"].createInstance();
+if (aFile instanceof Components.interfaces.nsILocalFile){
+ // do something
+}
+</pre>
+
+<p>    如果aFile实现nsILocalFile 接口 <code><a href="/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/instanceof_Operator" title="en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/instanceof_Operator">instanceof</a></code>返回真,在块中就可以调用 <code>QueryInterface()</code>。</p>
+
+<h3 id="Calling_the_Functions_of_an_Interface" name="Calling_the_Functions_of_an_Interface">调用接口函数</h3>
+
+<p>    现在你有了一个关联到 nsILocalFile 接口组件的一个引用,你就可以调用nsILocalFile通过的函数。下面列出了 nsILocalFile提供的属性及方法。</p>
+
+<dl>
+ <dt>initWithPath </dt>
+ <dd>此方法用于初始化文件名及路径,第一个参数是文件路径如 '/usr/local/mozilla'.</dd>
+ <dt>leafName </dt>
+ <dd>除去文件路径的文件名。</dd>
+ <dt>fileSize </dt>
+ <dd>文件尺寸。</dd>
+ <dt>isDirectory() </dt>
+ <dd> nsILocalFile 代表目录返回真。</dd>
+ <dt>remove(recursive) </dt>
+ <dd>删除一个文件。如果recursive 参数为true,一个目录及其中的所以文件包括子目录均被删除。</dd>
+ <dt>copyTo(directory,newname) </dt>
+ <dd>把文件复制到新目录,并随意更改文件名。目录应保存在 nsILocalFile对象中。</dd>
+ <dt>moveTo(directory,newname) </dt>
+ <dd>把文件移到新目录或重命名。 目录应保存在 nsILocalFile对象中。</dd>
+</dl>
+
+<p>    为了删除文件,需要将其赋值给 nsILocalFile。我们可以使用<code>initWithPath()</code> 方法指明所需文件,然后调用 <code>remove()</code> 函数,它带一个参数;是否递归删除,如下例。</p>
+
+<pre>var aFile = Components.classes["@mozilla.org/file/local;1"].createInstance();
+if (aFile instanceof Components.interfaces.nsILocalFile){
+ aFile.initWithPath("/mozilla/testfile.txt");
+ aFile.remove(false);
+}
+</pre>
+
+<p>    以上代码会定位 /mozilla/testfile.txt 并删除它。试着把它与事件处理相连。你可以把文件名改为一个需要删除的文件并把它删除。</p>
+
+<p>    上面的函数中 copyTo() 及moveTo()可以用于复制及移动文件。注意他们移动的目标目录不是保存在字符串中而是nsILocalFile,也就是说你需要两个文件字节,下面是一个复制文件的例子。</p>
+
+<pre>function copyFile(sourcefile,destdir)
+{
+ // get a component for the file to copy
+ var aFile = Components.classes["@mozilla.org/file/local;1"]
+ .createInstance(Components.interfaces.nsILocalFile);
+ if (!aFile) return false;
+
+ // get a component for the directory to copy to
+ var aDir = Components.classes["@mozilla.org/file/local;1"]
+ .createInstance(Components.interfaces.nsILocalFile);
+ if (!aDir) return false;
+
+ // next, assign URLs to the file components
+ aFile.initWithPath(sourcefile);
+ aDir.initWithPath(destdir);
+
+ // finally, copy the file, without renaming it
+ aFile.copyTo(aDir,null);
+}
+
+copyFile("/mozilla/testfile.txt","/etc");
+</pre>
+
+<h3 id="XPCOM_Services" name="XPCOM_Services">XPCOM 服务器</h3>
+
+<p>    一些 XPCOM 组件是被称为服务器的特殊组件,你无需创建他们因为他们只能存在一个副本。服务器提供了类似于读取,设置全局数据或操作其他对象的方法。我们使用<code>getService()代替</code> <code>createInstance()</code>方法来获取服务器组件,除此以外,服务器并没有与其他组件相异之处。</p>
+
+<p>    如Mozilla通过了一个书签服务器,它允许你向当前用户的书签列表中添加书签。如下例。</p>
+
+<pre>var bmarks = Components.classes["@mozilla.org/browser/bookmarks-service;1"].getService();
+bmarks.QueryInterface(Components.interfaces.nsIBookmarksService);
+bmarks.addBookmarkImmediately("http://www.mozilla.org","Mozilla",0,null);
+</pre>
+
+<p>    首先组件 "@mozilla.org/browser/bookmarks-service;1"被返回,并保存在变量 <code>bmarks</code>中,我们使用 <code>QueryInterface()</code> 得到 nsIBookmarksService 接口。这个接口通过的<code>addBookmarkImmediately()</code> 函数用于添加书签。函数的前两个参数是书签的 URL 和标题。第三个参数是书签类型通常是 0 ,最后一个参数是书签页的字符集,可为空。</p>
+
+<p>    下一章看看Mozilla为我们通过的接口。 <a href="/en/XUL_Tutorial/XPCOM_Examples" title="en/XUL_Tutorial/XPCOM_Examples">interfaces provided with Mozilla that we can use</a>.</p>
+
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Box_Objects" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:XPCOM_Examples">下一页 »</a></p>
+</div><p></p>
+
+<p>。</p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/xul_structure/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/xul_structure/index.html
new file mode 100644
index 0000000000..5983802be3
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/xul_structure/index.html
@@ -0,0 +1,43 @@
+---
+title: XUL_教程/XUL的结构
+slug: Mozilla/Tech/XUL/Tutorial/XUL_Structure
+tags:
+ - XUL_Tutorial
+translation_of: Archive/Mozilla/XUL/Tutorial/XUL_Structure
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/1-3_关于Chrome_URL">下一页 »</a></p>
+</div><p></p>
+<p> </p>
+<h2 id=".5BXUL.E5.AD.A6.E4.B9.A0.5DXUL_Tutorial.28.E4.BA.8C.29_--_XUL_Structure" name=".5BXUL.E5.AD.A6.E4.B9.A0.5DXUL_Tutorial.28.E4.BA.8C.29_--_XUL_Structure">XUL是怎么被处理的?</h2>
+<p>XUL与HTML的处理方式一样,先读出内容,然后解析为一棵对象树,再对每个对象作处理,使其显示出来。因为XUL是用来定义用户界面的,因此它与HTML用来做显示的功能一样。实际上,在Mozilla中,HTML和XUL,甚至SVG都是使用同样的底层代码来处理的。这样意味着一些CSS属性(注意是属性,不是CSS的全部)可以用在HTML和XUL。XUL同HTML一样可以从本地文件系统或web页面读取(不过这样多少有些功能上的限制)。另外就是打成一个包,可以让别人下载和安装。安装后的包就可以有一些更强的权限,象读文本文件,读用户参数和bookmark,以及访问其它系统特性。</p>
+<p>包注册就是Firefox扩展的安装方式。包是由XUL、Javascript、CSS、HTML和图片等构成。文件名后缀为.xpi,它其实是一个zip格式的压缩包。象Firefox的扩展一般是通过overlay的方式,对Firefox进行扩展的,如增加菜单、工具条等。但这些功能的代码其实是与浏览器分离的,而且卸载也很容易(就象NewEdit中的插件一样)。</p>
+<p>注册的包不一定要使用overlay的扩展方式(overlay是对已经存在的应用的扩展)。但这样,你就不能直接通过浏览器来使用这些功能。但你仍然可以使用称为chrome(增色) URL的方式来调用注册包。这种chrome URL的形式为"<a class="external" rel="freelink">chrome://</a>"。它用来指示安装的包和扩展。</p>
+<p>通过chrome方式来访问可以获得比http方式更多的权限,而通过这种方式,你就可以做访问本地文件等操作。这一点非常重要,权限的区分是通过URL的类型来实现的。通过http方式访问HTML和XUL,没有这些特别的权限,而通过chrome方式访问,HTML和XUL都具有这样的权力。</p>
+<p>Mozilla浏览器本身就是由许多的包构成的。而这些文件就是通过chrome URL来访问的,以获得特别的权限。</p>
+<p>Mozilla中有三种主要的文档类型:HTML, XUL和XML。它们之间有些是可能共享的特性,有些是不能共享的,使用时要注意。</p>
+<p>小结:</p>
+<p>Mozilla使用同样的引擎来渲染HTML和XUL,使用CSS来指明它们的外观。 XUL可以从web站点、本地文件系统,或作为包被安装并通过chrome URL来访问(这就是浏览器扩展所做的方式)。 Chrome URL可以用来访问安装的包,并且使用特别的权限来打开它们。 HTML、XUL、XML有不同的文档类型。一些特性是互通的,然而另一些特性是各自的。</p>
+<h3 id=".E5.8C.85.E7.BB.84.E7.BB.87" name=".E5.8C.85.E7.BB.84.E7.BB.87">包的组织</h3>
+<p>由Mozilla提供的包可以在Mozilla的安装目录下的chrome子目录中找到。但仅仅把文件拷贝到chrome目录下是不会赋给它任何的权限,也不可以通过chrome URL来访问的,还需要配置才可以。需要按照chrome包格式的要求来组织才可以。</p>
+<p>一个包的文件通常被组织为一个JAR文件。注意,很象Java中的Jar包,都是Zip格式的。但里面可不是Java程序。这也造成了某些人认为开发扩展需要懂Java,其实不是的。只是后缀与Java一样。(不清楚为什么用这个后缀)同时,也可以不打成一个JAR包,就是展开的目录也可以(如果你看到另一个教程XUL App Tutorial,你会看到就没有打成一个JAR包)。</p>
+<p>通常一个chrome包有三个目录,但它们都是可选的,分别为:content、skin和locale。</p>
+<ul>
+ <li>content -- 窗口和脚本</li>
+</ul>
+<p>用户界面的定义都放在XUL文件中,这些文件都以.xul为后缀。一个content目录下可以有多个XUL文件,但主窗体文件名必须与包名相同。例如editor包必须有一个叫做editor.xul的文件。其它的脚本文件(一般是.js文件,Javascript)也放在这个目录下。</p>
+<ul>
+ <li>skin -- 样式表、图片,和其它与theme相关的文件</li>
+</ul>
+<p>样式表用来描述窗口显示的外观。它们与XUL分离,可以灵活地修改程序的外观。</p>
+<ul>
+ <li>locale -- 与语言相关的文件</li>
+</ul>
+<p>所有界面中用到的文本都放在这里。如果支持多国语言,它们将按语言种类进行组织。只要在这里进行翻译即可实现多语言。 同时在每个目录下还应该有一个名为:contents.rdf的文件,它用来描述相关目录的信息清单。Mozilla将读取它,并使用它的内容来注册包,并给这个包分配一个chrome URL,这样这些文件就可以通过这个chrome URL来访问了。如果没有contents.rdf文件,这个包就不能被分配一个chrome URL,因此也就不能通过chrome来访问了。同时要注意,只有你需要通过chrome URL来访问的目录才需要contents.rdf文件,不需要访问的目录可能不要。再有,如果一个目录下还有子目录,但子目录通过与父目录相同的chrome URL来访问,子目录也可以不要contents.rdf文件。</p>
+<p>在locale目录中,语言化文件有两种形式:DTD和属性(properties)文件。DTD(Document Type Definition,文档类型定义)是XML中常用的文件,它一般是用来定义XML中的元素规则,还可以用来定义XML中出现的实体(entity)元素。XUL要使用DTD中的实体声明,用来显示文本信息。因此如果想实现多语言,就要按语种创建子目录,生成多个DTD文件。属性文件是给脚本使用的。</p>
+<p>Mozilla中的包通常是放在chrome目录下,但是你也可以不放在这个目录下,而是放在磁盘任意的地方。在chrome目录下的chrome.rdf文件保存了安装了的包、skin、locale的列表及它们的位置。放在chrome下是最常见的。对于存在多种skin和locale的情况,chrome.rdf中保存了激活的配置。</p>
+<p> </p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/1-3_关于Chrome_URL">下一页 »</a></p>
+</div><p></p>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/tutorial/更多的按钮特性/index.html b/files/zh-cn/mozilla/tech/xul/tutorial/更多的按钮特性/index.html
new file mode 100644
index 0000000000..4a72667660
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/tutorial/更多的按钮特性/index.html
@@ -0,0 +1,68 @@
+---
+title: XUL_教程/更多的按钮特性
+slug: Mozilla/Tech/XUL/Tutorial/更多的按钮特性
+tags:
+ - XUL_教程
+translation_of: Archive/Mozilla/XUL/Tutorial/More_Button_Features
+---
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Using_Spacers" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:The_Box_Model">下一页 »</a></p>
+</div><p></p>
+<p> </p>
+<h3 id=".E6.B7.BB.E5.8A.A0.E5.9B.BE.E5.83.8F" name=".E6.B7.BB.E5.8A.A0.E5.9B.BE.E5.83.8F">添加图像</h3>
+<p>你可以使用<code><code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code></code>属性通过指定URL为按钮添加一个图像。图像从URL进行加载,可以是一个相对或绝对的URL路径,然后在按钮上显示图像。 下面的按钮有<code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code> 和 <code><code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code></code> 'happy.png'。图像显示在标签的左边。你可以使用其它两个属性去改变这个位置。这将会在后面进行解释。</p>
+<p><span id="%E4%BE%8B1"><a id="%E4%BE%8B1"></a><strong>例1</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_advbtns_1.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_advbtns_1.xul">View</a></p>
+<pre>&lt;button label="help" image="happy.png"/&gt;
+</pre>
+<h4 id=".E4.BD.BF.E7.94.A8CSS.E5.9B.BE.E5.83.8F.E7.9A.84.E6.8C.89.E9.92.AE" name=".E4.BD.BF.E7.94.A8CSS.E5.9B.BE.E5.83.8F.E7.9A.84.E6.8C.89.E9.92.AE">使用CSS图像的按钮</h4>
+<p>在按钮上指定图像的另一个方法是使用样式表(CSS <a href="/zh-CN/docs/Web/CSS/list-style-image" title="list-style-image 属性用来指定一个能用来作为列表元素标记的图片。"><code>list-style-image</code></a> )属性。这将计划允许不改变XUL文件去改变"外观"(在这个例子,外观指按钮的图片)。</p>
+<p><span id="%E4%BE%8B2"><a id="%E4%BE%8B2"></a><strong>例2</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_advbtns_2.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_advbtns_2.xul">View</a></p>
+<pre>&lt;button id="find-button"
+ label="Find" style="list-style-image: url('happy.png')"/&gt;
+</pre>
+<p>在这个例子,在按钮上显示图像 'happy.png'。 <code><code id="a-style"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/style">style</a></code></code>属性的功能类似于在HTML中一样。通常,它可以使用在所有的XUL元素。注意你确实应该在一个分离的样式表里定义样式。</p>
+<h3 id=".E5.9B.BE.E5.83.8F.E5.AE.9A.E4.BD.8D" name=".E5.9B.BE.E5.83.8F.E5.AE.9A.E4.BD.8D">图像定位</h3>
+<p>默认情况下,按钮上的图像会放置在文本标签的左边。有两个属性可以用来控制定位。</p>
+<p><code><code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code></code>属性控制图像和文本的方向。设置这个属性的值为<code>reverse</code>,图像将会放在文本的右边。使用<code>normal</code>值,或者删除这个属性,图像将会放在文本的左边。</p>
+<p><code><code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code></code>属性用于在将图片放在文本的上面或下面。默认值是<code>horizontal</code>用于将用于将图像放在文本的左或右。你也可以使用值<code>vertical</code>将图像放在上方或下方。在这个例子,dir属性控制放置在上方或下方。相同的值被使用时,如果用在<code>normal</code>的意思是将图像放在文本的上方,而用在<code>reverse</code>的意思是将图像放在文本的下方。</p>
+<p><span id="%E4%BE%8B3"><a id="%E4%BE%8B3"></a><strong>例3</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_advbtns_3.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_advbtns_3.xul">View</a></p>
+<div class="float-right">
+ <img alt="Image:advbtns1.png" class="internal" src="/@api/deki/files/2642/=Advbtns1.png"></div>
+<pre>&lt;button label="Left" image="happy.png"/&gt;
+&lt;button label="Right" image="happy.png" dir="reverse"/&gt;
+&lt;button label="Above" image="happy.png" orient="vertical"/&gt;
+&lt;button label="Below" image="happy.png" orient="vertical" dir="reverse"/&gt;
+</pre>
+<p><br>
+ 这个例子展示了四个连续的不同类型的按钮。注意两个属性都没有指定说明使用的是默认值。</p>
+<h3 id=".E7.89.B9.E6.AE.8A.E5.86.85.E5.AE.B9.E6.8C.89.E9.92.AE" name=".E7.89.B9.E6.AE.8A.E5.86.85.E5.AE.B9.E6.8C.89.E9.92.AE">特殊内容按钮</h3>
+<p>按钮可以在内部包含任意的标记元素,这些元素将会被渲染在按钮内部。你或许不会经常使用这个,但你可以在创建自定义元素时使用它。</p>
+<p>例如,下面将创建一个有两个红字的按钮:</p>
+<p><span id="%E4%BE%8B4"><a id="%E4%BE%8B4"></a><strong>例4</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_advbtns_4.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_advbtns_4.xul">View</a></p>
+<pre>&lt;button&gt;
+ &lt;description value="This is a"/&gt;
+ &lt;description value="rather strange" style="color: red;"/&gt;
+ &lt;description value="button"/&gt;
+&lt;/button&gt;
+</pre>
+<p>任何XUL元素都可以放在<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/button" title="button">button</a></code></code>里面。HTML元素将被忽略,因此你需要使用<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/description" title="description">description</a></code></code>元素来包装它来达到换行的目的。如果你在按钮上指定<code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code>属性,它将会覆盖按钮内的所有内容。</p>
+<h4 id=".E5.BC.B9.E5.87.BA.E8.8F.9C.E5.8D.95.E6.8C.89.E9.92.AE" name=".E5.BC.B9.E5.87.BA.E8.8F.9C.E5.8D.95.E6.8C.89.E9.92.AE">弹出菜单按钮</h4>
+<p>你可以在按钮里面放置一个<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code></code>去促使在按钮被按下时向下弹出一个菜单,就像使用 <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code></code>。然而,在这个例子你必须设置<code><a href="/cn/XUL/Attribute/button.type" title="cn/XUL/Attribute/button.type">type</a></code> 属性的值为<code>menu</code>。</p>
+<p><span id="%E4%BE%8B5"><a id="%E4%BE%8B5"></a><strong>例5</strong></span> : <a href="https://developer.mozilla.org/samples/xultu/examples/ex_advbtns_5.xul.txt">Source</a> <a href="https://developer.mozilla.org/samples/xultu/examples/ex_advbtns_5.xul">View</a></p>
+<div class="float-right">
+ <img alt="Image:advbtns2.png" class="internal" src="/@api/deki/files/2643/=Advbtns2.png"></div>
+<pre>&lt;button type="menu" label="Device"&gt;
+ &lt;menupopup&gt;
+ &lt;menuitem label="Printer"/&gt;
+ &lt;menuitem label="Mouse"/&gt;
+ &lt;menuitem label="Keyboard"/&gt;
+ &lt;/menupopup&gt;
+&lt;/button&gt;
+</pre>
+<p>在这个例子中,用户可以点击按钮去弹出一个包括三个项目的菜单。注意在选择这些菜单项之中的一个时不会改变按钮的标签,不像<code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code></code>那样。这种按钮类型是有意做成类似于菜单的,在每个项目上附上脚本去执行任务。我们将会在后面看到更多的菜单。</p>
+<p>你也可以设置 <code><a href="/cn/XUL/Attribute/button.type" title="cn/XUL/Attribute/button.type">type</a></code> 属性的值为<code>menu-button</code>。这也可以创建一个像菜单的按钮,但显示会有所不同,右边的图像显示它们的区别。左边是一个'menu'而第二个是'menu-button'。 它有一个箭头标记菜单的存在。 在'menu'上,用户可以点击按钮的任何地方去显示菜单。在 'menu-button'上,用户点击箭头去显示菜单。</p>
+<p>接下来,我们将要学习更多关于 <a href="/cn/XUL_教程/盒状模型" title="cn/XUL_教程/盒状模型">在窗口中放置元素</a>.</p>
+<p></p><div class="prevnext" style="text-align: right;">
+ <p><a href="/zh-CN/docs/XUL_Tutorial:Using_Spacers" style="float: left;">« 上一页</a><a href="/zh-CN/docs/XUL_Tutorial:The_Box_Model">下一页 »</a></p>
+</div><p></p>
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/vbox/index.html b/files/zh-cn/mozilla/tech/xul/vbox/index.html
new file mode 100644
index 0000000000..eb23c89d10
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/vbox/index.html
@@ -0,0 +1,130 @@
+---
+title: vbox
+slug: Mozilla/Tech/XUL/vbox
+tags:
+ - XUL Elements
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/vbox
+---
+<div class="noinclude"><span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+
+<p>A container element which can contain any number of child elements. This is equivalent to the <code><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/box" title="box">box</a></code></code> element, except it defaults to vertical orientation.<br>
+ 一个可以包含任何子元素的容器元素。这相当于默认为垂直方向的<code style="font-style: normal;"><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/box" title="box">box</a></code></code> 元素。</p>
+
+<p>More information is available in the <a href="en/XUL_Tutorial/The_Box_Model">XUL tutorial</a>.<br>
+ 更多信息参考<a href="en/XUL_Tutorial/The_Box_Model">XUL tutorial</a>。</p>
+
+<h3 id="Example" name="Example">Example</h3>
+
+<h3 id="示例">示例</h3>
+
+<p><img alt="vbox example" src="https://mdn.mozillademos.org/files/7213/example.png" style="width: 94px; height: 46px;"></p>
+
+<pre>&lt;!-- Two labels at bottom --&gt;
+&lt;vbox&gt;
+ &lt;spacer flex="1"/&gt;
+ &lt;label value="One"/&gt;
+ &lt;label value="Two"/&gt;
+&lt;/vbox&gt;
+</pre>
+
+<h3 id="Attributes" name="Attributes">Attributes</h3>
+
+<h3 id="属性">属性</h3>
+
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0 0 10px 10px; padding: 0 10px; background: rgb(238, 238, 238);">
+<tbody>
+<tr>
+<td><p><strong>Inherited from XUL element</strong><br> <small>
+<code id="a-align"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/align">align</a></code>,
+<code id="a-allowevents"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allowevents">allowevents</a></code>,
+<code id="a-allownegativeassertions"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allownegativeassertions">allownegativeassertions</a></code>,
+<code id="a-class"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/class">class</a></code>,
+<code id="a-coalesceduplicatearcs"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/coalesceduplicatearcs">coalesceduplicatearcs</a></code>,
+<code id="a-collapsed"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/collapsed">collapsed</a></code>,
+<code id="a-container"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/container">container</a></code>,
+<code id="a-containment"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/containment">containment</a></code>,
+<code id="a-context"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/context">context</a></code>,
+<code id="a-contextmenu"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/contextmenu">contextmenu</a></code>,
+<code id="a-datasources"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/datasources">datasources</a></code>,
+<code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code>,
+<code id="a-empty"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/empty">empty</a></code>,
+<code id="a-equalsize"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/equalsize">equalsize</a></code>,
+<code id="a-flags"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flags">flags</a></code>,
+<code id="a-flex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/flex">flex</a></code>,
+<code id="a-height"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/height">height</a></code>,
+<code id="a-hidden"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/hidden">hidden</a></code>,
+<code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code>,
+<code id="a-insertafter"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/insertafter">insertafter</a></code>,
+<code id="a-insertbefore"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/insertbefore">insertbefore</a></code>,
+<code id="a-left"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/left">left</a></code>,
+<code id="a-maxheight"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/maxheight">maxheight</a></code>,
+<code id="a-maxwidth"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/maxwidth">maxwidth</a></code>,
+<code id="a-menu"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/menu">menu</a></code>,
+<code id="a-minheight"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/minheight">minheight</a></code>,
+<code id="a-minwidth"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/minwidth">minwidth</a></code>,
+<code id="a-mousethrough"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/mousethrough">mousethrough</a></code>,
+<code id="a-observes"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/observes">observes</a></code>,
+<code id="a-ordinal"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/ordinal">ordinal</a></code>,
+<code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code>,
+<code id="a-pack"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/pack">pack</a></code>,
+<code id="a-persist"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/persist">persist</a></code>,
+<code id="a-popup"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/popup">popup</a></code>,
+<code id="a-position"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/position">position</a></code>,
+<code id="a-preference-editable"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/preference-editable">preference-editable</a></code>,
+<code id="a-querytype"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/querytype">querytype</a></code>,
+<code id="a-ref"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/ref">ref</a></code>,
+<code id="a-removeelement"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/removeelement">removeelement</a></code>,
+<code id="a-sortDirection"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortDirection">sortDirection</a></code>,
+<code id="a-sortResource"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortResource">sortResource</a></code>,
+<code id="a-sortResource2"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/sortResource2">sortResource2</a></code>,
+<code id="a-statustext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/statustext">statustext</a></code>,
+<code id="a-style"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/style">style</a></code>,
+<code id="a-template"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/template">template</a></code>,
+<code id="a-tooltip"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tooltip">tooltip</a></code>,
+<code id="a-tooltiptext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tooltiptext">tooltiptext</a></code>,
+<code id="a-top"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/top">top</a></code>,
+<code id="a-uri"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/uri">uri</a></code>,
+<code id="a-wait-cursor"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/wait-cursor">wait-cursor</a></code>,
+<code id="a-width"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/width">width</a></code> </small></p>
+</td>
+</tr>
+</tbody>
+</table><p></p>
+
+<h3 id="Properties" name="Properties">Properties</h3>
+
+<h3 id="特性">特性</h3>
+
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited Properties</strong><br> <small> <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/align">align</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/allowEvents">allowEvents</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/boxObject">boxObject</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/builder">builder</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/className">className</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/collapsed">collapsed</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/contextMenu">contextMenu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/controllers">controllers</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/database">database</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/datasources">datasources</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/dir">dir</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/flex">flex</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/height">height</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/hidden">hidden</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/id">id</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/left">left</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxHeight">maxHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxWidth">maxWidth</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menu">menu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minHeight">minHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minWidth">minWidth</a></span></code>, , , , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/observes">observes</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ordinal">ordinal</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/orient">orient</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/pack">pack</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/persist">persist</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ref">ref</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/resource">resource</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/statusText">statusText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/style">style</a></span></code>, ,, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltip">tooltip</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltipText">tooltipText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/top">top</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/width">width</a></span></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+
+<h3 id="Methods" name="Methods">Methods</h3>
+
+<h3 id="方法">方法</h3>
+
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+
+<h3 id="Related" name="Related">Related</h3>
+
+<h3 id="相关">相关</h3>
+
+<dl>
+ <dt>Elements<br>
+ 元素</dt>
+ <dd><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/box" title="box">box</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/hbox" title="hbox">hbox</a></code></dd>
+</dl>
+
+<p> </p>
+
+<div class="noinclude"> </div>
+
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/window/index.html b/files/zh-cn/mozilla/tech/xul/window/index.html
new file mode 100644
index 0000000000..f748259648
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/window/index.html
@@ -0,0 +1,281 @@
+---
+title: window
+slug: Mozilla/Tech/XUL/window
+translation_of: Archive/Mozilla/XUL/window
+---
+<div class="noinclude"><span class="breadcrumbs XULRef_breadcrumbs">
+ « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a> [
+ <a href="#Examples">示例</a> |
+ <a href="#Attributes">属性</a> |
+ <a href="#Properties">特性</a> |
+ <a href="#Methods">方法</a> |
+ <a href="#Related">相关</a> ]
+</span></div>
+
+<p>window标签用来描述一个窗口的顶级结构,在 XUL文档中,他是一个根节点。默认情况下,它里面的控件是水平排列的。作为一个box容器, <a class="internal" href="/en/XUL/box" title="en/XUL/box">box</a>的属性都可以被使用. 默认的, 窗口将有一个特定于平台的框架围绕着他。</p>
+
+<p>如果需要给窗口添加一个图标,你需要首先创建一个 icon 文件,也就是例如 <var>&lt;windowid&gt;</var><code>.ico</code> 和 <var>&lt;windowid&gt;</var><code>.xpm</code> ,然后将他们放置到 <var>项目文件夹的</var><code>/chrome/icons/default/</code> 目录下. 这里所说的的 <var>&lt;windowid&gt;</var> 是此窗口内window标签的id. 这样,您就能为每个窗口设置不同的图标了。</p>
+
+<p>如果没有将 "<span class="nowiki">chrome://global/skin/</span>"下的指定css文件引用进来, 此窗口将不能正常加载 ,有可能看不见 或者被打开的时候出现漏洞.</p>
+
+<div class="note">
+<p><strong>注意:</strong> 通过<span title="(Firefox 3.6 / Thunderbird 3.1 / Fennec 1.0)">Gecko 1.9.2</span>标记, 当一个窗口通过查看动作引起的“激活”或“失活”事件被“激活”或“失活”时,你可以侦测到。这方面的信息,请查看  <a href="/en/XUL/Events#Window_activation_events" title="https://developer.mozilla.org/en/XUL/Events#Window_activation_events">窗口激活事件</a>.</p>
+</div>
+
+<p>更多的信息请查看 <a href="/en/XUL_Tutorial/Creating_a_Window" title="en/XUL_Tutorial/Creating_a_Window">XUL tutorial</a>.</p>
+
+<dl>
+ <dt>标记属性</dt>
+ <dd><a href="#a-accelerated">accelerated</a>, <a href="#a-chromemargin">chromemargin</a>, <a href="#a-disablechrome">disablechrome</a>, <a href="#a-disablefastfind">disablefastfind</a>, <a href="#a-drawintitlebar">drawintitlebar</a>, <a href="#a-fullscreenbutton">fullscreenbutton</a>, <a href="#a-height">height</a>, <a href="#a-hidechrome">hidechrome</a>, <a href="#a-id">id</a>, <a href="#a-lightweightthemes">lightweightthemes</a>, <a href="#a-lightweightthemesfooter">lightweightthemesfooter</a>, <a href="#a-screenX">screenX</a>, <a href="#a-screenY">screenY</a>, <a href="#a-sizemode">sizemode</a>, <a href="#a-title">title</a>, <a href="#a-width">width</a>, <a href="#a-windowtype">windowtype</a></dd>
+</dl>
+
+<h3 id="Examples" name="Examples">实例</h3>
+
+<pre class="brush: xml">&lt;?xml version="1.0"?&gt;
+&lt;?xml-stylesheet href="chrome://global/skin/" type="text/css"?&gt;
+&lt;!-- Extremely recommended to keep this css include!! --&gt;
+&lt;window id="rootWnd" title="Register Online!"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;
+ &lt;vbox&gt;
+ &lt;hbox&gt;
+ &lt;image src="application_form.png"/&gt;
+ &lt;description&gt;Register Online!&lt;/description&gt;
+ &lt;/hbox&gt;
+ &lt;groupbox align="start"&gt;
+ &lt;caption label="Your Information"/&gt;
+ &lt;radiogroup&gt;
+ &lt;vbox&gt;
+ &lt;hbox&gt;
+ &lt;label control="your-fname" value="Enter first name:"/&gt;
+ &lt;textbox id="your-fname" value="Johan"/&gt;
+ &lt;/hbox&gt;
+ &lt;hbox&gt;
+ &lt;label control="your-lname" value="Enter last name:"/&gt;
+ &lt;textbox id="your-lname" value="Hernandez"/&gt;
+ &lt;/hbox&gt;
+ &lt;hbox&gt;
+ &lt;button oncommand="alert('save!')"&gt;
+ &lt;description&gt;Save&lt;/description&gt;
+ &lt;/button&gt;
+ &lt;/hbox&gt;
+ &lt;/vbox&gt;
+ &lt;/radiogroup&gt;
+ &lt;/groupbox&gt;
+ &lt;/vbox&gt;
+&lt;/window&gt;
+</pre>
+
+<h3 id="Attributes" name="Attributes">标记属性</h3>
+
+<p></p><div id="a-accelerated">
+<dl><dt><code id="a-accelerated"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/accelerated">accelerated</a></code> </dt><dd>Type: <em>boolean</em></dd><dd>Set this attribute to <code>true</code> to allow hardware layer managers to accelerate the window.</dd></dl>
+</div><div id="a-activetitlebarcolor">
+
+<dl>
+ <dt>
+ <code id="a-activetitlebarcolor"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/activetitlebarcolor">activetitlebarcolor</a></code> </dt>
+ <dd>
+ Type: <em>color string</em></dd>
+ <dd>
+ Specify background color of the window's titlebar when it is active (foreground). Moreover this hides separator between titlebar and window contents. <em>This only affects Mac OS X.</em></dd>
+</dl>
+
+<p> </p>
+</div><div id="a-chromemargin">
+
+<dl> <dt><code id="a-chromemargin"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/chromemargin">chromemargin</a></code> </dt> <dd>Type: <em>margin string</em></dd> <dd>Controls the amount of chrome that should be visible on each side of the window. The specified string should contain four numbers, separated by commas, indicating the margin in pixels for the top, right, bottom, and left edges of the window, respectively. This value may be -1 to use the default margin for that side on the current platform, 0 to have no system border (that is, to extend the client area to the edge of the window), or a value greater than zero to indicate how much less than the default default width you wish the margin on that side to be. If this value turns out to be less than 0, 0 is used.</dd>
+</dl>
+</div><div id="a-disablechrome">
+
+<dl> <dt><code id="a-disablechrome"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/disablechrome">disablechrome</a></code> </dt> <dd>Type: <em>boolean</em></dd> <dd>Set this attribute to <code>true</code> to disable chrome in the window. This is used to hide chrome when showing in-browser UI such as the <code>about:addons</code> page, and causes the toolbars to be hidden, with only the tab strip (and, if currently displayed, the add-on bar) left showing.</dd> <div class="note"><strong>Note:</strong> This has no effect if the tabs on top preference is turned off.</div>
+</dl>
+</div><div id="a-disablefastfind">
+<dl><dt><code id="a-disablefastfind"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/disablefastfind">disablefastfind</a></code></dt><dd>Type: <em>boolean</em></dd><dd>Put <code>disablefastfind="true"</code> on the root element of a XUL document, which is intended to be loaded in a tab, to disable the find bar for the tab with this document. This is used to prevent the find bar from being displayed when it's not supported by the content (such as in the Add-ons manager tab).</dd></dl>
+</div><div id="a-drawintitlebar">
+
+<dl> <dt><code id="a-drawintitlebar"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/drawintitlebar">drawintitlebar</a></code> </dt> <dd>Type: <em>boolean</em></dd> <dd>If this attribute is <code>true</code>, the top of the window's content area will begin at the top edge of the title bar, instead of below the title bar. This allows the window to draw in the title bar. This is supported only from <code><a href="/en-US/docs/Mozilla/Tech/XUL/window" title="window">window</a></code> elements, and is ignored on platforms that don't support drawing into the title bar.</dd>
+</dl>
+</div><div id="a-fullscreenbutton">
+
+<dl> <dt><code id="a-fullscreenbutton"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/fullscreenbutton">fullscreenbutton</a></code> </dt> <dd>Type: <em>boolean</em></dd> <dd>Set this attribute to <code>true</code> to display a button in the window chrome to allow the user to switch the window into full screen mode. Supported on Mac OS X 10.7 Lion and later and on Windows. The window receives a "fullscreen" event once the change has been made.</dd>
+</dl>
+</div><div id="a-height">
+
+
+<dl>
+ <dt><code id="a-height"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/height">height</a></code></dt>
+ <dd>Type: <em>string</em> (representing an integer)</dd>
+ <dd>The preferred height of the element in pixels. The actual displayed height may be different if the element or its contents have a minimum or maximum height. The CSS height property may also be used.</dd>
+</dl>
+</div><div id="a-hidechrome">
+
+
+<dl>
+ <dt><code id="a-hidechrome"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/hidechrome">hidechrome</a></code></dt>
+ <dd>Type: <em>boolean</em></dd>
+ <dd>Set this attribute to <code>true</code> to have the chrome including the titlebar hidden.</dd>
+</dl>
+</div><div id="a-id">
+
+<dl>
+ <dt>
+ <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code></dt>
+ <dd>
+ 类型: <em>元素的ID,在主窗口中必须唯一</em></dd>
+ <dd>
+ 一个唯一的标识一边开发者能够定义. 你可以使用方法 <code><a href="/cn/DOM/document.getElementById" title="cn/DOM/document.getElementById">getElementById()</a></code> 或者其他 DOM 的函数并在样式表中添加对元素的引用。</dd>
+</dl>
+
+<p></p>
+</div><div id="a-inactivetitlebarcolor">
+
+
+<dl>
+ <dt><code id="a-inactivetitlebarcolor"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/inactivetitlebarcolor">inactivetitlebarcolor</a></code> </dt>
+ <dd>Type: <em>color string</em></dd>
+ <dd>Specify background color of the window's titlebar when it is inactive (background). Moreover this hides separator between titlebar and window contents. <em>This affects only on Mac OS X.</em></dd>
+</dl>
+</div><div id="a-lightweightthemes">
+
+<dl> <dt><code id="a-lightweightthemes"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/lightweightthemes">lightweightthemes</a></code> </dt> <dd>Type: <em>boolean</em></dd> <dd><code>true</code> if the window supports <a href="/en/Themes/Lightweight_themes" title="en/Themes/Lightweight themes">lightweight themes</a>, otherwise <code>false</code>.</dd>
+</dl>
+</div><div id="a-lightweightthemesfooter">
+
+<dl> <dt><code id="a-lightweightthemesfooter"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/lightweightthemesfooter">lightweightthemesfooter</a></code> </dt> <dd>Type: <em>id</em></dd> <dd>Specifies the ID of an element to which a <a href="/en/Themes/Lightweight_themes" title="en/Themes/Lightweight themes">lightweight theme</a>'s footer image will be applied.</dd>
+</dl>
+</div><div id="a-screenX">
+
+
+<dl>
+ <dt><code id="a-screenX"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/screenX">screenX</a></code></dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>The horizontal position at which the window appears on the screen.</dd>
+</dl>
+</div><div id="a-screenY">
+
+
+<dl>
+ <dt><code id="a-screenY"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/screenY">screenY</a></code></dt>
+ <dd>Type: <em>integer</em></dd>
+ <dd>The vertical position at which the window appears on the screen.</dd>
+</dl>
+</div><div id="a-sizemode">
+
+
+<dl>
+ <dt><code id="a-sizemode"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/sizemode">sizemode</a></code></dt>
+ <dd>Type: <em>one of the values below</em></dd>
+ <dd>The state of the <code><a href="/en-US/docs/Mozilla/Tech/XUL/window" title="window">window</a></code>. It can have one of the following values:</dd>
+ <dd>
+ <dl>
+ <dt><code>maximized</code></dt>
+ <dd>The window is maximized, and occupies the full size of the screen.</dd>
+ <dt><code>normal</code></dt>
+ <dd>The window appears in a normal state at the desired size.</dd>
+ </dl>
+ </dd>
+</dl>
+
+<p>This attribute is used to save and restore the state of a window (together with the <code><span><a href="https://developer.mozilla.org/en-US/docs/XUL/Property/persist">persist</a></span></code> attribute) and for CSS styles (e.g. to hide the resizer grippy on maximized windows).</p>
+
+<div class="note"><strong>Note:</strong> When a window is minimized, the <code>sizemode</code> attribute is not updated. This is done so that if a window is closed while minimized, its persisted <code>sizemode</code> attribute wouldn't be <code>minimized</code>.</div>
+
+<p>Setting this attribute does not change the window state. Use <a href="/en-US/docs/Web/API/Window/maximize" title="The documentation about this has not yet been written; please consider contributing!"><code>window.maximize()</code></a>, <a href="/en-US/docs/Web/API/Window/restore" title="This method is currently not working, but you can use:"><code>window.restore()</code></a>, or <a href="/en-US/docs/Web/API/Window/minimize" title="The Window.minimize() method sets the window to a minimized state."><code>window.minimize()</code></a> to change the window state.</p>
+
+<p>To get the window state from JavaScript code, use <a href="/en-US/docs/Web/API/Window/windowState" title="The windowState read-only property of the Window interface returns the window's current state."><code>window.windowState</code></a>. Listen to the <a href="/en/XUL/Events#Window_events" title="en/XUL/Events#Window_events"><code>sizemodechange</code> event</a> dispatched to the DOM window to get notified when the window state changes.</p>
+
+
+</div><div id="a-title">
+
+
+<dl>
+ <dt><code id="a-title"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/title">title</a></code></dt>
+ <dd>Type: <em>string</em></dd>
+ <dd>The text to appear in the title bar of the window.</dd>
+</dl>
+</div><div id="a-width">
+
+
+<dl>
+ <dt><code id="a-width"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/width">width</a></code></dt>
+ <dd>Type: <em>string</em> (representing an integer)</dd>
+ <dd>The preferred width of the element. The value should not include a unit as all values are in pixels. The actual displayed width may be different if the element or its contents have a minimum or maximum width, or the size is adjusted by the flexibility or alignment of its parent. The CSS width property may also be used.</dd>
+</dl>
+
+
+</div><div id="a-windowtype">
+
+<dl>
+ <dt>
+ <code id="a-windowtype"><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/windowtype">windowtype</a></code></dt>
+ <dd>
+ Type: <em>string</em></dd>
+ <dd>
+ Set to a string which can be used to identify the type of window. This might be used, for example, to distinguish between a browser window and an editor window. Some of Mozilla's window handling functions use this attribute to group windows of the same type together.</dd>
+</dl>
+<div class="note">
+ <p>Values for window type as found on MXR: <a href="http://mxr.mozilla.org/mozilla-release/search?string=windowtype">http://mxr.mozilla.org/mozilla-release/search?string=windowtype</a></p>
+ <p><strong>navigator:browser </strong>- Looks like if window has gBrowser it has this window type</p>
+ <p><strong>devtools:scratchpad </strong>- Scratchpad windows</p>
+ <p><strong>navigator:view-source</strong> - The view source windows</p>
+</div>
+
+<p> </p>
+</div><p></p>
+
+<h3 id="Properties" name="Properties">属性</h3>
+
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited Properties</strong><br> <small> <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/align">align</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/allowEvents">allowEvents</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/boxObject">boxObject</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/builder">builder</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/className">className</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/collapsed">collapsed</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/contextMenu">contextMenu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/controllers">controllers</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/database">database</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/datasources">datasources</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/dir">dir</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/flex">flex</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/height">height</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/hidden">hidden</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/id">id</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/left">left</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxHeight">maxHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxWidth">maxWidth</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menu">menu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minHeight">minHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minWidth">minWidth</a></span></code>, , , , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/observes">observes</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ordinal">ordinal</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/orient">orient</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/pack">pack</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/persist">persist</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ref">ref</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/resource">resource</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/statusText">statusText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/style">style</a></span></code>, ,, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltip">tooltip</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltipText">tooltipText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/top">top</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/width">width</a></span></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+
+<h3 id="Methods" name="Methods">方法</h3>
+
+<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
+</table><p></p>
+
+<p>另请参阅: <a href="/en/DOM/window#Methods" title="en/DOM/window#Methods">DOM <code>window</code> object methods</a><strong> </strong></p>
+
+<h3 id="Note" name="Note">请注意</h3>
+
+<p>DTD文件如果丢失或者不可访问,而XUL文件中却引用了其中的内容,将会引起 "XML Parsing Error: undefined entity...&lt;window" 的错误。DOCTYPE声明中系统关键字后如果含有文件名,将会引起没有提示的加载失败, 而唯一的错误提示将会是在下一个XUL元素加载时出现未定义实体的错误。</p>
+
+<h3 id="Related" name="Related">关联元素</h3>
+
+<dl>
+ <dd><code><a href="/zh-CN/docs/Mozilla/Tech/XUL/prefwindow" title="prefwindow">prefwindow</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/dialog" title="dialog">dialog</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/dialogheader" title="dialogheader">dialogheader</a></code></dd>
+</dl>
+
+<h3 id="相关的话题">相关的话题</h3>
+
+<dl>
+</dl>
+
+<h4 id="用户注意事项">用户注意事项</h4>
+
+<p>如果要更改窗口标题栏中的图标, 请参考这里: <a href="/en/Window_icons" title="en/Window_icons">Window icons</a>.</p>
+
+<p>如果要将小图标添加到地址栏和浏览器选项卡(即对话框不是弹出),请使用下面的代码片段来使用html名称空间和链接。</p>
+
+<pre class="brush: xml">&lt;window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:html="http://www.w3.org/1999/xhtml"&gt;
+
+&lt;!-- Icon from chrome --&gt;
+&lt;html:link rel="icon" href="chrome://myExtension/content/path/to/favicon.png"/&gt;
+
+&lt;!-- From a remote site --&gt;
+&lt;html:link rel="icon" href="http://www.mozilla.org/favicon.ico"/&gt;
+</pre>
+
+<p>由于Firefox3.6之前的代码不能正常工作 ——会出现以下提示: "Warning: XUL box for box element contained an inline link child, forcing all its children to be wrapped in a block". 如果这段代码放在window标签之间, 它将会使窗口内的所有其他控件都变得乱七八糟.而如果放在 <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/box" title="box">box</a></code> 标签之间, 窗口控件呈现反而很不错, 但是依然会引起错误。 这一问题可以如下解决:</p>
+
+<pre class="brush: xml">&lt;html:link rel="icon" href="chrome://myExtension/content/path/to/favicon.png" style="display:none"/&gt;
+</pre>
+
+<p>or</p>
+
+<pre class="brush: xml">&lt;html:head&gt;
+ &lt;html:link rel="icon" href="chrome://myExtension/content/path/to/favicon.png"/&gt;
+&lt;/html:head&gt;
+</pre>
+
+<p></p>
diff --git a/files/zh-cn/mozilla/tech/xul/xul_reference/index.html b/files/zh-cn/mozilla/tech/xul/xul_reference/index.html
new file mode 100644
index 0000000000..829a2a260e
--- /dev/null
+++ b/files/zh-cn/mozilla/tech/xul/xul_reference/index.html
@@ -0,0 +1,20 @@
+---
+title: XUL Reference
+slug: Mozilla/Tech/XUL/XUL_Reference
+tags:
+ - XUL
+ - XUL Reference
+translation_of: Archive/Mozilla/XUL/XUL_Reference
+---
+<p>« <a href="/en-US/docs/XUL" title="en-US/XUL">XUL Reference</a> «</p>
+<table class="fullwidth-table"> <tbody> <tr> <th colspan="3">全部 XUL 元素 (按英文字母顺序排列)</th> </tr> <tr> <td> <p><a href="/zh-cn/XUL/action" title="zh-cn/XUL/action">action</a><br> <a href="/ja/XUL/arrowscrollbox" title="ja/XUL/arrowscrollbox">arrowscrollbox</a><br> <a href="/ja/XUL/assign" title="ja/XUL/assign">assign</a><br> <a href="/ja/XUL/bbox" title="ja/XUL/bbox">bbox</a><br> <a href="/ja/XUL/binding" title="ja/XUL/binding">binding</a><br> <a href="/ja/XUL/bindings" title="ja/XUL/bindings">bindings</a><br> <a href="/ja/XUL/box" title="ja/XUL/box">box</a><br> <a href="/ja/XUL/broadcaster" title="ja/XUL/broadcaster">broadcaster</a><br> <a href="/ja/XUL/broadcasterset" title="ja/XUL/broadcasterset">broadcasterset</a><br> <a href="/ja/XUL/button" title="ja/XUL/button">button</a><br> <a href="/ja/XUL/browser" title="ja/XUL/browser">browser</a><br> <a href="/ja/XUL/checkbox" title="ja/XUL/checkbox">checkbox</a><br> <a href="/ja/XUL/caption" title="ja/XUL/caption">caption</a><br> <a href="/ja/XUL/colorpicker" title="ja/XUL/colorpicker">colorpicker</a><br> <a href="/ja/XUL/column" title="ja/XUL/column">column</a><br> <a href="/ja/XUL/columns" title="ja/XUL/columns">columns</a><br> <a href="/ja/XUL/commandset" title="ja/XUL/commandset">commandset</a><br> <a href="/ja/XUL/command" title="ja/XUL/command">command</a><br> <a href="/ja/XUL/conditions" title="ja/XUL/conditions">conditions</a><br> <a href="/ja/XUL/content" title="ja/XUL/content">content</a><br> <a href="/ja/XUL/datepicker" title="ja/XUL/datepicker">datepicker</a><br> <a href="/ja/XUL/deck" title="ja/XUL/deck">deck</a><br> <a href="/ja/XUL/description" title="ja/XUL/description">description</a><br> <a href="/ja/XUL/dialog" title="ja/XUL/dialog">dialog</a><br> <a href="/ja/XUL/dialogheader" title="ja/XUL/dialogheader">dialogheader</a><br> <a href="/ja/XUL/dropmarker" title="ja/XUL/dropmarker">dropmarker</a><br> <a href="/ja/XUL/editor" title="ja/XUL/editor">editor</a><br> <a href="/ja/XUL/grid" title="ja/XUL/grid">grid</a><br> <a href="/ja/XUL/grippy" title="ja/XUL/grippy">grippy</a><br> <a href="/ja/XUL/groupbox" title="ja/XUL/groupbox">groupbox</a><br> <a href="/ja/XUL/hbox" title="ja/XUL/hbox">hbox</a><br> <a href="/ja/XUL/iframe" title="ja/XUL/iframe">iframe</a><br> <a href="/ja/XUL/image" title="ja/XUL/image">image</a><br> <a href="/ja/XUL/key" title="ja/XUL/key">key</a><br> <a href="/ja/XUL/keyset" title="ja/XUL/keyset">keyset</a><br> <a href="/ja/XUL/label" title="ja/XUL/label">label</a><br> <a href="/ja/XUL/listbox" title="ja/XUL/listbox">listbox</a><br> <a href="/ja/XUL/listcell" title="ja/XUL/listcell">listcell</a><br> <a href="/ja/XUL/listcol" title="ja/XUL/listcol">listcol</a><br> <a href="/ja/XUL/listcols" title="ja/XUL/listcols">listcols</a><br> <a href="/ja/XUL/listhead" title="ja/XUL/listhead">listhead</a><br> <a href="/ja/XUL/listheader" title="ja/XUL/listheader">listheader</a><br> <a href="/ja/XUL/listitem" title="ja/XUL/listitem">listitem</a></p> </td> <td> <p><a href="/ja/XUL/member" title="ja/XUL/member">member</a><br> <a href="/ja/XUL/menu" title="ja/XUL/menu">menu</a><br> <a href="/ja/XUL/menubar" title="ja/XUL/menubar">menubar</a><br> <a href="/ja/XUL/menuitem" title="ja/XUL/menuitem">menuitem</a><br> <a href="/ja/XUL/menulist" title="ja/XUL/menulist">menulist</a><br> <a href="/ja/XUL/menupopup" title="ja/XUL/menupopup">menupopup</a><br> <a href="/ja/XUL/menuseparator" title="ja/XUL/menuseparator">menuseparator</a><br> <a href="/ja/XUL/notification" title="ja/XUL/notification">notification</a><br> <a href="/ja/XUL/notificationbox" title="ja/XUL/notificationbox">notificationbox</a><br> <a href="/ja/XUL/observes" title="ja/XUL/observes">observes</a><br> <a href="/ja/XUL/overlay" title="ja/XUL/overlay">overlay</a><br> <a href="/ja/XUL/page" title="ja/XUL/page">page</a><br> <a href="/ja/XUL/panel" title="ja/XUL/panel">panel</a><br> <a href="/ja/XUL/param" title="ja/XUL/param">param</a><br> <a href="/ja/XUL/popupset" title="ja/XUL/popupset">popupset</a><br> <a href="/ja/XUL/preference" title="ja/XUL/preference">preference</a><br> <a href="/ja/XUL/preferences" title="ja/XUL/preferences">preferences</a><br> <a href="/ja/XUL/prefpane" title="ja/XUL/prefpane">prefpane</a><br> <a href="/ja/XUL/prefwindow" title="ja/XUL/prefwindow">prefwindow</a><br> <a href="/ja/XUL/progressmeter" title="ja/XUL/progressmeter">progressmeter</a><br> <a href="/ja/XUL/query" title="ja/XUL/query">query</a><br> <a href="/ja/XUL/queryset" title="ja/XUL/queryset">queryset</a><br> <a href="/ja/XUL/radio" title="ja/XUL/radio">radio</a><br> <a href="/ja/XUL/radiogroup" title="ja/XUL/radiogroup">radiogroup</a><br> <a href="/ja/XUL/resizer" title="ja/XUL/resizer">resizer</a><br> <a href="/ja/XUL/richlistbox" title="ja/XUL/richlistbox">richlistbox</a><br> <a href="/ja/XUL/richlistitem" title="ja/XUL/richlistitem">richlistitem</a><br> <a href="/ja/XUL/row" title="ja/XUL/row">row</a><br> <a href="/ja/XUL/rows" title="ja/XUL/rows">rows</a><br> <a href="/ja/XUL/rule" title="ja/XUL/rule">rule</a><br> <a href="/ja/XUL/scale" title="ja/XUL/scale">scale</a><br> <a href="/ja/XUL/script" title="ja/XUL/script">script</a><br> <a href="/ja/XUL/scrollbar" title="ja/XUL/scrollbar">scrollbar</a><br> <a href="/ja/XUL/scrollbox" title="ja/XUL/scrollbox">scrollbox</a><br> <a href="/ja/XUL/scrollcorner" title="ja/XUL/scrollcorner">scrollcorner</a><br> <a href="/ja/XUL/separator" title="ja/XUL/separator">separator</a><br> <a href="/ja/XUL/spacer" title="ja/XUL/spacer">spacer</a><br> <a href="/ja/XUL/spinbuttons" title="ja/XUL/spinbuttons">spinbuttons</a><br> <a href="/ja/XUL/splitter" title="ja/XUL/splitter">splitter</a><br> <a href="/ja/XUL/stack" title="ja/XUL/stack">stack</a><br> <a href="/ja/XUL/statusbar" title="ja/XUL/statusbar">statusbar</a></p> </td> <td> <p><a href="/ja/XUL/statusbarpanel" title="ja/XUL/statusbarpanel">statusbarpanel</a><br> <a href="/ja/XUL/stringbundle" title="ja/XUL/stringbundle">stringbundle</a><br> <a href="/ja/XUL/stringbundleset" title="ja/XUL/stringbundleset">stringbundleset</a><br> <a href="/ja/XUL/tab" title="ja/XUL/tab">tab</a><br> <a href="/ja/XUL/tabbrowser" title="ja/XUL/tabbrowser">tabbrowser</a> (Firefox 3/Gecko 1.9 开始只用于Firefox本身)<br> <a href="/ja/XUL/tabbox" title="ja/XUL/tabbox">tabbox</a><br> <a href="/ja/XUL/tabpanel" title="ja/XUL/tabpanel">tabpanel</a><br> <a href="/ja/XUL/tabpanels" title="ja/XUL/tabpanels">tabpanels</a><br> <a href="/ja/XUL/tabs" title="ja/XUL/tabs">tabs</a><br> <a href="/ja/XUL/template" title="ja/XUL/template">template</a><br> <a href="/ja/XUL/textnode" title="ja/XUL/textnode">textnode</a><br> <a href="/ja/XUL/textbox" title="ja/XUL/textbox">textbox</a><br> <a href="/ja/XUL/textbox_(Firefox_autocomplete)" title="ja/XUL/textbox_(Firefox_autocomplete)">textbox (Firefox autocomplete)</a><br> <a href="/ja/XUL/textbox_(Mozilla_autocomplete)" title="ja/XUL/textbox_(Mozilla_autocomplete)">textbox (Mozilla autocomplete)</a><br> <a href="/ja/XUL/timepicker" title="ja/XUL/timepicker">timepicker</a><br> <a href="/ja/XUL/titlebar" title="ja/XUL/titlebar">titlebar</a><br> <a href="/ja/XUL/toolbar" title="ja/XUL/toolbar">toolbar</a><br> <a href="/ja/XUL/toolbarbutton" title="ja/XUL/toolbarbutton">toolbarbutton</a><br> <a href="/ja/XUL/toolbargrippy" title="ja/XUL/toolbargrippy">toolbargrippy</a><br> <a href="/ja/XUL/toolbaritem" title="ja/XUL/toolbaritem">toolbaritem</a><br> <a href="/ja/XUL/toolbarpalette" title="ja/XUL/toolbarpalette">toolbarpalette</a><br> <a href="/ja/XUL/toolbarseparator" title="ja/XUL/toolbarseparator">toolbarseparator</a><br> <a href="/ja/XUL/toolbarset" title="ja/XUL/toolbarset">toolbarset</a><br> <a href="/ja/XUL/toolbarspacer" title="ja/XUL/toolbarspacer">toolbarspacer</a><br> <a href="/ja/XUL/toolbarspring" title="ja/XUL/toolbarspring">toolbarspring</a><br> <a href="/ja/XUL/toolbox" title="ja/XUL/toolbox">toolbox</a><br> <a href="/ja/XUL/tooltip" title="ja/XUL/tooltip">tooltip</a><br> <a href="/ja/XUL/tree" title="ja/XUL/tree">tree</a><br> <a href="/ja/XUL/treecell" title="ja/XUL/treecell">treecell</a><br> <a href="/ja/XUL/treechildren" title="ja/XUL/treechildren">treechildren</a><br> <a href="/ja/XUL/treecol" title="ja/XUL/treecol">treecol</a><br> <a href="/ja/XUL/treecols" title="ja/XUL/treecols">treecols</a><br> <a href="/ja/XUL/treeitem" title="ja/XUL/treeitem">treeitem</a><br> <a href="/ja/XUL/treerow" title="ja/XUL/treerow">treerow</a><br> <a href="/ja/XUL/treeseparator" title="ja/XUL/treeseparator">treeseparator</a><br> <a href="/ja/XUL/triple" title="ja/XUL/triple">triple</a><br> <a href="/ja/XUL/vbox" title="ja/XUL/vbox">vbox</a><br> <a href="/ja/XUL/where" title="ja/XUL/where">where</a><br> <a href="/ja/XUL/window" title="ja/XUL/window">window</a><br> <a href="/ja/XUL/wizard" title="ja/XUL/wizard">wizard</a><br> <a href="/ja/XUL/wizardpage" title="ja/XUL/wizardpage">wizardpage</a></p> </td> </tr> </tbody>
+</table>
+<h1 id="XUL_参考">XUL 参考</h1>
+<p>« <a href="/en-US/docs/XUL" title="en-US/XUL">XUL Reference</a> «</p>
+<table class="fullwidth-table"> <tbody> <tr> <th colspan="3">XUL 要素 (按类别排序)</th> </tr> <tr> <td> <p><u><strong>WINDOWS</strong></u></p> <p><a href="/en/XUL/dialog" title="en/XUL/dialog">dialog</a><br> <a href="/en/XUL/overlay" title="en/XUL/overlay">overlay</a><br> <a href="/en/XUL/page" title="en/XUL/page">page</a><br> <a href="/en/XUL/window" title="en/XUL/window">window</a><br> <a href="/en/XUL/wizard" title="en/XUL/wizard">wizard</a><br> <a href="/en/XUL/wizardpage" title="en/XUL/wizardpage">wizardpage</a><br> <a href="/en/XUL/preference" title="en/XUL/preference">preference</a><br> <a href="/en/XUL/preferences" title="en/XUL/preferences">preferences</a><br> <a href="/en/XUL/prefpane" title="en/XUL/prefpane">prefpane</a><br> <a href="/en/XUL/prefwindow" title="en/XUL/prefwindow">prefwindow</a></p> <p><u><strong>WINDOW STRUCTURE</strong></u></p> <p><a href="/en/XUL/browser" title="en/XUL/browser">browser</a><br> <a href="/en/XUL/tabbrowser" title="en/XUL/tabbrowser">tabbrowser</a><br> <a href="/en/XUL/editor" title="en/XUL/editor">editor</a><br> <a href="/en/XUL/iframe" title="en/XUL/iframe">iframe</a><br> <a href="/en/XUL/titlebar" title="en/XUL/titlebar">titlebar</a><br> <a href="/en/XUL/resizer" title="en/XUL/resizer">resizer</a><br> <a href="/en/XUL/statusbar" title="en/XUL/statusbar">statusbar</a><br> <a href="/en/XUL/statusbarpanel" title="en/XUL/statusbarpanel">statusbarpanel</a><br> <a href="/en/XUL/dialogheader" title="en/XUL/dialogheader">dialogheader</a><br> <a href="/en/XUL/notification" title="en/XUL/notification">notification</a><br> <a href="/en/XUL/notificationbox" title="en/XUL/notificationbox">notificationbox</a></p> <p><u><strong>MENUS AND POPUPS</strong></u></p> <p><a href="/en/XUL/menubar" title="en/XUL/menubar">menubar</a><br> <a href="/en/XUL/menu" title="en/XUL/menu">menu</a><br> <a href="/en/XUL/menuitem" title="en/XUL/menuitem">menuitem</a><br> <a href="/en/XUL/menuseparator" title="en/XUL/menuseparator">menuseparator</a><br> <a href="/en/XUL/menupopup" title="en/XUL/menupopup">menupopup</a><br> <a href="/en/XUL/panel" title="en/XUL/panel">panel</a><br> <a href="/en/XUL/tooltip" title="en/XUL/tooltip">tooltip</a><br> <a href="/en/XUL/popupset" title="en/XUL/popupset">popupset</a></p> <p><u><strong>TOOLBARS</strong></u></p> <p><a href="/en/XUL/toolbar" title="en/XUL/toolbar">toolbar</a><br> <a href="/en/XUL/toolbarbutton" title="en/XUL/toolbarbutton">toolbarbutton</a><br> <a href="/en/XUL/toolbargrippy" title="en/XUL/toolbargrippy">toolbargrippy</a><br> <a href="/en/XUL/toolbaritem" title="en/XUL/toolbaritem">toolbaritem</a><br> <a href="/en/XUL/toolbarpalette" title="en/XUL/toolbarpalette">toolbarpalette</a><br> <a href="/en/XUL/toolbarseparator" title="en/XUL/toolbarseparator">toolbarseparator</a><br> <a href="/en/XUL/toolbarset" title="en/XUL/toolbarset">toolbarset</a><br> <a href="/en/XUL/toolbarspacer" title="en/XUL/toolbarspacer">toolbarspacer</a><br> <a href="/en/XUL/toolbarspring" title="en/XUL/toolbarspring">toolbarspring</a><br> <a href="/en/XUL/toolbox" title="en/XUL/toolbox">toolbox</a></p> <p><u><strong>TABS AND GROUPING</strong></u></p> <p><a href="/en/XUL/tabbox" title="en/XUL/tabbox">tabbox</a><br> <a href="/en/XUL/tabs" title="en/XUL/tabs">tabs</a><br> <a href="/en/XUL/tab" title="en/XUL/tab">tab</a><br> <a href="/en/XUL/tabpanels" title="en/XUL/tabpanels">tabpanels</a><br> <a href="/en/XUL/tabpanel" title="en/XUL/tabpanel">tabpanel</a><br> <a href="/en/XUL/groupbox" title="en/XUL/groupbox">groupbox</a><br> <a href="/en/XUL/caption" title="en/XUL/caption">caption</a><br> <a href="/en/XUL/separator" title="en/XUL/separator">separator</a><br> <a href="/en/XUL/spacer" title="en/XUL/spacer">spacer</a></p> </td> <td> <p><u><strong>CONTROLS</strong></u></p> <p><a href="/en/XUL/button" title="en/XUL/button">button</a><br> <a href="/en/XUL/checkbox" title="en/XUL/checkbox">checkbox</a><br> <a href="/en/XUL/colorpicker" title="en/XUL/colorpicker">colorpicker</a><br> <a href="/en/XUL/datepicker" title="en/XUL/datepicker">datepicker</a><br> <a href="/en/XUL/menulist" title="en/XUL/menulist">menulist</a><br> <a href="/en/XUL/progressmeter" title="en/XUL/progressmeter">progressmeter</a><br> <a href="/en/XUL/radio" title="en/XUL/radio">radio</a><br> <a href="/en/XUL/radiogroup" title="en/XUL/radiogroup">radiogroup</a><br> <a href="/en/XUL/scale" title="en/XUL/scale">scale</a><br> <a href="/en/XUL/splitter" title="en/XUL/splitter">splitter</a><br> <a href="/en/XUL/textbox" title="en/XUL/textbox">textbox</a><br> <a href="/En/XUL/Textbox_(Toolkit_autocomplete)" title="en/XUL/textbox_(Firefox_autocomplete)">textbox (Firefox autocomplete)</a><br> <a href="/En/XUL/Textbox_(XPFE_autocomplete)" title="en/XUL/textbox_(Mozilla_autocomplete)">textbox (Mozilla autocomplete)</a><br> <a href="/en/XUL/timepicker" title="en/XUL/timepicker">timepicker</a></p> <p><u><strong>TEXT AND IMAGES</strong></u></p> <p><a href="/en/XUL/description" title="en/XUL/description">description</a><br> <a href="/en/XUL/label" title="en/XUL/label">label</a><br> <a href="/en/XUL/image" title="en/XUL/image">image</a></p> <p><u><strong>LISTS</strong></u></p> <p><a href="/en/XUL/listbox" title="en/XUL/listbox">listbox</a><br> <a href="/en/XUL/listitem" title="en/XUL/listitem">listitem</a><br> <a href="/en/XUL/listcell" title="en/XUL/listcell">listcell</a><br> <a href="/en/XUL/listcol" title="en/XUL/listcol">listcol</a><br> <a href="/en/XUL/listcols" title="en/XUL/listcols">listcols</a><br> <a href="/en/XUL/listhead" title="en/XUL/listhead">listhead</a><br> <a href="/en/XUL/listheader" title="en/XUL/listheader">listheader</a><br> <a href="/en/XUL/richlistbox" title="en/XUL/richlistbox">richlistbox</a><br> <a href="/en/XUL/richlistitem" title="en/XUL/richlistitem">richlistitem</a></p> <p><u><strong>TREES</strong></u></p> <p><a href="/en/XUL/tree" title="en/XUL/tree">tree</a><br> <a href="/en/XUL/treecell" title="en/XUL/treecell">treecell</a><br> <a href="/en/XUL/treechildren" title="en/XUL/treechildren">treechildren</a><br> <a href="/en/XUL/treecol" title="en/XUL/treecol">treecol</a><br> <a href="/en/XUL/treecols" title="en/XUL/treecols">treecols</a><br> <a href="/en/XUL/treeitem" title="en/XUL/treeitem">treeitem</a><br> <a href="/en/XUL/treerow" title="en/XUL/treerow">treerow</a><br> <a href="/en/XUL/treeseparator" title="en/XUL/treeseparator">treeseparator</a></p> <p> </p> </td> <td> <p><u><strong>LAYOUT</strong></u></p> <p><a href="/en/XUL/box" title="en/XUL/box">box</a><br> <a href="/en/XUL/hbox" title="en/XUL/hbox">hbox</a><br> <a href="/en/XUL/vbox" title="en/XUL/vbox">vbox</a><br> <a href="/en/XUL/bbox" title="en/XUL/bbox">bbox</a><br> <a href="/en/XUL/deck" title="en/XUL/deck">deck</a><br> <a href="/en/XUL/stack" title="en/XUL/stack">stack</a><br> <a href="/en/XUL/grid" title="en/XUL/grid">grid</a><br> <a href="/en/XUL/columns" title="en/XUL/columns">columns</a><br> <a href="/en/XUL/column" title="en/XUL/column">column</a><br> <a href="/en/XUL/rows" title="en/XUL/rows">rows</a><br> <a href="/en/XUL/row" title="en/XUL/row">row</a><br> <a href="/en/XUL/scrollbox" title="en/XUL/scrollbox">scrollbox</a></p> <p><u><strong>TEMPLATES</strong></u></p> <p><a href="/en/XUL/action" title="en/XUL/action">action</a><br> <a href="/en/XUL/assign" title="en/XUL/assign">assign</a><br> <a href="/en/XUL/binding" title="en/XUL/binding">binding</a><br> <a href="/en/XUL/bindings" title="en/XUL/bindings">bindings</a><br> <a href="/en/XUL/conditions" title="en/XUL/conditions">conditions</a><br> <a href="/en/XUL/content" title="en/XUL/content">content</a><br> <a href="/en/XUL/member" title="en/XUL/member">member</a><br> <a href="/en/XUL/param" title="en/XUL/param">param</a><br> <a href="/en/XUL/query" title="en/XUL/query">query</a><br> <a href="/en/XUL/queryset" title="en/XUL/queryset">queryset</a><br> <a href="/en/XUL/rule" title="en/XUL/rule">rule</a><br> <a href="/en/XUL/template" title="en/XUL/template">template</a><br> <a href="/en/XUL/textnode" title="en/XUL/textnode">textnode</a><br> <a href="/en/XUL/triple" title="en/XUL/triple">triple</a><br> <a href="/en/XUL/where" title="en/XUL/where">where</a></p> <p><u><strong>SCRIPTING</strong></u></p> <p><a href="/en/XUL/script" title="en/XUL/script">script</a><br> <a href="/en/XUL/commandset" title="en/XUL/commandset">commandset</a><br> <a href="/en/XUL/command" title="en/XUL/command">command</a><br> <a href="/en/XUL/broadcaster" title="en/XUL/broadcaster">broadcaster</a><br> <a href="/en/XUL/broadcasterset" title="en/XUL/broadcasterset">broadcasterset</a><br> <a href="/en/XUL/observes" title="en/XUL/observes">observes</a><br> <a href="/en/XUL/key" title="en/XUL/key">key</a><br> <a href="/en/XUL/keyset" title="en/XUL/keyset">keyset</a><br> <a href="/en/XUL/stringbundle" title="en/XUL/stringbundle">stringbundle</a><br> <a href="/en/XUL/stringbundleset" title="en/XUL/stringbundleset">stringbundleset</a></p> <p><u><strong>HELPER ELEMENTS</strong></u></p> <p><a href="/en/XUL/scrollbar" title="en/XUL/scrollbar">arrowscrollbox<br> </a><a href="/en/XUL/dropmarker" title="en/XUL/dropmarker">dropmarker</a><br> <a href="/en/XUL/grippy" title="en/XUL/grippy">grippy</a><br> <a href="/en/XUL/scrollbar" title="en/XUL/scrollbar">scrollbar</a><br> <a href="/en/XUL/scrollcorner" title="en/XUL/scrollcorner">scrollcorner</a><br> <a href="/en/XUL/spinbuttons" title="en/XUL/spinbuttons">spinbuttons</a></p> </td> </tr> </tbody>
+</table>
+<h3 id="Other XUL lists" name="Other XUL lists">更多XUL相关列表</h3>
+<ul> <li><a href="/ja/XUL/Attribute" title="ja/XUL/Attribute">全部XUL属性</a></li> <li><a href="/ja/XUL/Property" title="ja/XUL/Property">全部XUL特性</a></li> <li><a href="/ja/XUL/Method" title="ja/XUL/Method">全部XUL方法</a></li> <li><a href="/ja/XUL_element_attributes" title="ja/XUL_element_attributes">Attributes defined for all XUL elements</a></li> <li><a href="/de/XUL/Style" rel="internal" title="de/XUL/Style">Style Klassen</a></li> <li><a href="/ja/XUL/Events" title="ja/XUL/Events">Event handlers</a></li> <li><a href="/Ja/XUL/Deprecated//Defunct_Markup" title="Ja/XUL/Deprecated//Defunct_Markup">Deprecated/Defunct Markup</a></li>
+</ul>
+<div class="noinclude"> <p></p>
+</div>
diff --git a/files/zh-cn/mozilla/thunderbird/index.html b/files/zh-cn/mozilla/thunderbird/index.html
new file mode 100644
index 0000000000..58129cc9e5
--- /dev/null
+++ b/files/zh-cn/mozilla/thunderbird/index.html
@@ -0,0 +1,75 @@
+---
+title: Thunderbird
+slug: Mozilla/Thunderbird
+translation_of: Mozilla/Thunderbird
+---
+<p><strong>Thunderbird</strong> 是Mozilla的电子邮件/消息应用程序。These pages document Thunderbird and also provide links to documentation about the <a href="/en-US/docs/tag/MailNews" title="tag/MailNews">MailNews</a> backend which is also used in other projects such as <a href="http://wiki.mozilla.org/Penelope">Eudora/Penelope</a>, <a href="http://www.seamonkey-project.org/">Seamonkey</a>, <a href="http://nkreeger.com/correo/">Correo</a>, etc.</p>
+<p>Thunderbird is Firefox's kid sibling, and is built on the same technical platform as the web browser. In development for many years, and currently one of the most popular open source email clients, it is used by millions of people around the world to bring together all their email accounts, newsgroup and feed reading in a familiar high-productivity environment.  (From early 2007 to early 2011 Thunderbird was developed by <a class="link-https" href="https://en.wikipedia.org/wiki/Mozilla_Messaging" title="https://en.wikipedia.org/wiki/Mozilla_Messaging">Mozilla Messaging</a>, a subsidiary that was owned by Mozilla.)</p>
+<table class="topicpage-table">
+ <tbody>
+ <tr>
+ <td>
+ <h2 class="Documentation" id="Documentation" name="Documentation">文档</h2>
+ <dl>
+ <dt>
+ <a href="https://developer.mozilla.org/en-US/docs/Simple_Thunderbird_build" title="Simple Thunderbird build">Building Thunderbird</a></dt>
+ <dd>
+ Information about building Thunderbird with the <a href="/en-US/docs/comm-central" title="comm-central">comm-central</a> repository. There's also information about <a href="/en-US/docs/How_comm-central%27s_build_system_works" title="How_comm-central's_build_system_works">how comm-central works</a>, how the <a href="/en-US/docs/Mailnews_and_Mail_code_review_requirements" title="Mailnews and Mail code review requirements">review process works</a> and how to use the <a href="/en-US/docs/Using_the_Mozilla_symbol_server" title="Using the Mozilla symbol server">Mozilla symbol server</a> to help with debugging.</dd>
+ <dt>
+ <a href="/en-US/docs/MailNews_Protocols" title="MailNews_Protocols">MailNews Protocols</a></dt>
+ <dd>
+ Rough documentation about mail protocols..</dd>
+ <dt>
+ <a href="/en-US/docs/DB_Views_%28message_lists%29" title="DB_Views_(message_lists)">Database views</a></dt>
+ <dd>
+ Backend information about {{ Interface("nsIMsgDBView") }} and related interfaces..</dd>
+ <dt>
+ <a href="/en-US/docs/Thunderbird/Thunderbird_API_documentation" title="Thunderbird API documentation">Thunderbird API documentation</a></dt>
+ <dd>
+ Thunderbird API documentation</dd>
+ <dt>
+ <a href="/en-US/docs/Extensions/Thunderbird" title="Extensions/Thunderbird/">Extension documentation</a></dt>
+ <dd>
+ Tutorials and tips for building Thunderbird extensions</dd>
+ <dt>
+ <a href="/en-US/docs/Thunderbird/Thunderbird_Automated_Testing" title="Thunderbird Automated Testing">Automated Testing</a></dt>
+ <dd>
+ Details of Thunderbird's automated testing facilities</dd>
+ <dt>
+ <a href="/en-US/docs/Thunderbird/Thunderbird_in_the_Enterprise" title="Thunderbird in the Enterprise">Thunderbird in the Enterprise</a></dt>
+ <dd>
+ Help with deploying Thunderbird in large organizations</dd>
+ </dl>
+ <p><span class="alllinks"><a href="/en-US/docs/tag/Thunderbird" title="tag/Thunderbird">View All...</a></span></p>
+ </td>
+ <td>
+ <h2 class="Community" id="Community" name="Community">社区</h2>
+ <ul>
+ <li>Support is handled at <a href="http://getsatisfaction.com/mozilla_messaging" title="http://getsatisfaction.com/mozilla_messaging">getsatisfaction</a>.</li>
+ <li>Extensions questions are frequently discussed on the dev-apps-thunderbird group: {{ DiscussionList("dev-apps-thunderbird", "mozilla.dev.apps.thunderbird") }}</li>
+ <li>Development discussion happens on the tb-planning mailing list:
+ <ul>
+ <li><a class="link-https" href="https://mail.mozilla.org/listinfo/tb-planning" title="https://mail.mozilla.org/listinfo/tb-planning">subscribe</a></li>
+ <li><a class="link-https" href="https://mail.mozilla.org/pipermail/tb-planning/" title="https://mail.mozilla.org/pipermail/tb-planning/">archives</a></li>
+ </ul>
+ </li>
+ <li><a href="http://forums.mozillazine.org/viewforum.php?f=50">Mozillazine forums</a></li>
+ <li><a href="http://www.mozillamessaging.com/">Mozilla Messaging web page</a></li>
+ <li><a class="link-irc" href="irc://irc.mozilla.org/thunderbird">#thunderbird on irc.mozilla.org</a> (for Users)</li>
+ <li><a class="link-irc" href="irc://irc.mozilla.org/maildev">#maildev on irc.mozilla.org</a> (for Developers)</li>
+ <li>a list of all <a href="http://wiki.mozilla.org/Thunderbird/CommunicationChannels" title="Thunderbird communication channels">Thunderbird communication channels</a></li>
+ </ul>
+ <h2 class="Tools" id="Tools" name="Tools">工具</h2>
+ <ul>
+ <li><a href="http://ted.mielczarek.org/code/mozilla/extensiondev/">Extension developer's extension</a></li>
+ <li><a href="/en-US/docs/DOM_Inspector" title="DOM_Inspector">DOM Inspector</a></li>
+ </ul>
+ <h2 class="Related_Topics" id="Related_Topics" name="Related_Topics">相关主题</h2>
+ <ul>
+ <li><a href="/en-US/docs/Extensions" title="Extensions">Extensions</a></li>
+ </ul>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
diff --git a/files/zh-cn/mozilla/thunderbird/mail_client_architecture_overview/index.html b/files/zh-cn/mozilla/thunderbird/mail_client_architecture_overview/index.html
new file mode 100644
index 0000000000..b289702d64
--- /dev/null
+++ b/files/zh-cn/mozilla/thunderbird/mail_client_architecture_overview/index.html
@@ -0,0 +1,94 @@
+---
+title: Mail client architecture overview
+slug: Mozilla/Thunderbird/Mail_client_architecture_overview
+translation_of: Mozilla/Thunderbird/Mail_client_architecture_overview
+---
+<p>{{ outdated("It was imported from mozilla.org and last updated in 2002. All of the links seem to be broken.") }}</p>
+
+<h2 id="The_mail_reader">The mail reader</h2>
+
+<table>
+ <tbody>
+ <tr>
+ <td colspan="4">
+ <div class="white" style="border: 1px solid black;"><em>Gecko (XUL and HTML rendering)</em></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div class="white" style="border: 1px solid black;"><em>RDF(dynamic widgets)</em></div>
+ </td>
+ <td colspan="2">
+ <div class="white" style="border: 1px solid black;"><em><a class="external" href="http://mxr.mozilla.org/js/">JS</a>(menus, events)</em></div>
+ </td>
+ <td rowspan="4">
+ <div class="mail"><span style="color: #000000;">libmime</span></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div class="mail white">Mail Datasources</div>
+ </td>
+ <td colspan="2">
+ <div class="mail white">Mail JavaScript</div>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <div class="white mail" style="border-bottom: medium none;">Folder/Message management</div>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">msgdb</td>
+ <td>
+ <div class="mail" style="border-top: medium none; border-left: medium none;"> </div>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="4">
+ <div class="mail">IMAP/NNTP/POP3</div>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="4">
+ <div class="white" style="border: 1px solid black;"><em>Necko(networking)</em></div>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p> <span style="background-color: #888888;">灰色</span> 带黑框的表示mail/news之外的模块。</p>
+
+<p> </p>
+
+<h2 id="The_base_Module">The base Module</h2>
+
+<p> </p>
+
+<p>基础模块提供了一个协议无关的消息服务接口。包括帐户、文件夹和消息管理。</p>
+
+<p>The base module consists of the following basic building blocks</p>
+
+<ul>
+ <li><a class="external" href="/en/Using_the_Multiple_Accounts_API" title="https://developer.mozilla.org/en/Using_the_Multiple_Accounts_API">Account Management</a> - The Account Manager is the root object of the server/folder/message hierarchy. It manages individual accounts on mail servers and the identity of users as used to send mail.</li>
+ <li><a class="external" href="http://mxr.mozilla.org/mozilla-org/source/html/mailnews/arch/folders.html">Folders</a> - Mail folders contain messages and folders. All folders have folder indexes.</li>
+ <li><a class="external" href="http://mxr.mozilla.org/mozilla-org/source/html/mailnews/arch/messages.html">Messages</a> - Messages are always stored and streamed in RFC822 format. Whenever multiple messages are stored in one file, the berkeley mailbox format is used.</li>
+ <li><a class="external" href="http://mxr.mozilla.org/mozilla-org/source/html/mailnews/arch/rdf.html">Datasources</a> - Datasources are the glue code that reflect mail data such as folders and messages into RDF. RDF will use the datasource to create user interfaces based on this data. Datasources are also used to run commands that operate on this mail data.</li>
+ <li><a class="external" href="http://mxr.mozilla.org/mozilla-org/source/html/mailnews/arch/events.html">Events</a> - As data changes throughout the mail application, the event system notifies key components such as datasources and the URL system of these changes.</li>
+ <li><a class="external" href="http://mxr.mozilla.org/mozilla-org/source/html/mailnews/arch/mailwindow.html">Mail Window Management</a> - Each mail window maintains a certain amount of state to aid in view navigation, progress display, etc.</li>
+ <li><a class="external" href="http://mxr.mozilla.org/mozilla-org/source/html/mailnews/arch/network.html">URL display and dispatching</a> - In order to perform network operations such as downloading new mail, copying and moving messages, and displaying messages from a remote server, the URL system interacts with necko and reflects it's state to the mail window.</li>
+</ul>
+
+<p>There are also a number of protocol independant subsystems that have a symbiotic relationship with base:</p>
+
+<ul>
+ <li><a class="external" href="http://mxr.mozilla.org/mozilla-org/source/html/mailnews/libmime-description.html">libMIME</a> - for dealing with RFC822 messages and their MIME parts. This library has the cabability to stream messages to an HTML renderer such as Gecko, manage individual parts of messages, and so forth.</li>
+ <li><a class="external" href="http://mxr.mozilla.org/mozilla-org/source/html/mailnews/arch/db.html">msgdb</a> - A message database for a given folder is a summary of some of the key attributes in a folder such as the Author and Subject.</li>
+</ul>
+
+<p>Finally, there are larger modules outside of the mail client that are mail-oriented. Most of these modules have little dependancy on the mail reader itself:</p>
+
+<ul>
+ <li><a class="external" href="http://mxr.mozilla.org/mozilla-org/source/html/mailnews/arch/compose/">Compose</a> - The mail compose module is responsible for anything that has to do with sending mail. This includes the mail compose window, creation of RFC822 messages from the data a user has entered, and sending the messages via SMTP.</li>
+ <li><a class="external" href="http://mxr.mozilla.org/mozilla-org/source/html/mailnews/arch/addrbook/">Address book</a> - The address book contains lists of people and all attributes associated with them such as their e-mail address, phone number, etc.</li>
+</ul>
diff --git a/files/zh-cn/mozilla/thunderbird/mailnews_protocols/index.html b/files/zh-cn/mozilla/thunderbird/mailnews_protocols/index.html
new file mode 100644
index 0000000000..b6b0c4873f
--- /dev/null
+++ b/files/zh-cn/mozilla/thunderbird/mailnews_protocols/index.html
@@ -0,0 +1,31 @@
+---
+title: MailNews Protocols
+slug: Mozilla/Thunderbird/MailNews_protocols
+translation_of: Mozilla/Thunderbird/MailNews_protocols
+---
+<ul>
+ <li><a href="en/IMAP">IMAP</a></li>
+ <li><a href="en/POP3">POP3</a></li>
+ <li><a href="en/NNTP">NNTP</a></li>
+ <li><a href="en/SMTP">SMTP</a></li>
+ <li><a href="en/Mailbox">Mailbox</a></li>
+ <li><a href="en/RSS">RSS</a></li>
+</ul>
+
+<p>除了RSS,这些协议以C++实现。 RSS以<a class="external" href="http://mxr.mozilla.org/mailnews/source/mail/extensions/newsblog/js/newsblog.js#1">JS</a> 实现,而且实现模式和其他以C++实现的协议不同。</p>
+
+<p>IMAP、POP3和NNTP 是 "incoming" 协议,即从服务器获取消息, 并以文件夹的形式展现给用户。这些协议在mailnews相应的协议子目录中定义(即 mailnews/imap, mailnews/local (for pop3), mailnews/news),均有如下的类组成:</p>
+
+<p>An <strong>incoming server</strong> class, which implements nsIMsgIncomingServer and inherits from mailnews/base/util/nsMsgIncomingServer, i.e.., nsPop3IncomingServer, nsImapIncomingServer, nsNNTPIncomingServer.</p>
+
+<p>A <strong>folder </strong>class, which implements nsIMsgFolder, and inherits from nsMsgDBFolder. Most commands/operations go through the folder object. nsImapMailFolder, <a class="external" href="http://mxr.mozilla.org/mozilla/source/mailnews/news/src/nsNewsFolder.cpp#116">nsNewsFolder</a>, nsLocalMailFolder (for POP3)</p>
+
+<p>A <strong>service </strong>class, which generally sits between the folder object or the server object, and the protocol object. The service class creates and initializes the url object for the operation, and hands that off to a protocol object to run. The service classes usually have their own interface, but they also implement nsIMsgMessageService.</p>
+
+<p>A <strong>url </strong>object. These implement nsIMsgMailNewsUrl, inherit from base/util/nsMsgMailNewsUrl, and implement their own protocol-specific interface (nsIImapUrl, nsINntpUrl, nsIPop3Url).</p>
+
+<p>A <strong>protocol </strong>object that takes a url and handles the network communications with the actual server required to run that url. These implement nsIMsgProtocol, inherit from nsMsgProtocol, and implement their own protocol-specific interface (nsIImapProtocol, nsIPop3Protocol, nsINntpProtocol)</p>
+
+<p>In addition, in mailnews/db/msgdb/public, we have protocol-specific msg db classes (and in the case of news, <a class="external" href="http://mxr.mozilla.org/mozilla/source/mailnews/db/msgdb/public/nsINewsDatabase.idl#49">a nsINewsDatabase interface</a>), so that we can use polymorphism when msg db operations need to be specialized for different kinds of folders.</p>
+
+<p>The <a class="external" href="http://bonsai.mozilla.org/rview.cgi?dir=mozilla%2Fmailnews%2Fbase%2Fsearch%2Fsrc&amp;rev=&amp;module=default&amp;cvsroot=%2Fcvsroot">message search code</a> also has protocol-specific code to handle searching on the server, or local mailbox. The search code also knows what the different search capabilities of the various protocols are.</p>
diff --git a/files/zh-cn/mozilla/toolkit_version_format/index.html b/files/zh-cn/mozilla/toolkit_version_format/index.html
new file mode 100644
index 0000000000..ce6e5b2399
--- /dev/null
+++ b/files/zh-cn/mozilla/toolkit_version_format/index.html
@@ -0,0 +1,88 @@
+---
+title: 版本格式说明
+slug: Mozilla/Toolkit_version_format
+tags:
+ - Toolkit API
+translation_of: Mozilla/Toolkit_version_format
+---
+<p>本文档是 Firefox 1.5(XULRunner 1.8)及更高版本中使用的版本格式的参考。此格式由扩展管理器,软件更新和平台其他部分的使用。至少以下位置的版本必须符合以下格式:</p>
+
+<ul>
+ <li><a href="zh-CN/docs/Install_Manifests#version">插件</a>和<a href="zh-CN/docs/Install_Manifests#targetApplication">目标应用</a>版本<a href="zh-CN/docs/Install_Manifests">安装</a>和<a href="zh-CN/docs/Update_Manifest">更新</a>清单</li>
+ <li><code><font face="Open Sans, arial, sans-serif">在 </font>app.extensions.version</code> 和 <code>extensions.lastAppVersion</code> 中</li>
+ <li><a href="zh-CN/docs/NsIXULAppInfo">nsIXULAppInfo</a> 返回的版本</li>
+ <li><a href="zh-CN/docs/XULRunner">XULRunner</a> 中的 <a href="zh-CN/docs/XUL_Application_Packaging"><code>application.ini</code></a></li>
+ <li><a href="zh-CN/docs/Chrome_Registration">chrome manifests</a> 中的 <a href="zh-CN/docs/Chrome_Registration#appversion">appversion flag</a></li>
+</ul>
+
+<p>您可以使用 {{ interface("nsIVersionComparator") }} 来比较应用程序的版本。</p>
+
+<p>有关 Firefox / Thunderbird 1.0 中使用的旧版本格式的说明,请参阅 {{ Anch("Older version formats") }}.</p>
+
+<h3 id="Version_format" name="Version_format">版本格式</h3>
+
+<p>版本字符串由一个或多个版本部分组成,用点分隔。</p>
+
+<p>每个版本的一部分本身解析为四个部分组成一个序列:<code>&lt;number-a&gt;&lt;string-b&gt;&lt;number-c&gt;&lt;string-d&gt;. </code>每个部分都是可选的。数字是 10 进制的整数(可以是负数),字符串是非数字的ASCII字符。</p>
+
+<p>有效版本部分的几个例子:</p>
+
+<ul>
+ <li><code>0</code> (例如 <code>1.0</code>): <code>&lt;number-a&gt;=0</code></li>
+ <li><code>5a</code> (例如 <code>1.5a</code>): <code>&lt;number-a&gt;=5</code>, <code>&lt;string-b&gt;=a</code></li>
+ <li><code>5pre4</code> (例如 <code>3.5pre4</code>): <code>&lt;number-a&gt;=5</code>, <code>&lt;string-b&gt;=pre</code>, <code>&lt;number-c&gt;=4</code></li>
+ <li><code>*</code> (例如 <code>1.0.*</code>): <code>&lt;string-b&gt;=*</code></li>
+</ul>
+
+<p>应用一些特殊的解析规则来实现向后兼容性和可读性:</p>
+
+<ul>
+ <li>如果版本部分是单个星号,则将其解释为无限大的数字:<br>
+ <code>1.5.0.*</code> 和 <code>1.5.0.</code> 是相同的<em>(无限大)</em></li>
+ <li>如果 <code>&lt;string-b&gt;</code> 是加号,则 <code>&lt;number-a&gt;</code> 会增加以与 Firefox 1.0.x 兼容的版本格式:<br>
+ <code>1.0+</code> 和 <code>1.1pre</code> 是相同的</li>
+</ul>
+
+<p>当比较版本时,将版本分解为字符串部分和数字部分对应起来一一比较, 例如 <code>'1.0pre1' &lt; '1.0pre10'。</code>有关如何比较版本的详细信息,请参阅下一节。</p>
+
+<h3 id="Comparing_versions" name="Comparing_versions">比较版本</h3>
+
+<p>当比较两个版本字符串时,它们的版本部分将从左到右进行比较。空的或缺少的版本部分等于 0 。</p>
+
+<p>当一个版本字符串的版本部分大于另一个版本字符串的相应版本部分时,第一个版本字符串大于另一个版本字符串。</p>
+
+<p>否则,版本字符串相等。请注意,由于缺少的版本部分被视为 0,所以以下版本字符串相等: <code>1, 1.0, 1.0., 1.0.0, </code>还有 <code>1.0...</code></p>
+
+<h4 id="Comparing_version_parts" name="Comparing_version_parts">比较版本部分</h4>
+
+<p>版本部分也从左到右进行比较,将 <code>&lt;number-a&gt; </code>和 <code>&lt;number-c&gt; </code>作为数字进行比较,而 <code>&lt;string-b&gt; </code>和 <code>&lt;string-b&gt; </code>按字节比较。 存在的字符串部分始终小于不存在的字符串部分(如 <code>1.6a </code>小于<code>1.6</code>)。</p>
+
+<h3 id="Examples" name="Examples">一些例子</h3>
+
+<pre class="eval">1.-1
+&lt; 1 == 1. == 1.0 == 1.0.0
+&lt; 1.1a &lt; 1.1aa &lt; 1.1ab &lt; 1.1b &lt; 1.1c
+&lt; 1.1whatever
+&lt; 1.1pre == 1.1pre0 == 1.0+
+&lt; 1.1pre1a &lt; 1.1pre1aa &lt; 1.1pre1b &lt; 1.1pre1
+&lt; 1.1pre2
+&lt; 1.1pre10
+&lt; 1.1.-1
+&lt; 1.1 == 1.1.0 == 1.1.00
+&lt; 1.10
+&lt; 1.* &lt; 1.*.1
+&lt; 2.0
+</pre>
+
+<h3 id="Technical Reference" name="Technical Reference">技术参考</h3>
+
+<p>如果你有兴趣看 toolkit 版本比较的实现, 请参考 <a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/nsVersionComparator.cpp" title="http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/nsVersionComparator.cpp">nsVersionComparator.cpp</a>.</p>
+
+<h3 id="Older_version_formats" name="Older_version_formats">旧版本的格式</h3>
+
+<p>Firefox 和 Thunderbird 1.0 使用简单的版本格式,即</p>
+
+<pre class="eval">major[.minor[.release[.build]]][+]
+</pre>
+
+<p>其中 <code>{{ mediawiki.external('..') }}</code> 表示可选部分, <code>major<font face="Open Sans, arial, sans-serif">,</font></code><code>minor</code>,<code>release </code>和 <code>build</code> 都是非负整数。</p>
diff --git a/files/zh-cn/mozilla/webidl_bindings/index.html b/files/zh-cn/mozilla/webidl_bindings/index.html
new file mode 100644
index 0000000000..27b670ceea
--- /dev/null
+++ b/files/zh-cn/mozilla/webidl_bindings/index.html
@@ -0,0 +1,920 @@
+---
+title: WebIDL绑定
+slug: Mozilla/WebIDL_bindings
+translation_of: Mozilla/WebIDL_bindings
+---
+<div class="note">
+<p>注意:需要记录索引和命名的setter / creator / deleter的设置。</p>
+</div>
+
+<p>在构建时生成 <a class="external external-icon" href="http://www.w3.org/TR/WebIDL/">WebIDL</a> binding 需要两个东西:一个实实在在的WebIDL文件,以及另一个描述了 WebIDL 如何映射为 Gecko 内部代码的元数据配置文件。</p>
+
+<p>所有的 WebIDL文件应该放置在 <a class="external external-icon" href="http://mxr.mozilla.org/mozilla-central/source/dom/webidl/"><code>dom/webidl</code></a> 中并将文件名添加到该目录下的 <a href="http://mxr.mozilla.org/mozilla-central/source/dom/webidl/moz.build">moz.build</a> 文件的列表中。</p>
+
+<p>注意如果你添加了新的接口,关于<code><a href="http://mxr.mozilla.org/mozilla-central/source/dom/tests/mochitest/general/test_interfaces.html"> dom/tests/mochitest/general/test_interfaces.html</a> </code>很可能会失效。这就表示你需要让你的 <a href="https://wiki.mozilla.org/Modules/All#Document_Object_Model">DOM peer</a> review 一下。不要急于在没有 review 的情况下将你的接口添加到<a href="https://dxr.mozilla.org/mozilla-central/source/dom/webidl/moz.build">moz.build</a> 列表中;这样只会惹恼你的 DOM peers,最后无论如何你的改动都得被重新review。</p>
+
+<p><code><a class="external external-icon" href="http://mxr.mozilla.org/mozilla-central/source/dom/bindings/Bindings.conf">dom/bindings/Bindings.conf</a></code>配置文件是一个简单的Python dict(字典)类型数据。它会将接口名称与接口信息相映射,这被称为<em>descriptor</em>(python描述符)。会有各种可能的方式来处理每种边缘情况,然而大多数描述符通常都非常简单。</p>
+
+<p>所有生成的代码都放置在 <code>mozilla::dom</code> namespace 中。对于每个接口,将创建一个名称以<code>Binding</code>为后缀的namespace ,与该接口的 binding 相关的所有内容都放在该namespace中。</p>
+
+<p>有许多放在 <a href="https://dxr.mozilla.org/mozilla-central/source/dom/bindings/"><code>dom/bindings</code></a> 目录中的助手对象和工具方法同样也在 <code>mozilla::dom</code> 命名空间中,其头文件也被导出到了 <code>mozilla/dom</code> 中(在编译时会放到 <code><code>$OBJDIR/dist/include</code></code> 目录).。</p>
+
+<h2 id="向一个类添加_WebIDL_绑定">向一个类添加 WebIDL 绑定</h2>
+
+<p>要将<code>MyInterface</code> 接口的WebIDL binding 添加到应该实现该接口的类 <code>mozilla::dom::MyInterface</code>中,你需要执行以下操作:</p>
+
+<ol>
+ <li>如果你的接口没有继承自其他任何接口,你应当继承 <code>nsWrapperCache</code>,并把该类Hook到生命周期收集器(cycle collector),以便它可以正确地跟踪 wrapper 缓存。请注意,如果您的对象只能创建,而不能从其他对象获取,则可能不需要执行此操作。如果你也继承了 <code>nsISupports</code>接口,请确保 <code>nsISupports </code>在父类列表中位于 <code>nsWrapperCache</code> 之前。如果您的接口 <em>确实 </em>继承了别的接口,则只需继承另一个接口对应的C++类型即可。</li>
+</ol>
+
+<p>如果确实需要Hook 生命周期收集器(cycle collector),在同样也继承了nsISupports的常见情况下,它将如下所示:</p>
+
+<pre>// Add strong pointers your class holds here. If you do, change to using
+// NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE.
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(MyClass)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(MyClass)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(MyClass)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MyClass)
+ NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+ NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END</pre>
+
+<p>       2. 如果你的类不是继承自实现了 <code>GetParentObject</code>接口的类,则添加一个同名函数。对于您的类的给定实例,该函数每次都返回相同的对象(除非您编写显式代码,通过重新设置JS wrapper来处理父对象的更改,就像节点所做的那样)。其思想是遍历 <code>GetParentObject </code>链最终会将您得到 Window。这样,每个WebIDL对象都与一个特定的窗口相关联。</p>
+
+<p>例如,<code>nsINode::GetParentObject  </code>返回节点的所有者文档。<code>GetParentObject</code>的返回类型并不重要,只是它必须单独从<code>nsISupports</code>继承,或者具有可以从中生成<code>nsISupports</code>的相应<a href="http://dxr.mozilla.org/mozilla-central/search?q=function%3AToSupports&amp;case=true"><code>ToSupports</code></a>方法。(这允许编译器通过该类的一个非显式构造函数将返回值隐式转换为 <a href="http://dxr.mozilla.org/mozilla-central/search?q=type%3AParentObject&amp;case=true&amp;redirect=true">ParentObject</a>实例.)</p>
+
+<p>如果希望快速创建许多 <code>MyInterface</code> 实例,则 <code>GetParentObject</code> 的返回值本身应从<code>nsWrapperCache</code> 继承以获得最佳性能。在出于安全目的将结果对象与随机全局对象相关联的情况下,允许从<code>GetParentObject</code>返回null ;对于将其暴露于Web content,这通常是不合适的。同样,如果您不需要wrapper 缓存,则不需要执行此操作。从<code>GetParentObject</code>返回的实际类型必须在你实现的头文件中的头部 include 中导入,以便此类型的定义对绑定代码可见。</p>
+
+<p>      3. 在 <code>dom/webidl</code>目录下添加 <code>MyInterface</code> 的WebIDL 定义, 并将该文件添加到 <code>dom/webidl/moz.build </code>的列表中.</p>
+
+<p>      4. 在<code>dom/bindings/Bindings.conf</code>中添加一个条目,用于设置有关接口实现的一些基本信息。如果C++类型不是 <code>mozilla::dom::MyInterface</code>,则需要将 <code>'nativeType'</code>设置为正确的类型。如果通过将“::”替换为“/”并附加“.h”路径 的该类型头文件中不存在,则将其相应的位置添加至相应的“headerFile”注释中 (或向.webidl文件添加 <code><a href="https://wiki.developer.mozilla.org/zh-CN/docs/Mozilla/WebIDL_bindings$edit#HeaderFile" title="#HeaderFile">HeaderFile</a> </code>annotation 注释)。如果您不需要设置任何注释,那么您也不需要添加条目,代码生成器将简单地采用此处的默认值。请注意,通常不建议使用“headerFile”注释。如果您确实使用了它,您将需要确保您的头文件 include 了 <code><a href="https://wiki.developer.mozilla.org/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Func">Func</a> </code>注释所需的所有头文件。</p>
+
+<p>    5. 将外部接口条目添加到<code>Bindings.conf</code>中,用于新接口的任何 作为 非webidl接口的参数或返回值。</p>
+
+<p>    6.  在<code>mozilla::dom::MyInterface</code>上实现<code>WrapObject</code> 重载,它只调用 <code>mozilla::dom::MyInterface_Binding::Wrap</code>。请注意,如果您的C++类型正在实现多个不同的Web IDL接口,则需要选择在此处调用哪个<code>mozilla::dom::MyInterface_Binding::Wrap</code>。例如,参见<code>AudioContext::WrapObject</code>。</p>
+
+<p>    7.  在<code>mozilla::dom::MyInterface</code>上公开接口需要的任何方法。它们可以是inline、virtual、具有任何调用约定的,等等,只要它们具有正确的参数类型和返回类型。通过运行<code>mach webidl-example MyInterface</code>,您可以看到函数声明应该是什么样子的示例。这将在objdir中的 <code>dom/bindings</code> 中生成两个文件:<code>MyInterface-example.h</code>和<code>MyInterface-example.cpp</code>,这两个文件显示了使用从<code>nsISupports</code>继承并具有包装器缓存的类的接口的基本实现。</p>
+
+<p>参见  <a class="link-https" href="https://hg.mozilla.org/mozilla-central/rev/dd08c10193c6">sample patch that migrates window.performance.* to WebIDL bindings</a>(这是一个往window添加接口的提交。译者注).</p>
+
+<div class="note"><strong>注意:</strong> 如果您的对象只能通过创建来被JS调用,而不是通过从某个地方获取它,那么您可以跳过上面的步骤1和2,而且向您的descriptor中添加 <code>'wrapperCache': False</code>。您需要在WebIDL中将返回对象的函数标记为<a href="https://heycam.github.io/webidl/#NewObject"><code>[NewObject]</code></a> 。如果您的对象没有使用引用计数,则返回它的函数的返回值应返回 nsAutoPtr</div>
+
+<h2 id="创建WebIDL_之_C反射">创建WebIDL 之  C++反射</h2>
+
+<h3 id="WebIDL操作之C反射方法">WebIDL操作之C++反射(方法)</h3>
+
+<p>WebIDL操作被转换为对底层C++对象的方法调用。如何确定返回类型和参数类型的方法 <a href="/zh-CN/docs/Mozilla/WebIDL_bindings#typemapping">如下所述</a>。除此之外,所有 <a href="/zh-CN/docs/Mozilla/WebIDL_bindings#Throws">允许抛出的方法</a> 都将获得一个附加到其参数列表中的<code> ErrorResult&amp; </code>参数。使用特定WebIDL类型( 如 <code>any</code> 或者<code>object</code> )的非静态方法将获得参数列表之前的<code>JSContext*</code>参数。静态方法将被传递一个 <a href="/zh-CN/docs/Mozilla/WebIDL_bindings#GlobalObject" title="#GlobalObject"><code>const GlobalObject&amp;</code></a> 用作相关的全局变量,并且可以通过对其调用 <code>Context()</code>来获取<code>JSContext*</code> 。</p>
+
+<p>C++方法的名称只是WebIDL操作的名称,第一个字母转换为大写。</p>
+
+<p>WebIDL重载被转换为C++重载:它们只是调用具有相同名称和不同签名的C++方法。</p>
+
+<p>例如如下所示的 webidl:</p>
+
+<pre><code>interface MyInterface
+{
+ void doSomething(long number);
+ double doSomething(MyInterface? otherInstance);
+
+ [Throws]
+ MyInterface doSomethingElse(optional long maybeNumber);
+ [Throws]
+ void doSomethingElse(MyInterface otherInstance);
+
+ void doTheOther(any something);
+
+ void doYetAnotherThing(optional boolean actuallyDoIt = false);
+
+ static void staticOperation(any arg);
+};</code></pre>
+
+<p>会需要这些方法声明:</p>
+
+<pre><code>class MyClass
+{
+ void DoSomething(int32_t aNumber);
+ double DoSomething(MyClass* aOtherInstance);
+
+ already_AddRefed&lt;MyInterface&gt; DoSomethingElse(Optional&lt;int32_t&gt; aMaybeNumber,
+ ErrorResult&amp; rv);
+ void DoSomethingElse(MyClass&amp; aOtherInstance, ErrorResult&amp; rv);
+
+ void DoTheOther(JSContext* cx, JS::Value aSomething);
+
+ void DoYetAnotherThing(bool aActuallyDoIt);
+
+ static void StaticOperation(const GlobalObject&amp; aGlobal, JS::Value aSomething);
+}</code></pre>
+
+<h3 id="WebIDL属性的C反射">WebIDL属性的C++反射</h3>
+
+<p>WebIDL属性被转换为底层C++对象上getter和setter的一对方法调用。只读属性只有getter而没有setter。</p>
+
+<p>getter的名称是将第一个字母转换为大写的属性的名称。如果满足以下任一条件,则将<code>Get</code> 前置:</p>
+
+<ol>
+ <li>属性的类型可以为空。</li>
+ <li>getter 可以 throw。</li>
+ <li>属性的返回值通过C++ 中的 out parameter 返回。</li>
+</ol>
+
+<p>getter的方法签名看起来就像没有参数的操作,并且属性的类型作为返回类型。</p>
+
+<p> setter 的名称是<code>Set</code> ,后跟属性的名称,第一个字母转换为大写。方法签名看起来就像一个具有void返回值和单个参数的操作,该参数的类型是属性的类型。</p>
+
+<h3 id="WebIDL构造函数的_C反射">WebIDL构造函数的 C++反射</h3>
+
+<p>WebIDL构造函数被转换为名为<code>Constructor</code>的静态类方法。此方法的参数将是WebIDL构造函数的参数,带有 <a href="/zh-CN/docs/Mozilla/WebIDL_bindings#GlobalObject" title="#GlobalObject"><code>const GlobalObject&amp;</code></a> 用于相关的全局前缀。对于非Worker情况,全局通常是构造函数附加到的 DOM Window 的 内部 Window 。如果由于某些参数类型也需要<code>JSContext*</code>,则它将位于全局变量之后。<code>MyInterface</code>的构造函数的返回值与返回<code>MyInterface</code>实例的方法的返回值完全相同。始终允许构造函数 throw。</p>
+
+<p>如下 IDL所示:</p>
+
+<pre><code>[Constructor,
+ Constructor(unsigned long someNumber)]
+interface MyInterface
+{
+};</code></pre>
+
+<p>需要在 <code>MyClass</code>中进行如下声明:</p>
+
+<pre><code>class MyClass {
+ // Various nsISupports stuff or whatnot
+ static
+ already_AddRefed&lt;MyClass&gt; Constructor(const GlobalObject&amp; aGlobal,
+ ErrorResult&amp; rv);
+ static
+ already_AddRefed&lt;MyClass&gt; Constructor(const GlobalObject&amp; aGlobal,
+ uint32_t aSomeNumber,
+ ErrorResult&amp; rv);
+};</code></pre>
+
+<h3 id="C_reflections_of_WebIDL_types">C++ reflections of WebIDL types</h3>
+
+<p>The exact C++ representation for WebIDL types can depend on the precise way that they're being used: e.g. return values, arguments, and sequence or dictionary members might all have different representations.</p>
+
+<p>Unless stated otherwise, a type only has one representation.  Also, unless stated otherwise, nullable types are represented by wrapping <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Nullable"><code>Nullable&lt;&gt;</code></a> around the base type.</p>
+
+<p>In all cases, optional arguments which do not have a default value are represented by wrapping<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Optional"><code>const Optional&lt;&gt;&amp;</code></a> around the representation of the argument type.  If the argument type is a C++ reference, it will also become a <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#NonNull">NonNull&lt;&gt;</a> around the actual type of the object in the process.  Optional arguments which do have a default value are just represented by the argument type itself, set to the default value if the argument was not in fact passed in.</p>
+
+<p>Variadic WebIDL arguments are treated as a <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Sequence"><code>const Sequence&lt;&gt;&amp;</code></a> around the actual argument type.</p>
+
+<h4 id="any"><code>any</code></h4>
+
+<p><code>any</code> is represented in three different ways, depending on use:</p>
+
+<ul>
+ <li><code>any</code> arguments become <code>JS::Handle&lt;JS::Value&gt;</code>.</li>
+ <li><code>any</code> return values become a <code>JS::MutableHandle&lt;JS::Value&gt;</code> out param appended to the argument list.  This comes after all IDL arguments, but before the <code>ErrorResult&amp;</code>, if any, for the method.</li>
+ <li><code>any</code> dictionary members and sequence elements become <code>JS::Value</code>.  The dictionary members and sequence elements are guaranteed to be marked by whoever puts the sequence or dictionary on the stack, using <code>SequenceRooter</code> and <code>DictionaryRooter</code>.</li>
+</ul>
+
+<p>Methods using <code>any</code> always get a <code>JSContext*</code> argument.</p>
+
+<p>For example, this WebIDL:</p>
+
+<pre class="language-html">interface Test { attribute any myAttr; any myMethod(any arg1, sequence&lt;any&gt; arg2, optional any arg3); };</pre>
+
+<p>will correspond to these C++ function declarations:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">void MyAttr(JSContext* cx, JS::MutableHandle&lt;JS::Value&gt; retval);
+void SetMyAttr(JSContext* cx, JS::Handle&lt;JS::Value&gt; value);
+void MyMethod(JSContext* cx, JS::Handle&lt;JS::Value&gt; arg1,
+ const Sequence&lt;JS::Value&gt;&amp; arg2,
+ const Optional&lt;JS::Handle&lt;JS::Value&gt; &gt;&amp; arg3,
+ JS::MutableHandle&lt;JS::Value&gt; retval);</code></pre>
+
+<h4 id="boolean"><code>boolean</code></h4>
+
+<p>The <code>boolean</code> WebIDL type is represented as a C++ <code>bool</code>.</p>
+
+<p>For example, this WebIDL:</p>
+
+<pre class="language-html">interface Test { attribute boolean myAttr; boolean myMethod(optional boolean arg); };</pre>
+
+<p>will correspond to these C++ function declarations:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">bool MyAttr();
+void SetMyAttr(bool value);
+JS::Value MyMethod(const Optional&lt;bool&gt;&amp; arg);</code></pre>
+
+<h4 id="Integer_types">Integer types</h4>
+
+<p>Integer WebIDL types are mapped to the corresponding C99 stdint types.</p>
+
+<p>For example, this WebIDL:</p>
+
+<pre class="language-html">interface Test { attribute short myAttr; long long myMethod(unsigned long? arg); };</pre>
+
+<p>will correspond to these C++ function declarations:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">int16_t MyAttr();
+void SetMyAttr(int16_t value);
+int64_t MyMethod(const Nullable&lt;uint32_t&gt;&amp; arg);</code></pre>
+
+<h4 id="Floating_point_types">Floating point types</h4>
+
+<p>Floating point WebIDL types are mapped to the C++ type of the same name.  So <code>float</code> and<code>unrestricted float</code> become a C++ <code>float</code>, while <code>double</code> and <code>unrestricted double</code>become a C++ <code>double</code>.</p>
+
+<p>For example, this WebIDL:</p>
+
+<pre class="language-html">interface Test { float myAttr; double myMethod(unrestricted double? arg); };</pre>
+
+<p>will correspond to these C++ function declarations:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">float MyAttr();
+void SetMyAttr(float value);
+double MyMethod(const Nullable&lt;double&gt;&amp; arg);</code></pre>
+
+<h4 id="DOMString"><code>DOMString</code></h4>
+
+<p>Strings are reflected in three different ways, depending on use:</p>
+
+<ul>
+ <li>String arguments become <code>const nsAString&amp;</code>.</li>
+ <li>String return values become a <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#DOMString-helper"><code>mozilla::dom::DOMString&amp;</code></a> out param appended to the argument list.  This comes after all IDL arguments, but before the <code>ErrorResult&amp;</code>, if any, for the method.  Note that this allows callees to declare their methods as taking an<code>nsAString&amp;</code> or <code>nsString&amp;</code> if desired.</li>
+ <li>Strings in sequences, dictionaries, owning unions, and variadic arguments become<code>nsString</code>.</li>
+</ul>
+
+<p>Nullable strings are represented by the same types as non-nullable ones, but the string will return true for <code>DOMStringIsNull()</code>.  Returning null as a string value can be done using<code>SetDOMStringToNull</code> on the out param if it's an <code>nsAString</code> or calling <code>SetNull()</code> on a<code>DOMString</code>.</p>
+
+<p>For example, this WebIDL:</p>
+
+<pre class="language-html">interface Test { DOMString myAttr; [Throws] DOMString myMethod(sequence&lt;DOMString&gt; arg1, DOMString? arg2, optional DOMString arg3); };</pre>
+
+<p>will correspond to these C++ function declarations:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">void GetMyAttr(nsString&amp; retval);
+void SetMyAttr(const nsAString&amp; value);
+void MyMethod(const Sequence&lt;nsString&gt;&amp; arg1, const nsAString&amp; arg2,
+ const Optional&lt;nsAString&gt;&amp; arg3, nsString&amp; retval, ErrorResult&amp; rv);</code></pre>
+
+<h4 id="ByteString"><code>ByteString</code></h4>
+
+<p><code>ByteString</code> is reflected in three different ways, depending on use:</p>
+
+<ul>
+ <li><code>ByteString</code> arguments become <code>const nsACString&amp;</code>.</li>
+ <li><code>ByteString</code> return values become an <code>nsCString&amp;</code> out param appended to the argument list.  This comes after all IDL arguments, but before the <code>ErrorResult&amp;</code>, if any, for the method.</li>
+ <li><code>ByteString</code> in sequences, dictionaries, owning unions, and variadic arguments becomes <code>nsCString</code>.</li>
+</ul>
+
+<p>Nullable <code>ByteString</code> are represented by the same types as non-nullable ones, but the string will return true for <code>IsVoid()</code>.  Returning null as a string value can be done using <code>SetIsVoid()</code>on the out param.</p>
+
+<h4 id="object"><code>object</code></h4>
+
+<p><code>object</code> is represented in three different ways, depending on use:</p>
+
+<ul>
+ <li><code>object</code> arguments become <code>JS::Handle&lt;JSObject*&gt;</code>.</li>
+ <li><code>object</code> return values become a <code>JS::MutableHandle&lt;JSObject*&gt;</code> out param appended to the argument list.  This comes after all IDL arguments, but before the<code>ErrorResult&amp;</code>, if any, for the method.</li>
+ <li><code>object</code> dictionary members and sequence elements become <code>JSObject*</code>.  The dictionary members and sequence elements are guaranteed to be marked by whoever puts the sequence or dictionary on the stack, using <code>SequenceRooter</code> and<code>DictionaryRooter</code>.</li>
+</ul>
+
+<p>Methods using <code>object</code> always get a <code>JSContext*</code> argument.</p>
+
+<p>For example, this WebIDL:</p>
+
+<pre class="language-html">interface Test { object myAttr; object myMethod(object arg1, object? arg2, sequence&lt;object&gt; arg3, optional object arg4, optional object? arg5); };</pre>
+
+<p>will correspond to these C++ function declarations:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">void GetMyAttr(JSContext* cx, JS::MutableHandle&lt;JSObject*&gt; retval);
+void SetMyAttr(JSContext* cx, JS::Handle&lt;JSObject*&gt; value);
+void MyMethod(JSContext* cx, JS::Handle&lt;JSObject*&gt; arg1, JS::Handle&lt;JSObject*&gt; arg2,
+ const Sequence&lt;JSObject*&gt;&amp; arg3,
+ const Optional&lt;JS::Handle&lt;JSObject*&gt; &gt;&amp; arg4,
+ const Optional&lt;JS::Handle&lt;JSObject*&gt; &gt;&amp; arg5,
+ JS::MutableHandle&lt;JSObject*&gt; retval);</code></pre>
+
+<h4 id="Interface_types">Interface types</h4>
+
+<p>There are four kinds of interface types in the WebIDL bindings.  Callback interfaces are used to represent script objects that browser code can call into.  External interfaces are used to represent objects that have not been converted to the WebIDL bindings yet.  WebIDL interfaces are used to represent WebIDL binding objects.  "SpiderMonkey" interfaces are used to represent objects that are implemented natively by the JavaScript engine (e.g. typed arrays).</p>
+
+<h5 id="Callback_interfaces">Callback interfaces</h5>
+
+<p>Callback interfaces are represented in C++ as objects inheriting from<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#CallbackInterface"><code>mozilla::dom::CallbackInterface</code></a>, whose name, in the <code>mozilla::dom</code> namespace, matches the name of the callback interface in the WebIDL.  The exact representation depends on how the type is being used.</p>
+
+<ul>
+ <li>Nullable arguments become <code>Foo*</code>.</li>
+ <li>Non-nullable arguments become <code>Foo&amp;</code>.</li>
+ <li>Return values become <code>already_AddRefed&lt;Foo&gt;</code> or <code>Foo*</code> as desired.  The pointer form is required if the method or property involved is flagged as <code>resultNotAddRefed</code> in<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Bindings.conf"><code>Bindings.conf</code></a>.</li>
+ <li>WebIDL callback interfaces in sequences, dictionaries, owning unions, and variadic arguments are represented by <code>nsRefPtr&lt;Foo&gt;</code> if nullable and <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#OwningNonNull"><code>OwningNonNull&lt;Foo&gt;</code></a>otherwise.</li>
+</ul>
+
+<p>If the interface is a single-opertion interface, the object exposes two methods that both invoke the same underlying JS callable.  The first of these methods allows the caller to pass in a <code>this</code>object, while the second defaults to <code>undefined</code> as the <code>this</code> value.  In either case, the <code>this</code>value is only used if the callback interface is implemented by a JS callable.  If it's implemented by an object with a property whose name matches the operation, the object itself is always used as <code>this</code>.</p>
+
+<p>If the interface is not a single-operation interface, it just exposes a single method for every IDL method/getter/setter.</p>
+
+<p>The signatures of the methods correspond to the signatures for throwing IDL methods/getters/setters with an additional trailing "<code>mozilla::dom::CallbackObject::ExceptionHandling</code> <code>aExceptionHandling</code>" argument, defaulting to <code>eReportExceptions</code>.  If <code>aReportExceptions</code> is set to<code>eReportExceptions</code>, the methods will report JS exceptions before returning.  If<code>aReportExceptions</code> is set to <code>eRethrowExceptions</code>, JS exceptions will be stashed in the<code>ErrorResult</code> and will be reported when the stack unwinds to wherever the <code>ErrorResult</code> was set up.</p>
+
+<p>For example, this WebIDL:</p>
+
+<pre class="language-html">callback interface MyCallback { attribute long someNumber; short someMethod(DOMString someString); }; callback interface MyOtherCallback { // single-operation interface short doSomething(Node someNode); }; interface MyInterface { attribute MyCallback foo; attribute MyCallback? bar; };</pre>
+
+<p>will lead to these C++ class declarations, in the <code>mozilla::dom</code> namespace:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">class MyCallback : public CallbackInterface
+{
+ int32_t GetSomeNumber(ErrorResult&amp; rv, ExceptionHandling aExceptionHandling = eReportExceptions);
+ void SetSomeNumber(int32_t arg, ErrorResult&amp; rv,
+ ExceptionHandling aExceptionHandling = eReportExceptions);
+ int16_t SomeMethod(const nsAString&amp; someString, ErrorResult&amp; rv,
+ ExceptionHandling aExceptionHandling = eReportExceptions);
+};
+
+class MyOtherCallback : public CallbackInterface
+{
+public:
+ int16_t
+ DoSomething(nsINode&amp; someNode, ErrorResult&amp; rv,
+ ExceptionHandling aExceptionHandling = eReportExceptions);
+
+ template&lt;typename T&gt;
+ int16_t
+ DoSomething(const T&amp; thisObj, nsINode&amp; someNode, ErrorResult&amp; rv,
+ ExceptionHandling aExceptionHandling = eReportExceptions);
+};</code></pre>
+
+<p>and these C++ function declarations on the implementation of <code>MyInterface</code>:</p>
+
+<pre class="language-html">already_AddRefed&lt;MyCallback&gt; GetFoo(); void SetFoo(MyCallback&amp;); already_AddRefed&lt;MyCallback&gt; GetBar(); void SetBar(MyCallback*);</pre>
+
+<h5 id="External_interfaces">External interfaces</h5>
+
+<p>External interfaces are represented in C++ as objects that XPConnect knows how to unwrap to.  This can mean XPCOM interfaces (whether declared in XPIDL or not) or it can mean some type that there's a castable native unwrapping function for.  The C++ type to be used should be the<code>nativeType</code> listed for the external interface in the <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Bindings.conf"><code>Bindings.conf</code></a> file.  The exact representation depends on how the type is being used.</p>
+
+<ul>
+ <li>Arguments become <code>nsIFoo*</code>.</li>
+ <li>Return values become <code>already_AddRefed&lt;nsIFoo&gt;</code> or <code>nsIFoo*</code> as desired.  The pointer form is required if the method or property involved is flagged as<code>resultNotAddRefed</code> in <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Bindings.conf"><code>Bindings.conf</code></a>.</li>
+ <li>External interfaces in sequences, dictionaries, owning unions, and variadic arguments are represented by <code>nsRefPtr&lt;nsIFoo&gt;.</code></li>
+</ul>
+
+<h5 id="WebIDL_interfaces">WebIDL interfaces</h5>
+
+<p>WebIDL interfaces are represented in C++ as C++ classes.  The class involved must either be refcounted or must be explicitly annotated in <code>Bindings.conf</code> as being directly owned by the JS object.  If the class inherits from <code>nsISupports</code>, then the canonical <code>nsISupports</code> must be on the primary inheritance chain of the object.  If the interface has a parent interface, the C++ class corresponding to the parent must be on the primary inheritance chain of the object.  This guarantees that a <code>void*</code> can be stored in the JSObject which can then be <code>reinterpret_cast</code>to any of the classes that correspond to interfaces the object implements.  The C++ type to be used should be the <code>nativeType</code> listed for the interface in the <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Bindings.conf"><code>Bindings.conf</code></a> file, or<code>mozilla::dom::InterfaceName</code> if none is listed.  The exact representation depends on how the type is being used.</p>
+
+<ul>
+ <li>Nullable arguments become <code>Foo*</code>.</li>
+ <li>Non-nullable arguments become <code>Foo&amp;</code>.</li>
+ <li>Return values become <code>already_AddRefed&lt;Foo&gt;</code> or <code>Foo*</code> as desired.  The pointer form is required if the method or property involved is flagged as <code>resultNotAddRefed</code> in<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Bindings.conf"><code>Bindings.conf</code></a>.</li>
+ <li>WebIDL interfaces in sequences, dictionaries, owning unions, and variadic arguments are represented by <code>nsRefPtr&lt;Foo&gt;</code> if nullable and <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#OwningNonNull"><code>OwningNonNull&lt;Foo&gt;</code></a> otherwise.</li>
+</ul>
+
+<p>For example, this WebIDL:</p>
+
+<pre class="language-html">interface MyInterface { attribute MyInterface myAttr; void passNullable(MyInterface? arg); MyInterface? doSomething(sequence&lt;MyInterface&gt; arg); MyInterface doTheOther(sequence&lt;MyInterface?&gt; arg); readonly attribute MyInterface? nullableAttr; readonly attribute MyInterface someOtherAttr; // Marked as resultNotAddRefed readonly attribute MyInterface someYetOtherAttr; };</pre>
+
+<p>Would correspond to these C++ function declarations:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">already_AddRefed&lt;MyClass&gt; MyAttr();
+void SetMyAttr(MyClass&amp; value);
+void PassNullable(MyClass* arg);
+already_AddRefed&lt;MyClass&gt; doSomething(const Sequence&lt;OwningNonNull&lt;MyClass&gt; &gt;&amp; arg);
+already_AddRefed&lt;MyClass&gt; doTheOther(const Sequence&lt;nsRefPtr&lt;MyClass&gt; &gt;&amp; arg);
+already_Addrefed&lt;MyClass&gt; GetMyAttr();
+MyClass* SomeOtherAttr();
+MyClass* SomeYetOtherAttr(); // Don't have to return already_AddRefed!</code></pre>
+
+<h5 id="SpiderMonkey_interfaces">"SpiderMonkey" interfaces</h5>
+
+<p>Typed array, array buffer, and array buffer view arguments are represented by the objects in<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#TypedArray"><code>TypedArray.h</code></a>.  For example, this WebIDL:</p>
+
+<pre class="language-html">interface Test { void passTypedArrayBuffer(ArrayBuffer arg); void passTypedArray(ArrayBufferView arg); void passInt16Array(Int16Array? arg); }</pre>
+
+<p>will correspond to these C++ function declarations:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">void PassTypedArrayBuffer(const ArrayBuffer&amp; arg);
+void PassTypedArray(const ArrayBufferView&amp; arg);
+void PassInt16Array(const Nullable&lt;Int16Array&gt;&amp; arg);</code></pre>
+
+<p>Typed array return values are represented by <code>JSObject*</code>.</p>
+
+<p>Typed arrays store a <code>JSObject*</code> and hence need to be rooted properly.  On-stack typed arrays can be declared as <code>RootedTypedArray&lt;TypedArrayType&gt;</code> (e.g.<code>RootedTypedArray&lt;Int16Array&gt;</code>).  Typed arrays on the heap need to be traced.</p>
+
+<h4 id="Dictionary_types">Dictionary types</h4>
+
+<p>A dictionary argument is represented by a const reference to a struct whose name is the dictionary name in the <code>mozilla::dom</code> namespace.  The struct has one member for each of the dictionary's members with the same name except the first letter uppercased and prefixed with "m". The members that have default values have types as described under the corresponding WebIDL type in this document.  The members that don't have default values have those types wrapped in <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Optional"><code>Optional&lt;&gt;</code></a>.</p>
+
+<p>Dictionary return values are represented by an out parameter whose type is a non-const reference to the struct described above, with all the members that have default values preinitialized to those default values.</p>
+
+<p>Note that optional dictionary arguments are always considered to have a default value of <code>null</code>so dictionary arguments are never wrapped in <code>Optional&lt;&gt;</code>.</p>
+
+<p>If necessary, dictionaries can be directly initialized from a <code>JS::Value</code> in C++ code by invoking their <code>Init()</code> method.  Consumers doing this should declare their dictionary as<code>RootedDictionary&lt;DictionaryName&gt;</code>.  When this is done, passing in a null scope object and even a null <code>JSContext*</code> is allowed if the passed-in <code>JS::Value</code> is <code>JS::NullValue()</code>.  Likewise, a dictionary struct can be converted to a <code>JS::Value</code> in C++ by calling <code>ToJSValue</code>with the dictionary as the second argument.  If <code>Init()</code> or <code>ToJSValue()</code> return false, they will generally set a pending exception on the JSContext; reporting those is the responsibility of the caller.</p>
+
+<p>For example, this WebIDL:</p>
+
+<pre class="language-html">dictionary Dict { long foo = 5; DOMString bar; }; interface Test { void initSomething(optional Dict arg); };</pre>
+
+<p>will correspond to this C++ function declaration:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">void InitSomething(const Dict&amp; arg);</code></pre>
+
+<p>and the <code>Dict</code> struct will look like this:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">struct Dict {
+ bool Init(JSContext* aCx, JS::Handle&lt;JS::Value&gt; aVal, const char* aSourceDescription = "value");
+
+ Optional&lt;nsString&gt; mBar;
+ int32_t mFoo;
+}</code></pre>
+
+<p>Note that the dictionary members are sorted in the struct in alphabetical order.</p>
+
+<h4 id="Enumeration_types">Enumeration types</h4>
+
+<p>WebIDL enumeration types are represented as C++ enums.  The values of the C++ enum are named by taking the strings in the WebIDL enumeration, replacing all non-alphanumerics with underscores, and uppercasing the first letter, with a special case for the empty string, which becomes the value <code>_empty</code>.</p>
+
+<p>For a WebIDL enum named <code>MyEnum</code>, the C++ enum is named <code>MyEnum</code> and placed in the<code>mozilla::dom</code> namespace, while the values are placed in the <code>mozilla::dom::MyEnum</code>namespace.  There is also a <code>mozilla::dom::MyEnumValues::strings</code> which is an array of<code>mozilla::dom::EnumEntry</code> structs that gives access to the string representations of the values.</p>
+
+<p>For example, this WebIDL:</p>
+
+<pre class="language-html">enum MyEnum { "something", "something-else", "", "another" };</pre>
+
+<p>would lead to this C++ enum declaration:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">MOZ_BEGIN_ENUM_CLASS(MyEnum, uint32_t)
+ Something,
+ Something_else,
+ _empty,
+ Another
+MOZ_END_ENUM_CLASS(MyEnum)
+
+namespace MyEnumValues {
+extern const EnumEntry strings[10];
+} // namespace MyEnumValues</code></pre>
+
+<h4 id="Callback_function_types">Callback function types</h4>
+
+<p>Callback functions are represented as an object, inheriting from<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#CallbackFunction"><code>mozilla::dom::CallbackFunction</code></a>, whose name, in the <code>mozilla::dom</code> namespace, matches the name of the callback function in the WebIDL.  If the type is nullable, a pointer is passed in; otherwise a reference is passed in.</p>
+
+<p>The object exposes two <code>Call</code> methods, which both invoke the underlying JS callable.  The first<code>Call</code> method has the same signature as a throwing method declared just like the callback function, with an additional trailing "<code>mozilla::dom::CallbackObject::ExceptionHandling</code> <code>aExceptionHandling</code>" argument, defaulting to <code>eReportExceptions</code>, and calling it will invoke the callable with<code>undefined</code> as the <code>this</code> value.  The second <code>Call</code> method allows passing in an explicit <code>this</code>value as the first argument.  This second call method is a template on the type of the first argument, so the <code>this</code> value can be passed in in whatever form is most convenient, as long as it's either a type that can be wrapped by XPConnect or a WebIDL interface type.</p>
+
+<p>If <code>aReportExceptions</code> is set to <code>eReportExceptions</code>, the <code>Call</code> methods will report JS exceptions before returning.  If <code>aReportExceptions</code> is set to <code>eRethrowExceptions</code>, JS exceptions will be stashed in the <code>ErrorResult</code> and will be reported when the stack unwinds to wherever the <code>ErrorResult</code> was set up.</p>
+
+<p>For example, this WebIDL:</p>
+
+<pre class="language-html">callback MyCallback = long (MyInterface arg1, boolean arg2); interface MyInterface { attribute MyCallback foo; attribute MyCallback? bar; };</pre>
+
+<p>will lead to this C++ class declaration, in the <code>mozilla::dom</code> namespace:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">class MyCallback : public CallbackFunction
+{
+public:
+ int32_t
+ Call(MyInterface&amp; arg1, bool arg2, ErrorResult&amp; rv,
+ ExceptionHandling aExceptionHandling = eReportExceptions);
+
+ template&lt;typename T&gt;
+ int32_t
+ Call(const T&amp; thisObj, MyInterface&amp; arg1, bool arg2, ErrorResult&amp; rv,
+ ExceptionHandling aExceptionHandling = eReportExceptions);
+};</code></pre>
+
+<p>and these C++ function declarations in the <code>MyInterface</code> class:</p>
+
+<pre class="language-html">already_AddRefed&lt;MyCallback&gt; GetFoo(); void SetFoo(MyCallback&amp;); already_AddRefed&lt;MyCallback&gt; GetBar(); void SetBar(MyCallback*);</pre>
+
+<h4 id="Sequences">Sequences</h4>
+
+<p>Sequence arguments are represented by <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Sequence"><code>const Sequence&lt;T&gt;&amp;</code></a>, where <code>T</code> depends on the type of elements in the WebIDL sequence.</p>
+
+<p>Sequence return values are represented by an <code>nsTArray&lt;T&gt;</code> out param appended to the argument list, where <code>T</code> is the return type for the elements of the WebIDL sequence.  This comes after all IDL arguments, but before the <code>ErrorResult&amp;</code>, if any, for the method.</p>
+
+<h4 id="Arrays">Arrays</h4>
+
+<p>IDL array objects are not supported yet.  The spec on these is likely to change drastically anyway.</p>
+
+<h4 id="Union_types">Union types</h4>
+
+<p>Union types are reflected as a struct in the <code>mozilla::dom</code> namespace.  There are two kinds of union structs: one kind does not keep its members alive (is "non-owning"), and the other does (is "owning").  Const references to non-owning unions are used for plain arguments.  Owning unions are used in dictionaries, sequences, and for variadic arguments.  Union return values become a non-const owning union out param.  The name of the struct is the concatenation of the names of the types in the union, with "Or" inserted between them, and for an owning struct "Owning" prepended.  So for example, this IDL:</p>
+
+<pre class="language-html">void passUnion((object or long) arg); (object or long) receiveUnion(); void passSequenceOfUnions(sequence&lt;(object or long)&gt; arg); void passOtherUnion((HTMLDivElement or ArrayBuffer or EventInit) arg);</pre>
+
+<p>would correspond to these C++ function declarations:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">void PassUnion(const ObjectOrLong&amp; aArg);
+void ReceiveUnion(OwningObjectObjectOrLong&amp; aArg);
+void PassSequenceOfUnions(const Sequence&lt;OwningObjectOrLong&gt;&amp; aArg);
+void PassOtherUnion(const HTMLDivElementOrArrayBufferOrEventInit&amp; aArg);</code></pre>
+
+<p>Union structs expose accessors to test whether they're of a given type and to get hold of the data of that type.  They also expose setters that set the union as being of a particular type and return a reference to the union's internal storage where that type could be stored.  The one exception is the <code>object</code> type, which uses a somewhat different form of setter where the<code>JSObject*</code> is passed in directly. For example, <code>ObjectOrLong</code> would have the following methods:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">bool IsObject() const;
+JSObject* GetAsObject() const;
+void SetToObject(JSContext*, JSObject*);
+bool IsLong() const;
+int32_t GetAsLong() const;
+int32_t&amp; SetAsLong()</code></pre>
+
+<p>Owning unions used on the stack should be declared as a <code>RootedUnion&lt;UnionType&gt;</code>.  For example, <code>RootedUnion&lt;OwningObjectOrLong&gt;</code>.</p>
+
+<h4 id="Date"><code>Date</code></h4>
+
+<p>WebIDL <code>Date</code> types are represented by a <code>mozilla::dom::Date</code> struct.</p>
+
+<h3 id="Stringifiers">Stringifiers</h3>
+
+<p>Named stringifiers operations in WebIDL will just invoke the corresponding C++ method.</p>
+
+<p>Anonymous stringifiers in WebIDL will invoke the C++ method called <code>Stringify</code>.  So for example given this IDL:</p>
+
+<pre class="language-html">interface FirstInterface { stringifier; }; interface SecondInterface { stringifier DOMString getStringRepresentation(); };</pre>
+
+<p>the corresponding C++ would be:</p>
+
+<pre class="language-html">class FirstInterface { public: void Stringify(nsAString&amp; aResult); }; class SecondInterface { public: void GetStringRepresentation(nsAString&amp; aResult); };</pre>
+
+<h3 id="Legacy_Callers">Legacy Callers</h3>
+
+<p>Only anonymous legacy callers are supported, and will invoke the C++ method called<code>LegacyCall</code>.  This will be passed the JS "this" value as the first argument, then the arguments to the actual operation.  A <code>JSContext</code> will be passed if any of the operation arguments need it.  So for example given this IDL:</p>
+
+<pre class="language-html">interface InterfaceWithCall { legacycaller long (float arg); };</pre>
+
+<p>the corresponding C++ would be:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">class InterfaceWithCall {
+public:
+ int32_t LegacyCall(JS::Handle&lt;JS::Value&gt; aThisVal, float aArgument);
+};</code></pre>
+
+<h3 id="Named_getters">Named getters</h3>
+
+<p>If the interface has a named getter, the binding will expect several methods on the C++ implementation:</p>
+
+<ul>
+ <li>A <code>NamedGetter</code> method.  This takes a property name and returns whatever type the named getter is declared to return.  It also has a boolean out param for whether a property with that name should exist at all.</li>
+ <li> A <code>NameIsEnumerable</code> method.  This takes a  that takes a property name and returns a boolean that indicates whether the property is enumerable.</li>
+ <li>A <code>GetSupportedNames</code> method.  This takes an unsigned integer which corresponds to the flags passed to the <code>iterate</code> proxy trap and returns a list of property names.  For implementations of this method, the important flags is <code>JSITER_HIDDEN</code>.  If that flag is set, the call needs to return all supported property names.  If it's not set, the call needs to return only the enumerable ones.</li>
+</ul>
+
+<p>The <code>NameIsEnumerable</code> and <code>GetSupportedNames</code> methods need to agree on which names are and are not enumerable.  The <code>NamedGetter</code> and <code>GetSupportedNames</code> methods need to agree on which names are supported.</p>
+
+<p>So for example, given this IDL:</p>
+
+<pre class="language-html">interface InterfaceWithNamedGetter { getter long(DOMString arg); };</pre>
+
+<p>the corresponding C++ would be:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">class InterfaceWithNamedGetter
+{
+public:
+ int32_t NamedGetter(const nsAString&amp; aName, bool&amp; aFound);
+ bool NameIsEnumerable(const nsAString&amp; aName);
+ void GetSupportedNames(unsigned aFlags, nsTArray&lt;nsString&gt;&amp; aNames);
+};</code></pre>
+
+<h2 id="Throwing_exceptions_from_WebIDL_methods_getters_and_setters">Throwing exceptions from WebIDL methods, getters, and setters</h2>
+
+<p>WebIDL methods, getters, and setters that are <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Throws">explicitly marked as allowed to throw</a> have an<code>ErrorResult&amp;</code> argument as their last argument.  To throw an exception, simply call <code>Throw()</code>on the <code>ErrorResult&amp;</code> and return from your C++ back into the binding code.</p>
+
+<p>In cases when the specification calls for throwing a <code>TypeError</code>, you should use<code>ErrorResult::ThrowTypeError()</code> instead of calling <code>Throw()</code>.</p>
+
+<h2 class="note" id="Custom_extended_attributes">Custom extended attributes</h2>
+
+<p>Our WebIDL parser and code generator recognize several extended attributes that are not present in the WebIDL spec.</p>
+
+<h3 id="ChromeOnly"><code>[ChromeOnly]</code></h3>
+
+<p>This extended attribute can be specified on any method, attribute, or constant on an interface or on an interface as a whole.</p>
+
+<p>Interface members flagged as <code>[ChromeOnly]</code> are only exposed in chrome Windows (and in particular, are not exposed to webpages).  From the point of view of web content, it's as if the interface member were not there at all.  These members <em>are</em> exposed to chrome script working with a content object via Xrays.</p>
+
+<p>If specified on an interface as a whole, this functions like <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#"><code>[Func]</code></a> except that the binding code will automatically check whether the caller script has the system principal (is chrome or a worker started from a chrome page) instead of calling into the C++ implementation to determine whether to expose the interface object on the global.   This means that accessing a  content global via Xrays will show <code>[ChromeOnly]</code> interface objects on it.</p>
+
+<p>This extended attibute can be specified together with <code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#AvailableIn">AvailableIn</a>]</code>, <code><code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#CheckPermissions">CheckPermissions</a>]</code></code>,<code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Func">Func</a>]</code>,  and <code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Pref">Pref</a>]</code>.  If more than one of these is specified, all conditions will need to test true for the interface or interface member to be exposed.</p>
+
+<h3 id="Prefprefname"><code>[Pref=prefname]</code></h3>
+
+<p>This extended attribute can be specified on any method, attribute, or constant on an interface or on an interface as a whole. It takes a value, which must be the name of a boolean preference.</p>
+
+<p>If specified on an interface member, the interface member involved is only exposed if the preference is set to <code>true</code>. An example of how this can be used:</p>
+
+<pre class="language-html">interface MyInterface { attribute long alwaysHere; [Pref="my.pref.name"] attribute long onlyHereIfEnabled; };</pre>
+
+<p>If specifed on an interface as a whole, this functions like <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#"><code>[Func]</code></a> except that the binding will check the value of the preference directly without calling into the C++ implementation of the interface at all. This is useful when the enable check is simple and it's desirable to keep the prefname with the WebIDL declaration. The implementation can call<code>MyInterfaceBinding::PrefEnabled()</code> to check whether it is enabled or not.  An example of how this can be used:</p>
+
+<pre class="language-html">[Pref="my.pref.name"] interface MyConditionalInterface { };</pre>
+
+<p>This extended attibute can be specified together with <code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#AvailableIn">AvailableIn</a>]</code>, <code><code><code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#CheckPermissions">CheckPermissions</a>]</code></code></code>,<code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#ChromeOnly">ChromeOnly</a>]</code>, and<code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Func">Func</a>]</code>.  If more than one of these is specified, all conditions will need to test true for the interface or interface member to be exposed.</p>
+
+<h3 id="Funcfuncname"><code>[Func="funcname"]</code></h3>
+
+<p>This extended attribute can be specified on any method, attribute, or constant on an interface or on an interface as a whole.  It takes a value, which must be the name of a static function. </p>
+
+<p>If specified on an interface member, the interface member involved is only exposed if the specified function returns <code>true</code>.   An example of how this can be used:</p>
+
+<pre class="language-html">interface MyInterface { attribute long alwaysHere; [Func="MyClass::StuffEnabled"] attribute long onlyHereIfEnabled; };</pre>
+
+<p>The function is invoked with two arguments: the <code>JSContext</code> that the operation is happening on and the <code>JSObject</code> for the global of the object that the property will be defined on if the function returns true.  In particular, in the Xray case the <code>JSContext</code> is in the caller compartment (typically chrome) but the <code>JSObject</code> is in the target compartment (typically content).  This allows the method implementation to select which compartment it cares about in its checks.</p>
+
+<p>The above IDL would also require the following C++:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">class MyClass {
+ static bool StuffEnabled(JSContext* cx, JSObject* obj);
+};</code></pre>
+
+<p>If specified on an interface as a whole, then lookups for the interface object for this interface on a DOM Window will only find it if the specified function returns true.  For objects that can only be created via a constructor, this allows disabling the functionality altogether and making it look like the feature is not implemented at all.</p>
+
+<p>An example of how <code>[Func]</code> can be used:</p>
+
+<pre class="language-html">[Func="MyClass::MyConditionalInterfaceEnabled"] interface MyConditionalInterface { };</pre>
+
+<p>In this case, the C++ function is passed a <code>JS::Handle&lt;JSObject*&gt;</code>.  So the C++ in this case would look like this:</p>
+
+<pre class="brush: cpp language-cpp"><code class="language-cpp">class MyClass {
+ static bool MyConditionalInterfaceEnabled(JSContext* cx, JS::Handle&lt;JSObject*&gt; obj);
+};</code></pre>
+
+<p>Just like in the interface member case, the <code>JSContext</code> is in the caller compartment but the<code>JSObject</code> is the actual object the property would be defined on.  In the Xray case that mean obj is in the target compartment (typically content) and <code>cx</code> is typically chrome.</p>
+
+<p>This extended attibute can be specified together with <code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#AvailableIn">AvailableIn</a>]</code>, <code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#CheckPermissions">CheckPermissions</a>]</code>,<code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#ChromeOnly">ChromeOnly</a>]</code>, and <code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Pref">Pref</a>]</code>.  If more than one of these is specified, all conditions will need to test true for the interface or interface member to be exposed.</p>
+
+<h3 id="AvailableInWhere"><code>[AvailableIn=Where]</code></h3>
+
+<p>This extended attribute can be specified on any method, attribute, or constant on an interface or on an interface as a whole. It takes a value, which must be either <code>PrivilegedApps</code> or<code>CertifiedApps</code>.  This will make the interface or interface member only visible in privileged and certified apps respectively on Firefox OS.</p>
+
+<p>This extended attibute can be specified together with <code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#ChromeOnly">ChromeOnly</a>]</code>, <code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#CheckPermissions">CheckPermissions</a>]</code>,<code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Func">Func</a>]</code>, and  <code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Pref">Pref</a>]</code>.  If more than one of these is specified, all conditions will need to test true for the interface or interface member to be exposed.</p>
+
+<h3 id="CheckPermissionslist_of_permissions"><code>[CheckPermissions="list of permissions"]</code></h3>
+
+<p>This extended attribute can be specified on any method, attribute, or constant on an interface or on an interface as a whole. It takes a whitespace-separated list of permissions to be checked before making the interface or interface member visible to a page or app. When multiple permission names are specified, <strong>at least one</strong> of them will need to be set to nsIPermissionManager::ALLOW_ACTION for the interface or interface member to be exposed.</p>
+
+<p>This extended attribute can be specified together with <code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#AvailableIn">AvailableIn</a>]</code>, <code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#ChromeOnly">ChromeOnly</a>]</code>,<code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Func">Func</a>]</code> and <code>[<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Pref">Pref</a>]. </code>If more than one of these is specified, all conditions will need to test true for the interface or interface member to be exposed.</p>
+
+<h3 id="Throws_GetterThrows_SetterThrows"><code>[Throws]</code>, <code>[GetterThrows]</code>, <code>[SetterThrows]</code></h3>
+
+<p>Used to flag methods or attributes as allowing the C++ callee to throw.  This causes the binding generator, and in many cases the JIT, to generate extra code to handle possible exceptions.  Possibly-throwing methods and attributes get an <code>ErrorResult&amp;</code> argument.</p>
+
+<p><code>[Throws]</code> applies to both methods and attributes; for attributes it means both the getter and the setter can throw.  <code>[GetterThrows]</code> applies only to attributes.  <code>[SetterThrows]</code> applies only to non-readonly attributes.</p>
+
+<p>For bindings that involve workers, the above can all be specified with <code>MainThread</code> or <code>Workers</code>as a value.  When doing this, if <code>[Throws]</code> is specified on an attribute, no matter what its value, then <code>[GetterThrows]</code> and <code>[SetterThrows]</code> will be ignored.  So to have an attribute which can throw both when getting and setting on main thread but can only throw from the setter in workers, use <code>[SetterThrows, GetterThrows=MainThread]</code>.</p>
+
+<p>For interfaces flagged with <code>[JSImplementation]</code>, all methods and properties are assumed to be able to throw and do not need to be flagged as throwing.</p>
+
+<h3 id="Pure"><code>[Pure]</code></h3>
+
+<p>Used to flag attributes whose getter has no side-effects or methods that have no side-effects in the DOM.  Attributes/methods flagged in this way promise that they will keep returning the same value as long as no DOM setters or non-<code>[Pure]</code> DOM methods executed.  This allows the JIT to perform loop-hoisting and common subexpression elimination on the return values of these attributes/methods in some cases.  <code>[Pure]</code> things are allowed to throw exceptions as long as they do so deterministically.  This extended attribute can be used on writable attributes as long as the getter obeys the above rules.</p>
+
+<h3 id="Constant"><code>[Constant]</code></h3>
+
+<p>Used to flag readonly attributes that could have been annotated with <code>[Pure]</code> and also always return the same value.  This allows the JIT to do even more aggressive optimization of getters for such attributes.  This should only be used when it's absolutely guaranteed that the return value of the attribute getter will always be the same from the JS engine's point of view.  This extended attribute implies <code>[Pure]</code> as far as the JIT is concerned.</p>
+
+<h3 id="NeedNewResolve"><code>[NeedNewResolve]</code></h3>
+
+<p>Used to flag interfaces which have a custom resolve hook.  This annotation will cause the<code>DoNewResolve</code> method to be called on the underlying C++ class when a property lookup happens on the object.  The signature of this method is: <code>bool DoNewResolve(JSContext*, JS::Handle&lt;JSObject*&gt;, JS::Handle&lt;jsid&gt;, JS::MutableHandle&lt;JS::Value&gt;)</code>.  Here the passed-in object is the object the property lookup is happening on (which may be an Xray for the actual DOM object) and the jsid is the property name.  The value that the property should have is returned in the <code>MutableHandle&lt;Value&gt;</code>, with <code>UndefinedValue()</code> indicating that the property does not exist.</p>
+
+<p>If this extended attribute is used, then the underlying C++ class must also implement a method called <code>GetOwnPropertyNames</code> with the signature <code>void GetOwnPropertyNames(JSContext* aCx, nsTArray&lt;nsString&gt;&amp; aNames, ErrorResult&amp; aRv)</code>.  This method wil be called by the JS engine's enumerate hook and must provide a superset of all the property names that <code>DoNewResolve</code> might resolve.  Providing names that <code>DoNewResolve</code> won't actually resolve is OK.</p>
+
+<h3 id="HeaderFilepathtoheaderfile.h"><code>[HeaderFile="path/to/headerfile.h"]</code></h3>
+
+<p>Indicates where the implementation can be found. Similar to the headerFile annotation in Bindings.conf.</p>
+
+<h3 id="JSImplementationmozilla.orgsome-contractid1"><code>[JSImplementation="@mozilla.org/some-contractid;1"]</code></h3>
+
+<p>Used on an interface to provide the contractid of the <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Implementing_WebIDL_using_Javascript">JavaScript component implementing the interface</a>.</p>
+
+<h3 id="NavigatorPropertypropName"><code>[NavigatorProperty="propName"]</code></h3>
+
+<p>Setting this extended attribute to <code>propName</code> on an interface causes<code>window.navigator.propName</code> to be an instance of the interface.</p>
+
+<h3 id="StoreInSlot"><code>[StoreInSlot]</code></h3>
+
+<p>Used to flag attributes that can be gotten very quickly from the JS object by the JIT.  Such attributes will have their getter called immediately when the JS wrapper for the DOM object is created, and the returned value will be stored directly on the JS object.  Later gets of the attribute will not call the C++ getter and instead use the cached value.  If the value returned by the attribute needs to change, the C++ code should call the <code>ClearCachedFooValue</code> method in the namespace of the relevant binding, where <code>foo</code> is the name of the attribute.  This will immediately call the C++ getter and cache the value it returns, so it needs a <code>JSContext</code> to work on.  This extended attribute can only be used in on attributes whose getters are <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Pure"><code>[Pure]</code></a> or<a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Constant"><code>[Constant]</code></a> and which are not <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Throws"><code>[Throws]</code></a> or <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Throws"><code>[GetterThrows]</code></a>.</p>
+
+<p>So for example, given this IDL:</p>
+
+<pre class="language-html">interface MyInterface { [Pure, StoreInSlot] attribute long myAttribute; };</pre>
+
+<p>the C++ implementation of MyInterface would clear the cached value by calling<code>mozilla::dom::MyInterfaceBinding::ClearCachedMyAttributeValue(cx, this)</code>.</p>
+
+<p>If the attribute is not readonly, setting it will automatically clear the cached value and reget it again before the setter returns.</p>
+
+<h3 id="Cached"><code>[Cached]</code></h3>
+
+<p>Used to flag attributes that, when their getter is called, will cache the returned value on the JS object.  This can be used to implement attributes whose value is a sequence or dictionary (which would otherwise end up returning a new object each time and hence not be allowed in WebIDL).</p>
+
+<p>Unlike <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#StoreInSlot"><code>[StoreInSlot]</code></a> this does <em>not</em> cause the getter to be eagerly called at JS wrapper creation time; the caching is lazy.  <code>[Cached]</code> attributes must be <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Pure"><code>[Pure]</code></a> or <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#Constant"><code>[Constant]</code></a>, because otherwise not calling the C++ getter would be observable, but are allowed to have throwing getters.  Their cached value can be cleared by calling the ClearCachedFooValue method in the namespace of the relevant binding, where foo is the name of the attribute.  Unlike <code>[StoreInSlot]</code> attributes, doing so will not immediately invoke the getter, so does not need a <code>JSContext</code>.</p>
+
+<p>So for example, given this IDL:</p>
+
+<pre class="language-html">interface MyInterface { [Pure, StoreInSlot] attribute long myAttribute; };</pre>
+
+<p>the C++ implementation of MyInterface would clear the cached value by calling<code>mozilla::dom::MyInterfaceBinding::ClearCachedMyAttributeValue(this)</code>.</p>
+
+<p>If the attribute is not readonly, setting it will automatically clear the cached value.</p>
+
+<h3 id="Frozen"><code>[Frozen]</code></h3>
+
+<p>Used to flag attributes that, when their getter is called, will call <a href="/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze"><code>Object.freeze</code></a> on the return value before returning it.  This extended attribute is only allowed on attributes that return sequences, and corresponds to returning a frozen <code>Array</code>.</p>
+
+<h3 id="ChromeConstructor"><code>[ChromeConstructor]</code></h3>
+
+<p><code>[ChromeConstructor]</code> has the same behaviour as <code>[Constructor]</code>, but the constructor will throw if it's not called from chrome code. The usage rules and restrictions as those for<code>[Constructor]</code> apply. Note that <code>[Constructor]</code> and <code>[ChromeConstructor]</code> are mutually exclusive, while there can be multiple of either, there can never be both on the same interface.</p>
+
+<h2 class="note" id="Helper_objects">Helper objects</h2>
+
+<p>The C++ side of the bindings uses a number of helper objects.</p>
+
+<h3 id="Nullable&lt;T>"><code>Nullable&lt;T&gt;</code></h3>
+
+<p><code>Nullable&lt;&gt;</code> is a struct declared in <a class="external external-icon" href="http://mxr.mozilla.org/mozilla-central/source/dom/bindings/Nullable.h"><code>Nullable.h</code></a> and exported to<code>mozilla/dom/Nullable.h</code> that is used to represent nullable values of types that don't have a natural way to represent null.</p>
+
+<p><code>Nullable&lt;T&gt;</code> has an <code>IsNull()</code> getter that returns whether null is represented and a <code>Value()</code>getter that returns a <code>const T&amp;</code> and can be used to get the value when it's not null.</p>
+
+<p><code>Nullable&lt;T&gt;</code> has a <code>SetNull()</code> setter that sets it as representing null and two setters that can be used to set it to a value: <code>"void SetValue(T)"</code> (for setting it to a given value) and <code>"T&amp; SetValue()"</code> for directly modifying the underlying <code>T&amp;</code>.</p>
+
+<h3 id="Optional&lt;T>"><code>Optional&lt;T&gt;</code></h3>
+
+<p><code>Optional&lt;&gt;</code> is a struct declared in <a class="external external-icon" href="http://mxr.mozilla.org/mozilla-central/source/dom/bindings/BindingDeclarations.h"><code>BindingDeclarations.h</code></a> and exported to<code>mozilla/dom/BindingDeclarations.h</code> that is used to represent optional arguments and dictionary members, but only those that have no default value.</p>
+
+<p><code>Optional&lt;T&gt;</code> has a <code>WasPassed()</code> getter that returns true if a value is available.  In that case, the <code>Value()</code> getter can be used to get a <code>const T&amp;</code> for the value.</p>
+
+<h3 id="NonNull&lt;T>"><code>NonNull&lt;T&gt;</code></h3>
+
+<p><code>NonNull&lt;T&gt;</code> is a struct declared in <a class="external external-icon" href="http://mxr.mozilla.org/mozilla-central/source/dom/bindings/BindingUtils.h"><code>BindingUtils.h</code></a> and exported to<code>mozilla/dom/BindingUtils.h</code> that is used to represent non-null C++ objects.  It has a conversion operator that produces <code>T&amp;</code>.</p>
+
+<h3 id="OwningNonNull&lt;T>"><code>OwningNonNull&lt;T&gt;</code></h3>
+
+<p><code>OwningNonNull&lt;T&gt;</code> is a struct declared in <a class="external external-icon" href="http://mxr.mozilla.org/mozilla-central/source/dom/bindings/BindingUtils.h"><code>BindingUtils.h</code></a> and exported to<code>mozilla/dom/BindingUtils.h</code> that is used to represent non-null C++ objects and holds a strong reference to them.  It has a conversion operator that produces <code>T&amp;</code>.</p>
+
+<h3 id="Typed_arrays_arraybuffers_array_buffer_views">Typed arrays, arraybuffers, array buffer views</h3>
+
+<p><code><a class="external external-icon" href="http://mxr.mozilla.org/mozilla-central/source/dom/bindings/TypedArray.h">TypedArray.h</a></code> is exported to <code>mozilla/dom/TypedArray.h</code> and exposes structs that correspond to the various typed array types, as well as <code>ArrayBuffer</code> and <code>ArrayBufferView</code>, all in the <code>mozilla::dom</code> namespace.  Each struct has an <code>Data()</code> method that returns a pointer to the relevant type (<code>uint8_t</code> for <code>ArrayBuffer</code> and <code>ArrayBufferView</code>) and a <code>Length()</code>method that returns the length in units of <code>*Data()</code>.  So for example, <code>Int32Array</code> has a<code>Data()</code> returning i<code>nt32_t</code><code>*</code> and a <code>Length()</code> that returns the number of 32-bit ints in the array..</p>
+
+<h3 id="Sequence&lt;T>"><code>Sequence&lt;T&gt;</code></h3>
+
+<p><code>Sequence&lt;&gt;</code> is a type declared in <a class="external external-icon" href="http://mxr.mozilla.org/mozilla-central/source/dom/bindings/BindingDeclarations.h"><code>BindingDeclarations.h</code></a> and exported to<code>mozilla/dom/BindingDeclarations.h</code> that is used to represent sequence arguments.  It's some kind of typed array, but which exact kind is opaque to consumers.  This allows the binding code to change the exact definition (e.g. to use auto arrays of different sizes and so forth) without having to update all the callees.</p>
+
+<h3 id="CallbackFunction"><code>CallbackFunction</code></h3>
+
+<p><code>CallbackFunction</code> is a type declared in <a href="http://mxr.mozilla.org/mozilla-central/source/dom/bindings/CallbackFunction.h">CallbackFunction.h</a> and exported to<code>mozilla/dom/CallbackFunction.h</code> that is used as a common base class for all the generated callback function representations.  This class inherits from <code>nsISupports</code>, and consumers must make sure to cycle-collect it, since it keeps JS objects alive.</p>
+
+<h3 id="CallbackInterface"><code>CallbackInterface</code></h3>
+
+<p><code>CallbackInterface</code> is a type declared in <a href="http://mxr.mozilla.org/mozilla-central/source/dom/bindings/CallbackInterface.h">CallbackInterface.h</a> and exported to<code>mozilla/dom/CallbackInterface.h</code> that is used as a common base class for all the generated callback interface representations.  This class inherits from <code>nsISupports</code>, and consumers must make sure to cycle-collect it, since it keeps JS objects alive.</p>
+
+<h3 id="DOMString_2"><code>DOMString</code></h3>
+
+<p><code>DOMString</code> is a class declared in <a href="http://mxr.mozilla.org/mozilla-central/source/dom/bindings/BindingDeclarations.h">BindingDeclarations.h</a> and exported to<code>mozilla/dom/BindingDeclarations.h</code> that is used for WebIDL <code>DOMString</code> return values.  It has a conversion operator to <code>nsString&amp;</code> so that it can be passed to methods that take that type or <code>nsAString&amp;</code>, but callees that care about performance, have an <code>nsStringBuffer</code>available, and promise to hold on to the <code>nsStringBuffer</code> at least until the binding code comes off the stack can also take a <code>DOMString</code> directly for their string return value and call its<code>SetStringBuffer</code> method with the <code>nsStringBuffer</code> and its length.  This allows the binding code to avoid extra reference-counting of the string buffer in many cases, and allows it to take a faster codepath even if it does end up having to addref the <code>nsStringBuffer</code>.</p>
+
+<h3 id="GlobalObject"><code>GlobalObject</code></h3>
+
+<p><code>GlobalObject</code> is a class declared in <a href="http://mxr.mozilla.org/mozilla-central/source/dom/bindings/BindingDeclarations.h">BindingDeclarations.h</a> and exported to<code>mozilla/dom/BindingDeclarations.h</code> that is used to represent the global object for static attributes and operations (including constructors).  It has a <code>Get()</code> method that returns the<code>JSObject*</code>  for the global and a <code>GetAsSupports()</code> method that returns an <code>nsISupports*</code>for the global on the main thread, if such is available. It also has a <code>GetContext()</code> method that returns the <code>JSContext*</code> the call is happening on.  A caveat: the compartment of the<code>JSContext</code> may not match the compartment of the global!</p>
+
+<h3 id="Date_2"><code>Date</code></h3>
+
+<p><code>Date</code> is a class declared in <a href="http://mxr.mozilla.org/mozilla-central/source/dom/bindings/BindingDeclarations.h">BindingDeclarations.h</a> and exported to<code>mozilla/dom/BindingDeclarations.h</code> that is used to represent WebIDL Dates.  It has a<code>TimeStamp()</code> method returning a double which represents a number of milliseconds since the epoch, as well as <code>SetTimeStamp()</code> methods that can be used to initialize it with a double timestamp or a JS <code>Date</code> object.  It also has a <code>ToDateObject()</code> method that can be used to create a new JS <code>Date</code>.</p>
+
+<h3 id="ErrorResult"><code>ErrorResult</code></h3>
+
+<p><code>ErrorResult</code> is a class declared in <a href="http://mxr.mozilla.org/mozilla-central/source/dom/bindings/ErrorResult.h">ErrorResult.h</a> and exported to <code>mozilla/ErrorResult.h</code>that is used to represent exceptions in WebIDL bindings.  This has the following methods:</p>
+
+<ul>
+ <li><code>Throw</code>: allows throwing an <code>nsresult</code>.  The <code>nsresult</code> must be a failure code.</li>
+ <li><code>ThrowTypeError</code>: allows throwing a <code>TypeError</code> with the given error message.  The list of allowed <code>TypeError</code>s and corresponding messages is in<a href="http://mxr.mozilla.org/mozilla-central/source/dom/bindings/Errors.msg"><code>dom/bindings/Errors.msg</code></a>.</li>
+ <li><code>ThrowJSException</code>: allows throwing a preexisting JS exception value. However, the<code>MightThrowJSException()</code> method must be called before any such exceptions are thrown (even if no exception is thrown).</li>
+ <li><code>Failed</code>: checks whether an exception has been thrown on this <code>ErrorResult</code>.</li>
+ <li><code>ErrorCode</code>: returns a failure <code>nsresult</code> representing (perhaps incompletely) the state of this <code>ErrorResult</code>.</li>
+ <li><code>operator=</code>: takes an <code>nsresult</code> and acts like <code>Throw</code> if the result is an error code, and like a no-op otherwise (unless an exception has already been thrown, in which case it asserts).  This should only be used for legacy code that has nsresult everywhere; we would like to get rid of this operator at some point.</li>
+</ul>
+
+<h2 id="Bindings.conf_details"><code>Bindings.conf</code> details</h2>
+
+<p>XXXbz write me.  In particular, need to describe at least use of <code>concrete</code>, <code>prefable</code>, and<code>addExternalInterface</code></p>
+
+<h3 id="How_to_get_a_JSContext_passed_to_a_given_method">How to get a JSContext passed to a given method</h3>
+
+<p>In some rare cases you may need a <code>JSContext*</code> argument to be passed to a C++ method that wouldn't otherwise get such an argument. To see how to achieve this, search for<code>implicitJSContext</code> in <a href="/en-US/docs/Mozilla/WebIDL_bindings#Bindings.conf">dom/bindings/Bindings.conf</a>.</p>
+
+<h2 id="Implementing_WebIDL_using_Javascript">Implementing WebIDL using Javascript</h2>
+
+<p>There is support for implementing WebIDL interfaces in JavaScript.  When this is done, there are actually two objects created: the implementation object (running as a chrome-privileged script) and the content-exposed object (which is what the web page sees).  This allows the implementation object to have various APIs that the content-exposed object does not.  It also means that consumers have to be careful about which object they are creating.</p>
+
+<h3 id="Creating_JS-implemented_WebIDL_objects">Creating JS-implemented WebIDL objects</h3>
+
+<p>To create a JS-implemented WebIDL object, one must create both the chrome-side implementation object and the content-side page-exposed object. There are three ways to do this.</p>
+
+<h4 id="Using_the_WebIDL_constructor">Using the WebIDL constructor</h4>
+
+<p>If the interface has a constructor, a content-side object can be created by getting that constructor from the relevant content window and invoking it. For example:</p>
+
+<pre class="brush: js language-js"><code class="language-js">var contentObject = new contentWin.RTCPeerConnection();</code></pre>
+
+<p>The returned object will be an Xray wrapper for the content-side object. Creating the object this way will automatically create the chrome-side object using its contractID.</p>
+
+<p>This method is limited to the constructor signatures exposed to webpages. Any additional configuration of the object needs to be done via <a href="/zh-CN/docs/Mozilla/WebIDL_bindings$edit#ChromeOnly"><code>[ChromeOnly]</code></a> methods on the interface. </p>
+
+<p>Creating many objects this way can be slow due to the createInstance overhead involved. </p>
+
+<h4 id="Using_a__create_method">Using a <code>_create</code> method  </h4>
+
+<p> A content-side object can be created for a given chrome-side object by invoking the static<code>_create</code> method on the interface. This method takes two arguments: the content window in which to create the object and the chrome-side object to use. For example:</p>
+
+<pre class="brush: js language-js"><code class="language-js">var contentObject = RTCPeerConnection._create(contentWin,
+ new MyPeerConnectionImpl());</code></pre>
+
+<p>However, if you are in a JS component, you may only be able to get to the correct interface object via some window object. In this case, the code would look more like:</p>
+
+<pre class="brush: js language-js"><code class="language-js">var contentObject = contentWin.RTCPeerConnection._create(contentWin,
+ new MyPeerConnectionImpl());</code></pre>
+
+<p>Creating the object this way will not invoke its <code>__init</code> method or <code>init</code> method.</p>
+
+<h4 id="By_returning_a_chrome-side_object_from_a_JS-implemented_WebIDL_method">By returning a chrome-side object from a JS-implemented WebIDL method</h4>
+
+<p>If a JS-implemented WebIDL method is declared as returning a JS-implemented interface, then a non-WebIDL object returned from that method will be treated as the chrome-side part of a JS-implemented WebIdL object and the content-side part will be automatically created.</p>
+
+<p>Creating the object this way will not invoke its <code>__init</code> method or <code>init</code> method.</p>
+
+<h3 id="Implementing_a_WebIDL_object_in_JavaScript">Implementing a WebIDL object in JavaScript</h3>
+
+<p>To implement a WebIDL interface in JavaScript, first add a WebIDL file, in the same way as you would for a C++-implemented interface.  To support implementation in JS, you must add an extended attribute <code>JSImplementation="CONTRACT_ID_STRING"</code> on your interface, where CONTRACT_ID_STRING is the XPCOM component contract ID of the JS implementation.  Here's an example:</p>
+
+<pre class="language-html">[Constructor(optional long firstNumber), JSImplementation="@mozilla.org/my-number;1"] interface MyNumber { attribute long value; readonly attribute long otherValue; void doNothing(); };</pre>
+
+<p>Next, create an XPCOM component that implements this interface.  <a href="/en-US/docs/How_to_Build_an_XPCOM_Component_in_Javascript">Basic directions</a> for how to do this can be found elsewhere on MDN.  Use the same contract ID as you specified in the WebIDL file.  The class ID doesn't matter, except that it should be a newly generated one.  For<code>QueryInterface</code>, you only need to implement <code>nsISupports</code>, not anything corresponding to the WebIDL interface.  The name you use for the XPCOM component should be distinct from the name of the interface, to avoid confusing error messages.</p>
+
+<p>WebIDL attributes are implemented as properties on the JS object or its prototype chain, whereas WebIDL methods are implemented as methods on the object or prototype.  Note that any other instances of the interface that you are passed in as arguments are the full web-facing version of the object, and not the JS implementation, so you currently cannot access any private data.</p>
+
+<p>The WebIDL constructor invocation will first create your object.  If the XPCOM component implements <code>nsIDOMGlobalPropertyInitializer</code>, then the object's <code>init</code> method will be invoked with a single argument: the content window the constructor came from.  This allows the JS implementation to know which content window it's associated with.  The <code>init</code> method should not return anything.  After this, the content-side object will be created. Then, if there are any constructor arguments, the object's <code>__init</code> method will be invoked, with the constructor arguments as its arguments.</p>
+
+<p>If you want an instance of the class to be added to <code>window.navigator</code>, add an extended attribute <code>NavigatorProperty="PropertyName"</code> which will make the instance available as<code>window.navigator.PropertyName</code>.</p>
+
+<h3 id="Checking_for_Permissions_or_Preferences">Checking for Permissions or Preferences</h3>
+
+<p>When implementing an XPIDL interface using Javascript, the <code>init</code> method may check if the caller has the proper permissions, or if the appropriate preference is set. If this check fails, then it will return <code>null</code> to indicate that the object should not be created.  JS-implemented WebIDL does NOT work like that.  In JS-implemented WebIDL, the <code>init</code> method should only return undefined.  If any other value, such as <code>null</code>, is returned, the bindings code will assert or crash.  In other words, it acts like it has a "void" return type.</p>
+
+<p>Instead, preference or permission checking should be implemented by adding an extended attribute to the WebIDL interface. This has the advantage that if the check fails, the constructor or object will not show up at all.</p>
+
+<p>For preference checking, add an extended attribute <code>Pref="myPref.enabled"</code> where<code>myPref.enabled</code> is the preference that should be checked.  <code>SettingsLock</code> is an example of this.</p>
+
+<p>For permissions or other kinds of checking, add an extended attribute<code>Func="MyPermissionChecker"</code> where <code>MyPermissionChecker</code> is a function implemented in C++ that returns true if the interface should be enabled.  This function can do whatever checking is needed.  One example of this is <code>PushManager</code>.</p>
+
+<h3 id="Example">Example</h3>
+
+<p>Here's an example JS implementation of the above interface. The <code>invisibleValue</code> field will not be accessible to web content, but is usable by the doNothing() method.</p>
+
+<pre class="language-html">Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); function MyNumberInner() { this.value = 111; this.invisibleValue = 12345; } MyNumberInner.prototype = { classDescription: "Get my number XPCOM Component", classID: Components.ID("{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}"), // dummy UUID contractID: "@mozilla.org/my-number;1", QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsISupports]), doNothing: function() {}, get otherValue() { return this.invisibleValue - 4; }, __init: function(firstNumber) { if (arguments.length &gt; 0) { this.value = firstNumber; } } } var components = [MyNumberInner]; var NSGetFactory = XPCOMUtils.generateNSGetFactory(components);</pre>
+
+<p>Finally, add a component and a contract and whatever other manifest stuff you need to implement an XPCOM component.</p>
+
+<h3 id="Guarantees_provided_by_bindings">Guarantees provided by bindings</h3>
+
+<p>When implementing a WebIDL interface in JavaScript, certain guarantees will be provided by the binding implementation.  For example, string or numeric arguments will actually be primitive strings or numbers.  Dictionaries will contain only the properties that they are declared to have, and they will have the right types.  Interface arguments will actually be objects implementing that interface.</p>
+
+<p>What the bindings will NOT guarantee is much of anything about <code>object</code> and <code>any</code> arguments.  They will get cross-compartment wrappers that make touching them from chrome code not be an immediate security bug, but otherwise they can have quite surprising behavior if the page is trying to be malicious.  Try to avoid using these types if possible.</p>
+
+<h3 id="Accessing_the_content_object_from_the_implementation">Accessing the content object from the implementation</h3>
+
+<p>If the JS implementation of the WebIDL interface needs to access the content object, it is available as a property called <code>__DOM_IMPL__</code> on the chrome implementation object.  This property only appears after the content-side object has been created. So it is available in<code>__init</code> but not in <code>init</code>.</p>
+
+<h3 id="Determining_the_principal_of_the_caller_that_invoked_the_WebIDL_API">Determining the principal of the caller that invoked the WebIDL API</h3>
+
+<p>This can be done by calling <code>Component.utils.getWebIDLCallerPrincipal()</code>.</p>
+
+<h3 id="Throwing_exceptions_from_JS-implemented_APIs">Throwing exceptions from JS-implemented APIs</h3>
+
+<p>There are two reasons a JS implemented API might throw.  The first reason is that some unforeseen condition occurred and the second is that a specification requires an exception to be thrown.</p>
+
+<p>When throwing for an unforeseen condition, the exception will be reported to the console, and a sanitized NS_ERROR_UNEXPECTED exception will be thrown to the calling content script, with the file/line of the content code that invoked your API.  This will avoid exposing chrome URIs and other implementation details to the content code.</p>
+
+<p>When throwing because a specification requires an exception, you need to communicate to the binding code that this is what you're doing.  Right now this is done by throwing a <code>DOMError</code>from the window your WebIDL object is associated with (the one that was passed to your <code>init</code>method).  The binding code will then rethrow just the message string of that <code>DOMError</code> to the web page, as a plain JS <code>Error</code>.  This does not allow implementing exceptions per spec (e.g. there is no way to explicitly throw a <code>TypeError</code> or other <code>Error</code> subclass), unfortunately; we're still working on that.  Since you know for this case the exception is being thrown because a spec requires it, you know you need to create the <code>DOMError</code>.  An example of how this could work:</p>
+
+<pre class="brush: js language-js"><code class="language-js">if (!isValid(passedInObject)) {
+ throw new this.contentWindow.DOMError("Error", "Object is invalid");
+}</code></pre>
+
+<p>In some cases you may need to perform operations whose exception message you just want to propagate to the content caller.  This can be done like so:</p>
+
+<pre class="brush: js language-js"><code class="language-js">try {
+ someOperationThatCanThrow();
+} catch (e) {
+ throw new this.contentWindow.DOMError(e.name, e.message);
+}</code></pre>
+
+<h3 id="Inheriting_from_interfaces_implemented_in_C">Inheriting from interfaces implemented in C++</h3>
+
+<p>It's possible to have an interface implemented in JavaScript inherit from an interface implemented in C++.  To do so, simply have one interface inherit from the other and the bindings code will auto-generate a C++ object inheriting from the implementation of the parent interface.  The class implementing the parent interface will need a constructor that takes an<code>nsPIDOMWindow*</code> (though it doesn't have to do anything with that argument).</p>
+
+<p>If the class implementing the parent interface is abstract and you want to use a specific concrete class as the implementation to inherit from, you will need to add a <code>defaultImpl</code> annotation to the descriptor for the parent interface in <code>Bindings.conf</code>.  The value of the annotation is the C++ class to use as the parent for JS-implemented descendants; if <code>defaultImpl</code> is not specified, the <code>nativeType</code> will be used.</p>
+
+<p>For example, consider this interface that we wish to implement in JavaScript:</p>
+
+<pre class="language-html">[<code class="language-html">JSImplementation</code></pre>
+
+<p>="some-contract"] interface MyEventTarget : EventTarget { attribute EventHandler onmyevent; void dispatchTheEvent(); // Sends a "myevent" event to this EventTarget }</p>
+
+<p>The implementation would look something like this, ignoring the XPCOM boilerplate:</p>
+
+<pre class="language-html">function MyEventTargetImpl() { } MyEventTargetImpl.prototype = { init: function(contentWindow) { // XXXbz need to document how to get this called on you! this.contentWindow = contentWindow; } get onmyevent() { return this.__DOM_IMPL__.getEventHandler("onmyevent"); } set onmyevent(handler) { this.__DOM_IMPL__.setEventHandler("onmyevent", handler); } dispatchTheEvent: function() { var event = new this.contentWindow.Event("myevent"); this.__DOM_IMPL__.dispatchEvent(event); } };</pre>
+
+<p>The implementation would automatically support the API exposed on <code>EventTarget</code> (so for example <code>addEventListener</code>).  Calling the <code>dispatchTheEvent</code> method would cause dispatch of an event that content script can see via listeners it has added.</p>
+
+<p>Note that in this case the chrome implementation is relying on some <code>[ChromeOnly]</code> methods on EventTarget that were added specifically to make it possible to easily implement event handlers.  Other cases can do similar things as needed</p>
+
+<p>
+ <audio></audio>
+</p>
+
+<p>
+ <audio></audio>
+</p>
diff --git a/files/zh-cn/mozilla/xmlhttprequest_changes_for_gecko_1.8/index.html b/files/zh-cn/mozilla/xmlhttprequest_changes_for_gecko_1.8/index.html
new file mode 100644
index 0000000000..cd7607f36c
--- /dev/null
+++ b/files/zh-cn/mozilla/xmlhttprequest_changes_for_gecko_1.8/index.html
@@ -0,0 +1,19 @@
+---
+title: XMLHttpRequest 在 Gecko1.8 发生的变化
+slug: Mozilla/XMLHttpRequest_changes_for_Gecko_1.8
+tags:
+ - AJAX
+ - Add-ons
+ - Extensions
+ - XMLHttpRequest
+translation_of: Mozilla/XMLHttpRequest_changes_for_Gecko_1.8
+---
+<p>此文档描述了 <a href="/en-US/docs/Mozilla/Gecko">Gecko</a>'s <a href="/en-US/docs/Web/API/XMLHttpRequest">XMLHttpRequest</a> 的实现自1.7版本 (i.e., Firefox 1.0附带的Gecko版本)。发生的一些改变,这些变化仅仅作用于XUL扩展以及XUL程序,将不会作用于web程序。</p>
+
+<h3 id="Changes_to_XMLHttpRequest.send" name="Changes_to_XMLHttpRequest.send"> XMLHttpRequest.send的改变</h3>
+
+<p>如果你将一个 <a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIInputStream">nsIInputStream</a> 实例传递给 <code>send</code> 方法, 那么流的起始部分将不再包含 Content-Length 和 Content-Type 头部信息. 并且 Content-Length 将由流的长度推断得出,  Content-Type 将必须通过调用 <code>setRequestHeader</code> 方法来手动指定. 更多关于这些要求的详细信息请查阅 <a class="external" href="http://lxr.mozilla.org/mozilla1.8/source/extensions/xmlextras/base/public/nsIXMLHttpRequest.idl#213">nsIXMLHttpRequest.idl</a>.</p>
+
+<h3 id="Changes_to_XMLHttpRequest.onreadystatechange" name="Changes_to_XMLHttpRequest.onreadystatechange">XMLHttpRequest.onreadystatechange 的改变</h3>
+
+<p>此属性现在的类型为 <code>nsIOnReadystatechangeHandler</code> 而不是 <code>nsIOnReadyStateChangeHandler</code>  。 (类型的名称中的 "S" 和 "C" 已变更为小写.)</p>
diff --git a/files/zh-cn/mozilla/同时使用多个相互独立的火狐浏览器/index.html b/files/zh-cn/mozilla/同时使用多个相互独立的火狐浏览器/index.html
new file mode 100644
index 0000000000..ab77b18752
--- /dev/null
+++ b/files/zh-cn/mozilla/同时使用多个相互独立的火狐浏览器/index.html
@@ -0,0 +1,123 @@
+---
+title: 同时使用多个相互独立的火狐浏览器
+slug: Mozilla/同时使用多个相互独立的火狐浏览器
+translation_of: Mozilla/Firefox/Multiple_profiles
+---
+<p>{{ draft() }}</p>
+<p>火狐浏览器的配置文件是用户在浏览器中的设置、自定义、个性化内容的集合。你可以在这个连接中看到它的详细内容: <a class="external" href="http://support.mozilla.org/kb/Profiles" title="http://support.mozilla.org/kb/Profiles">Profiles on Mozilla's end-user support site</a>.</p>
+<h2 id="为什么要拥有多个配置文件">为什么要拥有多个配置文件</h2>
+<p>不同的家庭成员可能希望使用不同的配置文件。这样他们的书签设置和插件就可以区分开来。</p>
+<p>Web developers might want a secondary profile for testing websites, apps, or other projects on different Firefox channels. For example, you might want to have the Firebug add-on installed for Web development, but not for general-purpose Web browsing. While using the Nightly channel, you may encounter some add-ons that have become temporarily incompatible with new API changes, until the add-on developer has a chance to update them. You can remove such add-ons from your profile for Nightly use, while keeping them for use with other profiles.</p>
+<p>For QA, testing, and bug triaging contributors, you may want to have multiple development versions of Firefox installed, each with its own profile. Creating new profiles for testing can keep you from losing your preferences, bookmarks, and history. It takes some time to set up a new profile, but once it is complete, all of your Firefox versions will update separately and can be run simultanesouly.</p>
+<h2 id="可用的浏览器开发通道">可用的浏览器开发通道</h2>
+<p>There are four available browser channels, each at a different level of stability and development. The four channels are <a class="link-https" href="https://www.mozilla.org/en-US/firefox/new/" title="Firefox Stable">Release</a>, <a class="link-https" href="https://www.mozilla.org/en-US/firefox/beta/" title="Firefox Beta">Beta</a>, <a class="link-https" href="https://www.mozilla.org/en-US/firefox/aurora/" title="Firefox Aurora">Aurora</a>, and <a class="external" href="http://nightly.mozilla.org/" title="Firefox Nightly">Nightly</a>. The Release channel is recommended for most users, as it is the "official release" channel. However, for those more adventurous, you can try one of the other three channels to see what is coming in Firefox and play around with emerging features. The Beta channel contains the features that are expected to be in the next release of Firefox and are in final stages of testing. Aurora contains experimental features, which are not yet at beta quality. Nightly contains the latest code from Firefox developers and is the least stable channel.</p>
+<h2 id="第三方工具"><span class="web-item">第三方工具</span></h2>
+<p>In addition to the built-in Profile Manager and the external Profile Manager, there are a few third-party tools that make working with multiple profiles easy:</p>
+<h3 id="Mac_OSX">Mac OSX</h3>
+<ul>
+ <li><a href="http://davemartorana.com/multifirefox/">Multifirefox</a> by Dave Martorana</li>
+</ul>
+<h2 id="配置文件管理器">配置文件管理器</h2>
+<p>{{ Note("On all operating systems, before you can start the Profile Manager, Firefox must be completely closed.") }}</p>
+<p><strong>These instructions are tentatively going away in favor of a new profile manager. You can find more details at <a href="/en/Profile_Manager" title="en/Profile_Manager">Profile Manager</a></strong></p>
+<h3 id="在Windows中启动配置文件管理器">在Windows中启动配置文件管理器</h3>
+<h4 id="Windows_XP">Windows XP</h4>
+<ol>
+ <li>Click the Start button</li>
+ <li>Click "Run"</li>
+ <li>Type "firefox -ProfileManager"</li>
+</ol>
+<h4 id="Windows_Vista7">Windows Vista/7</h4>
+<ol>
+ <li>Click the Start button</li>
+ <li>Click the search bar at the bottom.</li>
+ <li>Type "firefox -ProfileManager"</li>
+</ol>
+<h4 id="Windows_88.1">Windows 8/8.1</h4>
+<ol>
+ <li>Press "Windows + R" on your keyboard.</li>
+ <li>Type "firefox -ProfileManager".</li>
+</ol>
+<p>If the Profile Manager window does not open, Firefox may have been running in the background, even though it was not visible. Close all instances of Firefox or restart the computer and then try again.</p>
+<h3 id="在Linux中启动配置文件管理器">在Linux中启动配置文件管理器</h3>
+<p>If Firefox is already included in your Linux distribution or if you have installed Firefox with the package manager of your Linux distribution:</p>
+<ol>
+ <li>At the top of the Firefox window, click on the File menu and select Quit.</li>
+ <li>In Terminal run:<br>
+ firefox --ProfileManager</li>
+</ol>
+<p>If the Profile Manager window does not open, Firefox may have been running in the background, even though it was not visible. Close all instances of Firefox or restart the computer and then try again.</p>
+<h3 id="在Mac_OSX中启动配置文件管理器">在Mac OSX中启动配置文件管理器</h3>
+<p>Use the following tutorial until someone can test and step-by-step on a mac directly. <a class="link-https" href="http://sonnygill.net/mac/mac-multiple-firefox-profiles/"> Easily Run Multiple Firefox Instances on a Mac</a>.</p>
+<h3 id="创建配置文件">创建配置文件</h3>
+<p>These instructions should be the same for all operating systems.</p>
+<ol>
+ <li>To start the Create Profile Wizard, click "Create Profile..." in the Profile Manager.</li>
+ <li>Click Next and enter the name of the profile. Use a profile name that is descriptive, such as your personal name. This name is not exposed on the Internet.</li>
+ <li>You can also choose where to store the profile on your computer. To select storage location, click Choose Folder....</li>
+ <li>{{ Note("If you choose your own folder location for the profile, select a new or empty folder. If you choose a folder that isn't empty and you later remove the profile and choose the \"Delete Files\" option, everything inside that folder will be deleted.") }}</li>
+ <li>To create the new profile, click Finish.</li>
+</ol>
+<h3 id="删除配置文件">删除配置文件</h3>
+<ol>
+ <li>In the Profile Manager, select the profile to remove, and click Delete Profile....</li>
+ <li>Confirm that you wish to delete the profile:
+ <ul>
+ <li>Don't Delete Files removes the profile from the Profile Manager yet retains the profile data files on your computer in the storage folder, so that your information is not lost. "Don't Delete Files" is the preferred option because it saves the old profile's folder and allows you to recover the files to a new profile.</li>
+ <li>Delete Files removes the profile and its files, including the profile bookmarks, settings, passwords, etc. {{ warning("If you use the \"Delete Files\" option, the profile folder and files will be deleted. This action cannot be undone.") }}</li>
+ <li>Cancel interrupts the profile deletion.</li>
+ </ul>
+ </li>
+</ol>
+<h3 id="重命名配置文件">重命名配置文件</h3>
+<ol>
+ <li>In the Profile Manager, select the profile you want to rename, and then click "Rename Profile".</li>
+ <li>Enter a new name for the profile and click on OK.</li>
+ <li>{{ Note("The folder containing the files for the profile is not renamed. ") }}</li>
+</ol>
+<h2 id="可用选项">可用选项</h2>
+<h3 id="Work_Offline">Work Offline</h3>
+<p>Choosing this option loads the selected profile and starts Firefox offline. You can view previously viewed web pages and experiment with your profile.</p>
+<h3 id="Don't_ask_at_startup">Don't ask at startup</h3>
+<p>If you have multiple profiles, Firefox prompts you for the profile to use each time you start Firefox. Select this option to allow Firefox to load the selected profile without prompting at startup.</p>
+<p>{{ Note("To access other profiles after selecting this option, you must start the Profile Manager first.") }}</p>
+<h2 id="Using_the_profiles">Using the profiles</h2>
+<h3 id="Windows">Windows</h3>
+<p>If you want to have the profile manager to pop up each time you start Firefox, so you can choose a profile, you will need to edit the "Target" of the launch icon. To do this:</p>
+<ol>
+ <li>Right click the icon and choose "Properties".</li>
+ <li>When the properties dialog box pops up, you should see a "Target" text field that you can edit, and it should show the current file path.</li>
+ <li>After the closing quote, add "-ProfileManager"</li>
+ <li>Click Ok.</li>
+</ol>
+<p>Now whenever you double click that icon, the profile manager should appear, allowing you to choose which profile you'd like to use.</p>
+<p>If you want individual icons to launch specific profiles, you will need to edit the "Target" of each icon. To do this:</p>
+<ol>
+ <li>Right click the icon and choose "Properties".</li>
+ <li>When the properties dialog box pops up, you should see a "Target" text field that you can edit, and it should show the current file path.</li>
+ <li>To permanently set a specific profile, add "-p PROFILE_NAME" to the target path, but outside of the quotes, replacing "PROFILE_NAME" with the actual profile name you chose.</li>
+ <li>If you would like to also allow multiple instances of Firefox to run at the same time, add "-no-remote" after the profile name.</li>
+</ol>
+<p>Once you are all done, click Ok. Do this for each icon you'd like to have a specific profile for. Once done, each one should automatically start with the specified profile.</p>
+<h3 id="Linux">Linux</h3>
+<p>There is no extremely straightforward way to create custom application launchers in Gnome 3 like there was in Gnome 2. The following tutorial will help get you going overall: <a class="external" href="http://blog.randell.ph/2011/08/01/how-to-create-custom-application-launchers-in-gnome-3/" title="How to create custom application launchers in gnome 3">Gnome 3 Custom application launcher</a>. Once you get to the point of adding a new item, you can have the profile dialog show up every time or set the launcher to launch a specific profile.</p>
+<p>If you want to have the profile manager to pop up each time you start Firefox, so you can choose a profile, you will need to set the command line for your new launcher.</p>
+<ol>
+ <li>Set the "command" text field to target the executable file, likely "/usr/bin/firefox", and add the "-p" parameter.</li>
+</ol>
+<p>If you want individual icons to launch specific profiles, you will need to set the command line for your new launcher. To do this:</p>
+<ol>
+ <li>Set the "command" text field to target the executable file, likely "/usr/bin/firefox", and add the "-p PROFILE_NAME" parameter, replacing "PROFILE_NAME" with the specific profile.</li>
+ <li>Repeat as necessary for each profile you want to set.</li>
+ <li>If you would like to also allow multiple instances of Firefox to run at the same time, add "-no-remote" after the profile name.</li>
+</ol>
+<h3 id="Mac_OSX_2">Mac OSX</h3>
+<p>You can find a useful tutorial to set up custom launchers here: <a href="http://spf13.com/post/managing-multiple-firefox-profiles-in-os-x/" title="Managing Multiple Firefox Profiles in OSX">Managing Multiple Firefox Profiles in OSX</a>. Do note it's best to follow all steps in the "Creating the scripts" section, including the "edit Info.plist" step. Leave off the profile name if you want the profile selector to show up every time you launch.</p>
+<h2 id="Setting_up_multiple_profiles_for_different_Firefox_Channels">Setting up multiple profiles for different Firefox Channels</h2>
+<p>This section will be especially helpful if you are a developer wanting to work with multiple channels and each having their own separate launcher.</p>
+<h3 id="Windows_2">Windows</h3>
+<p>In Windows, the Aurora and Nightly builds get their own directory in the "Programs" folder, so you don't have to worry about where to store the downloaded files. However, all three will attempt to use the same profile by default, and you'll want to not keep this because the different channels have different levels of features. To set each launcher, follow the Windows instructions at <a href="#Windows">Windows Launcher</a></p>
+<h3 id="Linux_2">Linux</h3>
+<p>In Linux, things aren't as automatically set up, and you will likely get a prompt to download a tar.bz2 file to extract from. Extract the files to a new directory and use the new launcher instructions from <a href="#Linux">here</a>. The only change you will need to make is the command path. You will want to set it to the directory you extracted the Firefox channel's tar.bz2 file into, and the executable "firefox" file located within. The remaining profile assignment methods will remain the same. You will want to, for sure, add the "-no-remote" part to the end of the command field, so that you could run multiple instances at the same time.</p>
+<h3 id="Mac_OSX_3">Mac OSX</h3>
+<p>You can find a useful tutorial to set up custom launchers here: <a href="http://spf13.com/post/managing-multiple-firefox-profiles-in-os-x/" title="Managing Multiple Firefox Profiles in OSX">Managing Multiple Firefox Profiles in OSX</a>. Do note it's best to follow all steps in the "Creating the scripts" section, including the "edit Info.plist" step. Also you'll want to change the path in the do shell script to point to the correct .app file for the Firefox channel you want to target.</p>
diff --git a/files/zh-cn/mozilla/日历/index.html b/files/zh-cn/mozilla/日历/index.html
new file mode 100644
index 0000000000..876073f871
--- /dev/null
+++ b/files/zh-cn/mozilla/日历/index.html
@@ -0,0 +1,75 @@
+---
+title: Mozilla 日历
+slug: Mozilla/日历
+translation_of: Mozilla/Calendar
+---
+<table>
+ <tbody>
+ <tr>
+ <td><img alt="Sunbird-Logo-148x155.png" class="internal default" src="/@api/deki/files/3621/=Sunbird-Logo-148x155.png" style="width: 148px; height: 155px;"></td>
+ <td>
+ <p>Mozillar日历项目是一个基于Mozilla应用程序架构的社区驱动的项目,其核心是基于libical的日历后端。<a href="http://www.mozilla.org/projects/calendar/lightning/">Lightning附加组件</a>是在该平台上构建的,它为Mozilla的邮件客户端<a href="/zh-CN/docs/Mozilla/Thunderbird">Thunderbird</a>提供集成化的日历功能。</p>
+ <p>Mozilla Calendar emphasizes free and open source technology and supports standardized technology like the ical/ics (<a class="external" href="http://tools.ietf.org/html/rfc2445" title="http://tools.ietf.org/html/rfc2445">rfc2445</a>) format and the CalDAV (<a class="external" href="http://tools.ietf.org/html/rfc4791" title="http://tools.ietf.org/html/rfc4791">rfc4791</a>) protocol, which is implemented by many freely available servers and also some commercial providers.</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<table style="width: 1143px; height: 183px;">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;">
+ <h2 id="开发相关的主题">开发相关的主题</h2>
+ <dl>
+ <dt>
+ <a class="internal" href="/en/Simple_Sunbird_build" title="en/Simple Sunbird build">Building Calendar</a></dt>
+ <dd>
+ Information about building Calendar with the new <a class="internal" href="/en/comm-central" title="en/comm-central">comm-central</a> repository. There is also a simple build page for <a class="internal" href="/en/Simple_Thunderbird_build#Building_Thunderbird_and_Lightning" title="en/Simple Thunderbird build#Building Thunderbird and Lightning">Thunderbird including Lightning</a> and information about <a class="internal" href="/en/How_comm-central's_build_system_works" title="en/How comm-central's build system works">how comm-central works</a>.</dd>
+ </dl>
+ <dl>
+ <dt>
+ <a class="link-https" href="https://wiki.mozilla.org/Calendar:Creating_an_Extension" title="https://wiki.mozilla.org/Calendar:Creating_an_Extension">Creating a Calendar extension</a></dt>
+ <dd>
+ Tutorial on creating a Calendar extension for Sunbird and Lightning.</dd>
+ </dl>
+ <dl>
+ <dt>
+ <a class="internal" href="/en/Calendar/Localization" title="En/Calendar/Localization"><strong>Localization</strong></a></dt>
+ <dd>
+ How to get started with translating Calendar into your language and how to build Lightning in your Language. </dd>
+ <dt>
+ Testing Calendar</dt>
+ <dd>
+ <a class="internal" href="/en/Calendar/MozMill_Testing" title="En/Calendar/MozMill Testing">CalendarUtils reference</a> for writing <a class="internal" href="/en/Mozmill_Tests" title="en/Mozmill Tests">Mozmill tests</a>, which can automatically test the UI so that regressions can be easily found.</dd>
+ <dt>
+ <a href="/en/Calendar/Calendar_Versions" title="en/Calendar/Calendar Versions">Calendar Versions</a></dt>
+ <dd>
+ This page will tell you which Calendar version fits with which Mozilla Platform and where current development is being done.</dd>
+ </dl>
+ </td>
+ <td style="vertical-align: top;">
+ <h2 id="工具">工具</h2>
+ <dl>
+ <dt>
+ <a class="link-https" href="https://bugzilla.mozilla.org/query.cgi?format=specific&amp;product=Calendar" title="https://bugzilla.mozilla.org/query.cgi?format=specific&amp;product=Calendar">Bugzilla</a></dt>
+ <dd>
+ The <a class="internal" href="/en/Bugzilla" title="En/Bugzilla">Bugzilla</a> database used to track issues for Mozilla projects.</dd>
+ <dd>
+  </dd>
+ <dt>
+ <a class="external" href="http://mxr.mozilla.org/comm-central/" title="http://mxr.mozilla.org/comm-central/">MXR</a></dt>
+ <dd>
+ Browse and search the Calendar source code repository on the Web.</dd>
+ <dd>
+  </dd>
+ <dt>
+ <a class="link-https" href="https://wiki.mozilla.org/Calendar:QA_CalDAV_Support" title="https://wiki.mozilla.org/Calendar:QA_CalDAV_Support">Calendar Servers</a></dt>
+ <dd>
+ Setup your own calendar server, or check to see how well commercial products are supported.</dd>
+ <dt>
+  </dt>
+ </dl>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>