tbb-commits
Threads by month
- ----- 2025 -----
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
July 2015
- 3 participants
- 61 discussions

28 Jul '15
commit bdc340e960975098eb395fcf92c906748294c8fa
Author: David Fifield <david(a)bamsoftware.com>
Date: Mon Sep 29 04:35:26 2014 +0000
Install Noto fonts into bundles.
They are in the "fonts" directory next to the firefox executable, the
directory that is activated by --enable-bundled-fonts in
https://bugzilla.mozilla.org/show_bug.cgi?id=998844.
The license for the Noto fonts is from
https://github.com/googlei18n/noto-fonts/blob/720e34851382ee3c1ef024d8dffb6…
The license for Noto CJK is from
https://github.com/googlei18n/noto-cjk/blob/f36eda03dfa5582a6d49abbfb5c83d0…
---
Bundle-Data/Docs/Licenses/Noto-CJK-Font.txt | 92 ++++++++++++
Bundle-Data/Docs/Licenses/Noto-Fonts.txt | 201 ++++++++++++++++++++++++++
gitian/descriptors/linux/gitian-bundle.yml | 15 ++
gitian/descriptors/mac/gitian-bundle.yml | 15 ++
gitian/descriptors/windows/gitian-bundle.yml | 15 ++
gitian/mkbundle-linux.sh | 2 +-
gitian/mkbundle-mac.sh | 2 +-
gitian/mkbundle-windows.sh | 2 +-
8 files changed, 341 insertions(+), 3 deletions(-)
diff --git a/Bundle-Data/Docs/Licenses/Noto-CJK-Font.txt b/Bundle-Data/Docs/Licenses/Noto-CJK-Font.txt
new file mode 100644
index 0000000..d952d62
--- /dev/null
+++ b/Bundle-Data/Docs/Licenses/Noto-CJK-Font.txt
@@ -0,0 +1,92 @@
+This Font Software is licensed under the SIL Open Font License,
+Version 1.1.
+
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font
+creation efforts of academic and linguistic communities, and to
+provide a free and open framework in which fonts may be shared and
+improved in partnership with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply to
+any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software
+components as distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to,
+deleting, or substituting -- in part or in whole -- any of the
+components of the Original Version, by changing formats or by porting
+the Font Software to a new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed,
+modify, redistribute, and sell modified and unmodified copies of the
+Font Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components, in
+Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the
+corresponding Copyright Holder. This restriction only applies to the
+primary font name as presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created using
+the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/Bundle-Data/Docs/Licenses/Noto-Fonts.txt b/Bundle-Data/Docs/Licenses/Noto-Fonts.txt
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/Bundle-Data/Docs/Licenses/Noto-Fonts.txt
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/gitian/descriptors/linux/gitian-bundle.yml b/gitian/descriptors/linux/gitian-bundle.yml
index 455fc89..819a1de 100644
--- a/gitian/descriptors/linux/gitian-bundle.yml
+++ b/gitian/descriptors/linux/gitian-bundle.yml
@@ -24,6 +24,8 @@ remotes:
"dir": "https-everywhere"
- "url": "https://git.torproject.org/pluggable-transports/meek.git"
"dir": "meek"
+- "url": "https://github.com/googlei18n/noto-fonts.git"
+ "dir": "noto-fonts"
files:
# TODO: Can we use an env for this file+version??
- "tor-browser-linux32-gbuilt.zip"
@@ -51,6 +53,7 @@ files:
- "mar-tools-linux32.zip"
- "mar-tools-linux64.zip"
- "tbb-docs.zip"
+- "NotoSansCJKsc-Regular.otf"
script: |
INSTDIR="$HOME/install"
source versions
@@ -118,6 +121,18 @@ script: |
~/build/dzip.sh ../../tor-browser/Browser/TorBrowser/Data/Browser/profile.meek-http-helper/extensions/meek-http-helper(a)bamsoftware.com.xpi .
cd ~/build/
#
+ # Install fonts.
+ mkdir -p tor-browser/Browser/fonts
+ NOTO_FONTS_HINTED="Cousine-Regular.ttf NotoKufiArabic-Regular.ttf NotoNaskhArabic-Regular.ttf NotoSans-Regular.ttf NotoSansArmenian-Regular.ttf NotoSansBengali-Regular.ttf NotoSansDevanagari-Regular.ttf NotoSansEthiopic-Regular.ttf NotoSansGeorgian-Regular.ttf NotoSansGujarati-Regular.ttf NotoSansGurmukhi-Regular.ttf NotoSansHebrew-Regular.ttf NotoSansKannada-Regular.ttf NotoSansKhmer-Regular.ttf NotoSansLao-Regular.ttf NotoSansMalayalam-Regular.ttf NotoSansMyanmar-Regular.ttf NotoSansOriya-Regular.ttf NotoSansSinhala-Regular.ttf NotoSansTamil-Regular.ttf NotoSansTelugu-Regular.ttf NotoSansThaana-Regular.ttf NotoSansThai-Regular.ttf NotoSansTibetan-Regular.ttf NotoSerif-Regular.ttf NotoSerifArmenian-Regular.ttf NotoSerifKhmer-Regular.ttf NotoSerifLao-Regular.ttf NotoSerifThai-Regular.ttf"
+ for fontfile in $NOTO_FONTS_HINTED; do
+ cp "noto-fonts/hinted/$fontfile" tor-browser/Browser/fonts/
+ done
+ NOTO_FONTS_UNHINTED="NotoSansCanadianAboriginal-Regular.ttf NotoSansBuginese-Regular.ttf NotoSansCherokee-Regular.ttf NotoSansMongolian-Regular.ttf NotoSansYi-Regular.ttf"
+ for fontfile in $NOTO_FONTS_UNHINTED; do
+ cp "noto-fonts/unhinted/$fontfile" tor-browser/Browser/fonts/
+ done
+ cp NotoSansCJKsc-Regular.otf tor-browser/Browser/fonts/
+ #
unzip relativelink-src.zip
cp RelativeLink/* tor-browser/Browser/
#
diff --git a/gitian/descriptors/mac/gitian-bundle.yml b/gitian/descriptors/mac/gitian-bundle.yml
index 255d327..9b38d0f 100644
--- a/gitian/descriptors/mac/gitian-bundle.yml
+++ b/gitian/descriptors/mac/gitian-bundle.yml
@@ -30,6 +30,8 @@ remotes:
"dir": "libdmg-hfsplus"
- "url": "https://git.torproject.org/pluggable-transports/meek.git"
"dir": "meek"
+- "url": "https://github.com/googlei18n/noto-fonts.git"
+ "dir": "noto-fonts"
files:
# TODO: Can we use an env for this file+version??
- "tor-browser-mac64-gbuilt.zip"
@@ -54,6 +56,7 @@ files:
- "mar-tools-mac64.zip"
- "tbb-docs.zip"
- "mac-tor.sh"
+- "NotoSansCJKsc-Regular.otf"
script: |
INSTDIR="$HOME/install"
source versions
@@ -121,6 +124,18 @@ script: |
~/build/dzip.sh ../../$TORBROWSER_NAME.app/TorBrowser/Data/Browser/profile.meek-http-helper/extensions/meek-http-helper(a)bamsoftware.com.xpi .
cd ~/build/
#
+ # Install fonts.
+ mkdir -p $TORBROWSER_NAME.app/Contents/Resources/fonts
+ NOTO_FONTS_HINTED="Cousine-Regular.ttf NotoKufiArabic-Regular.ttf NotoNaskhArabic-Regular.ttf NotoSans-Regular.ttf NotoSansArmenian-Regular.ttf NotoSansBengali-Regular.ttf NotoSansDevanagari-Regular.ttf NotoSansEthiopic-Regular.ttf NotoSansGeorgian-Regular.ttf NotoSansGujarati-Regular.ttf NotoSansGurmukhi-Regular.ttf NotoSansHebrew-Regular.ttf NotoSansKannada-Regular.ttf NotoSansKhmer-Regular.ttf NotoSansLao-Regular.ttf NotoSansMalayalam-Regular.ttf NotoSansMyanmar-Regular.ttf NotoSansOriya-Regular.ttf NotoSansSinhala-Regular.ttf NotoSansTamil-Regular.ttf NotoSansTelugu-Regular.ttf NotoSansThaana-Regular.ttf NotoSansThai-Regular.ttf NotoSansTibetan-Regular.ttf NotoSerif-Regular.ttf NotoSerifArmenian-Regular.ttf NotoSerifKhmer-Regular.ttf NotoSerifLao-Regular.ttf NotoSerifThai-Regular.ttf"
+ for fontfile in $NOTO_FONTS_HINTED; do
+ cp "noto-fonts/hinted/$fontfile" $TORBROWSER_NAME.app/Contents/Resources/fonts/
+ done
+ NOTO_FONTS_UNHINTED="NotoSansCanadianAboriginal-Regular.ttf NotoSansBuginese-Regular.ttf NotoSansCherokee-Regular.ttf NotoSansMongolian-Regular.ttf NotoSansYi-Regular.ttf"
+ for fontfile in $NOTO_FONTS_UNHINTED; do
+ cp "noto-fonts/unhinted/$fontfile" $TORBROWSER_NAME.app/Contents/Resources/fonts/
+ done
+ cp NotoSansCJKsc-Regular.otf $TORBROWSER_NAME.app/Contents/Resources/fonts/
+ #
unzip tor-mac$GBUILD_BITS-gbuilt.zip
if [ $BUILD_PT_BUNDLES ]; then
unzip pluggable-transports-mac$GBUILD_BITS-gbuilt.zip
diff --git a/gitian/descriptors/windows/gitian-bundle.yml b/gitian/descriptors/windows/gitian-bundle.yml
index 54ea258..02a3816 100644
--- a/gitian/descriptors/windows/gitian-bundle.yml
+++ b/gitian/descriptors/windows/gitian-bundle.yml
@@ -29,6 +29,8 @@ remotes:
"dir": "https-everywhere"
- "url": "https://git.torproject.org/pluggable-transports/meek.git"
"dir": "meek"
+- "url": "https://github.com/googlei18n/noto-fonts.git"
+ "dir": "noto-fonts"
files:
# TODO: Can we use an env for this file+version??
- "tor-browser-win32-gbuilt.zip"
@@ -47,6 +49,7 @@ files:
- "mar-tools-win32.zip"
- "tbb-docs.zip"
- "pe_checksum_fix.py"
+- "NotoSansCJKsc-Regular.otf"
script: |
INSTDIR="$HOME/install"
source versions
@@ -110,6 +113,18 @@ script: |
mv ../meek-http-helper(a)bamsoftware.com.xpi ../../tbb-windows-installer/"Tor Browser"/Browser/TorBrowser/Data/Browser/profile.meek-http-helper/extensions/meek-http-helper(a)bamsoftware.com.xpi
cd ~/build/
#
+ # Install fonts.
+ mkdir -p tbb-windows-installer/"Tor Browser"/Browser/fonts
+ NOTO_FONTS_HINTED="Cousine-Regular.ttf NotoKufiArabic-Regular.ttf NotoNaskhArabic-Regular.ttf NotoSans-Regular.ttf NotoSansArmenian-Regular.ttf NotoSansBengali-Regular.ttf NotoSansDevanagari-Regular.ttf NotoSansEthiopic-Regular.ttf NotoSansGeorgian-Regular.ttf NotoSansGujarati-Regular.ttf NotoSansGurmukhi-Regular.ttf NotoSansHebrew-Regular.ttf NotoSansKannada-Regular.ttf NotoSansKhmer-Regular.ttf NotoSansLao-Regular.ttf NotoSansMalayalam-Regular.ttf NotoSansMyanmar-Regular.ttf NotoSansOriya-Regular.ttf NotoSansSinhala-Regular.ttf NotoSansTamil-Regular.ttf NotoSansTelugu-Regular.ttf NotoSansThaana-Regular.ttf NotoSansThai-Regular.ttf NotoSansTibetan-Regular.ttf NotoSerif-Regular.ttf NotoSerifArmenian-Regular.ttf NotoSerifKhmer-Regular.ttf NotoSerifLao-Regular.ttf NotoSerifThai-Regular.ttf"
+ for fontfile in $NOTO_FONTS_HINTED; do
+ cp "noto-fonts/hinted/$fontfile" tbb-windows-installer/"Tor Browser"/Browser/fonts/
+ done
+ NOTO_FONTS_UNHINTED="NotoSansCanadianAboriginal-Regular.ttf NotoSansBuginese-Regular.ttf NotoSansCherokee-Regular.ttf NotoSansMongolian-Regular.ttf NotoSansYi-Regular.ttf"
+ for fontfile in $NOTO_FONTS_UNHINTED; do
+ cp "noto-fonts/unhinted/$fontfile" tbb-windows-installer/"Tor Browser"/Browser/fonts/
+ done
+ cp NotoSansCJKsc-Regular.otf tbb-windows-installer/"Tor Browser"/Browser/fonts/
+ #
cd tbb-windows-installer/"Tor Browser"
unzip ~/build/tor-browser-win32-gbuilt.zip
cd Browser/TorBrowser
diff --git a/gitian/mkbundle-linux.sh b/gitian/mkbundle-linux.sh
index cb80214..65af74e 100755
--- a/gitian/mkbundle-linux.sh
+++ b/gitian/mkbundle-linux.sh
@@ -247,7 +247,7 @@ then
cd $WRAPPER_DIR && ./record-inputs.sh $VERSIONS_FILE && cd $GITIAN_DIR
- ./bin/gbuild -j $NUM_PROCS -m $VM_MEMORY --commit https-everywhere=$HTTPSE_TAG,tor-launcher=$TORLAUNCHER_TAG,torbutton=$TORBUTTON_TAG,meek=$MEEK_TAG $DESCRIPTOR_DIR/linux/gitian-bundle.yml
+ ./bin/gbuild -j $NUM_PROCS -m $VM_MEMORY --commit https-everywhere=$HTTPSE_TAG,tor-launcher=$TORLAUNCHER_TAG,torbutton=$TORBUTTON_TAG,meek=$MEEK_TAG,noto-fonts=$NOTOFONTS_TAG $DESCRIPTOR_DIR/linux/gitian-bundle.yml
if [ $? -ne 0 ];
then
#mv var/build.log ./bundle-fail-linux.log.`date +%Y%m%d%H%M%S`
diff --git a/gitian/mkbundle-mac.sh b/gitian/mkbundle-mac.sh
index 363ebb1..cf54e19 100755
--- a/gitian/mkbundle-mac.sh
+++ b/gitian/mkbundle-mac.sh
@@ -217,7 +217,7 @@ then
cd $WRAPPER_DIR && ./record-inputs.sh $VERSIONS_FILE && cd $GITIAN_DIR
- ./bin/gbuild -j $NUM_PROCS -m $VM_MEMORY --commit libdmg-hfsplus=$LIBDMG_TAG,https-everywhere=$HTTPSE_TAG,torbutton=$TORBUTTON_TAG,tor-launcher=$TORLAUNCHER_TAG,meek=$MEEK_TAG $DESCRIPTOR_DIR/mac/gitian-bundle.yml
+ ./bin/gbuild -j $NUM_PROCS -m $VM_MEMORY --commit libdmg-hfsplus=$LIBDMG_TAG,https-everywhere=$HTTPSE_TAG,torbutton=$TORBUTTON_TAG,tor-launcher=$TORLAUNCHER_TAG,meek=$MEEK_TAG,noto-fonts=$NOTOFONTS_TAG $DESCRIPTOR_DIR/mac/gitian-bundle.yml
if [ $? -ne 0 ];
then
#mv var/build.log ./bundle-fail-mac.log.`date +%Y%m%d%H%M%S`
diff --git a/gitian/mkbundle-windows.sh b/gitian/mkbundle-windows.sh
index 238ad51..24f8f4e 100755
--- a/gitian/mkbundle-windows.sh
+++ b/gitian/mkbundle-windows.sh
@@ -220,7 +220,7 @@ then
cd $WRAPPER_DIR && ./record-inputs.sh $VERSIONS_FILE && cd $GITIAN_DIR
- ./bin/gbuild -j $NUM_PROCS -m $VM_MEMORY --commit https-everywhere=$HTTPSE_TAG,torbutton=$TORBUTTON_TAG,tor-launcher=$TORLAUNCHER_TAG,tbb-windows-installer=$NSIS_TAG,meek=$MEEK_TAG $DESCRIPTOR_DIR/windows/gitian-bundle.yml
+ ./bin/gbuild -j $NUM_PROCS -m $VM_MEMORY --commit https-everywhere=$HTTPSE_TAG,torbutton=$TORBUTTON_TAG,tor-launcher=$TORLAUNCHER_TAG,tbb-windows-installer=$NSIS_TAG,meek=$MEEK_TAG,noto-fonts=$NOTOFONTS_TAG $DESCRIPTOR_DIR/windows/gitian-bundle.yml
if [ $? -ne 0 ];
then
#mv var/build.log ./bundle-fail-win32.log.`date +%Y%m%d%H%M%S`
1
0

28 Jul '15
commit 03cf87e2a76d15016703de631ca5140e42fdb1f4
Author: Georg Koppen <gk(a)torproject.org>
Date: Tue Jul 28 17:01:55 2015 +0000
Bug 16268: Taking lower-case into account
Patch by Pearl Crescent
---
trans_tools/import-translations.sh | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/trans_tools/import-translations.sh b/trans_tools/import-translations.sh
index 28816ff..ae686b4 100755
--- a/trans_tools/import-translations.sh
+++ b/trans_tools/import-translations.sh
@@ -66,18 +66,24 @@ fi
echo "Locales: $BUNDLE_LOCALES"
cd translation
for KEYVAL in "${FILEMAP[@]}"; do
- FILE="${KEYVAL%%:*}"
+ DEST_FILE="${KEYVAL%%:*}"
BRANCH="${KEYVAL##*:}"
- echo "Updating ${FILE}..."
+ echo "Updating ${DEST_FILE}..."
git checkout -q "$BRANCH"
git merge -q origin/"$BRANCH"
for i in $BUNDLE_LOCALES;
do
UL="`echo $i|tr - _`"
mkdir -p ../$LOCALE_DIR/$i/
+# Some file names are lowercase in Transifex.
+ if [ -f $UL/"$DEST_FILE" ]; then
+ SRCFILE="$DEST_FILE"
+ else
+ SRCFILE="`echo $DEST_FILE | tr '[:upper:]' '[:lower:]'`"
+ fi
# Use sed to work around a Transifex "double entity" issue.
sed -e 's/\&brandShortName;/\&brandShortName;/g' \
-e 's/\&vendorShortName;/\&vendorShortName;/g' \
- $UL/"$FILE" > ../$LOCALE_DIR/$i/"$FILE"
+ $UL/"$SRCFILE" > ../$LOCALE_DIR/$i/"$DEST_FILE"
done
done
1
0

28 Jul '15
commit 83e881b69a286c9d1e1c33f7522bb1ad9681b6f2
Author: Georg Koppen <gk(a)torproject.org>
Date: Tue Jul 28 15:59:40 2015 +0000
Adding new subkeys to gk's key
---
gitian/gpg/gk.gpg | Bin 11926 -> 33866 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/gitian/gpg/gk.gpg b/gitian/gpg/gk.gpg
index 9923c96..ad731ca 100644
Binary files a/gitian/gpg/gk.gpg and b/gitian/gpg/gk.gpg differ
1
0

[tor-browser-bundle/master] Enable meek-http-helper prefs that make the ALPN extension match.
by mikeperry@torproject.org 28 Jul '15
by mikeperry@torproject.org 28 Jul '15
28 Jul '15
commit 276e390fbd0aa2449675c55a477f337a0f2b78df
Author: David Fifield <david(a)bamsoftware.com>
Date: Fri Jul 24 10:07:38 2015 +0000
Enable meek-http-helper prefs that make the ALPN extension match.
https://trac.torproject.org/projects/tor/ticket/15512#comment:3
---
Bundle-Data/PTConfigs/meek-http-helper-user.js | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Bundle-Data/PTConfigs/meek-http-helper-user.js b/Bundle-Data/PTConfigs/meek-http-helper-user.js
index 23565d9..de2355c 100644
--- a/Bundle-Data/PTConfigs/meek-http-helper-user.js
+++ b/Bundle-Data/PTConfigs/meek-http-helper-user.js
@@ -9,6 +9,14 @@ user_pref("browser.dom.window.dump.enabled", true);
// https://trac.torproject.org/projects/tor/ticket/13442#comment:1
user_pref("security.ssl.disable_session_identifiers", false);
+// Enable SPDY and HTTP/2 as they are in Firefox 38, for a matching ALPN
+// extension.
+// https://trac.torproject.org/projects/tor/ticket/15512
+user_pref("network.http.spdy.enabled", true);
+user_pref("network.http.spdy.enabled.http2", true);
+user_pref("network.http.spdy.enabled.http2draft", true);
+user_pref("network.http.spdy.enabled.v3-1", true);
+
// Disable safe mode. In case of a crash, we don't want to prompt for a
// safe-mode browser that has extensions disabled.
// https://support.mozilla.org/en-US/questions/951221#answer-410562
1
0

[tor-browser/tor-browser-38.1.0esr-5.0-1] fixup! Bug 15646: Prevent keyboard layout fingerprinting in KeyboardEvent
by mikeperry@torproject.org 28 Jul '15
by mikeperry@torproject.org 28 Jul '15
28 Jul '15
commit 0396e4f834a31ec0cc7b9c4b853417891a09c43c
Author: Arthur Edelstein <arthuredelstein(a)gmail.com>
Date: Mon Jul 27 17:17:15 2015 -0700
fixup! Bug 15646: Prevent keyboard layout fingerprinting in KeyboardEvent
---
dom/events/KeyCodeConsensus.h | 9 +++++++--
dom/events/KeyboardEvent.cpp | 10 +++++++++-
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/dom/events/KeyCodeConsensus.h b/dom/events/KeyCodeConsensus.h
index 5493c36..53ec7f6 100644
--- a/dom/events/KeyCodeConsensus.h
+++ b/dom/events/KeyCodeConsensus.h
@@ -5,14 +5,15 @@
#include "nsString.h"
#include "nsDataHashtable.h"
+#include "mozilla/StaticMutex.h"
// KEY_INTERNAL is called by KEY or SHIFT.
-#define KEY_INTERNAL(key, code, keyCode, shift) \
+#define KEY_INTERNAL(key, code, keyCode, shift) \
gCodes->Put(NS_LITERAL_STRING(key), NS_LITERAL_STRING(#code)); \
gKeyCodes->Put(NS_LITERAL_STRING(key), keyCode); \
gShiftStates->Put(NS_LITERAL_STRING(key), shift);
-// KEY and SHIFT Assign a consensus codeName and keyCode for the given keyName.
+// KEY and SHIFT assign a consensus codeName and keyCode for the given keyName.
// KEY indicates that shift is off.
#define KEY(key, code, keyCode) KEY_INTERNAL(key, code, keyCode, false)
// SHIFT indicates that shift is on.
@@ -26,12 +27,16 @@ static nsDataHashtable<nsStringHashKey, uint32_t>* gKeyCodes;
// gShiftStates provides a shift value for each keyName.
static nsDataHashtable<nsStringHashKey, bool>* gShiftStates;
+static StaticMutex createKeyCodesMutex;
+
// Populate the global static maps gCodes, gKeCodes, gShiftStates
// with their constant values.
static void createKeyCodes()
{
if (gCodes) return;
+ StaticMutexAutoLock lock(createKeyCodesMutex);
+
gCodes = new nsDataHashtable<nsStringHashKey, nsString>();
gKeyCodes = new nsDataHashtable<nsStringHashKey, uint32_t>();
gShiftStates = new nsDataHashtable<nsStringHashKey, bool>();
diff --git a/dom/events/KeyboardEvent.cpp b/dom/events/KeyboardEvent.cpp
index 8829b8f..76e6e39 100644
--- a/dom/events/KeyboardEvent.cpp
+++ b/dom/events/KeyboardEvent.cpp
@@ -46,7 +46,15 @@ NS_INTERFACE_MAP_END_INHERITING(UIEvent)
bool
KeyboardEvent::AltKey()
{
- return mEvent->AsKeyboardEvent()->IsAlt();
+ bool altState = mEvent->AsKeyboardEvent()->IsAlt();
+ if (ResistFingerprinting()) {
+ nsString keyName;
+ GetKey(keyName);
+ bool exists = gCodes->Get(keyName, nullptr);
+ return exists ? false : altState;
+ } else {
+ return altState;
+ }
}
NS_IMETHODIMP
1
0

[tor-browser/tor-browser-38.1.0esr-5.0-1] Merge remote-tracking branch 'arthur/15646+2' into tor-browser-38.1.0esr-5.0-1
by mikeperry@torproject.org 28 Jul '15
by mikeperry@torproject.org 28 Jul '15
28 Jul '15
commit 8422662a5b8771b6e93a02e4cb6895ff1d8a3126
Merge: 2d81730 0396e4f
Author: Mike Perry <mikeperry-git(a)torproject.org>
Date: Tue Jul 28 07:30:10 2015 -0700
Merge remote-tracking branch 'arthur/15646+2' into tor-browser-38.1.0esr-5.0-1
dom/events/KeyCodeConsensus.h | 9 +++++++--
dom/events/KeyboardEvent.cpp | 10 +++++++++-
2 files changed, 16 insertions(+), 3 deletions(-)
1
0

[tor-browser/tor-browser-38.1.0esr-5.0-1] Bug 1078657 - Add SpawnTask.js for async tasks in mochitests. r=jmaher
by mikeperry@torproject.org 28 Jul '15
by mikeperry@torproject.org 28 Jul '15
28 Jul '15
commit 6bc7fec8c4381a2ed4112ab9c43a6b243c6a0dd5
Author: Arthur Edelstein <arthuredelstein(a)gmail.com>
Date: Fri Jul 17 12:37:24 2015 -0400
Bug 1078657 - Add SpawnTask.js for async tasks in mochitests. r=jmaher
---
testing/mochitest/chrome/chrome.ini | 1 +
testing/mochitest/chrome/test_sanitySpawnTask.xul | 70 ++++++
testing/mochitest/jar.mn | 1 +
.../mochitest/tests/Harness_sanity/mochitest.ini | 2 +-
.../tests/Harness_sanity/test_spawn_task.html | 73 ++++++
.../mochitest/tests/SimpleTest/LICENSE_SpawnTask | 24 ++
testing/mochitest/tests/SimpleTest/SpawnTask.js | 244 ++++++++++++++++++++
testing/mochitest/tests/SimpleTest/moz.build | 1 +
8 files changed, 415 insertions(+), 1 deletion(-)
diff --git a/testing/mochitest/chrome/chrome.ini b/testing/mochitest/chrome/chrome.ini
index ecd3911..a5ed449 100644
--- a/testing/mochitest/chrome/chrome.ini
+++ b/testing/mochitest/chrome/chrome.ini
@@ -12,4 +12,5 @@ skip-if = buildapp == 'mulet'
fail-if = true
[test_sanityManifest_pf.xul]
fail-if = true
+[test_sanitySpawnTask.xul]
[test_chromeGetTestFile.xul]
diff --git a/testing/mochitest/chrome/test_sanitySpawnTask.xul b/testing/mochitest/chrome/test_sanitySpawnTask.xul
new file mode 100644
index 0000000..c26b761
--- /dev/null
+++ b/testing/mochitest/chrome/test_sanitySpawnTask.xul
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+ - License, v. 2.0. If a copy of the MPL was not distributed with this
+ - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+ type="text/css"?>
+<window title="Test spawnTawk function"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"/>
+ <script type="application/javascript">
+ <![CDATA[
+ SimpleTest.waitForExplicitFinish();
+
+ var externalGeneratorFunction = function* () {
+ return 8;
+ };
+
+ var nestedFunction = function* () {
+ return yield function* () {
+ return yield function* () {
+ return yield function* () {
+ return yield Promise.resolve(9);
+ }();
+ }();
+ }();
+ }
+
+ var variousTests = function* () {
+ var val1 = yield [Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)];
+ is(val1.join(""), "123", "Array of promises -> Promise.all");
+ var val2 = yield Promise.resolve(2);
+ is(val2, 2, "Resolved promise yields value.");
+ var val3 = yield function* () { return 3; };
+ is(val3, 3, "Generator functions are spawned.");
+ //var val4 = yield function () { return 4; };
+ //is(val4, 4, "Plain functions run and return.");
+ var val5 = yield (function* () { return 5; }());
+ is(val5, 5, "Generators are spawned.");
+ try {
+ var val6 = yield Promise.reject(Error("error6"));
+ ok(false, "Shouldn't reach this line.");
+ } catch (error) {
+ is(error.message, "error6", "Rejected promise throws error.");
+ }
+ try {
+ var val7 = yield function* () { throw Error("error7"); };
+ ok(false, "Shouldn't reach this line.");
+ } catch (error) {
+ is(error.message, "error7", "Thrown error propagates.");
+ }
+ var val8 = yield externalGeneratorFunction();
+ is(val8, 8, "External generator also spawned.");
+ var val9 = yield nestedFunction();
+ is(val9, 9, "Nested generator functions work.");
+ return 10;
+ };
+
+ spawnTask(variousTests).then(function(result) {
+ is(result, 10, "spawnTask(...) returns promise");
+ SimpleTest.finish();
+ });
+ ]]>
+ </script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" >
+ </body>
+</window>
diff --git a/testing/mochitest/jar.mn b/testing/mochitest/jar.mn
index c678812..75f535d 100644
--- a/testing/mochitest/jar.mn
+++ b/testing/mochitest/jar.mn
@@ -20,6 +20,7 @@ mochikit.jar:
content/static/harness.css (static/harness.css)
content/tests/SimpleTest/ChromePowers.js (tests/SimpleTest/ChromePowers.js)
content/tests/SimpleTest/EventUtils.js (tests/SimpleTest/EventUtils.js)
+ content/tests/SimpleTest/SpawnTask.js (tests/SimpleTest/SpawnTask.js)
content/tests/SimpleTest/ChromeUtils.js (tests/SimpleTest/ChromeUtils.js)
content/tests/SimpleTest/LogController.js (tests/SimpleTest/LogController.js)
content/tests/SimpleTest/MemoryStats.js (tests/SimpleTest/MemoryStats.js)
diff --git a/testing/mochitest/tests/Harness_sanity/mochitest.ini b/testing/mochitest/tests/Harness_sanity/mochitest.ini
index 0eefc3f..935acc3 100644
--- a/testing/mochitest/tests/Harness_sanity/mochitest.ini
+++ b/testing/mochitest/tests/Harness_sanity/mochitest.ini
@@ -31,4 +31,4 @@ fail-if = true
[test_sanity_manifest_pf.html]
skip-if = toolkit == 'android' # we use the old manifest style on android
fail-if = true
-
+[test_spawn_task.html]
diff --git a/testing/mochitest/tests/Harness_sanity/test_spawn_task.html b/testing/mochitest/tests/Harness_sanity/test_spawn_task.html
new file mode 100644
index 0000000..425b7fd
--- /dev/null
+++ b/testing/mochitest/tests/Harness_sanity/test_spawn_task.html
@@ -0,0 +1,73 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test for mochitest SpawnTask.js sanity</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug 1078657</a>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for sanity **/
+SimpleTest.waitForExplicitFinish();
+
+var externalGeneratorFunction = function* () {
+ return 8;
+};
+
+var nestedFunction = function* () {
+ return yield function* () {
+ return yield function* () {
+ return yield function* () {
+ return yield Promise.resolve(9);
+ }();
+ }();
+ }();
+}
+
+var variousTests = function* () {
+ var val1 = yield [Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)];
+ is(val1.join(""), "123", "Array of promises -> Promise.all");
+ var val2 = yield Promise.resolve(2);
+ is(val2, 2, "Resolved promise yields value.");
+ var val3 = yield function* () { return 3; };
+ is(val3, 3, "Generator functions are spawned.");
+ //var val4 = yield function () { return 4; };
+ //is(val4, 4, "Plain functions run and return.");
+ var val5 = yield (function* () { return 5; }());
+ is(val5, 5, "Generators are spawned.");
+ try {
+ var val6 = yield Promise.reject(Error("error6"));
+ ok(false, "Shouldn't reach this line.");
+ } catch (error) {
+ is(error.message, "error6", "Rejected promise throws error.");
+ }
+ try {
+ var val7 = yield function* () { throw Error("error7"); };
+ ok(false, "Shouldn't reach this line.");
+ } catch (error) {
+ is(error.message, "error7", "Thrown error propagates.");
+ }
+ var val8 = yield externalGeneratorFunction();
+ is(val8, 8, "External generator also spawned.");
+ var val9 = yield nestedFunction();
+ is(val9, 9, "Nested generator functions work.");
+ return 10;
+};
+
+spawnTask(variousTests).then(function(result) {
+ is(result, 10, "spawnTask(...) returns promise");
+ SimpleTest.finish();
+});
+
+
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/testing/mochitest/tests/SimpleTest/LICENSE_SpawnTask b/testing/mochitest/tests/SimpleTest/LICENSE_SpawnTask
new file mode 100644
index 0000000..088c54c
--- /dev/null
+++ b/testing/mochitest/tests/SimpleTest/LICENSE_SpawnTask
@@ -0,0 +1,24 @@
+LICENSE for SpawnTask.js (the co library):
+
+(The MIT License)
+
+Copyright (c) 2014 TJ Holowaychuk <tj(a)vision-media.ca>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/testing/mochitest/tests/SimpleTest/SpawnTask.js b/testing/mochitest/tests/SimpleTest/SpawnTask.js
new file mode 100644
index 0000000..954dcc4
--- /dev/null
+++ b/testing/mochitest/tests/SimpleTest/SpawnTask.js
@@ -0,0 +1,244 @@
+// # SpawnTask.js
+// Directly copied from the "co" library by TJ Holowaychuk.
+// See https://github.com/tj/co/tree/4.6.0
+// For use with mochitest-plain and mochitest-chrome.
+
+// __spawnTask(generatorFunction)__.
+// Expose only the `co` function, which is very similar to Task.spawn in Task.jsm.
+// We call this function spawnTask to make its purpose more plain, and to
+// reduce the chance of name collisions.
+var spawnTask = (function () {
+
+/**
+ * slice() reference.
+ */
+
+var slice = Array.prototype.slice;
+
+/**
+ * Wrap the given generator `fn` into a
+ * function that returns a promise.
+ * This is a separate function so that
+ * every `co()` call doesn't create a new,
+ * unnecessary closure.
+ *
+ * @param {GeneratorFunction} fn
+ * @return {Function}
+ * @api public
+ */
+
+co.wrap = function (fn) {
+ createPromise.__generatorFunction__ = fn;
+ return createPromise;
+ function createPromise() {
+ return co.call(this, fn.apply(this, arguments));
+ }
+};
+
+/**
+ * Execute the generator function or a generator
+ * and return a promise.
+ *
+ * @param {Function} fn
+ * @return {Promise}
+ * @api public
+ */
+
+function co(gen) {
+ var ctx = this;
+ var args = slice.call(arguments, 1)
+
+ // we wrap everything in a promise to avoid promise chaining,
+ // which leads to memory leak errors.
+ // see https://github.com/tj/co/issues/180
+ return new Promise(function(resolve, reject) {
+ if (typeof gen === 'function') gen = gen.apply(ctx, args);
+ if (!gen || typeof gen.next !== 'function') return resolve(gen);
+
+ onFulfilled();
+
+ /**
+ * @param {Mixed} res
+ * @return {Promise}
+ * @api private
+ */
+
+ function onFulfilled(res) {
+ var ret;
+ try {
+ ret = gen.next(res);
+ } catch (e) {
+ return reject(e);
+ }
+ next(ret);
+ }
+
+ /**
+ * @param {Error} err
+ * @return {Promise}
+ * @api private
+ */
+
+ function onRejected(err) {
+ var ret;
+ try {
+ ret = gen.throw(err);
+ } catch (e) {
+ return reject(e);
+ }
+ next(ret);
+ }
+
+ /**
+ * Get the next value in the generator,
+ * return a promise.
+ *
+ * @param {Object} ret
+ * @return {Promise}
+ * @api private
+ */
+
+ function next(ret) {
+ if (ret.done) return resolve(ret.value);
+ var value = toPromise.call(ctx, ret.value);
+ if (value && isPromise(value)) return value.then(onFulfilled, onRejected);
+ return onRejected(new TypeError('You may only yield a function, promise, generator, array, or object, '
+ + 'but the following object was passed: "' + String(ret.value) + '"'));
+ }
+ });
+}
+
+/**
+ * Convert a `yield`ed value into a promise.
+ *
+ * @param {Mixed} obj
+ * @return {Promise}
+ * @api private
+ */
+
+function toPromise(obj) {
+ if (!obj) return obj;
+ if (isPromise(obj)) return obj;
+ if (isGeneratorFunction(obj) || isGenerator(obj)) return co.call(this, obj);
+ if ('function' == typeof obj) return thunkToPromise.call(this, obj);
+ if (Array.isArray(obj)) return arrayToPromise.call(this, obj);
+ if (isObject(obj)) return objectToPromise.call(this, obj);
+ return obj;
+}
+
+/**
+ * Convert a thunk to a promise.
+ *
+ * @param {Function}
+ * @return {Promise}
+ * @api private
+ */
+
+function thunkToPromise(fn) {
+ var ctx = this;
+ return new Promise(function (resolve, reject) {
+ fn.call(ctx, function (err, res) {
+ if (err) return reject(err);
+ if (arguments.length > 2) res = slice.call(arguments, 1);
+ resolve(res);
+ });
+ });
+}
+
+/**
+ * Convert an array of "yieldables" to a promise.
+ * Uses `Promise.all()` internally.
+ *
+ * @param {Array} obj
+ * @return {Promise}
+ * @api private
+ */
+
+function arrayToPromise(obj) {
+ return Promise.all(obj.map(toPromise, this));
+}
+
+/**
+ * Convert an object of "yieldables" to a promise.
+ * Uses `Promise.all()` internally.
+ *
+ * @param {Object} obj
+ * @return {Promise}
+ * @api private
+ */
+
+function objectToPromise(obj){
+ var results = new obj.constructor();
+ var keys = Object.keys(obj);
+ var promises = [];
+ for (var i = 0; i < keys.length; i++) {
+ var key = keys[i];
+ var promise = toPromise.call(this, obj[key]);
+ if (promise && isPromise(promise)) defer(promise, key);
+ else results[key] = obj[key];
+ }
+ return Promise.all(promises).then(function () {
+ return results;
+ });
+
+ function defer(promise, key) {
+ // predefine the key in the result
+ results[key] = undefined;
+ promises.push(promise.then(function (res) {
+ results[key] = res;
+ }));
+ }
+}
+
+/**
+ * Check if `obj` is a promise.
+ *
+ * @param {Object} obj
+ * @return {Boolean}
+ * @api private
+ */
+
+function isPromise(obj) {
+ return 'function' == typeof obj.then;
+}
+
+/**
+ * Check if `obj` is a generator.
+ *
+ * @param {Mixed} obj
+ * @return {Boolean}
+ * @api private
+ */
+
+function isGenerator(obj) {
+ return 'function' == typeof obj.next && 'function' == typeof obj.throw;
+}
+
+/**
+ * Check if `obj` is a generator function.
+ *
+ * @param {Mixed} obj
+ * @return {Boolean}
+ * @api private
+ */
+function isGeneratorFunction(obj) {
+ var constructor = obj.constructor;
+ if (!constructor) return false;
+ if ('GeneratorFunction' === constructor.name || 'GeneratorFunction' === constructor.displayName) return true;
+ return isGenerator(constructor.prototype);
+}
+
+/**
+ * Check for plain object.
+ *
+ * @param {Mixed} val
+ * @return {Boolean}
+ * @api private
+ */
+
+function isObject(val) {
+ return Object == val.constructor;
+}
+
+return co;
+})();
diff --git a/testing/mochitest/tests/SimpleTest/moz.build b/testing/mochitest/tests/SimpleTest/moz.build
index 4cf31c7..e07b652 100644
--- a/testing/mochitest/tests/SimpleTest/moz.build
+++ b/testing/mochitest/tests/SimpleTest/moz.build
@@ -17,6 +17,7 @@ TEST_HARNESS_FILES.testing.mochitest.tests.SimpleTest += [
'paint_listener.js',
'setup.js',
'SimpleTest.js',
+ 'SpawnTask.js',
'test.css',
'TestRunner.js',
'WindowSnapshot.js',
1
0

[tor-browser/tor-browser-38.1.0esr-5.0-1] fixup! Bug #15502, Part 2: Regression tests for blob URL isolation
by mikeperry@torproject.org 28 Jul '15
by mikeperry@torproject.org 28 Jul '15
28 Jul '15
commit eaeb778b28d2f300403a721db8374ea72f8499b6
Author: Arthur Edelstein <arthuredelstein(a)gmail.com>
Date: Mon Jun 22 16:18:46 2015 -0700
fixup! Bug #15502, Part 2: Regression tests for blob URL isolation
---
dom/base/test/bug15502_page_blobify.html | 3 ++-
dom/base/test/bug15502_page_deblobify.html | 3 ++-
dom/base/test/bug15502_tab.html | 5 +++--
dom/base/test/bug15502_utils.js | 15 +++++++--------
dom/base/test/bug15502_worker_blobify.html | 3 ++-
dom/base/test/bug15502_worker_deblobify.html | 3 ++-
dom/base/test/test_tor_bug15502.html | 17 ++++++++++++-----
7 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/dom/base/test/bug15502_page_blobify.html b/dom/base/test/bug15502_page_blobify.html
index d883929..5d81bec 100644
--- a/dom/base/test/bug15502_page_blobify.html
+++ b/dom/base/test/bug15502_page_blobify.html
@@ -6,6 +6,7 @@ https://bugs.torproject.org/15502
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Page blobifier for Tor Browser Bug 15502</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript;version=1.7" src="bug15502_utils.js"></script>
</head>
<body>
@@ -13,7 +14,7 @@ https://bugs.torproject.org/15502
<script type="text/javascript;version=1.7">
-Task.spawn(function* () {
+spawnTask(function* () {
sendMessage(window.parent, "ready");
let message = yield receiveMessage(window.parent),
blobURL = stringToBlobURL(message);
diff --git a/dom/base/test/bug15502_page_deblobify.html b/dom/base/test/bug15502_page_deblobify.html
index e8cbd51..c728c79 100644
--- a/dom/base/test/bug15502_page_deblobify.html
+++ b/dom/base/test/bug15502_page_deblobify.html
@@ -6,6 +6,7 @@ https://bugs.torproject.org/15502
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Page deblobifier for Tor Browser Bug 15502</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript;version=1.7" src="bug15502_utils.js"></script>
</head>
<body>
@@ -13,7 +14,7 @@ https://bugs.torproject.org/15502
<script type="text/javascript;version=1.7">
-Task.spawn(function* () {
+spawnTask(function* () {
sendMessage(window.parent, "ready");
let blobURL = yield receiveMessage(window.parent),
string;
diff --git a/dom/base/test/bug15502_tab.html b/dom/base/test/bug15502_tab.html
index 7bd4744..b41274e 100644
--- a/dom/base/test/bug15502_tab.html
+++ b/dom/base/test/bug15502_tab.html
@@ -6,6 +6,7 @@ https://bugs.torproject.org/15502
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Tab for Tor Browser Bug 15502</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript;version=1.7" src="bug15502_utils.js"></script>
</head>
<body>
@@ -18,7 +19,7 @@ https://bugs.torproject.org/15502
let iframe = document.getElementById("child");
let connect = function (sourceObject, destinationObject) {
- Task.spawn(function* () {
+ spawnTask(function* () {
for (;;) {
let message = yield receiveMessage(sourceObject);
sendMessage(destinationObject, message);
@@ -26,7 +27,7 @@ let connect = function (sourceObject, destinationObject) {
});
};
-Task.spawn(function* () {
+spawnTask(function* () {
sendMessage(window.opener, "ready");
let firstParentMessage = yield receiveMessage(window.opener);
iframe.src = firstParentMessage;
diff --git a/dom/base/test/bug15502_utils.js b/dom/base/test/bug15502_utils.js
index 9d69c12..23f61c4 100644
--- a/dom/base/test/bug15502_utils.js
+++ b/dom/base/test/bug15502_utils.js
@@ -1,11 +1,8 @@
-// Import Task.jsm
-let { Task } = SpecialPowers.Cu.import("resource://gre/modules/Task.jsm");
-
// __listen(target, eventType, timeoutMs, useCapture)__.
// Calls addEventListener on target, with the given eventType.
// Returns a Promise that resolves to an Event object, if the event fires.
// If a timeout occurs, then Promise is rejected with a "Timed out" error.
-// For use with Task.jsm.
+// For use with SpawnTask.js.
let listen = function (target, eventType, timeoutMs, useCapture) {
return new Promise(function (resolve, reject) {
let listenFunction = function (event) {
@@ -13,17 +10,19 @@ let listen = function (target, eventType, timeoutMs, useCapture) {
resolve(event);
};
target.addEventListener(eventType, listenFunction, useCapture);
- setTimeout(() => reject(new Error("Timed out")), timeoutMs);
+ if (timeoutMs) {
+ setTimeout(() => reject(new Error("Timed out")), timeoutMs);
+ }
});
};
// __receiveMessage(source)__.
// Returns an event object for the next message received from source.
-// A Task.jsm coroutine.
+// A SpawnTask.js coroutine.
let receiveMessage = function* (source) {
let event;
do {
- event = yield listen(self, "message", 5000, false);
+ event = yield listen(self, "message", null, false);
} while (event.source !== source);
return event.data;
};
@@ -94,7 +93,7 @@ let stringToBlobURL = function (s) {
// __workerIO(scriptFile, inputString)__.
// Sends inputString for the worker, and waits
// for the worker to return an outputString.
-// Task.jsm coroutine.
+// SpawnTask.js coroutine.
let workerIO = function* (scriptFile, inputString) {
let worker = new Worker(scriptFile);
worker.postMessage(inputString);
diff --git a/dom/base/test/bug15502_worker_blobify.html b/dom/base/test/bug15502_worker_blobify.html
index 3dd7926..7084366 100644
--- a/dom/base/test/bug15502_worker_blobify.html
+++ b/dom/base/test/bug15502_worker_blobify.html
@@ -6,6 +6,7 @@ https://bugs.torproject.org/15502
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Worker blobifier for Tor Browser Bug 15502</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript;version=1.7" src="bug15502_utils.js"></script>
</head>
<body>
@@ -14,7 +15,7 @@ https://bugs.torproject.org/15502
<pre id="test">
<script type="text/javascript;version=1.7">
-Task.spawn(function* () {
+spawnTask(function* () {
sendMessage(window.parent, "ready");
let message = yield receiveMessage(window.parent),
blobURL = yield workerIO("bug15502_worker_blobify.js", message);
diff --git a/dom/base/test/bug15502_worker_deblobify.html b/dom/base/test/bug15502_worker_deblobify.html
index 30ec6b4..4f498f1 100644
--- a/dom/base/test/bug15502_worker_deblobify.html
+++ b/dom/base/test/bug15502_worker_deblobify.html
@@ -6,6 +6,7 @@ https://bugs.torproject.org/15502
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Worker deblobifier for Tor Browser Bug 15502</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript;version=1.7" src="bug15502_utils.js"></script>
</head>
<body>
@@ -14,7 +15,7 @@ https://bugs.torproject.org/15502
<pre id="test">
<script type="text/javascript;version=1.7">
-Task.spawn(function* () {
+spawnTask(function* () {
sendMessage(window.parent, "ready");
let blobURL = yield receiveMessage(window.parent),
result = yield workerIO("bug15502_worker_deblobify.js", blobURL);
diff --git a/dom/base/test/test_tor_bug15502.html b/dom/base/test/test_tor_bug15502.html
index 06bcc1c..18b8459 100644
--- a/dom/base/test/test_tor_bug15502.html
+++ b/dom/base/test/test_tor_bug15502.html
@@ -7,6 +7,7 @@ https://bugs.torproject.org/15502
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Test for Tor Browser Bug 15502</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript;version=1.7" src="bug15502_utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
@@ -17,8 +18,14 @@ https://bugs.torproject.org/15502
<script class="testbody" type="application/javascript;version=1.7">
SimpleTest.waitForExplicitFinish();
-// __prefs__. Import the `Serivces.prefs` object.
-let prefs = SpecialPowers.Cu.import("resource://gre/modules/Services.jsm").Services.prefs;
+// __setPref(key, value)__.
+// Set a pref value asynchronously, returning a prmoise that resolves
+// when it succeeds.
+let setPref = function* (key, value) {
+ return new Promise(function(resolve, reject) {
+ SpecialPowers.pushPrefEnv({"set": [[key, value]]}, resolve);
+ });
+};
// ## Testing constants
let domain1 = "http://example.com",
@@ -47,7 +54,7 @@ let tabIO = function* (domain, child, input) {
// and then attempt to retrieve the object from the blobURL in `domainB`, using
// the page `deblobPage`.
let blobTest = function* (isolationOn, domainA, domainB, blobPage, deblobPage) {
- prefs.setIntPref("privacy.thirdparty.isolate", isolationOn ? 2 : 0);
+ yield setPref("privacy.thirdparty.isolate", isolationOn ? 2 : 0);
let input = "" + Math.random(),
blobURL = yield tabIO(domainA, blobPage, input),
result = yield tabIO(domainB, deblobPage, blobURL),
@@ -71,9 +78,9 @@ let blobTest = function* (isolationOn, domainA, domainB, blobPage, deblobPage) {
// ## The main test
-// Run a Task.jsm coroutine that tests various combinations of domains
+// Run a coroutine that tests various combinations of domains
// methods, and isolation states for reading and writing blob URLs.
-Task.spawn(function* () {
+spawnTask(function* () {
for (let isolate of [false, true]) {
for (let domainB of [domain1, domain2]) {
for (let blob of [page_blob, worker_blob]) {
1
0

[tor-browser/tor-browser-38.1.0esr-5.0-1] Revert "Bug #15502. Isolate blob URLs to first party; no blobURLs in Web Workers"
by mikeperry@torproject.org 28 Jul '15
by mikeperry@torproject.org 28 Jul '15
28 Jul '15
commit b4d97bc75ff672725fd80e0c640748a74c6edc3e
Author: Arthur Edelstein <arthuredelstein(a)gmail.com>
Date: Thu Jul 2 12:54:18 2015 -0700
Revert "Bug #15502. Isolate blob URLs to first party; no blobURLs in Web Workers"
This reverts commit 7a8d11b1ef502688c97d7900c57361c4be6ae13a.
---
.../pdfjs/content/PdfStreamConverter.jsm | 7 +-----
.../extensions/pdfjs/content/build/pdf.worker.js | 9 +-------
dom/base/ThirdPartyUtil.cpp | 9 --------
dom/base/nsHostObjectProtocolHandler.cpp | 23 ++------------------
dom/workers/URL.cpp | 7 ------
netwerk/base/mozIThirdPartyUtil.idl | 14 ------------
6 files changed, 4 insertions(+), 65 deletions(-)
diff --git a/browser/extensions/pdfjs/content/PdfStreamConverter.jsm b/browser/extensions/pdfjs/content/PdfStreamConverter.jsm
index 26515be..11db211 100644
--- a/browser/extensions/pdfjs/content/PdfStreamConverter.jsm
+++ b/browser/extensions/pdfjs/content/PdfStreamConverter.jsm
@@ -250,12 +250,6 @@ ChromeActions.prototype = {
filename = 'document.pdf';
}
var blobUri = data.blobUrl ? NetUtil.newURI(data.blobUrl) : originalUri;
- var netChannel;
- try {
- netChannel = NetUtil.newChannel(blobUri);
- } catch (e) {
- netChannel = NetUtil.newChannel(originalUri);
- }
var extHelperAppSvc =
Cc['@mozilla.org/uriloader/external-helper-app-service;1'].
getService(Ci.nsIExternalHelperAppService);
@@ -263,6 +257,7 @@ ChromeActions.prototype = {
getService(Ci.nsIWindowWatcher).activeWindow;
var docIsPrivate = this.isInPrivateBrowsing();
+ var netChannel = NetUtil.newChannel(blobUri);
if ('nsIPrivateBrowsingChannel' in Ci &&
netChannel instanceof Ci.nsIPrivateBrowsingChannel) {
netChannel.setPrivate(docIsPrivate);
diff --git a/browser/extensions/pdfjs/content/build/pdf.worker.js b/browser/extensions/pdfjs/content/build/pdf.worker.js
index a5dfe2f..c9de2ea 100644
--- a/browser/extensions/pdfjs/content/build/pdf.worker.js
+++ b/browser/extensions/pdfjs/content/build/pdf.worker.js
@@ -1152,14 +1152,7 @@ PDFJS.createObjectURL = (function createObjectURLClosure() {
if (!PDFJS.disableCreateObjectURL &&
typeof URL !== 'undefined' && URL.createObjectURL) {
var blob = PDFJS.createBlob(data, contentType);
- try {
- return URL.createObjectURL(blob);
- } catch(e) {
- // URL.createObjectURL has thrown an error; continue to
- // data schema fallback.
- // TODO: Remove this try-catch when we re-enable
- // createObjectURL in workers.
- }
+ return URL.createObjectURL(blob);
}
var buffer = 'data:' + contentType + ';base64,';
diff --git a/dom/base/ThirdPartyUtil.cpp b/dom/base/ThirdPartyUtil.cpp
index eb09b43..d0aed3a 100644
--- a/dom/base/ThirdPartyUtil.cpp
+++ b/dom/base/ThirdPartyUtil.cpp
@@ -746,12 +746,3 @@ ThirdPartyUtil::GetFirstPartyHostForIsolation(nsIURI *aFirstPartyURI,
aHost.Append("--");
return NS_OK;
}
-
-NS_IMETHODIMP
-ThirdPartyUtil::GetFirstPartyHostFromCaller(nsACString& aHost) {
- nsCOMPtr<nsIURI> uri;
- nsresult rv = GetFirstPartyIsolationURI(nullptr,
- nsContentUtils::GetDocumentFromCaller(), getter_AddRefs(uri));
- NS_ENSURE_SUCCESS(rv, rv);
- return GetFirstPartyHostForIsolation(uri, aHost);
-}
diff --git a/dom/base/nsHostObjectProtocolHandler.cpp b/dom/base/nsHostObjectProtocolHandler.cpp
index 8c440f4..aac33f9 100644
--- a/dom/base/nsHostObjectProtocolHandler.cpp
+++ b/dom/base/nsHostObjectProtocolHandler.cpp
@@ -16,7 +16,6 @@
#include "mozilla/dom/File.h"
#include "mozilla/Preferences.h"
#include "mozilla/LoadInfo.h"
-#include "mozIThirdPartyUtil.h"
using mozilla::dom::FileImpl;
using mozilla::ErrorResult;
@@ -30,20 +29,9 @@ struct DataInfo
nsCOMPtr<nsISupports> mObject;
nsCOMPtr<nsIPrincipal> mPrincipal;
nsCString mStack;
- nsCString mFirstPartyHost;
};
static nsClassHashtable<nsCStringHashKey, DataInfo>* gDataTable;
-static nsCOMPtr<mozIThirdPartyUtil> gThirdPartyUtilService;
-
-static nsCString GetFirstPartyHostFromCaller() {
- if (!gThirdPartyUtilService) {
- gThirdPartyUtilService = do_GetService(THIRDPARTYUTIL_CONTRACTID);
- }
- nsCString host;
- gThirdPartyUtilService->GetFirstPartyHostFromCaller(host);
- return host;
-}
// Memory reporting for the hash table.
namespace mozilla {
@@ -325,8 +313,6 @@ nsHostObjectProtocolHandler::AddDataEntry(const nsACString& aScheme,
info->mObject = aObject;
info->mPrincipal = aPrincipal;
- // Record the first party host that originated this object.
- info->mFirstPartyHost = GetFirstPartyHostFromCaller();
mozilla::BlobURLsReporter::GetJSStackForBlob(info);
gDataTable->Put(aUri, info);
@@ -451,10 +437,7 @@ GetDataObject(nsIURI* aURI)
aURI->GetSpec(spec);
DataInfo* info = GetDataInfo(spec);
- // Deny access to this object if the current first-party host
- // doesn't match the originating first-party host.
- return (info && info->mFirstPartyHost == GetFirstPartyHostFromCaller())
- ? info->mObject : nullptr;
+ return info ? info->mObject : nullptr;
}
// -----------------------------------------------------------------------
@@ -512,9 +495,7 @@ nsHostObjectProtocolHandler::NewChannel2(nsIURI* uri,
DataInfo* info = GetDataInfo(spec);
- // Deny access to this URI if the current first party host
- // doesn't match the first party host when it was created.
- if (!info || (info->mFirstPartyHost != GetFirstPartyHostFromCaller())) {
+ if (!info) {
return NS_ERROR_DOM_BAD_URI;
}
diff --git a/dom/workers/URL.cpp b/dom/workers/URL.cpp
index 2ad1276..fbf6987 100644
--- a/dom/workers/URL.cpp
+++ b/dom/workers/URL.cpp
@@ -889,13 +889,6 @@ URL::CreateObjectURL(const GlobalObject& aGlobal, File& aBlob,
JSContext* cx = aGlobal.Context();
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
- if (!workerPrivate->IsChromeWorker()) {
- workerPrivate->ReportError(cx, "Worker attempted to use createObjectURL; denied.", nullptr);
- NS_NAMED_LITERAL_STRING(argStr, "URL.createObjectURL");
- aRv.ThrowTypeError(MSG_METHOD_THIS_UNWRAPPING_DENIED, &argStr);
- return;
- }
-
nsRefPtr<FileImpl> blobImpl = aBlob.Impl();
MOZ_ASSERT(blobImpl);
diff --git a/netwerk/base/mozIThirdPartyUtil.idl b/netwerk/base/mozIThirdPartyUtil.idl
index a06841d..68a7099 100644
--- a/netwerk/base/mozIThirdPartyUtil.idl
+++ b/netwerk/base/mozIThirdPartyUtil.idl
@@ -262,20 +262,6 @@ interface mozIThirdPartyUtil : nsISupports
*/
AUTF8String getFirstPartyHostForIsolation(in nsIURI aFirstPartyURI);
- /**
- * getFirstPartyHostFromCaller
- *
- * Obtain the host or pseudo-host for the first party URI belonging
- * to the calling document. See getFirstPartyHostForIsolation(...) for
- * examples.
- *
- * @return host or pseudo host.
- *
- * @throws if the calling document's first party URI lacks a host
- * and the scheme is not a whitelisted one for which we
- * generate a pseudo host.
- */
- AUTF8String getFirstPartyHostFromCaller();
};
%{ C++
1
0

[tor-browser/tor-browser-38.1.0esr-5.0-1] Bug #15502. Isolate blob, mediasource & mediastream URLs to first party
by mikeperry@torproject.org 28 Jul '15
by mikeperry@torproject.org 28 Jul '15
28 Jul '15
commit f538052047ad61cf74f926381bc7c41b60fa2a3d
Author: Arthur Edelstein <arthuredelstein(a)gmail.com>
Date: Thu Jul 2 12:56:23 2015 -0700
Bug #15502. Isolate blob, mediasource & mediastream URLs to first party
This patch handles blob URLs created and retrieved in Web Workers.
See also #15703 and #16429.
---
dom/base/ThirdPartyUtil.cpp | 21 ++++++
dom/base/ThirdPartyUtil.h | 12 +++
dom/base/URL.cpp | 32 +++++---
dom/base/moz.build | 1 +
dom/base/nsDocument.cpp | 17 ++++-
dom/base/nsHostObjectProtocolHandler.cpp | 120 ++++++++++++++++++------------
dom/base/nsHostObjectProtocolHandler.h | 15 ++--
dom/fetch/Fetch.cpp | 17 ++++-
dom/fetch/FetchDriver.cpp | 8 +-
dom/fetch/FetchDriver.h | 5 +-
dom/html/HTMLMediaElement.cpp | 17 ++++-
dom/media/MediaResource.cpp | 6 +-
dom/workers/URL.cpp | 21 +++++-
dom/workers/WorkerPrivate.cpp | 22 +++++-
14 files changed, 232 insertions(+), 82 deletions(-)
diff --git a/dom/base/ThirdPartyUtil.cpp b/dom/base/ThirdPartyUtil.cpp
index d0aed3a..e8ec06c 100644
--- a/dom/base/ThirdPartyUtil.cpp
+++ b/dom/base/ThirdPartyUtil.cpp
@@ -33,6 +33,27 @@ static PRLogModuleInfo *gThirdPartyLog;
#undef LOG
#define LOG(args) PR_LOG(gThirdPartyLog, PR_LOG_DEBUG, args)
+// static
+mozIThirdPartyUtil* ThirdPartyUtil::gThirdPartyUtilService = nullptr;
+
+//static
+nsresult
+ThirdPartyUtil::GetFirstPartyHost(nsIChannel* aChannel, nsIDocument* aDocument, nsACString& aResult)
+{
+ if (!gThirdPartyUtilService) {
+ CallGetService(THIRDPARTYUTIL_CONTRACTID, &gThirdPartyUtilService);
+ }
+ nsCOMPtr<nsIURI> isolationURI;
+ nsresult rv = gThirdPartyUtilService->GetFirstPartyIsolationURI(aChannel, aDocument, getter_AddRefs(isolationURI));
+ NS_ENSURE_SUCCESS(rv, rv);
+ if (!isolationURI) {
+ // Isolation is not active.
+ aResult.Truncate();
+ return NS_OK;
+ }
+ return gThirdPartyUtilService->GetFirstPartyHostForIsolation(isolationURI, aResult);
+}
+
nsresult
ThirdPartyUtil::Init()
{
diff --git a/dom/base/ThirdPartyUtil.h b/dom/base/ThirdPartyUtil.h
index c03740e..77e73f7 100644
--- a/dom/base/ThirdPartyUtil.h
+++ b/dom/base/ThirdPartyUtil.h
@@ -24,6 +24,18 @@ public:
nsresult Init();
+ static mozIThirdPartyUtil* gThirdPartyUtilService;
+
+ static nsresult GetFirstPartyHost(nsIChannel* aChannel, nsIDocument* aDocument, nsACString& aResult);
+
+ static nsresult GetFirstPartyHost(nsIChannel* aChannel, nsACString& aResult) {
+ return GetFirstPartyHost(aChannel, nullptr, aResult);
+ }
+
+ static nsresult GetFirstPartyHost(nsIDocument* aDocument, nsACString& aResult) {
+ return GetFirstPartyHost(nullptr, aDocument, aResult);
+ }
+
private:
~ThirdPartyUtil() {}
diff --git a/dom/base/URL.cpp b/dom/base/URL.cpp
index fea8dd2..1931c28 100644
--- a/dom/base/URL.cpp
+++ b/dom/base/URL.cpp
@@ -17,6 +17,7 @@
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "nsIURL.h"
+#include "ThirdPartyUtil.h"
namespace mozilla {
namespace dom {
@@ -152,12 +153,6 @@ URL::CreateObjectURLInternal(const GlobalObject& aGlobal, nsISupports* aObject,
nsCOMPtr<nsIPrincipal> principal = nsContentUtils::ObjectPrincipal(aGlobal.Get());
nsCString url;
- nsresult rv = nsHostObjectProtocolHandler::AddDataEntry(aScheme, aObject,
- principal, url);
- if (NS_FAILED(rv)) {
- aError.Throw(rv);
- return;
- }
nsCOMPtr<nsPIDOMWindow> w = do_QueryInterface(aGlobal.GetAsSupports());
nsGlobalWindow* window = static_cast<nsGlobalWindow*>(w.get());
@@ -172,6 +167,18 @@ URL::CreateObjectURLInternal(const GlobalObject& aGlobal, nsISupports* aObject,
nsIDocument* doc = window->GetExtantDoc();
if (doc) {
+ nsCString isolationKey;
+ nsresult rv = ThirdPartyUtil::GetFirstPartyHost(doc, isolationKey);
+ if (NS_FAILED(rv)) {
+ aError.Throw(rv);
+ return;
+ }
+ rv = nsHostObjectProtocolHandler::AddDataEntry(aScheme, aObject,
+ principal, isolationKey, url);
+ if (NS_FAILED(rv)) {
+ aError.Throw(rv);
+ return;
+ }
doc->RegisterHostObjectUri(url);
}
}
@@ -193,10 +200,17 @@ URL::RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aURL)
nsCOMPtr<nsPIDOMWindow> w = do_QueryInterface(aGlobal.GetAsSupports());
nsGlobalWindow* window = static_cast<nsGlobalWindow*>(w.get());
- if (window && window->GetExtantDoc()) {
- window->GetExtantDoc()->UnregisterHostObjectUri(asciiurl);
+ if (window) {
+ nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
+ if (doc) {
+ doc->UnregisterHostObjectUri(asciiurl);
+ nsCString isolationKey;
+ nsresult rv = ThirdPartyUtil::GetFirstPartyHost(doc, isolationKey);
+ if (NS_SUCCEEDED(rv)) {
+ nsHostObjectProtocolHandler::RemoveDataEntry(asciiurl, isolationKey);
+ }
+ }
}
- nsHostObjectProtocolHandler::RemoveDataEntry(asciiurl);
}
}
diff --git a/dom/base/moz.build b/dom/base/moz.build
index 27de87b..1d92f94 100644
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -194,6 +194,7 @@ EXPORTS.mozilla.dom += [
'StyleSheetList.h',
'SubtleCrypto.h',
'Text.h',
+ 'ThirdPartyUtil.h',
'TreeWalker.h',
'URL.h',
'URLSearchParams.h',
diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
index 47f611e..e5f0a2f2 100644
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -226,6 +226,7 @@
#include "nsLocation.h"
#include "mozilla/dom/FontFaceSet.h"
#include "mozilla/dom/BoxObject.h"
+#include "ThirdPartyUtil.h"
#ifdef MOZ_MEDIA_NAVIGATOR
#include "mozilla/MediaManager.h"
@@ -1776,8 +1777,12 @@ nsDocument::~nsDocument()
mPendingTitleChangeEvent.Revoke();
- for (uint32_t i = 0; i < mHostObjectURIs.Length(); ++i) {
- nsHostObjectProtocolHandler::RemoveDataEntry(mHostObjectURIs[i]);
+ nsCString isolationKey;
+ nsresult rv = ThirdPartyUtil::GetFirstPartyHost(this, isolationKey);
+ if (NS_SUCCEEDED(rv)) {
+ for (uint32_t i = 0; i < mHostObjectURIs.Length(); ++i) {
+ nsHostObjectProtocolHandler::RemoveDataEntry(mHostObjectURIs[i], isolationKey);
+ }
}
// We don't want to leave residual locks on images. Make sure we're in an
@@ -2156,8 +2161,12 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCSSLoader)
}
- for (uint32_t i = 0; i < tmp->mHostObjectURIs.Length(); ++i) {
- nsHostObjectProtocolHandler::RemoveDataEntry(tmp->mHostObjectURIs[i]);
+ nsCString isolationKey;
+ nsresult rv = ThirdPartyUtil::GetFirstPartyHost(tmp, isolationKey);
+ if (NS_SUCCEEDED(rv)) {
+ for (uint32_t i = 0; i < tmp->mHostObjectURIs.Length(); ++i) {
+ nsHostObjectProtocolHandler::RemoveDataEntry(tmp->mHostObjectURIs[i], isolationKey);
+ }
}
// We own only the items in mDOMMediaQueryLists that have listeners;
diff --git a/dom/base/nsHostObjectProtocolHandler.cpp b/dom/base/nsHostObjectProtocolHandler.cpp
index aac33f9..429938b 100644
--- a/dom/base/nsHostObjectProtocolHandler.cpp
+++ b/dom/base/nsHostObjectProtocolHandler.cpp
@@ -16,6 +16,7 @@
#include "mozilla/dom/File.h"
#include "mozilla/Preferences.h"
#include "mozilla/LoadInfo.h"
+#include "ThirdPartyUtil.h"
using mozilla::dom::FileImpl;
using mozilla::ErrorResult;
@@ -29,6 +30,7 @@ struct DataInfo
nsCOMPtr<nsISupports> mObject;
nsCOMPtr<nsIPrincipal> mPrincipal;
nsCString mStack;
+ nsCString mFirstPartyHost;
};
static nsClassHashtable<nsCStringHashKey, DataInfo>* gDataTable;
@@ -298,6 +300,7 @@ nsresult
nsHostObjectProtocolHandler::AddDataEntry(const nsACString& aScheme,
nsISupports* aObject,
nsIPrincipal* aPrincipal,
+ const nsACString& aIsolationKey,
nsACString& aUri)
{
Init();
@@ -313,28 +316,55 @@ nsHostObjectProtocolHandler::AddDataEntry(const nsACString& aScheme,
info->mObject = aObject;
info->mPrincipal = aPrincipal;
+ // Record the first party host that originated this object.
+ info->mFirstPartyHost = aIsolationKey;
mozilla::BlobURLsReporter::GetJSStackForBlob(info);
gDataTable->Put(aUri, info);
return NS_OK;
}
+static DataInfo*
+GetDataInfo(const nsACString& aUri)
+{
+ if (!gDataTable) {
+ return nullptr;
+ }
+
+ DataInfo* res;
+ nsCString uriIgnoringRef;
+ int32_t hashPos = aUri.FindChar('#');
+ if (hashPos < 0) {
+ uriIgnoringRef = aUri;
+ }
+ else {
+ uriIgnoringRef = StringHead(aUri, hashPos);
+ }
+ gDataTable->Get(uriIgnoringRef, &res);
+
+ return res;
+}
+
void
-nsHostObjectProtocolHandler::RemoveDataEntry(const nsACString& aUri)
+nsHostObjectProtocolHandler::RemoveDataEntry(const nsACString& aUri,
+ const nsACString& aIsolationKey)
{
if (gDataTable) {
- nsCString uriIgnoringRef;
- int32_t hashPos = aUri.FindChar('#');
- if (hashPos < 0) {
- uriIgnoringRef = aUri;
- }
- else {
- uriIgnoringRef = StringHead(aUri, hashPos);
- }
- gDataTable->Remove(uriIgnoringRef);
- if (gDataTable->Count() == 0) {
- delete gDataTable;
- gDataTable = nullptr;
+ DataInfo* info = GetDataInfo(aUri);
+ if (info->mFirstPartyHost == aIsolationKey) {
+ nsCString uriIgnoringRef;
+ int32_t hashPos = aUri.FindChar('#');
+ if (hashPos < 0) {
+ uriIgnoringRef = aUri;
+ }
+ else {
+ uriIgnoringRef = StringHead(aUri, hashPos);
+ }
+ gDataTable->Remove(uriIgnoringRef);
+ if (gDataTable->Count() == 0) {
+ delete gDataTable;
+ gDataTable = nullptr;
+ }
}
}
}
@@ -375,27 +405,6 @@ nsHostObjectProtocolHandler::GenerateURIString(const nsACString &aScheme,
return NS_OK;
}
-static DataInfo*
-GetDataInfo(const nsACString& aUri)
-{
- if (!gDataTable) {
- return nullptr;
- }
-
- DataInfo* res;
- nsCString uriIgnoringRef;
- int32_t hashPos = aUri.FindChar('#');
- if (hashPos < 0) {
- uriIgnoringRef = aUri;
- }
- else {
- uriIgnoringRef = StringHead(aUri, hashPos);
- }
- gDataTable->Get(uriIgnoringRef, &res);
-
- return res;
-}
-
nsIPrincipal*
nsHostObjectProtocolHandler::GetDataEntryPrincipal(const nsACString& aUri)
{
@@ -431,13 +440,16 @@ nsHostObjectProtocolHandler::Traverse(const nsACString& aUri,
}
static nsISupports*
-GetDataObject(nsIURI* aURI)
+GetDataObject(nsIURI* aURI, const nsACString& aIsolationKey)
{
nsCString spec;
aURI->GetSpec(spec);
DataInfo* info = GetDataInfo(spec);
- return info ? info->mObject : nullptr;
+ // Deny access to this object if the current first-party host
+ // doesn't match the originating first-party host.
+ return (info && info->mFirstPartyHost == aIsolationKey)
+ ? info->mObject : nullptr;
}
// -----------------------------------------------------------------------
@@ -493,9 +505,19 @@ nsHostObjectProtocolHandler::NewChannel2(nsIURI* uri,
nsCString spec;
uri->GetSpec(spec);
- DataInfo* info = GetDataInfo(spec);
+ nsCString firstPartyHost;
+ if (aLoadInfo) {
+ nsCOMPtr<nsIDOMDocument> loadingDOMDocument;
+ aLoadInfo->GetLoadingDocument(getter_AddRefs(loadingDOMDocument));
+ nsCOMPtr<nsIDocument> loadingDocument = do_QueryInterface(loadingDOMDocument);
+ nsresult rv = ThirdPartyUtil::GetFirstPartyHost(loadingDocument, firstPartyHost);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
- if (!info) {
+ DataInfo* info = GetDataInfo(spec);
+ // Deny access to this URI if the current first party host
+ // doesn't match the first party host when it was created.
+ if (!info || (info->mFirstPartyHost != firstPartyHost)) {
return NS_ERROR_DOM_BAD_URI;
}
@@ -594,13 +616,13 @@ nsFontTableProtocolHandler::GetScheme(nsACString &result)
}
nsresult
-NS_GetBlobForBlobURI(nsIURI* aURI, FileImpl** aBlob)
+NS_GetBlobForBlobURI(nsIURI* aURI, const nsACString& aIsolationKey, FileImpl** aBlob)
{
NS_ASSERTION(IsBlobURI(aURI), "Only call this with blob URIs");
*aBlob = nullptr;
- nsCOMPtr<FileImpl> blob = do_QueryInterface(GetDataObject(aURI));
+ nsCOMPtr<FileImpl> blob = do_QueryInterface(GetDataObject(aURI, aIsolationKey));
if (!blob) {
return NS_ERROR_DOM_BAD_URI;
}
@@ -610,10 +632,12 @@ NS_GetBlobForBlobURI(nsIURI* aURI, FileImpl** aBlob)
}
nsresult
-NS_GetStreamForBlobURI(nsIURI* aURI, nsIInputStream** aStream)
+NS_GetStreamForBlobURI(nsIURI* aURI,
+ const nsACString& aIsolationKey,
+ nsIInputStream** aStream)
{
nsRefPtr<FileImpl> blobImpl;
- nsresult rv = NS_GetBlobForBlobURI(aURI, getter_AddRefs(blobImpl));
+ nsresult rv = NS_GetBlobForBlobURI(aURI, aIsolationKey, getter_AddRefs(blobImpl));
if (NS_FAILED(rv)) {
return rv;
}
@@ -622,11 +646,13 @@ NS_GetStreamForBlobURI(nsIURI* aURI, nsIInputStream** aStream)
}
nsresult
-NS_GetStreamForMediaStreamURI(nsIURI* aURI, mozilla::DOMMediaStream** aStream)
+NS_GetStreamForMediaStreamURI(nsIURI* aURI,
+ const nsACString& aIsolationKey,
+ mozilla::DOMMediaStream** aStream)
{
NS_ASSERTION(IsMediaStreamURI(aURI), "Only call this with mediastream URIs");
- nsISupports* dataObject = GetDataObject(aURI);
+ nsISupports* dataObject = GetDataObject(aURI, aIsolationKey);
if (!dataObject) {
return NS_ERROR_DOM_BAD_URI;
}
@@ -669,13 +695,15 @@ nsFontTableProtocolHandler::NewURI(const nsACString& aSpec,
}
nsresult
-NS_GetSourceForMediaSourceURI(nsIURI* aURI, mozilla::dom::MediaSource** aSource)
+NS_GetSourceForMediaSourceURI(nsIURI* aURI,
+ const nsACString& aIsolationKey,
+ mozilla::dom::MediaSource** aSource)
{
NS_ASSERTION(IsMediaSourceURI(aURI), "Only call this with mediasource URIs");
*aSource = nullptr;
- nsCOMPtr<mozilla::dom::MediaSource> source = do_QueryInterface(GetDataObject(aURI));
+ nsCOMPtr<mozilla::dom::MediaSource> source = do_QueryInterface(GetDataObject(aURI, aIsolationKey));
if (!source) {
return NS_ERROR_DOM_BAD_URI;
}
diff --git a/dom/base/nsHostObjectProtocolHandler.h b/dom/base/nsHostObjectProtocolHandler.h
index 977e5e0..e335886 100644
--- a/dom/base/nsHostObjectProtocolHandler.h
+++ b/dom/base/nsHostObjectProtocolHandler.h
@@ -53,8 +53,9 @@ public:
static nsresult AddDataEntry(const nsACString& aScheme,
nsISupports* aObject,
nsIPrincipal* aPrincipal,
+ const nsACString& aIsolationKey,
nsACString& aUri);
- static void RemoveDataEntry(const nsACString& aUri);
+ static void RemoveDataEntry(const nsACString& aUri, const nsACString& aIsolationKey);
static nsIPrincipal* GetDataEntryPrincipal(const nsACString& aUri);
static void Traverse(const nsACString& aUri, nsCycleCollectionTraversalCallback& aCallback);
@@ -121,16 +122,20 @@ inline bool IsFontTableURI(nsIURI* aUri)
}
extern nsresult
-NS_GetBlobForBlobURI(nsIURI* aURI, mozilla::dom::FileImpl** aBlob);
+NS_GetBlobForBlobURI(nsIURI* aURI, const nsACString& aIsolationKey,
+ mozilla::dom::FileImpl** aBlob);
extern nsresult
-NS_GetStreamForBlobURI(nsIURI* aURI, nsIInputStream** aStream);
+NS_GetStreamForBlobURI(nsIURI* aURI, const nsACString& aIsolationKey,
+ nsIInputStream** aStream);
extern nsresult
-NS_GetStreamForMediaStreamURI(nsIURI* aURI, mozilla::DOMMediaStream** aStream);
+NS_GetStreamForMediaStreamURI(nsIURI* aURI, const nsACString& aIsolationKey,
+ mozilla::DOMMediaStream** aStream);
extern nsresult
-NS_GetSourceForMediaSourceURI(nsIURI* aURI, mozilla::dom::MediaSource** aSource);
+NS_GetSourceForMediaSourceURI(nsIURI* aURI, const nsACString& aIsolationKey,
+ mozilla::dom::MediaSource** aSource);
#define NS_BLOBPROTOCOLHANDLER_CID \
{ 0xb43964aa, 0xa078, 0x44b2, \
diff --git a/dom/fetch/Fetch.cpp b/dom/fetch/Fetch.cpp
index b84393e..9a53555 100644
--- a/dom/fetch/Fetch.cpp
+++ b/dom/fetch/Fetch.cpp
@@ -27,6 +27,7 @@
#include "mozilla/dom/Request.h"
#include "mozilla/dom/Response.h"
#include "mozilla/dom/ScriptSettings.h"
+#include "mozilla/dom/ThirdPartyUtil.h"
#include "mozilla/dom/URLSearchParams.h"
#include "InternalRequest.h"
@@ -174,13 +175,18 @@ public:
nsCOMPtr<nsIPrincipal> principal = mResolver->GetWorkerPrivate()->GetPrincipal();
nsCOMPtr<nsILoadGroup> loadGroup = mResolver->GetWorkerPrivate()->GetLoadGroup();
- nsRefPtr<FetchDriver> fetch = new FetchDriver(mRequest, principal, loadGroup);
nsIDocument* doc = mResolver->GetWorkerPrivate()->GetDocument();
+ nsCString isolationKey;
+ nsresult rv = ThirdPartyUtil::GetFirstPartyHost(doc, isolationKey);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ return rv;
+ }
+ nsRefPtr<FetchDriver> fetch = new FetchDriver(mRequest, principal, isolationKey, loadGroup);
if (doc) {
fetch->SetReferrerPolicy(doc->GetReferrerPolicy());
}
- nsresult rv = fetch->Fetch(mResolver);
+ rv = fetch->Fetch(mResolver);
// Right now we only support async fetch, which should never directly fail.
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@@ -230,10 +236,15 @@ FetchRequest(nsIGlobalObject* aGlobal, const RequestOrUSVString& aInput,
return nullptr;
}
+ nsCString isolationKey;
+ nsresult rv = ThirdPartyUtil::GetFirstPartyHost(doc, isolationKey);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ return nullptr;
+ }
nsRefPtr<MainThreadFetchResolver> resolver = new MainThreadFetchResolver(p);
nsCOMPtr<nsILoadGroup> loadGroup = doc->GetDocumentLoadGroup();
nsRefPtr<FetchDriver> fetch =
- new FetchDriver(r, doc->NodePrincipal(), loadGroup);
+ new FetchDriver(r, doc->NodePrincipal(), isolationKey, loadGroup);
fetch->SetReferrerPolicy(doc->GetReferrerPolicy());
aRv = fetch->Fetch(resolver);
if (NS_WARN_IF(aRv.Failed())) {
diff --git a/dom/fetch/FetchDriver.cpp b/dom/fetch/FetchDriver.cpp
index ad54daf..b57141c 100644
--- a/dom/fetch/FetchDriver.cpp
+++ b/dom/fetch/FetchDriver.cpp
@@ -28,6 +28,7 @@
#include "Fetch.h"
#include "InternalRequest.h"
#include "InternalResponse.h"
+#include "mozilla/dom/ThirdPartyUtil.h"
namespace mozilla {
namespace dom {
@@ -36,9 +37,12 @@ NS_IMPL_ISUPPORTS(FetchDriver,
nsIStreamListener, nsIChannelEventSink, nsIInterfaceRequestor,
nsIAsyncVerifyRedirectCallback)
-FetchDriver::FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal,
+FetchDriver::FetchDriver(InternalRequest* aRequest,
+ nsIPrincipal* aPrincipal,
+ const nsACString& aIsolationKey,
nsILoadGroup* aLoadGroup)
: mPrincipal(aPrincipal)
+ , mIsolationKey(aIsolationKey)
, mLoadGroup(aLoadGroup)
, mRequest(aRequest)
, mFetchRecursionCount(0)
@@ -187,7 +191,7 @@ FetchDriver::BasicFetch()
if (scheme.LowerCaseEqualsLiteral("blob")) {
nsRefPtr<FileImpl> blobImpl;
- rv = NS_GetBlobForBlobURI(uri, getter_AddRefs(blobImpl));
+ rv = NS_GetBlobForBlobURI(uri, mIsolationKey, getter_AddRefs(blobImpl));
FileImpl* blob = static_cast<FileImpl*>(blobImpl.get());
if (NS_WARN_IF(NS_FAILED(rv))) {
FailWithNetworkError();
diff --git a/dom/fetch/FetchDriver.h b/dom/fetch/FetchDriver.h
index d58224209..c835149 100644
--- a/dom/fetch/FetchDriver.h
+++ b/dom/fetch/FetchDriver.h
@@ -53,7 +53,9 @@ public:
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
- explicit FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal,
+ explicit FetchDriver(InternalRequest* aRequest,
+ nsIPrincipal* aPrincipal,
+ const nsACString& isolationKey,
nsILoadGroup* aLoadGroup);
NS_IMETHOD Fetch(FetchDriverObserver* aObserver);
@@ -67,6 +69,7 @@ public:
private:
nsCOMPtr<nsIPrincipal> mPrincipal;
+ nsAutoCString mIsolationKey;
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsRefPtr<InternalRequest> mRequest;
nsRefPtr<InternalResponse> mResponse;
diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp
index 41a1505..d80cfff 100644
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -90,6 +90,7 @@
#include "ImageContainer.h"
#include "nsRange.h"
#include <algorithm>
+#include "ThirdPartyUtil.h"
#ifdef PR_LOGGING
static PRLogModuleInfo* gMediaElementLog;
@@ -521,7 +522,11 @@ HTMLMediaElement::GetMozMediaSourceObject() const
{
nsRefPtr<MediaSource> source;
if (mLoadingSrc && IsMediaSourceURI(mLoadingSrc)) {
- NS_GetSourceForMediaSourceURI(mLoadingSrc, getter_AddRefs(source));
+ nsCString isolationKey;
+ nsresult rv = ThirdPartyUtil::GetFirstPartyHost(GetOwnerDocument(), isolationKey);
+ if (NS_SUCCEEDED(rv)) {
+ NS_GetSourceForMediaSourceURI(mLoadingSrc, isolationKey, getter_AddRefs(source));
+ }
}
return source.forget();
}
@@ -1191,7 +1196,10 @@ nsresult HTMLMediaElement::LoadResource()
if (IsMediaStreamURI(mLoadingSrc)) {
nsRefPtr<DOMMediaStream> stream;
- rv = NS_GetStreamForMediaStreamURI(mLoadingSrc, getter_AddRefs(stream));
+ nsCString isolationKey;
+ rv = ThirdPartyUtil::GetFirstPartyHost(GetOwnerDocument(), isolationKey);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = NS_GetStreamForMediaStreamURI(mLoadingSrc, isolationKey, getter_AddRefs(stream));
if (NS_FAILED(rv)) {
nsCString specUTF8;
mLoadingSrc->GetSpec(specUTF8);
@@ -1206,7 +1214,10 @@ nsresult HTMLMediaElement::LoadResource()
if (IsMediaSourceURI(mLoadingSrc)) {
nsRefPtr<MediaSource> source;
- rv = NS_GetSourceForMediaSourceURI(mLoadingSrc, getter_AddRefs(source));
+ nsCString isolationKey;
+ rv = ThirdPartyUtil::GetFirstPartyHost(GetOwnerDocument(), isolationKey);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = NS_GetSourceForMediaSourceURI(mLoadingSrc, isolationKey, getter_AddRefs(source));
if (NS_FAILED(rv)) {
nsCString specUTF8;
mLoadingSrc->GetSpec(specUTF8);
diff --git a/dom/media/MediaResource.cpp b/dom/media/MediaResource.cpp
index 956776c..618b10a 100644
--- a/dom/media/MediaResource.cpp
+++ b/dom/media/MediaResource.cpp
@@ -32,6 +32,7 @@
#include <algorithm>
#include "nsProxyRelease.h"
#include "nsIContentPolicy.h"
+#include "mozilla/dom/ThirdPartyUtil.h"
#ifdef PR_LOGGING
PRLogModuleInfo* gMediaResourceLog;
@@ -1365,7 +1366,10 @@ nsresult FileMediaResource::Open(nsIStreamListener** aStreamListener)
rv = NS_NewLocalFileInputStream(getter_AddRefs(mInput), file);
} else if (IsBlobURI(mURI)) {
- rv = NS_GetStreamForBlobURI(mURI, getter_AddRefs(mInput));
+ nsCString isolationKey;
+ rv = ThirdPartyUtil::GetFirstPartyHost(mChannel, isolationKey);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = NS_GetStreamForBlobURI(mURI, isolationKey, getter_AddRefs(mInput));
}
} else {
// Ensure that we never load a local file from some page on a
diff --git a/dom/workers/URL.cpp b/dom/workers/URL.cpp
index fbf6987..1eda4fd 100644
--- a/dom/workers/URL.cpp
+++ b/dom/workers/URL.cpp
@@ -24,6 +24,7 @@
#include "WorkerPrivate.h"
#include "WorkerRunnable.h"
+#include "ThirdPartyUtil.h"
BEGIN_WORKERS_NAMESPACE
using mozilla::dom::GlobalObject;
@@ -140,10 +141,17 @@ public:
principal = mWorkerPrivate->GetPrincipal();
}
+ nsCString firstPartyHost;
+ nsresult rv = ThirdPartyUtil::GetFirstPartyHost(doc, firstPartyHost);
+ if (NS_FAILED(rv)) {
+ NS_WARNING("Isolation failed; blob URL creation denied.");
+ return false;
+ }
+
nsCString url;
- nsresult rv = nsHostObjectProtocolHandler::AddDataEntry(
+ rv = nsHostObjectProtocolHandler::AddDataEntry(
NS_LITERAL_CSTRING(BLOBURI_SCHEME),
- mBlobImpl, principal, url);
+ mBlobImpl, principal, firstPartyHost, url);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to add data entry for the blob!");
@@ -209,8 +217,13 @@ public:
if (doc) {
doc->UnregisterHostObjectUri(url);
}
-
- nsHostObjectProtocolHandler::RemoveDataEntry(url);
+ nsCString isolationKey;
+ nsresult rv = ThirdPartyUtil::GetFirstPartyHost(doc, isolationKey);
+ if (NS_FAILED(rv)) {
+ NS_WARNING("Isolation failed; blob removal denied.");
+ return false;
+ }
+ nsHostObjectProtocolHandler::RemoveDataEntry(url, isolationKey);
}
if (!window) {
diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
index 0d4702d..d998471 100644
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -99,6 +99,7 @@
#include "WorkerRunnable.h"
#include "WorkerScope.h"
#include "WorkerThread.h"
+#include "ThirdPartyUtil.h"
#ifdef XP_WIN
#undef PostMessage
@@ -708,14 +709,17 @@ class MainThreadReleaseRunnable final : public nsRunnable
nsTArray<nsCOMPtr<nsISupports>> mDoomed;
nsTArray<nsCString> mHostObjectURIs;
nsCOMPtr<nsILoadGroup> mLoadGroupToCancel;
+ nsRefPtr<WorkerPrivate> mWorkerPrivate;
public:
MainThreadReleaseRunnable(nsTArray<nsCOMPtr<nsISupports>>& aDoomed,
nsTArray<nsCString>& aHostObjectURIs,
+ WorkerPrivate* aWorkerPrivate,
nsCOMPtr<nsILoadGroup>& aLoadGroupToCancel)
{
mDoomed.SwapElements(aDoomed);
mHostObjectURIs.SwapElements(aHostObjectURIs);
+ mWorkerPrivate = aWorkerPrivate;
mLoadGroupToCancel.swap(aLoadGroupToCancel);
}
@@ -731,8 +735,17 @@ public:
mDoomed.Clear();
- for (uint32_t index = 0; index < mHostObjectURIs.Length(); index++) {
- nsHostObjectProtocolHandler::RemoveDataEntry(mHostObjectURIs[index]);
+ nsCOMPtr<nsIDocument> doc;
+ nsCOMPtr<nsPIDOMWindow> window = mWorkerPrivate->GetWindow();
+ if (window) {
+ doc = window->GetExtantDoc();
+ }
+ nsCString isolationKey;
+ nsresult rv = ThirdPartyUtil::GetFirstPartyHost(doc, isolationKey);
+ if (NS_SUCCEEDED(rv)) {
+ for (uint32_t index = 0; index < mHostObjectURIs.Length(); index++) {
+ nsHostObjectProtocolHandler::RemoveDataEntry(mHostObjectURIs[index], isolationKey);
+ }
}
return NS_OK;
@@ -782,7 +795,8 @@ private:
mFinishedWorker->StealHostObjectURIs(hostObjectURIs);
nsRefPtr<MainThreadReleaseRunnable> runnable =
- new MainThreadReleaseRunnable(doomed, hostObjectURIs, loadGroupToCancel);
+ new MainThreadReleaseRunnable(doomed, hostObjectURIs,
+ aWorkerPrivate, loadGroupToCancel);
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
NS_WARNING("Failed to dispatch, going to leak!");
}
@@ -840,7 +854,7 @@ private:
mFinishedWorker->StealHostObjectURIs(hostObjectURIs);
nsRefPtr<MainThreadReleaseRunnable> runnable =
- new MainThreadReleaseRunnable(doomed, hostObjectURIs, loadGroupToCancel);
+ new MainThreadReleaseRunnable(doomed, hostObjectURIs, mFinishedWorker, loadGroupToCancel);
if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) {
NS_WARNING("Failed to dispatch, going to leak!");
}
1
0