Merge inbound to central, a=merge
authorWes Kocher <wkocher@mozilla.com>
Thu, 12 Jan 2017 16:03:18 -0800
changeset 329196 b1c31c4a0a678194931779e0f13fba7b508eb109
parent 329195 721c28b39396010388fcab52459e98435ee8b33e (current diff)
parent 329190 81159dae56440e1f412656b7f927d4c503d05384 (diff)
child 329197 1cd2d1992f8a31a3ce92040c725b0787dc336bc2
child 329249 b371ef382f1a65fc2699c741ca9b4833ce56b77d
push id36011
push userkwierso@gmail.com
push dateFri, 13 Jan 2017 00:21:14 +0000
treeherderautoland@1cd2d1992f8a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge inbound to central, a=merge MozReview-Commit-ID: JupSuUl7bTn
browser/app/profile/firefox.js
browser/themes/shared/notification-icons.inc.css
dom/animation/test/crashtests/crashtests.list
layout/reftests/w3c-css/submitted/reftest.list
media/libvpx/1237848-check-lookahead-ctx.patch
media/libvpx/bug1137614.patch
media/libvpx/cast-char-to-uint-before-shift.patch
media/libvpx/clamp-abs-QIndex.patch
media/libvpx/clamp_abs_lvl_seg.patch
media/libvpx/clang-cl.patch
media/libvpx/config/generic/vp8_rtcd.h
media/libvpx/config/generic/vp9_rtcd.h
media/libvpx/config/generic/vpx_dsp_rtcd.h
media/libvpx/config/generic/vpx_scale_rtcd.h
media/libvpx/config/linux/arm/vp8_rtcd.h
media/libvpx/config/linux/arm/vp9_rtcd.h
media/libvpx/config/linux/arm/vpx_dsp_rtcd.h
media/libvpx/config/linux/arm/vpx_scale_rtcd.h
media/libvpx/config/linux/ia32/vp8_rtcd.h
media/libvpx/config/linux/ia32/vpx_dsp_rtcd.h
media/libvpx/config/linux/ia32/vpx_scale_rtcd.h
media/libvpx/config/linux/x64/vp8_rtcd.h
media/libvpx/config/linux/x64/vpx_dsp_rtcd.h
media/libvpx/config/linux/x64/vpx_scale_rtcd.h
media/libvpx/config/mac/ia32/vp8_rtcd.h
media/libvpx/config/mac/ia32/vpx_scale_rtcd.h
media/libvpx/config/mac/x64/vp8_rtcd.h
media/libvpx/config/mac/x64/vpx_dsp_rtcd.h
media/libvpx/config/mac/x64/vpx_scale_rtcd.h
media/libvpx/config/win/ia32/vp8_rtcd.h
media/libvpx/config/win/ia32/vpx_scale_rtcd.h
media/libvpx/config/win/x64/vp8_rtcd.h
media/libvpx/config/win/x64/vpx_dsp_rtcd.h
media/libvpx/config/win/x64/vpx_scale_rtcd.h
media/libvpx/input_frame_validation.patch
media/libvpx/input_frame_validation_vp9.patch
media/libvpx/libvpx/LICENSE
media/libvpx/libvpx/PATENTS
media/libvpx/libvpx/build/make/ads2gas.pl
media/libvpx/libvpx/build/make/thumb.pm
media/libvpx/libvpx/third_party/x86inc/x86inc.asm
media/libvpx/libvpx/vp8/common/alloccommon.c
media/libvpx/libvpx/vp8/common/alloccommon.h
media/libvpx/libvpx/vp8/common/arm/armv6/bilinearfilter_v6.asm
media/libvpx/libvpx/vp8/common/arm/armv6/copymem16x16_v6.asm
media/libvpx/libvpx/vp8/common/arm/armv6/copymem8x4_v6.asm
media/libvpx/libvpx/vp8/common/arm/armv6/copymem8x8_v6.asm
media/libvpx/libvpx/vp8/common/arm/armv6/dc_only_idct_add_v6.asm
media/libvpx/libvpx/vp8/common/arm/armv6/dequant_idct_v6.asm
media/libvpx/libvpx/vp8/common/arm/armv6/dequantize_v6.asm
media/libvpx/libvpx/vp8/common/arm/armv6/filter_v6.asm
media/libvpx/libvpx/vp8/common/arm/armv6/idct_blk_v6.c
media/libvpx/libvpx/vp8/common/arm/armv6/idct_v6.asm
media/libvpx/libvpx/vp8/common/arm/armv6/intra4x4_predict_v6.asm
media/libvpx/libvpx/vp8/common/arm/armv6/iwalsh_v6.asm
media/libvpx/libvpx/vp8/common/arm/armv6/loopfilter_v6.asm
media/libvpx/libvpx/vp8/common/arm/armv6/simpleloopfilter_v6.asm
media/libvpx/libvpx/vp8/common/arm/armv6/sixtappredict8x4_v6.asm
media/libvpx/libvpx/vp8/common/arm/armv6/vp8_variance_halfpixvar16x16_h_armv6.asm
media/libvpx/libvpx/vp8/common/arm/armv6/vp8_variance_halfpixvar16x16_hv_armv6.asm
media/libvpx/libvpx/vp8/common/arm/armv6/vp8_variance_halfpixvar16x16_v_armv6.asm
media/libvpx/libvpx/vp8/common/arm/bilinearfilter_arm.c
media/libvpx/libvpx/vp8/common/arm/bilinearfilter_arm.h
media/libvpx/libvpx/vp8/common/arm/dequantize_arm.c
media/libvpx/libvpx/vp8/common/arm/filter_arm.c
media/libvpx/libvpx/vp8/common/arm/loopfilter_arm.c
media/libvpx/libvpx/vp8/common/arm/neon/bilinearpredict_neon.c
media/libvpx/libvpx/vp8/common/arm/neon/copymem_neon.c
media/libvpx/libvpx/vp8/common/arm/neon/dc_only_idct_add_neon.c
media/libvpx/libvpx/vp8/common/arm/neon/dequant_idct_neon.c
media/libvpx/libvpx/vp8/common/arm/neon/dequantizeb_neon.c
media/libvpx/libvpx/vp8/common/arm/neon/idct_blk_neon.c
media/libvpx/libvpx/vp8/common/arm/neon/idct_dequant_0_2x_neon.c
media/libvpx/libvpx/vp8/common/arm/neon/idct_dequant_full_2x_neon.c
media/libvpx/libvpx/vp8/common/arm/neon/iwalsh_neon.c
media/libvpx/libvpx/vp8/common/arm/neon/loopfilter_neon.c
media/libvpx/libvpx/vp8/common/arm/neon/loopfiltersimplehorizontaledge_neon.c
media/libvpx/libvpx/vp8/common/arm/neon/loopfiltersimpleverticaledge_neon.c
media/libvpx/libvpx/vp8/common/arm/neon/mbloopfilter_neon.c
media/libvpx/libvpx/vp8/common/arm/neon/reconintra_neon.c
media/libvpx/libvpx/vp8/common/arm/neon/shortidct4x4llm_neon.c
media/libvpx/libvpx/vp8/common/arm/neon/sixtappredict_neon.c
media/libvpx/libvpx/vp8/common/arm/neon/vp8_subpixelvariance_neon.c
media/libvpx/libvpx/vp8/common/arm/variance_arm.c
media/libvpx/libvpx/vp8/common/blockd.c
media/libvpx/libvpx/vp8/common/blockd.h
media/libvpx/libvpx/vp8/common/coefupdateprobs.h
media/libvpx/libvpx/vp8/common/common.h
media/libvpx/libvpx/vp8/common/copy_c.c
media/libvpx/libvpx/vp8/common/debugmodes.c
media/libvpx/libvpx/vp8/common/default_coef_probs.h
media/libvpx/libvpx/vp8/common/dequantize.c
media/libvpx/libvpx/vp8/common/entropy.c
media/libvpx/libvpx/vp8/common/entropy.h
media/libvpx/libvpx/vp8/common/entropymode.c
media/libvpx/libvpx/vp8/common/entropymode.h
media/libvpx/libvpx/vp8/common/entropymv.c
media/libvpx/libvpx/vp8/common/entropymv.h
media/libvpx/libvpx/vp8/common/extend.c
media/libvpx/libvpx/vp8/common/extend.h
media/libvpx/libvpx/vp8/common/filter.c
media/libvpx/libvpx/vp8/common/filter.h
media/libvpx/libvpx/vp8/common/findnearmv.c
media/libvpx/libvpx/vp8/common/findnearmv.h
media/libvpx/libvpx/vp8/common/generic/systemdependent.c
media/libvpx/libvpx/vp8/common/header.h
media/libvpx/libvpx/vp8/common/idct_blk.c
media/libvpx/libvpx/vp8/common/idctllm.c
media/libvpx/libvpx/vp8/common/invtrans.h
media/libvpx/libvpx/vp8/common/loopfilter.c
media/libvpx/libvpx/vp8/common/loopfilter.h
media/libvpx/libvpx/vp8/common/loopfilter_filters.c
media/libvpx/libvpx/vp8/common/mbpitch.c
media/libvpx/libvpx/vp8/common/mfqe.c
media/libvpx/libvpx/vp8/common/modecont.c
media/libvpx/libvpx/vp8/common/modecont.h
media/libvpx/libvpx/vp8/common/mv.h
media/libvpx/libvpx/vp8/common/onyx.h
media/libvpx/libvpx/vp8/common/onyxc_int.h
media/libvpx/libvpx/vp8/common/onyxd.h
media/libvpx/libvpx/vp8/common/postproc.c
media/libvpx/libvpx/vp8/common/postproc.h
media/libvpx/libvpx/vp8/common/ppflags.h
media/libvpx/libvpx/vp8/common/quant_common.c
media/libvpx/libvpx/vp8/common/quant_common.h
media/libvpx/libvpx/vp8/common/reconinter.c
media/libvpx/libvpx/vp8/common/reconinter.h
media/libvpx/libvpx/vp8/common/reconintra.c
media/libvpx/libvpx/vp8/common/reconintra4x4.c
media/libvpx/libvpx/vp8/common/reconintra4x4.h
media/libvpx/libvpx/vp8/common/rtcd.c
media/libvpx/libvpx/vp8/common/setupintrarecon.c
media/libvpx/libvpx/vp8/common/setupintrarecon.h
media/libvpx/libvpx/vp8/common/swapyv12buffer.c
media/libvpx/libvpx/vp8/common/swapyv12buffer.h
media/libvpx/libvpx/vp8/common/systemdependent.h
media/libvpx/libvpx/vp8/common/threading.h
media/libvpx/libvpx/vp8/common/treecoder.c
media/libvpx/libvpx/vp8/common/treecoder.h
media/libvpx/libvpx/vp8/common/variance.h
media/libvpx/libvpx/vp8/common/variance_c.c
media/libvpx/libvpx/vp8/common/vp8_entropymodedata.h
media/libvpx/libvpx/vp8/common/x86/copy_sse2.asm
media/libvpx/libvpx/vp8/common/x86/copy_sse3.asm
media/libvpx/libvpx/vp8/common/x86/dequantize_mmx.asm
media/libvpx/libvpx/vp8/common/x86/filter_x86.c
media/libvpx/libvpx/vp8/common/x86/filter_x86.h
media/libvpx/libvpx/vp8/common/x86/idct_blk_mmx.c
media/libvpx/libvpx/vp8/common/x86/idct_blk_sse2.c
media/libvpx/libvpx/vp8/common/x86/idctllm_mmx.asm
media/libvpx/libvpx/vp8/common/x86/idctllm_sse2.asm
media/libvpx/libvpx/vp8/common/x86/iwalsh_mmx.asm
media/libvpx/libvpx/vp8/common/x86/iwalsh_sse2.asm
media/libvpx/libvpx/vp8/common/x86/loopfilter_block_sse2_x86_64.asm
media/libvpx/libvpx/vp8/common/x86/loopfilter_mmx.asm
media/libvpx/libvpx/vp8/common/x86/loopfilter_sse2.asm
media/libvpx/libvpx/vp8/common/x86/loopfilter_x86.c
media/libvpx/libvpx/vp8/common/x86/mfqe_sse2.asm
media/libvpx/libvpx/vp8/common/x86/postproc_mmx.asm
media/libvpx/libvpx/vp8/common/x86/postproc_sse2.asm
media/libvpx/libvpx/vp8/common/x86/recon_mmx.asm
media/libvpx/libvpx/vp8/common/x86/recon_sse2.asm
media/libvpx/libvpx/vp8/common/x86/recon_wrapper_sse2.c
media/libvpx/libvpx/vp8/common/x86/subpixel_mmx.asm
media/libvpx/libvpx/vp8/common/x86/subpixel_sse2.asm
media/libvpx/libvpx/vp8/common/x86/subpixel_ssse3.asm
media/libvpx/libvpx/vp8/common/x86/variance_impl_sse2.asm
media/libvpx/libvpx/vp8/common/x86/variance_impl_ssse3.asm
media/libvpx/libvpx/vp8/common/x86/variance_ssse3.c
media/libvpx/libvpx/vp8/common/x86/vp8_asm_stubs.c
media/libvpx/libvpx/vp8/common/x86/vp8_variance_impl_mmx.asm
media/libvpx/libvpx/vp8/common/x86/vp8_variance_mmx.c
media/libvpx/libvpx/vp8/common/x86/vp8_variance_sse2.c
media/libvpx/libvpx/vp8/decoder/dboolhuff.c
media/libvpx/libvpx/vp8/decoder/dboolhuff.h
media/libvpx/libvpx/vp8/decoder/decodeframe.c
media/libvpx/libvpx/vp8/decoder/decodemv.c
media/libvpx/libvpx/vp8/decoder/decodemv.h
media/libvpx/libvpx/vp8/decoder/decoderthreading.h
media/libvpx/libvpx/vp8/decoder/detokenize.c
media/libvpx/libvpx/vp8/decoder/detokenize.h
media/libvpx/libvpx/vp8/decoder/ec_types.h
media/libvpx/libvpx/vp8/decoder/error_concealment.c
media/libvpx/libvpx/vp8/decoder/error_concealment.h
media/libvpx/libvpx/vp8/decoder/onyxd_if.c
media/libvpx/libvpx/vp8/decoder/onyxd_int.h
media/libvpx/libvpx/vp8/decoder/threading.c
media/libvpx/libvpx/vp8/decoder/treereader.h
media/libvpx/libvpx/vp8/encoder/arm/armv6/vp8_short_fdct4x4_armv6.asm
media/libvpx/libvpx/vp8/encoder/arm/armv6/walsh_v6.asm
media/libvpx/libvpx/vp8/encoder/arm/dct_arm.c
media/libvpx/libvpx/vp8/encoder/arm/neon/denoising_neon.c
media/libvpx/libvpx/vp8/encoder/arm/neon/fastquantizeb_neon.c
media/libvpx/libvpx/vp8/encoder/arm/neon/shortfdct_neon.c
media/libvpx/libvpx/vp8/encoder/arm/neon/subtract_neon.c
media/libvpx/libvpx/vp8/encoder/arm/neon/vp8_shortwalsh4x4_neon.c
media/libvpx/libvpx/vp8/encoder/bitstream.c
media/libvpx/libvpx/vp8/encoder/bitstream.h
media/libvpx/libvpx/vp8/encoder/block.h
media/libvpx/libvpx/vp8/encoder/boolhuff.c
media/libvpx/libvpx/vp8/encoder/boolhuff.h
media/libvpx/libvpx/vp8/encoder/dct.c
media/libvpx/libvpx/vp8/encoder/dct_value_cost.h
media/libvpx/libvpx/vp8/encoder/dct_value_tokens.h
media/libvpx/libvpx/vp8/encoder/defaultcoefcounts.h
media/libvpx/libvpx/vp8/encoder/denoising.c
media/libvpx/libvpx/vp8/encoder/denoising.h
media/libvpx/libvpx/vp8/encoder/encodeframe.c
media/libvpx/libvpx/vp8/encoder/encodeframe.h
media/libvpx/libvpx/vp8/encoder/encodeintra.c
media/libvpx/libvpx/vp8/encoder/encodeintra.h
media/libvpx/libvpx/vp8/encoder/encodemb.c
media/libvpx/libvpx/vp8/encoder/encodemb.h
media/libvpx/libvpx/vp8/encoder/encodemv.c
media/libvpx/libvpx/vp8/encoder/encodemv.h
media/libvpx/libvpx/vp8/encoder/ethreading.c
media/libvpx/libvpx/vp8/encoder/firstpass.c
media/libvpx/libvpx/vp8/encoder/firstpass.h
media/libvpx/libvpx/vp8/encoder/lookahead.c
media/libvpx/libvpx/vp8/encoder/lookahead.h
media/libvpx/libvpx/vp8/encoder/mcomp.c
media/libvpx/libvpx/vp8/encoder/mcomp.h
media/libvpx/libvpx/vp8/encoder/modecosts.c
media/libvpx/libvpx/vp8/encoder/modecosts.h
media/libvpx/libvpx/vp8/encoder/mr_dissim.c
media/libvpx/libvpx/vp8/encoder/mr_dissim.h
media/libvpx/libvpx/vp8/encoder/onyx_if.c
media/libvpx/libvpx/vp8/encoder/onyx_int.h
media/libvpx/libvpx/vp8/encoder/pickinter.c
media/libvpx/libvpx/vp8/encoder/pickinter.h
media/libvpx/libvpx/vp8/encoder/picklpf.c
media/libvpx/libvpx/vp8/encoder/quantize.c
media/libvpx/libvpx/vp8/encoder/quantize.h
media/libvpx/libvpx/vp8/encoder/ratectrl.c
media/libvpx/libvpx/vp8/encoder/ratectrl.h
media/libvpx/libvpx/vp8/encoder/rdopt.c
media/libvpx/libvpx/vp8/encoder/rdopt.h
media/libvpx/libvpx/vp8/encoder/segmentation.c
media/libvpx/libvpx/vp8/encoder/segmentation.h
media/libvpx/libvpx/vp8/encoder/temporal_filter.c
media/libvpx/libvpx/vp8/encoder/tokenize.c
media/libvpx/libvpx/vp8/encoder/tokenize.h
media/libvpx/libvpx/vp8/encoder/treewriter.c
media/libvpx/libvpx/vp8/encoder/treewriter.h
media/libvpx/libvpx/vp8/encoder/x86/dct_mmx.asm
media/libvpx/libvpx/vp8/encoder/x86/dct_sse2.asm
media/libvpx/libvpx/vp8/encoder/x86/denoising_sse2.c
media/libvpx/libvpx/vp8/encoder/x86/encodeopt.asm
media/libvpx/libvpx/vp8/encoder/x86/fwalsh_sse2.asm
media/libvpx/libvpx/vp8/encoder/x86/quantize_mmx.asm
media/libvpx/libvpx/vp8/encoder/x86/quantize_sse2.c
media/libvpx/libvpx/vp8/encoder/x86/quantize_sse4.c
media/libvpx/libvpx/vp8/encoder/x86/quantize_ssse3.c
media/libvpx/libvpx/vp8/encoder/x86/ssim_opt_x86_64.asm
media/libvpx/libvpx/vp8/encoder/x86/subtract_mmx.asm
media/libvpx/libvpx/vp8/encoder/x86/subtract_sse2.asm
media/libvpx/libvpx/vp8/encoder/x86/temporal_filter_apply_sse2.asm
media/libvpx/libvpx/vp8/encoder/x86/vp8_enc_stubs_mmx.c
media/libvpx/libvpx/vp8/encoder/x86/vp8_enc_stubs_sse2.c
media/libvpx/libvpx/vp8/vp8_dx_iface.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_convolve8_avg_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_convolve8_avg_neon_asm.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_convolve8_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_convolve8_neon_asm.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_convolve_avg_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_convolve_avg_neon_asm.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_convolve_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_copy_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_copy_neon_asm.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct16x16_1_add_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct16x16_1_add_neon_asm.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct16x16_add_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct16x16_add_neon_asm.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct16x16_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct32x32_1_add_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct32x32_1_add_neon_asm.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct32x32_add_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct32x32_add_neon_asm.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct4x4_1_add_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct4x4_1_add_neon_asm.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct4x4_add_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct4x4_add_neon_asm.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct8x8_1_add_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct8x8_1_add_neon_asm.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct8x8_add_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_idct8x8_add_neon_asm.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_iht4x4_add_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_iht8x8_add_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_loopfilter_16_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_loopfilter_16_neon_asm.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_loopfilter_4_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_loopfilter_4_neon_asm.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_loopfilter_8_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_loopfilter_8_neon_asm.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_loopfilter_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_mb_lpf_neon.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_reconintra_neon.c
media/libvpx/libvpx/vp9/common/arm/neon/vp9_reconintra_neon_asm.asm
media/libvpx/libvpx/vp9/common/arm/neon/vp9_save_reg_neon.asm
media/libvpx/libvpx/vp9/common/vp9_alloccommon.c
media/libvpx/libvpx/vp9/common/vp9_alloccommon.h
media/libvpx/libvpx/vp9/common/vp9_blockd.c
media/libvpx/libvpx/vp9/common/vp9_blockd.h
media/libvpx/libvpx/vp9/common/vp9_common.h
media/libvpx/libvpx/vp9/common/vp9_common_data.c
media/libvpx/libvpx/vp9/common/vp9_common_data.h
media/libvpx/libvpx/vp9/common/vp9_convolve.c
media/libvpx/libvpx/vp9/common/vp9_convolve.h
media/libvpx/libvpx/vp9/common/vp9_debugmodes.c
media/libvpx/libvpx/vp9/common/vp9_entropy.c
media/libvpx/libvpx/vp9/common/vp9_entropy.h
media/libvpx/libvpx/vp9/common/vp9_entropymode.c
media/libvpx/libvpx/vp9/common/vp9_entropymode.h
media/libvpx/libvpx/vp9/common/vp9_entropymv.c
media/libvpx/libvpx/vp9/common/vp9_entropymv.h
media/libvpx/libvpx/vp9/common/vp9_enums.h
media/libvpx/libvpx/vp9/common/vp9_filter.c
media/libvpx/libvpx/vp9/common/vp9_filter.h
media/libvpx/libvpx/vp9/common/vp9_frame_buffers.c
media/libvpx/libvpx/vp9/common/vp9_frame_buffers.h
media/libvpx/libvpx/vp9/common/vp9_idct.c
media/libvpx/libvpx/vp9/common/vp9_idct.h
media/libvpx/libvpx/vp9/common/vp9_loopfilter.c
media/libvpx/libvpx/vp9/common/vp9_loopfilter.h
media/libvpx/libvpx/vp9/common/vp9_loopfilter_filters.c
media/libvpx/libvpx/vp9/common/vp9_mfqe.c
media/libvpx/libvpx/vp9/common/vp9_mfqe.h
media/libvpx/libvpx/vp9/common/vp9_mv.h
media/libvpx/libvpx/vp9/common/vp9_mvref_common.c
media/libvpx/libvpx/vp9/common/vp9_mvref_common.h
media/libvpx/libvpx/vp9/common/vp9_onyxc_int.h
media/libvpx/libvpx/vp9/common/vp9_postproc.c
media/libvpx/libvpx/vp9/common/vp9_postproc.h
media/libvpx/libvpx/vp9/common/vp9_ppflags.h
media/libvpx/libvpx/vp9/common/vp9_pred_common.c
media/libvpx/libvpx/vp9/common/vp9_pred_common.h
media/libvpx/libvpx/vp9/common/vp9_prob.c
media/libvpx/libvpx/vp9/common/vp9_prob.h
media/libvpx/libvpx/vp9/common/vp9_quant_common.c
media/libvpx/libvpx/vp9/common/vp9_quant_common.h
media/libvpx/libvpx/vp9/common/vp9_reconinter.c
media/libvpx/libvpx/vp9/common/vp9_reconinter.h
media/libvpx/libvpx/vp9/common/vp9_reconintra.c
media/libvpx/libvpx/vp9/common/vp9_reconintra.h
media/libvpx/libvpx/vp9/common/vp9_rtcd.c
media/libvpx/libvpx/vp9/common/vp9_scale.c
media/libvpx/libvpx/vp9/common/vp9_scale.h
media/libvpx/libvpx/vp9/common/vp9_scan.c
media/libvpx/libvpx/vp9/common/vp9_scan.h
media/libvpx/libvpx/vp9/common/vp9_seg_common.c
media/libvpx/libvpx/vp9/common/vp9_seg_common.h
media/libvpx/libvpx/vp9/common/vp9_systemdependent.h
media/libvpx/libvpx/vp9/common/vp9_thread.c
media/libvpx/libvpx/vp9/common/vp9_thread.h
media/libvpx/libvpx/vp9/common/vp9_thread_common.c
media/libvpx/libvpx/vp9/common/vp9_thread_common.h
media/libvpx/libvpx/vp9/common/vp9_tile_common.c
media/libvpx/libvpx/vp9/common/vp9_tile_common.h
media/libvpx/libvpx/vp9/common/x86/convolve.h
media/libvpx/libvpx/vp9/common/x86/vp9_asm_stubs.c
media/libvpx/libvpx/vp9/common/x86/vp9_copy_sse2.asm
media/libvpx/libvpx/vp9/common/x86/vp9_high_intrapred_sse2.asm
media/libvpx/libvpx/vp9/common/x86/vp9_high_loopfilter_intrin_sse2.c
media/libvpx/libvpx/vp9/common/x86/vp9_high_subpixel_8t_sse2.asm
media/libvpx/libvpx/vp9/common/x86/vp9_high_subpixel_bilinear_sse2.asm
media/libvpx/libvpx/vp9/common/x86/vp9_idct_intrin_sse2.c
media/libvpx/libvpx/vp9/common/x86/vp9_idct_intrin_sse2.h
media/libvpx/libvpx/vp9/common/x86/vp9_idct_ssse3_x86_64.asm
media/libvpx/libvpx/vp9/common/x86/vp9_intrapred_sse2.asm
media/libvpx/libvpx/vp9/common/x86/vp9_intrapred_ssse3.asm
media/libvpx/libvpx/vp9/common/x86/vp9_loopfilter_intrin_avx2.c
media/libvpx/libvpx/vp9/common/x86/vp9_loopfilter_intrin_sse2.c
media/libvpx/libvpx/vp9/common/x86/vp9_loopfilter_mmx.asm
media/libvpx/libvpx/vp9/common/x86/vp9_mfqe_sse2.asm
media/libvpx/libvpx/vp9/common/x86/vp9_postproc_sse2.asm
media/libvpx/libvpx/vp9/common/x86/vp9_subpixel_8t_intrin_avx2.c
media/libvpx/libvpx/vp9/common/x86/vp9_subpixel_8t_intrin_ssse3.c
media/libvpx/libvpx/vp9/common/x86/vp9_subpixel_8t_sse2.asm
media/libvpx/libvpx/vp9/common/x86/vp9_subpixel_8t_ssse3.asm
media/libvpx/libvpx/vp9/common/x86/vp9_subpixel_bilinear_sse2.asm
media/libvpx/libvpx/vp9/common/x86/vp9_subpixel_bilinear_ssse3.asm
media/libvpx/libvpx/vp9/decoder/vp9_decodeframe.c
media/libvpx/libvpx/vp9/decoder/vp9_decodeframe.h
media/libvpx/libvpx/vp9/decoder/vp9_decodemv.c
media/libvpx/libvpx/vp9/decoder/vp9_decodemv.h
media/libvpx/libvpx/vp9/decoder/vp9_decoder.c
media/libvpx/libvpx/vp9/decoder/vp9_decoder.h
media/libvpx/libvpx/vp9/decoder/vp9_detokenize.c
media/libvpx/libvpx/vp9/decoder/vp9_detokenize.h
media/libvpx/libvpx/vp9/decoder/vp9_dsubexp.c
media/libvpx/libvpx/vp9/decoder/vp9_dsubexp.h
media/libvpx/libvpx/vp9/decoder/vp9_dthread.c
media/libvpx/libvpx/vp9/decoder/vp9_dthread.h
media/libvpx/libvpx/vp9/decoder/vp9_read_bit_buffer.c
media/libvpx/libvpx/vp9/decoder/vp9_read_bit_buffer.h
media/libvpx/libvpx/vp9/decoder/vp9_reader.c
media/libvpx/libvpx/vp9/decoder/vp9_reader.h
media/libvpx/libvpx/vp9/encoder/arm/neon/vp9_dct_neon.c
media/libvpx/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c
media/libvpx/libvpx/vp9/encoder/arm/neon/vp9_subtract_neon.c
media/libvpx/libvpx/vp9/encoder/arm/neon/vp9_variance_neon.c
media/libvpx/libvpx/vp9/encoder/arm/neon/vp9enc_avg_neon.c
media/libvpx/libvpx/vp9/encoder/vp9_aq_complexity.c
media/libvpx/libvpx/vp9/encoder/vp9_aq_complexity.h
media/libvpx/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c
media/libvpx/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.h
media/libvpx/libvpx/vp9/encoder/vp9_aq_variance.c
media/libvpx/libvpx/vp9/encoder/vp9_aq_variance.h
media/libvpx/libvpx/vp9/encoder/vp9_avg.c
media/libvpx/libvpx/vp9/encoder/vp9_bitstream.c
media/libvpx/libvpx/vp9/encoder/vp9_bitstream.h
media/libvpx/libvpx/vp9/encoder/vp9_block.h
media/libvpx/libvpx/vp9/encoder/vp9_blockiness.c
media/libvpx/libvpx/vp9/encoder/vp9_context_tree.c
media/libvpx/libvpx/vp9/encoder/vp9_context_tree.h
media/libvpx/libvpx/vp9/encoder/vp9_cost.c
media/libvpx/libvpx/vp9/encoder/vp9_cost.h
media/libvpx/libvpx/vp9/encoder/vp9_dct.c
media/libvpx/libvpx/vp9/encoder/vp9_dct.h
media/libvpx/libvpx/vp9/encoder/vp9_denoiser.c
media/libvpx/libvpx/vp9/encoder/vp9_denoiser.h
media/libvpx/libvpx/vp9/encoder/vp9_encodeframe.c
media/libvpx/libvpx/vp9/encoder/vp9_encodeframe.h
media/libvpx/libvpx/vp9/encoder/vp9_encodemb.c
media/libvpx/libvpx/vp9/encoder/vp9_encodemb.h
media/libvpx/libvpx/vp9/encoder/vp9_encodemv.c
media/libvpx/libvpx/vp9/encoder/vp9_encodemv.h
media/libvpx/libvpx/vp9/encoder/vp9_encoder.c
media/libvpx/libvpx/vp9/encoder/vp9_encoder.h
media/libvpx/libvpx/vp9/encoder/vp9_ethread.c
media/libvpx/libvpx/vp9/encoder/vp9_ethread.h
media/libvpx/libvpx/vp9/encoder/vp9_extend.c
media/libvpx/libvpx/vp9/encoder/vp9_extend.h
media/libvpx/libvpx/vp9/encoder/vp9_fastssim.c
media/libvpx/libvpx/vp9/encoder/vp9_firstpass.c
media/libvpx/libvpx/vp9/encoder/vp9_firstpass.h
media/libvpx/libvpx/vp9/encoder/vp9_lookahead.c
media/libvpx/libvpx/vp9/encoder/vp9_lookahead.h
media/libvpx/libvpx/vp9/encoder/vp9_mbgraph.c
media/libvpx/libvpx/vp9/encoder/vp9_mbgraph.h
media/libvpx/libvpx/vp9/encoder/vp9_mcomp.c
media/libvpx/libvpx/vp9/encoder/vp9_mcomp.h
media/libvpx/libvpx/vp9/encoder/vp9_picklpf.c
media/libvpx/libvpx/vp9/encoder/vp9_picklpf.h
media/libvpx/libvpx/vp9/encoder/vp9_pickmode.c
media/libvpx/libvpx/vp9/encoder/vp9_pickmode.h
media/libvpx/libvpx/vp9/encoder/vp9_psnrhvs.c
media/libvpx/libvpx/vp9/encoder/vp9_quantize.c
media/libvpx/libvpx/vp9/encoder/vp9_quantize.h
media/libvpx/libvpx/vp9/encoder/vp9_ratectrl.c
media/libvpx/libvpx/vp9/encoder/vp9_ratectrl.h
media/libvpx/libvpx/vp9/encoder/vp9_rd.c
media/libvpx/libvpx/vp9/encoder/vp9_rd.h
media/libvpx/libvpx/vp9/encoder/vp9_rdopt.c
media/libvpx/libvpx/vp9/encoder/vp9_rdopt.h
media/libvpx/libvpx/vp9/encoder/vp9_resize.c
media/libvpx/libvpx/vp9/encoder/vp9_resize.h
media/libvpx/libvpx/vp9/encoder/vp9_segmentation.c
media/libvpx/libvpx/vp9/encoder/vp9_segmentation.h
media/libvpx/libvpx/vp9/encoder/vp9_skin_detection.c
media/libvpx/libvpx/vp9/encoder/vp9_skin_detection.h
media/libvpx/libvpx/vp9/encoder/vp9_speed_features.c
media/libvpx/libvpx/vp9/encoder/vp9_speed_features.h
media/libvpx/libvpx/vp9/encoder/vp9_ssim.h
media/libvpx/libvpx/vp9/encoder/vp9_subexp.c
media/libvpx/libvpx/vp9/encoder/vp9_subexp.h
media/libvpx/libvpx/vp9/encoder/vp9_svc_layercontext.c
media/libvpx/libvpx/vp9/encoder/vp9_svc_layercontext.h
media/libvpx/libvpx/vp9/encoder/vp9_temporal_filter.c
media/libvpx/libvpx/vp9/encoder/vp9_temporal_filter.h
media/libvpx/libvpx/vp9/encoder/vp9_tokenize.c
media/libvpx/libvpx/vp9/encoder/vp9_tokenize.h
media/libvpx/libvpx/vp9/encoder/vp9_treewriter.c
media/libvpx/libvpx/vp9/encoder/vp9_treewriter.h
media/libvpx/libvpx/vp9/encoder/vp9_variance.c
media/libvpx/libvpx/vp9/encoder/vp9_variance.h
media/libvpx/libvpx/vp9/encoder/vp9_write_bit_buffer.c
media/libvpx/libvpx/vp9/encoder/vp9_write_bit_buffer.h
media/libvpx/libvpx/vp9/encoder/vp9_writer.c
media/libvpx/libvpx/vp9/encoder/vp9_writer.h
media/libvpx/libvpx/vp9/encoder/x86/vp9_avg_intrin_sse2.c
media/libvpx/libvpx/vp9/encoder/x86/vp9_dct32x32_avx2_impl.h
media/libvpx/libvpx/vp9/encoder/x86/vp9_dct32x32_sse2_impl.h
media/libvpx/libvpx/vp9/encoder/x86/vp9_dct_avx2.c
media/libvpx/libvpx/vp9/encoder/x86/vp9_dct_mmx.asm
media/libvpx/libvpx/vp9/encoder/x86/vp9_dct_sse2.c
media/libvpx/libvpx/vp9/encoder/x86/vp9_dct_sse2.h
media/libvpx/libvpx/vp9/encoder/x86/vp9_dct_sse2_impl.h
media/libvpx/libvpx/vp9/encoder/x86/vp9_dct_ssse3.c
media/libvpx/libvpx/vp9/encoder/x86/vp9_dct_ssse3_x86_64.asm
media/libvpx/libvpx/vp9/encoder/x86/vp9_denoiser_sse2.c
media/libvpx/libvpx/vp9/encoder/x86/vp9_error_intrin_avx2.c
media/libvpx/libvpx/vp9/encoder/x86/vp9_error_sse2.asm
media/libvpx/libvpx/vp9/encoder/x86/vp9_highbd_block_error_intrin_sse2.c
media/libvpx/libvpx/vp9/encoder/x86/vp9_highbd_quantize_intrin_sse2.c
media/libvpx/libvpx/vp9/encoder/x86/vp9_highbd_subpel_variance.asm
media/libvpx/libvpx/vp9/encoder/x86/vp9_highbd_variance_sse2.c
media/libvpx/libvpx/vp9/encoder/x86/vp9_quantize_sse2.c
media/libvpx/libvpx/vp9/encoder/x86/vp9_quantize_ssse3_x86_64.asm
media/libvpx/libvpx/vp9/encoder/x86/vp9_ssim_opt_x86_64.asm
media/libvpx/libvpx/vp9/encoder/x86/vp9_subpel_variance.asm
media/libvpx/libvpx/vp9/encoder/x86/vp9_subpel_variance_impl_intrin_avx2.c
media/libvpx/libvpx/vp9/encoder/x86/vp9_subtract_sse2.asm
media/libvpx/libvpx/vp9/encoder/x86/vp9_temporal_filter_apply_sse2.asm
media/libvpx/libvpx/vp9/encoder/x86/vp9_variance_avx2.c
media/libvpx/libvpx/vp9/encoder/x86/vp9_variance_sse2.c
media/libvpx/libvpx/vp9/vp9_cx_iface.c
media/libvpx/libvpx/vp9/vp9_dx_iface.c
media/libvpx/libvpx/vp9/vp9_iface_common.h
media/libvpx/libvpx/vpx/internal/vpx_codec_internal.h
media/libvpx/libvpx/vpx/internal/vpx_psnr.h
media/libvpx/libvpx/vpx/src/svc_encodeframe.c
media/libvpx/libvpx/vpx/src/vpx_codec.c
media/libvpx/libvpx/vpx/src/vpx_decoder.c
media/libvpx/libvpx/vpx/src/vpx_encoder.c
media/libvpx/libvpx/vpx/src/vpx_image.c
media/libvpx/libvpx/vpx/src/vpx_psnr.c
media/libvpx/libvpx/vpx/svc_context.h
media/libvpx/libvpx/vpx/vp8.h
media/libvpx/libvpx/vpx/vp8cx.h
media/libvpx/libvpx/vpx/vp8dx.h
media/libvpx/libvpx/vpx/vpx_codec.h
media/libvpx/libvpx/vpx/vpx_decoder.h
media/libvpx/libvpx/vpx/vpx_encoder.h
media/libvpx/libvpx/vpx/vpx_frame_buffer.h
media/libvpx/libvpx/vpx/vpx_image.h
media/libvpx/libvpx/vpx/vpx_integer.h
media/libvpx/libvpx/vpx_dsp/arm/sad4d_neon.c
media/libvpx/libvpx/vpx_dsp/arm/sad_media.asm
media/libvpx/libvpx/vpx_dsp/arm/sad_neon.c
media/libvpx/libvpx/vpx_dsp/arm/variance_media.asm
media/libvpx/libvpx/vpx_dsp/arm/variance_neon.c
media/libvpx/libvpx/vpx_dsp/sad.c
media/libvpx/libvpx/vpx_dsp/variance.c
media/libvpx/libvpx/vpx_dsp/vpx_dsp_rtcd.c
media/libvpx/libvpx/vpx_dsp/x86/highbd_sad4d_sse2.asm
media/libvpx/libvpx/vpx_dsp/x86/highbd_sad_sse2.asm
media/libvpx/libvpx/vpx_dsp/x86/highbd_variance_impl_sse2.asm
media/libvpx/libvpx/vpx_dsp/x86/highbd_variance_sse2.c
media/libvpx/libvpx/vpx_dsp/x86/sad4d_avx2.c
media/libvpx/libvpx/vpx_dsp/x86/sad4d_sse2.asm
media/libvpx/libvpx/vpx_dsp/x86/sad_avx2.c
media/libvpx/libvpx/vpx_dsp/x86/sad_mmx.asm
media/libvpx/libvpx/vpx_dsp/x86/sad_sse2.asm
media/libvpx/libvpx/vpx_dsp/x86/sad_sse3.asm
media/libvpx/libvpx/vpx_dsp/x86/sad_sse4.asm
media/libvpx/libvpx/vpx_dsp/x86/sad_ssse3.asm
media/libvpx/libvpx/vpx_dsp/x86/variance_avx2.c
media/libvpx/libvpx/vpx_dsp/x86/variance_impl_avx2.c
media/libvpx/libvpx/vpx_dsp/x86/variance_impl_mmx.asm
media/libvpx/libvpx/vpx_dsp/x86/variance_mmx.c
media/libvpx/libvpx/vpx_dsp/x86/variance_sse2.c
media/libvpx/libvpx/vpx_mem/include/vpx_mem_intrnl.h
media/libvpx/libvpx/vpx_mem/vpx_mem.c
media/libvpx/libvpx/vpx_mem/vpx_mem.h
media/libvpx/libvpx/vpx_ports/arm.h
media/libvpx/libvpx/vpx_ports/arm_cpudetect.c
media/libvpx/libvpx/vpx_ports/config.h
media/libvpx/libvpx/vpx_ports/emmintrin_compat.h
media/libvpx/libvpx/vpx_ports/emms.asm
media/libvpx/libvpx/vpx_ports/mem.h
media/libvpx/libvpx/vpx_ports/mem_ops.h
media/libvpx/libvpx/vpx_ports/mem_ops_aligned.h
media/libvpx/libvpx/vpx_ports/msvc.h
media/libvpx/libvpx/vpx_ports/vpx_once.h
media/libvpx/libvpx/vpx_ports/vpx_timer.h
media/libvpx/libvpx/vpx_ports/x86.h
media/libvpx/libvpx/vpx_ports/x86_abi_support.asm
media/libvpx/libvpx/vpx_scale/generic/gen_scalers.c
media/libvpx/libvpx/vpx_scale/generic/vpx_scale.c
media/libvpx/libvpx/vpx_scale/generic/yv12config.c
media/libvpx/libvpx/vpx_scale/generic/yv12extend.c
media/libvpx/libvpx/vpx_scale/vpx_scale.h
media/libvpx/libvpx/vpx_scale/vpx_scale_rtcd.c
media/libvpx/libvpx/vpx_scale/yv12config.h
media/libvpx/moz.build
media/libvpx/sources.mozbuild
media/libvpx/stdint.patch
media/libvpx/update.py
media/libvpx/vp9_filter_restore_aligment.patch
media/libvpx/vpx_once.patch
netwerk/base/nsSocketTransport2.cpp
old-configure.in
--- a/accessible/ipc/DocAccessibleParent.cpp
+++ b/accessible/ipc/DocAccessibleParent.cpp
@@ -411,19 +411,24 @@ DocAccessibleParent::RecvShutdown()
   }
 
   return IPC_OK();
 }
 
 void
 DocAccessibleParent::Destroy()
 {
+  // If we are already shutdown that is because our containing tab parent is
+  // shutting down in which case we don't need to do anything.
+  if (mShutdown) {
+    return;
+  }
+
   NS_ASSERTION(mChildDocs.IsEmpty(),
                "why weren't the child docs destroyed already?");
-  MOZ_ASSERT(!mShutdown);
   mShutdown = true;
 
   uint32_t childDocCount = mChildDocs.Length();
   for (uint32_t i = childDocCount - 1; i < childDocCount; i--)
     mChildDocs[i]->Destroy();
 
   for (auto iter = mAccessibles.Iter(); !iter.Done(); iter.Next()) {
     MOZ_ASSERT(iter.Get()->mProxy != this);
--- a/browser/components/feeds/FeedWriter.js
+++ b/browser/components/feeds/FeedWriter.js
@@ -876,18 +876,18 @@ FeedWriter.prototype = {
    *        The window of the document invoking the BrowserFeedWriter
    */
   _getOriginalURI(aWindow) {
     let docShell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
                           .getInterface(Ci.nsIWebNavigation)
                           .QueryInterface(Ci.nsIDocShell);
     let chan = docShell.currentDocumentChannel;
 
-    // We probably need to call InheritFromDocShellToDoc for this, but right now
-    // we can't call it from JS.
+    // We probably need to call Inherit() for this, but right now we can't call
+    // it from JS.
     let attrs = docShell.getOriginAttributes();
     let ssm = Services.scriptSecurityManager;
     let nullPrincipal = ssm.createNullPrincipal(attrs);
 
     // this channel is not going to be openend, use a nullPrincipal
     // and the most restrctive securityFlag.
     let resolvedURI = NetUtil.newChannel({
       uri: "about:feeds",
--- a/browser/themes/shared/notification-icons.inc.css
+++ b/browser/themes/shared/notification-icons.inc.css
@@ -40,20 +40,16 @@
 }
 
 .notification-anchor-icon:not(.plugin-blocked):-moz-lwtheme,
 #blocked-permissions-container > .blocked-permission-icon:-moz-lwtheme {
   filter: url(chrome://global/skin/filters.svg#fill);
   fill: currentColor;
 }
 
-.notification-anchor-icon:not(.plugin-blocked):not(:hover) {
-  opacity: .8;
-}
-
 /* INDIVIDUAL NOTIFICATIONS */
 
 .popup-notification-icon[popupid="web-notifications"],
 .desktop-notification-icon {
   list-style-image: url(chrome://browser/skin/notification-icons.svg#desktop-notification);
 }
 
 .desktop-notification-icon.blocked-permission-icon {
--- a/caps/BasePrincipal.cpp
+++ b/caps/BasePrincipal.cpp
@@ -10,17 +10,16 @@
 #ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
 #endif
 #include "nsIAddonPolicyService.h"
 #include "nsIContentSecurityPolicy.h"
 #include "nsIEffectiveTLDService.h"
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
-#include "nsIScriptSecurityManager.h"
 
 #include "nsPrincipal.h"
 #include "nsNetUtil.h"
 #include "nsIURIWithPrincipal.h"
 #include "nsNullPrincipal.h"
 #include "nsScriptSecurityManager.h"
 #include "nsServiceManagerUtils.h"
 
@@ -30,104 +29,48 @@
 #include "mozilla/dom/ToJSValue.h"
 #include "mozilla/dom/URLSearchParams.h"
 
 namespace mozilla {
 
 using dom::URLParams;
 
 void
-PrincipalOriginAttributes::InheritFromDocShellToDoc(const DocShellOriginAttributes& aAttrs,
-                                                    const nsIURI* aURI)
+OriginAttributes::Inherit(const OriginAttributes& aAttrs)
 {
   mAppId = aAttrs.mAppId;
   mInIsolatedMozBrowser = aAttrs.mInIsolatedMozBrowser;
 
-  // addonId is computed from the principal URI and never propagated
-  mUserContextId = aAttrs.mUserContextId;
-
-  mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
-  mFirstPartyDomain = aAttrs.mFirstPartyDomain;
-}
+  StripAttributes(STRIP_ADDON_ID);
 
-void
-PrincipalOriginAttributes::InheritFromNecko(const NeckoOriginAttributes& aAttrs)
-{
-  mAppId = aAttrs.mAppId;
-  mInIsolatedMozBrowser = aAttrs.mInIsolatedMozBrowser;
-
-  // addonId is computed from the principal URI and never propagated
   mUserContextId = aAttrs.mUserContextId;
 
   mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
   mFirstPartyDomain = aAttrs.mFirstPartyDomain;
 }
 
 void
-PrincipalOriginAttributes::StripUserContextIdAndFirstPartyDomain()
-{
-  mUserContextId = nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID;
-  mFirstPartyDomain.Truncate();
-}
-
-void
-DocShellOriginAttributes::InheritFromDocToChildDocShell(const PrincipalOriginAttributes& aAttrs)
-{
-  mAppId = aAttrs.mAppId;
-  mInIsolatedMozBrowser = aAttrs.mInIsolatedMozBrowser;
-
-  // addonId is computed from the principal URI and never propagated
-  mUserContextId = aAttrs.mUserContextId;
-
-  mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
-  mFirstPartyDomain = aAttrs.mFirstPartyDomain;
-}
-
-void
-NeckoOriginAttributes::InheritFromDocToNecko(const PrincipalOriginAttributes& aAttrs)
+OriginAttributes::SetFirstPartyDomain(const bool aIsTopLevelDocument,
+                                      nsIURI* aURI)
 {
-  mAppId = aAttrs.mAppId;
-  mInIsolatedMozBrowser = aAttrs.mInIsolatedMozBrowser;
-
-  // addonId is computed from the principal URI and never propagated
-  mUserContextId = aAttrs.mUserContextId;
-
-  mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
-  mFirstPartyDomain = aAttrs.mFirstPartyDomain;
-}
-
-void
-NeckoOriginAttributes::InheritFromDocShellToNecko(const DocShellOriginAttributes& aAttrs,
-                                                  const bool aIsTopLevelDocument,
-                                                  nsIURI* aURI)
-{
-  mAppId = aAttrs.mAppId;
-  mInIsolatedMozBrowser = aAttrs.mInIsolatedMozBrowser;
-
-  // addonId is computed from the principal URI and never propagated
-  mUserContextId = aAttrs.mUserContextId;
-
-  mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
-
   bool isFirstPartyEnabled = IsFirstPartyEnabled();
 
   // When the pref is on, we also compute the firstPartyDomain attribute
   // if this is for top-level document.
   if (isFirstPartyEnabled && aIsTopLevelDocument) {
-    nsCOMPtr<nsIEffectiveTLDService> tldService = do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID);
+    nsCOMPtr<nsIEffectiveTLDService> tldService =
+      do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID);
     MOZ_ASSERT(tldService);
     if (!tldService) {
       return;
     }
 
     nsAutoCString baseDomain;
     tldService->GetBaseDomain(aURI, 0, baseDomain);
     mFirstPartyDomain = NS_ConvertUTF8toUTF16(baseDomain);
-  } else {
-    mFirstPartyDomain = aAttrs.mFirstPartyDomain;
   }
 }
 
 void
 OriginAttributes::CreateSuffix(nsACString& aStr) const
 {
   UniquePtr<URLParams> params(new URLParams());
   nsAutoString value;
@@ -321,27 +264,16 @@ OriginAttributes::PopulateFromOrigin(con
 }
 
 void
 OriginAttributes::SyncAttributesWithPrivateBrowsing(bool aInPrivateBrowsing)
 {
   mPrivateBrowsingId = aInPrivateBrowsing ? 1 : 0;
 }
 
-void
-OriginAttributes::SetFromGenericAttributes(const GenericOriginAttributes& aAttrs)
-{
-  mAppId = aAttrs.mAppId;
-  mInIsolatedMozBrowser = aAttrs.mInIsolatedMozBrowser;
-  mAddonId = aAttrs.mAddonId;
-  mUserContextId = aAttrs.mUserContextId;
-  mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
-  mFirstPartyDomain = aAttrs.mFirstPartyDomain;
-}
-
 /* static */
 bool
 OriginAttributes::IsFirstPartyEnabled()
 {
   // Cache the privacy.firstparty.isolate pref.
   static bool sFirstPartyIsolation = false;
   static bool sCachedFirstPartyPref = false;
   if (!sCachedFirstPartyPref) {
@@ -352,17 +284,17 @@ OriginAttributes::IsFirstPartyEnabled()
   return sFirstPartyIsolation;
 }
 
 /* static */
 bool
 OriginAttributes::IsPrivateBrowsing(const nsACString& aOrigin)
 {
   nsAutoCString dummy;
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   if (NS_WARN_IF(!attrs.PopulateFromOrigin(aOrigin, dummy))) {
     return false;
   }
 
   return !!attrs.mPrivateBrowsingId;
 }
 
 BasePrincipal::BasePrincipal()
@@ -679,17 +611,17 @@ BasePrincipal::AddonHasPermission(const 
 
   bool retval = false;
   nsresult rv = aps->AddonHasPermission(mOriginAttributes.mAddonId, aPerm, &retval);
   NS_ENSURE_SUCCESS(rv, false);
   return retval;
 }
 
 already_AddRefed<BasePrincipal>
-BasePrincipal::CreateCodebasePrincipal(nsIURI* aURI, const PrincipalOriginAttributes& aAttrs)
+BasePrincipal::CreateCodebasePrincipal(nsIURI* aURI, const OriginAttributes& aAttrs)
 {
   // If the URI is supposed to inherit the security context of whoever loads it,
   // we shouldn't make a codebase principal for it.
   bool inheritsPrincipal;
   nsresult rv = NS_URIChainHasFlags(aURI, nsIProtocolHandler::URI_INHERITS_SECURITY_CONTEXT,
                                     &inheritsPrincipal);
   if (NS_FAILED(rv) || inheritsPrincipal) {
     return nsNullPrincipal::Create(aAttrs);
@@ -719,33 +651,34 @@ BasePrincipal::CreateCodebasePrincipal(c
 {
   MOZ_ASSERT(!StringBeginsWith(aOrigin, NS_LITERAL_CSTRING("[")),
              "CreateCodebasePrincipal does not support System and Expanded principals");
 
   MOZ_ASSERT(!StringBeginsWith(aOrigin, NS_LITERAL_CSTRING(NS_NULLPRINCIPAL_SCHEME ":")),
              "CreateCodebasePrincipal does not support nsNullPrincipal");
 
   nsAutoCString originNoSuffix;
-  mozilla::PrincipalOriginAttributes attrs;
+  mozilla::OriginAttributes attrs;
   if (!attrs.PopulateFromOrigin(aOrigin, originNoSuffix)) {
     return nullptr;
   }
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = NS_NewURI(getter_AddRefs(uri), originNoSuffix);
   NS_ENSURE_SUCCESS(rv, nullptr);
 
   return BasePrincipal::CreateCodebasePrincipal(uri, attrs);
 }
 
 already_AddRefed<BasePrincipal>
 BasePrincipal::CloneStrippingUserContextIdAndFirstPartyDomain()
 {
-  PrincipalOriginAttributes attrs = OriginAttributesRef();
-  attrs.StripUserContextIdAndFirstPartyDomain();
+  OriginAttributes attrs = OriginAttributesRef();
+  attrs.StripAttributes(OriginAttributes::STRIP_USER_CONTEXT_ID |
+                        OriginAttributes::STRIP_FIRST_PARTY_DOMAIN);
 
   nsAutoCString originNoSuffix;
   nsresult rv = GetOriginNoSuffix(originNoSuffix);
   NS_ENSURE_SUCCESS(rv, nullptr);
 
   nsCOMPtr<nsIURI> uri;
   rv = NS_NewURI(getter_AddRefs(uri), originNoSuffix);
   NS_ENSURE_SUCCESS(rv, nullptr);
--- a/caps/BasePrincipal.h
+++ b/caps/BasePrincipal.h
@@ -6,42 +6,81 @@
 
 #ifndef mozilla_BasePrincipal_h
 #define mozilla_BasePrincipal_h
 
 #include "nsJSPrincipals.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/ChromeUtilsBinding.h"
+#include "nsIScriptSecurityManager.h"
 
 class nsIContentSecurityPolicy;
 class nsIObjectOutputStream;
 class nsIObjectInputStream;
 class nsIURI;
 
 class nsExpandedPrincipal;
 
 namespace mozilla {
 
-class GenericOriginAttributes;
-
 // Base OriginAttributes class. This has several subclass flavors, and is not
 // directly constructable itself.
 class OriginAttributes : public dom::OriginAttributesDictionary
 {
 public:
+  OriginAttributes() {}
+
+  OriginAttributes(uint32_t aAppId, bool aInIsolatedMozBrowser)
+  {
+    mAppId = aAppId;
+    mInIsolatedMozBrowser = aInIsolatedMozBrowser;
+  }
+
+  explicit OriginAttributes(const OriginAttributesDictionary& aOther)
+    : OriginAttributesDictionary(aOther)
+  {}
+
+  // This method 'clones' the OriginAttributes ignoring the addonId value becaue
+  // this is computed from the principal URI and never propagated.
+  void Inherit(const OriginAttributes& aAttrs);
+
+  void SetFirstPartyDomain(const bool aIsTopLevelDocument, nsIURI* aURI);
+
+  enum {
+    STRIP_FIRST_PARTY_DOMAIN = 0x01,
+    STRIP_ADDON_ID = 0x02,
+    STRIP_USER_CONTEXT_ID = 0x04,
+  };
+
+  inline void StripAttributes(uint32_t aFlags)
+  {
+    if (aFlags & STRIP_FIRST_PARTY_DOMAIN) {
+      mFirstPartyDomain.Truncate();
+    }
+
+    if (aFlags & STRIP_ADDON_ID) {
+      mAddonId.Truncate();
+    }
+
+    if (aFlags & STRIP_USER_CONTEXT_ID) {
+      mUserContextId = nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID;
+    }
+  }
+
   bool operator==(const OriginAttributes& aOther) const
   {
     return mAppId == aOther.mAppId &&
            mInIsolatedMozBrowser == aOther.mInIsolatedMozBrowser &&
            mAddonId == aOther.mAddonId &&
            mUserContextId == aOther.mUserContextId &&
            mPrivateBrowsingId == aOther.mPrivateBrowsingId &&
            mFirstPartyDomain == aOther.mFirstPartyDomain;
   }
+
   bool operator!=(const OriginAttributes& aOther) const
   {
     return !(*this == aOther);
   }
 
   // Serializes/Deserializes non-default values into the suffix format, i.e.
   // |!key1=value1&key2=value2|. If there are no non-default attributes, this
   // returns an empty string.
@@ -56,115 +95,22 @@ public:
   // |uri!key1=value1&key2=value2| and returns the uri without the suffix.
   MOZ_MUST_USE bool PopulateFromOrigin(const nsACString& aOrigin,
                                        nsACString& aOriginNoSuffix);
 
   // Helper function to match mIsPrivateBrowsing to existing private browsing
   // flags. Once all other flags are removed, this can be removed too.
   void SyncAttributesWithPrivateBrowsing(bool aInPrivateBrowsing);
 
-  void SetFromGenericAttributes(const GenericOriginAttributes& aAttrs);
-
   // check if "privacy.firstparty.isolate" is enabled.
   static bool IsFirstPartyEnabled();
 
   // returns true if the originAttributes suffix has mPrivateBrowsingId value
   // different than 0.
   static bool IsPrivateBrowsing(const nsACString& aOrigin);
-
-protected:
-  OriginAttributes() {}
-  explicit OriginAttributes(const OriginAttributesDictionary& aOther)
-    : OriginAttributesDictionary(aOther) {}
-};
-
-class PrincipalOriginAttributes;
-class DocShellOriginAttributes;
-class NeckoOriginAttributes;
-
-// Various classes in Gecko contain OriginAttributes members, and those
-// OriginAttributes get propagated to other classes according to certain rules.
-// For example, the OriginAttributes on the docshell affect the OriginAttributes
-// for the principal of a document loaded inside it, whose OriginAttributes in
-// turn affect those of network loads and child docshells. To codify and
-// centralize these rules, we introduce separate subclasses for the different
-// flavors, and a variety of InheritFrom* methods to implement the transfer
-// behavior.
-
-// For OriginAttributes stored on principals.
-class PrincipalOriginAttributes : public OriginAttributes
-{
-public:
-  PrincipalOriginAttributes() {}
-  PrincipalOriginAttributes(uint32_t aAppId, bool aInIsolatedMozBrowser)
-  {
-    mAppId = aAppId;
-    mInIsolatedMozBrowser = aInIsolatedMozBrowser;
-  }
-
-  // Inheriting OriginAttributes from docshell to document when user navigates.
-  //
-  // @param aAttrs  Origin Attributes of the docshell.
-  // @param aURI    The URI of the document.
-  void InheritFromDocShellToDoc(const DocShellOriginAttributes& aAttrs,
-                                const nsIURI* aURI);
-
-  // Inherit OriginAttributes from Necko.
-  void InheritFromNecko(const NeckoOriginAttributes& aAttrs);
-
-  void StripUserContextIdAndFirstPartyDomain();
-};
-
-// For OriginAttributes stored on docshells / loadcontexts / browsing contexts.
-class DocShellOriginAttributes : public OriginAttributes
-{
-public:
-  DocShellOriginAttributes() {}
-  DocShellOriginAttributes(uint32_t aAppId, bool aInIsolatedMozBrowser)
-  {
-    mAppId = aAppId;
-    mInIsolatedMozBrowser = aInIsolatedMozBrowser;
-  }
-
-  // Inheriting OriginAttributes from document to child docshell when an
-  // <iframe> is created.
-  //
-  // @param aAttrs  Origin Attributes of the document.
-  void
-  InheritFromDocToChildDocShell(const PrincipalOriginAttributes& aAttrs);
-};
-
-// For OriginAttributes stored on Necko.
-class NeckoOriginAttributes : public OriginAttributes
-{
-public:
-  NeckoOriginAttributes() {}
-  explicit NeckoOriginAttributes(bool aInIsolatedMozBrowser)
-  {
-    mInIsolatedMozBrowser = aInIsolatedMozBrowser;
-  }
-
-  // Inheriting OriginAttributes from document to necko when a network request
-  // is made.
-  void InheritFromDocToNecko(const PrincipalOriginAttributes& aAttrs);
-
-  // Inheriting OriginAttributes from a docshell when loading a top-level
-  // document.
-  void InheritFromDocShellToNecko(const DocShellOriginAttributes& aAttrs,
-                                  const bool aIsTopLevelDocument = false,
-                                  nsIURI* aURI = nullptr);
-};
-
-// For operating on OriginAttributes not associated with any data structure.
-class GenericOriginAttributes : public OriginAttributes
-{
-public:
-  GenericOriginAttributes() {}
-  explicit GenericOriginAttributes(const OriginAttributesDictionary& aOther)
-    : OriginAttributes(aOther) {}
 };
 
 class OriginAttributesPattern : public dom::OriginAttributesPatternDictionary
 {
 public:
   // To convert a JSON string to an OriginAttributesPattern, do the following:
   //
   // OriginAttributesPattern pattern;
@@ -289,20 +235,20 @@ public:
   virtual bool AddonHasPermission(const nsAString& aPerm);
 
   virtual bool IsOnCSSUnprefixingWhitelist() override { return false; }
 
   virtual bool IsCodebasePrincipal() const { return false; };
 
   static BasePrincipal* Cast(nsIPrincipal* aPrin) { return static_cast<BasePrincipal*>(aPrin); }
   static already_AddRefed<BasePrincipal>
-  CreateCodebasePrincipal(nsIURI* aURI, const PrincipalOriginAttributes& aAttrs);
+  CreateCodebasePrincipal(nsIURI* aURI, const OriginAttributes& aAttrs);
   static already_AddRefed<BasePrincipal> CreateCodebasePrincipal(const nsACString& aOrigin);
 
-  const PrincipalOriginAttributes& OriginAttributesRef() override { return mOriginAttributes; }
+  const OriginAttributes& OriginAttributesRef() override { return mOriginAttributes; }
   uint32_t AppId() const { return mOriginAttributes.mAppId; }
   uint32_t UserContextId() const { return mOriginAttributes.mUserContextId; }
   uint32_t PrivateBrowsingId() const { return mOriginAttributes.mPrivateBrowsingId; }
   bool IsInIsolatedMozBrowserElement() const { return mOriginAttributes.mInIsolatedMozBrowser; }
 
   enum PrincipalKind {
     eNullPrincipal,
     eCodebasePrincipal,
@@ -329,14 +275,14 @@ protected:
   friend class ::nsExpandedPrincipal;
 
   // Helper to check whether this principal is associated with an addon that
   // allows unprivileged code to load aURI.
   bool AddonAllowsLoad(nsIURI* aURI);
 
   nsCOMPtr<nsIContentSecurityPolicy> mCSP;
   nsCOMPtr<nsIContentSecurityPolicy> mPreloadCSP;
-  PrincipalOriginAttributes mOriginAttributes;
+  OriginAttributes mOriginAttributes;
 };
 
 } // namespace mozilla
 
 #endif /* mozilla_BasePrincipal_h */
--- a/caps/nsIPrincipal.idl
+++ b/caps/nsIPrincipal.idl
@@ -7,28 +7,28 @@
 
 #include "nsISerializable.idl"
 
 %{C++
 struct JSPrincipals;
 #include "nsCOMPtr.h"
 #include "nsTArray.h"
 namespace mozilla {
-class PrincipalOriginAttributes;
+class OriginAttributes;
 }
 %}
 
 interface nsIURI;
 interface nsIContentSecurityPolicy;
 interface nsIDOMDocument;
 
 [ptr] native JSContext(JSContext);
 [ptr] native JSPrincipals(JSPrincipals);
 [ptr] native PrincipalArray(nsTArray<nsCOMPtr<nsIPrincipal> >);
-[ref] native const_PrincipalOriginAttributes(const mozilla::PrincipalOriginAttributes);
+[ref] native const_OriginAttributes(const mozilla::OriginAttributes);
 
 [scriptable, builtinclass, uuid(3da7b133-f1a0-4de9-a2bc-5c49014c1077)]
 interface nsIPrincipal : nsISerializable
 {
     /**
      * Returns whether the other principal is equivalent to this principal.
      * Principals are considered equal if they are the same principal, or
      * they have the same origin.
@@ -193,17 +193,17 @@ interface nsIPrincipal : nsISerializable
      *
      * If you're looking for an easy-to-use canonical stringification of the origin
      * attributes, see |originSuffix| below.
      */
     [implicit_jscontext]
     readonly attribute jsval originAttributes;
 
     [noscript, notxpcom, nostdcall, binaryname(OriginAttributesRef)]
-    const_PrincipalOriginAttributes OriginAttributesRef();
+    const_OriginAttributes OriginAttributesRef();
 
     /**
      * A canonical representation of the origin for this principal. This
      * consists of a base string (which, for codebase principals, is of the
      * format scheme://host:port), concatenated with |originAttributes| (see
      * below).
      *
      * We maintain the invariant that principalA.equals(principalB) if and only
--- a/caps/nsJSPrincipals.cpp
+++ b/caps/nsJSPrincipals.cpp
@@ -121,17 +121,17 @@ nsJSPrincipals::ReadPrincipals(JSContext
         return false;
     }
 
     return ReadKnownPrincipalType(aCx, aReader, tag, aOutPrincipals);
 }
 
 static bool
 ReadSuffixAndSpec(JSStructuredCloneReader* aReader,
-                  PrincipalOriginAttributes& aAttrs,
+                  OriginAttributes& aAttrs,
                   nsACString& aSpec)
 {
     uint32_t suffixLength, specLength;
     if (!JS_ReadUint32Pair(aReader, &suffixLength, &specLength)) {
         return false;
     }
 
     nsAutoCString suffix;
@@ -155,17 +155,17 @@ ReadSuffixAndSpec(JSStructuredCloneReade
 static bool
 ReadPrincipalInfo(JSStructuredCloneReader* aReader,
                   uint32_t aTag,
                   PrincipalInfo& aInfo)
 {
     if (aTag == SCTAG_DOM_SYSTEM_PRINCIPAL) {
         aInfo = SystemPrincipalInfo();
     } else if (aTag == SCTAG_DOM_NULL_PRINCIPAL) {
-        PrincipalOriginAttributes attrs;
+        OriginAttributes attrs;
         nsAutoCString spec;
         if (!ReadSuffixAndSpec(aReader, attrs, spec)) {
             return false;
         }
         aInfo = NullPrincipalInfo(attrs, spec);
     } else if (aTag == SCTAG_DOM_EXPANDED_PRINCIPAL) {
         uint32_t length, unused;
         if (!JS_ReadUint32Pair(aReader, &length, &unused)) {
@@ -184,17 +184,17 @@ ReadPrincipalInfo(JSStructuredCloneReade
             if (!ReadPrincipalInfo(aReader, tag, sub)) {
                 return false;
             }
             expanded.whitelist().AppendElement(sub);
         }
 
         aInfo = expanded;
     } else if (aTag == SCTAG_DOM_CONTENT_PRINCIPAL) {
-        PrincipalOriginAttributes attrs;
+        OriginAttributes attrs;
         nsAutoCString spec;
         if (!ReadSuffixAndSpec(aReader, attrs, spec)) {
             return false;
         }
 
         aInfo = ContentPrincipalInfo(attrs, spec);
     } else {
         MOZ_CRASH("unexpected principal structured clone tag");
@@ -232,17 +232,17 @@ nsJSPrincipals::ReadKnownPrincipalType(J
     }
 
     *aOutPrincipals = get(prin.forget().take());
     return true;
 }
 
 static bool
 WriteSuffixAndSpec(JSStructuredCloneWriter* aWriter,
-                   const PrincipalOriginAttributes& aAttrs,
+                   const OriginAttributes& aAttrs,
                    const nsCString& aSpec)
 {
   nsAutoCString suffix;
   aAttrs.CreateSuffix(suffix);
 
   return JS_WriteUint32Pair(aWriter, suffix.Length(), aSpec.Length()) &&
          JS_WriteBytes(aWriter, suffix.get(), suffix.Length()) &&
          JS_WriteBytes(aWriter, aSpec.get(), aSpec.Length());
--- a/caps/nsNullPrincipal.cpp
+++ b/caps/nsNullPrincipal.cpp
@@ -43,39 +43,37 @@ nsNullPrincipal::CreateWithInheritedAttr
   nsresult rv = nullPrin->Init(Cast(aInheritFrom)->OriginAttributesRef());
   MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
   return nullPrin.forget();
 }
 
 /* static */ already_AddRefed<nsNullPrincipal>
 nsNullPrincipal::CreateWithInheritedAttributes(nsIDocShell* aDocShell)
 {
-  PrincipalOriginAttributes attrs;
-  attrs.InheritFromDocShellToDoc(nsDocShell::Cast(aDocShell)->GetOriginAttributes(), nullptr);
+  OriginAttributes attrs;
+  attrs.Inherit(nsDocShell::Cast(aDocShell)->GetOriginAttributes());
 
   RefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal();
   nsresult rv = nullPrin->Init(attrs);
   MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
   return nullPrin.forget();
 }
 
 /* static */ already_AddRefed<nsNullPrincipal>
-nsNullPrincipal::Create(const PrincipalOriginAttributes& aOriginAttributes,
-                        nsIURI* aURI)
+nsNullPrincipal::Create(const OriginAttributes& aOriginAttributes, nsIURI* aURI)
 {
   RefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal();
   nsresult rv = nullPrin->Init(aOriginAttributes, aURI);
   MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
 
   return nullPrin.forget();
 }
 
 nsresult
-nsNullPrincipal::Init(const PrincipalOriginAttributes& aOriginAttributes,
-                      nsIURI* aURI)
+nsNullPrincipal::Init(const OriginAttributes& aOriginAttributes, nsIURI* aURI)
 {
   mOriginAttributes = aOriginAttributes;
 
   if (aURI) {
     nsAutoCString scheme;
     nsresult rv = aURI->GetScheme(scheme);
     NS_ENSURE_SUCCESS(rv, rv);
 
--- a/caps/nsNullPrincipal.h
+++ b/caps/nsNullPrincipal.h
@@ -48,20 +48,20 @@ public:
   NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
   nsresult GetOriginInternal(nsACString& aOrigin) override;
 
   static already_AddRefed<nsNullPrincipal> CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom);
 
   static already_AddRefed<nsNullPrincipal> CreateWithInheritedAttributes(nsIDocShell* aDocShell);
 
   static already_AddRefed<nsNullPrincipal>
-  Create(const mozilla::PrincipalOriginAttributes& aOriginAttributes = mozilla::PrincipalOriginAttributes(),
+  Create(const mozilla::OriginAttributes& aOriginAttributes = mozilla::OriginAttributes(),
          nsIURI* aURI = nullptr);
 
-  nsresult Init(const mozilla::PrincipalOriginAttributes& aOriginAttributes = mozilla::PrincipalOriginAttributes(),
+  nsresult Init(const mozilla::OriginAttributes& aOriginAttributes = mozilla::OriginAttributes(),
                 nsIURI* aURI = nullptr);
 
   virtual nsresult GetScriptLocation(nsACString &aStr) override;
 
   PrincipalKind Kind() override { return eNullPrincipal; }
 
  protected:
   virtual ~nsNullPrincipal() {}
--- a/caps/nsPrincipal.cpp
+++ b/caps/nsPrincipal.cpp
@@ -77,17 +77,17 @@ nsPrincipal::~nsPrincipal()
 {
   // let's clear the principal within the csp to avoid a tangling pointer
   if (mCSP) {
     static_cast<nsCSPContext*>(mCSP.get())->clearLoadingPrincipal();
   }
 }
 
 nsresult
-nsPrincipal::Init(nsIURI *aCodebase, const PrincipalOriginAttributes& aOriginAttributes)
+nsPrincipal::Init(nsIURI *aCodebase, const OriginAttributes& aOriginAttributes)
 {
   NS_ENSURE_STATE(!mInitialized);
   NS_ENSURE_ARG(aCodebase);
 
   mInitialized = true;
 
   mCodebase = NS_TryToMakeImmutable(aCodebase);
   mCodebaseImmutable = URIIsImmutable(mCodebase);
@@ -399,17 +399,17 @@ nsPrincipal::Read(nsIObjectInputStream* 
   }
 
   domain = do_QueryInterface(supports);
 
   nsAutoCString suffix;
   rv = aStream->ReadCString(suffix);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   bool ok = attrs.PopulateFromSuffix(suffix);
   NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
 
   rv = NS_ReadOptionalObject(aStream, true, getter_AddRefs(supports));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = Init(codebase, attrs);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -683,17 +683,17 @@ struct OriginComparator
     nsAutoCString originB;
     rv = b->GetOrigin(originB);
     NS_ENSURE_SUCCESS(rv, false);
     return a == b;
   }
 };
 
 nsExpandedPrincipal::nsExpandedPrincipal(nsTArray<nsCOMPtr<nsIPrincipal>> &aWhiteList,
-                                         const PrincipalOriginAttributes& aAttrs)
+                                         const OriginAttributes& aAttrs)
 {
   // We force the principals to be sorted by origin so that nsExpandedPrincipal
   // origins can have a canonical form.
   OriginComparator c;
   for (size_t i = 0; i < aWhiteList.Length(); ++i) {
     mPrincipals.InsertElementSorted(aWhiteList[i], c);
   }
   mOriginAttributes = aAttrs;
--- a/caps/nsPrincipal.h
+++ b/caps/nsPrincipal.h
@@ -27,17 +27,18 @@ public:
   NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
   virtual bool IsOnCSSUnprefixingWhitelist() override;
   bool IsCodebasePrincipal() const override { return true; }
   nsresult GetOriginInternal(nsACString& aOrigin) override;
 
   nsPrincipal();
 
   // Init() must be called before the principal is in a usable state.
-  nsresult Init(nsIURI* aCodebase, const mozilla::PrincipalOriginAttributes& aOriginAttributes);
+  nsresult Init(nsIURI* aCodebase,
+                const mozilla::OriginAttributes& aOriginAttributes);
 
   virtual nsresult GetScriptLocation(nsACString& aStr) override;
   void SetURI(nsIURI* aURI);
 
   /**
    * Called at startup to setup static data, e.g. about:config pref-observers.
    */
   static void InitializeStatics();
@@ -58,17 +59,17 @@ protected:
   bool SubsumesInternal(nsIPrincipal* aOther, DocumentDomainConsideration aConsideration) override;
   bool MayLoadInternal(nsIURI* aURI) override;
 };
 
 class nsExpandedPrincipal : public nsIExpandedPrincipal, public mozilla::BasePrincipal
 {
 public:
   nsExpandedPrincipal(nsTArray<nsCOMPtr<nsIPrincipal>> &aWhiteList,
-                      const mozilla::PrincipalOriginAttributes& aAttrs);
+                      const mozilla::OriginAttributes& aAttrs);
 
   NS_DECL_NSIEXPANDEDPRINCIPAL
   NS_DECL_NSISERIALIZABLE
   NS_IMETHOD_(MozExternalRefCountType) AddRef() override { return nsJSPrincipals::AddRef(); };
   NS_IMETHOD_(MozExternalRefCountType) Release() override { return nsJSPrincipals::Release(); };
   NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
   NS_IMETHOD GetHashValue(uint32_t* aHashValue) override;
   NS_IMETHOD GetURI(nsIURI** aURI) override;
--- a/caps/nsScriptSecurityManager.cpp
+++ b/caps/nsScriptSecurityManager.cpp
@@ -293,21 +293,20 @@ nsScriptSecurityManager::GetChannelResul
 
     if (loadInfo) {
         if (!aIgnoreSandboxing && loadInfo->GetLoadingSandboxed()) {
             RefPtr<nsNullPrincipal> prin;
             if (loadInfo->LoadingPrincipal()) {
               prin =
                 nsNullPrincipal::CreateWithInheritedAttributes(loadInfo->LoadingPrincipal());
             } else {
-              NeckoOriginAttributes nAttrs;
-              loadInfo->GetOriginAttributes(&nAttrs);
-              PrincipalOriginAttributes pAttrs;
-              pAttrs.InheritFromNecko(nAttrs);
-              prin = nsNullPrincipal::Create(pAttrs);
+              OriginAttributes attrs;
+              loadInfo->GetOriginAttributes(&attrs);
+              attrs.StripAttributes(OriginAttributes::STRIP_ADDON_ID);
+              prin = nsNullPrincipal::Create(attrs);
             }
             prin.forget(aPrincipal);
             return NS_OK;
         }
 
         bool forceInherit = loadInfo->GetForceInheritPrincipal();
         if (aIgnoreSandboxing && !forceInherit) {
           // Check if SEC_FORCE_INHERIT_PRINCIPAL was dropped because of
@@ -351,17 +350,17 @@ nsScriptSecurityManager::GetChannelResul
                 return NS_OK;
             }
         }
     }
     return GetChannelURIPrincipal(aChannel, aPrincipal);
 }
 
 nsresult
-nsScriptSecurityManager::MaybeSetAddonIdFromURI(PrincipalOriginAttributes& aAttrs, nsIURI* aURI)
+nsScriptSecurityManager::MaybeSetAddonIdFromURI(OriginAttributes& aAttrs, nsIURI* aURI)
 {
   nsAutoCString scheme;
   nsresult rv = aURI->GetScheme(scheme);
   NS_ENSURE_SUCCESS(rv, rv);
   if (scheme.EqualsLiteral("moz-extension") && GetAddonPolicyService()) {
     rv = GetAddonPolicyService()->ExtensionURIToAddonId(aURI, aAttrs.mAddonId);
     NS_ENSURE_SUCCESS(rv, rv);
   }
@@ -395,21 +394,21 @@ nsScriptSecurityManager::GetChannelURIPr
     nsCOMPtr<nsILoadInfo> loadInfo;
     aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
 
     // Inherit the origin attributes from loadInfo.
     // If this is a top-level document load, the origin attributes of the
     // loadInfo will be set from nsDocShell::DoURILoad.
     // For subresource loading, the origin attributes of the loadInfo is from
     // its loadingPrincipal.
-    PrincipalOriginAttributes attrs;
+    OriginAttributes attrs;
 
     // For addons loadInfo might be null.
     if (loadInfo) {
-      attrs.InheritFromNecko(loadInfo->GetOriginAttributes());
+      attrs.Inherit(loadInfo->GetOriginAttributes());
     }
     rv = MaybeSetAddonIdFromURI(attrs, uri);
     NS_ENSURE_SUCCESS(rv, rv);
     nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
     prin.forget(aPrincipal);
     return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
 }
 
@@ -1065,34 +1064,34 @@ nsScriptSecurityManager::GetSystemPrinci
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::GetNoAppCodebasePrincipal(nsIURI* aURI,
                                                    nsIPrincipal** aPrincipal)
 {
-  PrincipalOriginAttributes attrs(NO_APP_ID, false);
+  OriginAttributes attrs;
   nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
   prin.forget(aPrincipal);
   return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::GetCodebasePrincipal(nsIURI* aURI,
                                               nsIPrincipal** aPrincipal)
 {
   return GetNoAppCodebasePrincipal(aURI, aPrincipal);
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::CreateCodebasePrincipal(nsIURI* aURI, JS::Handle<JS::Value> aOriginAttributes,
                                                  JSContext* aCx, nsIPrincipal** aPrincipal)
 {
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
       return NS_ERROR_INVALID_ARG;
   }
   nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
   prin.forget(aPrincipal);
   return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
 }
 
@@ -1112,17 +1111,17 @@ nsScriptSecurityManager::CreateCodebaseP
   prin.forget(aPrincipal);
   return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::CreateNullPrincipal(JS::Handle<JS::Value> aOriginAttributes,
                                              JSContext* aCx, nsIPrincipal** aPrincipal)
 {
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
       return NS_ERROR_INVALID_ARG;
   }
   nsCOMPtr<nsIPrincipal> prin = nsNullPrincipal::Create(attrs);
   prin.forget(aPrincipal);
   return NS_OK;
 }
 
@@ -1130,50 +1129,50 @@ NS_IMETHODIMP
 nsScriptSecurityManager::GetAppCodebasePrincipal(nsIURI* aURI,
                                                  uint32_t aAppId,
                                                  bool aInIsolatedMozBrowser,
                                                  nsIPrincipal** aPrincipal)
 {
   NS_ENSURE_TRUE(aAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID,
                  NS_ERROR_INVALID_ARG);
 
-  PrincipalOriginAttributes attrs(aAppId, aInIsolatedMozBrowser);
+  OriginAttributes attrs(aAppId, aInIsolatedMozBrowser);
   nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
   prin.forget(aPrincipal);
   return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::
   GetLoadContextCodebasePrincipal(nsIURI* aURI,
                                   nsILoadContext* aLoadContext,
                                   nsIPrincipal** aPrincipal)
 {
   NS_ENSURE_STATE(aLoadContext);
-  DocShellOriginAttributes docShellAttrs;
+  OriginAttributes docShellAttrs;
   bool result = aLoadContext->GetOriginAttributes(docShellAttrs);;
   NS_ENSURE_TRUE(result, NS_ERROR_FAILURE);
 
-  PrincipalOriginAttributes attrs;
-  attrs.InheritFromDocShellToDoc(docShellAttrs, aURI);
+  OriginAttributes attrs;
+  attrs.Inherit(docShellAttrs);
 
   nsresult rv = MaybeSetAddonIdFromURI(attrs, aURI);
   NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
   prin.forget(aPrincipal);
   return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::GetDocShellCodebasePrincipal(nsIURI* aURI,
                                                       nsIDocShell* aDocShell,
                                                       nsIPrincipal** aPrincipal)
 {
-  PrincipalOriginAttributes attrs;
-  attrs.InheritFromDocShellToDoc(nsDocShell::Cast(aDocShell)->GetOriginAttributes(), aURI);
+  OriginAttributes attrs;
+  attrs.Inherit(nsDocShell::Cast(aDocShell)->GetOriginAttributes());
 
   nsresult rv = MaybeSetAddonIdFromURI(attrs, aURI);
   NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
   prin.forget(aPrincipal);
   return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
 }
 
--- a/caps/nsScriptSecurityManager.h
+++ b/caps/nsScriptSecurityManager.h
@@ -22,17 +22,17 @@
 #include <stdint.h>
 
 class nsCString;
 class nsIIOService;
 class nsIStringBundle;
 class nsSystemPrincipal;
 
 namespace mozilla {
-class PrincipalOriginAttributes;
+class OriginAttributes;
 } // namespace mozilla
 
 /////////////////////////////
 // nsScriptSecurityManager //
 /////////////////////////////
 #define NS_SCRIPTSECURITYMANAGER_CID \
 { 0x7ee2a4c0, 0x4b93, 0x17d3, \
 { 0xba, 0x18, 0x00, 0x60, 0xb0, 0xf1, 0x99, 0xa2 }}
@@ -107,17 +107,17 @@ private:
 
     inline void
     ScriptSecurityPrefChanged();
 
     inline void
     AddSitesToFileURIWhitelist(const nsCString& aSiteList);
 
     // If aURI is a moz-extension:// URI, set mAddonId to the associated addon.
-    nsresult MaybeSetAddonIdFromURI(mozilla::PrincipalOriginAttributes& aAttrs, nsIURI* aURI);
+    nsresult MaybeSetAddonIdFromURI(mozilla::OriginAttributes& aAttrs, nsIURI* aURI);
 
     nsresult GetChannelResultPrincipal(nsIChannel* aChannel,
                                        nsIPrincipal** aPrincipal,
                                        bool aIgnoreSandboxing);
 
     nsresult
     CheckLoadURIFlags(nsIURI* aSourceURI, nsIURI* aTargetURI, nsIURI* aSourceBaseURI,
                       nsIURI* aTargetBaseURI, uint32_t aFlags);
--- a/caps/tests/gtest/TestOriginAttributes.cpp
+++ b/caps/tests/gtest/TestOriginAttributes.cpp
@@ -1,38 +1,38 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #include "gtest/gtest.h"
 #include "mozilla/BasePrincipal.h"
 
-using mozilla::PrincipalOriginAttributes;
+using mozilla::OriginAttributes;
 
 static void
-TestSuffix(const PrincipalOriginAttributes& attrs)
+TestSuffix(const OriginAttributes& attrs)
 {
   nsAutoCString suffix;
   attrs.CreateSuffix(suffix);
 
-  PrincipalOriginAttributes attrsFromSuffix;
+  OriginAttributes attrsFromSuffix;
   bool success = attrsFromSuffix.PopulateFromSuffix(suffix);
   EXPECT_TRUE(success);
 
   EXPECT_EQ(attrs, attrsFromSuffix);
 }
 
-TEST(PrincipalOriginAttributes, Suffix_default)
+TEST(OriginAttributes, Suffix_default)
 {
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   TestSuffix(attrs);
 }
 
-TEST(PrincipalOriginAttributes, Suffix_appId_inIsolatedMozBrowser)
+TEST(OriginAttributes, Suffix_appId_inIsolatedMozBrowser)
 {
-  PrincipalOriginAttributes attrs(1, true);
+  OriginAttributes attrs(1, true);
   TestSuffix(attrs);
 }
 
-TEST(PrincipalOriginAttributes, Suffix_maxAppId_inIsolatedMozBrowser)
+TEST(OriginAttributes, Suffix_maxAppId_inIsolatedMozBrowser)
 {
-  PrincipalOriginAttributes attrs(4294967295, true);
+  OriginAttributes attrs(4294967295, true);
   TestSuffix(attrs);
 }
--- a/docshell/base/LoadContext.cpp
+++ b/docshell/base/LoadContext.cpp
@@ -8,33 +8,33 @@
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/LoadContext.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/ScriptSettings.h" // for AutoJSAPI
 #include "nsContentUtils.h"
 #include "xpcpublic.h"
 
 bool
-nsILoadContext::GetOriginAttributes(mozilla::DocShellOriginAttributes& aAttrs)
+nsILoadContext::GetOriginAttributes(mozilla::OriginAttributes& aAttrs)
 {
   mozilla::dom::AutoJSAPI jsapi;
   bool ok = jsapi.Init(xpc::PrivilegedJunkScope());
   NS_ENSURE_TRUE(ok, false);
   JS::Rooted<JS::Value> v(jsapi.cx());
   nsresult rv = GetOriginAttributes(&v);
   NS_ENSURE_SUCCESS(rv, false);
   NS_ENSURE_TRUE(v.isObject(), false);
   JS::Rooted<JSObject*> obj(jsapi.cx(), &v.toObject());
 
   // If we're JS-implemented, the object will be left in a different (System-Principaled)
   // scope, so we may need to enter its compartment.
   MOZ_ASSERT(nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(obj)));
   JSAutoCompartment ac(jsapi.cx(), obj);
 
-  mozilla::DocShellOriginAttributes attrs;
+  mozilla::OriginAttributes attrs;
   ok = attrs.Init(jsapi.cx(), v);
   NS_ENSURE_TRUE(ok, false);
   aAttrs = attrs;
   return true;
 }
 
 namespace mozilla {
 
@@ -45,18 +45,17 @@ LoadContext::LoadContext(nsIPrincipal* a
   : mTopFrameElement(nullptr)
   , mNestedFrameId(0)
   , mIsContent(true)
   , mUseRemoteTabs(false)
 #ifdef DEBUG
   , mIsNotNull(true)
 #endif
 {
-  PrincipalOriginAttributes poa = aPrincipal->OriginAttributesRef();
-  mOriginAttributes.InheritFromDocToChildDocShell(poa);
+  mOriginAttributes.Inherit(aPrincipal->OriginAttributesRef());
   if (!aOptionalBase) {
     return;
   }
 
   MOZ_ALWAYS_SUCCEEDS(aOptionalBase->GetIsContent(&mIsContent));
   MOZ_ALWAYS_SUCCEEDS(aOptionalBase->GetUseRemoteTabs(&mUseRemoteTabs));
 }
 
--- a/docshell/base/LoadContext.h
+++ b/docshell/base/LoadContext.h
@@ -35,63 +35,63 @@ public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSILOADCONTEXT
   NS_DECL_NSIINTERFACEREQUESTOR
 
   // appId/inIsolatedMozBrowser arguments override those in SerializedLoadContext
   // provided by child process.
   LoadContext(const IPC::SerializedLoadContext& aToCopy,
               dom::Element* aTopFrameElement,
-              DocShellOriginAttributes& aAttrs)
+              OriginAttributes& aAttrs)
     : mTopFrameElement(do_GetWeakReference(aTopFrameElement))
     , mNestedFrameId(0)
     , mIsContent(aToCopy.mIsContent)
     , mUseRemoteTabs(aToCopy.mUseRemoteTabs)
     , mOriginAttributes(aAttrs)
 #ifdef DEBUG
     , mIsNotNull(aToCopy.mIsNotNull)
 #endif
   {
   }
 
   // appId/inIsolatedMozBrowser arguments override those in SerializedLoadContext
   // provided by child process.
   LoadContext(const IPC::SerializedLoadContext& aToCopy,
               uint64_t aNestedFrameId,
-              DocShellOriginAttributes& aAttrs)
+              OriginAttributes& aAttrs)
     : mTopFrameElement(nullptr)
     , mNestedFrameId(aNestedFrameId)
     , mIsContent(aToCopy.mIsContent)
     , mUseRemoteTabs(aToCopy.mUseRemoteTabs)
     , mOriginAttributes(aAttrs)
 #ifdef DEBUG
     , mIsNotNull(aToCopy.mIsNotNull)
 #endif
   {
   }
 
   LoadContext(dom::Element* aTopFrameElement,
               bool aIsContent,
               bool aUsePrivateBrowsing,
               bool aUseRemoteTabs,
-              const DocShellOriginAttributes& aAttrs)
+              const OriginAttributes& aAttrs)
     : mTopFrameElement(do_GetWeakReference(aTopFrameElement))
     , mNestedFrameId(0)
     , mIsContent(aIsContent)
     , mUseRemoteTabs(aUseRemoteTabs)
     , mOriginAttributes(aAttrs)
 #ifdef DEBUG
     , mIsNotNull(true)
 #endif
   {
     MOZ_DIAGNOSTIC_ASSERT(aUsePrivateBrowsing == (aAttrs.mPrivateBrowsingId > 0));
   }
 
   // Constructor taking reserved origin attributes.
-  explicit LoadContext(DocShellOriginAttributes& aAttrs)
+  explicit LoadContext(OriginAttributes& aAttrs)
     : mTopFrameElement(nullptr)
     , mNestedFrameId(0)
     , mIsContent(false)
     , mUseRemoteTabs(false)
     , mOriginAttributes(aAttrs)
 #ifdef DEBUG
     , mIsNotNull(true)
 #endif
@@ -105,17 +105,17 @@ public:
 
 private:
   ~LoadContext() {}
 
   nsWeakPtr mTopFrameElement;
   uint64_t mNestedFrameId;
   bool mIsContent;
   bool mUseRemoteTabs;
-  DocShellOriginAttributes mOriginAttributes;
+  OriginAttributes mOriginAttributes;
 #ifdef DEBUG
   bool mIsNotNull;
 #endif
 };
 
 } // namespace mozilla
 
 #endif // LoadContext_h
--- a/docshell/base/SerializedLoadContext.h
+++ b/docshell/base/SerializedLoadContext.h
@@ -47,17 +47,17 @@ public:
 
   // used to indicate if child-side LoadContext * was null.
   bool mIsNotNull;
   // used to indicate if child-side mUsePrivateBrowsing flag is valid, even if
   // mIsNotNull is false, i.e., child LoadContext was null.
   bool mIsPrivateBitValid;
   bool mIsContent;
   bool mUseRemoteTabs;
-  mozilla::DocShellOriginAttributes mOriginAttributes;
+  mozilla::OriginAttributes mOriginAttributes;
 };
 
 // Function to serialize over IPDL
 template<>
 struct ParamTraits<SerializedLoadContext>
 {
   typedef SerializedLoadContext paramType;
 
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -3551,19 +3551,19 @@ nsDocShell::CanAccessItem(nsIDocShellTre
   nsCOMPtr<nsIDocShellTreeItem> accessingRoot;
   aAccessingItem->GetSameTypeRootTreeItem(getter_AddRefs(accessingRoot));
   nsCOMPtr<nsIDocShell> accessingRootDS = do_QueryInterface(accessingRoot);
 
   nsCOMPtr<nsIDocShellTreeItem> targetRoot;
   aTargetItem->GetSameTypeRootTreeItem(getter_AddRefs(targetRoot));
   nsCOMPtr<nsIDocShell> targetRootDS = do_QueryInterface(targetRoot);
 
-  DocShellOriginAttributes targetOA =
+  OriginAttributes targetOA =
     static_cast<nsDocShell*>(targetDS.get())->GetOriginAttributes();
-  DocShellOriginAttributes accessingOA =
+  OriginAttributes accessingOA =
     static_cast<nsDocShell*>(accessingDS.get())->GetOriginAttributes();
 
   // When the first party isolation is on, the top-level docShell may not have
   // the firstPartyDomain in its originAttributes, but its document will have
   // it. So we get the firstPartyDomain from the nodePrincipal of the document
   // before we compare the originAttributes.
   if (OriginAttributes::IsFirstPartyEnabled()) {
     if (accessingDS == accessingRootDS &&
@@ -9668,18 +9668,18 @@ nsDocShell::JustStartedNetworkLoad()
 {
   return mDocumentRequest && mDocumentRequest != GetCurrentDocChannel();
 }
 
 nsresult
 nsDocShell::CreatePrincipalFromReferrer(nsIURI* aReferrer,
                                         nsIPrincipal** aResult)
 {
-  PrincipalOriginAttributes attrs;
-  attrs.InheritFromDocShellToDoc(mOriginAttributes, aReferrer);
+  OriginAttributes attrs;
+  attrs.Inherit(mOriginAttributes);
   nsCOMPtr<nsIPrincipal> prin =
     BasePrincipal::CreateCodebasePrincipal(aReferrer, attrs);
   prin.forget(aResult);
 
   return *aResult ? NS_OK : NS_ERROR_FAILURE;
 }
 
 bool
@@ -10893,22 +10893,24 @@ nsDocShell::DoURILoad(nsIURI* aURI,
 
   if (aPrincipalToInherit) {
     loadInfo->SetPrincipalToInherit(aPrincipalToInherit);
   }
 
   // We have to do this in case our OriginAttributes are different from the
   // OriginAttributes of the parent document. Or in case there isn't a
   // parent document.
-  NeckoOriginAttributes neckoAttrs;
   bool isTopLevelDoc = aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT &&
                        mItemType == typeContent &&
                        !GetIsMozBrowser();
-  neckoAttrs.InheritFromDocShellToNecko(GetOriginAttributes(), isTopLevelDoc, aURI);
-  rv = loadInfo->SetOriginAttributes(neckoAttrs);
+
+  OriginAttributes attrs;
+  attrs.Inherit(GetOriginAttributes());
+  attrs.SetFirstPartyDomain(isTopLevelDoc, aURI);
+  rv = loadInfo->SetOriginAttributes(attrs);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (!isSrcdoc) {
     rv = NS_NewChannelInternal(getter_AddRefs(channel),
                                aURI,
                                loadInfo,
@@ -12281,21 +12283,20 @@ nsDocShell::AddToSessionHistory(nsIURI* 
       // For now keep storing just the principal in the SHEntry.
       if (!principalToInherit) {
         if (loadInfo->GetLoadingSandboxed()) {
           if (loadInfo->LoadingPrincipal()) {
             principalToInherit = nsNullPrincipal::CreateWithInheritedAttributes(
             loadInfo->LoadingPrincipal());
           } else {
             // get the OriginAttributes
-            NeckoOriginAttributes nAttrs;
-            loadInfo->GetOriginAttributes(&nAttrs);
-            PrincipalOriginAttributes pAttrs;
-            pAttrs.InheritFromNecko(nAttrs);
-            principalToInherit = nsNullPrincipal::Create(pAttrs);
+            OriginAttributes attrs;
+            loadInfo->GetOriginAttributes(&attrs);
+            attrs.StripAttributes(OriginAttributes::STRIP_ADDON_ID);
+            principalToInherit = nsNullPrincipal::Create(attrs);
           }
         } else {
           principalToInherit = loadInfo->PrincipalToInherit();
         }
       }
     }
   }
 
@@ -14370,17 +14371,17 @@ nsDocShell::CanSetOriginAttributes()
       }
     }
   }
 
   return true;
 }
 
 nsresult
-nsDocShell::SetOriginAttributes(const DocShellOriginAttributes& aAttrs)
+nsDocShell::SetOriginAttributes(const OriginAttributes& aAttrs)
 {
   if (!CanSetOriginAttributes()) {
     return NS_ERROR_FAILURE;
   }
 
   AssertOriginAttributesMatchPrivateBrowsing();
   mOriginAttributes = aAttrs;
 
@@ -14408,29 +14409,29 @@ nsDocShell::SetOriginAttributesBeforeLoa
     return NS_ERROR_UNEXPECTED;
   }
 
   JSContext* cx = jsapi.cx();
   if (NS_WARN_IF(!cx)) {
     return NS_ERROR_FAILURE;
   }
 
-  DocShellOriginAttributes attrs;
+  OriginAttributes attrs;
   if (!aOriginAttributes.isObject() || !attrs.Init(cx, aOriginAttributes)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   return SetOriginAttributes(attrs);
 }
 
 NS_IMETHODIMP
 nsDocShell::SetOriginAttributes(JS::Handle<JS::Value> aOriginAttributes,
                                 JSContext* aCx)
 {
-  DocShellOriginAttributes attrs;
+  OriginAttributes attrs;
   if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   return SetOriginAttributes(attrs);
 }
 
 NS_IMETHODIMP
@@ -14600,18 +14601,18 @@ nsDocShell::ShouldPrepareForIntercept(ns
 
       if (isThirdPartyURI) {
         return NS_OK;
       }
     }
   }
 
   if (aIsNonSubresourceRequest) {
-    PrincipalOriginAttributes attrs;
-    attrs.InheritFromDocShellToDoc(mOriginAttributes, aURI);
+    OriginAttributes attrs;
+    attrs.Inherit(mOriginAttributes);
     nsCOMPtr<nsIPrincipal> principal =
       BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
     *aShouldIntercept = swm->IsAvailable(principal, aURI);
     return NS_OK;
   }
 
   nsCOMPtr<nsIDocument> doc = GetDocument();
   if (!doc) {
@@ -14652,22 +14653,18 @@ nsDocShell::ChannelIntercepted(nsIInterc
     // For top-level navigations, save a document ID which will be passed to
     // the FetchEvent as the clientId later on.
     rv = nsIDocument::GenerateDocumentId(mInterceptedDocumentId);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   bool isReload = mLoadType & LOAD_CMD_RELOAD;
 
-  nsCOMPtr<nsIURI> uri;
-  rv = channel->GetURI(getter_AddRefs(uri));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  PrincipalOriginAttributes attrs;
-  attrs.InheritFromDocShellToDoc(mOriginAttributes, uri);
+  OriginAttributes attrs;
+  attrs.Inherit(mOriginAttributes);
 
   ErrorResult error;
   swm->DispatchFetchEvent(attrs, doc, mInterceptedDocumentId, aChannel,
                           isReload, isSubresourceLoad, error);
   if (NS_WARN_IF(error.Failed())) {
     return error.StealNSResult();
   }
 
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -272,23 +272,23 @@ public:
     mInFrameSwap = aInSwap;
   }
   bool InFrameSwap();
 
 private:
   bool CanSetOriginAttributes();
 
 public:
-  const mozilla::DocShellOriginAttributes&
+  const mozilla::OriginAttributes&
   GetOriginAttributes()
   {
     return mOriginAttributes;
   }
 
-  nsresult SetOriginAttributes(const mozilla::DocShellOriginAttributes& aAttrs);
+  nsresult SetOriginAttributes(const mozilla::OriginAttributes& aAttrs);
 
   void GetInterceptedDocumentId(nsAString& aId)
   {
     aId = mInterceptedDocumentId;
   }
 
 private:
   // An observed docshell wrapper is created when recording markers is enabled.
@@ -1036,17 +1036,17 @@ private:
   nsCString mParentCharset;
   int32_t mParentCharsetSource;
   nsCOMPtr<nsIPrincipal> mParentCharsetPrincipal;
   nsTObserverArray<nsWeakPtr> mPrivacyObservers;
   nsTObserverArray<nsWeakPtr> mReflowObservers;
   nsTObserverArray<nsWeakPtr> mScrollObservers;
   nsCString mOriginalUriString;
   nsWeakPtr mOpener;
-  mozilla::DocShellOriginAttributes mOriginAttributes;
+  mozilla::OriginAttributes mOriginAttributes;
 
   // A depth count of how many times NotifyRunToCompletionStart
   // has been called without a matching NotifyRunToCompletionStop.
   uint32_t mJSRunToCompletionDepth;
 
   // Whether or not touch events are overridden. Possible values are defined
   // as constants in the nsIDocShell.idl file.
   uint32_t mTouchEventsOverride;
--- a/docshell/base/nsILoadContext.idl
+++ b/docshell/base/nsILoadContext.idl
@@ -6,17 +6,17 @@
 
 #include "nsISupports.idl"
 
 interface mozIDOMWindowProxy;
 interface nsIDOMElement;
 
 %{C++
 #ifdef MOZILLA_INTERNAL_API
-#include "mozilla/BasePrincipal.h" // for DocShellOriginAttributes
+#include "mozilla/BasePrincipal.h" // for OriginAttributes
 #endif
 %}
 
 /**
  * An nsILoadContext represents the context of a load.  This interface
  * can be queried for various information about where the load is
  * happening.
  */
@@ -122,17 +122,17 @@ interface nsILoadContext : nsISupports
 
 %{C++
 #ifdef MOZILLA_INTERNAL_API
   /**
    * The C++ getter for origin attributes.
    *
    * Defined in LoadContext.cpp
    */
-  bool GetOriginAttributes(mozilla::DocShellOriginAttributes& aAttrs);
+  bool GetOriginAttributes(mozilla::OriginAttributes& aAttrs);
 #endif
 %}
 
   /**
    * Returns true if tracking protection is enabled for the load context.
    */
   boolean IsTrackingProtectionOn();
 
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -425,16 +425,22 @@ KeyframeEffectReadOnly::EnsureBaseStyles
                                   CSS_PROPERTY_CAN_ANIMATE_ON_COMPOSITOR)) {
       continue;
     }
 
     if (aPropertiesToSkip.HasProperty(property.mProperty)) {
       continue;
     }
 
+    // We only call SetNeedsBaseStyle after calling GetBaseStyle so if
+    // NeedsBaseStyle is true, the base style should be already filled-in.
+    if (NeedsBaseStyle(property.mProperty)) {
+      continue;
+    }
+
     for (const AnimationPropertySegment& segment : property.mSegments) {
       if (segment.mFromComposite == dom::CompositeOperation::Replace &&
           segment.mToComposite == dom::CompositeOperation::Replace) {
         continue;
       }
 
       if (!styleContext) {
         styleContext = GetTargetStyleContext();
@@ -468,28 +474,25 @@ KeyframeEffectReadOnly::ComposeStyle(
   ComputedTiming computedTiming = GetComputedTiming();
   mProgressOnLastCompose = computedTiming.mProgress;
   mCurrentIterationOnLastCompose = computedTiming.mCurrentIteration;
 
   // If the progress is null, we don't have fill data for the current
   // time so we shouldn't animate.
   if (computedTiming.mProgress.IsNull()) {
     // If we are not in-effect, this effect might still be sent to the
-    // compositor and later become in-effect (e.g. if it is in the delay phase).
+    // compositor and later become in-effect (e.g. if it is in the delay phase,
+    // or, if it is in the end delay phase but with a negative playback rate).
     // In that case, we might need the base style in order to perform
     // additive/accumulative animation on the compositor.
 
-    // In case of properties that can be run on the compositor, we need the base
-    // styles for such properties because those animation will be sent to
-    // compositor while they are in delay phase so that we can composite this
-    // animation on the compositor once the animation is out of the delay phase
-    // on the compositor.
-    if (computedTiming.mPhase == ComputedTiming::AnimationPhase::Before) {
-      EnsureBaseStylesForCompositor(aPropertiesToSkip);
-    }
+    // Note, however, that we don't actually send animations with a negative
+    // playback rate in their end delay phase to the compositor at this stage
+    // (bug 1330498).
+    EnsureBaseStylesForCompositor(aPropertiesToSkip);
     return;
   }
 
   mNeedsBaseStyleSet.Empty();
 
   for (size_t propIdx = 0, propEnd = mProperties.Length();
        propIdx != propEnd; ++propIdx)
   {
@@ -586,16 +589,24 @@ KeyframeEffectReadOnly::ComposeStyle(
                                          valuePosition, val)) {
       aStyleRule->AddValue(prop.mProperty, Move(val));
     } else if (valuePosition < 0.5) {
       aStyleRule->AddValue(prop.mProperty, Move(fromValue));
     } else {
       aStyleRule->AddValue(prop.mProperty, Move(toValue));
     }
   }
+
+  // For properties that can be run on the compositor, we may need to prepare
+  // base styles to send to the compositor even if the current processing
+  // segment for properties does not have either an additive or accumulative
+  // composite mode, and even if the animation is not in-effect. That's because
+  // the animation may later progress to a segment which has an additive or
+  // accumulative composite on the compositor mode.
+  EnsureBaseStylesForCompositor(aPropertiesToSkip);
 }
 
 bool
 KeyframeEffectReadOnly::IsRunningOnCompositor() const
 {
   // We consider animation is running on compositor if there is at least
   // one property running on compositor.
   // Animation.IsRunningOnCompotitor will return more fine grained
new file mode 100644
--- /dev/null
+++ b/dom/animation/test/crashtests/1322291-2.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<style>
+div {
+  width: 100px;
+  height: 100px;
+  background-color: red;
+}
+</style>
+<body>
+<div id=o_0></div>
+<script>
+function boom(){
+  var anim = o_0.animate([
+    {},
+    {"transform": "scale(2)"},
+    {"transform": "none"}
+    ], {
+      duration: 100,
+      iterationStart: 0.5,
+    });
+  // We need to wait for finished promise just like we do in 1322291-1.html.
+  anim.finished.then(function() {
+    document.documentElement.classList.remove("reftest-wait");
+  });
+}
+document.addEventListener("DOMContentLoaded", boom);
+</script>
+
+</body>
+</html>
--- a/dom/animation/test/crashtests/crashtests.list
+++ b/dom/animation/test/crashtests/crashtests.list
@@ -8,13 +8,14 @@ asserts-if(stylo,4-10) pref(dom.animatio
 asserts-if(stylo,4-10) pref(dom.animations-api.core.enabled,true) load 1216842-6.html # bug 1324693
 asserts-if(stylo,3-10) pref(dom.animations-api.core.enabled,true) load 1272475-1.html # bug 1324693
 asserts-if(stylo,4-10) pref(dom.animations-api.core.enabled,true) load 1272475-2.html # bug 1324693
 asserts-if(stylo,5) pref(dom.animations-api.core.enabled,true) load 1278485-1.html # bug 1324691
 asserts-if(stylo,31) pref(dom.animations-api.core.enabled,true) load 1277272-1.html # bug 1324694
 asserts-if(stylo,2) pref(dom.animations-api.core.enabled,true) load 1290535-1.html # bug 1324690
 pref(dom.animations-api.core.enabled,true) load 1304886-1.html
 pref(dom.animations-api.core.enabled,true) load 1322382-1.html
-skip-if(stylo) pref(dom.animations-api.core.enabled,true) load 1322291-1.html # bug 1323733
+skip-if(stylo) pref(dom.animations-api.core.enabled,true) load 1322291-1.html # bug 1311257
+skip-if(stylo) pref(dom.animations-api.core.enabled,true) load 1322291-2.html # bug 1311257
 asserts-if(stylo,0-5) pref(dom.animations-api.core.enabled,true) load 1323114-1.html # bug 1324690
 asserts-if(stylo,0-5) pref(dom.animations-api.core.enabled,true) load 1323114-2.html # bug 1324690
 skip-if(stylo) pref(dom.animations-api.core.enabled,true) load 1330513-1.html # bug 1311257
 skip-if(stylo) pref(dom.animations-api.core.enabled,true) load 1325193-1.html # bug 1311257
--- a/dom/base/ChromeUtils.cpp
+++ b/dom/base/ChromeUtils.cpp
@@ -127,37 +127,37 @@ ThreadSafeChromeUtils::Base64URLDecode(G
 }
 
 /* static */ void
 ChromeUtils::OriginAttributesToSuffix(dom::GlobalObject& aGlobal,
                                       const dom::OriginAttributesDictionary& aAttrs,
                                       nsCString& aSuffix)
 
 {
-  GenericOriginAttributes attrs(aAttrs);
+  OriginAttributes attrs(aAttrs);
   attrs.CreateSuffix(aSuffix);
 }
 
 /* static */ bool
 ChromeUtils::OriginAttributesMatchPattern(dom::GlobalObject& aGlobal,
                                           const dom::OriginAttributesDictionary& aAttrs,
                                           const dom::OriginAttributesPatternDictionary& aPattern)
 {
-  GenericOriginAttributes attrs(aAttrs);
+  OriginAttributes attrs(aAttrs);
   OriginAttributesPattern pattern(aPattern);
   return pattern.Matches(attrs);
 }
 
 /* static */ void
 ChromeUtils::CreateOriginAttributesFromOrigin(dom::GlobalObject& aGlobal,
                                        const nsAString& aOrigin,
                                        dom::OriginAttributesDictionary& aAttrs,
                                        ErrorResult& aRv)
 {
-  GenericOriginAttributes attrs;
+  OriginAttributes attrs;
   nsAutoCString suffix;
   if (!attrs.PopulateFromOrigin(NS_ConvertUTF16toUTF8(aOrigin), suffix)) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
   aAttrs = attrs;
 }
 
--- a/dom/base/DOMParser.cpp
+++ b/dom/base/DOMParser.cpp
@@ -345,17 +345,17 @@ DOMParser::Init(nsIPrincipal* principal,
                                     NS_LITERAL_CSTRING("DOM"),
                                     nullptr,
                                     nsContentUtils::eDOM_PROPERTIES,
                                     "ChromeScriptedDOMParserWithoutPrincipal",
                                     nullptr,
                                     0,
                                     documentURI);
 
-    PrincipalOriginAttributes attrs;
+    OriginAttributes attrs;
     mPrincipal = BasePrincipal::CreateCodebasePrincipal(mDocumentURI, attrs);
     NS_ENSURE_TRUE(mPrincipal, NS_ERROR_FAILURE);
     mOriginalPrincipal = mPrincipal;
   } else {
     mOriginalPrincipal = mPrincipal;
     if (nsContentUtils::IsSystemPrincipal(mPrincipal)) {
       // Don't give DOMParsers the system principal.  Use a null
       // principal instead.
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -3140,52 +3140,50 @@ nsContentUtils::CanLoadImage(nsIURI* aUR
   if (aImageBlockingStatus) {
     *aImageBlockingStatus =
       NS_FAILED(rv) ? nsIContentPolicy::REJECT_REQUEST : decision;
   }
   return NS_FAILED(rv) ? false : NS_CP_ACCEPTED(decision);
 }
 
 // static
-mozilla::PrincipalOriginAttributes
+mozilla::OriginAttributes
 nsContentUtils::GetOriginAttributes(nsIDocument* aDocument)
 {
   if (!aDocument) {
-    return mozilla::PrincipalOriginAttributes();
+    return mozilla::OriginAttributes();
   }
 
   nsCOMPtr<nsILoadGroup> loadGroup = aDocument->GetDocumentLoadGroup();
   if (loadGroup) {
     return GetOriginAttributes(loadGroup);
   }
 
-  mozilla::PrincipalOriginAttributes attrs;
-  mozilla::NeckoOriginAttributes nattrs;
+  mozilla::OriginAttributes attrs;
   nsCOMPtr<nsIChannel> channel = aDocument->GetChannel();
-  if (channel && NS_GetOriginAttributes(channel, nattrs)) {
-    attrs.InheritFromNecko(nattrs);
+  if (channel && NS_GetOriginAttributes(channel, attrs)) {
+    attrs.StripAttributes(OriginAttributes::STRIP_ADDON_ID);
   }
   return attrs;
 }
 
 // static
-mozilla::PrincipalOriginAttributes
+mozilla::OriginAttributes
 nsContentUtils::GetOriginAttributes(nsILoadGroup* aLoadGroup)
 {
   if (!aLoadGroup) {
-    return mozilla::PrincipalOriginAttributes();
-  }
-  mozilla::PrincipalOriginAttributes attrs;
-  mozilla::DocShellOriginAttributes dsattrs;
+    return mozilla::OriginAttributes();
+  }
+  mozilla::OriginAttributes attrs;
   nsCOMPtr<nsIInterfaceRequestor> callbacks;
   aLoadGroup->GetNotificationCallbacks(getter_AddRefs(callbacks));
   if (callbacks) {
     nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(callbacks);
-    if (loadContext && loadContext->GetOriginAttributes(dsattrs)) {
-      attrs.InheritFromDocShellToDoc(dsattrs, nullptr);
+    if (loadContext && loadContext->GetOriginAttributes(attrs)) {
+      attrs.StripAttributes(OriginAttributes::STRIP_ADDON_ID);
     }
   }
   return attrs;
 }
 
 // static
 bool
 nsContentUtils::IsInPrivateBrowsing(nsIDocument* aDoc)
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -800,23 +800,23 @@ public:
    */
   static void GetEventArgNames(int32_t aNameSpaceID, nsIAtom *aEventName,
                                bool aIsForWindow,
                                uint32_t *aArgCount, const char*** aArgNames);
 
   /**
    * Returns origin attributes of the document.
    **/
-  static mozilla::PrincipalOriginAttributes
+  static mozilla::OriginAttributes
   GetOriginAttributes(nsIDocument* aDoc);
 
   /**
    * Returns origin attributes of the load group.
    **/
-  static mozilla::PrincipalOriginAttributes
+  static mozilla::OriginAttributes
   GetOriginAttributes(nsILoadGroup* aLoadGroup);
 
   /**
    * Returns true if this document is in a Private Browsing window.
    */
   static bool IsInPrivateBrowsing(nsIDocument* aDoc);
 
   /**
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -1425,16 +1425,17 @@ nsDocument::~nsDocument()
       } else {
         /* no mixed object subrequests loaded on page*/
         Accumulate(Telemetry::MIXED_CONTENT_OBJECT_SUBREQUEST, 0);
       }
 
       // record CSP telemetry on this document
       if (mHasCSP) {
         Accumulate(Telemetry::CSP_DOCUMENTS_COUNT, 1);
+        Accumulate(Telemetry::CSP_REFERRER_DIRECTIVE, mHasReferrerPolicyCSP);
       }
       if (mHasUnsafeInlineCSP) {
         Accumulate(Telemetry::CSP_UNSAFE_INLINE_DOCUMENTS_COUNT, 1);
       }
       if (mHasUnsafeEvalCSP) {
         Accumulate(Telemetry::CSP_UNSAFE_EVAL_DOCUMENTS_COUNT, 1);
       }
     }
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -1356,22 +1356,22 @@ nsFrameLoader::SwapWithOtherRemoteLoader
   // When we swap docShells, maybe we have to deal with a new page created just
   // for this operation. In this case, the browser code should already have set
   // the correct userContextId attribute value in the owning XULElement, but our
   // docShell, that has been created way before) doesn't know that that
   // happened.
   // This is the reason why now we must retrieve the correct value from the
   // usercontextid attribute before comparing our originAttributes with the
   // other one.
-  DocShellOriginAttributes ourOriginAttributes =
+  OriginAttributes ourOriginAttributes =
     mRemoteBrowser->OriginAttributesRef();
   rv = PopulateUserContextIdFromAttribute(ourOriginAttributes);
   NS_ENSURE_SUCCESS(rv,rv);
 
-  DocShellOriginAttributes otherOriginAttributes =
+  OriginAttributes otherOriginAttributes =
     aOther->mRemoteBrowser->OriginAttributesRef();
   rv = aOther->PopulateUserContextIdFromAttribute(otherOriginAttributes);
   NS_ENSURE_SUCCESS(rv,rv);
 
   if (ourOriginAttributes != otherOriginAttributes) {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
@@ -1754,22 +1754,22 @@ nsFrameLoader::SwapWithOtherLoader(nsFra
   // When we swap docShells, maybe we have to deal with a new page created just
   // for this operation. In this case, the browser code should already have set
   // the correct userContextId attribute value in the owning XULElement, but our
   // docShell, that has been created way before) doesn't know that that
   // happened.
   // This is the reason why now we must retrieve the correct value from the
   // usercontextid attribute before comparing our originAttributes with the
   // other one.
-  DocShellOriginAttributes ourOriginAttributes =
+  OriginAttributes ourOriginAttributes =
     ourDocshell->GetOriginAttributes();
   rv = PopulateUserContextIdFromAttribute(ourOriginAttributes);
   NS_ENSURE_SUCCESS(rv,rv);
 
-  DocShellOriginAttributes otherOriginAttributes =
+  OriginAttributes otherOriginAttributes =
     otherDocshell->GetOriginAttributes();
   rv = aOther->PopulateUserContextIdFromAttribute(otherOriginAttributes);
   NS_ENSURE_SUCCESS(rv,rv);
 
   if (ourOriginAttributes != otherOriginAttributes) {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
@@ -2401,51 +2401,51 @@ nsFrameLoader::MaybeCreateDocShell()
       mPartialSHistory = new PartialSHistory(this);
       nsCOMPtr<nsISHistoryListener> listener(do_QueryInterface(mPartialSHistory));
       nsCOMPtr<nsIPartialSHistoryListener> partialListener(do_QueryInterface(mPartialSHistory));
       sessionHistory->AddSHistoryListener(listener);
       sessionHistory->SetPartialSHistoryListener(partialListener);
     }
   }
 
-  DocShellOriginAttributes attrs;
+  OriginAttributes attrs;
   if (docShell->ItemType() == mDocShell->ItemType()) {
     attrs = nsDocShell::Cast(docShell)->GetOriginAttributes();
   }
 
   // Inherit origin attributes from parent document if
   // 1. It's in a content docshell.
   // 2. its nodePrincipal is not a SystemPrincipal.
   // 3. It's not a mozbrowser frame.
   //
   // For example, firstPartyDomain is computed from top-level document, it
   // doesn't exist in the top-level docshell.
   if (parentType == nsIDocShellTreeItem::typeContent &&
       !nsContentUtils::IsSystemPrincipal(doc->NodePrincipal()) &&
       !OwnerIsMozBrowserFrame()) {
-    PrincipalOriginAttributes poa = doc->NodePrincipal()->OriginAttributesRef();
+    OriginAttributes oa = doc->NodePrincipal()->OriginAttributesRef();
 
     // Assert on the firstPartyDomain from top-level docshell should be empty
     if (mIsTopLevelContent) {
       MOZ_ASSERT(attrs.mFirstPartyDomain.IsEmpty(),
                  "top-level docshell shouldn't have firstPartyDomain attribute.");
     }
 
-    // So far we want to make sure InheritFromDocToChildDocShell doesn't override
-    // any other origin attribute than firstPartyDomain.
-    MOZ_ASSERT(attrs.mAppId == poa.mAppId,
+    // So far we want to make sure Inherit doesn't override any other origin
+    // attribute than firstPartyDomain.
+    MOZ_ASSERT(attrs.mAppId == oa.mAppId,
               "docshell and document should have the same appId attribute.");
-    MOZ_ASSERT(attrs.mUserContextId == poa.mUserContextId,
+    MOZ_ASSERT(attrs.mUserContextId == oa.mUserContextId,
               "docshell and document should have the same userContextId attribute.");
-    MOZ_ASSERT(attrs.mInIsolatedMozBrowser == poa.mInIsolatedMozBrowser,
+    MOZ_ASSERT(attrs.mInIsolatedMozBrowser == oa.mInIsolatedMozBrowser,
               "docshell and document should have the same inIsolatedMozBrowser attribute.");
-    MOZ_ASSERT(attrs.mPrivateBrowsingId == poa.mPrivateBrowsingId,
+    MOZ_ASSERT(attrs.mPrivateBrowsingId == oa.mPrivateBrowsingId,
               "docshell and document should have the same privateBrowsingId attribute.");
 
-    attrs.InheritFromDocToChildDocShell(poa);
+    attrs.Inherit(oa);
   }
 
   if (OwnerIsMozBrowserFrame()) {
     attrs.mAppId = nsIScriptSecurityManager::NO_APP_ID;
     attrs.mInIsolatedMozBrowser = OwnerIsIsolatedMozBrowserFrame();
     mDocShell->SetFrameType(nsIDocShell::FRAME_TYPE_BROWSER);
   }
 
@@ -3587,17 +3587,17 @@ nsFrameLoader::MaybeUpdatePrimaryTabPare
     }
   }
 }
 
 nsresult
 nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
                                 nsIURI* aURI)
 {
-  DocShellOriginAttributes attrs;
+  OriginAttributes attrs;
   attrs.mInIsolatedMozBrowser = OwnerIsIsolatedMozBrowserFrame();
   nsresult rv;
 
   attrs.mAppId = nsIScriptSecurityManager::NO_APP_ID;
 
   // set the userContextId on the attrs before we pass them into
   // the tab context
   rv = PopulateUserContextIdFromAttribute(attrs);
@@ -3636,17 +3636,17 @@ nsFrameLoader::GetNewTabContext(MutableT
                                attrs,
                                presentationURLStr);
   NS_ENSURE_STATE(tabContextUpdated);
 
   return NS_OK;
 }
 
 nsresult
-nsFrameLoader::PopulateUserContextIdFromAttribute(DocShellOriginAttributes& aAttr)
+nsFrameLoader::PopulateUserContextIdFromAttribute(OriginAttributes& aAttr)
 {
   if (aAttr.mUserContextId ==
         nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID)  {
     // Grab the userContextId from owner if XUL
     nsAutoString userContextIdStr;
     int32_t namespaceID = mOwnerContent->GetNameSpaceID();
     if ((namespaceID == kNameSpaceID_XUL) &&
         mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::usercontextid,
--- a/dom/base/nsFrameLoader.h
+++ b/dom/base/nsFrameLoader.h
@@ -34,17 +34,17 @@ class nsIInProcessContentFrameMessageMan
 class AutoResetInShow;
 class AutoResetInFrameSwap;
 class nsITabParent;
 class nsIDocShellTreeItem;
 class nsIDocShellTreeOwner;
 
 namespace mozilla {
 
-class DocShellOriginAttributes;
+class OriginAttributes;
 
 namespace dom {
 class ContentParent;
 class PBrowserParent;
 class Promise;
 class TabParent;
 class MutableTabContext;
 
@@ -303,17 +303,17 @@ private:
 
   enum TabParentChange {
     eTabParentRemoved,
     eTabParentChanged
   };
   void MaybeUpdatePrimaryTabParent(TabParentChange aChange);
 
   nsresult
-  PopulateUserContextIdFromAttribute(mozilla::DocShellOriginAttributes& aAttr);
+  PopulateUserContextIdFromAttribute(mozilla::OriginAttributes& aAttr);
 
   // Swap ourselves with the frameloader aOther, and notify chrome code with
   // a BrowserChangedProcess event.
   bool SwapBrowsersAndNotify(nsFrameLoader* aOther);
 
   // Returns a promise which will be resolved once all of the blockers have
   // resolved which were added during the BrowserWillChangeProcess event.
   already_AddRefed<mozilla::dom::Promise> FireWillChangeProcessEvent();
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -270,17 +270,17 @@ class nsIScriptTimeoutHandler;
 #endif
 
 static const char kStorageEnabled[] = "dom.storage.enabled";
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::dom::ipc;
 using mozilla::BasePrincipal;
-using mozilla::PrincipalOriginAttributes;
+using mozilla::OriginAttributes;
 using mozilla::TimeStamp;
 using mozilla::TimeDuration;
 using mozilla::dom::cache::CacheStorage;
 
 static LazyLogModule gDOMLeakPRLog("DOMLeak");
 
 nsGlobalWindow::WindowByIdTable *nsGlobalWindow::sWindowsById = nullptr;
 bool nsGlobalWindow::sWarnedAboutWindowInternal = false;
@@ -2431,17 +2431,17 @@ nsGlobalWindow::ComputeIsSecureContext(n
     return true;
   }
 
   if (principal->GetIsNullPrincipal()) {
     nsCOMPtr<nsIURI> uri = aDocument->GetOriginalURI();
     // IsOriginPotentiallyTrustworthy doesn't care about origin attributes so
     // it doesn't actually matter what we use here, but reusing the document
     // principal's attributes is convenient.
-    const PrincipalOriginAttributes& attrs = principal->OriginAttributesRef();
+    const OriginAttributes& attrs = principal->OriginAttributesRef();
     // CreateCodebasePrincipal correctly gets a useful principal for blob: and
     // other URI_INHERITS_SECURITY_CONTEXT URIs.
     principal = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
     if (NS_WARN_IF(!principal)) {
       return false;
     }
   }
 
@@ -8481,17 +8481,17 @@ nsGlobalWindow::PostMessageMozOuter(JSCo
       return;
     }
 
     if (NS_FAILED(originURI->SetUserPass(EmptyCString())) ||
         NS_FAILED(originURI->SetPath(EmptyCString()))) {
       return;
     }
 
-    PrincipalOriginAttributes attrs = aSubjectPrincipal.OriginAttributesRef();
+    OriginAttributes attrs = aSubjectPrincipal.OriginAttributesRef();
     if (aSubjectPrincipal.GetIsSystemPrincipal()) {
       auto principal = BasePrincipal::Cast(GetPrincipal());
 
       if (attrs != principal->OriginAttributesRef()) {
         nsCOMPtr<nsIURI> targetURI;
         nsAutoCString targetURL;
         nsAutoCString sourceOrigin;
         nsAutoCString targetOrigin;
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -703,16 +703,24 @@ public:
    * Get mixed display content blocked flag for this document.
    */
   bool GetHasMixedDisplayContentBlocked()
   {
     return mHasMixedDisplayContentBlocked;
   }
 
   /**
+  * Set referrer policy CSP flag for this document.
+  */
+  void SetHasReferrerPolicyCSP(bool aHasReferrerPolicyCSP)
+  {
+    mHasReferrerPolicyCSP = aHasReferrerPolicyCSP;
+  }
+
+  /**
    * Set the mixed display content blocked flag for this document.
    */
   void SetHasMixedDisplayContentBlocked(bool aHasMixedDisplayContentBlocked)
   {
     mHasMixedDisplayContentBlocked = aHasMixedDisplayContentBlocked;
   }
 
   /**
@@ -3075,16 +3083,19 @@ protected:
   // true otherwise.
   bool mIsShowing : 1;
 
   // State for IsVisible(). mVisible starts off true. It becomes false when
   // OnPageHide happens, and becomes true again when OnPageShow happens.  So
   // it's false only when we're in bfcache or unloaded.
   bool mVisible : 1;
 
+  // True if a document load has a CSP with referrer attached.
+  bool mHasReferrerPolicyCSP : 1;
+
   // True if our content viewer has been removed from the docshell
   // (it may still be displayed, but in zombie state). Form control data
   // has been saved.
   bool mRemovedFromDocShell : 1;
 
   // True iff DNS prefetch is allowed for this document.  Note that if the
   // document has no window, DNS prefetch won't be performed no matter what.
   bool mAllowDNSPrefetch : 1;
--- a/dom/base/nsOpenURIInFrameParams.cpp
+++ b/dom/base/nsOpenURIInFrameParams.cpp
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsOpenURIInFrameParams.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/dom/ToJSValue.h"
 
 NS_IMPL_ISUPPORTS(nsOpenURIInFrameParams, nsIOpenURIInFrameParams)
 
-nsOpenURIInFrameParams::nsOpenURIInFrameParams(const mozilla::DocShellOriginAttributes& aOriginAttributes)
+nsOpenURIInFrameParams::nsOpenURIInFrameParams(const mozilla::OriginAttributes& aOriginAttributes)
   : mOpenerOriginAttributes(aOriginAttributes)
   , mIsPrivate(false)
 {
 }
 
 nsOpenURIInFrameParams::~nsOpenURIInFrameParams() {
 }
 
--- a/dom/base/nsOpenURIInFrameParams.h
+++ b/dom/base/nsOpenURIInFrameParams.h
@@ -4,26 +4,26 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/BasePrincipal.h"
 #include "nsIBrowserDOMWindow.h"
 #include "nsString.h"
 
 namespace mozilla {
-class DocShellOriginAttributes;
+class OriginAttributes;
 }
 
 class nsOpenURIInFrameParams final : public nsIOpenURIInFrameParams
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOPENURIINFRAMEPARAMS
 
-  explicit nsOpenURIInFrameParams(const mozilla::DocShellOriginAttributes& aOriginAttributes);
+  explicit nsOpenURIInFrameParams(const mozilla::OriginAttributes& aOriginAttributes);
 
 private:
   ~nsOpenURIInFrameParams();
 
-  mozilla::DocShellOriginAttributes mOpenerOriginAttributes;
+  mozilla::OriginAttributes mOpenerOriginAttributes;
   nsString mReferrer;
   bool mIsPrivate;
 };
--- a/dom/cache/DBSchema.cpp
+++ b/dom/cache/DBSchema.cpp
@@ -1970,17 +1970,17 @@ ReadResponse(mozIStorageConnection* aCon
 
   nsAutoCString serializedInfo;
   rv = state->GetUTF8String(5, serializedInfo);
   if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
 
   aSavedResponseOut->mValue.principalInfo() = void_t();
   if (!serializedInfo.IsEmpty()) {
     nsAutoCString originNoSuffix;
-    PrincipalOriginAttributes attrs;
+    OriginAttributes attrs;
     if (!attrs.PopulateFromOrigin(serializedInfo, originNoSuffix)) {
       NS_WARNING("Something went wrong parsing a serialized principal!");
       return NS_ERROR_FAILURE;
     }
 
     aSavedResponseOut->mValue.principalInfo() =
       mozilla::ipc::ContentPrincipalInfo(attrs, originNoSuffix);
   }
--- a/dom/console/Console.cpp
+++ b/dom/console/Console.cpp
@@ -147,17 +147,17 @@ public:
     MOZ_ASSERT(mIDType == eUnknown);
 
     mOuterIDString = aOuterID;
     mInnerIDString = aInnerID;
     mIDType = eString;
   }
 
   void
-  SetOriginAttributes(const PrincipalOriginAttributes& aOriginAttributes)
+  SetOriginAttributes(const OriginAttributes& aOriginAttributes)
   {
     mOriginAttributes = aOriginAttributes;
   }
 
   bool
   PopulateArgumentsSequence(Sequence<JS::Value>& aSequence) const
   {
     AssertIsOnOwningThread();
@@ -243,17 +243,17 @@ public:
   } mIDType;
 
   uint64_t mOuterIDNumber;
   nsString mOuterIDString;
 
   uint64_t mInnerIDNumber;
   nsString mInnerIDString;
 
-  PrincipalOriginAttributes mOriginAttributes;
+  OriginAttributes mOriginAttributes;
 
   nsString mMethodString;
 
   // Stack management is complicated, because we want to do it as
   // lazily as possible.  Therefore, we have the following behavior:
   // 1)  mTopStackFrame is initialized whenever we have any JS on the stack
   // 2)  mReifiedStack is initialized if we're created in a worker.
   // 3)  mStack is set (possibly to null if there is no JS on the stack) if
@@ -1196,17 +1196,17 @@ Console::MethodInternal(JSContext* aCx, 
 
   ClearException ce(aCx);
 
   if (NS_WARN_IF(!callData->Initialize(aCx, aMethodName, aMethodString,
                                        aData, this))) {
     return;
   }
 
-  PrincipalOriginAttributes oa;
+  OriginAttributes oa;
 
   if (mWindow) {
     // Save the principal's OriginAttributes in the console event data
     // so that we will be able to filter messages by origin attributes.
     nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(mWindow);
     if (NS_WARN_IF(!sop)) {
       return;
     }
--- a/dom/file/FileReader.cpp
+++ b/dom/file/FileReader.cpp
@@ -328,16 +328,17 @@ FileReader::DoReadData(uint64_t aCount)
     }
 
     if (mDataFormat != FILE_AS_ARRAYBUFFER) {
       mFileData = (char *) realloc(mFileData, mDataLen + aCount);
       NS_ENSURE_TRUE(mFileData, NS_ERROR_OUT_OF_MEMORY);
     }
 
     uint32_t bytesRead = 0;
+    MOZ_DIAGNOSTIC_ASSERT(mFileData);
     mAsyncStream->Read(mFileData + mDataLen, aCount, &bytesRead);
     MOZ_ASSERT(bytesRead == aCount, "failed to read data");
   }
 
   mDataLen += aCount;
   return NS_OK;
 }
 
@@ -726,24 +727,26 @@ FileReader::Notify(Status aStatus)
   }
 
   return true;
 }
 
 void
 FileReader::Shutdown()
 {
-  FreeFileData();
-  mResultArrayBuffer = nullptr;
+  mReadyState = DONE;
 
   if (mAsyncStream) {
     mAsyncStream->Close();
     mAsyncStream = nullptr;
   }
 
+  FreeFileData();
+  mResultArrayBuffer = nullptr;
+
   if (mWorkerPrivate && mBusyCount != 0) {
     ReleaseWorker();
     mWorkerPrivate = nullptr;
     mBusyCount = 0;
   }
 }
 
 } // dom namespace
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -662,17 +662,17 @@ ContentChild::ProvideWindow(mozIDOMWindo
                              aCalledFromJS, aPositionSpecified,
                              aSizeSpecified, aURI, aName, aFeatures,
                              aForceNoOpener, aWindowIsNew, aReturn);
 }
 
 static nsresult
 GetWindowParamsFromParent(mozIDOMWindowProxy* aParent,
                           nsACString& aBaseURIString, float* aFullZoom,
-                          DocShellOriginAttributes& aOriginAttributes)
+                          OriginAttributes& aOriginAttributes)
 {
   *aFullZoom = 1.0f;
   auto* opener = nsPIDOMWindowOuter::From(aParent);
   if (!opener) {
     return NS_OK;
   }
 
   nsCOMPtr<nsIDocument> doc = opener->GetDoc();
@@ -729,17 +729,17 @@ ContentChild::ProvideWindowCommon(TabChi
     nsCOMPtr<nsIWebBrowserChrome3> browserChrome3;
     rv = aTabOpener->GetWebBrowserChrome(getter_AddRefs(browserChrome3));
     if (NS_SUCCEEDED(rv) && browserChrome3) {
       bool shouldLoad;
       rv = browserChrome3->ShouldLoadURIInThisProcess(aURI, &shouldLoad);
       if (NS_SUCCEEDED(rv) && !shouldLoad) {
         nsAutoCString baseURIString;
         float fullZoom;
-        DocShellOriginAttributes originAttributes;
+        OriginAttributes originAttributes;
         rv = GetWindowParamsFromParent(aParent, baseURIString, &fullZoom,
                                        originAttributes);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
 
         URIParams uriToLoad;
         SerializeURI(aURI, uriToLoad);
@@ -829,17 +829,17 @@ ContentChild::ProvideWindowCommon(TabChi
 
     newChild->SendBrowserFrameOpenWindow(aTabOpener, renderFrame, NS_ConvertUTF8toUTF16(url),
                                          name, NS_ConvertUTF8toUTF16(features),
                                          aWindowIsNew, &textureFactoryIdentifier,
                                          &layersId);
   } else {
     nsAutoCString baseURIString;
     float fullZoom;
-    DocShellOriginAttributes originAttributes;
+    OriginAttributes originAttributes;
     rv = GetWindowParamsFromParent(aParent, baseURIString, &fullZoom,
                                    originAttributes);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     if (!SendCreateWindow(aTabOpener, newChild, renderFrame,
                           aChromeFlags, aCalledFromJS, aPositionSpecified,
@@ -2319,17 +2319,17 @@ ContentChild::RecvAddPermission(const IP
   nsPermissionManager* permissionManager =
     static_cast<nsPermissionManager*>(permissionManagerIface.get());
   MOZ_ASSERT(permissionManager,
          "We have no permissionManager in the Content process !");
 
   // note we do not need to force mUserContextId to the default here because
   // the permission manager does that internally.
   nsAutoCString originNoSuffix;
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   bool success = attrs.PopulateFromOrigin(permission.origin, originNoSuffix);
   NS_ENSURE_TRUE(success, IPC_FAIL_NO_REASON(this));
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = NS_NewURI(getter_AddRefs(uri), originNoSuffix);
   NS_ENSURE_SUCCESS(rv, IPC_OK());
 
   nsCOMPtr<nsIPrincipal> principal = mozilla::BasePrincipal::CreateCodebasePrincipal(uri, attrs);
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -4172,17 +4172,17 @@ ContentParent::CommonCreateWindow(PBrows
                                   bool aSetOpener,
                                   const uint32_t& aChromeFlags,
                                   const bool& aCalledFromJS,
                                   const bool& aPositionSpecified,
                                   const bool& aSizeSpecified,
                                   nsIURI* aURIToLoad,
                                   const nsCString& aFeatures,
                                   const nsCString& aBaseURI,
-                                  const DocShellOriginAttributes& aOpenerOriginAttributes,
+                                  const OriginAttributes& aOpenerOriginAttributes,
                                   const float& aFullZoom,
                                   nsresult& aResult,
                                   nsCOMPtr<nsITabParent>& aNewTabParent,
                                   bool* aWindowIsNew)
 
 {
   // The content process should never be in charge of computing whether or
   // not a window should be private or remote - the parent will do that.
@@ -4296,17 +4296,17 @@ ContentParent::RecvCreateWindow(PBrowser
                                 PBrowserParent* aNewTab,
                                 PRenderFrameParent* aRenderFrame,
                                 const uint32_t& aChromeFlags,
                                 const bool& aCalledFromJS,
                                 const bool& aPositionSpecified,
                                 const bool& aSizeSpecified,
                                 const nsCString& aFeatures,
                                 const nsCString& aBaseURI,
-                                const DocShellOriginAttributes& aOpenerOriginAttributes,
+                                const OriginAttributes& aOpenerOriginAttributes,
                                 const float& aFullZoom,
                                 nsresult* aResult,
                                 bool* aWindowIsNew,
                                 InfallibleTArray<FrameScriptInfo>* aFrameScripts,
                                 nsCString* aURLToLoad,
                                 TextureFactoryIdentifier* aTextureFactoryIdentifier,
                                 uint64_t* aLayersId)
 {
@@ -4363,17 +4363,17 @@ ContentParent::RecvCreateWindowInDiffere
   PBrowserParent* aThisTab,
   const uint32_t& aChromeFlags,
   const bool& aCalledFromJS,
   const bool& aPositionSpecified,
   const bool& aSizeSpecified,
   const URIParams& aURIToLoad,
   const nsCString& aFeatures,
   const nsCString& aBaseURI,
-  const DocShellOriginAttributes& aOpenerOriginAttributes,
+  const OriginAttributes& aOpenerOriginAttributes,
   const float& aFullZoom)
 {
   nsCOMPtr<nsITabParent> newRemoteTab;
   bool windowIsNew;
   nsCOMPtr<nsIURI> uriToLoad = DeserializeURI(aURIToLoad);
   nsresult rv;
   mozilla::ipc::IPCResult ipcResult =
     CommonCreateWindow(aThisTab, /* aSetOpener = */ false, aChromeFlags,
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -495,17 +495,17 @@ public:
                    PBrowserParent* aNewTab,
                    layout::PRenderFrameParent* aRenderFrame,
                    const uint32_t& aChromeFlags,
                    const bool& aCalledFromJS,
                    const bool& aPositionSpecified,
                    const bool& aSizeSpecified,
                    const nsCString& aFeatures,
                    const nsCString& aBaseURI,
-                   const DocShellOriginAttributes& aOpenerOriginAttributes,
+                   const OriginAttributes& aOpenerOriginAttributes,
                    const float& aFullZoom,
                    nsresult* aResult,
                    bool* aWindowIsNew,
                    InfallibleTArray<FrameScriptInfo>* aFrameScripts,
                    nsCString* aURLToLoad,
                    layers::TextureFactoryIdentifier* aTextureFactoryIdentifier,
                    uint64_t* aLayersId) override;
 
@@ -513,17 +513,17 @@ public:
     PBrowserParent* aThisTab,
     const uint32_t& aChromeFlags,
     const bool& aCalledFromJS,
     const bool& aPositionSpecified,
     const bool& aSizeSpecified,
     const URIParams& aURIToLoad,
     const nsCString& aFeatures,
     const nsCString& aBaseURI,
-    const DocShellOriginAttributes& aOpenerOriginAttributes,
+    const OriginAttributes& aOpenerOriginAttributes,
     const float& aFullZoom) override;
 
   static bool AllocateLayerTreeId(TabParent* aTabParent, uint64_t* aId);
 
   static void
   BroadcastBlobURLRegistration(const nsACString& aURI,
                                BlobImpl* aBlobImpl,
                                nsIPrincipal* aPrincipal,
@@ -608,17 +608,17 @@ private:
                      bool aSetOpener,
                      const uint32_t& aChromeFlags,
                      const bool& aCalledFromJS,
                      const bool& aPositionSpecified,
                      const bool& aSizeSpecified,
                      nsIURI* aURIToLoad,
                      const nsCString& aFeatures,
                      const nsCString& aBaseURI,
-                     const DocShellOriginAttributes& aOpenerOriginAttributes,
+                     const OriginAttributes& aOpenerOriginAttributes,
                      const float& aFullZoom,
                      nsresult& aResult,
                      nsCOMPtr<nsITabParent>& aNewTabParent,
                      bool* aWindowIsNew);
 
   FORWARD_SHMEM_ALLOCATOR_TO(PContentParent)
 
   ContentParent(ContentParent* aOpener,
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -85,17 +85,17 @@ using mozilla::hal::ProcessPriority from
 using mozilla::gfx::IntSize from "mozilla/gfx/2D.h";
 using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
 using mozilla::dom::ContentParentId from "mozilla/dom/ipc/IdType.h";
 using mozilla::LayoutDeviceIntPoint from "Units.h";
 using struct LookAndFeelInt from "mozilla/widget/WidgetMessageUtils.h";
 using class mozilla::dom::MessagePort from "mozilla/dom/MessagePort.h";
 using class mozilla::dom::ipc::StructuredCloneData from "mozilla/dom/ipc/StructuredCloneData.h";
 using mozilla::DataStorageType from "ipc/DataStorageIPCUtils.h";
-using mozilla::DocShellOriginAttributes from "mozilla/ipc/BackgroundUtils.h";
+using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
 using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h";
 using struct mozilla::dom::FlyWebPublishOptions from "mozilla/dom/FlyWebPublishOptionsIPCSerializer.h";
 using mozilla::Telemetry::Accumulation from "mozilla/TelemetryComms.h";
 using mozilla::Telemetry::KeyedAccumulation from "mozilla/TelemetryComms.h";
 
 union ChromeRegistryItem
 {
     ChromePackage;
@@ -1061,17 +1061,17 @@ parent:
                       PBrowser aNewTab,
                       PRenderFrame aRenderFrame,
                       uint32_t aChromeFlags,
                       bool aCalledFromJS,
                       bool aPositionSpecified,
                       bool aSizeSpecified,
                       nsCString aFeatures,
                       nsCString aBaseURI,
-                      DocShellOriginAttributes aOpenerOriginAttributes,
+                      OriginAttributes aOpenerOriginAttributes,
                       float aFullZoom)
       returns (nsresult rv,
                bool windowOpened,
                FrameScriptInfo[] frameScripts,
                nsCString urlToLoad,
                TextureFactoryIdentifier textureFactoryIdentifier,
                uint64_t layersId);
 
@@ -1079,17 +1079,17 @@ parent:
       PBrowser aThisTab,
       uint32_t aChromeFlags,
       bool aCalledFromJS,
       bool aPositionSpecified,
       bool aSizeSpecified,
       URIParams aURIToLoad,
       nsCString aFeatures,
       nsCString aBaseURI,
-      DocShellOriginAttributes aOpenerOriginAttributes,
+      OriginAttributes aOpenerOriginAttributes,
       float aFullZoom);
 
     sync GetDeviceStorageLocation(nsString type)
         returns (nsString path);
 
     sync GetDeviceStorageLocations()
 	returns (DeviceStorageLocationInfo info);
 
--- a/dom/ipc/PTabContext.ipdlh
+++ b/dom/ipc/PTabContext.ipdlh
@@ -3,17 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 include protocol PBrowser;
 include PBrowserOrId;
 
 using UIStateChangeType from "nsPIDOMWindow.h";
-using mozilla::DocShellOriginAttributes from "mozilla/ipc/BackgroundUtils.h";
+using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
 
 namespace mozilla {
 namespace dom {
 
 // An IPCTabContext which corresponds to a PBrowser opened by a child when it
 // receives window.open().
 //
 // If isMozBrowserElement is false, this PopupIPCTabContext is either a
@@ -32,17 +32,17 @@ struct PopupIPCTabContext
   PBrowserOrId opener;
   bool isMozBrowserElement;
 };
 
 // An IPCTabContext which corresponds to an app, browser, or normal frame.
 struct FrameIPCTabContext
 {
   // The originAttributes dictionary.
-  DocShellOriginAttributes originAttributes;
+  OriginAttributes originAttributes;
 
   // Whether this is a mozbrowser frame.  <iframe mozbrowser mozapp> and
   // <xul:browser> are not considered to be mozbrowser frames.
   bool isMozBrowserElement;
 
   // Whether this TabContext should work in prerender mode.
   bool isPrerendered;
 
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1195,17 +1195,17 @@ TabChild::ApplyShowInfo(const ShowInfo& 
       if (!context->UsePrivateBrowsing()) {
         if (docShell->GetHasLoadedNonBlankURI()) {
           nsContentUtils::ReportToConsoleNonLocalized(
             NS_LITERAL_STRING("We should not switch to Private Browsing after loading a document."),
             nsIScriptError::warningFlag,
             NS_LITERAL_CSTRING("mozprivatebrowsing"),
             nullptr);
         } else {
-          DocShellOriginAttributes attrs(nsDocShell::Cast(docShell)->GetOriginAttributes());
+          OriginAttributes attrs(nsDocShell::Cast(docShell)->GetOriginAttributes());
           attrs.SyncAttributesWithPrivateBrowsing(true);
           nsDocShell::Cast(docShell)->SetOriginAttributes(attrs);
         }
       }
     }
   }
   mDPI = aInfo.dpi();
   mRounding = aInfo.widgetRounding();
--- a/dom/ipc/TabContext.cpp
+++ b/dom/ipc/TabContext.cpp
@@ -75,17 +75,17 @@ TabContext::UpdateTabContextAfterSwap(co
   if (aContext.mOriginAttributes != mOriginAttributes) {
     return false;
   }
 
   mIsMozBrowserElement = aContext.mIsMozBrowserElement;
   return true;
 }
 
-const DocShellOriginAttributes&
+const OriginAttributes&
 TabContext::OriginAttributesRef() const
 {
   return mOriginAttributes;
 }
 
 const nsAString&
 TabContext::PresentationURL() const
 {
@@ -104,17 +104,17 @@ TabContext::ShowFocusRings() const
   return mShowFocusRings;
 }
 
 bool
 TabContext::SetTabContext(bool aIsMozBrowserElement,
                           bool aIsPrerendered,
                           UIStateChangeType aShowAccelerators,
                           UIStateChangeType aShowFocusRings,
-                          const DocShellOriginAttributes& aOriginAttributes,
+                          const OriginAttributes& aOriginAttributes,
                           const nsAString& aPresentationURL)
 {
   NS_ENSURE_FALSE(mInitialized, false);
 
   // Veryify that app id matches mAppId passed in originAttributes
   MOZ_RELEASE_ASSERT(aOriginAttributes.mAppId == NO_APP_ID);
 
   mInitialized = true;
@@ -138,17 +138,17 @@ TabContext::AsIPCTabContext() const
                                           mShowFocusRings));
 }
 
 MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
   : mInvalidReason(nullptr)
 {
   bool isMozBrowserElement = false;
   bool isPrerendered = false;
-  DocShellOriginAttributes originAttributes;
+  OriginAttributes originAttributes;
   nsAutoString presentationURL;
   UIStateChangeType showAccelerators = UIStateChangeType_NoChange;
   UIStateChangeType showFocusRings = UIStateChangeType_NoChange;
 
   switch(aParams.type()) {
     case IPCTabContext::TPopupIPCTabContext: {
       const PopupIPCTabContext &ipcContext = aParams.get_PopupIPCTabContext();
 
--- a/dom/ipc/TabContext.h
+++ b/dom/ipc/TabContext.h
@@ -59,21 +59,21 @@ public:
   /**
    * Does this TabContext correspond to a mozbrowser?  This is equivalent to
    * IsMozBrowserElement().  Returns false for <xul:browser>, which isn't a
    * mozbrowser.
    */
   bool IsMozBrowser() const;
 
   /**
-   * OriginAttributesRef() returns the DocShellOriginAttributes of this frame to
+   * OriginAttributesRef() returns the OriginAttributes of this frame to
    * the caller. This is used to store any attribute associated with the frame's
    * docshell.
    */
-  const DocShellOriginAttributes& OriginAttributesRef() const;
+  const OriginAttributes& OriginAttributesRef() const;
 
   /**
    * Returns the presentation URL associated with the tab if this tab is
    * created for presented content
    */
   const nsAString& PresentationURL() const;
 
   UIStateChangeType ShowAccelerators() const;
@@ -100,17 +100,17 @@ protected:
    * Set the tab context's origin attributes to a private browsing value.
    */
   void SetPrivateBrowsingAttributes(bool aIsPrivateBrowsing);
 
   bool SetTabContext(bool aIsMozBrowserElement,
                      bool aIsPrerendered,
                      UIStateChangeType aShowAccelerators,
                      UIStateChangeType aShowFocusRings,
-                     const DocShellOriginAttributes& aOriginAttributes,
+                     const OriginAttributes& aOriginAttributes,
                      const nsAString& aPresentationURL);
 
   /**
    * Modify this TabContext to match the given TabContext.  This is a special
    * case triggered by nsFrameLoader::SwapWithOtherRemoteLoader which may have
    * caused the owner content to change.
    *
    * This special case only allows the field `mIsMozBrowserElement` to be
@@ -134,19 +134,19 @@ private:
    * Whether this TabContext corresponds to a mozbrowser.
    *
    * <iframe mozbrowser> and <xul:browser> are not considered to be
    * mozbrowser elements.
    */
   bool mIsMozBrowserElement;
 
   /**
-   * DocShellOriginAttributes of the top level tab docShell
+   * OriginAttributes of the top level tab docShell
    */
-  DocShellOriginAttributes mOriginAttributes;
+  OriginAttributes mOriginAttributes;
 
   /**
    * The requested presentation URL.
    */
   nsString mPresentationURL;
 
   /**
    * Keyboard indicator state (focus rings, accelerators).
@@ -168,17 +168,17 @@ public:
     return TabContext::SetTabContext(aContext);
   }
 
   bool
   SetTabContext(bool aIsMozBrowserElement,
                 bool aIsPrerendered,
                 UIStateChangeType aShowAccelerators,
                 UIStateChangeType aShowFocusRings,
-                const DocShellOriginAttributes& aOriginAttributes,
+                const OriginAttributes& aOriginAttributes,
                 const nsAString& aPresentationURL = EmptyString())
   {
     return TabContext::SetTabContext(aIsMozBrowserElement,
                                      aIsPrerendered,
                                      aShowAccelerators,
                                      aShowFocusRings,
                                      aOriginAttributes,
                                      aPresentationURL);
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -354,16 +354,20 @@ TabParent::IsVisible() const
 
 void
 TabParent::DestroyInternal()
 {
   IMEStateManager::OnTabParentDestroying(this);
 
   RemoveWindowListeners();
 
+  if (a11y::DocAccessibleParent* tabDoc = GetTopLevelDocAccessible()) {
+    tabDoc->Destroy();
+  }
+
   // If this fails, it's most likely due to a content-process crash,
   // and auto-cleanup will kick in.  Otherwise, the child side will
   // destroy itself and send back __delete__().
   Unused << SendDestroy();
 
   if (RenderFrameParent* frame = GetRenderFrame()) {
     RemoveTabParentFromTable(frame->GetLayersId());
     frame->Destroy();
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -1585,30 +1585,30 @@ MatchOrigin(nsIFile* aPath,
             const mozilla::OriginAttributesPattern& aPattern)
 {
   // http://en.wikipedia.org/wiki/Domain_Name_System#Domain_name_syntax
   static const uint32_t MaxDomainLength = 253;
 
   nsresult rv;
   nsCString str;
   nsCString originNoSuffix;
-  mozilla::PrincipalOriginAttributes originAttributes;
+  mozilla::OriginAttributes originAttributes;
 
   rv = ReadFromFile(aPath, NS_LITERAL_CSTRING("origin"), str, MaxDomainLength);
   if (!originAttributes.PopulateFromOrigin(str, originNoSuffix)) {
     // Fails on parsing the originAttributes, treat this as a non-match.
     return false;
   }
 
   if (NS_SUCCEEDED(rv) && ExtractHostName(originNoSuffix, str) && str.Equals(aSite) &&
       aPattern.Matches(originAttributes)) {
     return true;
   }
 
-  mozilla::PrincipalOriginAttributes topLevelOriginAttributes;
+  mozilla::OriginAttributes topLevelOriginAttributes;
   rv = ReadFromFile(aPath, NS_LITERAL_CSTRING("topLevelOrigin"), str, MaxDomainLength);
   if (!topLevelOriginAttributes.PopulateFromOrigin(str, originNoSuffix)) {
     // Fails on paring the originAttributes, treat this as a non-match.
     return false;
   }
 
   if (NS_SUCCEEDED(rv) && ExtractHostName(originNoSuffix, str) && str.Equals(aSite) &&
       aPattern.Matches(topLevelOriginAttributes)) {
--- a/dom/media/gtest/TestGMPCrossOrigin.cpp
+++ b/dom/media/gtest/TestGMPCrossOrigin.cpp
@@ -465,17 +465,17 @@ GetNodeId(const nsAString& aOrigin,
   RefPtr<GeckoMediaPluginServiceParent> service =
     GeckoMediaPluginServiceParent::GetSingleton();
   EXPECT_TRUE(service);
   nsCString nodeId;
   nsresult result;
   UniquePtr<GetNodeIdCallback> callback(new TestGetNodeIdCallback(nodeId,
                                                                   result));
 
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   attrs.mPrivateBrowsingId = aInPBMode ? 1 : 0;
 
   nsAutoCString suffix;
   attrs.CreateSuffix(suffix);
 
   nsAutoString origin;
   origin.Assign(aOrigin);
   origin.Append(NS_ConvertUTF8toUTF16(suffix));
--- a/dom/media/systemservices/CamerasParent.cpp
+++ b/dom/media/systemservices/CamerasParent.cpp
@@ -635,17 +635,17 @@ CamerasParent::RecvGetCaptureDevice(cons
   DispatchToVideoCaptureThread(webrtc_runnable);
   return IPC_OK();
 }
 
 static nsresult
 GetPrincipalFromOrigin(const nsACString& aOrigin, nsIPrincipal** aPrincipal)
 {
   nsAutoCString originNoSuffix;
-  mozilla::PrincipalOriginAttributes attrs;
+  mozilla::OriginAttributes attrs;
   if (!attrs.PopulateFromOrigin(aOrigin, originNoSuffix)) {
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = NS_NewURI(getter_AddRefs(uri), originNoSuffix);
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/dom/offline/nsDOMOfflineResourceList.cpp
+++ b/dom/offline/nsDOMOfflineResourceList.cpp
@@ -809,17 +809,17 @@ nsDOMOfflineResourceList::CacheKeys()
     return NS_OK;
 
   nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(GetOwner());
   nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(window);
   nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(webNav);
 
   nsAutoCString originSuffix;
   if (loadContext) {
-    mozilla::DocShellOriginAttributes oa;
+    mozilla::OriginAttributes oa;
     bool ok = loadContext->GetOriginAttributes(oa);
     NS_ENSURE_TRUE(ok, NS_ERROR_UNEXPECTED);
 
     oa.CreateSuffix(originSuffix);
   }
 
   nsAutoCString groupID;
   mApplicationCacheService->BuildGroupIDForSuffix(
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -556,17 +556,17 @@ NS_IMETHODIMP nsPluginInstanceOwner::Get
 
   // if security checks (in particular CheckLoadURIWithPrincipal) needs
   // to be skipped we are creating a codebasePrincipal to make sure
   // that security check succeeds. Please note that we do not want to
   // fall back to using the systemPrincipal, because that would also
   // bypass ContentPolicy checks which should still be enforced.
   nsCOMPtr<nsIPrincipal> triggeringPrincipal;
   if (!aDoCheckLoadURIChecks) {
-    mozilla::PrincipalOriginAttributes attrs =
+    mozilla::OriginAttributes attrs =
       BasePrincipal::Cast(content->NodePrincipal())->OriginAttributesRef();
     triggeringPrincipal = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
   }
 
   rv = lh->OnLinkClick(content, uri, unitarget.get(), NullString(),
                        aPostStream, headersDataStream, true, triggeringPrincipal);
 
   return rv;
--- a/dom/presentation/PresentationRequest.cpp
+++ b/dom/presentation/PresentationRequest.cpp
@@ -527,17 +527,17 @@ PresentationRequest::IsPrioriAuthenticat
     return false;
   }
 
   if (uriSpec.EqualsLiteral("about:blank") ||
       uriSpec.EqualsLiteral("about:srcdoc")) {
     return true;
   }
 
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   nsCOMPtr<nsIPrincipal> principal =
     BasePrincipal::CreateCodebasePrincipal(uri, attrs);
   if (NS_WARN_IF(!principal)) {
     return false;
   }
 
   nsCOMPtr<nsIContentSecurityManager> csm =
     do_GetService(NS_CONTENTSECURITYMANAGER_CONTRACTID);
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -1357,17 +1357,17 @@ struct StorageDirectoryHelper::OriginPro
   enum Type
   {
     eChrome,
     eContent
   };
 
   nsCOMPtr<nsIFile> mDirectory;
   nsCString mSpec;
-  PrincipalOriginAttributes mAttrs;
+  OriginAttributes mAttrs;
   int64_t mTimestamp;
   nsCString mSuffix;
   nsCString mGroup;
   nsCString mOrigin;
 
   Type mType;
   bool mIsApp;
   bool mNeedsRestore;
@@ -1410,17 +1410,17 @@ class MOZ_STACK_CLASS OriginParser final
     eExpectingPort,
     eExpectingEmptyTokenOrDriveLetterOrPathnameComponent,
     eExpectingEmptyTokenOrPathnameComponent,
     eComplete,
     eHandledTrailingSeparator
   };
 
   const nsCString mOrigin;
-  const PrincipalOriginAttributes mOriginAttributes;
+  const OriginAttributes mOriginAttributes;
   Tokenizer mTokenizer;
 
   uint32_t mAppId;
   nsCString mSchema;
   nsCString mHost;
   Nullable<uint32_t> mPort;
   nsTArray<nsCString> mPathnameComponents;
   nsCString mHandledTokens;
@@ -1428,36 +1428,36 @@ class MOZ_STACK_CLASS OriginParser final
   SchemaType mSchemaType;
   State mState;
   bool mInIsolatedMozBrowser;
   bool mMaybeDriveLetter;
   bool mError;
 
 public:
   OriginParser(const nsACString& aOrigin,
-               const PrincipalOriginAttributes& aOriginAttributes)
+               const OriginAttributes& aOriginAttributes)
     : mOrigin(aOrigin)
     , mOriginAttributes(aOriginAttributes)
     , mTokenizer(aOrigin, '+')
     , mAppId(kNoAppId)
     , mPort()
     , mSchemaType(eNone)
     , mState(eExpectingAppIdOrSchema)
     , mInIsolatedMozBrowser(false)
     , mMaybeDriveLetter(false)
     , mError(false)
   { }
 
   static bool
   ParseOrigin(const nsACString& aOrigin,
               nsCString& aSpec,
-              PrincipalOriginAttributes* aAttrs);
+              OriginAttributes* aAttrs);
 
   bool
-  Parse(nsACString& aSpec, PrincipalOriginAttributes* aAttrs);
+  Parse(nsACString& aSpec, OriginAttributes* aAttrs);
 
 private:
   void
   HandleSchema(const nsDependentCSubstring& aSchema);
 
   void
   HandlePathnameComponent(const nsDependentCSubstring& aSchema);
 
@@ -1870,32 +1870,32 @@ GetJarPrefix(uint32_t aAppId,
 
 nsresult
 CreateDirectoryMetadata(nsIFile* aDirectory, int64_t aTimestamp,
                         const nsACString& aSuffix, const nsACString& aGroup,
                         const nsACString& aOrigin, bool aIsApp)
 {
   AssertIsOnIOThread();
 
-  PrincipalOriginAttributes groupAttributes;
+  OriginAttributes groupAttributes;
 
   nsCString groupNoSuffix;
   bool ok = groupAttributes.PopulateFromOrigin(aGroup, groupNoSuffix);
   if (!ok) {
     return NS_ERROR_FAILURE;
   }
 
   nsCString groupPrefix;
   GetJarPrefix(groupAttributes.mAppId,
                groupAttributes.mInIsolatedMozBrowser,
                groupPrefix);
 
   nsCString group = groupPrefix + groupNoSuffix;
 
-  PrincipalOriginAttributes originAttributes;
+  OriginAttributes originAttributes;
 
   nsCString originNoSuffix;
   ok = originAttributes.PopulateFromOrigin(aOrigin, originNoSuffix);
   if (!ok) {
     return NS_ERROR_FAILURE;
   }
 
   nsCString originPrefix;
@@ -4562,17 +4562,17 @@ QuotaManager::EnsureOriginIsInitialized(
     nsString leafName;
     nsresult rv = directory->GetLeafName(leafName);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     if (!leafName.EqualsLiteral(kChromeOrigin)) {
       nsCString spec;
-      PrincipalOriginAttributes attrs;
+      OriginAttributes attrs;
       bool result = OriginParser::ParseOrigin(NS_ConvertUTF16toUTF8(leafName),
                                               spec, &attrs);
       if (NS_WARN_IF(!result)) {
         QM_WARNING("Preventing creation of a new origin directory which is not "
                    "supported by our origin parser!");
 
         return NS_ERROR_FAILURE;
       }
@@ -6542,17 +6542,17 @@ StorageDirectoryHelper::AddOriginDirecto
 
   if (leafName.EqualsLiteral(kChromeOrigin)) {
     originProps = mOriginProps.AppendElement();
     originProps->mDirectory = aDirectory;
     originProps->mSpec = kChromeOrigin;
     originProps->mType = OriginProps::eChrome;
   } else {
     nsCString spec;
-    PrincipalOriginAttributes attrs;
+    OriginAttributes attrs;
     bool result = OriginParser::ParseOrigin(NS_ConvertUTF16toUTF8(leafName),
                                             spec, &attrs);
     if (NS_WARN_IF(!result)) {
       return NS_ERROR_FAILURE;
     }
 
     originProps = mOriginProps.AppendElement();
     originProps->mDirectory = aDirectory;
@@ -6680,35 +6680,35 @@ StorageDirectoryHelper::Run()
 
   return NS_OK;
 }
 
 // static
 bool
 OriginParser::ParseOrigin(const nsACString& aOrigin,
                           nsCString& aSpec,
-                          PrincipalOriginAttributes* aAttrs)
+                          OriginAttributes* aAttrs)
 {
   MOZ_ASSERT(!aOrigin.IsEmpty());
   MOZ_ASSERT(aAttrs);
 
-  PrincipalOriginAttributes originAttributes;
+  OriginAttributes originAttributes;
 
   nsCString originNoSuffix;
   bool ok = originAttributes.PopulateFromOrigin(aOrigin, originNoSuffix);
   if (!ok) {
     return false;
   }
 
   OriginParser parser(originNoSuffix, originAttributes);
   return parser.Parse(aSpec, aAttrs);
 }
 
 bool
-OriginParser::Parse(nsACString& aSpec, PrincipalOriginAttributes* aAttrs)
+OriginParser::Parse(nsACString& aSpec, OriginAttributes* aAttrs)
 {
   MOZ_ASSERT(aAttrs);
 
   while (mTokenizer.hasMoreTokens()) {
     const nsDependentCSubstring& token = mTokenizer.nextToken();
 
     HandleToken(token);
 
@@ -6737,17 +6737,17 @@ OriginParser::Parse(nsACString& aSpec, P
 
   MOZ_ASSERT(mState == eComplete || mState == eHandledTrailingSeparator);
 
   if (mAppId == kNoAppId) {
     *aAttrs = mOriginAttributes;
   } else {
     MOZ_ASSERT(mOriginAttributes.mAppId == kNoAppId);
 
-    *aAttrs = PrincipalOriginAttributes(mAppId, mInIsolatedMozBrowser);
+    *aAttrs = OriginAttributes(mAppId, mInIsolatedMozBrowser);
   }
 
   nsAutoCString spec(mSchema);
 
   if (mSchemaType == eFile) {
     spec.AppendLiteral("://");
 
     for (uint32_t count = mPathnameComponents.Length(), index = 0;
--- a/dom/quota/OriginScope.h
+++ b/dom/quota/OriginScope.h
@@ -23,17 +23,17 @@ public:
     ePrefix,
     eNull
   };
 
 private:
   struct OriginAndAttributes
   {
     nsCString mOrigin;
-    PrincipalOriginAttributes mAttributes;
+    OriginAttributes mAttributes;
 
     OriginAndAttributes(const OriginAndAttributes& aOther)
       : mOrigin(aOther.mOrigin)
       , mAttributes(aOther.mAttributes)
     {
       MOZ_COUNT_CTOR(OriginAndAttributes);
     }
 
--- a/dom/security/nsCSPParser.cpp
+++ b/dom/security/nsCSPParser.cpp
@@ -919,16 +919,21 @@ nsCSPParser::referrerDirectiveValue(nsCS
   }
 
   //referrer-directive deprecation warning
   const char16_t* params[] = { mCurDir[1].get() };
   logWarningErrorToConsole(nsIScriptError::warningFlag, "deprecatedReferrerDirective",
                              params, ArrayLength(params));
 
   // the referrer policy is valid, so go ahead and use it.
+  nsWeakPtr ctx = mCSPContext->GetLoadingContext();
+  nsCOMPtr<nsIDocument> doc = do_QueryReferent(ctx);
+  if (doc) {
+    doc->SetHasReferrerPolicyCSP(true);
+  }
   mPolicy->setReferrerPolicy(&mCurDir[1]);
   mPolicy->addDirective(aDir);
 }
 
 void
 nsCSPParser::requireSRIForDirectiveValue(nsRequireSRIForDirective* aDir)
 {
   CSPPARSERLOG(("nsCSPParser::requireSRIForDirectiveValue"));
--- a/dom/security/nsCSPService.cpp
+++ b/dom/security/nsCSPService.cpp
@@ -68,40 +68,39 @@ subjectToCSP(nsIURI* aURI, nsContentPoli
   rv = aURI->SchemeIs("blob", &match);
   if (NS_SUCCEEDED(rv) && match) {
     return true;
   }
   rv = aURI->SchemeIs("filesystem", &match);
   if (NS_SUCCEEDED(rv) && match) {
     return true;
   }
-  // finally we have to whitelist "about:" which does not fall in
-  // any of the two categories underneath but is not subject to CSP.
+
+  // Finally we have to whitelist "about:" which does not fall into
+  // the category underneath and also "javascript:" which is not
+  // subject to CSP content loading rules.
   rv = aURI->SchemeIs("about", &match);
   if (NS_SUCCEEDED(rv) && match) {
     return false;
   }
+  rv = aURI->SchemeIs("javascript", &match);
+  if (NS_SUCCEEDED(rv) && match) {
+    return false;
+  }
 
   // Other protocols are not subject to CSP and can be whitelisted:
   // * URI_IS_LOCAL_RESOURCE
   //   e.g. chrome:, data:, blob:, resource:, moz-icon:
-  // * URI_INHERITS_SECURITY_CONTEXT
-  //   e.g. javascript:
-  //
   // Please note that it should be possible for websites to
   // whitelist their own protocol handlers with respect to CSP,
   // hence we use protocol flags to accomplish that.
   rv = NS_URIChainHasFlags(aURI, nsIProtocolHandler::URI_IS_LOCAL_RESOURCE, &match);
   if (NS_SUCCEEDED(rv) && match) {
     return false;
   }
-  rv = NS_URIChainHasFlags(aURI, nsIProtocolHandler::URI_INHERITS_SECURITY_CONTEXT, &match);
-  if (NS_SUCCEEDED(rv) && match) {
-    return false;
-  }
   // all other protocols are subject To CSP.
   return true;
 }
 
 /* nsIContentPolicy implementation */
 NS_IMETHODIMP
 CSPService::ShouldLoad(uint32_t aContentType,
                        nsIURI *aContentLocation,
--- a/dom/storage/StorageDBThread.cpp
+++ b/dom/storage/StorageDBThread.cpp
@@ -49,17 +49,17 @@ namespace { // anon
 // key in the schema version 0 format for the scope column.
 nsCString
 Scheme0Scope(StorageCacheBridge* aCache)
 {
   nsCString result;
 
   nsCString suffix = aCache->OriginSuffix();
 
-  PrincipalOriginAttributes oa;
+  OriginAttributes oa;
   if (!suffix.IsEmpty()) {
     DebugOnly<bool> success = oa.PopulateFromSuffix(suffix);
     MOZ_ASSERT(success);
   }
 
   if (oa.mAppId != nsIScriptSecurityManager::NO_APP_ID ||
       oa.mInIsolatedMozBrowser) {
     result.AppendInt(oa.mAppId);
@@ -763,17 +763,17 @@ OriginAttrsPatternMatchSQLFunction::OnFu
     mozIStorageValueArray* aFunctionArguments, nsIVariant** aResult)
 {
   nsresult rv;
 
   nsAutoCString suffix;
   rv = aFunctionArguments->GetUTF8String(0, suffix);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  PrincipalOriginAttributes oa;
+  OriginAttributes oa;
   bool success = oa.PopulateFromSuffix(suffix);
   NS_ENSURE_TRUE(success, NS_ERROR_FAILURE);
   bool result = mPattern.Matches(oa);
 
   RefPtr<nsVariant> outVar(new nsVariant());
   rv = outVar->SetAsBool(result);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -1203,17 +1203,17 @@ StorageDBThread::PendingOperations::HasT
   return !!mUpdates.Count() || !!mClears.Count();
 }
 
 namespace {
 
 bool OriginPatternMatches(const nsACString& aOriginSuffix,
                           const OriginAttributesPattern& aPattern)
 {
-  PrincipalOriginAttributes oa;
+  OriginAttributes oa;
   DebugOnly<bool> rv = oa.PopulateFromSuffix(aOriginSuffix);
   MOZ_ASSERT(rv);
   return aPattern.Matches(oa);
 }
 
 } // namespace
 
 bool
--- a/dom/storage/StorageDBUpdater.cpp
+++ b/dom/storage/StorageDBUpdater.cpp
@@ -130,17 +130,17 @@ public:
       Token t;
       while (Next(t)) {
         if (t.Equals(Token::Char(':'))) {
           Claim(suffix);
           break;
         }
       }
     } else {
-      PrincipalOriginAttributes attrs(appId, inIsolatedMozBrowser);
+      OriginAttributes attrs(appId, inIsolatedMozBrowser);
       attrs.CreateSuffix(suffix);
     }
 
     // Consume the rest of the input as "origin".
     origin.Assign(Substring(mCursor, mEnd));
   }
 };
 
--- a/dom/storage/StorageManager.cpp
+++ b/dom/storage/StorageManager.cpp
@@ -480,17 +480,17 @@ StorageManagerBase::GetLocalStorageForPr
 }
 
 void
 StorageManagerBase::ClearCaches(uint32_t aUnloadFlags,
                                 const OriginAttributesPattern& aPattern,
                                 const nsACString& aOriginScope)
 {
   for (auto iter1 = mCaches.Iter(); !iter1.Done(); iter1.Next()) {
-    PrincipalOriginAttributes oa;
+    OriginAttributes oa;
     DebugOnly<bool> rv = oa.PopulateFromSuffix(iter1.Key());
     MOZ_ASSERT(rv);
     if (!aPattern.Matches(oa)) {
       // This table doesn't match the given origin attributes pattern
       continue;
     }
 
     CacheOriginHashtable* table = iter1.Data();
--- a/dom/workers/PServiceWorkerManager.ipdl
+++ b/dom/workers/PServiceWorkerManager.ipdl
@@ -2,43 +2,43 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 include protocol PBackground;
 
 include PBackgroundSharedTypes;
 include ServiceWorkerRegistrarTypes;
 
-using mozilla::PrincipalOriginAttributes from "mozilla/ipc/BackgroundUtils.h";
+using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
 
 namespace mozilla {
 namespace dom {
 
 protocol PServiceWorkerManager
 {
   manager PBackground;
 
 parent:
   async Register(ServiceWorkerRegistrationData data);
 
   async Unregister(PrincipalInfo principalInfo, nsString scope);
 
-  async PropagateSoftUpdate(PrincipalOriginAttributes originAttributes,
+  async PropagateSoftUpdate(OriginAttributes originAttributes,
                             nsString scope);
   async PropagateUnregister(PrincipalInfo principalInfo, nsString scope);
 
   async PropagateRemove(nsCString host);
 
   async PropagateRemoveAll();
 
   async Shutdown();
 
 child:
   async NotifyRegister(ServiceWorkerRegistrationData data);
-  async NotifySoftUpdate(PrincipalOriginAttributes originAttributes, nsString scope);
+  async NotifySoftUpdate(OriginAttributes originAttributes, nsString scope);
   async NotifyUnregister(PrincipalInfo principalInfo, nsString scope);
   async NotifyRemove(nsCString host);
   async NotifyRemoveAll();
 
   async __delete__();
 };
 
 } // namespace dom
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -247,17 +247,17 @@ GetWorkerPref(const nsACString& aPref,
 }
 
 // This fn creates a key for a SharedWorker that contains the name, script
 // spec, and the serialized origin attributes:
 // "name|scriptSpec^key1=val1&key2=val2&key3=val3"
 void
 GenerateSharedWorkerKey(const nsACString& aScriptSpec,
                         const nsACString& aName,
-                        const PrincipalOriginAttributes& aAttrs,
+                        const OriginAttributes& aAttrs,
                         nsCString& aKey)
 {
   nsAutoCString suffix;
   aAttrs.CreateSuffix(suffix);
 
   aKey.Truncate();
   aKey.SetCapacity(aName.Length() + aScriptSpec.Length() + suffix.Length() + 2);
   aKey.Append(aName);
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -412,17 +412,17 @@ private:
   FailLoaders(nsresult aRv);
 
   RefPtr<Cache> mCache;
   RefPtr<CacheStorage> mCacheStorage;
   nsCOMPtr<nsIGlobalObject> mSandboxGlobalObject;
   nsTArray<RefPtr<CacheScriptLoader>> mLoaders;
 
   nsString mCacheName;
-  PrincipalOriginAttributes mOriginAttributes;
+  OriginAttributes mOriginAttributes;
 };
 
 NS_IMPL_ISUPPORTS0(CacheCreator)
 
 class CacheScriptLoader final : public PromiseNativeHandler
                                   , public nsIStreamLoaderObserver
 {
 public:
--- a/dom/workers/ServiceWorkerInfo.h
+++ b/dom/workers/ServiceWorkerInfo.h
@@ -27,17 +27,17 @@ class ServiceWorkerInfo final : public n
 {
 private:
   nsCOMPtr<nsIPrincipal> mPrincipal;
   const nsCString mScope;
   const nsCString mScriptSpec;
   const nsString mCacheName;
   const nsLoadFlags mLoadFlags;
   ServiceWorkerState mState;
-  PrincipalOriginAttributes mOriginAttributes;
+  OriginAttributes mOriginAttributes;
 
   // This id is shared with WorkerPrivate to match requests issued by service
   // workers to their corresponding serviceWorkerInfo.
   uint64_t mServiceWorkerID;
 
   // We hold rawptrs since the ServiceWorker constructor and destructor ensure
   // addition and removal.
   // There is a high chance of there being at least one ServiceWorker
@@ -108,17 +108,17 @@ public:
                     nsLoadFlags aLoadFlags);
 
   ServiceWorkerState
   State() const
   {
     return mState;
   }
 
-  const PrincipalOriginAttributes&
+  const OriginAttributes&
   GetOriginAttributes() const
   {
     return mOriginAttributes;
   }
 
   const nsString&
   CacheName() const
   {
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -316,17 +316,17 @@ public:
   NS_INLINE_DECL_REFCOUNTING(ServiceWorkerResolveWindowPromiseOnRegisterCallback, override)
 };
 
 namespace {
 
 class PropagateSoftUpdateRunnable final : public Runnable
 {
 public:
-  PropagateSoftUpdateRunnable(const PrincipalOriginAttributes& aOriginAttributes,
+  PropagateSoftUpdateRunnable(const OriginAttributes& aOriginAttributes,
                               const nsAString& aScope)
     : mOriginAttributes(aOriginAttributes)
     , mScope(aScope)
   {}
 
   NS_IMETHOD Run() override
   {
     AssertIsOnMainThread();
@@ -337,17 +337,17 @@ public:
     swm->PropagateSoftUpdate(mOriginAttributes, mScope);
     return NS_OK;
   }
 
 private:
   ~PropagateSoftUpdateRunnable()
   {}
 
-  const PrincipalOriginAttributes mOriginAttributes;
+  const OriginAttributes mOriginAttributes;
   const nsString mScope;
 };
 
 class PropagateUnregisterRunnable final : public Runnable
 {
 public:
   PropagateUnregisterRunnable(nsIPrincipal* aPrincipal,
                               nsIServiceWorkerUnregisterCallback* aCallback,
@@ -923,17 +923,17 @@ ServiceWorkerManager::SendPushEvent(cons
 }
 
 nsresult
 ServiceWorkerManager::SendPushEvent(const nsACString& aOriginAttributes,
                                     const nsACString& aScope,
                                     const nsAString& aMessageId,
                                     const Maybe<nsTArray<uint8_t>>& aData)
 {
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   if (!attrs.PopulateFromSuffix(aOriginAttributes)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   ServiceWorkerInfo* serviceWorker = GetActiveWorkerInfoForScope(attrs, aScope);
   if (NS_WARN_IF(!serviceWorker)) {
     return NS_ERROR_FAILURE;
   }
@@ -945,17 +945,17 @@ ServiceWorkerManager::SendPushEvent(cons
   return serviceWorker->WorkerPrivate()->SendPushEvent(aMessageId, aData,
                                                        registration);
 }
 
 NS_IMETHODIMP
 ServiceWorkerManager::SendPushSubscriptionChangeEvent(const nsACString& aOriginAttributes,
                                                       const nsACString& aScope)
 {
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   if (!attrs.PopulateFromSuffix(aOriginAttributes)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   ServiceWorkerInfo* info = GetActiveWorkerInfoForScope(attrs, aScope);
   if (!info) {
     return NS_ERROR_FAILURE;
   }
@@ -971,17 +971,17 @@ ServiceWorkerManager::SendNotificationEv
                                             const nsAString& aDir,
                                             const nsAString& aLang,
                                             const nsAString& aBody,
                                             const nsAString& aTag,
                                             const nsAString& aIcon,
                                             const nsAString& aData,
                                             const nsAString& aBehavior)
 {
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   if (!attrs.PopulateFromSuffix(aOriginSuffix)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   ServiceWorkerInfo* info = GetActiveWorkerInfoForScope(attrs, aScope);
   if (!info) {
     return NS_ERROR_FAILURE;
   }
@@ -1131,17 +1131,17 @@ ServiceWorkerManager::CheckReadyPromise(
     aPromise->MaybeResolve(swr);
     return true;
   }
 
   return false;
 }
 
 ServiceWorkerInfo*
-ServiceWorkerManager::GetActiveWorkerInfoForScope(const PrincipalOriginAttributes& aOriginAttributes,
+ServiceWorkerManager::GetActiveWorkerInfoForScope(const OriginAttributes& aOriginAttributes,
                                                   const nsACString& aScope)
 {
   AssertIsOnMainThread();
 
   nsCOMPtr<nsIURI> scopeURI;
   nsresult rv = NS_NewURI(getter_AddRefs(scopeURI), aScope, nullptr, nullptr);
   if (NS_FAILED(rv)) {
     return nullptr;
@@ -2334,17 +2334,17 @@ public:
 
     return NS_OK;
   }
 };
 
 } // anonymous namespace
 
 void
-ServiceWorkerManager::DispatchFetchEvent(const PrincipalOriginAttributes& aOriginAttributes,
+ServiceWorkerManager::DispatchFetchEvent(const OriginAttributes& aOriginAttributes,
                                          nsIDocument* aDoc,
                                          const nsAString& aDocumentIdForTopLevelNavigation,
                                          nsIInterceptedChannel* aChannel,
                                          bool aIsReload,
                                          bool aIsSubresourceLoad,
                                          ErrorResult& aRv)
 {
   MOZ_ASSERT(aChannel);
@@ -2608,17 +2608,17 @@ ServiceWorkerManager::NotifyServiceWorke
 
     if (utf8Scope.Equals(aRegistration->mScope)) {
       target->RegistrationRemoved();
     }
   }
 }
 
 void
-ServiceWorkerManager::SoftUpdate(const PrincipalOriginAttributes& aOriginAttributes,
+ServiceWorkerManager::SoftUpdate(const OriginAttributes& aOriginAttributes,
                                  const nsACString& aScope)
 {
   AssertIsOnMainThread();
 
   if (mShuttingDown) {
     return;
   }
 
@@ -3589,27 +3589,27 @@ ServiceWorkerManager::Observe(nsISupport
 
 NS_IMETHODIMP
 ServiceWorkerManager::PropagateSoftUpdate(JS::Handle<JS::Value> aOriginAttributes,
                                           const nsAString& aScope,
                                           JSContext* aCx)
 {
   AssertIsOnMainThread();
 
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   PropagateSoftUpdate(attrs, aScope);
   return NS_OK;
 }
 
 void
-ServiceWorkerManager::PropagateSoftUpdate(const PrincipalOriginAttributes& aOriginAttributes,
+ServiceWorkerManager::PropagateSoftUpdate(const OriginAttributes& aOriginAttributes,
                                           const nsAString& aScope)
 {
   AssertIsOnMainThread();
 
   if (!mActor) {
     RefPtr<nsIRunnable> runnable =
       new PropagateSoftUpdateRunnable(aOriginAttributes, aScope);
     AppendPendingOperation(runnable);
@@ -3915,17 +3915,17 @@ ServiceWorkerManager::UpdateTimerFired(n
   if (!registration) {
     return;
   }
 
   if (!registration->CheckAndClearIfUpdateNeeded()) {
     return;
   }
 
-  PrincipalOriginAttributes attrs = aPrincipal->OriginAttributesRef();
+  OriginAttributes attrs = aPrincipal->OriginAttributesRef();
 
   SoftUpdate(attrs, aScope);
 }
 
 void
 ServiceWorkerManager::MaybeSendUnregister(nsIPrincipal* aPrincipal,
                                           const nsACString& aScope)
 {
--- a/dom/workers/ServiceWorkerManager.h
+++ b/dom/workers/ServiceWorkerManager.h
@@ -32,17 +32,17 @@
 #include "nsRefPtrHashtable.h"
 #include "nsTArrayForwardDeclare.h"
 #include "nsTObserverArray.h"
 
 class nsIConsoleReportCollector;
 
 namespace mozilla {
 
-class PrincipalOriginAttributes;
+class OriginAttributes;
 
 namespace dom {
 
 class ServiceWorkerRegistrationListener;
 
 namespace workers {
 
 class ServiceWorkerClientInfo;
@@ -145,35 +145,35 @@ public:
   // semantics that ensure this method returns true until the worker is known to
   // have shut down in order to allow the caller to induce a crash for security
   // reasons without having to worry about shutdown races with the worker.
   bool
   MayHaveActiveServiceWorkerInstance(ContentParent* aContent,
                                      nsIPrincipal* aPrincipal);
 
   void
-  DispatchFetchEvent(const PrincipalOriginAttributes& aOriginAttributes,
+  DispatchFetchEvent(const OriginAttributes& aOriginAttributes,
                      nsIDocument* aDoc,
                      const nsAString& aDocumentIdForTopLevelNavigation,
                      nsIInterceptedChannel* aChannel,
                      bool aIsReload,
                      bool aIsSubresourceLoad,
                      ErrorResult& aRv);
 
   void
   Update(nsIPrincipal* aPrincipal,
          const nsACString& aScope,
          ServiceWorkerUpdateFinishCallback* aCallback);
 
   void
-  SoftUpdate(const PrincipalOriginAttributes& aOriginAttributes,
+  SoftUpdate(const OriginAttributes& aOriginAttributes,
              const nsACString& aScope);
 
   void
-  PropagateSoftUpdate(const PrincipalOriginAttributes& aOriginAttributes,
+  PropagateSoftUpdate(const OriginAttributes& aOriginAttributes,
                       const nsAString& aScope);
 
   void
   PropagateRemove(const nsACString& aHost);
 
   void
   Remove(const nsACString& aHost);
 
@@ -353,17 +353,17 @@ private:
 
   nsresult
   GetServiceWorkerForScope(nsPIDOMWindowInner* aWindow,
                            const nsAString& aScope,
                            WhichServiceWorker aWhichWorker,
                            nsISupports** aServiceWorker);
 
   ServiceWorkerInfo*
-  GetActiveWorkerInfoForScope(const PrincipalOriginAttributes& aOriginAttributes,
+  GetActiveWorkerInfoForScope(const OriginAttributes& aOriginAttributes,
                               const nsACString& aScope);
 
   ServiceWorkerInfo*
   GetActiveWorkerInfoForDocument(nsIDocument* aDocument);
 
   void
   TransitionServiceWorkerRegistrationWorker(ServiceWorkerRegistrationInfo* aRegistration,
                                             WhichServiceWorker aWhichOne);
--- a/dom/workers/ServiceWorkerManagerChild.cpp
+++ b/dom/workers/ServiceWorkerManagerChild.cpp
@@ -27,17 +27,17 @@ ServiceWorkerManagerChild::RecvNotifyReg
   MOZ_ASSERT(swm);
 
   swm->LoadRegistration(aData);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ServiceWorkerManagerChild::RecvNotifySoftUpdate(
-                                      const PrincipalOriginAttributes& aOriginAttributes,
+                                      const OriginAttributes& aOriginAttributes,
                                       const nsString& aScope)
 {
   if (mShuttingDown) {
     return IPC_OK();
   }
 
   RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
   MOZ_ASSERT(swm);
--- a/dom/workers/ServiceWorkerManagerChild.h
+++ b/dom/workers/ServiceWorkerManagerChild.h
@@ -7,17 +7,17 @@
 #ifndef mozilla_dom_ServiceWorkerManagerChild_h
 #define mozilla_dom_ServiceWorkerManagerChild_h
 
 #include "mozilla/dom/PServiceWorkerManagerChild.h"
 #include "mozilla/ipc/BackgroundUtils.h"
 
 namespace mozilla {
 
-class PrincipalOriginAttributes;
+class OriginAttributes;
 
 namespace ipc {
 class BackgroundChildImpl;
 } // namespace ipc
 
 namespace dom {
 namespace workers {
 
@@ -31,17 +31,17 @@ public:
   void ManagerShuttingDown()
   {
     mShuttingDown = true;
   }
 
   virtual mozilla::ipc::IPCResult RecvNotifyRegister(const ServiceWorkerRegistrationData& aData)
                                                                        override;
 
-  virtual mozilla::ipc::IPCResult RecvNotifySoftUpdate(const PrincipalOriginAttributes& aOriginAttributes,
+  virtual mozilla::ipc::IPCResult RecvNotifySoftUpdate(const OriginAttributes& aOriginAttributes,
                                                        const nsString& aScope) override;
 
   virtual mozilla::ipc::IPCResult RecvNotifyUnregister(const PrincipalInfo& aPrincipalInfo,
                                                        const nsString& aScope) override;
 
   virtual mozilla::ipc::IPCResult RecvNotifyRemove(const nsCString& aHost) override;
 
   virtual mozilla::ipc::IPCResult RecvNotifyRemoveAll() override;
--- a/dom/workers/ServiceWorkerManagerParent.cpp
+++ b/dom/workers/ServiceWorkerManagerParent.cpp
@@ -226,17 +226,17 @@ ServiceWorkerManagerParent::RecvUnregist
     new CheckPrincipalWithCallbackRunnable(parent.forget(), aPrincipalInfo,
                                            callback);
   MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable));
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
-ServiceWorkerManagerParent::RecvPropagateSoftUpdate(const PrincipalOriginAttributes& aOriginAttributes,
+ServiceWorkerManagerParent::RecvPropagateSoftUpdate(const OriginAttributes& aOriginAttributes,
                                                     const nsString& aScope)
 {
   AssertIsOnBackgroundThread();
 
   if (NS_WARN_IF(!mService)) {
     return IPC_FAIL_NO_REASON(this);
   }
 
--- a/dom/workers/ServiceWorkerManagerParent.h
+++ b/dom/workers/ServiceWorkerManagerParent.h
@@ -6,17 +6,17 @@
 
 #ifndef mozilla_dom_ServiceWorkerManagerParent_h
 #define mozilla_dom_ServiceWorkerManagerParent_h
 
 #include "mozilla/dom/PServiceWorkerManagerParent.h"
 
 namespace mozilla {
 
-class PrincipalOriginAttributes;
+class OriginAttributes;
 
 namespace ipc {
 class BackgroundParentImpl;
 } // namespace ipc
 
 namespace dom {
 namespace workers {
 
@@ -39,17 +39,17 @@ private:
   ~ServiceWorkerManagerParent();
 
   virtual mozilla::ipc::IPCResult RecvRegister(
     const ServiceWorkerRegistrationData& aData) override;
 
   virtual mozilla::ipc::IPCResult RecvUnregister(const PrincipalInfo& aPrincipalInfo,
                                                  const nsString& aScope) override;
 
-  virtual mozilla::ipc::IPCResult RecvPropagateSoftUpdate(const PrincipalOriginAttributes& aOriginAttributes,
+  virtual mozilla::ipc::IPCResult RecvPropagateSoftUpdate(const OriginAttributes& aOriginAttributes,
                                                           const nsString& aScope) override;
 
   virtual mozilla::ipc::IPCResult RecvPropagateUnregister(const PrincipalInfo& aPrincipalInfo,
                                                           const nsString& aScope) override;
 
   virtual mozilla::ipc::IPCResult RecvPropagateRemove(const nsCString& aHost) override;
 
   virtual mozilla::ipc::IPCResult RecvPropagateRemoveAll() override;
--- a/dom/workers/ServiceWorkerManagerService.cpp
+++ b/dom/workers/ServiceWorkerManagerService.cpp
@@ -108,17 +108,17 @@ ServiceWorkerManagerService::PropagateRe
 #ifdef DEBUG
   MOZ_ASSERT(parentFound);
 #endif
 }
 
 void
 ServiceWorkerManagerService::PropagateSoftUpdate(
                                       uint64_t aParentID,
-                                      const PrincipalOriginAttributes& aOriginAttributes,
+                                      const OriginAttributes& aOriginAttributes,
                                       const nsAString& aScope)
 {
   AssertIsOnBackgroundThread();
 
   DebugOnly<bool> parentFound = false;
   for (auto iter = mAgents.Iter(); !iter.Done(); iter.Next()) {
     RefPtr<ServiceWorkerManagerParent> parent = iter.Get()->GetKey();
     MOZ_ASSERT(parent);
--- a/dom/workers/ServiceWorkerManagerService.h
+++ b/dom/workers/ServiceWorkerManagerService.h
@@ -8,17 +8,17 @@
 #define mozilla_dom_ServiceWorkerManagerService_h
 
 #include "nsISupportsImpl.h"
 #include "nsHashKeys.h"
 #include "nsTHashtable.h"
 
 namespace mozilla {
 
-class PrincipalOriginAttributes;
+class OriginAttributes;
 
 namespace ipc {
 class PrincipalInfo;
 } // namespace ipc
 
 namespace dom {
 
 class ServiceWorkerRegistrationData;
@@ -37,17 +37,17 @@ public:
 
   void RegisterActor(ServiceWorkerManagerParent* aParent);
   void UnregisterActor(ServiceWorkerManagerParent* aParent);
 
   void PropagateRegistration(uint64_t aParentID,
                              ServiceWorkerRegistrationData& aData);
 
   void PropagateSoftUpdate(uint64_t aParentID,
-                           const PrincipalOriginAttributes& aOriginAttributes,
+                           const OriginAttributes& aOriginAttributes,
                            const nsAString& aScope);
 
   void PropagateUnregister(uint64_t aParentID,
                            const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
                            const nsAString& aScope);
 
   void PropagateRemove(uint64_t aParentID, const nsACString& aHost);
 
--- a/dom/workers/ServiceWorkerRegistrar.cpp
+++ b/dom/workers/ServiceWorkerRegistrar.cpp
@@ -336,17 +336,17 @@ ServiceWorkerRegistrar::ReadData()
     }
 
     nsAutoCString line;
     nsAutoCString unused;
     if (version.EqualsLiteral(SERVICEWORKERREGISTRAR_VERSION)) {
       nsAutoCString suffix;
       GET_LINE(suffix);
 
-      PrincipalOriginAttributes attrs;
+      OriginAttributes attrs;
       if (!attrs.PopulateFromSuffix(suffix)) {
         return NS_ERROR_INVALID_ARG;
       }
 
       GET_LINE(entry->scope());
 
       entry->principal() =
         mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope());
@@ -377,17 +377,17 @@ ServiceWorkerRegistrar::ReadData()
       }
     } else if (version.EqualsLiteral("5")) {
       overwrite = true;
       dedupe = true;
 
       nsAutoCString suffix;
       GET_LINE(suffix);
 
-      PrincipalOriginAttributes attrs;
+      OriginAttributes attrs;
       if (!attrs.PopulateFromSuffix(suffix)) {
         return NS_ERROR_INVALID_ARG;
       }
 
       GET_LINE(entry->scope());
 
       entry->principal() =
         mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope());
@@ -410,17 +410,17 @@ ServiceWorkerRegistrar::ReadData()
       entry->loadFlags() = nsIRequest::VALIDATE_ALWAYS;
     } else if (version.EqualsLiteral("4")) {
       overwrite = true;
       dedupe = true;
 
       nsAutoCString suffix;
       GET_LINE(suffix);
 
-      PrincipalOriginAttributes attrs;
+      OriginAttributes attrs;
       if (!attrs.PopulateFromSuffix(suffix)) {
         return NS_ERROR_INVALID_ARG;
       }
 
       GET_LINE(entry->scope());
 
       entry->principal() =
         mozilla::ipc::ContentPrincipalInfo(attrs, entry->scope());
@@ -437,17 +437,17 @@ ServiceWorkerRegistrar::ReadData()
       entry->loadFlags() = nsIRequest::VALIDATE_ALWAYS;
     } else if (version.EqualsLiteral("3")) {
       overwrite = true;
       dedupe = true;
 
       nsAutoCString suffix;
       GET_LINE(suffix);
 
-      PrincipalOriginAttributes attrs;
+      OriginAttributes attrs;
       if (!attrs.PopulateFromSuffix(suffix)) {
         return NS_ERROR_INVALID_ARG;
       }
 
       // principal spec is no longer used; we use scope directly instead
       GET_LINE(unused);
 
       GET_LINE(entry->scope());
@@ -467,17 +467,17 @@ ServiceWorkerRegistrar::ReadData()
       entry->loadFlags() = nsIRequest::VALIDATE_ALWAYS;
     } else if (version.EqualsLiteral("2")) {
       overwrite = true;
       dedupe = true;
 
       nsAutoCString suffix;
       GET_LINE(suffix);
 
-      PrincipalOriginAttributes attrs;
+      OriginAttributes attrs;
       if (!attrs.PopulateFromSuffix(suffix)) {
         return NS_ERROR_INVALID_ARG;
       }
 
       // principal spec is no longer used; we use scope directly instead
       GET_LINE(unused);
 
       GET_LINE(entry->scope());
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -4458,17 +4458,17 @@ WorkerPrivate::GetLoadInfo(JSContext* aC
         if (NS_FAILED(rv)) {
           return rv;
         }
       }
       loadInfo.mXHRParamsAllowed = true;
       loadInfo.mFromWindow = false;
       loadInfo.mWindowID = UINT64_MAX;
       loadInfo.mStorageAllowed = true;
-      loadInfo.mOriginAttributes = PrincipalOriginAttributes();
+      loadInfo.mOriginAttributes = OriginAttributes();
     }
 
     MOZ_ASSERT(loadInfo.mPrincipal);
     MOZ_ASSERT(isChrome || !loadInfo.mDomain.IsEmpty());
 
     if (!loadInfo.mLoadGroup || aLoadGroupBehavior == OverrideLoadGroup) {
       OverrideLoadInfoLoadGroup(loadInfo);
     }
--- a/dom/workers/WorkerPrivate.h
+++ b/dom/workers/WorkerPrivate.h
@@ -784,17 +784,17 @@ public:
   }
 
   bool
   IsStorageAllowed() const
   {
     return mLoadInfo.mStorageAllowed;
   }
 
-  const PrincipalOriginAttributes&
+  const OriginAttributes&
   GetOriginAttributes() const
   {
     return mLoadInfo.mOriginAttributes;
   }
 
   // Determine if the SW testing per-window flag is set by devtools
   bool
   ServiceWorkersTestingInWindow() const
--- a/dom/workers/Workers.h
+++ b/dom/workers/Workers.h
@@ -266,17 +266,17 @@ struct WorkerLoadInfo
   net::ReferrerPolicy mReferrerPolicy;
   bool mFromWindow;
   bool mEvalAllowed;
   bool mReportCSPViolations;
   bool mXHRParamsAllowed;
   bool mPrincipalIsSystem;
   bool mStorageAllowed;
   bool mServiceWorkersTestingInWindow;
-  PrincipalOriginAttributes mOriginAttributes;
+  OriginAttributes mOriginAttributes;
 
   WorkerLoadInfo();
   ~WorkerLoadInfo();
 
   void StealFrom(WorkerLoadInfo& aOther);
 };
 
 // All of these are implemented in RuntimeService.cpp
--- a/dom/workers/test/gtest/TestReadWrite.cpp
+++ b/dom/workers/test/gtest/TestReadWrite.cpp
@@ -234,17 +234,17 @@ TEST(ServiceWorkerRegistrar, TestWriteDa
       reg.currentWorkerHandlesFetch() = true;
       reg.cacheName() =
         NS_ConvertUTF8toUTF16(nsPrintfCString("cacheName write %d", i));
       reg.loadFlags() = nsIRequest::VALIDATE_ALWAYS;
 
       nsAutoCString spec;
       spec.AppendPrintf("spec write %d", i);
       reg.principal() =
-        mozilla::ipc::ContentPrincipalInfo(mozilla::PrincipalOriginAttributes(i, i % 2), spec);
+        mozilla::ipc::ContentPrincipalInfo(mozilla::OriginAttributes(i, i % 2), spec);
 
       swr->TestRegisterServiceWorker(reg);
     }
 
     nsresult rv = swr->TestWriteData();
     ASSERT_EQ(NS_OK, rv) << "WriteData() should not fail";
   }
 
@@ -257,17 +257,17 @@ TEST(ServiceWorkerRegistrar, TestWriteDa
   ASSERT_EQ((uint32_t)10, data.Length()) << "10 entries should be found";
 
   for (int i = 0; i < 10; ++i) {
     nsAutoCString test;
 
     ASSERT_EQ(data[i].principal().type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo);
     const mozilla::ipc::ContentPrincipalInfo& cInfo = data[i].principal();
 
-    mozilla::PrincipalOriginAttributes attrs(i, i % 2);
+    mozilla::OriginAttributes attrs(i, i % 2);
     nsAutoCString suffix, expectSuffix;
     attrs.CreateSuffix(expectSuffix);
     cInfo.attrs().CreateSuffix(suffix);
 
     ASSERT_STREQ(expectSuffix.get(), suffix.get());
 
     test.AppendPrintf("scope write %d", i);
     ASSERT_STREQ(test.get(), cInfo.spec().get());
@@ -588,17 +588,17 @@ TEST(ServiceWorkerRegistrar, TestDedupeW
       reg.currentWorkerHandlesFetch() = true;
       reg.cacheName() =
         NS_ConvertUTF8toUTF16(nsPrintfCString("cacheName write %d", i));
       reg.loadFlags() = nsIRequest::VALIDATE_ALWAYS;
 
       nsAutoCString spec;
       spec.AppendPrintf("spec write dedupe/%d", i);
       reg.principal() =
-        mozilla::ipc::ContentPrincipalInfo(mozilla::PrincipalOriginAttributes(0, false), spec);
+        mozilla::ipc::ContentPrincipalInfo(mozilla::OriginAttributes(0, false), spec);
 
       swr->TestRegisterServiceWorker(reg);
     }
 
     nsresult rv = swr->TestWriteData();
     ASSERT_EQ(NS_OK, rv) << "WriteData() should not fail";
   }
 
@@ -609,17 +609,17 @@ TEST(ServiceWorkerRegistrar, TestDedupeW
 
   // Duplicate entries should be removed.
   const nsTArray<ServiceWorkerRegistrationData>& data = swr->TestGetData();
   ASSERT_EQ((uint32_t)1, data.Length()) << "1 entry should be found";
 
   ASSERT_EQ(data[0].principal().type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo);
   const mozilla::ipc::ContentPrincipalInfo& cInfo = data[0].principal();
 
-  mozilla::PrincipalOriginAttributes attrs(0, false);
+  mozilla::OriginAttributes attrs(0, false);
   nsAutoCString suffix, expectSuffix;
   attrs.CreateSuffix(expectSuffix);
   cInfo.attrs().CreateSuffix(suffix);
 
   // Last entry passed to RegisterServiceWorkerInternal() should overwrite
   // previous values.  So expect "9" in values here.
   ASSERT_STREQ(expectSuffix.get(), suffix.get());
   ASSERT_STREQ("scope write dedupe", cInfo.spec().get());
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -1608,23 +1608,21 @@ XMLHttpRequestMainThread::Open(const nsA
   return NS_OK;
 }
 
 void
 XMLHttpRequestMainThread::SetOriginAttributes(const OriginAttributesDictionary& aAttrs)
 {
   MOZ_ASSERT((mState == State::opened) && !mFlagSend);
 
-  GenericOriginAttributes attrs(aAttrs);
-  NeckoOriginAttributes neckoAttrs;
-  neckoAttrs.SetFromGenericAttributes(attrs);
+  OriginAttributes attrs(aAttrs);
 
   nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
   MOZ_ASSERT(loadInfo);
-  loadInfo->SetOriginAttributes(neckoAttrs);
+  loadInfo->SetOriginAttributes(attrs);
 }
 
 void
 XMLHttpRequestMainThread::PopulateNetworkInterfaceId()
 {
   if (mNetworkInterfaceId.IsEmpty()) {
     return;
   }
--- a/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp
+++ b/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp
@@ -409,17 +409,17 @@ txCompileObserver::loadURI(const nsAStri
     nsCOMPtr<nsIURI> uri;
     nsresult rv = NS_NewURI(getter_AddRefs(uri), aUri);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIURI> referrerUri;
     rv = NS_NewURI(getter_AddRefs(referrerUri), aReferrerUri);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    PrincipalOriginAttributes attrs;
+    OriginAttributes attrs;
     nsCOMPtr<nsIPrincipal> referrerPrincipal =
       BasePrincipal::CreateCodebasePrincipal(referrerUri, attrs);
     NS_ENSURE_TRUE(referrerPrincipal, NS_ERROR_FAILURE);
 
     return startLoad(uri, aCompiler, referrerPrincipal, aReferrerPolicy);
 }
 
 void
@@ -614,17 +614,17 @@ txSyncCompileObserver::loadURI(const nsA
     nsresult rv = NS_NewURI(getter_AddRefs(uri), aUri);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIURI> referrerUri;
     rv = NS_NewURI(getter_AddRefs(referrerUri), aReferrerUri);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIPrincipal> referrerPrincipal =
-      BasePrincipal::CreateCodebasePrincipal(referrerUri, PrincipalOriginAttributes());
+      BasePrincipal::CreateCodebasePrincipal(referrerUri, OriginAttributes());
     NS_ENSURE_TRUE(referrerPrincipal, NS_ERROR_FAILURE);
 
     // This is probably called by js, a loadGroup for the channel doesn't
     // make sense.
     nsCOMPtr<nsINode> source;
     if (mProcessor) {
       source =
         do_QueryInterface(mProcessor->GetSourceContentModel());
--- a/embedding/browser/nsIWebBrowser.idl
+++ b/embedding/browser/nsIWebBrowser.idl
@@ -10,21 +10,21 @@ interface nsIInterfaceRequestor;
 interface nsIWebBrowserChrome;
 interface nsIURIContentListener;
 interface nsIDOMWindow;
 interface mozIDOMWindowProxy;
 interface nsIWeakReference;
 
 %{C++
 namespace mozilla {
-class DocShellOriginAttributes;
+class OriginAttributes;
 }
 %}
 
-[ref] native const_OriginAttributesRef(const mozilla::DocShellOriginAttributes);
+[ref] native const_OriginAttributesRef(const mozilla::OriginAttributes);
 
 /**
  * The nsIWebBrowser interface is implemented by web browser objects.
  * Embedders use this interface during initialisation to associate
  * the new web browser instance with the embedders chrome and
  * to register any listeners. The interface may also be used at runtime
  * to obtain the content DOM window and from that the rest of the DOM.
  */
--- a/embedding/browser/nsWebBrowser.cpp
+++ b/embedding/browser/nsWebBrowser.cpp
@@ -385,17 +385,17 @@ nsWebBrowser::SetIsActive(bool aIsActive
   // If we have a docshell, pass on the request
   if (mDocShell) {
     return mDocShell->SetIsActive(aIsActive);
   }
   return NS_OK;
 }
 
 void
-nsWebBrowser::SetOriginAttributes(const DocShellOriginAttributes& aAttrs)
+nsWebBrowser::SetOriginAttributes(const OriginAttributes& aAttrs)
 {
   mOriginAttributes = aAttrs;
 }
 
 //*****************************************************************************
 // nsWebBrowser::nsIDocShellTreeItem
 //*****************************************************************************
 
--- a/embedding/browser/nsWebBrowser.h
+++ b/embedding/browser/nsWebBrowser.h
@@ -128,17 +128,17 @@ protected:
 protected:
   RefPtr<nsDocShellTreeOwner> mDocShellTreeOwner;
   nsCOMPtr<nsIDocShell> mDocShell;
   nsCOMPtr<nsIInterfaceRequestor> mDocShellAsReq;
   nsCOMPtr<nsIBaseWindow> mDocShellAsWin;
   nsCOMPtr<nsIWebNavigation> mDocShellAsNav;
   nsCOMPtr<nsIScrollable> mDocShellAsScrollable;
   nsCOMPtr<nsITextScroll> mDocShellAsTextScroll;
-  mozilla::DocShellOriginAttributes mOriginAttributes;
+  mozilla::OriginAttributes mOriginAttributes;
 
   nsCOMPtr<nsIWidget> mInternalWidget;
   nsCOMPtr<nsIWindowWatcher> mWWatch;
   nsAutoPtr<nsWebBrowserInitInfo> mInitInfo;
   uint32_t mContentType;
   bool mActivating;
   bool mShouldEnableHistory;
   bool mIsActive;
--- a/embedding/components/windowwatcher/nsWindowWatcher.cpp
+++ b/embedding/components/windowwatcher/nsWindowWatcher.cpp
@@ -1098,18 +1098,18 @@ nsWindowWatcher::OpenWindowInternal(mozI
   if (windowIsNew) {
     auto* docShell = static_cast<nsDocShell*>(newDocShell.get());
 
     // If this is not a chrome docShell, we apply originAttributes from the
     // subjectPrincipal unless if it's an expanded or system principal.
     if (subjectPrincipal &&
         !nsContentUtils::IsSystemOrExpandedPrincipal(subjectPrincipal) &&
         docShell->ItemType() != nsIDocShellTreeItem::typeChrome) {
-      DocShellOriginAttributes attrs;
-      attrs.InheritFromDocToChildDocShell(subjectPrincipal->OriginAttributesRef());
+      OriginAttributes attrs;
+      attrs.Inherit(subjectPrincipal->OriginAttributesRef());
       isPrivateBrowsingWindow = !!attrs.mPrivateBrowsingId;
       docShell->SetOriginAttributes(attrs);
     } else {
       nsCOMPtr<nsIDocShellTreeItem> parentItem;
       GetWindowTreeItem(aParent, getter_AddRefs(parentItem));
       nsCOMPtr<nsILoadContext> parentContext = do_QueryInterface(parentItem);
       if (parentContext) {
         isPrivateBrowsingWindow = parentContext->UsePrivateBrowsing();
--- a/extensions/cookie/nsPermission.cpp
+++ b/extensions/cookie/nsPermission.cpp
@@ -105,18 +105,18 @@ nsPermission::Matches(nsIPrincipal* aPri
 
   // If we are matching with an exact host, we're done now - the permissions don't match
   // otherwise, we need to start comparing subdomains!
   if (aExactHost) {
       return NS_OK;
   }
 
   // Compare their OriginAttributes
-  const mozilla::PrincipalOriginAttributes& theirAttrs = principal->OriginAttributesRef();
-  const mozilla::PrincipalOriginAttributes& ourAttrs = mPrincipal->OriginAttributesRef();
+  const mozilla::OriginAttributes& theirAttrs = principal->OriginAttributesRef();
+  const mozilla::OriginAttributes& ourAttrs = mPrincipal->OriginAttributesRef();
 
   if (theirAttrs != ourAttrs) {
       return NS_OK;
   }
 
   nsCOMPtr<nsIURI> theirURI;
   nsresult rv = principal->GetURI(getter_AddRefs(theirURI));
   NS_ENSURE_SUCCESS(rv, rv);
@@ -188,14 +188,14 @@ nsPermission::Matches(nsIPrincipal* aPri
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPermission::MatchesURI(nsIURI* aURI, bool aExactHost, bool* aMatches)
 {
   NS_ENSURE_ARG_POINTER(aURI);
 
-  mozilla::PrincipalOriginAttributes attrs;
+  mozilla::OriginAttributes attrs;
   nsCOMPtr<nsIPrincipal> principal = mozilla::BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
   NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
 
   return Matches(principal, aExactHost, aMatches);
 }
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -106,69 +106,71 @@ GetOriginFromPrincipal(nsIPrincipal* aPr
 {
   nsresult rv = aPrincipal->GetOriginNoSuffix(aOrigin);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString suffix;
   rv = aPrincipal->GetOriginSuffix(suffix);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  mozilla::PrincipalOriginAttributes attrs;
+  mozilla::OriginAttributes attrs;
   if (!attrs.PopulateFromSuffix(suffix)) {
     return NS_ERROR_FAILURE;
   }
 
   // mPrivateBrowsingId must be set to false because PermissionManager is not supposed to have
   // any knowledge of private browsing. Allowing it to be true changes the suffix being hashed.
   attrs.mPrivateBrowsingId = 0;
 
   // Disable userContext and firstParty isolation for permissions.
-  attrs.StripUserContextIdAndFirstPartyDomain();
+  attrs.StripAttributes(mozilla::OriginAttributes::STRIP_USER_CONTEXT_ID |
+                        mozilla::OriginAttributes::STRIP_FIRST_PARTY_DOMAIN);
 
   attrs.CreateSuffix(suffix);
   aOrigin.Append(suffix);
   return NS_OK;
 }
 
 nsresult
 GetPrincipalFromOrigin(const nsACString& aOrigin, nsIPrincipal** aPrincipal)
 {
   nsAutoCString originNoSuffix;
-  mozilla::PrincipalOriginAttributes attrs;
+  mozilla::OriginAttributes attrs;
   if (!attrs.PopulateFromOrigin(aOrigin, originNoSuffix)) {
     return NS_ERROR_FAILURE;
   }
 
   // Disable userContext and firstParty isolation for permissions.
-  attrs.StripUserContextIdAndFirstPartyDomain();
+  attrs.StripAttributes(mozilla::OriginAttributes::STRIP_USER_CONTEXT_ID |
+                        mozilla::OriginAttributes::STRIP_FIRST_PARTY_DOMAIN);
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = NS_NewURI(getter_AddRefs(uri), originNoSuffix);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIPrincipal> principal = mozilla::BasePrincipal::CreateCodebasePrincipal(uri, attrs);
   principal.forget(aPrincipal);
   return NS_OK;
 }
 
 nsresult
 GetPrincipal(nsIURI* aURI, uint32_t aAppId, bool aIsInIsolatedMozBrowserElement, nsIPrincipal** aPrincipal)
 {
-  mozilla::PrincipalOriginAttributes attrs(aAppId, aIsInIsolatedMozBrowserElement);
+  mozilla::OriginAttributes attrs(aAppId, aIsInIsolatedMozBrowserElement);
   nsCOMPtr<nsIPrincipal> principal = mozilla::BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
   NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
 
   principal.forget(aPrincipal);
   return NS_OK;
 }
 
 nsresult
 GetPrincipal(nsIURI* aURI, nsIPrincipal** aPrincipal)
 {
-  mozilla::PrincipalOriginAttributes attrs;
+  mozilla::OriginAttributes attrs;
   nsCOMPtr<nsIPrincipal> principal = mozilla::BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
   NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
 
   principal.forget(aPrincipal);
   return NS_OK;
 }
 
 nsCString
@@ -2203,20 +2205,21 @@ nsPermissionManager::GetPermissionHashKe
     }
 
     rv = newURI->SetHost(domain);
     if (NS_FAILED(rv)) {
       return nullptr;
     }
 
     // Copy the attributes over
-    mozilla::PrincipalOriginAttributes attrs = aPrincipal->OriginAttributesRef();
+    mozilla::OriginAttributes attrs = aPrincipal->OriginAttributesRef();
 
     // Disable userContext and firstParty isolation for permissions.
-    attrs.StripUserContextIdAndFirstPartyDomain();
+    attrs.StripAttributes(mozilla::OriginAttributes::STRIP_USER_CONTEXT_ID |
+                          mozilla::OriginAttributes::STRIP_FIRST_PARTY_DOMAIN);
 
     nsCOMPtr<nsIPrincipal> principal =
       mozilla::BasePrincipal::CreateCodebasePrincipal(newURI, attrs);
 
     return GetPermissionHashKey(principal, aType, aExactHostMatch);
   }
 
   // No entry, really...
--- a/image/ImageCacheKey.cpp
+++ b/image/ImageCacheKey.cpp
@@ -41,17 +41,17 @@ BlobSerial(ImageURL* aURI)
       blob) {
     return Some(blob->GetSerialNumber());
   }
 
   return Nothing();
 }
 
 ImageCacheKey::ImageCacheKey(nsIURI* aURI,
-                             const PrincipalOriginAttributes& aAttrs,
+                             const OriginAttributes& aAttrs,
                              nsIDocument* aDocument,
                              nsresult& aRv)
   : mURI(new ImageURL(aURI, aRv))
   , mOriginAttributes(aAttrs)
   , mControlledDocument(GetControlledDocumentToken(aDocument))
   , mIsChrome(URISchemeIs(mURI, "chrome"))
 {
   NS_ENSURE_SUCCESS_VOID(aRv);
@@ -61,17 +61,17 @@ ImageCacheKey::ImageCacheKey(nsIURI* aUR
   if (URISchemeIs(mURI, "blob")) {
     mBlobSerial = BlobSerial(mURI);
   }
 
   mHash = ComputeHash(mURI, mBlobSerial, mOriginAttributes, mControlledDocument);
 }
 
 ImageCacheKey::ImageCacheKey(ImageURL* aURI,
-                             const PrincipalOriginAttributes& aAttrs,
+                             const OriginAttributes& aAttrs,
                              nsIDocument* aDocument)
   : mURI(aURI)
   , mOriginAttributes(aAttrs)
   , mControlledDocument(GetControlledDocumentToken(aDocument))
   , mIsChrome(URISchemeIs(mURI, "chrome"))
 {
   MOZ_ASSERT(aURI);
 
@@ -126,17 +126,17 @@ const char*
 ImageCacheKey::Spec() const
 {
   return mURI->Spec();
 }
 
 /* static */ uint32_t
 ImageCacheKey::ComputeHash(ImageURL* aURI,
                            const Maybe<uint64_t>& aBlobSerial,
-                           const PrincipalOriginAttributes& aAttrs,
+                           const OriginAttributes& aAttrs,
                            void* aControlledDocument)
 {
   // Since we frequently call Hash() several times in a row on the same
   // ImageCacheKey, as an optimization we compute our hash once and store it.
 
   nsPrintfCString ptr("%p", aControlledDocument);
   nsAutoCString suffix;
   aAttrs.CreateSuffix(suffix);
--- a/image/ImageCacheKey.h
+++ b/image/ImageCacheKey.h
@@ -28,19 +28,19 @@ class ImageURL;
  * We key the cache on the initial URI (before any redirects), with some
  * canonicalization applied. See ComputeHash() for the details.
  * Controlled documents do not share their cache entries with
  * non-controlled documents, or other controlled documents.
  */
 class ImageCacheKey final
 {
 public:
-  ImageCacheKey(nsIURI* aURI, const PrincipalOriginAttributes& aAttrs,
+  ImageCacheKey(nsIURI* aURI, const OriginAttributes& aAttrs,
                 nsIDocument* aDocument, nsresult& aRv);
-  ImageCacheKey(ImageURL* aURI, const PrincipalOriginAttributes& aAttrs,
+  ImageCacheKey(ImageURL* aURI, const OriginAttributes& aAttrs,
                 nsIDocument* aDocument);
 
   ImageCacheKey(const ImageCacheKey& aOther);
   ImageCacheKey(ImageCacheKey&& aOther);
 
   bool operator==(const ImageCacheKey& aOther) const;
   uint32_t Hash() const { return mHash; }
 
@@ -52,23 +52,23 @@ public:
 
   /// A token indicating which service worker controlled document this entry
   /// belongs to, if any.
   void* ControlledDocument() const { return mControlledDocument; }
 
 private:
   static uint32_t ComputeHash(ImageURL* aURI,
                               const Maybe<uint64_t>& aBlobSerial,
-                              const PrincipalOriginAttributes& aAttrs,
+                              const OriginAttributes& aAttrs,
                               void* aControlledDocument);
   static void* GetControlledDocumentToken(nsIDocument* aDocument);
 
   RefPtr<ImageURL> mURI;
   Maybe<uint64_t> mBlobSerial;
-  PrincipalOriginAttributes mOriginAttributes;
+  OriginAttributes mOriginAttributes;
   void* mControlledDocument;
   uint32_t mHash;
   bool mIsChrome;
 };
 
 } // namespace image
 } // namespace mozilla
 
--- a/image/imgLoader.cpp
+++ b/image/imgLoader.cpp
@@ -747,21 +747,21 @@ NewImageChannel(nsIChannel** aResult,
     if (NS_FAILED(rv)) {
       return rv;
     }
 
     if (aPolicyType == nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON) {
       // If this is a favicon loading, we will use the originAttributes from the
       // loadingPrincipal as the channel's originAttributes. This allows the favicon
       // loading from XUL will use the correct originAttributes.
-      NeckoOriginAttributes neckoAttrs;
-      neckoAttrs.InheritFromDocToNecko(aLoadingPrincipal->OriginAttributesRef());
+      OriginAttributes attrs;
+      attrs.Inherit(aLoadingPrincipal->OriginAttributesRef());
 
       nsCOMPtr<nsILoadInfo> loadInfo = (*aResult)->GetLoadInfo();
-      rv = loadInfo->SetOriginAttributes(neckoAttrs);
+      rv = loadInfo->SetOriginAttributes(attrs);
     }
   } else {
     // either we are loading something inside a document, in which case
     // we should always have a requestingNode, or we are loading something
     // outside a document, in which case the loadingPrincipal and
     // triggeringPrincipal should always be the systemPrincipal.
     // However, there are exceptions: one is Notifications which create a
     // channel in the parent prcoess in which case we can't get a requestingNode.
@@ -776,24 +776,24 @@ NewImageChannel(nsIChannel** aResult,
 
     if (NS_FAILED(rv)) {
       return rv;
     }
 
     // Use the OriginAttributes from the loading principal, if one is available,
     // and adjust the private browsing ID based on what kind of load the caller
     // has asked us to perform.
-    NeckoOriginAttributes neckoAttrs;
+    OriginAttributes attrs;
     if (aLoadingPrincipal) {
-      neckoAttrs.InheritFromDocToNecko(aLoadingPrincipal->OriginAttributesRef());
+      attrs.Inherit(aLoadingPrincipal->OriginAttributesRef());
     }
-    neckoAttrs.mPrivateBrowsingId = aRespectPrivacy ? 1 : 0;
+    attrs.mPrivateBrowsingId = aRespectPrivacy ? 1 : 0;
 
     nsCOMPtr<nsILoadInfo> loadInfo = (*aResult)->GetLoadInfo();
-    rv = loadInfo->SetOriginAttributes(neckoAttrs);
+    rv = loadInfo->SetOriginAttributes(attrs);
   }
 
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   // only inherit if we have a principal
   *aForcePrincipalCheckForCacheEntry =
@@ -1343,17 +1343,17 @@ NS_IMETHODIMP
 imgLoader::FindEntryProperties(nsIURI* uri,
                                nsIDOMDocument* aDOMDoc,
                                nsIProperties** _retval)
 {
   *_retval = nullptr;
 
   nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDOMDoc);
 
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   if (doc) {
     nsCOMPtr<nsIPrincipal> principal = doc->NodePrincipal();
     if (principal) {
       attrs = principal->OriginAttributesRef();
     }
   }
 
   nsresult rv;
@@ -2106,17 +2106,17 @@ imgLoader::LoadImage(nsIURI* aURI,
   }
 
   RefPtr<imgCacheEntry> entry;
 
   // Look in the cache for our URI, and then validate it.
   // XXX For now ignore aCacheKey. We will need it in the future
   // for correctly dealing with image load requests that are a result
   // of post data.
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   if (aLoadingPrincipal) {
     attrs = aLoadingPrincipal->OriginAttributesRef();
   }
   ImageCacheKey key(aURI, attrs, aLoadingDocument, rv);
   NS_ENSURE_SUCCESS(rv, rv);
   imgCacheTable& cache = GetCache(key);
 
   if (cache.Get(key, getter_AddRefs(entry)) && entry) {
@@ -2318,19 +2318,19 @@ imgLoader::LoadImageWithChannel(nsIChann
 
   nsCOMPtr<nsIURI> uri;
   channel->GetURI(getter_AddRefs(uri));
   nsCOMPtr<nsIDocument> doc = do_QueryInterface(aCX);
 
   NS_ENSURE_TRUE(channel, NS_ERROR_FAILURE);
   nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
 
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   if (loadInfo) {
-    attrs.InheritFromNecko(loadInfo->GetOriginAttributes());
+    attrs.Inherit(loadInfo->GetOriginAttributes());
   }
 
   nsresult rv;
   ImageCacheKey key(uri, attrs, doc, rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsLoadFlags requestFlags = nsIRequest::LOAD_NORMAL;
   channel->GetLoadFlags(&requestFlags);
--- a/ipc/glue/BackgroundUtils.cpp
+++ b/ipc/glue/BackgroundUtils.cpp
@@ -78,17 +78,17 @@ PrincipalInfoToPrincipal(const Principal
         aPrincipalInfo.get_ContentPrincipalInfo();
 
       nsCOMPtr<nsIURI> uri;
       rv = NS_NewURI(getter_AddRefs(uri), info.spec());
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return nullptr;
       }
 
-      PrincipalOriginAttributes attrs;
+      OriginAttributes attrs;
       if (info.attrs().mAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID) {
         attrs = info.attrs();
       }
       principal = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
       rv = principal ? NS_OK : NS_ERROR_FAILURE;
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return nullptr;
       }
--- a/ipc/glue/BackgroundUtils.h
+++ b/ipc/glue/BackgroundUtils.h
@@ -36,30 +36,18 @@ struct OriginAttributesParamTraits
     nsAutoCString suffix;
     return ReadParam(aMsg, aIter, &suffix) &&
            aResult->PopulateFromSuffix(suffix);
   }
 };
 } // namespace detail
 
 template<>
-struct ParamTraits<mozilla::PrincipalOriginAttributes>
-  : public detail::OriginAttributesParamTraits<mozilla::PrincipalOriginAttributes> {};
-
-template<>
-struct ParamTraits<mozilla::DocShellOriginAttributes>
-  : public detail::OriginAttributesParamTraits<mozilla::DocShellOriginAttributes> {};
-
-template<>
-struct ParamTraits<mozilla::NeckoOriginAttributes>
-  : public detail::OriginAttributesParamTraits<mozilla::NeckoOriginAttributes> {};
-
-template<>
-struct ParamTraits<mozilla::GenericOriginAttributes>
-  : public detail::OriginAttributesParamTraits<mozilla::GenericOriginAttributes> {};
+struct ParamTraits<mozilla::OriginAttributes>
+  : public detail::OriginAttributesParamTraits<mozilla::OriginAttributes> {};
 
 } // namespace IPC
 
 namespace mozilla {
 namespace net {
 class OptionalLoadInfoArgs;
 } // namespace net
 
--- a/ipc/glue/PBackgroundSharedTypes.ipdlh
+++ b/ipc/glue/PBackgroundSharedTypes.ipdlh
@@ -1,36 +1,36 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-using mozilla::PrincipalOriginAttributes from "mozilla/ipc/BackgroundUtils.h";
+using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
 using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
 
 namespace mozilla {
 namespace ipc {
 
 struct ContentPrincipalInfo
 {
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   nsCString spec;
 };
 
 struct SystemPrincipalInfo
 { };
 
 struct NullPrincipalInfo
 {
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   nsCString spec;
 };
 
 struct ExpandedPrincipalInfo
 {
-  PrincipalOriginAttributes attrs;
+  OriginAttributes attrs;
   PrincipalInfo[] whitelist;
 };
 
 union PrincipalInfo
 {
   ContentPrincipalInfo;
   SystemPrincipalInfo;
   NullPrincipalInfo;
--- a/js/src/builtin/Array.js
+++ b/js/src/builtin/Array.js
@@ -729,19 +729,25 @@ function ArrayIteratorNext() {
     // Step 6.
     // The index might not be an integer, so we have to do a generic get here.
     var index = UnsafeGetReservedSlot(this, ITERATOR_SLOT_NEXT_INDEX);
 
     // Step 7.
     var itemKind = UnsafeGetInt32FromReservedSlot(this, ITERATOR_SLOT_ITEM_KIND);
 
     // Step 8-9.
-    var len = IsPossiblyWrappedTypedArray(a)
-              ? PossiblyWrappedTypedArrayLength(a)
-              : ToLength(a.length);
+    var len;
+    if (IsPossiblyWrappedTypedArray(a)) {
+        if (PossiblyWrappedTypedArrayHasDetachedBuffer(a))
+            ThrowTypeError(JSMSG_TYPED_ARRAY_DETACHED);
+
+        len = PossiblyWrappedTypedArrayLength(a);
+    } else {
+        len = ToLength(a.length);
+    }
 
     // Step 10.
     if (index >= len) {
         UnsafeSetReservedSlot(this, ITERATOR_SLOT_TARGET, null);
         result.done = true;
         return result;
     }
 
--- a/js/src/jit-test/tests/asm.js/testBug1301191.js
+++ b/js/src/jit-test/tests/asm.js/testBug1301191.js
@@ -9,13 +9,16 @@ timeout(1);
             ff()
         }
         return f
     })(this, {
         ff: arguments.callee
     })
 })()
 function m(f) {
+    var i = 0;
     while (true) {
         f();
+        if ((i++ % 1000) === 0)
+            gc();
     }
 }
 m(g);
--- a/js/src/jit-test/tests/asm.js/testBug975182.js
+++ b/js/src/jit-test/tests/asm.js/testBug975182.js
@@ -8,11 +8,13 @@ Function("\
         return f\
     })(this, {\
         ff: arguments.callee\
     }, new ArrayBuffer(4096))\
 ")()
 function m(f) {
     for (var j = 0; j < 6000; ++j) {
         f();
+        if ((j % 1000) === 0)
+            gc();
     }
 }
 m(g);
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/bug1323854-2.js
@@ -0,0 +1,14 @@
+// |jit-test| --ion-gvn=off;
+
+try  {
+    var g = newGlobal();
+    var dbg = new Debugger(g);
+    dbg.onExceptionUnwind = function(m) {
+        do {
+            m = m.older;
+        } while (m != null);
+    };
+    g.eval("try { throw (function() {});} finally {}");
+} catch(e) {
+
+}
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/ion/bug1323854.js
@@ -0,0 +1,15 @@
+
+g = (function () {
+    "use asm";
+    function f(i0, d1) {
+        d1 = 4258326539 >>> 0;
+        switch (-8 && i0) {
+            case -1:
+                d1 = 0;
+            case 0:
+        }
+    }
+    return f;
+})();
+g();
+g();
--- a/js/src/jit/BaselineIC.cpp
+++ b/js/src/jit/BaselineIC.cpp
@@ -4626,16 +4626,22 @@ ICCallStubCompiler::guardFunApply(MacroA
         // Ensure that the second arg is magic arguments.
         masm.branchTestMagic(Assembler::NotEqual, secondArgSlot, failure);
 
         // Ensure that this frame doesn't have an arguments object.
         masm.branchTest32(Assembler::NonZero,
                           Address(BaselineFrameReg, BaselineFrame::reverseOffsetOfFlags()),
                           Imm32(BaselineFrame::HAS_ARGS_OBJ),
                           failure);
+
+        // Limit the length to something reasonable.
+        masm.branch32(Assembler::Above,
+                      Address(BaselineFrameReg, BaselineFrame::offsetOfNumActualArgs()),
+                      Imm32(ICCall_ScriptedApplyArray::MAX_ARGS_ARRAY_LENGTH),
+                      failure);
     } else {
         MOZ_ASSERT(applyThing == FunApply_Array);
 
         AllocatableGeneralRegisterSet regsx = regs;
 
         // Ensure that the second arg is an array.
         ValueOperand secondArgVal = regsx.takeAnyValue();
         masm.loadValue(secondArgSlot, secondArgVal);
--- a/js/src/jit/ExecutableAllocator.cpp
+++ b/js/src/jit/ExecutableAllocator.cpp
@@ -22,16 +22,18 @@
  * 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.
  */
 
 #include "jit/ExecutableAllocator.h"
 
+#include "mozilla/Atomics.h"
+
 #include "jit/JitCompartment.h"
 #include "js/MemoryMetrics.h"
 
 #ifdef __APPLE__
 #include <TargetConditionals.h>
 #endif
 
 using namespace js::jit;
@@ -231,18 +233,18 @@ ExecutableAllocator::createPool(size_t n
 
     ExecutablePool* pool = js_new<ExecutablePool>(this, a);
     if (!pool) {
         systemRelease(a);
         return nullptr;
     }
 
     if (!m_pools.put(pool)) {
+        // Note: this will call |systemRelease(a)|.
         js_delete(pool);
-        systemRelease(a);
         return nullptr;
     }
 
     return pool;
 }
 
 void*
 ExecutableAllocator::alloc(size_t n, ExecutablePool** poolp, CodeKind type)
@@ -402,8 +404,52 @@ ExecutableAllocator::poisonCode(JSRuntim
         ExecutablePool* pool = ranges[i].pool;
         if (pool->isMarked()) {
             reprotectPool(rt, pool, Executable);
             pool->unmark();
         }
         pool->release();
     }
 }
+
+// Limit on the number of bytes of executable memory to prevent JIT spraying
+// attacks.
+#if JS_BITS_PER_WORD == 32
+static const size_t MaxCodeBytesPerProcess = 128 * 1024 * 1024;
+#else
+static const size_t MaxCodeBytesPerProcess = 512 * 1024 * 1024;
+#endif
+
+static mozilla::Atomic<size_t> allocatedExecutableBytes(0);
+
+bool
+js::jit::AddAllocatedExecutableBytes(size_t bytes)
+{
+    MOZ_ASSERT(allocatedExecutableBytes <= MaxCodeBytesPerProcess);
+
+    // Multiple threads can call this concurrently. We use compareExchange to
+    // ensure allocatedExecutableBytes is always <= MaxCodeBytesPerProcess.
+    while (true) {
+        size_t bytesOld = allocatedExecutableBytes;
+        size_t bytesNew = bytesOld + bytes;
+
+        if (bytesNew > MaxCodeBytesPerProcess)
+            return false;
+
+        if (allocatedExecutableBytes.compareExchange(bytesOld, bytesNew))
+            return true;
+    }
+
+    MOZ_CRASH();
+}
+
+void
+js::jit::SubAllocatedExecutableBytes(size_t bytes)
+{
+    MOZ_ASSERT(bytes <= allocatedExecutableBytes);
+    allocatedExecutableBytes -= bytes;
+}
+
+void
+js::jit::AssertAllocatedExecutableBytesIsZero()
+{
+    MOZ_ASSERT(allocatedExecutableBytes == 0);
+}
--- a/js/src/jit/ExecutableAllocator.h
+++ b/js/src/jit/ExecutableAllocator.h
@@ -159,19 +159,16 @@ struct JitPoisonRange
 };
 
 typedef Vector<JitPoisonRange, 0, SystemAllocPolicy> JitPoisonRangeVector;
 
 #define NON_WRITABLE_JIT_CODE 1
 
 class ExecutableAllocator
 {
-#ifdef XP_WIN
-    mozilla::Maybe<mozilla::non_crypto::XorShift128PlusRNG> randomNumberGenerator;
-#endif
     JSRuntime* rt_;
 
   public:
     enum ProtectionSetting { Writable, Executable };
 
     explicit ExecutableAllocator(JSRuntime* rt);
     ~ExecutableAllocator();
 
@@ -194,17 +191,16 @@ class ExecutableAllocator
 
     static const size_t OVERSIZE_ALLOCATION = size_t(-1);
 
     static size_t roundUpAllocationSize(size_t request, size_t granularity);
 
     // On OOM, this will return an Allocation where pages is nullptr.
     ExecutablePool::Allocation systemAlloc(size_t n);
     static void systemRelease(const ExecutablePool::Allocation& alloc);
-    void* computeRandomAllocationAddress();
 
     ExecutablePool* createPool(size_t n);
     ExecutablePool* poolForSize(size_t n);
 
     static void reprotectPool(JSRuntime* rt, ExecutablePool* pool, ProtectionSetting protection);
 
   public:
     MOZ_MUST_USE
@@ -333,18 +329,31 @@ class ExecutableAllocator
     typedef js::HashSet<ExecutablePool*, js::DefaultHasher<ExecutablePool*>, js::SystemAllocPolicy>
             ExecPoolHashSet;
     ExecPoolHashSet m_pools;    // All pools, just for stats purposes.
 
     static size_t determinePageSize();
 };
 
 extern void*
-AllocateExecutableMemory(void* addr, size_t bytes, unsigned permissions, const char* tag,
+AllocateExecutableMemory(size_t bytes, unsigned permissions, const char* tag,
                          size_t pageSize);
 
 extern void
 DeallocateExecutableMemory(void* addr, size_t bytes, size_t pageSize);
 
+// These functions are called by the platform-specific definitions of
+// (Allocate|Deallocate)ExecutableMemory and should not otherwise be
+// called directly.
+
+extern MOZ_MUST_USE bool
+AddAllocatedExecutableBytes(size_t bytes);
+
+extern void
+SubAllocatedExecutableBytes(size_t bytes);
+
+extern void
+AssertAllocatedExecutableBytesIsZero();
+
 } // namespace jit
 } // namespace js
 
 #endif /* jit_ExecutableAllocator_h */
--- a/js/src/jit/ExecutableAllocatorPosix.cpp
+++ b/js/src/jit/ExecutableAllocatorPosix.cpp
@@ -21,16 +21,17 @@
  * 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.
  */
 
 #include "mozilla/DebugOnly.h"
+#include "mozilla/ScopeExit.h"
 #include "mozilla/TaggedAnonymousMemory.h"
 
 #include <errno.h>
 #include <sys/mman.h>
 #include <unistd.h>
 
 #include "jit/ExecutableAllocator.h"
 #include "js/Utility.h"
@@ -39,36 +40,49 @@ using namespace js::jit;
 
 size_t
 ExecutableAllocator::determinePageSize()
 {
     return getpagesize();
 }
 
 void*
-js::jit::AllocateExecutableMemory(void* addr, size_t bytes, unsigned permissions, const char* tag,
+js::jit::AllocateExecutableMemory(size_t bytes, unsigned permissions, const char* tag,
                                   size_t pageSize)
 {
     MOZ_ASSERT(bytes % pageSize == 0);
-    void* p = MozTaggedAnonymousMmap(addr, bytes, permissions, MAP_PRIVATE | MAP_ANON, -1, 0, tag);
-    return p == MAP_FAILED ? nullptr : p;
+
+    if (!AddAllocatedExecutableBytes(bytes))
+        return nullptr;
+
+    auto autoSubtract = mozilla::MakeScopeExit([&] { SubAllocatedExecutableBytes(bytes); });
+
+    void* p = MozTaggedAnonymousMmap(nullptr, bytes, permissions, MAP_PRIVATE | MAP_ANON, -1, 0,
+                                     tag);
+    if (p == MAP_FAILED)
+        return nullptr;
+
+    autoSubtract.release();
+    return p;
 }
 
 void
 js::jit::DeallocateExecutableMemory(void* addr, size_t bytes, size_t pageSize)
 {
     MOZ_ASSERT(bytes % pageSize == 0);
     mozilla::DebugOnly<int> result = munmap(addr, bytes);
     MOZ_ASSERT(!result || errno == ENOMEM);
+
+    SubAllocatedExecutableBytes(bytes);
 }
 
 ExecutablePool::Allocation
 ExecutableAllocator::systemAlloc(size_t n)
 {
-    void* allocation = AllocateExecutableMemory(nullptr, n, initialProtectionFlags(Executable),
+    void* allocation = AllocateExecutableMemory(n, initialProtectionFlags(Executable),
                                                 "js-jit-code", pageSize);
     ExecutablePool::Allocation alloc = { reinterpret_cast<char*>(allocation), n };
     return alloc;
 }