summaryrefslogtreecommitdiffstats
path: root/layout/reftests/bidi
diff options
context:
space:
mode:
Diffstat (limited to 'layout/reftests/bidi')
-rw-r--r--layout/reftests/bidi/1067268-1-ref.html25
-rw-r--r--layout/reftests/bidi/1067268-1.html32
-rw-r--r--layout/reftests/bidi/1069941-inline-bidi-border-1-ref.html15
-rw-r--r--layout/reftests/bidi/1069941-inline-bidi-border-1.html15
-rw-r--r--layout/reftests/bidi/1069941-inline-bidi-margin-1-ref.html20
-rw-r--r--layout/reftests/bidi/1069941-inline-bidi-margin-1.html20
-rw-r--r--layout/reftests/bidi/1155359-1-ref.xul4
-rw-r--r--layout/reftests/bidi/1155359-1.xul4
-rw-r--r--layout/reftests/bidi/1157726-1-ref.html24
-rw-r--r--layout/reftests/bidi/1157726-1.html24
-rw-r--r--layout/reftests/bidi/115921-1-ref.html14
-rw-r--r--layout/reftests/bidi/115921-1.html14
-rw-r--r--layout/reftests/bidi/115921-2-ref.html14
-rw-r--r--layout/reftests/bidi/115921-2.html14
-rw-r--r--layout/reftests/bidi/1161752-1-embed.html34
-rw-r--r--layout/reftests/bidi/1161752-2-embed.html34
-rw-r--r--layout/reftests/bidi/1161752-3-embed.html32
-rw-r--r--layout/reftests/bidi/1161752-4-embed.html34
-rw-r--r--layout/reftests/bidi/1161752-5-embed-ref.html30
-rw-r--r--layout/reftests/bidi/1161752-5-embed.html34
-rw-r--r--layout/reftests/bidi/1161752-ref.html35
-rw-r--r--layout/reftests/bidi/1161752.html73
-rw-r--r--layout/reftests/bidi/1217833-1-ref.html16
-rw-r--r--layout/reftests/bidi/1217833-1.html18
-rw-r--r--layout/reftests/bidi/1217833-2-ref.html21
-rw-r--r--layout/reftests/bidi/1217833-2.html23
-rw-r--r--layout/reftests/bidi/1231175-1-ref.html17
-rw-r--r--layout/reftests/bidi/1231175-1.html17
-rw-r--r--layout/reftests/bidi/151407-1-ref.html15
-rw-r--r--layout/reftests/bidi/151407-1.html25
-rw-r--r--layout/reftests/bidi/151407-1a.html31
-rw-r--r--layout/reftests/bidi/151407-2-auto-ref.html10
-rw-r--r--layout/reftests/bidi/151407-2-auto.html16
-rw-r--r--layout/reftests/bidi/151407-2-empty-ref.html10
-rw-r--r--layout/reftests/bidi/151407-2-empty.html16
-rw-r--r--layout/reftests/bidi/151407-2-foopy.html16
-rw-r--r--layout/reftests/bidi/151407-2-ltr-ref.html10
-rw-r--r--layout/reftests/bidi/151407-2-ltr.html16
-rw-r--r--layout/reftests/bidi/151407-2-rtl-ref.html10
-rw-r--r--layout/reftests/bidi/151407-2-rtl.html16
-rw-r--r--layout/reftests/bidi/151407-3-auto-ref.html10
-rw-r--r--layout/reftests/bidi/151407-3-auto.html17
-rw-r--r--layout/reftests/bidi/151407-3-empty-ref.html10
-rw-r--r--layout/reftests/bidi/151407-3-foopy.html17
-rw-r--r--layout/reftests/bidi/151407-3-ltr-ref.html10
-rw-r--r--layout/reftests/bidi/151407-3-ltr.html17
-rw-r--r--layout/reftests/bidi/151407-3-rtl-ref.html10
-rw-r--r--layout/reftests/bidi/151407-3-rtl.html17
-rw-r--r--layout/reftests/bidi/229367-1-ref.html10
-rw-r--r--layout/reftests/bidi/229367-1.html10
-rw-r--r--layout/reftests/bidi/229367-2-ref.html43
-rw-r--r--layout/reftests/bidi/229367-2.html43
-rw-r--r--layout/reftests/bidi/229367-3-ref.html35
-rw-r--r--layout/reftests/bidi/229367-3.html30
-rw-r--r--layout/reftests/bidi/258928-1-ref.html50
-rw-r--r--layout/reftests/bidi/258928-1.html52
-rw-r--r--layout/reftests/bidi/263359-1-ref.html11
-rw-r--r--layout/reftests/bidi/263359-1.html12
-rw-r--r--layout/reftests/bidi/263359-1a.html20
-rw-r--r--layout/reftests/bidi/263359-1b.html20
-rw-r--r--layout/reftests/bidi/263359-2-ref.html47
-rw-r--r--layout/reftests/bidi/263359-2.html46
-rw-r--r--layout/reftests/bidi/263359-3-ref.html35
-rw-r--r--layout/reftests/bidi/263359-3.html36
-rw-r--r--layout/reftests/bidi/263359-4-ref.html16
-rw-r--r--layout/reftests/bidi/263359-4.html24
-rw-r--r--layout/reftests/bidi/267459-1-ref.html24
-rw-r--r--layout/reftests/bidi/267459-1.html30
-rw-r--r--layout/reftests/bidi/267459-2-ref.html24
-rw-r--r--layout/reftests/bidi/267459-2.html24
-rw-r--r--layout/reftests/bidi/299065-1-ref.html13
-rw-r--r--layout/reftests/bidi/299065-1.html13
-rw-r--r--layout/reftests/bidi/305643-1-ref.html17
-rw-r--r--layout/reftests/bidi/305643-1.html17
-rw-r--r--layout/reftests/bidi/332655-1-ref.html11
-rw-r--r--layout/reftests/bidi/332655-1.html16
-rw-r--r--layout/reftests/bidi/332655-2-ref.html11
-rw-r--r--layout/reftests/bidi/332655-2.html16
-rw-r--r--layout/reftests/bidi/381279-1-ref.html23
-rw-r--r--layout/reftests/bidi/381279-1.html23
-rw-r--r--layout/reftests/bidi/386339-ref.html34
-rw-r--r--layout/reftests/bidi/386339.html37
-rw-r--r--layout/reftests/bidi/409375-ref.html14
-rw-r--r--layout/reftests/bidi/409375.html14
-rw-r--r--layout/reftests/bidi/413542-1-ref.html20
-rw-r--r--layout/reftests/bidi/413542-1.html21
-rw-r--r--layout/reftests/bidi/413542-2-ref.html20
-rw-r--r--layout/reftests/bidi/413542-2.html21
-rw-r--r--layout/reftests/bidi/413928-1-ref.html58
-rw-r--r--layout/reftests/bidi/413928-1.html63
-rw-r--r--layout/reftests/bidi/413928-2-ref.html58
-rw-r--r--layout/reftests/bidi/413928-2.html63
-rw-r--r--layout/reftests/bidi/425338-1-ref.html8
-rw-r--r--layout/reftests/bidi/425338-1a.html14
-rw-r--r--layout/reftests/bidi/425338-1b.html16
-rw-r--r--layout/reftests/bidi/489517-1-ref.html11
-rw-r--r--layout/reftests/bidi/489517-1.html20
-rw-r--r--layout/reftests/bidi/489887-1-ref.html15
-rw-r--r--layout/reftests/bidi/489887-1.html15
-rw-r--r--layout/reftests/bidi/492231-1-ref.html7
-rw-r--r--layout/reftests/bidi/492231-1.html7
-rw-r--r--layout/reftests/bidi/496006-1-ref.html10
-rw-r--r--layout/reftests/bidi/496006-1.html21
-rw-r--r--layout/reftests/bidi/503269-1-ref.html16
-rw-r--r--layout/reftests/bidi/503269-1.html16
-rw-r--r--layout/reftests/bidi/503957-1-ref.html20
-rw-r--r--layout/reftests/bidi/503957-1.html24
-rw-r--r--layout/reftests/bidi/525740-1-ref.html11
-rw-r--r--layout/reftests/bidi/525740-1.html11
-rw-r--r--layout/reftests/bidi/536963-1-ref.html13
-rw-r--r--layout/reftests/bidi/536963-1.html20
-rw-r--r--layout/reftests/bidi/562169-1-ref.html31
-rw-r--r--layout/reftests/bidi/562169-1.html32
-rw-r--r--layout/reftests/bidi/562169-1a.html46
-rw-r--r--layout/reftests/bidi/562169-2-ref.html29
-rw-r--r--layout/reftests/bidi/562169-2.html30
-rw-r--r--layout/reftests/bidi/562169-2a.html36
-rw-r--r--layout/reftests/bidi/562169-3-ref.html16
-rw-r--r--layout/reftests/bidi/562169-3.html15
-rw-r--r--layout/reftests/bidi/562169-3a.html26
-rw-r--r--layout/reftests/bidi/562169-4-ref.html16
-rw-r--r--layout/reftests/bidi/562169-4.html29
-rw-r--r--layout/reftests/bidi/588739-1.html12
-rw-r--r--layout/reftests/bidi/588739-2.html12
-rw-r--r--layout/reftests/bidi/588739-3.html12
-rw-r--r--layout/reftests/bidi/588739-ref.html9
-rw-r--r--layout/reftests/bidi/612843-1-ref.html16
-rw-r--r--layout/reftests/bidi/612843-1.html16
-rw-r--r--layout/reftests/bidi/613149-1-ref.html19
-rw-r--r--layout/reftests/bidi/613149-1a.html17
-rw-r--r--layout/reftests/bidi/613149-1b.html20
-rw-r--r--layout/reftests/bidi/613149-2-ref.html9
-rw-r--r--layout/reftests/bidi/613149-2a.html12
-rw-r--r--layout/reftests/bidi/613149-2b.html18
-rw-r--r--layout/reftests/bidi/613157-1-ref.html10
-rw-r--r--layout/reftests/bidi/613157-1.html10
-rw-r--r--layout/reftests/bidi/613157-2-ref.html10
-rw-r--r--layout/reftests/bidi/613157-2.html11
-rw-r--r--layout/reftests/bidi/662288-1-ref.html22
-rw-r--r--layout/reftests/bidi/662288-1.html23
-rw-r--r--layout/reftests/bidi/670226-1-ref.html14
-rw-r--r--layout/reftests/bidi/670226-1.html20
-rw-r--r--layout/reftests/bidi/676245-1-ref.html18
-rw-r--r--layout/reftests/bidi/676245-1.html18
-rw-r--r--layout/reftests/bidi/698291-1-frame.html10
-rw-r--r--layout/reftests/bidi/698291-1-ref.html10
-rw-r--r--layout/reftests/bidi/698291-1.html18
-rw-r--r--layout/reftests/bidi/698706-1-ref.html10
-rw-r--r--layout/reftests/bidi/698706-1.html12
-rw-r--r--layout/reftests/bidi/704837-1-ref.html10
-rw-r--r--layout/reftests/bidi/704837-1.html10
-rw-r--r--layout/reftests/bidi/712600-1-ref.html36
-rw-r--r--layout/reftests/bidi/712600-1.html42
-rw-r--r--layout/reftests/bidi/712600-2-dyn.html45
-rw-r--r--layout/reftests/bidi/712600-2-ref.html33
-rw-r--r--layout/reftests/bidi/712600-2.html32
-rw-r--r--layout/reftests/bidi/712600-3-ref.html51
-rw-r--r--layout/reftests/bidi/712600-3.html63
-rw-r--r--layout/reftests/bidi/718236-1-ref.html9
-rw-r--r--layout/reftests/bidi/718236-1.html22
-rw-r--r--layout/reftests/bidi/718236-2-ref.html9
-rw-r--r--layout/reftests/bidi/718236-2.html22
-rw-r--r--layout/reftests/bidi/718236-3-ref.html9
-rw-r--r--layout/reftests/bidi/718236-3.html22
-rw-r--r--layout/reftests/bidi/726420-1-ref.html58
-rw-r--r--layout/reftests/bidi/726420-1.html58
-rw-r--r--layout/reftests/bidi/726460-1-ref.html9
-rw-r--r--layout/reftests/bidi/726460-1.html23
-rw-r--r--layout/reftests/bidi/729047-1-ref.html10
-rw-r--r--layout/reftests/bidi/729047-1.html10
-rw-r--r--layout/reftests/bidi/730562-1-ref.html12
-rw-r--r--layout/reftests/bidi/730562-1.html24
-rw-r--r--layout/reftests/bidi/746987-1-ref.html10
-rw-r--r--layout/reftests/bidi/746987-1.html15
-rw-r--r--layout/reftests/bidi/746987-2-ref.html24
-rw-r--r--layout/reftests/bidi/746987-2.html27
-rw-r--r--layout/reftests/bidi/746987-3-ref.html25
-rw-r--r--layout/reftests/bidi/746987-3.html31
-rw-r--r--layout/reftests/bidi/746987-4-ref.html24
-rw-r--r--layout/reftests/bidi/746987-4.html33
-rw-r--r--layout/reftests/bidi/779003-1-dynamic.html53
-rw-r--r--layout/reftests/bidi/779003-1-ref.html47
-rw-r--r--layout/reftests/bidi/779003-1.html44
-rw-r--r--layout/reftests/bidi/817406-1-ref.html4
-rw-r--r--layout/reftests/bidi/817406-1.html4
-rw-r--r--layout/reftests/bidi/817406-2-ref.html4
-rw-r--r--layout/reftests/bidi/817406-2.html4
-rw-r--r--layout/reftests/bidi/817406-3.html6
-rw-r--r--layout/reftests/bidi/817406-4-ref.html6
-rw-r--r--layout/reftests/bidi/817406-4.html6
-rw-r--r--layout/reftests/bidi/83958-1-ref.html23
-rw-r--r--layout/reftests/bidi/83958-1a.html24
-rw-r--r--layout/reftests/bidi/83958-1b.html32
-rw-r--r--layout/reftests/bidi/83958-1c.html32
-rw-r--r--layout/reftests/bidi/83958-2-ref.html28
-rw-r--r--layout/reftests/bidi/83958-2a.html29
-rw-r--r--layout/reftests/bidi/83958-2b.html33
-rw-r--r--layout/reftests/bidi/847242-1-ref.html15
-rw-r--r--layout/reftests/bidi/847242-1.html18
-rw-r--r--layout/reftests/bidi/869833-1-ref.xul41
-rw-r--r--layout/reftests/bidi/869833-1.xul40
-rw-r--r--layout/reftests/bidi/922530-1-ref.html13
-rw-r--r--layout/reftests/bidi/922530-1.html25
-rw-r--r--layout/reftests/bidi/922550-1-ref.html28
-rw-r--r--layout/reftests/bidi/922550-1.html26
-rw-r--r--layout/reftests/bidi/bdi-element-ref.html19
-rw-r--r--layout/reftests/bidi/bdi-element.html19
-rw-r--r--layout/reftests/bidi/bidi-000-ref.html17
-rw-r--r--layout/reftests/bidi/bidi-000.html17
-rw-r--r--layout/reftests/bidi/bidi-001-j.html16
-rw-r--r--layout/reftests/bidi/bidi-001-ref.html15
-rw-r--r--layout/reftests/bidi/bidi-001-v.html16
-rw-r--r--layout/reftests/bidi/bidi-001.html16
-rw-r--r--layout/reftests/bidi/bidi-002-ref.html15
-rw-r--r--layout/reftests/bidi/bidi-002.html16
-rw-r--r--layout/reftests/bidi/bidi-003-ref.html15
-rw-r--r--layout/reftests/bidi/bidi-003.html17
-rw-r--r--layout/reftests/bidi/bidi-004-j.html17
-rw-r--r--layout/reftests/bidi/bidi-004-ref.html16
-rw-r--r--layout/reftests/bidi/bidi-004.html17
-rw-r--r--layout/reftests/bidi/bidi-005-ref.html15
-rw-r--r--layout/reftests/bidi/bidi-005.html16
-rw-r--r--layout/reftests/bidi/bidi-006-j.html49
-rw-r--r--layout/reftests/bidi/bidi-006-ref.html41
-rw-r--r--layout/reftests/bidi/bidi-006.html48
-rw-r--r--layout/reftests/bidi/bidiMirroring-ref.svg8
-rw-r--r--layout/reftests/bidi/bidiMirroring.js407
-rw-r--r--layout/reftests/bidi/bidiMirroring.svg22
-rw-r--r--layout/reftests/bidi/bidiSVG-01-ref.svg3
-rw-r--r--layout/reftests/bidi/bidiSVG-01.svg3
-rw-r--r--layout/reftests/bidi/bidiSVG-02-ref.svg3
-rw-r--r--layout/reftests/bidi/bidiSVG-02.svg3
-rw-r--r--layout/reftests/bidi/bidiSVG-03-ref.svg3
-rw-r--r--layout/reftests/bidi/bidiSVG-03.svg3
-rw-r--r--layout/reftests/bidi/bidiSVG-04-ref.svg3
-rw-r--r--layout/reftests/bidi/bidiSVG-04.svg3
-rw-r--r--layout/reftests/bidi/bidiSVG-05-ref.svg3
-rw-r--r--layout/reftests/bidi/bidiSVG-05.svg3
-rw-r--r--layout/reftests/bidi/brackets-1a-ltr-ref.html15
-rw-r--r--layout/reftests/bidi/brackets-1a-ltr.html16
-rw-r--r--layout/reftests/bidi/brackets-1a-rtl-ref.html15
-rw-r--r--layout/reftests/bidi/brackets-1a-rtl.html16
-rw-r--r--layout/reftests/bidi/brackets-1b-ltr-ref.html15
-rw-r--r--layout/reftests/bidi/brackets-1b-ltr.html16
-rw-r--r--layout/reftests/bidi/brackets-1b-rtl-ref.html15
-rw-r--r--layout/reftests/bidi/brackets-1b-rtl.html16
-rw-r--r--layout/reftests/bidi/brackets-1c-ltr-ref.html15
-rw-r--r--layout/reftests/bidi/brackets-1c-ltr.html16
-rw-r--r--layout/reftests/bidi/brackets-1c-rtl-ref.html15
-rw-r--r--layout/reftests/bidi/brackets-1c-rtl.html16
-rw-r--r--layout/reftests/bidi/brackets-2a-ltr-ref.html15
-rw-r--r--layout/reftests/bidi/brackets-2a-ltr.html16
-rw-r--r--layout/reftests/bidi/brackets-2a-rtl-ref.html15
-rw-r--r--layout/reftests/bidi/brackets-2a-rtl.html16
-rw-r--r--layout/reftests/bidi/brackets-2b-ltr-ref.html15
-rw-r--r--layout/reftests/bidi/brackets-2b-ltr.html16
-rw-r--r--layout/reftests/bidi/brackets-2b-rtl-ref.html15
-rw-r--r--layout/reftests/bidi/brackets-2b-rtl.html16
-rw-r--r--layout/reftests/bidi/brackets-2c-ltr-ref.html15
-rw-r--r--layout/reftests/bidi/brackets-2c-ltr.html16
-rw-r--r--layout/reftests/bidi/brackets-2c-rtl-ref.html15
-rw-r--r--layout/reftests/bidi/brackets-2c-rtl.html16
-rw-r--r--layout/reftests/bidi/brackets-3a-ltr-ref.html15
-rw-r--r--layout/reftests/bidi/brackets-3a-ltr.html16
-rw-r--r--layout/reftests/bidi/brackets-3a-rtl-ref.html15
-rw-r--r--layout/reftests/bidi/brackets-3a-rtl.html16
-rw-r--r--layout/reftests/bidi/brackets-3b-ltr-ref.html16
-rw-r--r--layout/reftests/bidi/brackets-3b-ltr.html16
-rw-r--r--layout/reftests/bidi/brackets-3b-rtl-ref.html16
-rw-r--r--layout/reftests/bidi/brackets-3b-rtl.html16
-rw-r--r--layout/reftests/bidi/dirAuto/1103348-1-ref.html19
-rw-r--r--layout/reftests/bidi/dirAuto/1103348-1.html36
-rw-r--r--layout/reftests/bidi/dirAuto/1169267-delete-add-1-ref.html17
-rw-r--r--layout/reftests/bidi/dirAuto/1169267-delete-add-1a.html18
-rw-r--r--layout/reftests/bidi/dirAuto/1169267-delete-add-1b.html18
-rw-r--r--layout/reftests/bidi/dirAuto/1169267-delete-add-2-ref.html17
-rw-r--r--layout/reftests/bidi/dirAuto/1169267-delete-add-2a.html18
-rw-r--r--layout/reftests/bidi/dirAuto/1169267-delete-add-2b.html18
-rw-r--r--layout/reftests/bidi/dirAuto/839886-1-ref.html17
-rw-r--r--layout/reftests/bidi/dirAuto/839886-1.html17
-rw-r--r--layout/reftests/bidi/dirAuto/859093-1-ref.html11
-rw-r--r--layout/reftests/bidi/dirAuto/859093-1.html11
-rw-r--r--layout/reftests/bidi/dirAuto/889742-1-ref.html16
-rw-r--r--layout/reftests/bidi/dirAuto/889742-1.html21
-rw-r--r--layout/reftests/bidi/dirAuto/bdi-auto-dir-default-ref.html34
-rw-r--r--layout/reftests/bidi/dirAuto/bdi-auto-dir-default.html40
-rw-r--r--layout/reftests/bidi/dirAuto/dir_auto-contained-dir-L-ref.html61
-rw-r--r--layout/reftests/bidi/dirAuto/dir_auto-contained-dir-R-ref.html58
-rw-r--r--layout/reftests/bidi/dirAuto/dir_auto-set-contained-dir-L.html74
-rw-r--r--layout/reftests/bidi/dirAuto/dir_auto-set-contained-dir-R.html71
-rw-r--r--layout/reftests/bidi/dirAuto/dir_auto-set-contained-invalid-dir-L.html75
-rw-r--r--layout/reftests/bidi/dirAuto/dir_auto-set-contained-invalid-dir-R.html72
-rw-r--r--layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-L-ref.html61
-rw-r--r--layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-L.html71
-rw-r--r--layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-R-ref.html64
-rw-r--r--layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-R.html74
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR1.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR10.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR2.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR3.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR4.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR5.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR6.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR7.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR8.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR9.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL1.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL10.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL2.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL3.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL4.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL5.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL6.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL7.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL8.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL9.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-LTR1.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-LTR2.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-LTR3.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-RTL1.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-RTL2.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-RTL3.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-addLTR-Auto.html14
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-addRTL-Auto.html14
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-refLTR-LTR.html17
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-refLTR-RTL.html17
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-refRTL-LTR.html17
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-refRTL-NoDir.html20
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-refRTL-RTL.html17
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto1.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto2.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto3.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto4.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto5.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto6.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir1.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir2.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir3.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir4.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir5.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir6.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir7.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir8.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR1.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR2.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR3.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR4.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR5.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR6.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR7.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR8.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir1.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir2.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir3.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir4.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir5.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir6.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir7.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir8.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL1.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL2.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL3.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL4.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL5.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL6.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL7.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL8.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto1.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto2.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto3.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto4.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto5.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto6.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir1.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir2.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir3.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir4.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir5.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir6.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir7.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir8.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR1.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR2.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR3.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR4.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR5.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR6.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR7.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR8.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir1.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir2.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir3.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir4.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir5.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir6.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir7.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir8.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL1.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL2.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL3.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL4.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL5.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL6.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL7.html18
-rw-r--r--layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL8.html18
-rw-r--r--layout/reftests/bidi/dirAuto/reftest-stylo.list120
-rw-r--r--layout/reftests/bidi/dirAuto/reftest.list119
-rw-r--r--layout/reftests/bidi/dirAuto/setDir.js247
-rw-r--r--layout/reftests/bidi/logicalmarquee.html11
-rw-r--r--layout/reftests/bidi/marquee-ref.html11
-rw-r--r--layout/reftests/bidi/mirroring-01-ref.html13
-rw-r--r--layout/reftests/bidi/mirroring-01.html20
-rw-r--r--layout/reftests/bidi/mirroring-02-ref.html11
-rw-r--r--layout/reftests/bidi/mirroring-02.html18
-rw-r--r--layout/reftests/bidi/mirroring-03-ref.html9
-rw-r--r--layout/reftests/bidi/mirroring-03.html9
-rw-r--r--layout/reftests/bidi/mixedChartype-00-j.html17
-rw-r--r--layout/reftests/bidi/mixedChartype-00-ref.html16
-rw-r--r--layout/reftests/bidi/mixedChartype-00.html16
-rw-r--r--layout/reftests/bidi/mixedChartype-01-j.html16
-rw-r--r--layout/reftests/bidi/mixedChartype-01-ref.html16
-rw-r--r--layout/reftests/bidi/mixedChartype-01.html16
-rw-r--r--layout/reftests/bidi/mixedChartype-02-j.html19
-rw-r--r--layout/reftests/bidi/mixedChartype-02-ref.html18
-rw-r--r--layout/reftests/bidi/mixedChartype-02.html18
-rw-r--r--layout/reftests/bidi/mixedChartype-03-j.html17
-rw-r--r--layout/reftests/bidi/mixedChartype-03-ref.html16
-rw-r--r--layout/reftests/bidi/mixedChartype-03.html16
-rw-r--r--layout/reftests/bidi/numeral/arabic-1-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/arabic-1.html8
-rw-r--r--layout/reftests/bidi/numeral/arabic-2-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/arabic-2.html8
-rw-r--r--layout/reftests/bidi/numeral/arabic-3-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/arabic-3.html8
-rw-r--r--layout/reftests/bidi/numeral/arabic-4-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/arabic-4.html8
-rw-r--r--layout/reftests/bidi/numeral/arabic-5-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/arabic-5.html8
-rw-r--r--layout/reftests/bidi/numeral/bug441782-1-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/bug441782-1.html8
-rw-r--r--layout/reftests/bidi/numeral/bug441782-2-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/bug441782-2.html8
-rw-r--r--layout/reftests/bidi/numeral/bug441782-3-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/bug441782-3.html8
-rw-r--r--layout/reftests/bidi/numeral/bug441782-4-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/bug441782-4.html8
-rw-r--r--layout/reftests/bidi/numeral/bug441782-5-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/bug441782-5.html8
-rw-r--r--layout/reftests/bidi/numeral/bug467672-1-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/bug467672-1.html8
-rw-r--r--layout/reftests/bidi/numeral/bug467672-2-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/bug467672-2.html8
-rw-r--r--layout/reftests/bidi/numeral/bug467672-3-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/bug467672-3.html8
-rw-r--r--layout/reftests/bidi/numeral/bug467672-4-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/bug467672-4.html8
-rw-r--r--layout/reftests/bidi/numeral/bug467672-5-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/bug467672-5.html8
-rw-r--r--layout/reftests/bidi/numeral/persian-1-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/persian-1.html8
-rw-r--r--layout/reftests/bidi/numeral/persian-2-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/persian-2.html8
-rw-r--r--layout/reftests/bidi/numeral/persian-3-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/persian-3.html8
-rw-r--r--layout/reftests/bidi/numeral/persian-4-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/persian-4.html8
-rw-r--r--layout/reftests/bidi/numeral/persian-5-ref.html8
-rw-r--r--layout/reftests/bidi/numeral/persian-5.html8
-rw-r--r--layout/reftests/bidi/numeral/reftest-stylo.list121
-rw-r--r--layout/reftests/bidi/numeral/reftest.list120
-rw-r--r--layout/reftests/bidi/reftest-stylo.list186
-rw-r--r--layout/reftests/bidi/reftest.list174
-rw-r--r--layout/reftests/bidi/unicode-bidi-anonymous-001-ref.html3
-rw-r--r--layout/reftests/bidi/unicode-bidi-anonymous-001.html3
-rw-r--r--layout/reftests/bidi/unicode-bidi-anonymous-002-ref.html5
-rw-r--r--layout/reftests/bidi/unicode-bidi-anonymous-002.html5
-rw-r--r--layout/reftests/bidi/unicode-bidi-isolate-aharon-ref.html69
-rw-r--r--layout/reftests/bidi/unicode-bidi-isolate-aharon.html72
-rw-r--r--layout/reftests/bidi/unicode-bidi-isolate-basic-ref.html22
-rw-r--r--layout/reftests/bidi/unicode-bidi-isolate-basic.html22
-rw-r--r--layout/reftests/bidi/unicode-bidi-isolate-basic.js44
-rw-r--r--layout/reftests/bidi/unicode-bidi-plaintext-ref.html26
-rw-r--r--layout/reftests/bidi/unicode-bidi-plaintext-textarea-1.html17
-rw-r--r--layout/reftests/bidi/unicode-bidi-plaintext-textarea-2.html20
-rw-r--r--layout/reftests/bidi/unicode-bidi-plaintext-textarea-3.html20
-rw-r--r--layout/reftests/bidi/unicode-bidi-plaintext-textarea-4.html20
-rw-r--r--layout/reftests/bidi/unicode-bidi-plaintext-textarea-ref.html19
-rw-r--r--layout/reftests/bidi/unicode-bidi-plaintext.html27
-rw-r--r--layout/reftests/bidi/visualmarquee.html11
-rw-r--r--layout/reftests/bidi/with-first-letter-1-ref.html19
-rw-r--r--layout/reftests/bidi/with-first-letter-1a.html19
-rw-r--r--layout/reftests/bidi/with-first-letter-1b.html19
-rw-r--r--layout/reftests/bidi/with-first-letter-2-ref.html20
-rw-r--r--layout/reftests/bidi/with-first-letter-2a.html19
-rw-r--r--layout/reftests/bidi/with-first-letter-2b.html19
495 files changed, 11116 insertions, 0 deletions
diff --git a/layout/reftests/bidi/1067268-1-ref.html b/layout/reftests/bidi/1067268-1-ref.html
new file mode 100644
index 000000000..c02883462
--- /dev/null
+++ b/layout/reftests/bidi/1067268-1-ref.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html dir="rtl">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <meta charset="utf-8">
+ <title>Testcase for bug 1067268</title>
+ <style type="text/css">
+ .drowning { height: 24px; padding-right: 26px; }
+ </style>
+ </head>
+ <body>
+ <ul>
+ <li>
+ <div>
+ <div class="drowning"><div class="text">חדשות</div></div>
+ </div>
+ </li>
+ <li>
+ <div>
+ <div class="drowning"><div class="text">הודעות</div></div>
+ </div>
+ </li>
+ </ul>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/1067268-1.html b/layout/reftests/bidi/1067268-1.html
new file mode 100644
index 000000000..463aac64f
--- /dev/null
+++ b/layout/reftests/bidi/1067268-1.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html dir="rtl">
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <meta charset="utf-8">
+ <style type="text/css">
+ li { clear: both; }
+
+ .text { overflow: hidden; }
+
+ .floating { float: left; width: 21px; height: 24px}
+
+ .drowning { height: 24px; padding-right: 26px; }
+ </style>
+ <title>Testcase for bug 1067268</title>
+ </head>
+ <body>
+ <ul>
+ <li>
+ <div>
+ <div class="floating"></div>
+ <div class="drowning"><div class="text">חדשות</div></div>
+ </div>
+ </li>
+ <li>
+ <div>
+ <div class="drowning"><div class="text">הודעות</div></div>
+ </div>
+ </li>
+ </ul>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/1069941-inline-bidi-border-1-ref.html b/layout/reftests/bidi/1069941-inline-bidi-border-1-ref.html
new file mode 100644
index 000000000..eeca3ef8c
--- /dev/null
+++ b/layout/reftests/bidi/1069941-inline-bidi-border-1-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Test for bug 1069941 -- borders</title>
+</head>
+<body>
+<div dir="ltr">
+ <span dir="ltr" style="color:transparent;background:gray;border-left:10px solid teal;">+٥</span>
+</div>
+<div dir="ltr">
+ <span dir="ltr" style="color:transparent;background:gray;border-right:10px solid teal;">+٥</span>
+</div>
+</body>
+</html>
diff --git a/layout/reftests/bidi/1069941-inline-bidi-border-1.html b/layout/reftests/bidi/1069941-inline-bidi-border-1.html
new file mode 100644
index 000000000..79b41aaf1
--- /dev/null
+++ b/layout/reftests/bidi/1069941-inline-bidi-border-1.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Test for bug 1069941 -- borders</title>
+</head>
+<body>
+<div dir="ltr">
+ <span dir="rtl" style="color:transparent;background:gray;border-left:10px solid teal;">+٥</span>
+</div>
+<div dir="ltr">
+ <span dir="rtl" style="color:transparent;background:gray;border-right:10px solid teal;">+٥</span>
+</div>
+</body>
+</html>
diff --git a/layout/reftests/bidi/1069941-inline-bidi-margin-1-ref.html b/layout/reftests/bidi/1069941-inline-bidi-margin-1-ref.html
new file mode 100644
index 000000000..c981cd73c
--- /dev/null
+++ b/layout/reftests/bidi/1069941-inline-bidi-margin-1-ref.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Test for bug 1069941 -- margins</title>
+<style type="text/css">
+ .outer {
+ display: inline-block;
+ border: 1px solid lime;
+ }
+ .inner {
+ color:transparent;
+ margin-left: 50px;
+ border: 2px solid teal;
+ }
+</style>
+</head>
+<body>
+<span class="outer"><span class="inner">(12]</span></span>
+</body>
+</html>
diff --git a/layout/reftests/bidi/1069941-inline-bidi-margin-1.html b/layout/reftests/bidi/1069941-inline-bidi-margin-1.html
new file mode 100644
index 000000000..02d0d325c
--- /dev/null
+++ b/layout/reftests/bidi/1069941-inline-bidi-margin-1.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Test for bug 1069941 -- margins</title>
+<style type="text/css">
+ .outer {
+ display: inline-block;
+ border: 1px solid lime;
+ }
+ .inner {
+ color:transparent;
+ margin-left: 50px;
+ border: 2px solid teal;
+ }
+</style>
+</head>
+<body>
+<span class="outer"><span class="inner" dir="rtl">[12)</span></span>
+</body>
+</html>
diff --git a/layout/reftests/bidi/1155359-1-ref.xul b/layout/reftests/bidi/1155359-1-ref.xul
new file mode 100644
index 000000000..c4820b658
--- /dev/null
+++ b/layout/reftests/bidi/1155359-1-ref.xul
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <label value="A." style="direction: ltr;"/>
+</window>
diff --git a/layout/reftests/bidi/1155359-1.xul b/layout/reftests/bidi/1155359-1.xul
new file mode 100644
index 000000000..9ac4b25c1
--- /dev/null
+++ b/layout/reftests/bidi/1155359-1.xul
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <label value="A." style="direction: rtl;"/>
+</window>
diff --git a/layout/reftests/bidi/1157726-1-ref.html b/layout/reftests/bidi/1157726-1-ref.html
new file mode 100644
index 000000000..fd4ff9a74
--- /dev/null
+++ b/layout/reftests/bidi/1157726-1-ref.html
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>unicode bidi isolate characters</title>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <meta charset="utf-8">
+</head>
+<body>
+<p>اتع +1-416-848-3114 abc</p>
+
+<p>اتع <bdi>+1-416-848-3114</bdi> abc</p>
+<p>اتع <bdi>+1-416-848-3114a</bdi> abc</p>
+<p>اتع <bdi>+1-416-848-3114ش</bdi> abc</p>
+
+<p>اتع <bdi dir="ltr">+1-416-848-3114</bdi> abc</p>
+<p>اتع <bdi dir="ltr">+1-416-848-3114a</bdi> abc</p>
+<p>اتع <bdi dir="ltr">+1-416-848-3114ش</bdi> abc</p>
+
+<p>اتع <bdi dir="rtl">+1-416-848-3114</bdi> abc</p>
+<p>اتع <bdi dir="rtl">+1-416-848-3114a</bdi> abc</p>
+<p>اتع <bdi dir="rtl">+1-416-848-3114ش</bdi> abc</p>
+
+</body>
+</html>
diff --git a/layout/reftests/bidi/1157726-1.html b/layout/reftests/bidi/1157726-1.html
new file mode 100644
index 000000000..d8615b43d
--- /dev/null
+++ b/layout/reftests/bidi/1157726-1.html
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>unicode bidi isolate characters</title>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <meta charset="utf-8">
+</head>
+<body>
+<p>اتع +1-416-848-3114 abc</p>
+
+<p>اتع &#x2068;+1-416-848-3114&#x2069; abc</p>
+<p>اتع &#x2068;+1-416-848-3114a&#x2069; abc</p>
+<p>اتع &#x2068;+1-416-848-3114ش&#x2069; abc</p>
+
+<p>اتع &#x2066;+1-416-848-3114&#x2069; abc</p>
+<p>اتع &#x2066;+1-416-848-3114a&#x2069; abc</p>
+<p>اتع &#x2066;+1-416-848-3114ش&#x2069; abc</p>
+
+<p>اتع &#x2067;+1-416-848-3114&#x2069; abc</p>
+<p>اتع &#x2067;+1-416-848-3114a&#x2069; abc</p>
+<p>اتع &#x2067;+1-416-848-3114ش&#x2069; abc</p>
+
+</body>
+</html>
diff --git a/layout/reftests/bidi/115921-1-ref.html b/layout/reftests/bidi/115921-1-ref.html
new file mode 100644
index 000000000..87d40f7dc
--- /dev/null
+++ b/layout/reftests/bidi/115921-1-ref.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>bidi overrides</title>
+</head><body>
+&amp;#x202d; forces ltr<br />
+&amp;#x202e; forces rtl<br />
+&amp;#x202c; restores bidi<br />
+<blockquote>
+this is ltr: hello<br />
+this is rtl: olleh
+</blockquote>
+</body>
+</html>
diff --git a/layout/reftests/bidi/115921-1.html b/layout/reftests/bidi/115921-1.html
new file mode 100644
index 000000000..f12134f48
--- /dev/null
+++ b/layout/reftests/bidi/115921-1.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>bidi overrides</title>
+</head><body>
+&amp;#x202d; forces ltr<br />
+&amp;#x202e; forces rtl<br />
+&amp;#x202c; restores bidi<br />
+<blockquote>
+this is ltr: &#x202d;hello&#x202c;<br />
+this is rtl: &#x202e;hello&#x202c;
+</blockquote>
+</body>
+</html>
diff --git a/layout/reftests/bidi/115921-2-ref.html b/layout/reftests/bidi/115921-2-ref.html
new file mode 100644
index 000000000..72685d706
--- /dev/null
+++ b/layout/reftests/bidi/115921-2-ref.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>bidi overrides</title>
+</head><body>
+&lt;bdo dir="LTR"&gt; forces ltr<br />
+&lt;bdo dir="RTL"&gt; forces rtl<br />
+&lt;/bdo&gt; restores bidi<br />
+<blockquote>
+this is ltr: hello<br />
+this is rtl: olleh
+</blockquote>
+</body>
+</html>
diff --git a/layout/reftests/bidi/115921-2.html b/layout/reftests/bidi/115921-2.html
new file mode 100644
index 000000000..33c41a9f6
--- /dev/null
+++ b/layout/reftests/bidi/115921-2.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>bidi overrides</title>
+</head><body>
+&lt;bdo dir="LTR"&gt; forces ltr<br />
+&lt;bdo dir="RTL"&gt; forces rtl<br />
+&lt;/bdo&gt; restores bidi<br />
+<blockquote>
+this is ltr: <bdo dir="LTR">hello</bdo><br />
+this is rtl: <bdo dir="RTL">hello</bdo>
+</blockquote>
+</body>
+</html>
diff --git a/layout/reftests/bidi/1161752-1-embed.html b/layout/reftests/bidi/1161752-1-embed.html
new file mode 100644
index 000000000..f8bae49cc
--- /dev/null
+++ b/layout/reftests/bidi/1161752-1-embed.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title></title>
+
+ <style type="text/css">
+
+ html { direction: ltr; }
+
+ div
+ {
+ background-color: green;
+ border-left: green none 0px;
+ border-right: green none 0px;
+ height: 50px;
+ left: 20%;
+ margin-left: 0px;
+ margin-right: 0px;
+ position: absolute;
+ right: 20%;
+ top: 0px;
+ width: 20%;
+ }
+
+ </style>
+ </head>
+
+ <body>
+
+ <div></div>
+
+ </body>
+</html>
diff --git a/layout/reftests/bidi/1161752-2-embed.html b/layout/reftests/bidi/1161752-2-embed.html
new file mode 100644
index 000000000..b6a24ce01
--- /dev/null
+++ b/layout/reftests/bidi/1161752-2-embed.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title></title>
+
+ <style type="text/css">
+
+ html { direction: rtl; }
+
+ div
+ {
+ background-color: green;
+ border-left: green none 0px;
+ border-right: green none 0px;
+ height: 50px;
+ left: 20%;
+ margin-left: 0px;
+ margin-right: 0px;
+ position: absolute;
+ right: 20%;
+ top: 0px;
+ width: 20%;
+ }
+
+ </style>
+ </head>
+
+ <body>
+
+ <div></div>
+
+ </body>
+</html>
diff --git a/layout/reftests/bidi/1161752-3-embed.html b/layout/reftests/bidi/1161752-3-embed.html
new file mode 100644
index 000000000..d18228fe0
--- /dev/null
+++ b/layout/reftests/bidi/1161752-3-embed.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html dir="ltr">
+ <head>
+ <meta charset="utf-8">
+ <title></title>
+
+ <style type="text/css">
+
+ div
+ {
+ background-color: green;
+ border-left: green none 0px;
+ border-right: green none 0px;
+ height: 50px;
+ left: 20%;
+ margin-left: 0px;
+ margin-right: 0px;
+ position: absolute;
+ right: 20%;
+ top: 0px;
+ width: 20%;
+ }
+
+ </style>
+ </head>
+
+ <body>
+
+ <div></div>
+
+ </body>
+</html>
diff --git a/layout/reftests/bidi/1161752-4-embed.html b/layout/reftests/bidi/1161752-4-embed.html
new file mode 100644
index 000000000..78e0e27a1
--- /dev/null
+++ b/layout/reftests/bidi/1161752-4-embed.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title></title>
+
+ <style type="text/css">
+
+ html { direction: ltr; }
+
+ div
+ {
+ background-color: green;
+ border-left: green none 0px;
+ border-right: green none 0px;
+ height: 50px;
+ left: 20%;
+ margin-left: 0px;
+ margin-right: 0px;
+ position: fixed;
+ right: 20%;
+ top: 0px;
+ width: 20%;
+ }
+
+ </style>
+ </head>
+
+ <body>
+
+ <div></div>
+
+ </body>
+</html>
diff --git a/layout/reftests/bidi/1161752-5-embed-ref.html b/layout/reftests/bidi/1161752-5-embed-ref.html
new file mode 100644
index 000000000..138bc0327
--- /dev/null
+++ b/layout/reftests/bidi/1161752-5-embed-ref.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html class="reftest-print">
+ <head>
+ <title>Testcase for bug 1161752</title>
+<style>
+ body,html { margin:0; padding:0; }
+ div
+ {
+ height: 56px;
+ width: 100px;
+ vertical-align: top;
+ margin-bottom: 50px;
+ margin-right: 100px;
+ margin-left: auto;
+ }
+ div div
+ {
+ height: 50px;
+ width: 100px;
+ background-color: green;
+ }
+
+</style>
+ </head>
+ <body>
+
+ <div><div></div></div>
+
+ </body>
+</html>
diff --git a/layout/reftests/bidi/1161752-5-embed.html b/layout/reftests/bidi/1161752-5-embed.html
new file mode 100644
index 000000000..4dffa0068
--- /dev/null
+++ b/layout/reftests/bidi/1161752-5-embed.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html class="reftest-print">
+ <head>
+ <meta charset="utf-8">
+ <title></title>
+
+ <style type="text/css">
+
+ html { direction: rtl; }
+
+ div
+ {
+ background-color: green;
+ border-left: green none 0px;
+ border-right: green none 0px;
+ height: 50px;
+ left: 100px;
+ margin-left: 0px;
+ margin-right: 0px;
+ position: fixed;
+ right: 100px;
+ top: 0px;
+ width: 100px;
+ }
+
+ </style>
+ </head>
+
+ <body>
+
+ <div></div>
+
+ </body>
+</html>
diff --git a/layout/reftests/bidi/1161752-ref.html b/layout/reftests/bidi/1161752-ref.html
new file mode 100644
index 000000000..c6ffce33f
--- /dev/null
+++ b/layout/reftests/bidi/1161752-ref.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Testcase for bug 1161752</title>
+<style>
+ div
+ {
+ height: 56px;
+ width: 100px;
+ vertical-align: top;
+ margin-bottom: 50px;
+ }
+ div div
+ {
+ height: 50px;
+ width: 100px;
+ background-color: green;
+ margin-left: 300px;
+ }
+
+</style>
+ </head>
+ <body>
+
+ <p>Test passes if there are three filled green rectangles and <strong>no red</strong>.</p>
+
+
+ <div><div></div></div>
+ <div><div></div></div>
+ <div><div></div></div>
+ <div><div></div></div>
+ <div><div></div></div>
+
+ </body>
+</html>
diff --git a/layout/reftests/bidi/1161752.html b/layout/reftests/bidi/1161752.html
new file mode 100644
index 000000000..e3fa245f5
--- /dev/null
+++ b/layout/reftests/bidi/1161752.html
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Testcase for bug 1161752</title>
+<style>
+ object.overlapping-green
+ {
+ height: 56px;
+ width: 500px;
+ vertical-align: top;
+ }
+
+ div.red-overlapped-reference
+ {
+ background-color: red;
+ bottom: 56px;
+ height: 50px;
+ left: 300px;
+ position: relative;
+ width: 100px;
+ z-index: -1;
+ }
+</style>
+<script>
+function runTest1() {
+ var root = document.querySelector('#test1').contentDocument.documentElement;
+ root.style.direction='rtl';
+ root.offsetHeight;
+}
+function runTest2() {
+ var root = document.querySelector('#test2').contentDocument.documentElement;
+ root.style.display='none';
+ root.offsetHeight;
+ root.style.display='block';
+ root.offsetHeight;
+}
+function runTest3() {
+ var doc = document.querySelector('#test3').contentDocument;
+ var root = doc.documentElement;
+ doc.removeChild(root);
+ var newRoot = root.cloneNode(true);
+ newRoot.setAttribute('dir','rtl');
+ doc.appendChild(newRoot);
+}
+function runTest4() {
+ var root = document.querySelector('#test4').contentDocument.documentElement;
+ root.style.direction='rtl';
+ root.offsetHeight;
+}
+</script>
+ </head>
+ <body>
+
+ <p>Test passes if there are three filled green rectangles and <strong>no red</strong>.</p>
+
+
+ <div><object id="test1" data="1161752-1-embed.html" type="text/html" class="overlapping-green" onload="runTest1()">This test requires a browser with capability to embed an HTML document thanks to the HTML &lt;object&gt; element.</object></div>
+ <div class="red-overlapped-reference"></div>
+
+ <div><object id="test2" data="1161752-2-embed.html" type="text/html" class="overlapping-green" onload="runTest2()">This test requires a browser with capability to embed an HTML document thanks to the HTML &lt;object&gt; element.</object></div>
+ <div class="red-overlapped-reference"></div>
+
+ <div><object id="test3" data="1161752-3-embed.html" type="text/html" class="overlapping-green" onload="runTest3()">This test requires a browser with capability to embed an HTML document thanks to the HTML &lt;object&gt; element.</object></div>
+ <div class="red-overlapped-reference"></div>
+
+ <div><object id="test4" data="1161752-4-embed.html" type="text/html" class="overlapping-green" onload="runTest4()">This test requires a browser with capability to embed an HTML document thanks to the HTML &lt;object&gt; element.</object></div>
+ <div class="red-overlapped-reference"></div>
+
+ <div><object id="test5" data="1161752-5-embed.html" type="text/html" class="overlapping-green">This test requires a browser with capability to embed an HTML document thanks to the HTML &lt;object&gt; element.</object></div>
+ <div class="red-overlapped-reference"></div>
+
+ </body>
+</html>
diff --git a/layout/reftests/bidi/1217833-1-ref.html b/layout/reftests/bidi/1217833-1-ref.html
new file mode 100644
index 000000000..9ed72ef3d
--- /dev/null
+++ b/layout/reftests/bidi/1217833-1-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8" />
+<style>
+html, body { overflow:hidden }
+div{
+ background: yellow;
+ width:150px;
+ height:50px;
+ margin: 0 auto;
+ text-align:right;
+ color: blue;
+}
+</style>
+</head><body><div>test</div></body></html>
diff --git a/layout/reftests/bidi/1217833-1.html b/layout/reftests/bidi/1217833-1.html
new file mode 100644
index 000000000..2a1eea325
--- /dev/null
+++ b/layout/reftests/bidi/1217833-1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html dir="rtl">
+<head>
+<meta charset="utf-8" />
+<style>
+html, body { overflow:hidden }
+div{
+ background: yellow;
+ width:150px;
+ height:50px;
+ margin: 0 auto;
+ text-align:right;
+}
+div:first-line {
+ color: blue;
+}
+</style>
+</head><body><div dir="rtl">test</div></body></html>
diff --git a/layout/reftests/bidi/1217833-2-ref.html b/layout/reftests/bidi/1217833-2-ref.html
new file mode 100644
index 000000000..e328be5f9
--- /dev/null
+++ b/layout/reftests/bidi/1217833-2-ref.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8" />
+<style>
+html, body { overflow:hidden }
+div{
+ background: yellow;
+ width:150px;
+ height:50px;
+ margin: 0 auto;
+ text-align:right;
+ color: blue;
+ direction: ltr; unicode-bidi: bidi-override;
+}
+span {
+ background: aqua;
+ margin: 0 3px;
+}
+</style>
+</head><body><div dir="rtl">הקי<span>דב</span>te<span>st</span></div></body></html>
diff --git a/layout/reftests/bidi/1217833-2.html b/layout/reftests/bidi/1217833-2.html
new file mode 100644
index 000000000..699947a2d
--- /dev/null
+++ b/layout/reftests/bidi/1217833-2.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html dir="rtl">
+<head>
+<meta charset="utf-8" />
+<style>
+html, body { overflow:hidden }
+div{
+ background: yellow;
+ width:150px;
+ height:50px;
+ margin: 0 auto;
+ text-align:right;
+}
+div:first-line {
+ color: blue;
+}
+span {
+ background: aqua;
+ margin: 0 3px;
+ box-decoration-break: clone;
+}
+</style>
+</head><body><div dir="rtl">te<span>stבד</span>יקה</div></body></html>
diff --git a/layout/reftests/bidi/1231175-1-ref.html b/layout/reftests/bidi/1231175-1-ref.html
new file mode 100644
index 000000000..b6238cf6b
--- /dev/null
+++ b/layout/reftests/bidi/1231175-1-ref.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<style>
+div { width: 200px; border: 1px solid blue; }
+span { direction: rtl; color: red; unicode-bidi: bidi-override; }
+</style>
+<body>
+<p>The number in the red text should read "18" in all cases.
+<div>
+<ol dir=rtl>
+<li><span>81 ديسمبر</span></li>
+<li><span>81 ديسمبر</span></li>
+<li><span>81 ديسمبر</span></li>
+<li><span>81 ديسمبر</span></li>
+<li><span>81 ديسمبر</span></li>
+<li><span>81 ديسمبر</span></li>
+<li><span>81 ديسمبر</span></li>
diff --git a/layout/reftests/bidi/1231175-1.html b/layout/reftests/bidi/1231175-1.html
new file mode 100644
index 000000000..ebe0e2671
--- /dev/null
+++ b/layout/reftests/bidi/1231175-1.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<style>
+div { width: 200px; border: 1px solid blue; }
+span { direction: rtl; color: red; }
+</style>
+<body>
+<p>The number in the red text should read "18" in all cases.
+<div>
+<ol dir=rtl>
+<li><span style="unicode-bidi: normal">18 ديسمبر</span></li>
+<li><span style="unicode-bidi: embed">18 ديسمبر</span></li>
+<li><span style="unicode-bidi: isolate">18 ديسمبر</span></li>
+<li><span style="unicode-bidi: plaintext">18 ديسمبر</span></li>
+<li><span>&#x202B;18 ديسمبر&#x202C;</span></li>
+<li><span>&#x2067;18 ديسمبر&#x2069;</span></li>
+<li><span>&#x2068;18 ديسمبر&#x2069;</span></li>
diff --git a/layout/reftests/bidi/151407-1-ref.html b/layout/reftests/bidi/151407-1-ref.html
new file mode 100644
index 000000000..43ef5f3f8
--- /dev/null
+++ b/layout/reftests/bidi/151407-1-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test GetDir() for elements</title>
+ </head>
+ <body>
+ <div dir="">dir="", getDir returns ""</div>
+ <div dir="ltr">dir="ltr", getDir returns "ltr"</div>
+ <div dir="rtl">dir="rtl", getDir returns "rtl"</div>
+ <div dir="auto">dir="auto", getDir returns "auto"</div>
+ <div dir="foopy">dir="foopy", getDir returns ""</div>
+ <div>no dir attribute, getDir returns ""</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-1.html b/layout/reftests/bidi/151407-1.html
new file mode 100644
index 000000000..265c80815
--- /dev/null
+++ b/layout/reftests/bidi/151407-1.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test GetDir() for elements</title>
+ <script type="text/javascript">
+function fill() {
+ for (var i = 0; ; ++i) {
+ div = document.getElementById("div" + i);
+ if (!div) break;
+ span = document.getElementById("span" + i);
+ span.innerHTML = div.dir;
+ }
+}
+ </script>
+ </head>
+ <body onLoad="fill()">
+ <div id="div0" dir="">dir="", getDir returns "<span id="span0"></span>"</div>
+ <div id="div1" dir="ltr">dir="ltr", getDir returns "<span id="span1"></span>"</div>
+ <div id="div2" dir="rtl">dir="rtl", getDir returns "<span id="span2"></span>"</div>
+ <div id="div3" dir="auto">dir="auto", getDir returns "<span id="span3"></span>"</div>
+ <div id="div4" dir="foopy">dir="foopy", getDir returns "<span id="span4"></span>"</div>
+ <div id="div5">no dir attribute, getDir returns "<span id="span5"></span>"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-1a.html b/layout/reftests/bidi/151407-1a.html
new file mode 100644
index 000000000..2406dcf92
--- /dev/null
+++ b/layout/reftests/bidi/151407-1a.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test GetDir() for elements</title>
+ <script type="text/javascript">
+function fill() {
+ div0.dir = "";
+ div1.dir = "ltr";
+ div2.dir = "rtl";
+ div3.dir = "auto";
+ div4.dir = "foopy";
+
+ for (var i = 0; ; ++i) {
+ div = document.getElementById("div" + i);
+ if (!div) break;
+ span = document.getElementById("span" + i);
+ span.innerHTML = div.dir;
+ }
+}
+ </script>
+ </head>
+ <body onLoad="fill()">
+ <div id="div0">dir="", getDir returns "<span id="span0"></span>"</div>
+ <div id="div1">dir="ltr", getDir returns "<span id="span1"></span>"</div>
+ <div id="div2">dir="rtl", getDir returns "<span id="span2"></span>"</div>
+ <div id="div3">dir="auto", getDir returns "<span id="span3"></span>"</div>
+ <div id="div4">dir="foopy", getDir returns "<span id="span4"></span>"</div>
+ <div id="div5">no dir attribute, getDir returns "<span id="span5"></span>"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-2-auto-ref.html b/layout/reftests/bidi/151407-2-auto-ref.html
new file mode 100644
index 000000000..bd3b88b99
--- /dev/null
+++ b/layout/reftests/bidi/151407-2-auto-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html dir="auto">
+ <head>
+ <meta charset="utf-8">
+ <title>Test GetDir() for documents</title>
+ </head>
+ <body>
+ <div>getDir on document returns "auto"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-2-auto.html b/layout/reftests/bidi/151407-2-auto.html
new file mode 100644
index 000000000..d1b04fd24
--- /dev/null
+++ b/layout/reftests/bidi/151407-2-auto.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html dir="auto">
+ <head>
+ <meta charset="utf-8">
+ <title>Test GetDir() for documents</title>
+ <script type="text/javascript">
+function fill() {
+ span = document.getElementById("span0");
+ span.innerHTML = document.dir;
+}
+ </script>
+ </head>
+ <body onLoad="fill()">
+ <div>getDir on document returns "<span id="span0"></span>"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-2-empty-ref.html b/layout/reftests/bidi/151407-2-empty-ref.html
new file mode 100644
index 000000000..f3d1e3225
--- /dev/null
+++ b/layout/reftests/bidi/151407-2-empty-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test GetDir() for documents</title>
+ </head>
+ <body>
+ <div>getDir on document returns ""</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-2-empty.html b/layout/reftests/bidi/151407-2-empty.html
new file mode 100644
index 000000000..284f9c6b6
--- /dev/null
+++ b/layout/reftests/bidi/151407-2-empty.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test GetDir() for documents</title>
+ <script type="text/javascript">
+function fill() {
+ span = document.getElementById("span0");
+ span.innerHTML = document.dir;
+}
+ </script>
+ </head>
+ <body onLoad="fill()">
+ <div>getDir on document returns "<span id="span0"></span>"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-2-foopy.html b/layout/reftests/bidi/151407-2-foopy.html
new file mode 100644
index 000000000..71b5eb6b0
--- /dev/null
+++ b/layout/reftests/bidi/151407-2-foopy.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html dir="foopy">
+ <head>
+ <meta charset="utf-8">
+ <title>Test GetDir() for documents</title>
+ <script type="text/javascript">
+function fill() {
+ span = document.getElementById("span0");
+ span.innerHTML = document.dir;
+}
+ </script>
+ </head>
+ <body onLoad="fill()">
+ <div>getDir on document returns "<span id="span0"></span>"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-2-ltr-ref.html b/layout/reftests/bidi/151407-2-ltr-ref.html
new file mode 100644
index 000000000..993afae23
--- /dev/null
+++ b/layout/reftests/bidi/151407-2-ltr-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test GetDir() for documents</title>
+ </head>
+ <body>
+ <div>getDir on document returns "ltr"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-2-ltr.html b/layout/reftests/bidi/151407-2-ltr.html
new file mode 100644
index 000000000..09ebdfed7
--- /dev/null
+++ b/layout/reftests/bidi/151407-2-ltr.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html dir="ltr">
+ <head>
+ <meta charset="utf-8">
+ <title>Test GetDir() for documents</title>
+ <script type="text/javascript">
+function fill() {
+ span = document.getElementById("span0");
+ span.innerHTML = document.dir;
+}
+ </script>
+ </head>
+ <body onLoad="fill()">
+ <div>getDir on document returns "<span id="span0"></span>"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-2-rtl-ref.html b/layout/reftests/bidi/151407-2-rtl-ref.html
new file mode 100644
index 000000000..bec0509f0
--- /dev/null
+++ b/layout/reftests/bidi/151407-2-rtl-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html dir="rtl">
+ <head>
+ <meta charset="utf-8">
+ <title>Test GetDir() for documents</title>
+ </head>
+ <body>
+ <div>getDir on document returns "rtl"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-2-rtl.html b/layout/reftests/bidi/151407-2-rtl.html
new file mode 100644
index 000000000..d11378d16
--- /dev/null
+++ b/layout/reftests/bidi/151407-2-rtl.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html dir="rtl">
+ <head>
+ <meta charset="utf-8">
+ <title>Test GetDir() for documents</title>
+ <script type="text/javascript">
+function fill() {
+ span = document.getElementById("span0");
+ span.innerHTML = document.dir;
+}
+ </script>
+ </head>
+ <body onLoad="fill()">
+ <div>getDir on document returns "<span id="span0"></span>"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-3-auto-ref.html b/layout/reftests/bidi/151407-3-auto-ref.html
new file mode 100644
index 000000000..3f1241e32
--- /dev/null
+++ b/layout/reftests/bidi/151407-3-auto-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test SetDir() for documents</title>
+ </head>
+ <body>
+ <div>getDir on document after setDir returns "auto"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-3-auto.html b/layout/reftests/bidi/151407-3-auto.html
new file mode 100644
index 000000000..982c5348f
--- /dev/null
+++ b/layout/reftests/bidi/151407-3-auto.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html dir="rtl">
+ <head>
+ <meta charset="utf-8">
+ <title>Test SetDir() for documents</title>
+ <script type="text/javascript">
+function fill() {
+ document.dir = "auto"
+ span = document.getElementById("span0");
+ span.innerHTML = document.dir;
+}
+ </script>
+ </head>
+ <body onLoad="fill()">
+ <div>getDir on document after setDir returns "<span id="span0"></span>"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-3-empty-ref.html b/layout/reftests/bidi/151407-3-empty-ref.html
new file mode 100644
index 000000000..d0feebc95
--- /dev/null
+++ b/layout/reftests/bidi/151407-3-empty-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test SetDir() for documents</title>
+ </head>
+ <body>
+ <div>getDir on document after setDir returns ""</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-3-foopy.html b/layout/reftests/bidi/151407-3-foopy.html
new file mode 100644
index 000000000..c77596824
--- /dev/null
+++ b/layout/reftests/bidi/151407-3-foopy.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html dir="rtl">
+ <head>
+ <meta charset="utf-8">
+ <title>Test SetDir() for documents</title>
+ <script type="text/javascript">
+function fill() {
+ document.dir = "foopy"
+ span = document.getElementById("span0");
+ span.innerHTML = document.dir;
+}
+ </script>
+ </head>
+ <body onLoad="fill()">
+ <div>getDir on document after setDir returns "<span id="span0"></span>"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-3-ltr-ref.html b/layout/reftests/bidi/151407-3-ltr-ref.html
new file mode 100644
index 000000000..9cf5539e2
--- /dev/null
+++ b/layout/reftests/bidi/151407-3-ltr-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test SetDir() for documents</title>
+ </head>
+ <body>
+ <div>getDir on document after setDir returns "ltr"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-3-ltr.html b/layout/reftests/bidi/151407-3-ltr.html
new file mode 100644
index 000000000..e043d489e
--- /dev/null
+++ b/layout/reftests/bidi/151407-3-ltr.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html dir="rtl">
+ <head>
+ <meta charset="utf-8">
+ <title>Test SetDir() for documents</title>
+ <script type="text/javascript">
+function fill() {
+ document.dir = "ltr"
+ span = document.getElementById("span0");
+ span.innerHTML = document.dir;
+}
+ </script>
+ </head>
+ <body onLoad="fill()">
+ <div>getDir on document after setDir returns "<span id="span0"></span>"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-3-rtl-ref.html b/layout/reftests/bidi/151407-3-rtl-ref.html
new file mode 100644
index 000000000..884a54217
--- /dev/null
+++ b/layout/reftests/bidi/151407-3-rtl-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html dir="rtl">
+ <head>
+ <meta charset="utf-8">
+ <title>Test SetDir() for documents</title>
+ </head>
+ <body>
+ <div>getDir on document after setDir returns "rtl"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/151407-3-rtl.html b/layout/reftests/bidi/151407-3-rtl.html
new file mode 100644
index 000000000..781cd6f79
--- /dev/null
+++ b/layout/reftests/bidi/151407-3-rtl.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html dir="ltr">
+ <head>
+ <meta charset="utf-8">
+ <title>Test SetDir() for documents</title>
+ <script type="text/javascript">
+function fill() {
+ document.dir = "rtl"
+ span = document.getElementById("span0");
+ span.innerHTML = document.dir;
+}
+ </script>
+ </head>
+ <body onLoad="fill()">
+ <div>getDir on document after setDir returns "<span id="span0"></span>"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/229367-1-ref.html b/layout/reftests/bidi/229367-1-ref.html
new file mode 100644
index 000000000..5e30c4a7e
--- /dev/null
+++ b/layout/reftests/bidi/229367-1-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>br-as-bidi-paragraph-break</title>
+ <meta charset="UTF-8">
+ </head>
+ <body>
+ <p>&#x05D0; --&gt;&lrm;<br>--&gt; &#x05D1;</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/229367-1.html b/layout/reftests/bidi/229367-1.html
new file mode 100644
index 000000000..079eb18c6
--- /dev/null
+++ b/layout/reftests/bidi/229367-1.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>br-as-bidi-paragraph-break</title>
+ <meta charset="UTF-8">
+ </head>
+ <body>
+ <p>&#x05D0; --&gt;<br>--&gt; &#x05D1;</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/229367-2-ref.html b/layout/reftests/bidi/229367-2-ref.html
new file mode 100644
index 000000000..5d8b606c4
--- /dev/null
+++ b/layout/reftests/bidi/229367-2-ref.html
@@ -0,0 +1,43 @@
+<DOCTYPE html>
+<html DIR=RTL>
+ <head>
+ <meta charset=UTF-8>
+ <title>BIDI Layout Testing</title>
+ </head>
+ <body>
+ <h2>This is a testing for BiDi layout issues.</h2>
+<br>
+
+1 - No tag<br>
+2 - SPAN<br>
+3 - P<br>
+4 - DIV<br>
+
+<br>
+<b>Test1: No space</b><br>
+This is a testing for BiDi layout issues.&rlm;<br>
+<span>This is a testing for BiDi layout issues.&rlm;<br></span>
+<p>This is a testing for BiDi layout issues.&rlm;<br></p>
+<div>This is a testing for BiDi layout issues.&rlm;<br></div>
+<br><br>
+<b>Test2: 3 spaces at the end</b><br>
+This is a testing for BiDi layout issues.&rlm;&nbsp;&nbsp;&nbsp;<br>
+<span>This is a testing for BiDi layout issues.&rlm;&nbsp;&nbsp;&nbsp;<br></span>
+
+<p>This is a testing for BiDi layout issues.&rlm;&nbsp;&nbsp;&nbsp;<br></p>
+<div>This is a testing for BiDi layout issues.&rlm;&nbsp;&nbsp;&nbsp;<br></div>
+<br><br>
+<b>Test3: 3 spaces at the beginning</b><br>
+&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&rlm;<br>
+<span>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&rlm;<br></span>
+<p>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&rlm;<br></p>
+<div>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&rlm;<br></div>
+<br><br>
+
+<b>Test4: 3 spaces at the end and the beginning</b><br>
+&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&rlm;&nbsp;&nbsp;&nbsp;<br>
+<span>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&rlm;&nbsp;&nbsp;&nbsp;<br></span>
+<p>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&rlm;&nbsp;&nbsp;&nbsp;<br></p>
+<div>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&rlm;&nbsp;&nbsp;&nbsp;<br></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/229367-2.html b/layout/reftests/bidi/229367-2.html
new file mode 100644
index 000000000..5c7a2a97c
--- /dev/null
+++ b/layout/reftests/bidi/229367-2.html
@@ -0,0 +1,43 @@
+<DOCTYPE html>
+<html DIR=RTL>
+ <head>
+ <meta charset=UTF-8>
+ <title>BIDI Layout Testing</title>
+ </head>
+ <body>
+ <h2>This is a testing for BiDi layout issues.</h2>
+<br>
+
+1 - No tag<br>
+2 - SPAN<br>
+3 - P<br>
+4 - DIV<br>
+
+<br>
+<b>Test1: No space</b><br>
+This is a testing for BiDi layout issues.<br>
+<span>This is a testing for BiDi layout issues.<br></span>
+<p>This is a testing for BiDi layout issues.<br></p>
+<div>This is a testing for BiDi layout issues.<br></div>
+<br><br>
+<b>Test2: 3 spaces at the end</b><br>
+This is a testing for BiDi layout issues.&nbsp;&nbsp;&nbsp;<br>
+<span>This is a testing for BiDi layout issues.&nbsp;&nbsp;&nbsp;<br></span>
+
+<p>This is a testing for BiDi layout issues.&nbsp;&nbsp;&nbsp;<br></p>
+<div>This is a testing for BiDi layout issues.&nbsp;&nbsp;&nbsp;<br></div>
+<br><br>
+<b>Test3: 3 spaces at the beginning</b><br>
+&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.<br>
+<span>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.<br></span>
+<p>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.<br></p>
+<div>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.<br></div>
+<br><br>
+
+<b>Test4: 3 spaces at the end and the beginning</b><br>
+&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&nbsp;&nbsp;&nbsp;<br>
+<span>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&nbsp;&nbsp;&nbsp;<br></span>
+<p>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&nbsp;&nbsp;&nbsp;<br></p>
+<div>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&nbsp;&nbsp;&nbsp;<br></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/229367-3-ref.html b/layout/reftests/bidi/229367-3-ref.html
new file mode 100644
index 000000000..2f2baf913
--- /dev/null
+++ b/layout/reftests/bidi/229367-3-ref.html
@@ -0,0 +1,35 @@
+<DOCTYPE html>
+<!-- This tests that embeddings and overrides are preserved after <br> -->
+<html>
+ <head>
+ <meta charset=UTF-8>
+ <title>Bug 229367</title>
+ <style type="text/css">
+ p { margin: 0; text-align: left; }
+ p.er { unicode-bidi: embed; direction: rtl; }
+ p.ol { unicode-bidi: bidi-override; direction: ltr; }
+ p.or { unicode-bidi: bidi-override; direction: rtl; }
+ </style>
+ </head>
+ <body>
+ <p>במה מדליקין,</p>
+ <p>ובמה אין מדליקין?</p>
+ <p class="er">אין מדליקין לא בלכש, </p>
+ <p class="er">ולא בחוסן, </p>
+ <p class="er">ולא בכלך, </p>
+ <p class="er">ולא בפתילת האידן, </p>
+ <p class="ol">ולא בפתילת המדבר, </p>
+ <p class="ol">ולא בירוקה שעל פני המים. </p>
+ <p class="ol">לא בזפת, </p>
+ <p class="or">ולא בשעווה, </p>
+ <p class="or">ולא בשמן קיק, </p>
+ <p class="or">ולא בשמן שריפה, </p>
+ <p class="or">ולא באליה, </p>
+ <p class="ol">ולא בחלב. </p>
+ <p class="ol">נחום המדי אומר, </p>
+ <p class="er">מדליקין בחלב מבושל;</p>
+ <p class="er">וחכמים אומרים, </p>
+ <p>אחד מבושל ואחד שאינו מבושל,</p>
+ <p>אין מדליקין בו.</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/229367-3.html b/layout/reftests/bidi/229367-3.html
new file mode 100644
index 000000000..1ea70e3b1
--- /dev/null
+++ b/layout/reftests/bidi/229367-3.html
@@ -0,0 +1,30 @@
+<DOCTYPE html>
+<!-- This tests that embeddings and overrides are preserved after <br> -->
+<html>
+ <head>
+ <meta charset=UTF-8>
+ <title>Bug 229367</title>
+ </head>
+ <body>
+ <div>במה מדליקין,<br>
+ובמה אין מדליקין?<br>
+<span style="unicode-bidi: embed; direction: rtl">אין מדליקין לא בלכש, <br>
+ולא בחוסן, <br>
+ולא בכלך, <br>
+ולא בפתילת האידן, <br>
+<span style="unicode-bidi: bidi-override; direction: ltr">ולא בפתילת המדבר, <br>
+ולא בירוקה שעל פני המים. <br>
+לא בזפת, <br>
+<span style="unicode-bidi: bidi-override; direction: rtl">ולא בשעווה, <br>
+ולא בשמן קיק, <br>
+ולא בשמן שריפה, <br>
+ולא באליה, <br></span>
+ולא בחלב. <br>
+נחום המדי אומר, <br></span>
+מדליקין בחלב מבושל; <br>
+וחכמים אומרים, <br></span>
+אחד מבושל ואחד שאינו מבושל,<br>
+אין מדליקין בו.
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/258928-1-ref.html b/layout/reftests/bidi/258928-1-ref.html
new file mode 100644
index 000000000..6a3c7d864
--- /dev/null
+++ b/layout/reftests/bidi/258928-1-ref.html
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title>RTL list displayed as inline broken</title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
+ <style type="text/css">
+ul {
+ padding: 3px 10px;
+ border-bottom: 3px solid #4949A9;
+ white-space: nowrap;
+ font-size: 13px;
+}
+
+ul li {
+ display: inline;
+ margin: 0;
+ padding: 3px 10px;
+ border-top: 1px solid gray;
+ border-right: 1px solid gray;
+ border-left: 1px solid gray;
+ background-color: #f0f0f0;
+}
+ </style>
+ </head>
+ <body>
+ <h1>Broken RTL list when displayed as inline</h1>
+ <h2>One Item</h2>
+ <ul class="tabs">
+ <li>Tab</li>
+ </ul>
+ <h2>Two Items</h2>
+ <ul class="tabs">
+ <li>Tab</li>
+ <li>Tab</li>
+ </ul>
+ <h2>Many</h2>
+ <ul class="tabs">
+ <li>Tab</li>
+ <li>Tab</li>
+ <li>Tab</li>
+ <li>Tab</li>
+ <li>Tab</li>
+ <li>Tab</li>
+ <li>Tab</li>
+ <li>Tab</li>
+ <li>Tab</li>
+ <li>Tab</li>
+ </ul>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/258928-1.html b/layout/reftests/bidi/258928-1.html
new file mode 100644
index 000000000..224d0011f
--- /dev/null
+++ b/layout/reftests/bidi/258928-1.html
@@ -0,0 +1,52 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title>RTL list displayed as inline broken</title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
+ <style type="text/css">
+ul {
+ padding: 3px 10px;
+ border-bottom: 3px solid #4949A9;
+ white-space: nowrap;
+ font-size: 13px;
+ direction: rtl;
+ text-align: left;
+}
+
+ul li {
+ display: inline;
+ margin: 0;
+ padding: 3px 10px;
+ border-top: 1px solid gray;
+ border-right: 1px solid gray;
+ border-left: 1px solid gray;
+ background-color: #f0f0f0;
+}
+ </style>
+ </head>
+ <body>
+ <h1>Broken RTL list when displayed as inline</h1>
+ <h2>One Item</h2>
+ <ul class="tabs">
+ <li>Tab</li>
+ </ul>
+ <h2>Two Items</h2>
+ <ul class="tabs">
+ <li>Tab</li>
+ <li>Tab</li>
+ </ul>
+ <h2>Many</h2>
+ <ul class="tabs">
+ <li>Tab</li>
+ <li>Tab</li>
+ <li>Tab</li>
+ <li>Tab</li>
+ <li>Tab</li>
+ <li>Tab</li>
+ <li>Tab</li>
+ <li>Tab</li>
+ <li>Tab</li>
+ <li>Tab</li>
+ </ul>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/263359-1-ref.html b/layout/reftests/bidi/263359-1-ref.html
new file mode 100644
index 000000000..203a055e5
--- /dev/null
+++ b/layout/reftests/bidi/263359-1-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>preformatted-paragraph-break-as-bidi-paragraph-break</title>
+ <meta charset="UTF-8">
+ </head>
+ <body>
+ <pre>&#x05D0; --&gt;&lrm;
+--&gt; &#x05D1;</pre>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/263359-1.html b/layout/reftests/bidi/263359-1.html
new file mode 100644
index 000000000..71f78338c
--- /dev/null
+++ b/layout/reftests/bidi/263359-1.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>preformatted-paragraph-break-as-bidi-paragraph-break</title>
+ <meta charset="UTF-8">
+ </head>
+ <body>
+ <pre>&#x05D0; --&gt;
+--&gt; &#x05D1;</pre>
+</body>
+</html>
+
diff --git a/layout/reftests/bidi/263359-1a.html b/layout/reftests/bidi/263359-1a.html
new file mode 100644
index 000000000..11cc5cd82
--- /dev/null
+++ b/layout/reftests/bidi/263359-1a.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>preformatted-paragraph-break-as-bidi-paragraph-break</title>
+ <meta charset="UTF-8">
+<script type="text/javascript">
+
+function boom()
+{
+ document.getElementById("w").style.whiteSpace="pre";
+}
+
+</script>
+ </head>
+ <body onload="boom();">
+ <pre id="w" style="white-space: normal">&#x05D0; --&gt;
+--&gt; &#x05D1;</pre>
+</body>
+</html>
+
diff --git a/layout/reftests/bidi/263359-1b.html b/layout/reftests/bidi/263359-1b.html
new file mode 100644
index 000000000..029384af8
--- /dev/null
+++ b/layout/reftests/bidi/263359-1b.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>preformatted-paragraph-break-as-bidi-paragraph-break</title>
+ <meta charset="UTF-8">
+<script type="text/javascript">
+
+function boom()
+{
+ document.getElementById("w").style.whiteSpace="normal";
+}
+
+</script>
+ </head>
+ <body onload="boom();">
+ <pre id="w">&#x05D0; --&gt;
+--&gt; &#x05D1;</pre>
+</body>
+</html>
+
diff --git a/layout/reftests/bidi/263359-2-ref.html b/layout/reftests/bidi/263359-2-ref.html
new file mode 100644
index 000000000..bca0323d6
--- /dev/null
+++ b/layout/reftests/bidi/263359-2-ref.html
@@ -0,0 +1,47 @@
+<DOCTYPE html>
+<html DIR=RTL>
+ <head>
+ <meta charset=UTF-8>
+ <title>BIDI Layout Testing</title>
+ </head>
+ <body>
+ <div style="white-space: pre">
+<b>Test1: No space</b>
+This is a testing for BiDi layout issues. &rlm;
+<span>This is a testing for BiDi layout issues.&rlm;
+</span>
+<p>This is a testing for BiDi layout issues.&rlm;
+</p>
+<div>This is a testing for BiDi layout issues.&rlm;
+</div>
+
+<b>Test2: 3 spaces at the end</b>
+This is a testing for BiDi layout issues.&rlm;&nbsp;&nbsp;&nbsp;
+<span>This is a testing for BiDi layout issues.&rlm;&nbsp;&nbsp;&nbsp;
+</span>
+
+<p>This is a testing for BiDi layout issues.&rlm;&nbsp;&nbsp;&nbsp;
+</p>
+<div>This is a testing for BiDi layout issues.&rlm;&nbsp;&nbsp;&nbsp;
+</div>
+
+<b>Test3: 3 spaces at the beginning</b>
+&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&rlm;
+<span>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&rlm;
+</span>
+<p>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&rlm;
+</p>
+<div>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&rlm;
+</div>
+
+<b>Test4: 3 spaces at the end and the beginning</b>
+&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&rlm;&nbsp;&nbsp;&nbsp;
+<span>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&rlm;&nbsp;&nbsp;&nbsp;
+</span>
+<p>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&rlm;&nbsp;&nbsp;&nbsp;
+</p>
+<div>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&rlm;&nbsp;&nbsp;&nbsp;
+</div>
+</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/263359-2.html b/layout/reftests/bidi/263359-2.html
new file mode 100644
index 000000000..9e6ab5ed4
--- /dev/null
+++ b/layout/reftests/bidi/263359-2.html
@@ -0,0 +1,46 @@
+<DOCTYPE html>
+<html DIR=RTL>
+ <head>
+ <meta charset=UTF-8>
+ <title>BIDI Layout Testing</title>
+ </head>
+ <body>
+ <div style="white-space: pre">
+<b>Test1: No space</b>
+This is a testing for BiDi layout issues.
+<span>This is a testing for BiDi layout issues.
+</span>
+<p>This is a testing for BiDi layout issues.
+</p>
+<div>This is a testing for BiDi layout issues.</div>
+
+<b>Test2: 3 spaces at the end</b>
+This is a testing for BiDi layout issues.&nbsp;&nbsp;&nbsp;
+<span>This is a testing for BiDi layout issues.&nbsp;&nbsp;&nbsp;
+</span>
+
+<p>This is a testing for BiDi layout issues.&nbsp;&nbsp;&nbsp;
+</p>
+<div>This is a testing for BiDi layout issues.&nbsp;&nbsp;&nbsp;
+</div>
+
+<b>Test3: 3 spaces at the beginning</b>
+&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.
+<span>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.
+</span>
+<p>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.
+</p>
+<div>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.
+</div>
+
+<b>Test4: 3 spaces at the end and the beginning</b>
+&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&nbsp;&nbsp;&nbsp;
+<span>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&nbsp;&nbsp;&nbsp;
+</span>
+<p>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&nbsp;&nbsp;&nbsp;
+</p>
+<div>&nbsp;&nbsp;&nbsp;This is a testing for BiDi layout issues.&nbsp;&nbsp;&nbsp;
+</div>
+</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/263359-3-ref.html b/layout/reftests/bidi/263359-3-ref.html
new file mode 100644
index 000000000..92e017b71
--- /dev/null
+++ b/layout/reftests/bidi/263359-3-ref.html
@@ -0,0 +1,35 @@
+<DOCTYPE html>
+<!-- This tests that embeddings and overrides are preserved after <br> -->
+<html>
+ <head>
+ <meta charset=UTF-8>
+ <title>Bug 263359</title>
+ <style type="text/css">
+ p { margin: 0; text-align: left; white-space: pre }
+ p.er { direction: rtl; }
+ p.ol { unicode-bidi: bidi-override; direction: ltr; }
+ p.or { unicode-bidi: bidi-override; direction: rtl; }
+ </style>
+ </head>
+ <body>
+<p>במה מדליקין,</p>
+<p>ובמה אין מדליקין?</p>
+<p class="er">אין מדליקין לא בלכש,</p>
+<p class="er">ולא בחוסן,</p>
+<p class="er">ולא בכלך,</p>
+<p class="er">ולא בפתילת האידן,</p>
+<p class="ol">ולא בפתילת המדבר,</p>
+<p class="ol">ולא בירוקה שעל פני המים.</p>
+<p class="ol">לא בזפת,</p>
+<p class="or">ולא בשעווה,</p>
+<p class="or">ולא בשמן קיק,</p>
+<p class="or">ולא בשמן שריפה,</p>
+<p class="or">ולא באליה,</p>
+<p class="ol">ולא בחלב.</p>
+<p class="ol">נחום המדי אומר,</p>
+<p class="er">מדליקין בחלב מבושל;</p>
+<p class="er">וחכמים אומרים,</p>
+<p>אחד מבושל ואחד שאינו מבושל,</p>
+<p>אין מדליקין בו.</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/263359-3.html b/layout/reftests/bidi/263359-3.html
new file mode 100644
index 000000000..b225517bd
--- /dev/null
+++ b/layout/reftests/bidi/263359-3.html
@@ -0,0 +1,36 @@
+<DOCTYPE html>
+<!-- This tests that embeddings and overrides are preserved in <pre> -->
+<html>
+ <head>
+ <meta charset=UTF-8>
+ <title>Bug 263359</title>
+ <style type="text/css">
+ p {
+ white-space: pre;
+ margin: 0;
+ }
+ </style>
+ </head>
+ <body>
+ <p style="">במה מדליקין,
+ובמה אין מדליקין?
+<span dir="rtl">אין מדליקין לא בלכש,
+ולא בחוסן,
+ולא בכלך,
+ולא בפתילת האידן,
+<span style="unicode-bidi: bidi-override; direction: ltr">ולא בפתילת המדבר,
+ולא בירוקה שעל פני המים.
+לא בזפת,
+<span style="unicode-bidi: bidi-override; direction: rtl">ולא בשעווה,
+ולא בשמן קיק,
+ולא בשמן שריפה,
+ולא באליה, </span>
+ולא בחלב.
+נחום המדי אומר, </span>
+מדליקין בחלב מבושל;
+וחכמים אומרים, </span>
+אחד מבושל ואחד שאינו מבושל,
+אין מדליקין בו.
+ </pre>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/263359-4-ref.html b/layout/reftests/bidi/263359-4-ref.html
new file mode 100644
index 000000000..e155f79d4
--- /dev/null
+++ b/layout/reftests/bidi/263359-4-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>change direction of pre with bidi text</title>
+ <meta charset="UTF-8">
+ </head>
+ <body>
+ <pre dir="rtl"> can_be_executable=TRUE
+ [he]description=סוג לא ידוע
+ description=Unknown type
+ [ar]description=نوع غير معروف
+ [az]description=Namə'lum növ
+</pre>
+</body>
+</html>
+
diff --git a/layout/reftests/bidi/263359-4.html b/layout/reftests/bidi/263359-4.html
new file mode 100644
index 000000000..d766c862c
--- /dev/null
+++ b/layout/reftests/bidi/263359-4.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>change direction of pre with bidi text</title>
+ <meta charset="UTF-8">
+<script type="text/javascript">
+
+function boom()
+{
+ document.getElementById("w").style.direction="rtl";
+}
+
+</script>
+ </head>
+ <body onload="boom();">
+ <pre id="w"> can_be_executable=TRUE
+ [he]description=סוג לא ידוע
+ description=Unknown type
+ [ar]description=نوع غير معروف
+ [az]description=Namə'lum növ
+</pre>
+</body>
+</html>
+
diff --git a/layout/reftests/bidi/267459-1-ref.html b/layout/reftests/bidi/267459-1-ref.html
new file mode 100644
index 000000000..467a4eb44
--- /dev/null
+++ b/layout/reftests/bidi/267459-1-ref.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Test unicode-bidi in form controls</title>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ </head>
+ <body>
+ <p dir="rtl">&#x202e;This paragraph should appear backwards&#x202c;</p>
+ <p>
+ <textarea rows="3" cols="80" dir="rtl" style="resize:none">&#x202e;This textarea should appear backwards&#x202c;</textarea><br>
+ <input type="text" size="80" dir="rtl" value="&#x202e;This input should appear backwards&#x202c;"><br>
+ <input type="button" dir="rtl" value="&#x202e;This button should appear backwards&#x202c;"><br>
+ <select dir="rtl" size="6">
+ <option selected>&#x202e;This&#x202c;</option>
+ <optgroup label="&#x202e;select&#x202c;">
+ <option>&#x202e;should&#x202c;</option>
+ <option>&#x202e;appear&#x202c;</option>
+ </optgroup>
+ <optgroup label="&#x202e;backwards&#x202c;">
+ <option>&#x202e;throughout&#x202c;</option>
+ </optgroup>
+ </select><br>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/267459-1.html b/layout/reftests/bidi/267459-1.html
new file mode 100644
index 000000000..5caf199f0
--- /dev/null
+++ b/layout/reftests/bidi/267459-1.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Test unicode-bidi in form controls</title>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+ .reversed {
+ direction: rtl;
+ unicode-bidi: bidi-override;
+ }
+ </style>
+ </head>
+ <body>
+ <p class="reversed">This paragraph should appear backwards</p>
+ <p>
+ <textarea class="reversed" rows="3" cols="80" style="resize:none">This textarea should appear backwards</textarea><br>
+ <input class="reversed" type="text" size="80" value="This input should appear backwards"><br>
+ <input class="reversed" type="button" value="This button should appear backwards"><br>
+ <select size="6" class="reversed">
+ <option selected class="reversed">This</option>
+ <optgroup class="reversed" label="select">
+ <option class="reversed">should</option>
+ <option class="reversed">appear</option>
+ </optgroup>
+ <optgroup class="reversed" label="backwards">
+ <option class="reversed">throughout</option>
+ </optgroup>
+ </select><br>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/267459-2-ref.html b/layout/reftests/bidi/267459-2-ref.html
new file mode 100644
index 000000000..e2a023b53
--- /dev/null
+++ b/layout/reftests/bidi/267459-2-ref.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Test unicode-bidi in form controls</title>
+ <meta http-equiv="Content-type" content="text/html; charset=iso-8859-8-i">
+ </head>
+ <body>
+ <p>&#x202d; &#x202c;</p>
+ <p>
+ <textarea rows="3" cols="80"> </textarea><br>
+ <input type="text" size="80" value=" "><br>
+ <input type="button" value=" "><br>
+ <select size="6">
+ <option selected></option>
+ <optgroup label="">
+ <option></option>
+ <option></option>
+ </optgroup>
+ <optgroup label="">
+ <option></option>
+ </optgroup>
+ </select><br>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/267459-2.html b/layout/reftests/bidi/267459-2.html
new file mode 100644
index 000000000..9529b32b0
--- /dev/null
+++ b/layout/reftests/bidi/267459-2.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Test unicode-bidi in form controls</title>
+ <meta http-equiv="Content-type" content="text/html; charset=iso-8859-8">
+ </head>
+ <body>
+ <p> </p>
+ <p>
+ <textarea rows="3" cols="80"> </textarea><br>
+ <input type="text" size="80" value=" "><br>
+ <input type="button" value=" "><br>
+ <select size="6">
+ <option selected></option>
+ <optgroup label="">
+ <option></option>
+ <option></option>
+ </optgroup>
+ <optgroup label="">
+ <option></option>
+ </optgroup>
+ </select><br>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/299065-1-ref.html b/layout/reftests/bidi/299065-1-ref.html
new file mode 100644
index 000000000..e836a04d1
--- /dev/null
+++ b/layout/reftests/bidi/299065-1-ref.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>Testcase, bug 299065</title>
+ <style type="text/css">
+ p { border: thin solid; background: aqua; color: blue; }
+ span { background: yellow; color: olive; }
+ </style>
+ </head>
+ <body>
+ <p>AA<span>AA</span><span>&#x5D0;&#x5D0;</span>&#x5D0;&#x5D0;</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/299065-1.html b/layout/reftests/bidi/299065-1.html
new file mode 100644
index 000000000..ca5583027
--- /dev/null
+++ b/layout/reftests/bidi/299065-1.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>Testcase, bug 299065</title>
+ <style type="text/css">
+ p { border: thin solid; background: aqua; color: blue; }
+ span { background: yellow; color: olive; }
+ </style>
+ </head>
+ <body>
+ <p>AA<span>AA&#x5D0;&#x5D0;</span>&#x5D0;&#x5D0;</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/305643-1-ref.html b/layout/reftests/bidi/305643-1-ref.html
new file mode 100644
index 000000000..ff8f06414
--- /dev/null
+++ b/layout/reftests/bidi/305643-1-ref.html
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="iso-8859-8-i">
+ </head>
+ <body>
+ <table>
+ <tbody>
+ <tr>
+ <td dir="rtl" align="right">
+ <span style="unicode-bidi: bidi-override; font-size: 12px;">(: 20:52) : </span>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/305643-1.html b/layout/reftests/bidi/305643-1.html
new file mode 100644
index 000000000..85562ab34
--- /dev/null
+++ b/layout/reftests/bidi/305643-1.html
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="iso-8859-8">
+ </head>
+ <body>
+ <table>
+ <tbody>
+ <tr>
+ <td dir="rtl" align="right">
+ <span style="font-size: 12px;">(: 20:52) : </span>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/332655-1-ref.html b/layout/reftests/bidi/332655-1-ref.html
new file mode 100644
index 000000000..b4ea71bb1
--- /dev/null
+++ b/layout/reftests/bidi/332655-1-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+<style type="text/css">
+#q { outline: 1px dotted; }
+</style>
+</head>
+
+<body><p><span id="q">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas volutpat. Duis purus lectus, hendrerit vitae, blandit ac, tristique quis, neque. Cras a nisl. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In consectetuer lorem sit amet quam facilisis mollis. Etiam dolor. Donec elementum leo in ligula. Duis lacus diam, sodales vitae, rutrum a, feugiat non, tortor. Maecenas cursus lobortis diam. Mauris in pede eu purus ultricies vehicula. עברית</span></p>
+</body></html>
diff --git a/layout/reftests/bidi/332655-1.html b/layout/reftests/bidi/332655-1.html
new file mode 100644
index 000000000..324b682bb
--- /dev/null
+++ b/layout/reftests/bidi/332655-1.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+<script type="text/javascript">
+
+function boom()
+{
+ document.getElementById("q").style.outline="1px dotted";
+}
+
+</script>
+</head>
+
+<body onload="boom();"><p><span id="q">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas volutpat. Duis purus lectus, hendrerit vitae, blandit ac, tristique quis, neque. Cras a nisl. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In consectetuer lorem sit amet quam facilisis mollis. Etiam dolor. Donec elementum leo in ligula. Duis lacus diam, sodales vitae, rutrum a, feugiat non, tortor. Maecenas cursus lobortis diam. Mauris in pede eu purus ultricies vehicula. עברית</span></p>
+</body></html>
diff --git a/layout/reftests/bidi/332655-2-ref.html b/layout/reftests/bidi/332655-2-ref.html
new file mode 100644
index 000000000..9f7a9b3e6
--- /dev/null
+++ b/layout/reftests/bidi/332655-2-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+<style type="text/css">
+#q { outline: 1px dotted; }
+</style>
+</head>
+
+<body><p><span id="q">עברית Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas volutpat. Duis purus lectus, hendrerit vitae, blandit ac, tristique quis, neque. Cras a nisl. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In consectetuer lorem sit amet quam facilisis mollis. Etiam dolor. Donec elementum leo in ligula. Duis lacus diam, sodales vitae, rutrum a, feugiat non, tortor. Maecenas cursus lobortis diam. Mauris in pede eu purus ultricies vehicula.</span></p>
+</body></html>
diff --git a/layout/reftests/bidi/332655-2.html b/layout/reftests/bidi/332655-2.html
new file mode 100644
index 000000000..fcffcd015
--- /dev/null
+++ b/layout/reftests/bidi/332655-2.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+<script type="text/javascript">
+
+function boom()
+{
+ document.getElementById("q").style.outline="1px dotted";
+}
+
+</script>
+</head>
+
+<body onload="boom();"><p><span id="q">עברית Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas volutpat. Duis purus lectus, hendrerit vitae, blandit ac, tristique quis, neque. Cras a nisl. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In consectetuer lorem sit amet quam facilisis mollis. Etiam dolor. Donec elementum leo in ligula. Duis lacus diam, sodales vitae, rutrum a, feugiat non, tortor. Maecenas cursus lobortis diam. Mauris in pede eu purus ultricies vehicula.</span></p>
+</body></html>
diff --git a/layout/reftests/bidi/381279-1-ref.html b/layout/reftests/bidi/381279-1-ref.html
new file mode 100644
index 000000000..7a085dffd
--- /dev/null
+++ b/layout/reftests/bidi/381279-1-ref.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+<style>
+div {
+ border: 1px solid black;
+ font-family: monospace;
+ width: 10ch;
+}
+</style>
+</head>
+
+<body>
+<div>
+ <span style="direction: rtl;">
+ <span style="unicode-bidi: bidi-override; color: blue;">abcd abcd abcd</span>
+ foo
+ </span>
+</div>
+</body>
+
+</html>
diff --git a/layout/reftests/bidi/381279-1.html b/layout/reftests/bidi/381279-1.html
new file mode 100644
index 000000000..89d3f18a3
--- /dev/null
+++ b/layout/reftests/bidi/381279-1.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+<style>
+div {
+ border: 1px solid black;
+ font-family: monospace;
+ width: 10ch;
+}
+</style>
+</head>
+
+<body onload="document.getElementById('r').style.direction = 'rtl';">
+<div>
+ <span id="r">
+ <span style="unicode-bidi: bidi-override; color: blue;">abcd abcd abcd</span>
+ foo
+ </span>
+</div>
+</body>
+
+</html>
diff --git a/layout/reftests/bidi/386339-ref.html b/layout/reftests/bidi/386339-ref.html
new file mode 100644
index 000000000..b3002d005
--- /dev/null
+++ b/layout/reftests/bidi/386339-ref.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ </head>
+ <body>
+ <table border="1">
+ <tbody>
+ <tr><th colspan="5">Symmetric characters with mirrored glyphs</th></tr>
+ <tr>
+ <td>U003C</td>
+ <td>LESS-THAN SIGN</td>
+ <td dir="rtl">א &lrm;|&gt;|&lrm; ב</td>
+ <td>a &lrm;|&lt;|&lrm; b</td>
+ <td dir="rtl">ا &lrm;|&gt;|&lrm; ب</td>
+ </tr>
+ <tr>
+ <td>U00AB</td>
+ <td>LEFT-POINTING DOUBLE ANGLE QUOTATION MARK</td>
+ <td dir="rtl">א &lrm;|»|&lrm; ב</td>
+ <td>a &lrm;|«|&lrm; b</td>
+ <td dir="rtl">ا &lrm;|»|&lrm; ب</td>
+ </tr>
+ <tr>
+ <td>U2039</td>
+ <td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK</td>
+ <td dir="rtl">א &lrm;|›|&lrm; ב</td>
+ <td>a &lrm;|‹|&lrm; b</td>
+ <td dir="rtl">ا &lrm;|›|&lrm; ب</td>
+ </tr>
+ </tbody>
+ </table>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/386339.html b/layout/reftests/bidi/386339.html
new file mode 100644
index 000000000..0746e1ce1
--- /dev/null
+++ b/layout/reftests/bidi/386339.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ </head>
+ <body>
+ <table border="1">
+ <tbody>
+ <tr><th colspan="5">Symmetric characters with mirrored glyphs</th></tr>
+ <!-- NOTE: vertical bars (which do not affect the mirroring)
+ added to work around vertical ClearType clipping at tips
+ of diagonal lines; see bug 559879. -->
+ <tr>
+ <td>U003C</td>
+ <td>LESS-THAN SIGN</td>
+ <td dir="rtl">א |&lt;| ב</td>
+ <td>a |&lt;| b</td>
+ <td dir="rtl">ا |&lt;| ب</td>
+ </tr>
+ <tr>
+ <td>U00AB</td>
+ <td>LEFT-POINTING DOUBLE ANGLE QUOTATION MARK</td>
+ <td dir="rtl">א |«| ב</td>
+ <td>a |«| b</td>
+ <td dir="rtl">ا |«| ب</td>
+ </tr>
+ <tr>
+ <td>U2039</td>
+ <td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK</td>
+ <td dir="rtl">א |‹| ב</td>
+ <td>a |‹| b</td>
+ <td dir="rtl">ا |‹| ب</td>
+ </tr>
+ </tbody>
+ </table>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/409375-ref.html b/layout/reftests/bidi/409375-ref.html
new file mode 100644
index 000000000..4b05ab2a1
--- /dev/null
+++ b/layout/reftests/bidi/409375-ref.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ </head>
+ <body>
+ <div dir="rtl">
+ <pre>
+
+English
+
+ </pre>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/409375.html b/layout/reftests/bidi/409375.html
new file mode 100644
index 000000000..ca8e99871
--- /dev/null
+++ b/layout/reftests/bidi/409375.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ </head>
+ <body onload="document.getElementById('div').style.direction = 'rtl';">
+ <div id="div">
+ <pre>
+
+English
+
+ </pre>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/413542-1-ref.html b/layout/reftests/bidi/413542-1-ref.html
new file mode 100644
index 000000000..63bb8f3c6
--- /dev/null
+++ b/layout/reftests/bidi/413542-1-ref.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Percentage padding on inlines ignored in presence of certain characters in source</title>
+ <style type="text/css">
+#test {
+ border: 1px solid #000;
+ width: 500px;
+}
+#test span {
+ border: 1px solid #f00;
+ padding: 0 10%;
+}
+ </style>
+ </head>
+ <body>
+ <div id="test"><span>one</span><span>two</span></div>
+ </body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/413542-1.html b/layout/reftests/bidi/413542-1.html
new file mode 100644
index 000000000..663818995
--- /dev/null
+++ b/layout/reftests/bidi/413542-1.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Percentage padding on inlines ignored in presence of certain characters in source</title>
+ <style type="text/css">
+#test {
+ border: 1px solid #000;
+ width: 500px;
+}
+#test span {
+ border: 1px solid #f00;
+ padding: 0 10%;
+}
+ </style>
+ </head>
+ <body>
+<!-- To enable bidi: א -->
+ <div id="test"><span>one</span><span>two</span></div>
+ </body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/413542-2-ref.html b/layout/reftests/bidi/413542-2-ref.html
new file mode 100644
index 000000000..606dd7433
--- /dev/null
+++ b/layout/reftests/bidi/413542-2-ref.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Percentage margin on inlines ignored in presence of certain characters in source</title>
+ <style type="text/css">
+#test {
+ border: 1px solid #000;
+ width: 500px;
+}
+#test span {
+ border: 1px solid #f00;
+ margin: 0 10%;
+}
+ </style>
+ </head>
+ <body>
+ <div id="test"><span>one</span><span>two</span></div>
+ </body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/413542-2.html b/layout/reftests/bidi/413542-2.html
new file mode 100644
index 000000000..872d889a2
--- /dev/null
+++ b/layout/reftests/bidi/413542-2.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Percentage margin on inlines ignored in presence of certain characters in source</title>
+ <style type="text/css">
+#test {
+ border: 1px solid #000;
+ width: 500px;
+}
+#test span {
+ border: 1px solid #f00;
+ margin: 0 10%;
+}
+ </style>
+ </head>
+ <body>
+<!-- To enable bidi: א -->
+ <div id="test"><span>one</span><span>two</span></div>
+ </body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/413928-1-ref.html b/layout/reftests/bidi/413928-1-ref.html
new file mode 100644
index 000000000..e8679fcc8
--- /dev/null
+++ b/layout/reftests/bidi/413928-1-ref.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
+ <title>Bug 413928</title>
+ <style type="text/css">
+.li {
+ line-height: 2em;
+}
+.list-number-he {
+ direction: rtl;
+ unicode-bidi: bidi-override;
+}
+ </style>
+ </head>
+ <body>
+ <div class="li"><span class="list-number">-3.</span></div>
+ <div class="li"><span class="list-number">-2.</span></div>
+ <div class="li"><span class="list-number">-1.</span></div>
+ <div class="li"><span class="list-number">0.</span></div>
+ <div class="li"><span class="list-number-he">.א</span></div>
+ <div class="li"><span class="list-number-he">.ב</span></div>
+ <div class="li"><span class="list-number-he">.ג</span></div>
+ <div class="li"><span class="list-number-he">.ד</span></div>
+ <div class="li"><span class="list-number-he">.ה</span></div>
+ <div class="li"><span class="list-number-he">.יד</span></div>
+ <div class="li"><span class="list-number-he">.טו</span></div>
+ <div class="li"><span class="list-number-he">.טז</span></div>
+ <div class="li"><span class="list-number-he">.יז</span></div>
+ <div class="li"><span class="list-number-he">.צז</span></div>
+ <div class="li"><span class="list-number-he">.צח</span></div>
+ <div class="li"><span class="list-number-he">.צט</span></div>
+ <div class="li"><span class="list-number-he">.ק</span></div>
+ <div class="li"><span class="list-number-he">.קא</span></div>
+ <div class="li"><span class="list-number-he">.תתקמד</span></div>
+ <div class="li"><span class="list-number-he">.תתקמה</span></div>
+ <div class="li"><span class="list-number-he">.תתקמו</span></div>
+ <div class="li"><span class="list-number-he">.תתקצט</span></div>
+ <div class="li"><span class="list-number-he">.א׳</span></div>
+ <div class="li"><span class="list-number-he">.א׳א</span></div>
+ <div class="li"><span class="list-number-he">.א׳תתקצח</span></div>
+ <div class="li"><span class="list-number-he">.א׳תתקצט</span></div>
+ <div class="li"><span class="list-number-he">.ב׳</span></div>
+ <div class="li"><span class="list-number-he">.ב׳א</span></div>
+ <div class="li"><span class="list-number-he">.ב׳ג</span></div>
+ <div class="li"><span class="list-number-he">.ב׳תשמח</span></div>
+ <div class="li"><span class="list-number-he">.ב׳תשנ</span></div>
+ <div class="li"><span class="list-number">1000000.</span></div>
+ <div class="li"><span class="list-number">1500000.</span></div>
+ <div class="li"><span class="list-number">2000000.</span></div>
+ <div class="li"><span class="list-number">9999999.</span></div>
+ <div class="li"><span class="list-number">10000212.</span></div>
+ <div class="li"><span class="list-number">10000425.</span></div>
+ <div class="li"><span class="list-number">10000851.</span></div>
+ <div class="li"><span class="list-number">10001064.</span></div>
+ <div class="li"><span class="list-number">10001277.</span></div>
+ </body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/413928-1.html b/layout/reftests/bidi/413928-1.html
new file mode 100644
index 000000000..de722d606
--- /dev/null
+++ b/layout/reftests/bidi/413928-1.html
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
+ <title>Bug 413928</title>
+ <style type="text/css">
+ ol {
+ list-style-type: hebrew;
+ list-style-position: inside;
+ padding: 0;
+ margin: 0;
+}
+
+ li {
+ line-height: 2em;
+}
+ </style>
+ </head>
+ <body>
+ <ol start="-3">
+ <li></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li value="14"></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li value="97"></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li value="944"></li>
+ <li></li>
+ <li></li>
+ <li value="999"></li>
+ <li></li>
+ <li></li>
+ <li value="1998"></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li value="2003"></li>
+ <li value="2748"></li>
+ <li value="2750"></li>
+ <li value="1000000"></li>
+ <li value="1500000"></li>
+ <li value="2000000"></li>
+ <li value="9999999"></li>
+ <li value="10000212"></li>
+ <li value="10000425"></li>
+ <li value="10000851"></li>
+ <li value="10001064"></li>
+ <li value="10001277"></li>
+ </ol>
+ </body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/413928-2-ref.html b/layout/reftests/bidi/413928-2-ref.html
new file mode 100644
index 000000000..5cd9cd76a
--- /dev/null
+++ b/layout/reftests/bidi/413928-2-ref.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
+ <title>Bug 413928</title>
+ <style type="text/css">
+.li {
+ line-height: 2em;
+}
+.list-number-he {
+ direction: rtl;
+ unicode-bidi: bidi-override;
+}
+ </style>
+ </head>
+ <body dir="rtl">
+ <div class="li"><span class="list-number">&lrm;-3.</span></div>
+ <div class="li"><span class="list-number">&lrm;-2.</span></div>
+ <div class="li"><span class="list-number">&lrm;-1.</span></div>
+ <div class="li"><span class="list-number">0.</span></div>
+ <div class="li"><span class="list-number-he">א.</span></div>
+ <div class="li"><span class="list-number-he">ב.</span></div>
+ <div class="li"><span class="list-number-he">ג.</span></div>
+ <div class="li"><span class="list-number-he">ד.</span></div>
+ <div class="li"><span class="list-number-he">ה.</span></div>
+ <div class="li"><span class="list-number-he">יד.</span></div>
+ <div class="li"><span class="list-number-he">טו.</span></div>
+ <div class="li"><span class="list-number-he">טז.</span></div>
+ <div class="li"><span class="list-number-he">יז.</span></div>
+ <div class="li"><span class="list-number-he">צז.</span></div>
+ <div class="li"><span class="list-number-he">צח.</span></div>
+ <div class="li"><span class="list-number-he">צט.</span></div>
+ <div class="li"><span class="list-number-he">ק.</span></div>
+ <div class="li"><span class="list-number-he">קא.</span></div>
+ <div class="li"><span class="list-number-he">תתקמד.</span></div>
+ <div class="li"><span class="list-number-he">תתקמה.</span></div>
+ <div class="li"><span class="list-number-he">תתקמו.</span></div>
+ <div class="li"><span class="list-number-he">תתקצט.</span></div>
+ <div class="li"><span class="list-number-he">א׳.</span></div>
+ <div class="li"><span class="list-number-he">א׳א.</span></div>
+ <div class="li"><span class="list-number-he">א׳תתקצח.</span></div>
+ <div class="li"><span class="list-number-he">א׳תתקצט.</span></div>
+ <div class="li"><span class="list-number-he">ב׳.</span></div>
+ <div class="li"><span class="list-number-he">ב׳א.</span></div>
+ <div class="li"><span class="list-number-he">ב׳ג.</span></div>
+ <div class="li"><span class="list-number-he">ב׳תשמח.</span></div>
+ <div class="li"><span class="list-number-he">ב׳תשנ.</span></div>
+ <div class="li"><span class="list-number">1000000.</span></div>
+ <div class="li"><span class="list-number">1500000.</span></div>
+ <div class="li"><span class="list-number">2000000.</span></div>
+ <div class="li"><span class="list-number">9999999.</span></div>
+ <div class="li"><span class="list-number">10000212.</span></div>
+ <div class="li"><span class="list-number">10000425.</span></div>
+ <div class="li"><span class="list-number">10000851.</span></div>
+ <div class="li"><span class="list-number">10001064.</span></div>
+ <div class="li"><span class="list-number">10001277.</span></div>
+ </body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/413928-2.html b/layout/reftests/bidi/413928-2.html
new file mode 100644
index 000000000..a81e92c44
--- /dev/null
+++ b/layout/reftests/bidi/413928-2.html
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
+ <title>Bug 413928</title>
+ <style type="text/css">
+ ol {
+ list-style-type: hebrew;
+ list-style-position: inside;
+ padding: 0;
+ margin: 0;
+}
+
+ li {
+ line-height: 2em;
+}
+ </style>
+ </head>
+ <body dir="rtl">
+ <ol start="-3">
+ <li></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li value="14"></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li value="97"></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li value="944"></li>
+ <li></li>
+ <li></li>
+ <li value="999"></li>
+ <li></li>
+ <li></li>
+ <li value="1998"></li>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li value="2003"></li>
+ <li value="2748"></li>
+ <li value="2750"></li>
+ <li value="1000000"></li>
+ <li value="1500000"></li>
+ <li value="2000000"></li>
+ <li value="9999999"></li>
+ <li value="10000212"></li>
+ <li value="10000425"></li>
+ <li value="10000851"></li>
+ <li value="10001064"></li>
+ <li value="10001277"></li>
+ </ol>
+ </body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/425338-1-ref.html b/layout/reftests/bidi/425338-1-ref.html
new file mode 100644
index 000000000..083522962
--- /dev/null
+++ b/layout/reftests/bidi/425338-1-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+<span id="a"><span>a</span>b<span>א</span>c</span>
+</body>
+</html>
diff --git a/layout/reftests/bidi/425338-1a.html b/layout/reftests/bidi/425338-1a.html
new file mode 100644
index 000000000..70b55cb3c
--- /dev/null
+++ b/layout/reftests/bidi/425338-1a.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+<script type="text/javascript">
+function c()
+{
+ document.getElementById("a").style.height = "10em";
+}
+</script>
+</head>
+<body onload="c();">
+<span id="a"><span>a</span>b<span>א</span>c</span>
+</body>
+</html>
diff --git a/layout/reftests/bidi/425338-1b.html b/layout/reftests/bidi/425338-1b.html
new file mode 100644
index 000000000..7d3e063c9
--- /dev/null
+++ b/layout/reftests/bidi/425338-1b.html
@@ -0,0 +1,16 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+<script type="text/javascript">
+function c()
+{
+ document.getElementById("a").style.height = "10em";
+ document.body.offsetHeight;
+ document.getElementById("a").style.height = "";
+}
+</script>
+</head>
+<body onload="c();">
+<span id="a"><span>a</span>b<span>א</span>c</span>
+</body>
+</html>
diff --git a/layout/reftests/bidi/489517-1-ref.html b/layout/reftests/bidi/489517-1-ref.html
new file mode 100644
index 000000000..c49a11f74
--- /dev/null
+++ b/layout/reftests/bidi/489517-1-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style type="text/css">
+.flipped { direction: rtl; unicode-bidi: bidi-override; }
+</style>
+</head>
+
+<body><div class="flipped">AB</div>
+</body>
+</html>
diff --git a/layout/reftests/bidi/489517-1.html b/layout/reftests/bidi/489517-1.html
new file mode 100644
index 000000000..95295549b
--- /dev/null
+++ b/layout/reftests/bidi/489517-1.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style type="text/css">
+.flipped { direction: rtl; unicode-bidi: bidi-override; }
+</style>
+
+<script type="text/javascript">
+
+function boom()
+{
+ document.getElementById("outer").className = "flipped";
+}
+
+</script>
+</head>
+
+<body onload="boom();"><div id="outer">AB</div>
+</body>
+</html>
diff --git a/layout/reftests/bidi/489887-1-ref.html b/layout/reftests/bidi/489887-1-ref.html
new file mode 100644
index 000000000..314d694be
--- /dev/null
+++ b/layout/reftests/bidi/489887-1-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type="text/javascript">
+function boom()
+{
+ document.getElementById("w").firstChild.data = "";
+
+}
+</script>
+</head>
+<body onload="boom();">
+<div><span>&#x06cd;</span><span id="w"> </span><span>&#x06cb;</span></div>
+</body>
+</html>
diff --git a/layout/reftests/bidi/489887-1.html b/layout/reftests/bidi/489887-1.html
new file mode 100644
index 000000000..9bff09672
--- /dev/null
+++ b/layout/reftests/bidi/489887-1.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type="text/javascript">
+function boom()
+{
+ document.getElementById("w").firstChild.data = "";
+ document.documentElement.appendChild(document.body);
+}
+</script>
+</head>
+<body onload="boom();">
+<div><span>&#x06cd;</span><span id="w"> </span><span>&#x06cb;</span></div>
+</body>
+</html>
diff --git a/layout/reftests/bidi/492231-1-ref.html b/layout/reftests/bidi/492231-1-ref.html
new file mode 100644
index 000000000..3d276bff1
--- /dev/null
+++ b/layout/reftests/bidi/492231-1-ref.html
@@ -0,0 +1,7 @@
+<!DOCTYPE HTML>
+<html>
+<head><meta charset="iso-8859-8"></head>
+<body style="direction: rtl;">
+<span>+&#x05E9;</span>
+</body>
+</html>
diff --git a/layout/reftests/bidi/492231-1.html b/layout/reftests/bidi/492231-1.html
new file mode 100644
index 000000000..04ac87374
--- /dev/null
+++ b/layout/reftests/bidi/492231-1.html
@@ -0,0 +1,7 @@
+<!DOCTYPE HTML>
+<html>
+<head><meta charset="iso-8859-8"></head>
+<body onload="document.body.style.direction = 'rtl';">
+<span>+&#x05E9;</span>
+</body>
+</html>
diff --git a/layout/reftests/bidi/496006-1-ref.html b/layout/reftests/bidi/496006-1-ref.html
new file mode 100644
index 000000000..704befb66
--- /dev/null
+++ b/layout/reftests/bidi/496006-1-ref.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+</head>
+<body style="direction: rtl;">
+m
+<span id="a" style="border: 1px solid black"></span>
+<div></div>
+m
+</body>
+</html>
diff --git a/layout/reftests/bidi/496006-1.html b/layout/reftests/bidi/496006-1.html
new file mode 100644
index 000000000..5629fa4ea
--- /dev/null
+++ b/layout/reftests/bidi/496006-1.html
@@ -0,0 +1,21 @@
+<html class="reftest-wait">
+<head>
+</head>
+<body style="direction: rtl;">
+m
+<span id="a" style="border: 1px solid black;"></span>
+<div><script>document.body.offsetHeight;</script></div>
+m
+
+<script>
+function doe() {
+var a=document.getElementById('a');
+a.style.outline = '1px solid transparent';
+document.body.offsetHeight;
+a.style.outline = '';
+document.documentElement.removeAttribute('class');
+}
+setTimeout(doe, 500);
+</script>
+</body>
+</html>
diff --git a/layout/reftests/bidi/503269-1-ref.html b/layout/reftests/bidi/503269-1-ref.html
new file mode 100644
index 000000000..c9401fd85
--- /dev/null
+++ b/layout/reftests/bidi/503269-1-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <title>Welcome to Flickr!</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ </head>
+ <body>
+ <div>
+ <ul>
+ <li><span><a href="/photos/foo/" title="مسجد قبة الصخرة by Yaqut"><img src="/foo.jpg" width="75" height="75" alt="مسجد قبة الصخرة by Yaqut"></a></span><div>From <a href="/photos/yaqut/" title="Yaqut">Yaqut</a></div></li>
+ <li><span><a href="/photos/bar/" title="מערכת שליחת ההודעות באתר אורנג עובדת בפיירפוקס - מזל טוב!"><img src="/bar.jpg" width="75" height="75" alt="מערכת שליחת ההודעות באתר אורנג עובדת בפיירפוקס - מזל טוב! by MosheOofnik"></a></span><div>From <a href="/photos/mosheoofnik/" title="MosheOofnik">Moshe Oofnik</a></div></li>
+ <li><span><a href="/photos/baz/" title="Fruit Basket by Elmo"><img src="/baz.jpg" width="75" height="75" alt="Fruit Basket by Elmo"></a></span><div>From <a href="/photos/elmo/" title="Elmo">Elmo</a></div></li>
+ </ul>&rlm;
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/503269-1.html b/layout/reftests/bidi/503269-1.html
new file mode 100644
index 000000000..c08989e09
--- /dev/null
+++ b/layout/reftests/bidi/503269-1.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <title>Welcome to Flickr!</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ </head>
+ <body>
+ <div>
+ <ul>
+ <li><span><a href="/photos/foo/" title="مسجد قبة الصخرة by Yaqut"><img src="/foo.jpg" width="75" height="75" alt="مسجد قبة الصخرة by Yaqut"></a></span><div>From <a href="/photos/yaqut/" title="Yaqut">Yaqut</a></div></li>
+ <li><span><a href="/photos/bar/" title="מערכת שליחת ההודעות באתר אורנג עובדת בפיירפוקס - מזל טוב!"><img src="/bar.jpg" width="75" height="75" alt="מערכת שליחת ההודעות באתר אורנג עובדת בפיירפוקס - מזל טוב! by MosheOofnik"></a></span><div>From <a href="/photos/mosheoofnik/" title="MosheOofnik">Moshe Oofnik</a></div></li>
+ <li><span><a href="/photos/baz/" title="Fruit Basket by Elmo"><img src="/baz.jpg" width="75" height="75" alt="Fruit Basket by Elmo"></a></span><div>From <a href="/photos/elmo/" title="Elmo">Elmo</a></div></li>
+ </ul>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/503957-1-ref.html b/layout/reftests/bidi/503957-1-ref.html
new file mode 100644
index 000000000..4f6a43c1a
--- /dev/null
+++ b/layout/reftests/bidi/503957-1-ref.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html dir="rtl">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>Test Page</title>
+ <style type="text/css">
+ span {
+ margin: 1em;
+ }
+ </style>
+ </head>
+ <body>
+ <p>
+ <span dir="rtl">אתר התוספות של Mozilla</span>
+ <span dir="rtl">one</span>
+ <span dir="rtl">two</span>
+ <span dir="rtl">three</span>
+ </p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/503957-1.html b/layout/reftests/bidi/503957-1.html
new file mode 100644
index 000000000..f06bea794
--- /dev/null
+++ b/layout/reftests/bidi/503957-1.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html dir="rtl">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>Test Page</title>
+ <style type="text/css">
+ ol li {
+ display: inline;
+ margin: 1em;
+ }
+ ol {
+ padding-inline-start: 0px;
+ }
+ </style>
+ </head>
+ <body>
+ <ol>
+ <li>אתר התוספות של Mozilla</li>
+ <li>one</li>
+ <li>two</li>
+ <li>three</li>
+ </ol>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/525740-1-ref.html b/layout/reftests/bidi/525740-1-ref.html
new file mode 100644
index 000000000..0de424fbd
--- /dev/null
+++ b/layout/reftests/bidi/525740-1-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <style type="text/css">
+ div:first-letter { float: right; color: lime; }
+ </style>
+ </head>
+ <body dir="rtl">
+ <div>ab &#x06CD; c</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/525740-1.html b/layout/reftests/bidi/525740-1.html
new file mode 100644
index 000000000..45fd1a453
--- /dev/null
+++ b/layout/reftests/bidi/525740-1.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <style type="text/css">
+ div:first-letter { float: right; color: lime; }
+ </style>
+ </head>
+ <body dir="rtl">
+ <div><span>ab &#x06CD; c</span></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/536963-1-ref.html b/layout/reftests/bidi/536963-1-ref.html
new file mode 100644
index 000000000..40f7314a7
--- /dev/null
+++ b/layout/reftests/bidi/536963-1-ref.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title>Dynamic bidi bug</title>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <style type="text/css">
+ p { width: 3ch;}
+ </style>
+ </head>
+ <body>
+ <p dir="rtl">0 123 4</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/536963-1.html b/layout/reftests/bidi/536963-1.html
new file mode 100644
index 000000000..dd3169923
--- /dev/null
+++ b/layout/reftests/bidi/536963-1.html
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title>Dynamic bidi bug</title>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <style type="text/css">
+ p { width: 3ch;}
+ </style>
+ <script type="text/javascript">
+function flip()
+{
+ var flipped= document.getElementById('flipped');
+ flipped.dir = "rtl";
+}
+ </script>
+ </head>
+ <body onload="flip()">
+ <p id="flipped">0 123 4</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/562169-1-ref.html b/layout/reftests/bidi/562169-1-ref.html
new file mode 100644
index 000000000..8aded4f76
--- /dev/null
+++ b/layout/reftests/bidi/562169-1-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>dir() selector</title>
+ <style>
+ .blue { color: blue; direction: ltr; }
+ .lime { color: lime; direction: rtl; }
+ div { text-align: left; }
+ </style>
+ </head>
+ <body>
+ <div class="blue">This element has default direction.</div>
+ <div class="blue">This element is ltr.</div>
+ <div class="lime">This element is rtl.</div>
+ <div class="blue">
+ <div>This element should inherit ltr.</div>
+ <div class="blue">This element is ltr.</div>
+ <div class="lime">This element is rtl.</div>
+ <div class="blue">Every word in this element should inherit ltr.</div>
+ </div>
+ <div class="lime">
+ <div>This element should inherit rtl.</div>
+ <div class="blue">This element is ltr.</div>
+ <div class="lime">This element is rtl.</div>
+ <div class="lime">Every word in this element should inherit rtl.</div>
+ </div>
+ <div class="blue">This element has an invalid dir attribute and
+ should have default direction.</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/562169-1.html b/layout/reftests/bidi/562169-1.html
new file mode 100644
index 000000000..d6cfe554f
--- /dev/null
+++ b/layout/reftests/bidi/562169-1.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>dir() selector</title>
+ <style>
+ :dir(ltr) { color: blue }
+ :dir(rtl) { color: lime }
+ :dir(foopy) { color: red }
+ div { text-align: left; }
+ </style>
+ </head>
+ <body>
+ <div>This element has default direction.</div>
+ <div dir="ltr">This element is ltr.</div>
+ <div dir="rtl">This element is rtl.</div>
+ <div dir="ltr">
+ <div>This element should inherit ltr.</div>
+ <div dir="ltr">This element is ltr.</div>
+ <div dir="rtl">This element is rtl.</div>
+ <div><span>Every <span>word <span>in <span>this <span>element <span>should <span>inherit <span>ltr</span></span></span></span></span></span></span></span>.</div>
+ </div>
+ <div dir="rtl">
+ <div>This element should inherit rtl.</div>
+ <div dir="ltr">This element is ltr.</div>
+ <div dir="rtl">This element is rtl.</div>
+ <div><span>Every <span>word <span>in <span>this <span>element <span>should <span>inherit <span>rtl</span></span></span></span></span></span></span></span>.</div>
+ </div>
+ <div dir="foopy">This element has an invalid dir attribute and
+ should have default direction.</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/562169-1a.html b/layout/reftests/bidi/562169-1a.html
new file mode 100644
index 000000000..f6102951f
--- /dev/null
+++ b/layout/reftests/bidi/562169-1a.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>dir() selector</title>
+ <style>
+ :dir(ltr) { color: blue }
+ :dir(rtl) { color: lime }
+ :dir(foopy) { color: red }
+ div { text-align: left; }
+ </style>
+ <script type="text/javascript">
+function switchDir()
+{
+ divs = document.getElementsByTagName("div");
+ for (var i = 0; i < divs.length; ++i) {
+ theDiv = divs[i];
+ if (theDiv.dir == "ltr") {
+ theDiv.dir = "rtl";
+ } else if (theDiv.dir == "rtl") {
+ theDiv.dir = "ltr";
+ }
+ }
+}
+ </script>
+ </head>
+ <body onload="switchDir()">
+ <div>This element has default direction.</div>
+ <div dir="rtl">This element is ltr.</div>
+ <div dir="ltr">This element is rtl.</div>
+ <div dir="rtl">
+ <div>This element should inherit ltr.</div>
+ <div dir="rtl">This element is ltr.</div>
+ <div dir="ltr">This element is rtl.</div>
+ <div><span>Every <span>word <span>in <span>this <span>element <span>should <span>inherit <span>ltr</span></span></span></span></span></span></span></span>.</div>
+ </div>
+ <div dir="ltr">
+ <div>This element should inherit rtl.</div>
+ <div dir="rtl">This element is ltr.</div>
+ <div dir="ltr">This element is rtl.</div>
+ <div><span>Every <span>word <span>in <span>this <span>element <span>should <span>inherit <span>rtl</span></span></span></span></span></span></span></span>.</div>
+ </div>
+ <div dir="foopy">This element has an invalid dir attribute and
+ should have default direction.</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/562169-2-ref.html b/layout/reftests/bidi/562169-2-ref.html
new file mode 100644
index 000000000..0acc957b1
--- /dev/null
+++ b/layout/reftests/bidi/562169-2-ref.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>dir() selector</title>
+ <style>
+ .blue { color: blue; direction: ltr; }
+ .lime { color: lime; direction: rtl; }
+ div { text-align: left; }
+ </style>
+ </head>
+ <body>
+ <div class="lime">This element has default direction.</div>
+ <div class="blue">This element is ltr.</div>
+ <div class="lime">This element is rtl.</div>
+ <div class="blue">
+ <div>This element should inherit ltr.</div>
+ <div class="blue">This element is ltr.</div>
+ <div class="lime">This element is rtl.</div>
+ </div>
+ <div class="lime">
+ <div>This element should inherit rtl.</div>
+ <div class="blue">This element is ltr.</div>
+ <div class="lime">This element is rtl.</div>
+ </div>
+ <div class="lime">This element has an invalid dir attribute and
+ should have default direction.</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/562169-2.html b/layout/reftests/bidi/562169-2.html
new file mode 100644
index 000000000..cea59a3fe
--- /dev/null
+++ b/layout/reftests/bidi/562169-2.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html dir="rtl">
+ <head>
+ <meta charset="UTF-8">
+ <title>dir() selector</title>
+ <style>
+ :dir(ltr) { color: blue }
+ :dir(rtl) { color: lime }
+ :dir(foopy) { color: red }
+ div { text-align: left; }
+ </style>
+ </head>
+ <body>
+ <div>This element has default direction.</div>
+ <div dir="ltr">This element is ltr.</div>
+ <div dir="rtl">This element is rtl.</div>
+ <div dir="ltr">
+ <div>This element should inherit ltr.</div>
+ <div dir="ltr">This element is ltr.</div>
+ <div dir="rtl">This element is rtl.</div>
+ </div>
+ <div dir="rtl">
+ <div>This element should inherit rtl.</div>
+ <div dir="ltr">This element is ltr.</div>
+ <div dir="rtl">This element is rtl.</div>
+ </div>
+ <div dir="foopy">This element has an invalid dir attribute and
+ should have default direction.</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/562169-2a.html b/layout/reftests/bidi/562169-2a.html
new file mode 100644
index 000000000..3f8044fd0
--- /dev/null
+++ b/layout/reftests/bidi/562169-2a.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>dir() selector</title>
+ <style>
+ :dir(ltr) { color: blue }
+ :dir(rtl) { color: lime }
+ :dir(foopy) { color: red }
+ div { text-align: left; }
+ </style>
+ <script type="text/javascript">
+function switchDir()
+{
+ document.dir = "rtl";
+}
+ </script>
+ </head>
+ <body onload="switchDir()">
+ <div>This element has default direction.</div>
+ <div dir="ltr">This element is ltr.</div>
+ <div dir="rtl">This element is rtl.</div>
+ <div dir="ltr">
+ <div>This element should inherit ltr.</div>
+ <div dir="ltr">This element is ltr.</div>
+ <div dir="rtl">This element is rtl.</div>
+ </div>
+ <div dir="rtl">
+ <div>This element should inherit rtl.</div>
+ <div dir="ltr">This element is ltr.</div>
+ <div dir="rtl">This element is rtl.</div>
+ </div>
+ <div dir="foopy">This element has an invalid dir attribute and
+ should have default direction.</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/562169-3-ref.html b/layout/reftests/bidi/562169-3-ref.html
new file mode 100644
index 000000000..ea848f61a
--- /dev/null
+++ b/layout/reftests/bidi/562169-3-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>dir() selector</title>
+ <style>
+ .ltr { direction: ltr }
+ .rtl { direction: rtl }
+ div { color: lime; text-align: left; }
+ </style>
+ </head>
+ <body>
+ <div class="rtl">This element is rtl.</div>
+ <div>This element has default direction.</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/562169-3.html b/layout/reftests/bidi/562169-3.html
new file mode 100644
index 000000000..422e60827
--- /dev/null
+++ b/layout/reftests/bidi/562169-3.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>dir() selector</title>
+ <style>
+ :not(:dir(rtl)) + div { color: blue }
+ div { color: lime; text-align: left; }
+ </style>
+ </head>
+ <body>
+ <div dir="rtl">This element is rtl.</div>
+ <div>This element has default direction.</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/562169-3a.html b/layout/reftests/bidi/562169-3a.html
new file mode 100644
index 000000000..9df28794a
--- /dev/null
+++ b/layout/reftests/bidi/562169-3a.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>dir() selector</title>
+ <style>
+ :not(:dir(rtl)) + div { color: blue }
+ div { color: lime; text-align: left; }
+ </style>
+ <script type="text/javascript">
+function switchDir()
+{
+ theDiv = document.getElementById("d");
+ if (theDiv.dir == "ltr") {
+ theDiv.dir = "rtl";
+ } else if (theDiv.dir == "rtl") {
+ theDiv.dir = "ltr";
+ }
+}
+ </script>
+ </head>
+ <body onload="switchDir()">
+ <div id="d" dir="ltr">This element is rtl.</div>
+ <div>This element has default direction.</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/562169-4-ref.html b/layout/reftests/bidi/562169-4-ref.html
new file mode 100644
index 000000000..b5cdada97
--- /dev/null
+++ b/layout/reftests/bidi/562169-4-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>dir() selector</title>
+ <style>
+ .lime { direction: rtl; color: lime }
+ div { text-align: left; }
+ </style>
+ </head>
+ <body>
+ <div class="lime">This element is rtl. <span>This span should
+ inherit rtl from the parent. <span>This span should inherit rtl
+ from the grandparent.</span></span></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/562169-4.html b/layout/reftests/bidi/562169-4.html
new file mode 100644
index 000000000..56075adc2
--- /dev/null
+++ b/layout/reftests/bidi/562169-4.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>dir() selector</title>
+ <style>
+ :dir(ltr) { color: blue }
+ :dir(rtl) { color: lime }
+ div { text-align: left; }
+ </style>
+ <script type="text/javascript">
+function AppendElementWithChild() {
+ var x = document.createElement("span");
+ x.innerHTML = "This span should inherit rtl from the parent. ";
+
+ var y = document.createElement("span");
+ y.innerHTML = "This span should inherit rtl from the grandparent.";
+
+ var z = document.getElementById("z");
+
+ x.appendChild(y);
+ z.appendChild(x);
+}
+ </script>
+ </head>
+ <body onload="AppendElementWithChild()">
+ <div id="z" dir="rtl">This element is rtl. </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/588739-1.html b/layout/reftests/bidi/588739-1.html
new file mode 100644
index 000000000..842ee5e05
--- /dev/null
+++ b/layout/reftests/bidi/588739-1.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <style type="text/css">
+ span.page-sep { position:absolute; visibility:hidden; }
+ </style>
+ </head>
+ <body>
+עמוד <span>1<span class="page-sep"></span>2<span class="page-sep"></span>3</span>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/588739-2.html b/layout/reftests/bidi/588739-2.html
new file mode 100644
index 000000000..65592eb16
--- /dev/null
+++ b/layout/reftests/bidi/588739-2.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <style type="text/css">
+ span.page-sep { visibility:hidden; }
+ </style>
+ </head>
+ <body>
+עמוד <span>1<span class="page-sep"></span>2<span class="page-sep"></span>3</span>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/588739-3.html b/layout/reftests/bidi/588739-3.html
new file mode 100644
index 000000000..e309774d7
--- /dev/null
+++ b/layout/reftests/bidi/588739-3.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <style type="text/css">
+ span.page-sep { position:absolute; }
+ </style>
+ </head>
+ <body>
+עמוד <span>1<span class="page-sep"></span>2<span class="page-sep"></span>3</span>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/588739-ref.html b/layout/reftests/bidi/588739-ref.html
new file mode 100644
index 000000000..7cac69a93
--- /dev/null
+++ b/layout/reftests/bidi/588739-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ </head>
+ <body>
+עמוד 321
+ </body>
+</html>
diff --git a/layout/reftests/bidi/612843-1-ref.html b/layout/reftests/bidi/612843-1-ref.html
new file mode 100644
index 000000000..5dab89080
--- /dev/null
+++ b/layout/reftests/bidi/612843-1-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!-- Tests bidi class of U+070F SYRIAC ABBREVIATION MARK -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ </head>
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+}
+ </style
+ <body>
+ <p dir="rtl" style="unicode-bidi: bidi-override;">&#x661;&#x662;&#x60c;&#x070f;&#x071f;&#x0725;</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/612843-1.html b/layout/reftests/bidi/612843-1.html
new file mode 100644
index 000000000..2065322c5
--- /dev/null
+++ b/layout/reftests/bidi/612843-1.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!-- Tests bidi class of U+070F SYRIAC ABBREVIATION MARK -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ </head>
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+}
+ </style
+ <body>
+ <p dir="rtl">&#x662;&#x661;&#x60c;&#x070f;&#x071f;&#x0725;</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/613149-1-ref.html b/layout/reftests/bidi/613149-1-ref.html
new file mode 100644
index 000000000..906a0951d
--- /dev/null
+++ b/layout/reftests/bidi/613149-1-ref.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Bidi isolation - reference</title>
+ <style type="text/css">
+ body { font-family: monospace }
+ p { unicode-bidi: bidi-override; }
+ </style>
+ </head>
+ <body>
+ <p>טאראק 24 בהז הציפ - 3 reviews</p>
+ <p>תובוגת 5 - Joe's לפאלפ Bar :הנושאר הדעסמ</p>
+ <p>תובוגת 5 - Joe's לפאלפ Bar :הנושאר הדעסמ</p>
+ <p>.(position: relative) css-ב שמתשת</p>
+ <p>documents &gt; ילש ןושארה ןמורה &gt; 1 קרפ</p>
+ <p>joe hacker: overdrawn</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/613149-1a.html b/layout/reftests/bidi/613149-1a.html
new file mode 100644
index 000000000..140d70b93
--- /dev/null
+++ b/layout/reftests/bidi/613149-1a.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Bidi isolation - bdi element</title>
+ <!-- Examples from http://www.w3.org/International/docs/html-bidi-requirements/#bidi-isolation -->
+ <style type="text/css">body { font-family: monospace; }</style>
+ </head>
+ <body>
+ <p><bdi>פיצה זהב 24 קאראט</bdi> - 3 reviews</p>
+ <p>מסעדה ראשונה: <bdi dir="ltr">Joe's פלאפל Bar</bdi> - 5 תגובות</p>
+ <p>מסעדה ראשונה: <bdi dir="ltr"><bdo dir="rtl">raB פלאפל s'eoJ</bdo></bdi> - 5 תגובות</p>
+ <p dir="rtl" align="left">תשתמש ב-css (<bdi dir="ltr">position: relative</bdi>).</p>
+ <p>documents &gt; <bdi dir="rtl">הרומן הראשון שלי</bdi> &gt; <bdi dir="rtl">פרק 1</bdi></p>
+ <p><bdi>joe hacker&#x202e;</bdi>: overdrawn</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/613149-1b.html b/layout/reftests/bidi/613149-1b.html
new file mode 100644
index 000000000..9e8218d0a
--- /dev/null
+++ b/layout/reftests/bidi/613149-1b.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Bidi isolation - css</title>
+ <style type="text/css">
+ body { font-family: monospace; }
+ span { unicode-bidi: isolate; }
+ span.override { unicode-bidi: isolate-override; }
+ </style>
+ </head>
+ <body>
+ <p><span>פיצה זהב 24 קאראט</span> - 3 reviews</p>
+ <p>מסעדה ראשונה: <span dir="ltr">Joe's פלאפל Bar</span> - 5 תגובות</p>
+ <p>מסעדה ראשונה: <span class="override" dir="rtl">raB פלאפל s'eoJ</span> - 5 תגובות</p>
+ <p dir="rtl" align="left">תשתמש ב-css (<span dir="ltr">position: relative</span>).</p>
+ <p>documents &gt; <span dir="rtl">הרומן הראשון שלי</span> &gt; <span dir="rtl">פרק 1</span></p>
+ <p><span>joe hacker&#x202e;</span>: overdrawn</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/613149-2-ref.html b/layout/reftests/bidi/613149-2-ref.html
new file mode 100644
index 000000000..7139f8b56
--- /dev/null
+++ b/layout/reftests/bidi/613149-2-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <title>Google Reader minimized test case</title>
+ </head>
+ <body>
+ <div style="font-size: 18pt; unicode-bidi: bidi-override; text-align: right">אסרג ןוכדע רחאל תלגלגב היעב :Mozilla Firefox • Re</div>
+</body></html>
diff --git a/layout/reftests/bidi/613149-2a.html b/layout/reftests/bidi/613149-2a.html
new file mode 100644
index 000000000..3fe56e0b7
--- /dev/null
+++ b/layout/reftests/bidi/613149-2a.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <title>Google Reader minimized test case</title>
+ <style type="text/css">
+ span div {display: inline;}
+ </style>
+ </head>
+ <body>
+ <div style="font-size: 18pt" dir="rtl"><span><div>Mozilla Firefox • Re: בעיה בגלגלת לאחר עדכון גרסא</div></span></div>
+</body></html>
diff --git a/layout/reftests/bidi/613149-2b.html b/layout/reftests/bidi/613149-2b.html
new file mode 100644
index 000000000..074b4326a
--- /dev/null
+++ b/layout/reftests/bidi/613149-2b.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <title>Google Reader minimized test case</title>
+ <style type="text/css">
+ span div {display: inline;}
+ </style>
+ <script type="text/javascript">
+function boom()
+{
+ document.getElementById("d").style.fontWeight="normal";
+}
+ </script>
+ </head>
+ <body onload="boom()">
+ <div dir="rtl"><span><div id="d" style="font-size: 18pt; font-weight: bold;">Mozilla Firefox • Re: בעיה בגלגלת לאחר עדכון גרסא</div></span></div>
+</body></html>
diff --git a/layout/reftests/bidi/613157-1-ref.html b/layout/reftests/bidi/613157-1-ref.html
new file mode 100644
index 000000000..38cc7d062
--- /dev/null
+++ b/layout/reftests/bidi/613157-1-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>block-element-as-bidi-paragraph-break</title>
+ <meta charset="UTF-8">
+ </head>
+ <body>
+ <div>&#x05D0; --&gt;&lrm;<hr>--&gt; &#x05D1;</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/613157-1.html b/layout/reftests/bidi/613157-1.html
new file mode 100644
index 000000000..63948990c
--- /dev/null
+++ b/layout/reftests/bidi/613157-1.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>block-element-as-bidi-paragraph-break</title>
+ <meta charset="UTF-8">
+ </head>
+ <body>
+ <div>&#x05D0; --&gt;<hr>--&gt; &#x05D1;</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/613157-2-ref.html b/layout/reftests/bidi/613157-2-ref.html
new file mode 100644
index 000000000..a41becbea
--- /dev/null
+++ b/layout/reftests/bidi/613157-2-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Inline blocks shouldn't end the paragraph</title>
+ </head>
+ <body>
+ <p>&#x202e;ימים בשבוע 8&lt;-- 4 xoferiF&lt;--אני אוהב</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/613157-2.html b/layout/reftests/bidi/613157-2.html
new file mode 100644
index 000000000..0d635f6f1
--- /dev/null
+++ b/layout/reftests/bidi/613157-2.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Inline blocks shouldn't end the paragraph</title>
+ </head>
+ <body>
+ <p><span dir="rtl">אני אוהב</span>--&gt;<span style="display: inline-block">Firefox 4&nbsp;</span>--&gt;8 ימים בשבוע
+ </p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/662288-1-ref.html b/layout/reftests/bidi/662288-1-ref.html
new file mode 100644
index 000000000..afc16824c
--- /dev/null
+++ b/layout/reftests/bidi/662288-1-ref.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>pre element with auto-direction</title>
+ </head>
+ <body>
+ <pre><div dir="ltr">The word Automaton is the latinization of the Greek
+αὐτόματον,... automaton, (neuter) “acting of one’s own will”. It is more
+often used to describe non-electronic moving machines, especially those that
+have been made to resemble human or animal actions, such as the jacks on old
+public striking clocks, or the cuckoo and any other animated figures on a
+cuckoo clock.</div><div dir="rtl">העדויות על בובות מכניות ראשונות הן מיוון העתיקה, שם הופעלו פסלים נעים בכוח הקיטור
+שנקראו אוטומטון (ביוונית: αὐτόματος - נע מעצמו). האוטומטונים שימשו הן כצעצועים והן
+לצורכי בימת התיאטרון היווני, כמייצגים אלים, במיוחד בכניסה מפתיעה בסוף המחזה. הביטוי
+דאוס אקס מכינה ("האל מתוך המכונה"), שמשמעותו מצב בסיפור שבו הכותב מכניס לעלילה
+גורם שאינו נובע מהשרשרת הסיבתית העלילתית כדי לפתור בעיות עלילתיות, מגיע מהופעת ה"אל"
+מתוך הפסל המכני שהוריד אותו אל הבמה. למנגנוני תנועה מכניים אוטומטיים מאותה תקופה נמצא
+שריד ארכאולוגי בדמותו של מנגנון אנטיקיתרה, ששימש למכונת חישוב קדומה.</div>
+</pre>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/662288-1.html b/layout/reftests/bidi/662288-1.html
new file mode 100644
index 000000000..b79f961b8
--- /dev/null
+++ b/layout/reftests/bidi/662288-1.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>pre element with auto-direction</title>
+ </head>
+ <body>
+ <pre dir="auto">The word Automaton is the latinization of the Greek
+αὐτόματον,... automaton, (neuter) “acting of one’s own will”. It is more
+often used to describe non-electronic moving machines, especially those that
+have been made to resemble human or animal actions, such as the jacks on old
+public striking clocks, or the cuckoo and any other animated figures on a
+cuckoo clock.
+העדויות על בובות מכניות ראשונות הן מיוון העתיקה, שם הופעלו פסלים נעים בכוח הקיטור
+שנקראו אוטומטון (ביוונית: αὐτόματος - נע מעצמו). האוטומטונים שימשו הן כצעצועים והן
+לצורכי בימת התיאטרון היווני, כמייצגים אלים, במיוחד בכניסה מפתיעה בסוף המחזה. הביטוי
+דאוס אקס מכינה ("האל מתוך המכונה"), שמשמעותו מצב בסיפור שבו הכותב מכניס לעלילה
+גורם שאינו נובע מהשרשרת הסיבתית העלילתית כדי לפתור בעיות עלילתיות, מגיע מהופעת ה"אל"
+מתוך הפסל המכני שהוריד אותו אל הבמה. למנגנוני תנועה מכניים אוטומטיים מאותה תקופה נמצא
+שריד ארכאולוגי בדמותו של מנגנון אנטיקיתרה, ששימש למכונת חישוב קדומה.
+</pre>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/670226-1-ref.html b/layout/reftests/bidi/670226-1-ref.html
new file mode 100644
index 000000000..ef15ed749
--- /dev/null
+++ b/layout/reftests/bidi/670226-1-ref.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Bug 670226</title>
+ <style type="text/css">
+ pre:first-letter { float:left; color: lime}
+ pre { font-size: 16pt }
+ </style>
+ </head>
+ <body>
+ <pre dir="rtl">a+b
+c</pre>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/670226-1.html b/layout/reftests/bidi/670226-1.html
new file mode 100644
index 000000000..bd230a7a9
--- /dev/null
+++ b/layout/reftests/bidi/670226-1.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Bug 670226</title>
+ <style type="text/css">
+ pre:first-letter { float:left; color: lime}
+ </style>
+ <script type="text/javascript">
+function boom()
+{
+ var p = document.getElementById("p");
+ p.style.fontSize="16pt";
+}
+ </script>
+ </head>
+ <body onload="boom()">
+ <pre id="p" dir="rtl">a+b
+c</pre>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/676245-1-ref.html b/layout/reftests/bidi/676245-1-ref.html
new file mode 100644
index 000000000..4908bb6de
--- /dev/null
+++ b/layout/reftests/bidi/676245-1-ref.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title>block-as-inline</title>
+ <style>
+ .inline-block {display: inline-block;}
+ </style>
+ </head>
+ <body>
+ <div>
+ I like:
+ <div class="inline-block">A</div>
+ <div class="inline-block" dir="rtl">&#x05D0;</div>
+ <div class="inline-block" dir="rtl">&#x05D1;</div>
+ (3 things total).
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/676245-1.html b/layout/reftests/bidi/676245-1.html
new file mode 100644
index 000000000..63470a1d2
--- /dev/null
+++ b/layout/reftests/bidi/676245-1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title>block-as-inline</title>
+ <style>
+ .inline {display: inline;}
+ </style>
+ </head>
+ <body>
+ <div>
+ I like:
+ <div class="inline">A</div>
+ <div class="inline" dir="rtl">&#x05D0;</div>
+ <div class="inline" dir="rtl">&#x05D1;</div>
+ (3 things total).
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/698291-1-frame.html b/layout/reftests/bidi/698291-1-frame.html
new file mode 100644
index 000000000..3b745c77f
--- /dev/null
+++ b/layout/reftests/bidi/698291-1-frame.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test for bug 698291</title>
+ </head>
+ <body>
+ <textarea dir="auto" style="width: 100%">בדיקה</textarea>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/698291-1-ref.html b/layout/reftests/bidi/698291-1-ref.html
new file mode 100644
index 000000000..5526e1c4c
--- /dev/null
+++ b/layout/reftests/bidi/698291-1-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test for bug 698291</title>
+ </head>
+ <body>
+ <iframe style="width: 100%" src="698291-1-frame.html"></iframe>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/698291-1.html b/layout/reftests/bidi/698291-1.html
new file mode 100644
index 000000000..555ba8dd0
--- /dev/null
+++ b/layout/reftests/bidi/698291-1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+ <head>
+ <meta charset="utf-8">
+ <title>Test for bug 698291</title>
+ </head>
+ <body>
+ <iframe style="width: 50%" id="f" src="698291-1-frame.html"></iframe>
+ <script type="text/javascript">
+function expandFrame()
+{
+ document.getElementById("f").style.width="100%";
+ document.documentElement.removeAttribute("class");
+}
+document.addEventListener("MozReftestInvalidate", expandFrame, false);
+ </script>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/698706-1-ref.html b/layout/reftests/bidi/698706-1-ref.html
new file mode 100644
index 000000000..a5fb48020
--- /dev/null
+++ b/layout/reftests/bidi/698706-1-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Facebook</title>
+ </head>
+ <body dir="rtl">
+ <div style="font-size: 18pt; letter-spacing: 2pt;"><bdi>Winnie the Pooh</bdi> commented on his own קישור on <bdi>Christopher Robin</bdi>'s <bdi>wall</bdi>: "<bdi>Lorem ipsum dolor sit amet</bdi>"</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/698706-1.html b/layout/reftests/bidi/698706-1.html
new file mode 100644
index 000000000..de7e619bd
--- /dev/null
+++ b/layout/reftests/bidi/698706-1.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Facebook</title>
+ </head>
+ <body dir="rtl">
+ <div style="font-size: 18pt; letter-spacing: 2pt;">
+ <div style="display: inline;"><span dir="ltr">Winnie the Pooh</span> commented on his own קישור on <span dir="ltr">Christopher Robin</span>'s <span dir="ltr">wall</span>: "<span dir="ltr">Lorem ipsum dolor sit amet</span>"</div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/704837-1-ref.html b/layout/reftests/bidi/704837-1-ref.html
new file mode 100644
index 000000000..d6c438733
--- /dev/null
+++ b/layout/reftests/bidi/704837-1-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Bug 704837</title>
+ </head>
+ <body dir="rtl">
+ <div>אקספלורר 9, פיירפוקס<br> וכרום</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/704837-1.html b/layout/reftests/bidi/704837-1.html
new file mode 100644
index 000000000..6ba299510
--- /dev/null
+++ b/layout/reftests/bidi/704837-1.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Bug 704837</title>
+ </head>
+ <body dir="rtl">
+ <div><div style="display: inline">אקספלורר 9, פיירפוקס<br> וכרום</div></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/712600-1-ref.html b/layout/reftests/bidi/712600-1-ref.html
new file mode 100644
index 000000000..9a85b379b
--- /dev/null
+++ b/layout/reftests/bidi/712600-1-ref.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html><head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <meta charset="utf-8">
+ <title>HTML Test: BDI: neutral to surrounding letters</title>
+ <link rel="reference" href="https://bug712600.bugzilla.mozilla.org/bdi-neutral-to-surrounding-run-ref.html">
+ <link rel="author" title="Aharon Lanin" href="mailto:aharon@google.com">
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com">
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-bdi-element">
+ <meta name="assert" content="
+ 'For the purposes of applying the bidirectional algorithm to the paragraph-level
+ container that a bdi element finds itself within, the bdi element must be treated
+ like a U+FFFC OBJECT REPLACEMENT CHARACTER.'
+
+ Thus, regardless of its content and its dir attribute (if any), a BDI will not prevent
+ a strongly RTL (or LTR) character preceding it from forming a single directional run with
+ another strongly RTL (LTR) character following it.">
+ <style>
+ body{
+ font-size:2em;
+ }
+ </style>
+ </head>
+ <body>
+ <!-- Key to entities used below:
+ &#x05D0; ... &#x05D5; - The first six Hebrew letters (strongly RTL).
+ &#x202D; - The LRO (left-to-right-override) formatting character.
+ &#x202C; - The PDF (pop directional formatting) formatting character; closes LRO. -->
+
+ <div dir="ltr">‭ג &lt; [b] &lt; א...‬</div>
+ <div dir="ltr">‭ג &lt; [b] &lt; א...‬</div>
+ <div dir="ltr">‭ג &lt; [b] &lt; א...‬</div>
+ <div dir="rtl">‭...a &gt; [ב] &gt; c‬</div>
+ <div dir="rtl">‭...a &gt; [ב] &gt; c‬</div>
+ <div dir="rtl">‭...a &gt; [ב] &gt; c‬</div>
+</body></html>
diff --git a/layout/reftests/bidi/712600-1.html b/layout/reftests/bidi/712600-1.html
new file mode 100644
index 000000000..b80c33455
--- /dev/null
+++ b/layout/reftests/bidi/712600-1.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html><head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <meta charset="utf-8">
+ <title>HTML Test: BDI: neutral to surrounding letters</title>
+ <link rel="reference" href="https://bug712600.bugzilla.mozilla.org/bdi-neutral-to-surrounding-run-ref.html">
+ <link rel="author" title="Aharon Lanin" href="mailto:aharon@google.com">
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com">
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-bdi-element">
+ <meta name="assert" content="
+ 'For the purposes of applying the bidirectional algorithm to the paragraph-level
+ container that a bdi element finds itself within, the bdi element must be treated
+ like a U+FFFC OBJECT REPLACEMENT CHARACTER.'
+
+ Thus, regardless of its content and its dir attribute (if any), a BDI will not prevent
+ a strongly RTL (or LTR) character preceding it from forming a single directional run with
+ another strongly RTL (LTR) character following it.">
+ <style>
+ body{
+ font-size:2em;
+ }
+ </style>
+ </head>
+ <body>
+ <!-- Key to entities used below:
+ &#x05D0; ... &#x05D5; - The first six Hebrew letters (strongly RTL).
+ &#x202D; - The LRO (left-to-right-override) formatting character.
+ &#x202C; - The PDF (pop directional formatting) formatting character; closes LRO. -->
+
+ <!--
+ If the BDI in the following DIV were a SPAN, its b would prevent the &#x05D0; and the &#x05D1;
+ from forming a single RTL run and thus keep the &gt;s between from being mirrored into &lt;s.
+ -->
+ <div dir="ltr">א &gt; <bdi>[b]</bdi> &gt; ג...</div>
+ <div dir="ltr">א &gt; <bdi dir="ltr">[b]</bdi> &gt; ג...</div>
+ <div dir="ltr">א &gt; <bdi dir="rtl">[b]</bdi> &gt; ג...</div>
+ <div dir="rtl">a &gt; <bdi>[ב]</bdi> &gt; c...</div>
+ <div dir="rtl">a &gt; <bdi dir="ltr">[ב]</bdi> &gt; c...</div>
+ <div dir="rtl">a &gt; <bdi dir="rtl">[ב]</bdi> &gt; c...</div>
+
+
+</body></html>
diff --git a/layout/reftests/bidi/712600-2-dyn.html b/layout/reftests/bidi/712600-2-dyn.html
new file mode 100644
index 000000000..a1b582a0a
--- /dev/null
+++ b/layout/reftests/bidi/712600-2-dyn.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html class="reftest-wait"><head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <meta charset="utf-8">
+ <title>HTML Test: BDI: neutral when nested</title>
+ <link rel="reference" href="https://bug712600.bugzilla.mozilla.org/bdi-neutral-nested-ref.html">
+ <link rel="author" title="Aharon Lanin" href="mailto:aharon@google.com">
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com">
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-bdi-element">
+ <meta name="assert" content="
+ 'For the purposes of applying the bidirectional algorithm to the paragraph-level
+ container that a bdi element finds itself within, the bdi element must be treated
+ like a U+FFFC OBJECT REPLACEMENT CHARACTER.'">
+ <style>
+ body{
+ font-size:2em;
+ }
+ </style>
+ </head>
+ <body>
+ <!-- Key to entities used below:
+ &#x05D0; ... &#x05D5; - The first six Hebrew letters (strongly RTL).
+ &#x202D; - The LRO (left-to-right-override) formatting character.
+ &#x202C; - The PDF (pop directional formatting) formatting character; closes LRO. -->
+
+ <div dir="ltr">א + <bdi>[a + <bdi>[ב + <bdi>[b + 4]</bdi> + 3]</bdi> + 2]</bdi> + 1</div>
+ <div dir="ltr">א + <bdi dir="rtl">[a + <bdi dir="ltr">[ב + <bdi dir="rtl">[b + 4]</bdi> + 3]</bdi> + 2]</bdi> + 1</div>
+ <div dir="ltr">א + <bdi dir="ltr">[<span id='delete1'>z +</span>a + <bdi dir="rtl">[ב + <bdi dir="ltr">[b + 4]</bdi> + 3]</bdi> + 2]</bdi> + 1</div>
+ <div dir="rtl">a + <bdi>[א + <bdi>[b + <bdi>[ב + 3]</bdi> + 2]</bdi> + 1]</bdi> + 0</div>
+ <div dir="rtl">a + <bdi dir="ltr">[א + <bdi dir="rtl">[b + <bdi dir="ltr">[ב + 3]</bdi> + 2]</bdi> + 1]</bdi> + 0</div>
+ <div dir="rtl">a + <bdi dir="rtl">[א + <bdi dir="ltr">[<span
+ id='delete2'>z + </span>b + <bdi dir="rtl">[ב + 3]</bdi> + 2]</bdi> + 1]</bdi> + 0</div>
+
+ <script type="text/javascript">
+ function deleteSpans() {
+ var n = document.getElementById('delete1');
+ var n2 = document.getElementById('delete2');
+ n.parentNode.removeChild(n);
+ n2.parentNode.removeChild(n2);
+ document.documentElement.removeAttribute("class");
+ }
+ document.addEventListener("MozReftestInvalidate", deleteSpans, false);
+ </script>
+
+</body></html>
diff --git a/layout/reftests/bidi/712600-2-ref.html b/layout/reftests/bidi/712600-2-ref.html
new file mode 100644
index 000000000..388194655
--- /dev/null
+++ b/layout/reftests/bidi/712600-2-ref.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html><head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <meta charset="utf-8">
+ <title>HTML Test: BDI: neutral when nested</title>
+ <link rel="reference" href="https://bug712600.bugzilla.mozilla.org/bdi-neutral-nested-ref.html">
+ <link rel="author" title="Aharon Lanin" href="mailto:aharon@google.com">
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com">
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-bdi-element">
+ <meta name="assert" content="
+ 'For the purposes of applying the bidirectional algorithm to the paragraph-level
+ container that a bdi element finds itself within, the bdi element must be treated
+ like a U+FFFC OBJECT REPLACEMENT CHARACTER.'">
+ <style>
+ body{
+ font-size:2em;
+ }
+ </style>
+ </head>
+ <body>
+ <!-- Key to entities used below:
+ &#x05D0; ... &#x05D5; - The first six Hebrew letters (strongly RTL).
+ &#x202D; - The LRO (left-to-right-override) formatting character.
+ &#x202C; - The PDF (pop directional formatting) formatting character; closes LRO. -->
+
+ <div dir="ltr">‭1 + [a + [3 + [b + 4] + ב] + 2] + א‬</div>
+ <div dir="ltr">‭1 + [a + [3 + [b + 4] + ב] + 2] + א‬</div>
+ <div dir="ltr">‭1 + [a + [3 + [b + 4] + ב] + 2] + א‬</div>
+ <div dir="rtl">‭a + [1 + [b + [3 + ב] + 2] + א] + 0‬</div>
+ <div dir="rtl">‭a + [1 + [b + [3 + ב] + 2] + א] + 0‬</div>
+ <div dir="rtl">‭a + [1 + [b + [3 + ב] + 2] + א] + 0‬</div>
+
+</body></html>
diff --git a/layout/reftests/bidi/712600-2.html b/layout/reftests/bidi/712600-2.html
new file mode 100644
index 000000000..dae4353b3
--- /dev/null
+++ b/layout/reftests/bidi/712600-2.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html><head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <meta charset="utf-8">
+ <title>HTML Test: BDI: neutral when nested</title>
+ <link rel="reference" href="https://bug712600.bugzilla.mozilla.org/bdi-neutral-nested-ref.html">
+ <link rel="author" title="Aharon Lanin" href="mailto:aharon@google.com">
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com">
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-bdi-element">
+ <meta name="assert" content="
+ 'For the purposes of applying the bidirectional algorithm to the paragraph-level
+ container that a bdi element finds itself within, the bdi element must be treated
+ like a U+FFFC OBJECT REPLACEMENT CHARACTER.'">
+ <style>
+ body{
+ font-size:2em;
+ }
+ </style>
+ </head>
+ <body>
+ <!-- Key to entities used below:
+ &#x05D0; ... &#x05D5; - The first six Hebrew letters (strongly RTL).
+ &#x202D; - The LRO (left-to-right-override) formatting character.
+ &#x202C; - The PDF (pop directional formatting) formatting character; closes LRO. -->
+
+ <div dir="ltr">א + <bdi>[a + <bdi>[ב + <bdi>[b + 4]</bdi> + 3]</bdi> + 2]</bdi> + 1</div>
+ <div dir="ltr">א + <bdi dir="rtl">[a + <bdi dir="ltr">[ב + <bdi dir="rtl">[b + 4]</bdi> + 3]</bdi> + 2]</bdi> + 1</div>
+ <div dir="ltr">א + <bdi dir="ltr">[a + <bdi dir="rtl">[ב + <bdi dir="ltr">[b + 4]</bdi> + 3]</bdi> + 2]</bdi> + 1</div>
+ <div dir="rtl">a + <bdi>[א + <bdi>[b + <bdi>[ב + 3]</bdi> + 2]</bdi> + 1]</bdi> + 0</div>
+ <div dir="rtl">a + <bdi dir="ltr">[א + <bdi dir="rtl">[b + <bdi dir="ltr">[ב + 3]</bdi> + 2]</bdi> + 1]</bdi> + 0</div>
+ <div dir="rtl">a + <bdi dir="rtl">[א + <bdi dir="ltr">[b + <bdi dir="rtl">[ב + 3]</bdi> + 2]</bdi> + 1]</bdi> + 0</div>
+</body></html>
diff --git a/layout/reftests/bidi/712600-3-ref.html b/layout/reftests/bidi/712600-3-ref.html
new file mode 100644
index 000000000..123dd3a37
--- /dev/null
+++ b/layout/reftests/bidi/712600-3-ref.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>HTML Test: BDI: neutral when wrapped</title>
+ <link rel="reference" href="bdi-neutral-wrapped-ref.html">
+ <link rel="author" title="Aharon Lanin" href="mailto:aharon@google.com">
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com">
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-bdi-element">
+ <meta name="assert" content="
+ 'For the purposes of applying the bidirectional algorithm to the paragraph-level
+ container that a bdi element finds itself within, the bdi element must be treated
+ like a U+FFFC OBJECT REPLACEMENT CHARACTER.'
+
+ Obviously, this should hold even if the BDI's content is wrapped over more than one line.
+ A single character (U+FFFC or otherwise) obviously never gets wrapped over more than one
+ line, but we still expect the part of the content preceding the BDI, if any, that is
+ displayed on the same line as some part of the BDI to be ordered the same as it would be
+ if that part of the BDI were replaced with U+FFFC. Similarly, we expect the part of the
+ content following the BDI, if any, that is displayed on the same line as some part of the
+ BDI to be ordered the same as it would be if that part of the BDI were replaced with U+FFFC.
+
+ In the test below, the content surrounding the BDI forms a single directional run (despite
+ the containing element and the BDI both having the opposite direction, because the BDI is
+ treated as a neutral). Thus, on the line containing the first part of the BDI, the BDI's
+ content appears after the content preceding it, and on the line containing the last part of
+ the BDI, the BDI content appears before the content following it, where both 'before' and
+ 'after' are defined relative to the surrounding content's direction. And, of course, the line
+ containing just BDI content should be ordered in the BDI's direction.">
+ <style>
+ body{
+ font-size:2em;
+ }
+ .box {
+ border: medium solid gray;
+ width: 400px;
+ margin: 20px;
+ }
+ </style>
+ </head>
+ <body>
+ <!-- Key to entities used below:
+ &#x05D0; ... &#x05D5; - The first six Hebrew letters (strongly RTL).
+ &#x202D; - The LRO (left-to-right-override) formatting character.
+ &#x202C; - The PDF (pop directional formatting) formatting character; closes LRO. -->
+ <div class="box">
+ <div dir="ltr">&#x202D;b &lt; &#x05D0;&#x202C;<br/>&#x202D;&gt;&gt;&gt;&#x202C;<br/>&#x202D;&#x05D3; &lt; c...&#x202C;</div>
+ <div dir="rtl">&#x202D;a &gt; &#x05D1;&#x202C;<br/>&#x202D;&lt;&lt;&lt;&#x202C;<br/>&#x202D;...&#x05D2; &gt; d&#x202C;</div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/712600-3.html b/layout/reftests/bidi/712600-3.html
new file mode 100644
index 000000000..68d44b0e3
--- /dev/null
+++ b/layout/reftests/bidi/712600-3.html
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>HTML Test: BDI: neutral when wrapped</title>
+ <link rel="reference" href="bdi-neutral-wrapped-ref.html">
+ <link rel="author" title="Aharon Lanin" href="mailto:aharon@google.com">
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com">
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-bdi-element">
+ <meta name="assert" content="
+ 'For the purposes of applying the bidirectional algorithm to the paragraph-level
+ container that a bdi element finds itself within, the bdi element must be treated
+ like a U+FFFC OBJECT REPLACEMENT CHARACTER.'
+
+ Obviously, this should hold even if the BDI's content is wrapped over more than one line.
+ A single character (U+FFFC or otherwise) obviously never gets wrapped over more than one
+ line, but we still expect the part of the content preceding the BDI, if any, that is
+ displayed on the same line as some part of the BDI to be ordered the same as it would be
+ if that part of the BDI were replaced with U+FFFC. Similarly, we expect the part of the
+ content following the BDI, if any, that is displayed on the same line as some part of the
+ BDI to be ordered the same as it would be if that part of the BDI were replaced with U+FFFC.
+
+ In the test below, the content surrounding the BDI forms a single directional run (despite
+ the containing element and the BDI both having the opposite direction, because the BDI is
+ treated as a neutral). Thus, on the line containing the first part of the BDI, the BDI's
+ content appears after the content preceding it, and on the line containing the last part of
+ the BDI, the BDI content appears before the content following it, where both 'before' and
+ 'after' are defined relative to the surrounding content's direction. And, of course, the line
+ containing just BDI content should be ordered in the BDI's direction.">
+ <style>
+ body{
+ font-size:2em;
+ }
+ .box {
+ border: medium solid gray;
+ width: 400px;
+ margin: 20px;
+ }
+ </style>
+ </head>
+ <body>
+ <!-- Key to entities used below:
+ &#x05D0; ... &#x05D5; - The first six Hebrew letters (strongly RTL).
+ &#x202D; - The LRO (left-to-right-override) formatting character.
+ &#x202C; - The PDF (pop directional formatting) formatting character; closes LRO. -->
+ <div class="box">
+ <div dir="ltr">
+ &#x05D0; &gt;
+ <bdi>b
+ &gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+ c</bdi>
+ &gt; &#x05D3;...
+ </div>
+ <div dir="rtl">
+ a &gt;
+ <bdi>&#x05D1;
+ &gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+ &#x05D2;</bdi>
+ &gt; d...
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/718236-1-ref.html b/layout/reftests/bidi/718236-1-ref.html
new file mode 100644
index 000000000..46f88459a
--- /dev/null
+++ b/layout/reftests/bidi/718236-1-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ </head>
+ <body>
+ <div>&#x062A;<span>&#x0661;</span><span>&#x0663;</span></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/718236-1.html b/layout/reftests/bidi/718236-1.html
new file mode 100644
index 000000000..52d28a485
--- /dev/null
+++ b/layout/reftests/bidi/718236-1.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <script>
+
+function boom()
+{
+ // Force frame construction
+ document.documentElement.offsetHeight;
+
+ // A dynamic change
+ var x = document.getElementById("x");
+ x.parentNode.removeChild(x);
+}
+
+ </script>
+ </head>
+ <body onload="boom();">
+ <div>&#x062A;<span>&#x0661;<span id="x"></span>&#x0663;</span></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/718236-2-ref.html b/layout/reftests/bidi/718236-2-ref.html
new file mode 100644
index 000000000..765430874
--- /dev/null
+++ b/layout/reftests/bidi/718236-2-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ </head>
+ <body>
+ <div><span>&#x0661;</span><span>&#x0663;</span>&#x062A;</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/718236-2.html b/layout/reftests/bidi/718236-2.html
new file mode 100644
index 000000000..54fd5f338
--- /dev/null
+++ b/layout/reftests/bidi/718236-2.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <script>
+
+function boom()
+{
+ // Force frame construction
+ document.documentElement.offsetHeight;
+
+ // A dynamic change
+ var x = document.getElementById("x");
+ x.parentNode.removeChild(x);
+}
+
+ </script>
+ </head>
+ <body onload="boom();">
+ <div><span>&#x0661;<span id="x"></span>&#x0663;</span>&#x062A;</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/718236-3-ref.html b/layout/reftests/bidi/718236-3-ref.html
new file mode 100644
index 000000000..e25629f29
--- /dev/null
+++ b/layout/reftests/bidi/718236-3-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ </head>
+ <body>
+ <div><span>&#x0661;</span><span>&#x0663;</span></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/718236-3.html b/layout/reftests/bidi/718236-3.html
new file mode 100644
index 000000000..b120389c9
--- /dev/null
+++ b/layout/reftests/bidi/718236-3.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <script>
+
+function boom()
+{
+ // Force frame construction
+ document.documentElement.offsetHeight;
+
+ // A dynamic change
+ var x = document.getElementById("x");
+ x.parentNode.removeChild(x);
+}
+
+ </script>
+ </head>
+ <body onload="boom();">
+ <div><span>&#x0661;<span id="x"></span>&#x0663;</span></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/726420-1-ref.html b/layout/reftests/bidi/726420-1-ref.html
new file mode 100644
index 000000000..74473c529
--- /dev/null
+++ b/layout/reftests/bidi/726420-1-ref.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>HTML Test: textarea with dir=auto, all N+EN</title>
+ <link rel="author" title="Aharon Lanin" href="mailto:aharon@google.com">
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com">
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-dir-attribute">
+ <link rel="help" href="http://dev.w3.org/csswg/css3-writing-modes/#unicode-bidi0">
+ <meta name="assert" content="
+ When dir='auto', the direction is set according to the first strong character
+ of the text.
+ For textarea and pre elements, the heuristic is applied on a per-paragraph level.
+ If there is no strong character, as in this test, the direction defaults to LTR.">
+ <style>
+ body { text-align:left }
+ textarea {
+ font-size:18px;
+ text-align:left;
+ resize: none;
+ }
+ .ref {
+ border: medium solid gray;
+ width: 400px;
+ margin: 20px;
+ }
+ .comments {
+ display: none;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="comments">
+ We use text-align:left because neither the dir="auto" nor the unicode-bidi:plaintext
+ specification states whether text-align:start and text-align:end should obey the paragraph
+ direction or the direction property in a unicode-bidi:plaintext element.
+ The ...! paragraph, being neutral, is supposed to be displayed LTR (i.e. as ...!, not as !...)
+ despite both the paragraph before it and the paragraph after it being all-RTL, which makes the
+ element as a whole RTL.
+ </div>
+ <div class="ref">
+ <div dir="ltr">
+ <textarea rows="5" dir="ltr">@123!
+&#x05d0;
+...!
+&#x05d0;
+ </textarea>
+ </div>
+ <div dir="rtl">
+ <textarea rows="5" dir="ltr">@123!
+&#x05d0;
+...!
+&#x05d0;
+ </textarea>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/726420-1.html b/layout/reftests/bidi/726420-1.html
new file mode 100644
index 000000000..aae3baa4f
--- /dev/null
+++ b/layout/reftests/bidi/726420-1.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>HTML Test: textarea with dir=auto, all N+EN</title>
+ <link rel="author" title="Aharon Lanin" href="mailto:aharon@google.com">
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com">
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-dir-attribute">
+ <link rel="help" href="http://dev.w3.org/csswg/css3-writing-modes/#unicode-bidi0">
+ <meta name="assert" content="
+ When dir='auto', the direction is set according to the first strong character
+ of the text.
+ For textarea and pre elements, the heuristic is applied on a per-paragraph level.
+ If there is no strong character, as in this test, the direction defaults to LTR.">
+ <style>
+ body { text-align:left; }
+ textarea {
+ font-size:18px;
+ text-align:left;
+ resize: none;
+ }
+ .test {
+ border: medium solid gray;
+ width: 400px;
+ margin: 20px;
+ }
+ .comments {
+ display: none;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="comments">
+ We use text-align:left because neither the dir="auto" nor the unicode-bidi:plaintext
+ specification states whether text-align:start and text-align:end should obey the paragraph
+ direction or the direction property in a unicode-bidi:plaintext element.
+ The ...! paragraph, being neutral, is supposed to be displayed LTR (i.e. as ...!, not as !...)
+ despite both the paragraph before it and the paragraph after it being all-RTL, which makes the
+ element as a whole RTL.
+ </div>
+ <div class="test">
+ <div dir="ltr">
+ <textarea rows="5" dir="auto">@123!
+&#x05d0;
+...!
+&#x05d0;
+ </textarea>
+ </div>
+ <div dir="rtl">
+ <textarea rows="5" dir="auto">@123!
+&#x05d0;
+...!
+&#x05d0;
+ </textarea>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/726460-1-ref.html b/layout/reftests/bidi/726460-1-ref.html
new file mode 100644
index 000000000..a3430fa71
--- /dev/null
+++ b/layout/reftests/bidi/726460-1-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ </head>
+ <body>
+ <div><span><span>&#x062A</span>C</span></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/726460-1.html b/layout/reftests/bidi/726460-1.html
new file mode 100644
index 000000000..88956fa04
--- /dev/null
+++ b/layout/reftests/bidi/726460-1.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <script>
+
+function boom()
+{
+ // Force frame construction
+ document.documentElement.offsetHeight;
+
+ // A dynamic change
+ document.getElementById("x").firstChild.data = "\u062A"
+}
+
+window.addEventListener("load", boom, false);
+
+ </script>
+ </head>
+ <body>
+ <div><span><span id="x">&#x06CD;B</span>C</span></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/729047-1-ref.html b/layout/reftests/bidi/729047-1-ref.html
new file mode 100644
index 000000000..e84a1fe96
--- /dev/null
+++ b/layout/reftests/bidi/729047-1-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title>Bug 729047</title>
+ <style>body { line-height: 1.2em; }</style>
+ </head>
+ <body>
+ <div dir=rtl>123,&#x200b;456</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/729047-1.html b/layout/reftests/bidi/729047-1.html
new file mode 100644
index 000000000..016847606
--- /dev/null
+++ b/layout/reftests/bidi/729047-1.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title>Bug 729047</title>
+ <style>body { line-height: 1.2em; }</style>
+ </head>
+ <body>
+ <div dir=rtl>123,<wbr>456</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/730562-1-ref.html b/layout/reftests/bidi/730562-1-ref.html
new file mode 100644
index 000000000..04a7431a4
--- /dev/null
+++ b/layout/reftests/bidi/730562-1-ref.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ </head>
+ <body>
+ <div style="direction: rtl; white-space: pre;"><span style="outline: 1px solid red;" id="x">
+
+
+</span></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/730562-1.html b/layout/reftests/bidi/730562-1.html
new file mode 100644
index 000000000..3b6ca3bf3
--- /dev/null
+++ b/layout/reftests/bidi/730562-1.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <script>
+
+function boom()
+{
+ // Force frame construction
+ document.documentElement.offsetHeight;
+
+ // A dynamic change
+ var x = document.getElementById("x");
+ x.removeChild(x.firstChild);
+ x.appendChild(document.createTextNode("\n\n\n"));
+}
+
+ </script>
+ </head>
+ <body onload="boom();">
+ <div style="direction: rtl; white-space: pre;"><span style="outline: 1px solid red;" id="x">
+ :p</span></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/746987-1-ref.html b/layout/reftests/bidi/746987-1-ref.html
new file mode 100644
index 000000000..519be1dcc
--- /dev/null
+++ b/layout/reftests/bidi/746987-1-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>unicode-bidi:plaintext on inline</title>
+ </head>
+ <body>
+ <div>[<span dir="rtl">:-) &#x05d0;</span>&lrm;]: 100</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/746987-1.html b/layout/reftests/bidi/746987-1.html
new file mode 100644
index 000000000..b576bd8bf
--- /dev/null
+++ b/layout/reftests/bidi/746987-1.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <style>
+ .plaintext {
+ unicode-bidi: plaintext;
+ }
+ </style>
+ <title>unicode-bidi:plaintext on inline</title>
+ </head>
+ <body>
+ <div>[<span class="plaintext">:-) &#x05d0;</span>]: 100</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/746987-2-ref.html b/layout/reftests/bidi/746987-2-ref.html
new file mode 100644
index 000000000..e8d74ba6a
--- /dev/null
+++ b/layout/reftests/bidi/746987-2-ref.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8"/>
+ <style>
+ body {
+ font-size:2em;
+ text-align:left;
+ }
+ .ref {
+ border: medium solid gray;
+ padding: 10px;
+ width: 400px;
+ margin: 20px;
+ }
+ </style>
+ <title>unicode-bidi:plaintext on inline with paragraph breaks</title>
+ </head>
+ <body>
+ <div class="ref">
+ a-><br/>&#x05D0;->&rlm;<br/>a-><br/>&#x05D0;->&rlm;
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/746987-2.html b/layout/reftests/bidi/746987-2.html
new file mode 100644
index 000000000..7df556b82
--- /dev/null
+++ b/layout/reftests/bidi/746987-2.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8"/>
+ <style>
+ body {
+ font-size:2em;
+ text-align:left;
+ }
+ .test {
+ border: medium solid gray;
+ padding: 10px;
+ width: 400px;
+ margin: 20px;
+ }
+ .plaintext {
+ unicode-bidi: plaintext;
+ }
+ </style>
+ <title>unicode-bidi:plaintext on inline with paragraph breaks</title>
+ </head>
+ <body>
+ <div class="test">
+ <span class="plaintext">a-><br/>&#x05D0;-><br/>a-><br/>&#x05D0;-></span>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/746987-3-ref.html b/layout/reftests/bidi/746987-3-ref.html
new file mode 100644
index 000000000..b195db0a4
--- /dev/null
+++ b/layout/reftests/bidi/746987-3-ref.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8"/>
+ <style>
+ body {
+ font-size:2em;
+ text-align:left;
+ }
+ .ref {
+ border: medium solid gray;
+ padding: 10px;
+ width: 400px;
+ margin: 20px;
+ }
+ </style>
+ <title>unicode-bidi:plaintext does not apply to embedded unicode-bidi:isolate</title>
+ </head>
+ <body>
+ <div class="ref">
+ &#x05D0;->=>&lrm;
+ <span dir="rtl">&#x05D1;->=></span>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/746987-3.html b/layout/reftests/bidi/746987-3.html
new file mode 100644
index 000000000..2afc59503
--- /dev/null
+++ b/layout/reftests/bidi/746987-3.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8"/>
+ <style>
+ body {
+ font-size:2em;
+ text-align:left;
+ }
+ .test {
+ border: medium solid gray;
+ padding: 10px;
+ width: 400px;
+ margin: 20px;
+ }
+ .plaintext {
+ unicode-bidi: plaintext;
+ }
+ .isolate {
+ unicode-bidi: isolate;
+ }
+ </style>
+ <title>unicode-bidi:plaintext does not apply to embedded unicode-bidi:isolate</title>
+ </head>
+ <body>
+ <div class="test">
+ <span class="plaintext"><span class="isolate">&#x05D0;-></span>=></span>
+ <span class="plaintext"><span>&#x05D1;-></span>=></span>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/746987-4-ref.html b/layout/reftests/bidi/746987-4-ref.html
new file mode 100644
index 000000000..86043f6cb
--- /dev/null
+++ b/layout/reftests/bidi/746987-4-ref.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8"/>
+ <style>
+ body {
+ font-size:2em;
+ text-align:left;
+ }
+ .ref {
+ border: medium solid gray;
+ padding: 10px;
+ width: 400px;
+ margin: 20px;
+ }
+ </style>
+ <title>unicode-bidi:plaintext does not apply to embedded display:block</title>
+ </head>
+ <body>
+ <div class="ref">
+ &#x05D0;->&rlm;<br/>&#x05D0;-><br/>a-><br/>&#x05D0;-><br/>&#x05D0;->&rlm;
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/746987-4.html b/layout/reftests/bidi/746987-4.html
new file mode 100644
index 000000000..37ae02e46
--- /dev/null
+++ b/layout/reftests/bidi/746987-4.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8"/>
+ <style>
+ body {
+ font-size:2em;
+ text-align:left;
+ }
+ .test {
+ border: medium solid gray;
+ padding: 10px;
+ width: 400px;
+ margin: 20px;
+ }
+ .plaintext {
+ unicode-bidi: plaintext;
+ }
+ </style>
+ <title>unicode-bidi:plaintext does not apply to embedded display:block</title>
+ </head>
+ <body>
+ <div class="test">
+ <div class="plaintext">
+ &#x05D0;->
+ <div>&#x05D0;-></div>
+ a->
+ <div>&#x05D0;-></div>
+ &#x05D0;->
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/779003-1-dynamic.html b/layout/reftests/bidi/779003-1-dynamic.html
new file mode 100644
index 000000000..1cd2e65fd
--- /dev/null
+++ b/layout/reftests/bidi/779003-1-dynamic.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <style type="text/css">
+#searchPaginationFooter {
+ direction: rtl;
+}
+
+.backLink {
+ display: inline;
+}
+
+.nextLink {
+ display: inline;
+}
+
+.pagination,
+.pagination li {
+ display: inline;
+}
+ </style>
+ </head>
+ <body>
+ <div>
+ <div id="searchPaginationFooter">
+ <p class="backLink"> &lt; <span class="gray">السابق</span></p>
+ <ul class="pagination">
+ <li><span class="select">1</span></li>
+ <li><a href="#page=2">2</a></li>
+ <li><a href="#page=3">3</a></li>
+ <li><a href="#page=4">4</a></li>
+ <li><a href="#page=5">5</a></li>
+ <li><a href="#page=6">6</a></li>
+ <li><a href="#page=7">7</a></li>
+ <li><a href="#page=8">8</a></li>
+ <li id="here"><a href="#page=9">9</a></li>
+ <li>...</li>
+ <li><a href="#page=325">325</a></li>
+ </ul>
+ <p class="nextLink"><a href="#page=2">التالي</a> &gt; </p>
+ </div>
+ </div>
+<script type="text/javascript">
+function removePage() {
+ var here = document.getElementById("here");
+ here.parentNode.removeChild(here);
+ document.documentElement.removeAttribute("class");
+}
+document.addEventListener("MozReftestInvalidate", removePage, false);
+</script>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/779003-1-ref.html b/layout/reftests/bidi/779003-1-ref.html
new file mode 100644
index 000000000..dfbc638ff
--- /dev/null
+++ b/layout/reftests/bidi/779003-1-ref.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <style type="text/css">
+#searchPaginationFooter {
+ direction: rtl;
+}
+
+.backLink {
+ display: inline-block;
+}
+
+.nextLink {
+ display: inline-block;
+}
+
+.pagination,
+.pagination li {
+ display: inline-block;
+ margin: 0;
+}
+
+p { margin: 0; }
+ </style>
+ </head>
+ <body>
+ <div>
+ <div id="searchPaginationFooter">
+ <p class="backLink"> &lt; <span class="gray">السابق</span></p>
+ <ul class="pagination">
+ <li><span class="select">1</span></li>
+ <li><a href="#page=2">2</a></li>
+ <li><a href="#page=3">3</a></li>
+ <li><a href="#page=4">4</a></li>
+ <li><a href="#page=5">5</a></li>
+ <li><a href="#page=6">6</a></li>
+ <li><a href="#page=7">7</a></li>
+ <li><a href="#page=8">8</a></li>
+ <li>...</li>
+ <li><a href="#page=325">325</a></li>
+ </ul>
+ <p class="nextLink"><a href="#page=2">التالي</a> &gt; </p>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/779003-1.html b/layout/reftests/bidi/779003-1.html
new file mode 100644
index 000000000..2fffb8eb1
--- /dev/null
+++ b/layout/reftests/bidi/779003-1.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <style type="text/css">
+#searchPaginationFooter {
+ direction: rtl;
+}
+
+.backLink {
+ display: inline;
+}
+
+.nextLink {
+ display: inline;
+}
+
+.pagination,
+.pagination li {
+ display: inline;
+}
+ </style>
+ </head>
+ <body>
+ <div>
+ <div id="searchPaginationFooter">
+ <p class="backLink"> &lt; <span class="gray">السابق</span></p>
+ <ul class="pagination">
+ <li><span class="select">1</span></li>
+ <li><a href="#page=2">2</a></li>
+ <li><a href="#page=3">3</a></li>
+ <li><a href="#page=4">4</a></li>
+ <li><a href="#page=5">5</a></li>
+ <li><a href="#page=6">6</a></li>
+ <li><a href="#page=7">7</a></li>
+ <li><a href="#page=8">8</a></li>
+ <li>...</li>
+ <li><a href="#page=325">325</a></li>
+ </ul>
+ <p class="nextLink"><a href="#page=2">التالي</a> &gt; </p>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/817406-1-ref.html b/layout/reftests/bidi/817406-1-ref.html
new file mode 100644
index 000000000..1e3e74702
--- /dev/null
+++ b/layout/reftests/bidi/817406-1-ref.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<html style="width: 50%; margin-left: auto;">
+<div style="background: green; height: 10em;"></div>
+</html>
diff --git a/layout/reftests/bidi/817406-1.html b/layout/reftests/bidi/817406-1.html
new file mode 100644
index 000000000..d01fa724e
--- /dev/null
+++ b/layout/reftests/bidi/817406-1.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<html dir="rtl" style="width: 50%;">
+<div style="background: green; height: 10em;"></div>
+</html>
diff --git a/layout/reftests/bidi/817406-2-ref.html b/layout/reftests/bidi/817406-2-ref.html
new file mode 100644
index 000000000..fd1f20e0c
--- /dev/null
+++ b/layout/reftests/bidi/817406-2-ref.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<html style="width: 50%; right: 0; position: absolute;">
+<div style="background: green; height: 10em;"></div>
+</html>
diff --git a/layout/reftests/bidi/817406-2.html b/layout/reftests/bidi/817406-2.html
new file mode 100644
index 000000000..ebc3ebb98
--- /dev/null
+++ b/layout/reftests/bidi/817406-2.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<html style="width: 50%; direction: rtl; position: absolute;">
+<div style="background: green; height: 10em;"></div>
+</html>
diff --git a/layout/reftests/bidi/817406-3.html b/layout/reftests/bidi/817406-3.html
new file mode 100644
index 000000000..90313bde4
--- /dev/null
+++ b/layout/reftests/bidi/817406-3.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html style="width: 50%;">
+<body onload="document.documentElement.dir = 'rtl'">
+<div style="background: green; height: 10em;"></div>
+</body>
+</html>
diff --git a/layout/reftests/bidi/817406-4-ref.html b/layout/reftests/bidi/817406-4-ref.html
new file mode 100644
index 000000000..e6e1c8d1f
--- /dev/null
+++ b/layout/reftests/bidi/817406-4-ref.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html style="width: 50%;">
+<body style="">
+<div style="background: green; height: 10em;"></div>
+</body>
+</html>
diff --git a/layout/reftests/bidi/817406-4.html b/layout/reftests/bidi/817406-4.html
new file mode 100644
index 000000000..3e9027424
--- /dev/null
+++ b/layout/reftests/bidi/817406-4.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html style="width: 50%;">
+<body style="direction: rtl;">
+<div style="background: green; height: 10em;"></div>
+</body>
+</html>
diff --git a/layout/reftests/bidi/83958-1-ref.html b/layout/reftests/bidi/83958-1-ref.html
new file mode 100644
index 000000000..146b7cd32
--- /dev/null
+++ b/layout/reftests/bidi/83958-1-ref.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Bidirectional Text Test 2</title>
+ <style>
+ body { font-size: 300%; }
+ p { font-family: monospace; margin: 0; }
+ </style>
+ </head>
+ <body>
+ <p>The following lines should all read "ABCDEFGHI":</p>
+ <p>ABCDEFGHI</p>
+ <p>ABCDEFGHI</p>
+ <p>ABCDEFGHI</p>
+ <p>ABCDEFGHI</p>
+ <p>ABCDEFGHI</p>
+ <p>ABCDEFGHI</p>
+ <p>ABCDEFGHI</p>
+ <p>ABCDEFGHI</p>
+ <p>ABCDEFGHI</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/83958-1a.html b/layout/reftests/bidi/83958-1a.html
new file mode 100644
index 000000000..5362759e0
--- /dev/null
+++ b/layout/reftests/bidi/83958-1a.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Bidirectional Text Test 2 - Formatting Characters</title>
+ <style>
+ body { font-size: 300%; }
+ p { font-family: monospace; text-align: left; margin: 0; }
+ </style>
+ </head>
+<!-- Testcases based on https://dbaron.org/css/test/bidi2_charcode by L. David Baron. -->
+ <body>
+ <p>The following lines should all read "ABCDEFGHI":</p>
+ <p>ABCDEFGHI</p>
+ <p dir="rtl">&#x202b;ABCDEFGHI&#x202c;</p>
+ <p dir="rtl">&#x202b;ABC<span>DEF</span>GHI&#x202c;</p>
+ <p dir="rtl">&#x202e;IHGFEDCBA&#x202c;</p>
+ <p dir="rtl">&#x202e;IHG<span>FED</span>CBA&#x202c;</p>
+ <p dir="rtl">&#x202e;IHG&#x202b;DEF&#x202c;CBA&#x202c;</p>
+ <p dir="rtl">&#x202e;IHG&#x202e;FED&#x202c;CBA&#x202c;</p>
+ <p dir="rtl">&#x202e;IHG&#x202e;FED&#x202c;CBA&#x202c;</p>
+ <p dir="rtl">&#x202e;IHG&#x202d;DEF&#x202c;CBA&#x202c;</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/83958-1b.html b/layout/reftests/bidi/83958-1b.html
new file mode 100644
index 000000000..22d72a49c
--- /dev/null
+++ b/layout/reftests/bidi/83958-1b.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Bidirectional Text Test 2 - CSS</title>
+ <style>
+ body { font-size: 300%; }
+ p { font-family: monospace; text-align: left; margin: 0; }
+.rtl { direction: rtl; }
+.ltr { direction: ltr; }
+.rle { direction: rtl; unicode-bidi: embed; }
+.lre { direction: ltr; unicode-bidi: embed; }
+.rlo { direction: rtl; unicode-bidi: bidi-override; }
+.lro { direction: ltr; unicode-bidi: bidi-override; }
+.embed { unicode-bidi: embed; }
+.override { unicode-bidi: bidi-override; }
+ </style>
+ </head>
+<!-- Testcases based on https://dbaron.org/css/test/bidi2 by L. David Baron. -->
+ <body>
+ <p>The following lines should all read "ABCDEFGHI":</p>
+ <p>ABCDEFGHI</p>
+ <p class="rtl">ABCDEFGHI</p>
+ <p class="rtl">ABC<span>DEF</span>GHI</p>
+ <p class="rlo">IHGFEDCBA</p>
+ <p class="rlo">IHG<span>FED</span>CBA</p>
+ <p class="rlo">IHG<span class="embed">DEF</span>CBA</p>
+ <p class="rlo">IHG<span class="override">FED</span>CBA</p>
+ <p class="rlo">IHG<span style="unicode-bidi: inherit">FED</span>CBA</p>
+ <p class="rlo">IHG<span class="lro">DEF</span>CBA</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/83958-1c.html b/layout/reftests/bidi/83958-1c.html
new file mode 100644
index 000000000..b81362fb4
--- /dev/null
+++ b/layout/reftests/bidi/83958-1c.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Bidirectional Text Test 2 - HTML</title>
+ <style>
+ body { font-size: 300%; }
+ p { font-family: monospace; text-align: left; margin: 0; }
+.rtl { direction: rtl; }
+.ltr { direction: ltr; }
+.rle { direction: rtl; unicode-bidi: embed; }
+.lre { direction: ltr; unicode-bidi: embed; }
+.rlo { direction: rtl; unicode-bidi: bidi-override;}
+.lro { direction: ltr; unicode-bidi: bidi-override; }
+.embed { unicode-bidi: embed; }
+.override { unicode-bidi: bidi-override; }
+ </style>
+ </head>
+<!-- Testcases based on https://dbaron.org/css/test/bidi2_html by L. David Baron. -->
+ <body>
+ <p>The following lines should all read "ABCDEFGHI":</p>
+ <p>ABCDEFGHI</p>
+ <p class="rtl">ABCDEFGHI</p>
+ <p class="rtl">ABC<span>DEF</span>GHI</p>
+ <p class="rlo">IHGFEDCBA</p>
+ <p class="rlo">IHG<span>FED</span>CBA</p>
+ <p class="rlo">IHG<span dir="rtl">DEF</span>CBA</p>
+ <p class="rlo">IHG<bdo dir="rtl">FED</bdo>CBA</p>
+ <p class="rlo">IHG<span style="unicode-bidi: inherit">FED</span>CBA</p>
+ <p class="rlo">IHG<bdo dir="ltr">DEF</bdo>CBA</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/83958-2-ref.html b/layout/reftests/bidi/83958-2-ref.html
new file mode 100644
index 000000000..2f775efb1
--- /dev/null
+++ b/layout/reftests/bidi/83958-2-ref.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Bidirectional Text Test 2</title>
+ <style>
+ p { font-family: monospace; direction: ltr; unicode-bidi: bidi-override;}
+ </style>
+ </head>
+ <body>
+ <p>&#x05D2;&#x05D1;&#x05D0;</p>
+ <p>&#x05D2;&#x05D1;&#x05D0;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2;</p>
+ <p>&#x05D2;&#x05D1;&#x05D0;&nbsp;ABC&nbsp;&#x05D5;&#x05D4;&#x05D3;</p>
+ <p>&#x05D5;&#x05D4;&#x05D3;&nbsp;ABC&nbsp;&#x05D2;&#x05D1;&#x05D0;</p>
+ <p>&#x05D2;&#x05D1;&#x05D0;&nbsp;ABC&nbsp;&#x05D5;&#x05D4;&#x05D3;&nbsp;DEF&nbsp;&#x05D8;&#x05D7;&#x05D6;</p>
+ <p>&#x05D2;&#x05D1;&#x05D0;&nbsp;ABC&nbsp;&#x05D5;&#x05D4;&#x05D3;&nbsp;DEF&nbsp;&#x05D8;&#x05D7;&#x05D6;</p>
+ <p>&#x05D2;&#x05D1;&#x05D0;&nbsp;ABC&nbsp;&#x05D5;&#x05D4;&#x05D3;&nbsp;DEF&nbsp;&#x05D8;&#x05D7;&#x05D6;</p>
+ <p>&#x05D8;&#x05D7;&#x05D6;&nbsp;DEF&nbsp;&#x05D5;&#x05D4;&#x05D3;&nbsp;ABC&nbsp;&#x05D2;&#x05D1;&#x05D0;</p>
+ <p>&#x05D5;&#x05D4;&#x05D3;&nbsp;ABC&nbsp;&#x05D2;&#x05D1;&#x05D0;&nbsp;DEF&nbsp;&#x05D8;&#x05D7;&#x05D6;</p>
+ <p>&#x05D5;&#x05D4;&#x05D3;&nbsp;CBA&nbsp;&#x05D2;&#x05D1;&#x05D0;&nbsp;DEF&nbsp;&#x05D8;&#x05D7;&#x05D6;</p>
+ <p>&#x05D2;&#x05D1;&#x05D0;&nbsp;ABC&nbsp;&#x05D3;&#x05D4;&#x05D5;&nbsp;DEF&nbsp;&#x05D8;&#x05D7;&#x05D6;</p>
+ <p>&#x05D8;&#x05D7;&#x05D6;&nbsp;ABC&nbsp;&#x05D3;&#x05D4;&#x05D5;&nbsp;DEF&nbsp;&#x05D2;&#x05D1;&#x05D0;</p>
+ <p>&#x05D2;&#x05D1;&#x05D0;&nbsp;ABC&nbsp;&#x05D5;&#x05D4;&#x05D3;&nbsp;DEF&nbsp;GHI&nbsp;&#x05D8;&#x05D7;&#x05D6;</p>
+ <p>FED&nbsp;&#x05D5;&#x05D4;&#x05D3;&nbsp;CBA&nbsp;&#x05D2;&#x05D1;&#x05D0;&nbsp;GHI&nbsp;&#x05D8;&#x05D7;&#x05D6;</p>
+ <p>&#x05D2;&#x05D1;&#x05D0;&nbsp;ABC&nbsp;FED&nbsp;&#x05D5;&#x05D4;&#x05D3;&nbspGHI&nbsp;&#x05D8;&#x05D7;&#x05D6;</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/83958-2a.html b/layout/reftests/bidi/83958-2a.html
new file mode 100644
index 000000000..f9872c73b
--- /dev/null
+++ b/layout/reftests/bidi/83958-2a.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Bidirectional Text Test 2 - Formatting Characters</title>
+ <style>
+ p { font-family: monospace; text-align: left; }
+ </style>
+ </head>
+<!-- Testcases based on https://dbaron.org/css/test/bidi2_charcode by L. David Baron. -->
+ <body>
+ <p>&#x05D0;&#x05D1;&#x05D2;</p>
+ <p>&#x202a;&#x05D0;&#x05D1;&#x05D2;&#x202c;</p>
+ <p>&#x202d;&#x05D0;&#x05D1;&#x05D2;&#x202c;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; ABC &#x05D3;&#x05D4;&#x05D5;</p>
+ <p dir="rtl">&#x05D0;&#x05D1;&#x05D2; ABC &#x05D3;&#x05D4;&#x05D5;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; ABC &#x05D3;&#x05D4;&#x05D5; DEF &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; <span>ABC &#x05D3;&#x05D4;&#x05D5;</span> DEF &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; &#x202a;ABC &#x05D3;&#x05D4;&#x05D5; DEF&#x202c; &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; &#x202b;ABC &#x05D3;&#x05D4;&#x05D5; DEF&#x202c; &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; &#x202b;ABC &#x05D3;&#x05D4;&#x05D5;&#x202c; DEF &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; &#x202e;ABC &#x05D3;&#x05D4;&#x05D5;&#x202c; DEF &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; &#x202d;ABC &#x05D3;&#x05D4;&#x05D5;&#x202c; DEF &#x05D6;&#x05D7;&#x05D8;</p>
+ <p dir="rtl">&#x05D0;&#x05D1;&#x05D2; &#x202d;ABC &#x05D3;&#x05D4;&#x05D5;&#x202c; DEF &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; ABC &#x05D3;&#x05D4;&#x05D5; DEF GHI &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; &#x202e;ABC &#x05D3;&#x05D4;&#x05D5; DEF&#x202c; GHI &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; ABC &#x202e;&#x05D3;&#x05D4;&#x05D5; DEF&#x202c; GHI &#x05D6;&#x05D7;&#x05D8;</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/83958-2b.html b/layout/reftests/bidi/83958-2b.html
new file mode 100644
index 000000000..d6c8c2f65
--- /dev/null
+++ b/layout/reftests/bidi/83958-2b.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Bidirectional Text Test 2 - CSS</title>
+ <style>
+p { font-family: monospace; text-align: left; }
+.embed { unicode-bidi: embed; }
+.override { unicode-bidi: bidi-override; }
+.rtl { direction: rtl; }
+.ltr { direction: ltr; }
+ </style>
+ </head>
+<!-- Testcases based on https://dbaron.org/css/test/bidi2 by L. David Baron. -->
+ <body>
+ <p>&#x05D0;&#x05D1;&#x05D2;</p>
+ <p class="embed">&#x05D0;&#x05D1;&#x05D2;</p>
+ <p class="override">&#x05D0;&#x05D1;&#x05D2;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; ABC &#x05D3;&#x05D4;&#x05D5;</p>
+ <p class="rtl">&#x05D0;&#x05D1;&#x05D2; ABC &#x05D3;&#x05D4;&#x05D5;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; ABC &#x05D3;&#x05D4;&#x05D5; DEF &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; <span>ABC &#x05D3;&#x05D4;&#x05D5;</span> DEF &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; <span class="ltr embed">ABC &#x05D3;&#x05D4;&#x05D5; DEF</span> &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; <span class="rtl embed">ABC &#x05D3;&#x05D4;&#x05D5; DEF</span> &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; <span class="rtl embed">ABC &#x05D3;&#x05D4;&#x05D5;</span> DEF &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; <span class="rtl override">ABC &#x05D3;&#x05D4;&#x05D5;</span> DEF &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; <span class="ltr override">ABC &#x05D3;&#x05D4;&#x05D5;</span> DEF &#x05D6;&#x05D7;&#x05D8;</p>
+ <p class="rtl">&#x05D0;&#x05D1;&#x05D2; <span class="ltr override">ABC &#x05D3;&#x05D4;&#x05D5;</span> DEF &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; ABC &#x05D3;&#x05D4;&#x05D5; DEF GHI &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; <span class="rtl override">ABC &#x05D3;&#x05D4;&#x05D5; DEF</span> GHI &#x05D6;&#x05D7;&#x05D8;</p>
+ <p>&#x05D0;&#x05D1;&#x05D2; ABC <span class="rtl override">&#x05D3;&#x05D4;&#x05D5; DEF</span> GHI &#x05D6;&#x05D7;&#x05D8;</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/847242-1-ref.html b/layout/reftests/bidi/847242-1-ref.html
new file mode 100644
index 000000000..8bb910fa0
--- /dev/null
+++ b/layout/reftests/bidi/847242-1-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <style>
+ div {
+ font-family: monospace;
+ font-size: 24px;
+ }
+ </style>
+ </head>
+ <body>
+ <div>PASS&#x2029;</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/847242-1.html b/layout/reftests/bidi/847242-1.html
new file mode 100644
index 000000000..7672216f7
--- /dev/null
+++ b/layout/reftests/bidi/847242-1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <style>
+ div {
+ unicode-bidi: bidi-override;
+ direction: rtl;
+ text-align: left;
+ font-family: monospace;
+ font-size: 24px;
+ }
+ </style>
+ </head>
+ <body>
+ <div>&#x2029;SSAP</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/869833-1-ref.xul b/layout/reftests/bidi/869833-1-ref.xul
new file mode 100644
index 000000000..52f75b0dc
--- /dev/null
+++ b/layout/reftests/bidi/869833-1-ref.xul
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/css" href="data:text/css,
+label.ltr { direction: ltr; }
+label.rtl { direction: rtl; }
+tree { height: 100px; }
+"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <tree>
+ <treecols>
+ <treecol flex="1"/>
+ </treecols>
+ <treechildren>
+ <treeitem>
+ <treerow>
+ <treecell label="&#x202a;Hello!&#x202c;"/>
+ </treerow>
+ </treeitem>
+ <treeitem>
+ <treerow>
+ <treecell label="&#x202b;שלום!&#x202c;"/>
+ </treerow>
+ </treeitem>
+ <treeitem>
+ <treerow>
+ <treecell label="&#x202b;123 إفتح يا سمسم !&#x202c;"/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </tree>
+ <vbox>
+ <hbox>
+ <label class="ltr" value="Hello!"/>
+ </hbox>
+ <hbox>
+ <label class="rtl" value="שלום!"/>
+ </hbox>
+ <hbox>
+ <label class="rtl" value="123 إفتح يا سمسم !"/>
+ </hbox>
+ </vbox>
+</window>
diff --git a/layout/reftests/bidi/869833-1.xul b/layout/reftests/bidi/869833-1.xul
new file mode 100644
index 000000000..d3de6602b
--- /dev/null
+++ b/layout/reftests/bidi/869833-1.xul
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/css" href="data:text/css,
+treechildren::-moz-tree-cell, label { unicode-bidi: plaintext; }
+tree { height: 100px; }
+"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <tree>
+ <treecols>
+ <treecol flex="1"/>
+ </treecols>
+ <treechildren>
+ <treeitem>
+ <treerow>
+ <treecell label="Hello!"/>
+ </treerow>
+ </treeitem>
+ <treeitem>
+ <treerow>
+ <treecell label="שלום!"/>
+ </treerow>
+ </treeitem>
+ <treeitem>
+ <treerow>
+ <treecell label="123 إفتح يا سمسم !"/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </tree>
+ <vbox>
+ <hbox>
+ <label value="Hello!"/>
+ </hbox>
+ <hbox>
+ <label value="שלום!"/>
+ </hbox>
+ <hbox>
+ <label value="123 إفتح يا سمسم !"/>
+ </hbox>
+ </vbox>
+</window>
diff --git a/layout/reftests/bidi/922530-1-ref.html b/layout/reftests/bidi/922530-1-ref.html
new file mode 100644
index 000000000..ba297056a
--- /dev/null
+++ b/layout/reftests/bidi/922530-1-ref.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>ALM character</title>
+ <style type="text/css">
+ p { font-size: 2em; }
+ </style>
+ </head>
+ <body>
+ <p>a2+1</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/922530-1.html b/layout/reftests/bidi/922530-1.html
new file mode 100644
index 000000000..584f6d285
--- /dev/null
+++ b/layout/reftests/bidi/922530-1.html
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>ALM character</title>
+ <style type="text/css">
+ p { font-size: 2em; }
+ </style>
+ <!--
+ Test that U+061C functions as an invisible Arabic character.
+
+ In the test text it is followed by two European numbers with a
+ European separator between them. By rules W2, W3 and W6 of the
+ Bidi algorithm (http://unicode.org/reports/tr9/#W2) the
+ European numbers change to Arabic numbers, the ARABIC LETTER
+ MARK changes to R and the separator changes to Other Neutral,
+ and then by rule N1 the Arabic numbers make the separator
+ change to R, so the final visual order is "a2+1&#x061c;", but
+ the &#x061c should not appear
+ -->
+</head>
+ <body>
+ <p>a&#x061c;1+2</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/922550-1-ref.html b/layout/reftests/bidi/922550-1-ref.html
new file mode 100644
index 000000000..40a51ca71
--- /dev/null
+++ b/layout/reftests/bidi/922550-1-ref.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Bidi with European terminators</title>
+ <style type="text/css">
+ p { unicode-bidi: bidi-override; }
+ </style>
+ </head>
+ <body>
+ <p>In the Bidi Algorithm, a sequence of European terminators
+ adjacent to European numbers changes to all European numbers. A
+ change was made in Unicode 6.3 so that all undefined Unicode
+ codepoints betweem U+20A0 and U+20CF would have the bidi category of
+ European terminator by default</p>
+ <p>$$$$1000000 סרפ!!!</p>
+ <p>&#x20A0;&#x20A0;&#x20A0;&#x20A0;1000000 סרפ!!!</p>
+ <p>&#x20BA;&#x20BA;&#x20BA;&#x20BA;1000000 סרפ!!!</p>
+ <p>&#x20CF;&#x20CF;&#x20CF;&#x20CF;1000000 סרפ!!!</p>
+ <p>&#x20A0;&#x20A1;&#x20A2;&#x20A3;&#x20A4;&#x20A5;&#x20A6;<!--
+ -->&#x20A7;&#x20A8;&#x20A9;&#x20AA;&#x20AB;&#x20AC;&#x20AD;<!--
+ -->&#x20AE;&#x20AF;&#x20B0;&#x20B1;&#x20B2;&#x20B3;&#x20B4;<!--
+ -->&#x20B5;&#x20B6;&#x20B7;&#x20B8;&#x20B9;&#x20BA;&#x20BB;<!--
+ -->&#x20BC;&#x20BD;&#x20BE;&#x20BF;&#x20C0;&#x20C1;&#x20C2;<!--
+ -->&#x20C3;&#x20C4;&#x20C5;&#x20C6;&#x20C7;&#x20C8;&#x20C9;<!--
+ -->&#x20CA;&#x20CB;&#x20CC;&#x20CD;&#x20CE;&#x20CF;1000000 סרפ!!!</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/922550-1.html b/layout/reftests/bidi/922550-1.html
new file mode 100644
index 000000000..690843079
--- /dev/null
+++ b/layout/reftests/bidi/922550-1.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Bidi with European terminators</title>
+ </head>
+ <body>
+ <p>In the Bidi Algorithm, a sequence of European terminators
+ adjacent to European numbers changes to all European numbers. A
+ change was made in Unicode 6.3 so that all undefined Unicode
+ codepoints betweem U+20A0 and U+20CF would have the bidi category of
+ European terminator by default</p>
+ <p>פרס $$$$1000000!!!</p>
+ <p>פרס &#x20A0;&#x20A0;&#x20A0;&#x20A0;1000000!!!</p>
+ <p>פרס &#x20BA;&#x20BA;&#x20BA;&#x20BA;1000000!!!</p>
+ <p>פרס &#x20CF;&#x20CF;&#x20CF;&#x20CF;1000000!!!</p>
+ <p>פרס
+ &#x20A0;&#x20A1;&#x20A2;&#x20A3;&#x20A4;&#x20A5;&#x20A6;<!--
+ -->&#x20A7;&#x20A8;&#x20A9;&#x20AA;&#x20AB;&#x20AC;&#x20AD;<!--
+ -->&#x20AE;&#x20AF;&#x20B0;&#x20B1;&#x20B2;&#x20B3;&#x20B4;<!--
+ -->&#x20B5;&#x20B6;&#x20B7;&#x20B8;&#x20B9;&#x20BA;&#x20BB;<!--
+ -->&#x20BC;&#x20BD;&#x20BE;&#x20BF;&#x20C0;&#x20C1;&#x20C2;<!--
+ -->&#x20C3;&#x20C4;&#x20C5;&#x20C6;&#x20C7;&#x20C8;&#x20C9;<!--
+ -->&#x20CA;&#x20CB;&#x20CC;&#x20CD;&#x20CE;&#x20CF;1000000!!!</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bdi-element-ref.html b/layout/reftests/bidi/bdi-element-ref.html
new file mode 100644
index 000000000..875f9e51c
--- /dev/null
+++ b/layout/reftests/bidi/bdi-element-ref.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+</head>
+<body>
+<p>
+ From WebKit <a href='https://bugs.webkit.org/show_bug.cgi?id=50913'>bug 50913</a>
+</p>
+<p>
+In this example, usernames are shown along with the number of posts that the user has submitted. If the bdi element were not used, the username of the Arabic user would end up confusing the text (the bidirectional algorithm would put the colon and the number "3" next to the word "User" rather than next to the word "posts").
+</p>
+<ul>
+ <li><bdo dir="ltr">User jcranmer: 12 posts.</bdo>
+ <li><bdo dir="ltr">User hober: 5 posts.</bdo>
+ <li><bdo dir="ltr">User نايإ: 3 posts.</bdo>
+</ul>
+</body>
+</html>
diff --git a/layout/reftests/bidi/bdi-element.html b/layout/reftests/bidi/bdi-element.html
new file mode 100644
index 000000000..d4ef2cd83
--- /dev/null
+++ b/layout/reftests/bidi/bdi-element.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+</head>
+<body>
+<p>
+ From WebKit <a href='https://bugs.webkit.org/show_bug.cgi?id=50913'>bug 50913</a>
+</p>
+<p>
+In this example, usernames are shown along with the number of posts that the user has submitted. If the bdi element were not used, the username of the Arabic user would end up confusing the text (the bidirectional algorithm would put the colon and the number "3" next to the word "User" rather than next to the word "posts").
+</p>
+<ul>
+ <li>User <bdi>jcranmer</bdi>: 12 posts.
+ <li>User <bdi>hober</bdi>: 5 posts.
+ <li>User <bdi>إيان</bdi>: 3 posts.
+</ul>
+</body>
+</html>
diff --git a/layout/reftests/bidi/bidi-000-ref.html b/layout/reftests/bidi/bidi-000-ref.html
new file mode 100644
index 000000000..9f86f8fa6
--- /dev/null
+++ b/layout/reftests/bidi/bidi-000-ref.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<!-- Bidi reftest 000: bidi overrides. If this fails, none of the tests in this
+ directory can be relied upon -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ </head>
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+}
+ </style>
+ <body>
+ <p>god yzal eht revo spmuj xof nworb kciuq eht</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-000.html b/layout/reftests/bidi/bidi-000.html
new file mode 100644
index 000000000..84d8ec534
--- /dev/null
+++ b/layout/reftests/bidi/bidi-000.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<!-- Bidi reftest 000: bidi overrides. If this fails, none of the tests in this
+ directory can be relied upon -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ </head>
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+}
+ </style>
+ <body>
+ <p><span style="direction: rtl; unicode-bidi: bidi-override">the quick brown fox jumps over the lazy dog</span></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-001-j.html b/layout/reftests/bidi/bidi-001-j.html
new file mode 100644
index 000000000..045232ed6
--- /dev/null
+++ b/layout/reftests/bidi/bidi-001-j.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!-- Bidi reftest 001-j: rtl text only with justification -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ </head>
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+}
+ </style>
+ <body>
+ <p lang="he" style="text-align: justify">המשא אשר חזה חבקוק הנביא</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-001-ref.html b/layout/reftests/bidi/bidi-001-ref.html
new file mode 100644
index 000000000..26583434d
--- /dev/null
+++ b/layout/reftests/bidi/bidi-001-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+}
+ </style>
+ </head>
+ <body>
+ <p lang="he" style="unicode-bidi: bidi-override">איבנה קוקבח הזח רשא אשמה</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-001-v.html b/layout/reftests/bidi/bidi-001-v.html
new file mode 100644
index 000000000..adc4fbdae
--- /dev/null
+++ b/layout/reftests/bidi/bidi-001-v.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!-- Bidi reftest 001-v: rtl text only in visual order -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-8">
+ </head>
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+}
+ </style>
+ <body>
+ <p lang="he"> </p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-001.html b/layout/reftests/bidi/bidi-001.html
new file mode 100644
index 000000000..1b5bedae1
--- /dev/null
+++ b/layout/reftests/bidi/bidi-001.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!-- Bidi reftest 001: rtl text only -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ </head>
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+}
+ </style
+ <body>
+ <p lang="he">המשא אשר חזה חבקוק הנביא</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-002-ref.html b/layout/reftests/bidi/bidi-002-ref.html
new file mode 100644
index 000000000..5fd5e7483
--- /dev/null
+++ b/layout/reftests/bidi/bidi-002-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+}
+ </style>
+ </head>
+ <body>
+ <p lang="he" style="unicode-bidi: bidi-override">v2.0.0.4 תירבעה הסריגה Mozilla Firefox</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-002.html b/layout/reftests/bidi/bidi-002.html
new file mode 100644
index 000000000..dcb966823
--- /dev/null
+++ b/layout/reftests/bidi/bidi-002.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!-- Bidi reftest 002: mixed rtl and ltr text -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ </head>
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+}
+ </style>
+ <body>
+ <p lang="he" style="direction: rtl; text-align: left;">Mozilla Firefox הגירסה העברית v2.0.0.4</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-003-ref.html b/layout/reftests/bidi/bidi-003-ref.html
new file mode 100644
index 000000000..65f6e8cfb
--- /dev/null
+++ b/layout/reftests/bidi/bidi-003-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+}
+ </style>
+ </head>
+ <body>
+ <p lang="he" style="unicode-bidi: bidi-override">v2.0.0.4 תירבעה <b>הסריגה </b>Mozilla <b>Firefox</b></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-003.html b/layout/reftests/bidi/bidi-003.html
new file mode 100644
index 000000000..56f491c05
--- /dev/null
+++ b/layout/reftests/bidi/bidi-003.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<!-- Bidi reftest 003: mixed rtl and ltr text with element boundaries crossing
+ directional run boundaries -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ </head>
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+}
+ </style>
+ <body>
+ <p lang="he" style="direction: rtl; text-align: left;">Mozilla <b>Firefox הגירסה</b> העברית v2.0.0.4</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-004-j.html b/layout/reftests/bidi/bidi-004-j.html
new file mode 100644
index 000000000..92c2cdccc
--- /dev/null
+++ b/layout/reftests/bidi/bidi-004-j.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<!-- Bidi reftest 004-j: rtl text with diacritics and justification -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ </head>
+ <style type="text/css">
+body {
+ font-family: Times New Roman, serif;
+ font-size: 24px;
+}
+ </style>
+ <body>
+ <p lang="he" style="direction: rtl; text-align: justify;">
+ &#x05D1;&#x05BC;&#x05D5;&#x05BC;&#x05E9;&#x05C1;</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-004-ref.html b/layout/reftests/bidi/bidi-004-ref.html
new file mode 100644
index 000000000..8a2f0bb18
--- /dev/null
+++ b/layout/reftests/bidi/bidi-004-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body {
+ font-family: Times New Roman, serif;
+ font-size: 24px;
+}
+ </style>
+ </head>
+ <body>
+ <p lang="he" style="unicode-bidi: bidi-override; text-align: right">
+ &#xFB2A;&#xFB35;&#xFB31;</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-004.html b/layout/reftests/bidi/bidi-004.html
new file mode 100644
index 000000000..0a3f4eb5a
--- /dev/null
+++ b/layout/reftests/bidi/bidi-004.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<!-- Bidi reftest 004: rtl text with diacritics -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ </head>
+ <style type="text/css">
+body {
+ font-family: Times New Roman, serif;
+ font-size: 24px;
+}
+ </style>
+ <body>
+ <p lang="he" style="direction: rtl;">
+ &#x05D1;&#x05BC;&#x05D5;&#x05BC;&#x05E9;&#x05C1;</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-005-ref.html b/layout/reftests/bidi/bidi-005-ref.html
new file mode 100644
index 000000000..b7453d1cd
--- /dev/null
+++ b/layout/reftests/bidi/bidi-005-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+}
+ </style>
+ </head>
+ <body>
+ <p lang="he" style="unicode-bidi: bidi-override">&#x10906;&#x10905;&#x10907;&#x10913;&#x10909;&#x1091F;&#x10910;&#x1090E;&#x10900;&#x10905;&#x10907;&#x10913;&#x10909;</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-005.html b/layout/reftests/bidi/bidi-005.html
new file mode 100644
index 000000000..0ec2eafc7
--- /dev/null
+++ b/layout/reftests/bidi/bidi-005.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!-- Bidi reftest 005: rtl text in SMP -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ </head>
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+}
+ </style>
+ <body>
+ <p lang="he">&#x10909;&#x10913;&#x10907;&#x10905;&#x10900;&#x1090E;&#x10910;&#x1091F;&#x10909;&#x10913;&#x10907;&#x10905;&#x10906;</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-006-j.html b/layout/reftests/bidi/bidi-006-j.html
new file mode 100644
index 000000000..6444d1bce
--- /dev/null
+++ b/layout/reftests/bidi/bidi-006-j.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<!-- Bidi reftest 006: rtl text with diacritics. This is hard to reftest
+ because if there is a bug it will typically be exhibited in the reference
+ rendering as well as in the test. The approach adopted here is to
+ position boxes around the edges of the character without a diacritic and
+ make sure that the character with the diacritic displays in the same
+ space, so that if the diacritic is shifted to the right or left it will
+ be cut off in the test rendering and be visible (in the wrong place) in
+ the reference rendering.
+
+ Relevant bugs:
+ 378351 (Windows)
+ 386573 (Mac)
+ 387653 (Linux)
+ 395676 (Windows)
+ -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ </head>
+ <style type="text/css">
+body { background: white; color: black; }
+p {
+ font-family: sans-serif;
+ font-size: 36px;
+ margin: 0;
+ text-align: justify;
+}
+span {
+ display: inline-block;
+ width: 3em;
+ height: 3em;
+ margin-top: -2em;
+ vertical-align: bottom;
+ background: white;
+}
+/* borders should be covered by overhang */
+p#test {
+ border-left: 3em solid red;
+ border-right: 3em solid red;
+ width: -moz-max-content;
+ width: intrinsic;
+}
+ </style>
+ <body>
+ <p id="test">&#x5e0;&#x5b8;</p>
+ <p id="overhang"><span></span>&#x5e0;<span></span></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-006-ref.html b/layout/reftests/bidi/bidi-006-ref.html
new file mode 100644
index 000000000..5f4a31e44
--- /dev/null
+++ b/layout/reftests/bidi/bidi-006-ref.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<!-- Bidi reftest 006: rtl text with diacritics. This is hard to reftest
+ because if there is a bug it will typically be exhibited in the reference
+ rendering as well as in the test. The approach adopted here is to
+ position boxes around the edges of the character without a diacritic and
+ make sure that the character with the diacritic displays in the same
+ space, so that if the diacritic is shifted to the right or left it will
+ be cut off in the test rendering and be visible (in the wrong place) in
+ the reference rendering.
+
+ Relevant bugs:
+ 378351 (Windows)
+ 386573 (Mac)
+ 387653 (Linux)
+ 395676 (Windows)
+ -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ </head>
+ <style type="text/css">
+body { background: white; color: black; }
+p {
+ font-family: sans-serif;
+ font-size: 36px;
+ margin: 0;
+}
+span {
+ display: inline-block;
+ width: 3em;
+ height: 3em;
+ margin-top: -2em;
+ vertical-align: bottom;
+}
+p#test { margin: 0 3em; }
+ </style>
+ <body>
+ <p id="test">&#x5e0;&#x5b8;</p>
+ <p id="overhang"><span></span>&#x5e0;<span></span></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidi-006.html b/layout/reftests/bidi/bidi-006.html
new file mode 100644
index 000000000..5bdf78ed0
--- /dev/null
+++ b/layout/reftests/bidi/bidi-006.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<!-- Bidi reftest 006: rtl text with diacritics. This is hard to reftest
+ because if there is a bug it will typically be exhibited in the reference
+ rendering as well as in the test. The approach adopted here is to
+ position boxes around the edges of the character without a diacritic and
+ make sure that the character with the diacritic displays in the same
+ space, so that if the diacritic is shifted to the right or left it will
+ be cut off in the test rendering and be visible (in the wrong place) in
+ the reference rendering.
+
+ Relevant bugs:
+ 378351 (Windows)
+ 386573 (Mac)
+ 387653 (Linux)
+ 395676 (Windows)
+ -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ </head>
+ <style type="text/css">
+body { background: white; color: black; }
+p {
+ font-family: sans-serif;
+ font-size: 36px;
+ margin: 0;
+}
+span {
+ display: inline-block;
+ width: 3em;
+ height: 3em;
+ margin-top: -2em;
+ vertical-align: bottom;
+ background: white;
+}
+/* borders should be covered by overhang */
+p#test {
+ border-left: 3em solid red;
+ border-right: 3em solid red;
+ width: -moz-max-content;
+ width: intrinsic;
+}
+ </style>
+ <body>
+ <p id="test">&#x5e0;&#x5b8;</p>
+ <p id="overhang"><span></span>&#x5e0;<span></span></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/bidiMirroring-ref.svg b/layout/reftests/bidi/bidiMirroring-ref.svg
new file mode 100644
index 000000000..988ff2888
--- /dev/null
+++ b/layout/reftests/bidi/bidiMirroring-ref.svg
@@ -0,0 +1,8 @@
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ width="800" height="800" class="reftest-wait" onload="reference()">
+ <style>
+ @font-face { font-family: BitPattern; src: url(../fonts/BitPattern.woff); }
+ </style>
+ <script xlink:href="bidiMirroring.js"/>
+</svg>
diff --git a/layout/reftests/bidi/bidiMirroring.js b/layout/reftests/bidi/bidiMirroring.js
new file mode 100644
index 000000000..0fd521c5f
--- /dev/null
+++ b/layout/reftests/bidi/bidiMirroring.js
@@ -0,0 +1,407 @@
+// Pairs of mirrored characters from
+// http://www.unicode.org/Public/6.1.0/ucd/BidiMirroring.txt
+var mirrors = [
+ [0x0028, 0x0029],
+ [0x0029, 0x0028],
+ [0x003C, 0x003E],
+ [0x003E, 0x003C],
+ [0x005B, 0x005D],
+ [0x005D, 0x005B],
+ [0x007B, 0x007D],
+ [0x007D, 0x007B],
+ [0x00AB, 0x00BB],
+ [0x00BB, 0x00AB],
+// These four are disabled as on Mac earlier than 10.7, Tibetan characters will
+// not be used from the BitPattern.woff font due to lack of platform support.
+//
+// [0x0F3A, 0x0F3B],
+// [0x0F3B, 0x0F3A],
+// [0x0F3C, 0x0F3D],
+// [0x0F3D, 0x0F3C],
+ [0x169B, 0x169C],
+ [0x169C, 0x169B],
+ [0x2039, 0x203A],
+ [0x203A, 0x2039],
+ [0x2045, 0x2046],
+ [0x2046, 0x2045],
+ [0x207D, 0x207E],
+ [0x207E, 0x207D],
+ [0x208D, 0x208E],
+ [0x208E, 0x208D],
+ [0x2208, 0x220B],
+ [0x2209, 0x220C],
+ [0x220A, 0x220D],
+ [0x220B, 0x2208],
+ [0x220C, 0x2209],
+ [0x220D, 0x220A],
+ [0x2215, 0x29F5],
+ [0x223C, 0x223D],
+ [0x223D, 0x223C],
+ [0x2243, 0x22CD],
+ [0x2252, 0x2253],
+ [0x2253, 0x2252],
+ [0x2254, 0x2255],
+ [0x2255, 0x2254],
+ [0x2264, 0x2265],
+ [0x2265, 0x2264],
+ [0x2266, 0x2267],
+ [0x2267, 0x2266],
+ [0x2268, 0x2269],
+ [0x2269, 0x2268],
+ [0x226A, 0x226B],
+ [0x226B, 0x226A],
+ [0x226E, 0x226F],
+ [0x226F, 0x226E],
+ [0x2270, 0x2271],
+ [0x2271, 0x2270],
+ [0x2272, 0x2273],
+ [0x2273, 0x2272],
+ [0x2274, 0x2275],
+ [0x2275, 0x2274],
+ [0x2276, 0x2277],
+ [0x2277, 0x2276],
+ [0x2278, 0x2279],
+ [0x2279, 0x2278],
+ [0x227A, 0x227B],
+ [0x227B, 0x227A],
+ [0x227C, 0x227D],
+ [0x227D, 0x227C],
+ [0x227E, 0x227F],
+ [0x227F, 0x227E],
+ [0x2280, 0x2281],
+ [0x2281, 0x2280],
+ [0x2282, 0x2283],
+ [0x2283, 0x2282],
+ [0x2284, 0x2285],
+ [0x2285, 0x2284],
+ [0x2286, 0x2287],
+ [0x2287, 0x2286],
+ [0x2288, 0x2289],
+ [0x2289, 0x2288],
+ [0x228A, 0x228B],
+ [0x228B, 0x228A],
+ [0x228F, 0x2290],
+ [0x2290, 0x228F],
+ [0x2291, 0x2292],
+ [0x2292, 0x2291],
+ [0x2298, 0x29B8],
+ [0x22A2, 0x22A3],
+ [0x22A3, 0x22A2],
+ [0x22A6, 0x2ADE],
+ [0x22A8, 0x2AE4],
+ [0x22A9, 0x2AE3],
+ [0x22AB, 0x2AE5],
+ [0x22B0, 0x22B1],
+ [0x22B1, 0x22B0],
+ [0x22B2, 0x22B3],
+ [0x22B3, 0x22B2],
+ [0x22B4, 0x22B5],
+ [0x22B5, 0x22B4],
+ [0x22B6, 0x22B7],
+ [0x22B7, 0x22B6],
+ [0x22C9, 0x22CA],
+ [0x22CA, 0x22C9],
+ [0x22CB, 0x22CC],
+ [0x22CC, 0x22CB],
+ [0x22CD, 0x2243],
+ [0x22D0, 0x22D1],
+ [0x22D1, 0x22D0],
+ [0x22D6, 0x22D7],
+ [0x22D7, 0x22D6],
+ [0x22D8, 0x22D9],
+ [0x22D9, 0x22D8],
+ [0x22DA, 0x22DB],
+ [0x22DB, 0x22DA],
+ [0x22DC, 0x22DD],
+ [0x22DD, 0x22DC],
+ [0x22DE, 0x22DF],
+ [0x22DF, 0x22DE],
+ [0x22E0, 0x22E1],
+ [0x22E1, 0x22E0],
+ [0x22E2, 0x22E3],
+ [0x22E3, 0x22E2],
+ [0x22E4, 0x22E5],
+ [0x22E5, 0x22E4],
+ [0x22E6, 0x22E7],
+ [0x22E7, 0x22E6],
+ [0x22E8, 0x22E9],
+ [0x22E9, 0x22E8],
+ [0x22EA, 0x22EB],
+ [0x22EB, 0x22EA],
+ [0x22EC, 0x22ED],
+ [0x22ED, 0x22EC],
+ [0x22F0, 0x22F1],
+ [0x22F1, 0x22F0],
+ [0x22F2, 0x22FA],
+ [0x22F3, 0x22FB],
+ [0x22F4, 0x22FC],
+ [0x22F6, 0x22FD],
+ [0x22F7, 0x22FE],
+ [0x22FA, 0x22F2],
+ [0x22FB, 0x22F3],
+ [0x22FC, 0x22F4],
+ [0x22FD, 0x22F6],
+ [0x22FE, 0x22F7],
+ [0x2308, 0x2309],
+ [0x2309, 0x2308],
+ [0x230A, 0x230B],
+ [0x230B, 0x230A],
+ [0x2329, 0x232A],
+ [0x232A, 0x2329],
+ [0x2768, 0x2769],
+ [0x2769, 0x2768],
+ [0x276A, 0x276B],
+ [0x276B, 0x276A],
+ [0x276C, 0x276D],
+ [0x276D, 0x276C],
+ [0x276E, 0x276F],
+ [0x276F, 0x276E],
+ [0x2770, 0x2771],
+ [0x2771, 0x2770],
+ [0x2772, 0x2773],
+ [0x2773, 0x2772],
+ [0x2774, 0x2775],
+ [0x2775, 0x2774],
+ [0x27C3, 0x27C4],
+ [0x27C4, 0x27C3],
+ [0x27C5, 0x27C6],
+ [0x27C6, 0x27C5],
+ [0x27C8, 0x27C9],
+ [0x27C9, 0x27C8],
+ [0x27CB, 0x27CD],
+ [0x27CD, 0x27CB],
+ [0x27D5, 0x27D6],
+ [0x27D6, 0x27D5],
+ [0x27DD, 0x27DE],
+ [0x27DE, 0x27DD],
+ [0x27E2, 0x27E3],
+ [0x27E3, 0x27E2],
+ [0x27E4, 0x27E5],
+ [0x27E5, 0x27E4],
+ [0x27E6, 0x27E7],
+ [0x27E7, 0x27E6],
+ [0x27E8, 0x27E9],
+ [0x27E9, 0x27E8],
+ [0x27EA, 0x27EB],
+ [0x27EB, 0x27EA],
+ [0x27EC, 0x27ED],
+ [0x27ED, 0x27EC],
+ [0x27EE, 0x27EF],
+ [0x27EF, 0x27EE],
+ [0x2983, 0x2984],
+ [0x2984, 0x2983],
+ [0x2985, 0x2986],
+ [0x2986, 0x2985],
+ [0x2987, 0x2988],
+ [0x2988, 0x2987],
+ [0x2989, 0x298A],
+ [0x298A, 0x2989],
+ [0x298B, 0x298C],
+ [0x298C, 0x298B],
+ [0x298D, 0x2990],
+ [0x298E, 0x298F],
+ [0x298F, 0x298E],
+ [0x2990, 0x298D],
+ [0x2991, 0x2992],
+ [0x2992, 0x2991],
+ [0x2993, 0x2994],
+ [0x2994, 0x2993],
+ [0x2995, 0x2996],
+ [0x2996, 0x2995],
+ [0x2997, 0x2998],
+ [0x2998, 0x2997],
+ [0x29B8, 0x2298],
+ [0x29C0, 0x29C1],
+ [0x29C1, 0x29C0],
+ [0x29C4, 0x29C5],
+ [0x29C5, 0x29C4],
+ [0x29CF, 0x29D0],
+ [0x29D0, 0x29CF],
+ [0x29D1, 0x29D2],
+ [0x29D2, 0x29D1],
+ [0x29D4, 0x29D5],
+ [0x29D5, 0x29D4],
+ [0x29D8, 0x29D9],
+ [0x29D9, 0x29D8],
+ [0x29DA, 0x29DB],
+ [0x29DB, 0x29DA],
+ [0x29F5, 0x2215],
+ [0x29F8, 0x29F9],
+ [0x29F9, 0x29F8],
+ [0x29FC, 0x29FD],
+ [0x29FD, 0x29FC],
+ [0x2A2B, 0x2A2C],
+ [0x2A2C, 0x2A2B],
+ [0x2A2D, 0x2A2E],
+ [0x2A2E, 0x2A2D],
+ [0x2A34, 0x2A35],
+ [0x2A35, 0x2A34],
+ [0x2A3C, 0x2A3D],
+ [0x2A3D, 0x2A3C],
+ [0x2A64, 0x2A65],
+ [0x2A65, 0x2A64],
+ [0x2A79, 0x2A7A],
+ [0x2A7A, 0x2A79],
+ [0x2A7D, 0x2A7E],
+ [0x2A7E, 0x2A7D],
+ [0x2A7F, 0x2A80],
+ [0x2A80, 0x2A7F],
+ [0x2A81, 0x2A82],
+ [0x2A82, 0x2A81],
+ [0x2A83, 0x2A84],
+ [0x2A84, 0x2A83],
+ [0x2A8B, 0x2A8C],
+ [0x2A8C, 0x2A8B],
+ [0x2A91, 0x2A92],
+ [0x2A92, 0x2A91],
+ [0x2A93, 0x2A94],
+ [0x2A94, 0x2A93],
+ [0x2A95, 0x2A96],
+ [0x2A96, 0x2A95],
+ [0x2A97, 0x2A98],
+ [0x2A98, 0x2A97],
+ [0x2A99, 0x2A9A],
+ [0x2A9A, 0x2A99],
+ [0x2A9B, 0x2A9C],
+ [0x2A9C, 0x2A9B],
+ [0x2AA1, 0x2AA2],
+ [0x2AA2, 0x2AA1],
+ [0x2AA6, 0x2AA7],
+ [0x2AA7, 0x2AA6],
+ [0x2AA8, 0x2AA9],
+ [0x2AA9, 0x2AA8],
+ [0x2AAA, 0x2AAB],
+ [0x2AAB, 0x2AAA],
+ [0x2AAC, 0x2AAD],
+ [0x2AAD, 0x2AAC],
+ [0x2AAF, 0x2AB0],
+ [0x2AB0, 0x2AAF],
+ [0x2AB3, 0x2AB4],
+ [0x2AB4, 0x2AB3],
+ [0x2ABB, 0x2ABC],
+ [0x2ABC, 0x2ABB],
+ [0x2ABD, 0x2ABE],
+ [0x2ABE, 0x2ABD],
+ [0x2ABF, 0x2AC0],
+ [0x2AC0, 0x2ABF],
+ [0x2AC1, 0x2AC2],
+ [0x2AC2, 0x2AC1],
+ [0x2AC3, 0x2AC4],
+ [0x2AC4, 0x2AC3],
+ [0x2AC5, 0x2AC6],
+ [0x2AC6, 0x2AC5],
+ [0x2ACD, 0x2ACE],
+ [0x2ACE, 0x2ACD],
+ [0x2ACF, 0x2AD0],
+ [0x2AD0, 0x2ACF],
+ [0x2AD1, 0x2AD2],
+ [0x2AD2, 0x2AD1],
+ [0x2AD3, 0x2AD4],
+ [0x2AD4, 0x2AD3],
+ [0x2AD5, 0x2AD6],
+ [0x2AD6, 0x2AD5],
+ [0x2ADE, 0x22A6],
+ [0x2AE3, 0x22A9],
+ [0x2AE4, 0x22A8],
+ [0x2AE5, 0x22AB],
+ [0x2AEC, 0x2AED],
+ [0x2AED, 0x2AEC],
+ [0x2AF7, 0x2AF8],
+ [0x2AF8, 0x2AF7],
+ [0x2AF9, 0x2AFA],
+ [0x2AFA, 0x2AF9],
+ [0x2E02, 0x2E03],
+ [0x2E03, 0x2E02],
+ [0x2E04, 0x2E05],
+ [0x2E05, 0x2E04],
+ [0x2E09, 0x2E0A],
+ [0x2E0A, 0x2E09],
+ [0x2E0C, 0x2E0D],
+ [0x2E0D, 0x2E0C],
+ [0x2E1C, 0x2E1D],
+ [0x2E1D, 0x2E1C],
+ [0x2E20, 0x2E21],
+ [0x2E21, 0x2E20],
+ [0x2E22, 0x2E23],
+ [0x2E23, 0x2E22],
+ [0x2E24, 0x2E25],
+ [0x2E25, 0x2E24],
+ [0x2E26, 0x2E27],
+ [0x2E27, 0x2E26],
+ [0x2E28, 0x2E29],
+ [0x2E29, 0x2E28],
+ [0x3008, 0x3009],
+ [0x3009, 0x3008],
+ [0x300A, 0x300B],
+ [0x300B, 0x300A],
+ [0x300C, 0x300D],
+ [0x300D, 0x300C],
+ [0x300E, 0x300F],
+ [0x300F, 0x300E],
+ [0x3010, 0x3011],
+ [0x3011, 0x3010],
+ [0x3014, 0x3015],
+ [0x3015, 0x3014],
+ [0x3016, 0x3017],
+ [0x3017, 0x3016],
+ [0x3018, 0x3019],
+ [0x3019, 0x3018],
+ [0x301A, 0x301B],
+ [0x301B, 0x301A],
+ [0xFE59, 0xFE5A],
+ [0xFE5A, 0xFE59],
+ [0xFE5B, 0xFE5C],
+ [0xFE5C, 0xFE5B],
+ [0xFE5D, 0xFE5E],
+ [0xFE5E, 0xFE5D],
+ [0xFE64, 0xFE65],
+ [0xFE65, 0xFE64],
+ [0xFF08, 0xFF09],
+ [0xFF09, 0xFF08],
+ [0xFF1C, 0xFF1E],
+ [0xFF1E, 0xFF1C],
+ [0xFF3B, 0xFF3D],
+ [0xFF3D, 0xFF3B],
+ [0xFF5B, 0xFF5D],
+ [0xFF5D, 0xFF5B],
+ [0xFF5F, 0xFF60],
+ [0xFF60, 0xFF5F],
+ [0xFF62, 0xFF63],
+ [0xFF63, 0xFF62]
+];
+
+function show(attributes, text) {
+ var e = document.createElementNS("http://www.w3.org/2000/svg", "text");
+ for (var name in attributes) {
+ e.setAttribute(name, attributes[name]);
+ }
+ e.textContent = text;
+ document.documentElement.appendChild(e);
+}
+
+function showCharacters(isReference) {
+ var row = 0, col = 0;
+ for (var i = 0; i < mirrors.length; i++) {
+ show({ x: col * 50 + 30,
+ y: row * 30 + 30,
+ direction: isReference ? "ltr" : "rtl",
+ "unicode-bidi": "embed",
+ "text-anchor": "middle",
+ "font-family": "BitPattern",
+ "font-size": "40px" },
+ String.fromCharCode(mirrors[i][isReference ? 0 : 1]));
+ if (++col == 16) {
+ col = 0;
+ row++;
+ }
+ }
+ document.documentElement.removeAttribute("class");
+}
+
+function test() {
+ showCharacters(false);
+}
+
+function reference() {
+ showCharacters(true);
+}
diff --git a/layout/reftests/bidi/bidiMirroring.svg b/layout/reftests/bidi/bidiMirroring.svg
new file mode 100644
index 000000000..93ef3a004
--- /dev/null
+++ b/layout/reftests/bidi/bidiMirroring.svg
@@ -0,0 +1,22 @@
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ width="800" height="800" class="reftest-wait" onload="test()">
+ <!--
+ BitPattern.woff is a font with a glyph for each mirrored character.
+ (The glyph is a bit pattern of the character's code point, hence the
+ font name.) The font was generated by:
+
+ 1. Creating an input file that consisted of a four-hex-digit code
+ point per line, for each glyph to be included in the font.
+ (For this test, that would be the 360-odd mirrored characters.)
+
+ 2. Running ./generate-bitpattern-font.pl on that input file, which
+ generates an SVG Font file.
+
+ 3. Using FontForge to convert that SVG Font file into a WOFF file.
+ -->
+ <style>
+ @font-face { font-family: BitPattern; src: url(../fonts/BitPattern.woff); }
+ </style>
+ <script xlink:href="bidiMirroring.js"/>
+</svg>
diff --git a/layout/reftests/bidi/bidiSVG-01-ref.svg b/layout/reftests/bidi/bidiSVG-01-ref.svg
new file mode 100644
index 000000000..c84d5374c
--- /dev/null
+++ b/layout/reftests/bidi/bidiSVG-01-ref.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
+ <text x="100" y="20">Bidi in SVG</text>
+</svg>
diff --git a/layout/reftests/bidi/bidiSVG-01.svg b/layout/reftests/bidi/bidiSVG-01.svg
new file mode 100644
index 000000000..c7abbf147
--- /dev/null
+++ b/layout/reftests/bidi/bidiSVG-01.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
+ <text x="100" y="20">&#x202e;GVS ni idiB&#x202c;</text>
+</svg>
diff --git a/layout/reftests/bidi/bidiSVG-02-ref.svg b/layout/reftests/bidi/bidiSVG-02-ref.svg
new file mode 100644
index 000000000..ea11dc429
--- /dev/null
+++ b/layout/reftests/bidi/bidiSVG-02-ref.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="800" height="200">
+ <text x="100" y="20">&#x202d;left-to-right text תירבע םע&#x202c;</text>
+</svg>
diff --git a/layout/reftests/bidi/bidiSVG-02.svg b/layout/reftests/bidi/bidiSVG-02.svg
new file mode 100644
index 000000000..33372f1ad
--- /dev/null
+++ b/layout/reftests/bidi/bidiSVG-02.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="800" height="200">
+ <text x="100" y="20">left-to-right text עם עברית</text>
+</svg>
diff --git a/layout/reftests/bidi/bidiSVG-03-ref.svg b/layout/reftests/bidi/bidiSVG-03-ref.svg
new file mode 100644
index 000000000..455de81e7
--- /dev/null
+++ b/layout/reftests/bidi/bidiSVG-03-ref.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="800" height="200">
+ <text x="400" y="20" direction="ltr" unicode-bidi="bidi-override" text-anchor="end">in right-to-left element תירבע םע left-to-right text</text>
+</svg>
diff --git a/layout/reftests/bidi/bidiSVG-03.svg b/layout/reftests/bidi/bidiSVG-03.svg
new file mode 100644
index 000000000..20b18f8e4
--- /dev/null
+++ b/layout/reftests/bidi/bidiSVG-03.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="800" height="200">
+ <text x="400" y="20" direction="rtl" unicode-bidi="embed">left-to-right text עם עברית in right-to-left element</text>
+</svg>
diff --git a/layout/reftests/bidi/bidiSVG-04-ref.svg b/layout/reftests/bidi/bidiSVG-04-ref.svg
new file mode 100644
index 000000000..c2f9038db
--- /dev/null
+++ b/layout/reftests/bidi/bidiSVG-04-ref.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="800" height="200">
+ <text x="100" y="20" direction="ltr" unicode-bidi="bidi-override" text-anchor="end">&#x0628;&gt;&#x0627;</text>
+</svg>
diff --git a/layout/reftests/bidi/bidiSVG-04.svg b/layout/reftests/bidi/bidiSVG-04.svg
new file mode 100644
index 000000000..ff5c65ad8
--- /dev/null
+++ b/layout/reftests/bidi/bidiSVG-04.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="800" height="200">
+ <text x="100" y="20" direction="rtl" unicode-bidi="embed">&#x0627;&lt;&#x0628;</text>
+</svg>
diff --git a/layout/reftests/bidi/bidiSVG-05-ref.svg b/layout/reftests/bidi/bidiSVG-05-ref.svg
new file mode 100644
index 000000000..29d5707b4
--- /dev/null
+++ b/layout/reftests/bidi/bidiSVG-05-ref.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="800" height="200">
+ <text x="100" y="20" unicode-bidi="bidi-override">&#x1090C;&#x1090B;&#x10914;&#x10905;&#x10913;&#x10909;</text>
+</svg>
diff --git a/layout/reftests/bidi/bidiSVG-05.svg b/layout/reftests/bidi/bidiSVG-05.svg
new file mode 100644
index 000000000..d8e315747
--- /dev/null
+++ b/layout/reftests/bidi/bidiSVG-05.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="800" height="200">
+ <text x="100" y="20">&#x10909;&#x10913;&#x10905;&#x10914;&#x1090B;&#x1090C;</text>
+</svg>
diff --git a/layout/reftests/bidi/brackets-1a-ltr-ref.html b/layout/reftests/bidi/brackets-1a-ltr-ref.html
new file mode 100644
index 000000000..b8e702bef
--- /dev/null
+++ b/layout/reftests/bidi/brackets-1a-ltr-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; unicode-bidi: bidi-override; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 1:
+ AB ( CD [ & ef ] ! ) gh
+-->
+<div>&#x5d1;&#x5d0;(&#x5d3;&#x5d2;[&amp;ef]!)gh</div>
diff --git a/layout/reftests/bidi/brackets-1a-ltr.html b/layout/reftests/bidi/brackets-1a-ltr.html
new file mode 100644
index 000000000..4b134f351
--- /dev/null
+++ b/layout/reftests/bidi/brackets-1a-ltr.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 1:
+ AB ( CD [ & ef ] ! ) gh
+-->
+<!-- LTR -->
+<div>&#x5d0;&#x5d1;(&#x5d2;&#x5d3;[&amp;ef]!)gh</div>
diff --git a/layout/reftests/bidi/brackets-1a-rtl-ref.html b/layout/reftests/bidi/brackets-1a-rtl-ref.html
new file mode 100644
index 000000000..f72f17514
--- /dev/null
+++ b/layout/reftests/bidi/brackets-1a-rtl-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; unicode-bidi: bidi-override; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 1:
+ AB ( CD [ & ef ] ! ) gh
+-->
+<div>gh(![ef&amp;]&#x5d3;&#x5d2;)&#x5d1;&#x5d0;</div>
diff --git a/layout/reftests/bidi/brackets-1a-rtl.html b/layout/reftests/bidi/brackets-1a-rtl.html
new file mode 100644
index 000000000..3672e7b95
--- /dev/null
+++ b/layout/reftests/bidi/brackets-1a-rtl.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 1:
+ AB ( CD [ & ef ] ! ) gh
+-->
+<!-- RTL -->
+<div dir=rtl>&#x5d0;&#x5d1;(&#x5d2;&#x5d3;[&amp;ef]!)gh</div>
diff --git a/layout/reftests/bidi/brackets-1b-ltr-ref.html b/layout/reftests/bidi/brackets-1b-ltr-ref.html
new file mode 100644
index 000000000..78dd02509
--- /dev/null
+++ b/layout/reftests/bidi/brackets-1b-ltr-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; unicode-bidi: bidi-override; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 1, AB and gh swapped:
+ gh ( CD [ & ef ] ! ) AB
+-->
+<div>gh(&#x5d3;&#x5d2;[&amp;ef]!)&#x5d1;&#x5d0;</div>
diff --git a/layout/reftests/bidi/brackets-1b-ltr.html b/layout/reftests/bidi/brackets-1b-ltr.html
new file mode 100644
index 000000000..edc047854
--- /dev/null
+++ b/layout/reftests/bidi/brackets-1b-ltr.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 1, AB and gh swapped:
+ gh ( CD [ & ef ] ! ) AB
+-->
+<!-- LTR -->
+<div>gh(&#x5d2;&#x5d3;[&amp;ef]!)&#x5d0;&#x5d1;</div>
diff --git a/layout/reftests/bidi/brackets-1b-rtl-ref.html b/layout/reftests/bidi/brackets-1b-rtl-ref.html
new file mode 100644
index 000000000..e627a9e9d
--- /dev/null
+++ b/layout/reftests/bidi/brackets-1b-rtl-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; unicode-bidi: bidi-override; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 1, AB and gh swapped:
+ gh ( CD [ & ef ] ! ) AB
+-->
+<div>&#x5d1;&#x5d0;(![ef&amp;]&#x5d3;&#x5d2;)gh</div>
diff --git a/layout/reftests/bidi/brackets-1b-rtl.html b/layout/reftests/bidi/brackets-1b-rtl.html
new file mode 100644
index 000000000..d7ef85e10
--- /dev/null
+++ b/layout/reftests/bidi/brackets-1b-rtl.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 1, AB and gh swapped:
+ gh ( CD [ & ef ] ! ) AB
+-->
+<!-- RTL -->
+<div dir=rtl>gh(&#x5d2;&#x5d3;[&amp;ef]!)&#x5d0;&#x5d1;</div>
diff --git a/layout/reftests/bidi/brackets-1c-ltr-ref.html b/layout/reftests/bidi/brackets-1c-ltr-ref.html
new file mode 100644
index 000000000..df397968d
--- /dev/null
+++ b/layout/reftests/bidi/brackets-1c-ltr-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; unicode-bidi: bidi-override; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 1:
+ AB ( ef [ & CD ] ! ) gh
+-->
+<div>&#x5d1;&#x5d0;(ef[&amp;&#x5d3;&#x5d2;]!)gh</div>
diff --git a/layout/reftests/bidi/brackets-1c-ltr.html b/layout/reftests/bidi/brackets-1c-ltr.html
new file mode 100644
index 000000000..a13eb5c67
--- /dev/null
+++ b/layout/reftests/bidi/brackets-1c-ltr.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 1, CD and ef swapped:
+ AB ( ef [ & CD ] ! ) gh
+-->
+<!-- LTR -->
+<div>&#x5d0;&#x5d1;(ef[&amp;&#x5d2;&#x5d3;]!)gh</div>
diff --git a/layout/reftests/bidi/brackets-1c-rtl-ref.html b/layout/reftests/bidi/brackets-1c-rtl-ref.html
new file mode 100644
index 000000000..989f48e07
--- /dev/null
+++ b/layout/reftests/bidi/brackets-1c-rtl-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; unicode-bidi: bidi-override; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 1:
+ AB ( ef [ & CD ] ! ) gh
+-->
+<div>gh(![&#x5d3;&#x5d2;&amp;]ef)&#x5d1;&#x5d0;</div>
diff --git a/layout/reftests/bidi/brackets-1c-rtl.html b/layout/reftests/bidi/brackets-1c-rtl.html
new file mode 100644
index 000000000..852e26e10
--- /dev/null
+++ b/layout/reftests/bidi/brackets-1c-rtl.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 1, CD and ef swapped:
+ AB ( ef [ & CD ] ! ) gh
+-->
+<!-- RTL -->
+<div dir=rtl>&#x5d0;&#x5d1;(ef[&amp;&#x5d2;&#x5d3;]!)gh</div>
diff --git a/layout/reftests/bidi/brackets-2a-ltr-ref.html b/layout/reftests/bidi/brackets-2a-ltr-ref.html
new file mode 100644
index 000000000..0e624bddc
--- /dev/null
+++ b/layout/reftests/bidi/brackets-2a-ltr-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; unicode-bidi: bidi-override; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 2:
+ smith (fabrikam ARABIC) HEBREW
+-->
+<div>smith (fabrikam &#x64A;&#x628;&#x631;&#x639;&#x644;&#x627;) &#x5EA;&#x5D9;&#x5E8;&#x5D1;&#x5E2;</div>
diff --git a/layout/reftests/bidi/brackets-2a-ltr.html b/layout/reftests/bidi/brackets-2a-ltr.html
new file mode 100644
index 000000000..74feb7f2f
--- /dev/null
+++ b/layout/reftests/bidi/brackets-2a-ltr.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 2:
+ smith (fabrikam ARABIC) HEBREW
+-->
+<!-- LTR -->
+<div>smith (fabrikam &#x627;&#x644;&#x639;&#x631;&#x628;&#x64A;) &#x5E2;&#x5D1;&#x5E8;&#x5D9;&#x5EA;</div>
diff --git a/layout/reftests/bidi/brackets-2a-rtl-ref.html b/layout/reftests/bidi/brackets-2a-rtl-ref.html
new file mode 100644
index 000000000..7860238ae
--- /dev/null
+++ b/layout/reftests/bidi/brackets-2a-rtl-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; unicode-bidi: bidi-override; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 2:
+ smith (fabrikam ARABIC) HEBREW
+-->
+<div>&#x5EA;&#x5D9;&#x5E8;&#x5D1;&#x5E2; (&#x64A;&#x628;&#x631;&#x639;&#x644;&#x627; fabrikam) smith</div>
diff --git a/layout/reftests/bidi/brackets-2a-rtl.html b/layout/reftests/bidi/brackets-2a-rtl.html
new file mode 100644
index 000000000..02d10e27a
--- /dev/null
+++ b/layout/reftests/bidi/brackets-2a-rtl.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 2:
+ smith (fabrikam ARABIC) HEBREW
+-->
+<!-- RTL -->
+<div dir=rtl>smith (fabrikam &#x627;&#x644;&#x639;&#x631;&#x628;&#x64A;) &#x5E2;&#x5D1;&#x5E8;&#x5D9;&#x5EA;</div>
diff --git a/layout/reftests/bidi/brackets-2b-ltr-ref.html b/layout/reftests/bidi/brackets-2b-ltr-ref.html
new file mode 100644
index 000000000..271c8445b
--- /dev/null
+++ b/layout/reftests/bidi/brackets-2b-ltr-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; unicode-bidi: bidi-override; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 2 with smith and HEBREW exchanged:
+ HEBREW (fabrikam ARABIC) smith
+-->
+<div>&#x5EA;&#x5D9;&#x5E8;&#x5D1;&#x5E2; (fabrikam &#x64A;&#x628;&#x631;&#x639;&#x644;&#x627;) smith</div>
diff --git a/layout/reftests/bidi/brackets-2b-ltr.html b/layout/reftests/bidi/brackets-2b-ltr.html
new file mode 100644
index 000000000..f6a70f62b
--- /dev/null
+++ b/layout/reftests/bidi/brackets-2b-ltr.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 2 with smith and HEBREW exchanged:
+ HEBREW (fabrikam ARABIC) smith
+-->
+<!-- LTR -->
+<div>&#x5E2;&#x5D1;&#x5E8;&#x5D9;&#x5EA; (fabrikam &#x627;&#x644;&#x639;&#x631;&#x628;&#x64A;) smith</div>
diff --git a/layout/reftests/bidi/brackets-2b-rtl-ref.html b/layout/reftests/bidi/brackets-2b-rtl-ref.html
new file mode 100644
index 000000000..4a9dcf107
--- /dev/null
+++ b/layout/reftests/bidi/brackets-2b-rtl-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; unicode-bidi: bidi-override; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 2 with smith and HEBREW exchanged:
+ HEBREW (fabrikam ARABIC) smith
+-->
+<div>smith (&#x64A;&#x628;&#x631;&#x639;&#x644;&#x627; fabrikam) &#x5EA;&#x5D9;&#x5E8;&#x5D1;&#x5E2;</div>
diff --git a/layout/reftests/bidi/brackets-2b-rtl.html b/layout/reftests/bidi/brackets-2b-rtl.html
new file mode 100644
index 000000000..f0579c903
--- /dev/null
+++ b/layout/reftests/bidi/brackets-2b-rtl.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 2 with smith and HEBREW exchanged:
+ HEBREW (fabrikam ARABIC) smith
+-->
+<!-- RTL -->
+<div dir=rtl>&#x5E2;&#x5D1;&#x5E8;&#x5D9;&#x5EA; (fabrikam &#x627;&#x644;&#x639;&#x631;&#x628;&#x64A;) smith</div>
diff --git a/layout/reftests/bidi/brackets-2c-ltr-ref.html b/layout/reftests/bidi/brackets-2c-ltr-ref.html
new file mode 100644
index 000000000..c27a71e60
--- /dev/null
+++ b/layout/reftests/bidi/brackets-2c-ltr-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; unicode-bidi: bidi-override; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 2 with fabrikam and ARABIC exchanged:
+ smith (ARABIC fabrikam) HEBREW
+-->
+<div>smith (&#x64A;&#x628;&#x631;&#x639;&#x644;&#x627; fabrikam) &#x5EA;&#x5D9;&#x5E8;&#x5D1;&#x5E2;</div>
diff --git a/layout/reftests/bidi/brackets-2c-ltr.html b/layout/reftests/bidi/brackets-2c-ltr.html
new file mode 100644
index 000000000..481ee51c6
--- /dev/null
+++ b/layout/reftests/bidi/brackets-2c-ltr.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 2 with fabrikam and ARABIC exchanged:
+ smith (ARABIC fabrikam) HEBREW
+-->
+<!-- LTR -->
+<div>smith (&#x627;&#x644;&#x639;&#x631;&#x628;&#x64A; fabrikam) &#x5E2;&#x5D1;&#x5E8;&#x5D9;&#x5EA;</div>
diff --git a/layout/reftests/bidi/brackets-2c-rtl-ref.html b/layout/reftests/bidi/brackets-2c-rtl-ref.html
new file mode 100644
index 000000000..635a1bd80
--- /dev/null
+++ b/layout/reftests/bidi/brackets-2c-rtl-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; unicode-bidi: bidi-override; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 2 with fabrikam and ARABIC exchanged:
+ smith (ARABIC fabrikam) HEBREW
+-->
+<div>&#x5EA;&#x5D9;&#x5E8;&#x5D1;&#x5E2; (fabrikam &#x64A;&#x628;&#x631;&#x639;&#x644;&#x627;) smith</div>
diff --git a/layout/reftests/bidi/brackets-2c-rtl.html b/layout/reftests/bidi/brackets-2c-rtl.html
new file mode 100644
index 000000000..1fa504546
--- /dev/null
+++ b/layout/reftests/bidi/brackets-2c-rtl.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 2 with fabrikam and ARABIC exchanged:
+ smith (ARABIC fabrikam) HEBREW
+-->
+<!-- RTL -->
+<div dir=rtl>smith (&#x627;&#x644;&#x639;&#x631;&#x628;&#x64A; fabrikam) &#x5E2;&#x5D1;&#x5E8;&#x5D9;&#x5EA;</div>
diff --git a/layout/reftests/bidi/brackets-3a-ltr-ref.html b/layout/reftests/bidi/brackets-3a-ltr-ref.html
new file mode 100644
index 000000000..7ccd06f0d
--- /dev/null
+++ b/layout/reftests/bidi/brackets-3a-ltr-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; unicode-bidi: bidi-override; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 3:
+ ARABIC book(s)
+-->
+<div>&#x64A;&#x628;&#x631;&#x639;&#x644;&#x627; book(s)</div>
diff --git a/layout/reftests/bidi/brackets-3a-ltr.html b/layout/reftests/bidi/brackets-3a-ltr.html
new file mode 100644
index 000000000..624535287
--- /dev/null
+++ b/layout/reftests/bidi/brackets-3a-ltr.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 3:
+ ARABIC book(s)
+-->
+<!-- LTR -->
+<div>&#x627;&#x644;&#x639;&#x631;&#x628;&#x64A; book(s)</div>
diff --git a/layout/reftests/bidi/brackets-3a-rtl-ref.html b/layout/reftests/bidi/brackets-3a-rtl-ref.html
new file mode 100644
index 000000000..038a72c87
--- /dev/null
+++ b/layout/reftests/bidi/brackets-3a-rtl-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; unicode-bidi: bidi-override; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 3:
+ ARABIC book(s)
+-->
+<div>book(s) &#x64A;&#x628;&#x631;&#x639;&#x644;&#x627;</div>
diff --git a/layout/reftests/bidi/brackets-3a-rtl.html b/layout/reftests/bidi/brackets-3a-rtl.html
new file mode 100644
index 000000000..9fdea3fd3
--- /dev/null
+++ b/layout/reftests/bidi/brackets-3a-rtl.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 3:
+ ARABIC book(s)
+-->
+<!-- RTL -->
+<div dir=rtl>&#x627;&#x644;&#x639;&#x631;&#x628;&#x64A; book(s)</div>
diff --git a/layout/reftests/bidi/brackets-3b-ltr-ref.html b/layout/reftests/bidi/brackets-3b-ltr-ref.html
new file mode 100644
index 000000000..01f4134b7
--- /dev/null
+++ b/layout/reftests/bidi/brackets-3b-ltr-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+span { unicode-bidi: isolate; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 3, LTR and RTL exchanged:
+ arabic BOOK(S)
+-->
+<div>arabic (<span dir=rtl>&#x643;&#x64f;&#x62a;&#x64f;&#x628;</span>)<span dir=rtl>&#x643;&#x650;&#x62a;&#x64e;&#x627;&#x628;</span></div>
diff --git a/layout/reftests/bidi/brackets-3b-ltr.html b/layout/reftests/bidi/brackets-3b-ltr.html
new file mode 100644
index 000000000..004f31a57
--- /dev/null
+++ b/layout/reftests/bidi/brackets-3b-ltr.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 3, LTR and RTL exchanged:
+ arabic BOOK(S)
+-->
+<!-- LTR -->
+<div>arabic &#x643;&#x650;&#x62a;&#x64e;&#x627;&#x628;(&#x643;&#x64f;&#x62a;&#x64f;&#x628;)</div>
diff --git a/layout/reftests/bidi/brackets-3b-rtl-ref.html b/layout/reftests/bidi/brackets-3b-rtl-ref.html
new file mode 100644
index 000000000..10553a120
--- /dev/null
+++ b/layout/reftests/bidi/brackets-3b-rtl-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+span { unicode-bidi: isolate; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 3, LTR and RTL exchanged:
+ arabic BOOK(S)
+-->
+<div>(<span dir=rtl>&#x643;&#x64f;&#x62a;&#x64f;&#x628;</span>)<span dir=rtl>&#x643;&#x650;&#x62a;&#x64e;&#x627;&#x628;</span> arabic</div>
diff --git a/layout/reftests/bidi/brackets-3b-rtl.html b/layout/reftests/bidi/brackets-3b-rtl.html
new file mode 100644
index 000000000..916b8736f
--- /dev/null
+++ b/layout/reftests/bidi/brackets-3b-rtl.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<style>
+body { font: 32px monospace; }
+div { text-align: center; }
+</style>
+
+<body>
+
+<!--
+ http://unicode.org/reports/tr9/#N0, Example 3, LTR and RTL exchanged:
+ arabic BOOK(S)
+-->
+<!-- RTL -->
+<div dir=rtl>arabic &#x643;&#x650;&#x62a;&#x64e;&#x627;&#x628;(&#x643;&#x64f;&#x62a;&#x64f;&#x628;)</div>
diff --git a/layout/reftests/bidi/dirAuto/1103348-1-ref.html b/layout/reftests/bidi/dirAuto/1103348-1-ref.html
new file mode 100644
index 000000000..50fba8c41
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/1103348-1-ref.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Dynamic changes and dir=auto</title>
+ </head>
+ <body>
+ <div>Test for elements with dir="auto" whose content changes between directional and neutral</div>
+ <div dir="auto">xyz</div>
+ <div dir="auto">ابج</div>
+ <div dir="auto">456</div>
+ <div dir="auto">xyz</div>
+ <div dir="auto">ابج</div>
+ <div dir="auto">456</div>
+ <div dir="auto">xyz</div>
+ <div dir="auto">ابج</div>
+ <div dir="auto">456</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/1103348-1.html b/layout/reftests/bidi/dirAuto/1103348-1.html
new file mode 100644
index 000000000..e60202ca8
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/1103348-1.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+ <head>
+ <meta charset="utf-8">
+ <title>Dynamic changes and dir=auto</title>
+ </head>
+ <body>
+ <div>Test for elements with dir="auto" whose content changes between directional and neutral</div>
+ <div dir="auto" id="from_ltr_to_ltr">abc</div>
+ <div dir="auto" id="from_ltr_to_rtl">abc</div>
+ <div dir="auto" id="from_ltr_to_neutral">abc</div>
+ <div dir="auto" id="from_rtl_to_ltr">אבג</div>
+ <div dir="auto" id="from_rtl_to_rtl">אבג</div>
+ <div dir="auto" id="from_rtl_to_neutral">אבג</div>
+ <div dir="auto" id="from_neutral_to_ltr">123</div>
+ <div dir="auto" id="from_neutral_to_rtl">123</div>
+ <div dir="auto" id="from_neutral_to_neutral">123</div>
+ <script type="text/javascript">
+function changeContent()
+{
+ var directionalTexts = {ltr:"xyz", rtl:"ابج", neutral:"456"};
+
+ for (var dirFrom in directionalTexts) {
+ for (var dirTo in directionalTexts) {
+ var element = document.getElementById("from_" + dirFrom +
+ "_to_" + dirTo);
+ element.textContent = directionalTexts[dirTo];
+ }
+ }
+ document.documentElement.removeAttribute("class");
+}
+
+document.addEventListener("MozReftestInvalidate", changeContent, false);
+ </script>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/1169267-delete-add-1-ref.html b/layout/reftests/bidi/dirAuto/1169267-delete-add-1-ref.html
new file mode 100644
index 000000000..d6e2ab456
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/1169267-delete-add-1-ref.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test bug 1169267</title>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body>
+ <div><input type="text" dir="rtl" value="123אבג"></div>
+ <div><span dir="rtl">123אבג</span></div>
+ <div><textarea dir="rtl">123אבג</textarea></div>
+ <div><button dir="rtl">123אבג</button></div>
+ <div><bdi dir="rtl">123אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/1169267-delete-add-1a.html b/layout/reftests/bidi/dirAuto/1169267-delete-add-1a.html
new file mode 100644
index 000000000..a53257877
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/1169267-delete-add-1a.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test bug 1169267</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="appendTextFromArray(new Array('123', 'אבג'))">
+ <div><input type="text" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto"></span></div>
+ <div><textarea id="set2" dir="auto"></textarea></div>
+ <div><button id="set3" dir="auto"></button></div>
+ <div><bdi id="set4"></bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/1169267-delete-add-1b.html b/layout/reftests/bidi/dirAuto/1169267-delete-add-1b.html
new file mode 100644
index 000000000..3127c3e37
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/1169267-delete-add-1b.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test bug 1169267</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="appendDeleteAppendTextFromArray(new Array('123', 'אבג', 'אבג'))">
+ <div><input type="text" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto"></span></div>
+ <div><textarea id="set2" dir="auto"></textarea></div>
+ <div><button id="set3" dir="auto"></button></div>
+ <div><bdi id="set4"></bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/1169267-delete-add-2-ref.html b/layout/reftests/bidi/dirAuto/1169267-delete-add-2-ref.html
new file mode 100644
index 000000000..10685967f
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/1169267-delete-add-2-ref.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test bug 1169267</title>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body>
+ <div><input type="text" dir="rtl" value="456גדה"></div>
+ <div><span dir="rtl">456גדה</span></div>
+ <div><textarea dir="rtl">456גדה</textarea></div>
+ <div><button dir="rtl">456גדה</button></div>
+ <div><bdi dir="rtl">456גדה</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/1169267-delete-add-2a.html b/layout/reftests/bidi/dirAuto/1169267-delete-add-2a.html
new file mode 100644
index 000000000..4a0cd1e16
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/1169267-delete-add-2a.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test bug 1169267</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="appendTextFromArray(new Array('456', 'גדה'))">
+ <div><input type="text" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto"></span></div>
+ <div><textarea id="set2" dir="auto"></textarea></div>
+ <div><button id="set3" dir="auto"></button></div>
+ <div><bdi id="set4"></bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/1169267-delete-add-2b.html b/layout/reftests/bidi/dirAuto/1169267-delete-add-2b.html
new file mode 100644
index 000000000..bc520f83f
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/1169267-delete-add-2b.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Test bug 1169267</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="appendDeleteAppendTextFromArray(new Array('456', 'def', 'גדה'))">
+ <div><input type="text" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto"></span></div>
+ <div><textarea id="set2" dir="auto"></textarea></div>
+ <div><button id="set3" dir="auto"></button></div>
+ <div><bdi id="set4"></bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/839886-1-ref.html b/layout/reftests/bidi/dirAuto/839886-1-ref.html
new file mode 100644
index 000000000..df08a25bd
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/839886-1-ref.html
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>dir="auto" and inputs</title>
+ </head>
+ <body>
+ <p>The next three lines should be left-to-right:</p>
+ <div dir="ltr"><input value="abcdefghi"> is left-to-right.</div>
+ <div dir="ltr"><input value="ابتثجحخدذ"> is right-to-left.</div>
+ <div dir="ltr"><input value="!()*;<=>?"> is neutral.</div>
+ <p dir="rtl">The next three lines should be right-to-left:</p>
+ <div dir="rtl"><input value="abcdefghi"> שמאל-ימין.</div>
+ <div dir="rtl"><input value="ابتثجحخدذ"> ימין-שמאל.</div>
+ <div dir="rtl"><input value="!()*;<=>?"> נייטראלי.</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/839886-1.html b/layout/reftests/bidi/dirAuto/839886-1.html
new file mode 100644
index 000000000..4cddec7fe
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/839886-1.html
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>dir="auto" and inputs</title>
+ </head>
+ <body>
+ <p>The next three lines should be left-to-right:</p>
+ <div dir="auto"><input value="abcdefghi"> is left-to-right.</div>
+ <div dir="auto"><input value="ابتثجحخدذ"> is right-to-left.</div>
+ <div dir="auto"><input value="!()*;<=>?"> is neutral.</div>
+ <p dir="rtl">The next three lines should be right-to-left:</p>
+ <div dir="auto"><input value="abcdefghi"> שמאל-ימין.</div>
+ <div dir="auto"><input value="ابتثجحخدذ"> ימין-שמאל.</div>
+ <div dir="auto"><input value="!()*;<=>?"> נייטראלי.</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/859093-1-ref.html b/layout/reftests/bidi/dirAuto/859093-1-ref.html
new file mode 100644
index 000000000..f7afe90f5
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/859093-1-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html dir="rtl" lang="he">
+ <head>
+ <meta charset="utf-8" />
+ </head>
+ <body>
+ <ul>
+ <li><span lang="en">correct rendering, parentheses at the end of the line: (<span dir="rtl">משהו בעברית: Something in English</span>)</span></li>
+ </ul>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/859093-1.html b/layout/reftests/bidi/dirAuto/859093-1.html
new file mode 100644
index 000000000..b692a43f9
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/859093-1.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html dir="rtl" lang="he">
+ <head>
+ <meta charset="utf-8" />
+ </head>
+ <body>
+ <ul>
+ <li><span lang="en">correct rendering, parentheses at the end of the line: (<span dir="auto">משהו בעברית: Something in English</span>)</span></li>
+ </ul>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/889742-1-ref.html b/layout/reftests/bidi/dirAuto/889742-1-ref.html
new file mode 100644
index 000000000..4e0237ba6
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/889742-1-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Auto dir and alignment</title>
+ </head>
+ <body>
+ <h1>Auto dir and alignment</h1>
+ <p>Every line below should read "<span style="unicode-bidi: bidi-override"
+>!world םולש</span>" and should be aligned to the right</p>
+ <p dir="rtl">שלום world!</p>
+ <p dir="rtl"><b>שלום</b> world!</p>
+ <p dir="rtl">שלום world!</p>
+ <p dir="rtl"><b>שלום</b> world!</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/889742-1.html b/layout/reftests/bidi/dirAuto/889742-1.html
new file mode 100644
index 000000000..019083d28
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/889742-1.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Auto dir and alignment</title>
+ <style type="text/css">
+ p.plaintext {
+ unicode-bidi: plaintext;
+ }
+ </style>
+ </head>
+ <body>
+ <h1>Auto dir and alignment</h1>
+ <p>Every line below should read "<span style="unicode-bidi: bidi-override"
+>!world םולש</span>" and should be aligned to the right</p>
+ <p class="plaintext">שלום world!</p>
+ <p class="plaintext"><b>שלום</b> world!</p>
+ <p dir="auto">שלום world!</p>
+ <p dir="auto"><b>שלום</b> world!</p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/bdi-auto-dir-default-ref.html b/layout/reftests/bidi/dirAuto/bdi-auto-dir-default-ref.html
new file mode 100644
index 000000000..fd255638a
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/bdi-auto-dir-default-ref.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>HTML Test: BDI: paragraph-level container</title>
+ <link rel="reference" href="bdi-auto-dir-default-ref.html">
+ <link rel="author" title="Aharon Lanin" href="mailto:aharon@google.com">
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com">
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-bdi-element">
+ <meta name="assert" content="
+ 'The dir global attribute defaults to auto on this element (it never inherits from the parent
+ element like with other elements).'">
+ <style>
+ body{
+ font-size:2em;
+ }
+ .box {
+ border: medium solid gray;
+ width: 500px;
+ margin: 20px;
+ }
+ </style>
+ </head>
+ <body>
+ <!-- Key to entities used below:
+ &#x05D0; ... &#x05D5; - The first six Hebrew letters (strongly RTL).
+ &#x202D; - The LRO (left-to-right-override) formatting character.
+ &#x202C; - The PDF (pop directional formatting) formatting character; closes LRO. -->
+ <div class="box">
+ <div dir="ltr">&#x202D;[:)], [+- a &#x05D1;], [d &#x05D2; 1]...&#x202C;</div>
+ <div dir="rtl">&#x202D;...[d &#x05D2; 1] ,[+- a &#x05D1;] ,[:)]&#x202C;</div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/bdi-auto-dir-default.html b/layout/reftests/bidi/dirAuto/bdi-auto-dir-default.html
new file mode 100644
index 000000000..d4fb58420
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/bdi-auto-dir-default.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>HTML Test: BDI: paragraph-level container</title>
+ <link rel="reference" href="bdi-auto-dir-default-ref.html">
+ <link rel="author" title="Aharon Lanin" href="mailto:aharon@google.com">
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com">
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-bdi-element">
+ <meta name="assert" content="
+ 'The dir global attribute defaults to auto on this element (it never inherits from the parent
+ element like with other elements).'">
+ <style>
+ body{
+ font-size:2em;
+ }
+ .box {
+ border: medium solid gray;
+ width: 500px;
+ margin: 20px;
+ }
+ </style>
+ </head>
+ <body>
+ <!-- Key to entities used below:
+ &#x05D0; ... &#x05D5; - The first six Hebrew letters (strongly RTL).
+ &#x202D; - The LRO (left-to-right-override) formatting character.
+ &#x202C; - The PDF (pop directional formatting) formatting character; closes LRO. -->
+ <div class="box">
+ <!--
+ In each DIV below:
+ - the first BDI, having no characters with strong direction, should be LTR by default;
+ - the second BDI, having an LTR character first, should be LTR by default;
+ - the thord BDI, having an RTL character first, should be RTL by default.
+ -->
+ <div dir="ltr"><bdi>[:)]</bdi>, <bdi>[+- a &#x05D1;]</bdi>, <bdi>[1 &#x05D2; d]</bdi>...</div>
+ <div dir="rtl"><bdi>[:)]</bdi>, <bdi>[+- a &#x05D1;]</bdi>, <bdi>[1 &#x05D2; d]</bdi>...</div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dir_auto-contained-dir-L-ref.html b/layout/reftests/bidi/dirAuto/dir_auto-contained-dir-L-ref.html
new file mode 100644
index 000000000..d5935d83f
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dir_auto-contained-dir-L-ref.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>HTML Test: dir=auto, start with dir, then L</title>
+ <link rel="reference" href="dir_auto-contained-dir-L-ref.html" />
+ <link rel="author" title="Matitiahu Allouche" href="mailto:matitiahu.allouche@google.com" />
+ <link rel="author" title="Oren Roth" href="mailto:oren.roth@gmail.com" />
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com" />
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-dir-attribute" />
+ <meta name="assert" content="
+ When dir='auto', the direction is set according to the first strong character
+ of the text while ignoring contained elements with an explicit dir of their own.
+ In this test, it is the Latin letter A, thus the direction must be
+ resolved as LTR." />
+ <style>
+ input, textarea {
+ font-size:1em;
+ }
+ body {
+ font-size:2em;
+ }
+ .test, .ref {
+ border: medium solid gray;
+ width: 400px;
+ margin: 20px;
+ }
+ .comments {
+ display: none;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="instructions"><p>Test passes if the two boxes below look exactly the same.</p></div>
+ <div class="comments">
+ Key to entities used below:
+ &#x05D0; - The Hebrew letter Alef (strongly RTL).
+ &#x05D1; - The Hebrew letter Bet (strongly RTL).
+ &#x05D2; - The Hebrew letter Gimel (strongly RTL).
+ &#x05D3; - The Hebrew letter Dalet (strongly RTL).
+ &#x05D4; - The Hebrew letter He (strongly RTL).
+ &#x05D5; - The Hebrew letter Vav (strongly RTL).
+ </div>
+ <div class="test">
+ <div dir="ltr">
+ <div dir="ltr"><p dir="rtl">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="ltr"><p dir="rtl">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ </div>
+ <div class="ref">
+ <div dir="ltr">
+ <div dir="ltr"><p dir="rtl">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="ltr"><p dir="rtl">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dir_auto-contained-dir-R-ref.html b/layout/reftests/bidi/dirAuto/dir_auto-contained-dir-R-ref.html
new file mode 100644
index 000000000..5ae48d897
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dir_auto-contained-dir-R-ref.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>HTML Test: dir=auto, start with dir, then R</title>
+ <link rel="reference" href="dir_auto-contained-dir-R-ref.html" />
+ <link rel="author" title="Matitiahu Allouche" href="mailto:matitiahu.allouche@google.com" />
+ <link rel="author" title="Oren Roth" href="mailto:oren.roth@gmail.com" />
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com" />
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-dir-attribute" />
+ <meta name="assert" content="
+ When dir='auto', the direction is set according to the first strong character
+ of the text while ignoring contained elements with an explicit dir of their own.
+ In this test, it is the Hebrew letter Alef, thus the direction must be
+ resolved as RTL." />
+ <style>
+ input, textarea {
+ font-size:1em;
+ }
+ body {
+ font-size:2em;
+ }
+ .test, .ref {
+ border: medium solid gray;
+ width: 400px;
+ margin: 20px;
+ }
+ .comments {
+ display: none;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="instructions"><p>Test passes if the two boxes below look exactly the same.</p></div>
+ <div class="comments">
+ Key to entities used below:
+ &#x05D0; - The Hebrew letter Alef (strongly RTL).
+ &#x05D1; - The Hebrew letter Bet (strongly RTL).
+ &#x05D2; - The Hebrew letter Gimel (strongly RTL).
+ </div>
+ <div class="test">
+ <div dir="ltr">
+ <div dir="rtl"><p dir="ltr">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="rtl"><p dir="ltr">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ </div>
+ <div class="ref">
+ <div dir="ltr">
+ <div dir="rtl"><p dir="ltr">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="rtl"><p dir="ltr">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dir_auto-set-contained-dir-L.html b/layout/reftests/bidi/dirAuto/dir_auto-set-contained-dir-L.html
new file mode 100644
index 000000000..41bf37180
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dir_auto-set-contained-dir-L.html
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>HTML Test: dir=auto, start with dir, then L</title>
+ <link rel="reference" href="dir_auto-contained-dir-L-ref.html" />
+ <link rel="author" title="Matitiahu Allouche" href="mailto:matitiahu.allouche@google.com" />
+ <link rel="author" title="Oren Roth" href="mailto:oren.roth@gmail.com" />
+ <link rel="author" title="Simon Montagu" href="mailto:smontagu@smontagu.org" />
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com" />
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-dir-attribute" />
+ <meta name="assert" content="
+ When dir='auto', the direction is set according to the first strong character
+ of the text while ignoring contained elements with an explicit dir of their own.
+ In this test, it is the Latin letter A, thus the direction must be
+ resolved as LTR.
+ This is a variation of the original dir_auto-contained-dir-L.html in which
+ the explicit dir is set by script after loading the page" />
+ <style>
+ input, textarea {
+ font-size:1em;
+ }
+ body {
+ font-size:2em;
+ }
+ .test, .ref {
+ border: medium solid gray;
+ width: 400px;
+ margin: 20px;
+ }
+ .comments {
+ display: none;
+ }
+ </style>
+ <script type="text/javascript">
+function setDirs(value)
+{
+ var p1 = document.getElementById("p1");
+ p1.dir = value;
+
+ var p1 = document.getElementById("p2");
+ p2.dir = value;
+}
+ </script>
+ </head>
+ <body onload="setDirs('rtl')">
+ <div class="instructions"><p>Test passes if the two boxes below look exactly the same.</p></div>
+ <div class="comments">
+ Key to entities used below:
+ &#x05D0; - The Hebrew letter Alef (strongly RTL).
+ &#x05D1; - The Hebrew letter Bet (strongly RTL).
+ &#x05D2; - The Hebrew letter Gimel (strongly RTL).
+ &#x05D3; - The Hebrew letter Dalet (strongly RTL).
+ &#x05D4; - The Hebrew letter He (strongly RTL).
+ &#x05D5; - The Hebrew letter Vav (strongly RTL).
+ </div>
+ <div class="test">
+ <div dir="ltr">
+ <div dir="auto"><p id="p1">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="auto"><p id="p2">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ </div>
+ <div class="ref">
+ <div dir="ltr">
+ <div dir="ltr"><p dir="rtl">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="ltr"><p dir="rtl">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dir_auto-set-contained-dir-R.html b/layout/reftests/bidi/dirAuto/dir_auto-set-contained-dir-R.html
new file mode 100644
index 000000000..0c74b3f3b
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dir_auto-set-contained-dir-R.html
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>HTML Test: dir=auto, start with dir, then R</title>
+ <link rel="reference" href="dir_auto-contained-dir-R-ref.html" />
+ <link rel="author" title="Matitiahu Allouche" href="mailto:matitiahu.allouche@google.com" />
+ <link rel="author" title="Oren Roth" href="mailto:oren.roth@gmail.com" />
+ <link rel="author" title="Simon Montagu" href="mailto:smontagu@smontagu.org" />
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com" />
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-dir-attribute" />
+ <meta name="assert" content="
+ When dir='auto', the direction is set according to the first strong character
+ of the text while ignoring contained elements with an explicit dir of their own.
+ In this test, it is the Hebrew letter Alef, thus the direction must be
+ resolved as RTL.
+ This is a variation of the original dir_auto-contained-dir-R.html in which
+ the explicit dir is set by script after loading the page" />
+ <style>
+ input, textarea {
+ font-size:1em;
+ }
+ body {
+ font-size:2em;
+ }
+ .test, .ref {
+ border: medium solid gray;
+ width: 400px;
+ margin: 20px;
+ }
+ .comments {
+ display: none;
+ }
+ </style>
+ <script type="text/javascript">
+function setDirs(value)
+{
+ var p1 = document.getElementById("p1");
+ p1.dir = value;
+
+ var p1 = document.getElementById("p2");
+ p2.dir = value;
+}
+ </script>
+ </head>
+ <body onload="setDirs('ltr')">
+ <div class="instructions"><p>Test passes if the two boxes below look exactly the same.</p></div>
+ <div class="comments">
+ Key to entities used below:
+ &#x05D0; - The Hebrew letter Alef (strongly RTL).
+ &#x05D1; - The Hebrew letter Bet (strongly RTL).
+ &#x05D2; - The Hebrew letter Gimel (strongly RTL).
+ </div>
+ <div class="test">
+ <div dir="ltr">
+ <div dir="auto"><p id="p1">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="auto"><p id="p2">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ </div>
+ <div class="ref">
+ <div dir="ltr">
+ <div dir="rtl"><p dir="ltr">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="rtl"><p dir="ltr">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dir_auto-set-contained-invalid-dir-L.html b/layout/reftests/bidi/dirAuto/dir_auto-set-contained-invalid-dir-L.html
new file mode 100644
index 000000000..10a75a4ce
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dir_auto-set-contained-invalid-dir-L.html
@@ -0,0 +1,75 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>HTML Test: dir=auto, start with dir, then L</title>
+ <link rel="reference" href="dir_auto-contained-dir-L-ref.html" />
+ <link rel="author" title="Matitiahu Allouche" href="mailto:matitiahu.allouche@google.com" />
+ <link rel="author" title="Oren Roth" href="mailto:oren.roth@gmail.com" />
+ <link rel="author" title="Simon Montagu" href="mailto:smontagu@smontagu.org" />
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com" />
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-dir-attribute" />
+ <meta name="assert" content="
+ When dir='auto', the direction is set according to the first strong character
+ of the text while ignoring contained elements with an explicit dir of their own.
+ In this test, it is the Latin letter A, thus the direction must be
+ resolved as LTR.
+ This is a variation of the original dir_auto-contained-dir-L.html in which
+ an element with an invalid dir attribute has the dir attribute set by
+ script after loading the page" />
+ <style>
+ input, textarea {
+ font-size:1em;
+ }
+ body {
+ font-size:2em;
+ }
+ .test, .ref {
+ border: medium solid gray;
+ width: 400px;
+ margin: 20px;
+ }
+ .comments {
+ display: none;
+ }
+ </style>
+ <script type="text/javascript">
+function setDirs(value)
+{
+ var p1 = document.getElementById("p1");
+ p1.dir = value;
+
+ var p1 = document.getElementById("p2");
+ p2.dir = value;
+}
+ </script>
+ </head>
+ <body onload="setDirs('rtl')">
+ <div class="instructions"><p>Test passes if the two boxes below look exactly the same.</p></div>
+ <div class="comments">
+ Key to entities used below:
+ &#x05D0; - The Hebrew letter Alef (strongly RTL).
+ &#x05D1; - The Hebrew letter Bet (strongly RTL).
+ &#x05D2; - The Hebrew letter Gimel (strongly RTL).
+ &#x05D3; - The Hebrew letter Dalet (strongly RTL).
+ &#x05D4; - The Hebrew letter He (strongly RTL).
+ &#x05D5; - The Hebrew letter Vav (strongly RTL).
+ </div>
+ <div class="test">
+ <div dir="ltr">
+ <div dir="auto"><p id="p1" dir="foopy">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="auto"><p id="p2" dir="foopy">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ </div>
+ <div class="ref">
+ <div dir="ltr">
+ <div dir="ltr"><p dir="rtl">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="ltr"><p dir="rtl">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dir_auto-set-contained-invalid-dir-R.html b/layout/reftests/bidi/dirAuto/dir_auto-set-contained-invalid-dir-R.html
new file mode 100644
index 000000000..0ff92cb55
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dir_auto-set-contained-invalid-dir-R.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>HTML Test: dir=auto, start with dir, then R</title>
+ <link rel="reference" href="dir_auto-contained-dir-R-ref.html" />
+ <link rel="author" title="Matitiahu Allouche" href="mailto:matitiahu.allouche@google.com" />
+ <link rel="author" title="Oren Roth" href="mailto:oren.roth@gmail.com" />
+ <link rel="author" title="Simon Montagu" href="mailto:smontagu@smontagu.org" />
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com" />
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-dir-attribute" />
+ <meta name="assert" content="
+ When dir='auto', the direction is set according to the first strong character
+ of the text while ignoring contained elements with an explicit dir of their own.
+ In this test, it is the Hebrew letter Alef, thus the direction must be
+ resolved as RTL.
+ This is a variation of the original dir_auto-contained-dir-R.html in which
+ an element with an invalid dir attribute has the dir attribute set by
+ script after loading the page" />
+ <style>
+ input, textarea {
+ font-size:1em;
+ }
+ body {
+ font-size:2em;
+ }
+ .test, .ref {
+ border: medium solid gray;
+ width: 400px;
+ margin: 20px;
+ }
+ .comments {
+ display: none;
+ }
+ </style>
+ <script type="text/javascript">
+function setDirs(value)
+{
+ var p1 = document.getElementById("p1");
+ p1.dir = value;
+
+ var p1 = document.getElementById("p2");
+ p2.dir = value;
+}
+ </script>
+ </head>
+ <body onload="setDirs('ltr')">
+ <div class="instructions"><p>Test passes if the two boxes below look exactly the same.</p></div>
+ <div class="comments">
+ Key to entities used below:
+ &#x05D0; - The Hebrew letter Alef (strongly RTL).
+ &#x05D1; - The Hebrew letter Bet (strongly RTL).
+ &#x05D2; - The Hebrew letter Gimel (strongly RTL).
+ </div>
+ <div class="test">
+ <div dir="ltr">
+ <div dir="auto"><p id="p1" dir="foopy">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="auto"><p id="p2" dir="foopy">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ </div>
+ <div class="ref">
+ <div dir="ltr">
+ <div dir="rtl"><p dir="ltr">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="rtl"><p dir="ltr">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-L-ref.html b/layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-L-ref.html
new file mode 100644
index 000000000..a78643049
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-L-ref.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>HTML Test: dir=auto, start with dir, then R</title>
+ <link rel="reference" href="dir_auto-contained-dir-R-ref.html" />
+ <link rel="author" title="Matitiahu Allouche" href="mailto:matitiahu.allouche@google.com" />
+ <link rel="author" title="Oren Roth" href="mailto:oren.roth@gmail.com" />
+ <link rel="author" title="Simon Montagu" href="mailto:smontagu@smontagu.org" />
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com" />
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-dir-attribute" />
+ <meta name="assert" content="
+ When dir='auto', the direction is set according to the first strong character
+ of the text while ignoring contained elements with an explicit dir of their own.
+ In this test, it is the Latin letter D, thus the direction must be
+ resolved as LTR.
+ This is a variation of the original dir_auto-contained-dir-R.html in which
+ the explicit dir is unset by script after loading the page" />
+ <style>
+ input, textarea {
+ font-size:1em;
+ }
+ body {
+ font-size:2em;
+ }
+ .test, .ref {
+ border: medium solid gray;
+ width: 400px;
+ margin: 20px;
+ }
+ .comments {
+ display: none;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="instructions"><p>Test passes if the two boxes below look exactly the same.</p></div>
+ <div class="comments">
+ Key to entities used below:
+ &#x05D0; - The Hebrew letter Alef (strongly RTL).
+ &#x05D1; - The Hebrew letter Bet (strongly RTL).
+ &#x05D2; - The Hebrew letter Gimel (strongly RTL).
+ </div>
+ <div class="test">
+ <div dir="ltr">
+ <div dir="ltr"><p id="p1" dir="ltr">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="ltr"><p id="p2" dir="ltr">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ </div>
+ <div class="ref">
+ <div dir="ltr">
+ <div dir="ltr"><p dir="ltr">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="ltr"><p dir="ltr">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-L.html b/layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-L.html
new file mode 100644
index 000000000..c2cbdc241
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-L.html
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>HTML Test: dir=auto, start with dir, then R</title>
+ <link rel="reference" href="dir_auto-contained-dir-R-ref.html" />
+ <link rel="author" title="Matitiahu Allouche" href="mailto:matitiahu.allouche@google.com" />
+ <link rel="author" title="Oren Roth" href="mailto:oren.roth@gmail.com" />
+ <link rel="author" title="Simon Montagu" href="mailto:smontagu@smontagu.org" />
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com" />
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-dir-attribute" />
+ <meta name="assert" content="
+ When dir='auto', the direction is set according to the first strong character
+ of the text while ignoring contained elements with an explicit dir of their own.
+ In this test, it is the Latin letter D, thus the direction must be
+ resolved as LTR.
+ This is a variation of the original dir_auto-contained-dir-R.html in which
+ the explicit dir is unset by script after loading the page" />
+ <style>
+ input, textarea {
+ font-size:1em;
+ }
+ body {
+ font-size:2em;
+ }
+ .test, .ref {
+ border: medium solid gray;
+ width: 400px;
+ margin: 20px;
+ }
+ .comments {
+ display: none;
+ }
+ </style>
+ <script type="text/javascript">
+function setDirs(value)
+{
+ var p1 = document.getElementById("p1");
+ p1.dir = value;
+
+ var p1 = document.getElementById("p2");
+ p2.dir = value;
+}
+ </script>
+ </head>
+ <body onload="setDirs('')">
+ <div class="instructions"><p>Test passes if the two boxes below look exactly the same.</p></div>
+ <div class="comments">
+ Key to entities used below:
+ &#x05D0; - The Hebrew letter Alef (strongly RTL).
+ &#x05D1; - The Hebrew letter Bet (strongly RTL).
+ &#x05D2; - The Hebrew letter Gimel (strongly RTL).
+ </div>
+ <div class="test">
+ <div dir="ltr">
+ <div dir="auto"><p id="p1" dir="ltr">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="auto"><p id="p2" dir="ltr">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ </div>
+ <div class="ref">
+ <div dir="ltr">
+ <div dir="ltr"><p dir="ltr">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="ltr"><p dir="ltr">DEF</p>&#x05D0;&#x05D1;&#x05D2;ABC.</div>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-R-ref.html b/layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-R-ref.html
new file mode 100644
index 000000000..f38365221
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-R-ref.html
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>HTML Test: dir=auto, start with dir, then L</title>
+ <link rel="reference" href="dir_auto-contained-dir-L-ref.html" />
+ <link rel="author" title="Matitiahu Allouche" href="mailto:matitiahu.allouche@google.com" />
+ <link rel="author" title="Oren Roth" href="mailto:oren.roth@gmail.com" />
+ <link rel="author" title="Simon Montagu" href="mailto:smontagu@smontagu.org" />
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com" />
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-dir-attribute" />
+ <meta name="assert" content="
+ When dir='auto', the direction is set according to the first strong character
+ of the text while ignoring contained elements with an explicit dir of their own.
+ In this test, it is the Hebrew letter Dalet, thus the direction must be
+ resolved as RTL.
+ This is a variation of the original dir_auto-contained-dir-L.html in which
+ the explicit dir is unset by script after loading the page" />
+ <style>
+ input, textarea {
+ font-size:1em;
+ }
+ body {
+ font-size:2em;
+ }
+ .test, .ref {
+ border: medium solid gray;
+ width: 400px;
+ margin: 20px;
+ }
+ .comments {
+ display: none;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="instructions"><p>Test passes if the two boxes below look exactly the same.</p></div>
+ <div class="comments">
+ Key to entities used below:
+ &#x05D0; - The Hebrew letter Alef (strongly RTL).
+ &#x05D1; - The Hebrew letter Bet (strongly RTL).
+ &#x05D2; - The Hebrew letter Gimel (strongly RTL).
+ &#x05D3; - The Hebrew letter Dalet (strongly RTL).
+ &#x05D4; - The Hebrew letter He (strongly RTL).
+ &#x05D5; - The Hebrew letter Vav (strongly RTL).
+ </div>
+ <div class="test">
+ <div dir="ltr">
+ <div dir="rtl"><p id="p1" dir="rtl">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="rtl"><p id="p2" dir="rtl">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ </div>
+ <div class="ref">
+ <div dir="ltr">
+ <div dir="rtl"><p dir="rtl">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="rtl"><p dir="rtl">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-R.html b/layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-R.html
new file mode 100644
index 000000000..a63f718ce
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-R.html
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>HTML Test: dir=auto, start with dir, then L</title>
+ <link rel="reference" href="dir_auto-contained-dir-L-ref.html" />
+ <link rel="author" title="Matitiahu Allouche" href="mailto:matitiahu.allouche@google.com" />
+ <link rel="author" title="Oren Roth" href="mailto:oren.roth@gmail.com" />
+ <link rel="author" title="Simon Montagu" href="mailto:smontagu@smontagu.org" />
+ <link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com" />
+ <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-dir-attribute" />
+ <meta name="assert" content="
+ When dir='auto', the direction is set according to the first strong character
+ of the text while ignoring contained elements with an explicit dir of their own.
+ In this test, it is the Hebrew letter Dalet, thus the direction must be
+ resolved as RTL.
+ This is a variation of the original dir_auto-contained-dir-L.html in which
+ the explicit dir is unset by script after loading the page" />
+ <style>
+ input, textarea {
+ font-size:1em;
+ }
+ body {
+ font-size:2em;
+ }
+ .test, .ref {
+ border: medium solid gray;
+ width: 400px;
+ margin: 20px;
+ }
+ .comments {
+ display: none;
+ }
+ </style>
+ <script type="text/javascript">
+function setDirs(value)
+{
+ var p1 = document.getElementById("p1");
+ p1.dir = value;
+
+ var p1 = document.getElementById("p2");
+ p2.dir = value;
+}
+ </script>
+ </head>
+ <body onload="setDirs('')">
+ <div class="instructions"><p>Test passes if the two boxes below look exactly the same.</p></div>
+ <div class="comments">
+ Key to entities used below:
+ &#x05D0; - The Hebrew letter Alef (strongly RTL).
+ &#x05D1; - The Hebrew letter Bet (strongly RTL).
+ &#x05D2; - The Hebrew letter Gimel (strongly RTL).
+ &#x05D3; - The Hebrew letter Dalet (strongly RTL).
+ &#x05D4; - The Hebrew letter He (strongly RTL).
+ &#x05D5; - The Hebrew letter Vav (strongly RTL).
+ </div>
+ <div class="test">
+ <div dir="ltr">
+ <div dir="auto"><p id="p1" dir="rtl">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="auto"><p id="p2" dir="rtl">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ </div>
+ <div class="ref">
+ <div dir="ltr">
+ <div dir="rtl"><p dir="rtl">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ <div dir="rtl">
+ <div dir="rtl"><p dir="rtl">&#x05D3;&#x05D4;&#x05D5;</p>ABC&#x05D0;&#x05D1;&#x05D2;.</div>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR1.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR1.html
new file mode 100644
index 000000000..223aa56e6
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllTextValuesTo('ABC אבג')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">אבג ABC</span></div>
+ <div><textarea id="set2" dir="auto">אבג ABC</textarea></div>
+ <div><button id="set3" dir="auto">אבג ABC</button></div>
+ <div><bdi id="set4">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR10.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR10.html
new file mode 100644
index 000000000..bd3dad92a
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR10.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllTextDefaultValuesTo('ABC אבג')">
+ <div><input type="text" value="..." id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">...</span></div>
+ <div><textarea id="set2" dir="auto">...</textarea></div>
+ <div><button id="set3" dir="auto">...</button></div>
+ <div><bdi id="set4">...</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR2.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR2.html
new file mode 100644
index 000000000..f9af6b961
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllTextValuesTo('ABC אבג')">
+ <div><input type="text" value="..." id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">...</span></div>
+ <div><textarea id="set2" dir="auto">...</textarea></div>
+ <div><button id="set3" dir="auto">...</button></div>
+ <div><bdi id="set4">...</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR3.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR3.html
new file mode 100644
index 000000000..2d07131d5
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR3.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="appendTextFromArray(new Array('ABC', ' ', 'אבג'))">
+ <div><input type="text" value="&#x00ad;" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">&#x00ad;</span></div>
+ <div><textarea id="set2" dir="auto">&#x00ad;</textarea></div>
+ <div><button id="set3" dir="auto">&#x00ad;</button></div>
+ <div><bdi id="set4">&#x00ad;</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR4.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR4.html
new file mode 100644
index 000000000..38801d2a4
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR4.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="prependTextFromArray(new Array('אבג', ' ', 'ABC'))">
+ <div><input type="text" value="&#x00ad;" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">&#x00ad;</span></div>
+ <div><textarea id="set2" dir="auto">&#x00ad;</textarea></div>
+ <div><button id="set3" dir="auto">&#x00ad;</button></div>
+ <div><bdi id="set4">&#x00ad;</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR5.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR5.html
new file mode 100644
index 000000000..7cd5db77c
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR5.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="appendSpansFromArray(new Array('ABC', ' ', 'אבג'))">
+ <div><input type="text" value="&#x00ad;" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">&#x00ad;</span></div>
+ <div><textarea id="set2" dir="auto">&#x00ad;</textarea></div>
+ <div><button id="set3" dir="auto">&#x00ad;</button></div>
+ <div><bdi id="set4">&#x00ad;</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR6.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR6.html
new file mode 100644
index 000000000..b66f5e306
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR6.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="prependSpansFromArray(new Array('אבג', ' ', 'ABC'))">
+ <div><input type="text" value="&#x00ad;" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">&#x00ad;</span></div>
+ <div><textarea id="set2" dir="auto">&#x00ad;</textarea></div>
+ <div><button id="set3" dir="auto">&#x00ad;</button></div>
+ <div><bdi id="set4">&#x00ad;</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR7.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR7.html
new file mode 100644
index 000000000..461118996
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR7.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllTextChildrenTo('ABC אבג')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">אבג ABC</span></div>
+ <div><textarea id="set2" dir="auto">אבג ABC</textarea></div>
+ <div><button id="set3" dir="auto">אבג ABC</button></div>
+ <div><bdi id="set4">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR8.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR8.html
new file mode 100644
index 000000000..2fb2148f9
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR8.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllTextChildrenTo('ABC אבג')">
+ <div><input type="text" value="..." id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">...</span></div>
+ <div><textarea id="set2" dir="auto">...</textarea></div>
+ <div><button id="set3" dir="auto">...</button></div>
+ <div><bdi id="set4">...</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR9.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR9.html
new file mode 100644
index 000000000..087d5104f
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-LTR9.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllTextDefaultValuesTo('ABC אבג')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">אבג ABC</span></div>
+ <div><textarea id="set2" dir="auto">אבג ABC</textarea></div>
+ <div><button id="set3" dir="auto">אבג ABC</button></div>
+ <div><bdi id="set4">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL1.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL1.html
new file mode 100644
index 000000000..361fcd1e7
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllTextValuesTo('אבג ABC')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">ABC אבג</span></div>
+ <div><textarea id="set2" dir="auto">ABC אבג</textarea></div>
+ <div><button id="set3" dir="auto">ABC אבג</button></div>
+ <div><bdi id="set4">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL10.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL10.html
new file mode 100644
index 000000000..01e6f6bcb
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL10.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllTextDefaultValuesTo('אבג ABC')">
+ <div><input type="text" value="..." id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">...</span></div>
+ <div><textarea id="set2" dir="auto">...</textarea></div>
+ <div><button id="set3" dir="auto">...</button></div>
+ <div><bdi id="set4">...</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL2.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL2.html
new file mode 100644
index 000000000..f243dec4f
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllTextValuesTo('אבג ABC')">
+ <div><input type="text" value="..." id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">...</span></div>
+ <div><textarea id="set2" dir="auto">...</textarea></div>
+ <div><button id="set3" dir="auto">...</button></div>
+ <div><bdi id="set4">...</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL3.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL3.html
new file mode 100644
index 000000000..0aaedfe4a
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL3.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="appendTextFromArray(new Array('אבג', ' ', 'ABC'))">
+ <div><input type="text" value="&#x00ad;" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">&#x00ad;</span></div>
+ <div><textarea id="set2" dir="auto">&#x00ad;</textarea></div>
+ <div><button id="set3" dir="auto">&#x00ad;</button></div>
+ <div><bdi id="set4">&#x00ad;</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL4.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL4.html
new file mode 100644
index 000000000..60df2980c
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL4.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="prependTextFromArray(new Array('ABC', ' ', 'אבג'))">
+ <div><input type="text" value="&#x00ad;" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">&#x00ad;</span></div>
+ <div><textarea id="set2" dir="auto">&#x00ad;</textarea></div>
+ <div><button id="set3" dir="auto">&#x00ad;</button></div>
+ <div><bdi id="set4">&#x00ad;</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL5.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL5.html
new file mode 100644
index 000000000..36d2940e5
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL5.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="appendSpansFromArray(new Array('אבג', ' ', 'ABC'))">
+ <div><input type="text" value="&#x00ad;" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">&#x00ad;</span></div>
+ <div><textarea id="set2" dir="auto">&#x00ad;</textarea></div>
+ <div><button id="set3" dir="auto">&#x00ad;</button></div>
+ <div><bdi id="set4">&#x00ad;</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL6.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL6.html
new file mode 100644
index 000000000..440945bb5
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL6.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="prependSpansFromArray(new Array('ABC', ' ', 'אבג'))">
+ <div><input type="text" value="&#x00ad;" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">&#x00ad;</span></div>
+ <div><textarea id="set2" dir="auto">&#x00ad;</textarea></div>
+ <div><button id="set3" dir="auto">&#x00ad;</button></div>
+ <div><bdi id="set4">&#x00ad;</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL7.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL7.html
new file mode 100644
index 000000000..032c2f4eb
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL7.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllTextChildrenTo('אבג ABC')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">ABC אבג</span></div>
+ <div><textarea id="set2" dir="auto">ABC אבג</textarea></div>
+ <div><button id="set3" dir="auto">ABC אבג</button></div>
+ <div><bdi id="set4">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL8.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL8.html
new file mode 100644
index 000000000..9c1da6b0f
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL8.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllTextChildrenTo('אבג ABC')">
+ <div><input type="text" value="..." id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">...</span></div>
+ <div><textarea id="set2" dir="auto">...</textarea></div>
+ <div><button id="set3" dir="auto">...</button></div>
+ <div><bdi id="set4">...</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL9.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL9.html
new file mode 100644
index 000000000..b7c4c3653
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-ChangeText-RTL9.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllTextDefaultValuesTo('אבג ABC')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">ABC אבג</span></div>
+ <div><textarea id="set2" dir="auto">ABC אבג</textarea></div>
+ <div><button id="set3" dir="auto">ABC אבג</button></div>
+ <div><bdi id="set4">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-LTR1.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-LTR1.html
new file mode 100644
index 000000000..4ba7a037f
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-LTR1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="removeElements()">
+ <div><input type="text" value="ABC אבג" dir="auto"></div>
+ <div><span dir="auto"><span id="set0">DEF </span>ABC אבג</span></div>
+ <div><textarea dir="auto">ABC אבג</textarea></div>
+ <div><button dir="auto"><span id="set1">DEF </span>ABC אבג</button></div>
+ <div><bdi><span id="set2">DEF </span>ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-LTR2.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-LTR2.html
new file mode 100644
index 000000000..4bea44d83
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-LTR2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="removeElements()">
+ <div><input type="text" value="ABC אבג" dir="auto"></div>
+ <div><span dir="auto"><span id="set0">גדה </span>ABC אבג</span></div>
+ <div><textarea dir="auto">ABC אבג</textarea></div>
+ <div><button dir="auto"><span id="set1">גדה </span>ABC אבג</button></div>
+ <div><bdi><span id="set2">גדה </span>ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-LTR3.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-LTR3.html
new file mode 100644
index 000000000..2c1682953
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-LTR3.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="removeElements()">
+ <div><input type="text" value="ABC אבג" dir="auto"></div>
+ <div><span dir="auto"><span id="set0">... </span>ABC אבג</span></div>
+ <div><textarea dir="auto">ABC אבג</textarea></div>
+ <div><button dir="auto"><span id="set1">... </span>ABC אבג</button></div>
+ <div><bdi><span id="set2">... </span>ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-RTL1.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-RTL1.html
new file mode 100644
index 000000000..ab08388b8
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-RTL1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="removeElements()">
+ <div><input type="text" value="אבג ABC" dir="auto"></div>
+ <div><span dir="auto"><span id="set0">DEF </span>אבג ABC</span></div>
+ <div><textarea dir="auto">אבג ABC</textarea></div>
+ <div><button dir="auto"><span id="set1">DEF </span>אבג ABC</button></div>
+ <div><bdi><span id="set2">DEF </span>אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-RTL2.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-RTL2.html
new file mode 100644
index 000000000..477e155a0
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-RTL2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="removeElements()">
+ <div><input type="text" value="אבג ABC" dir="auto"></div>
+ <div><span dir="auto"><span id="set0">גדה </span>אבג ABC</span></div>
+ <div><textarea dir="auto">אבג ABC</textarea></div>
+ <div><button dir="auto"><span id="set1">גדה </span>אבג ABC</button></div>
+ <div><bdi><span id="set2">גדה </span>אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-RTL3.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-RTL3.html
new file mode 100644
index 000000000..cf4069567
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-DeleteText-RTL3.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="removeElements()">
+ <div><input type="text" value="אבג ABC" dir="auto"></div>
+ <div><span dir="auto"><span id="set0">... </span>אבג ABC</span></div>
+ <div><textarea dir="auto">אבג ABC</textarea></div>
+ <div><button dir="auto"><span id="set1">... </span>אבג ABC</button></div>
+ <div><bdi><span id="set2">... </span>אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-addLTR-Auto.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-addLTR-Auto.html
new file mode 100644
index 000000000..16dc62b5b
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-addLTR-Auto.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="addLTRAutoElements()">
+ <div id="container"></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-addRTL-Auto.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-addRTL-Auto.html
new file mode 100644
index 000000000..52c0949c9
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-addRTL-Auto.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="addRTLAutoElements()">
+ <div id="container"></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-refLTR-LTR.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-refLTR-LTR.html
new file mode 100644
index 000000000..62a74bf33
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-refLTR-LTR.html
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body>
+ <div><input type="text" value="ABC אבג" dir="ltr"></div>
+ <div><span dir="ltr">ABC אבג</span></div>
+ <div><textarea dir="ltr">ABC אבג</textarea></div>
+ <div><button dir="ltr">ABC אבג</button></div>
+ <div><span dir="ltr">ABC אבג</span></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-refLTR-RTL.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-refLTR-RTL.html
new file mode 100644
index 000000000..60619730a
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-refLTR-RTL.html
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body>
+ <div><input type="text" value="ABC אבג" dir="rtl"></div>
+ <div><span dir="rtl">ABC אבג</span></div>
+ <div><textarea dir="rtl">ABC אבג</textarea></div>
+ <div><button dir="rtl">ABC אבג</button></div>
+ <div><span dir="rtl">ABC אבג</span></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-refRTL-LTR.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-refRTL-LTR.html
new file mode 100644
index 000000000..4ea471a8d
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-refRTL-LTR.html
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body>
+ <div><input type="text" value="אבג ABC" dir="ltr"></div>
+ <div><span dir="ltr">אבג ABC</span></div>
+ <div><textarea dir="ltr">אבג ABC</textarea></div>
+ <div><button dir="ltr">אבג ABC</button></div>
+ <div><span dir="ltr">אבג ABC</span></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-refRTL-NoDir.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-refRTL-NoDir.html
new file mode 100644
index 000000000..b2f56c1ac
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-refRTL-NoDir.html
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body>
+ <div><input type="text" value="אבג ABC" dir="ltr"></div>
+ <div><span dir="ltr">אבג ABC</span></div>
+ <div><textarea dir="ltr">אבג ABC</textarea></div>
+ <div><button dir="ltr">אבג ABC</button></div>
+ <!-- the last line is span dir="rtl" because it's the reference
+ for a bdi that begins with rtl characters, so with an empty or
+ invalid value for the dir attribute it will be resolved as rtl -->
+ <div><span dir="rtl">אבג ABC</span></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-refRTL-RTL.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-refRTL-RTL.html
new file mode 100644
index 000000000..71c42ea3e
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-refRTL-RTL.html
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body>
+ <div><input type="text" value="אבג ABC" dir="rtl"></div>
+ <div><span dir="rtl">אבג ABC</span></div>
+ <div><textarea dir="rtl">אבג ABC</textarea></div>
+ <div><button dir="rtl">אבג ABC</button></div>
+ <div><span dir="rtl">אבג ABC</span></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto1.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto1.html
new file mode 100644
index 000000000..2c1c525f9
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('auto')">
+ <div><input type="text" value="ABC אבג" id="set0"></div>
+ <div><span id="set1">ABC אבג</span></div>
+ <div><textarea id="set2">ABC אבג</textarea></div>
+ <div><button id="set3">ABC אבג</button></div>
+ <div><bdi id="set4">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto2.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto2.html
new file mode 100644
index 000000000..f0400e0d0
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('auto')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="rtl"></div>
+ <div><span id="set1" dir="rtl">ABC אבג</span></div>
+ <div><textarea id="set2" dir="rtl">ABC אבג</textarea></div>
+ <div><button id="set3" dir="rtl">ABC אבג</button></div>
+ <div><bdi id="set4" dir="rtl">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto3.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto3.html
new file mode 100644
index 000000000..2cbf52716
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto3.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('auto')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">ABC אבג</span></div>
+ <div><textarea id="set2" dir="foopy">ABC אבג</textarea></div>
+ <div><button id="set3" dir="foopy">ABC אבג</button></div>
+ <div><bdi id="set4" dir="foopy">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto4.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto4.html
new file mode 100644
index 000000000..5bcec0648
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto4.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('auto')">
+ <div><input type="text" value="ABC אבג" id="set0"></div>
+ <div><span id="set1">ABC אבג</span></div>
+ <div><textarea id="set2">ABC אבג</textarea></div>
+ <div><button id="set3">ABC אבג</button></div>
+ <div><bdi id="set4">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto5.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto5.html
new file mode 100644
index 000000000..a0423c246
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto5.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('auto')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="rtl"></div>
+ <div><span id="set1" dir="rtl">ABC אבג</span></div>
+ <div><textarea id="set2" dir="rtl">ABC אבג</textarea></div>
+ <div><button id="set3" dir="rtl">ABC אבג</button></div>
+ <div><bdi id="set4" dir="rtl">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto6.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto6.html
new file mode 100644
index 000000000..2574c867f
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-Auto6.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('auto')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">ABC אבג</span></div>
+ <div><textarea id="set2" dir="foopy">ABC אבג</textarea></div>
+ <div><button id="set3" dir="foopy">ABC אבג</button></div>
+ <div><bdi id="set4" dir="foopy">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir1.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir1.html
new file mode 100644
index 000000000..1913335b8
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('foopy')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="rtl"></div>
+ <div><span id="set1" dir="rtl">ABC אבג</span></div>
+ <div><textarea id="set2" dir="rtl">ABC אבג</textarea></div>
+ <div><button id="set3" dir="rtl">ABC אבג</button></div>
+ <div><bdi id="set4" dir="rtl">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir2.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir2.html
new file mode 100644
index 000000000..596f1143a
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('foopy')">
+ <div><input type="text" value="ABC אבג" id="set0"></div>
+ <div><span id="set1">ABC אבג</span></div>
+ <div><textarea id="set2">ABC אבג</textarea></div>
+ <div><button id="set3">ABC אבג</button></div>
+ <div><bdi id="set4">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir3.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir3.html
new file mode 100644
index 000000000..f22dd147d
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir3.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('foopy')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">ABC אבג</span></div>
+ <div><textarea id="set2" dir="auto">ABC אבג</textarea></div>
+ <div><button id="set3" dir="auto">ABC אבג</button></div>
+ <div><bdi id="set4" dir="auto">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir4.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir4.html
new file mode 100644
index 000000000..f876484e4
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir4.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="foopy"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('foopy')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">ABC אבג</span></div>
+ <div><textarea id="set2" dir="foopy">ABC אבג</textarea></div>
+ <div><button id="set3" dir="foopy">ABC אבג</button></div>
+ <div><bdi id="set4" dir="foopy">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir5.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir5.html
new file mode 100644
index 000000000..6da8dff2f
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir5.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('foopy')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="rtl"></div>
+ <div><span id="set1" dir="rtl">ABC אבג</span></div>
+ <div><textarea id="set2" dir="rtl">ABC אבג</textarea></div>
+ <div><button id="set3" dir="rtl">ABC אבג</button></div>
+ <div><bdi id="set4" dir="rtl">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir6.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir6.html
new file mode 100644
index 000000000..b63c0dd0d
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir6.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('foopy')">
+ <div><input type="text" value="ABC אבג" id="set0"></div>
+ <div><span id="set1">ABC אבג</span></div>
+ <div><textarea id="set2">ABC אבג</textarea></div>
+ <div><button id="set3">ABC אבג</button></div>
+ <div><bdi id="set4">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir7.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir7.html
new file mode 100644
index 000000000..e1b9d82c1
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir7.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('foopy')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">ABC אבג</span></div>
+ <div><textarea id="set2" dir="auto">ABC אבג</textarea></div>
+ <div><button id="set3" dir="auto">ABC אבג</button></div>
+ <div><bdi id="set4" dir="auto">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir8.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir8.html
new file mode 100644
index 000000000..9b80f42d0
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-InvalidDir8.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="foopy"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('foopy')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">ABC אבג</span></div>
+ <div><textarea id="set2" dir="foopy">ABC אבג</textarea></div>
+ <div><button id="set3" dir="foopy">ABC אבג</button></div>
+ <div><bdi id="set4" dir="foopy">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR1.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR1.html
new file mode 100644
index 000000000..e89fc7921
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('ltr')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="rtl"></div>
+ <div><span id="set1" dir="rtl">ABC אבג</span></div>
+ <div><textarea id="set2" dir="rtl">ABC אבג</textarea></div>
+ <div><button id="set3" dir="rtl">ABC אבג</button></div>
+ <div><bdi id="set4" dir="rtl">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR2.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR2.html
new file mode 100644
index 000000000..5a8e4f122
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('ltr')">
+ <div><input type="text" value="ABC אבג" id="set0"></div>
+ <div><span id="set1">ABC אבג</span></div>
+ <div><textarea id="set2">ABC אבג</textarea></div>
+ <div><button id="set3">ABC אבג</button></div>
+ <div><bdi id="set4">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR3.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR3.html
new file mode 100644
index 000000000..bbc5f8090
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR3.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('ltr')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">ABC אבג</span></div>
+ <div><textarea id="set2" dir="auto">ABC אבג</textarea></div>
+ <div><button id="set3" dir="auto">ABC אבג</button></div>
+ <div><bdi id="set4" dir="auto">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR4.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR4.html
new file mode 100644
index 000000000..08b21e09a
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR4.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="foopy"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('ltr')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">ABC אבג</span></div>
+ <div><textarea id="set2" dir="foopy">ABC אבג</textarea></div>
+ <div><button id="set3" dir="foopy">ABC אבג</button></div>
+ <div><bdi id="set4" dir="foopy">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR5.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR5.html
new file mode 100644
index 000000000..cffe2556b
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR5.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('ltr')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="rtl"></div>
+ <div><span id="set1" dir="rtl">ABC אבג</span></div>
+ <div><textarea id="set2" dir="rtl">ABC אבג</textarea></div>
+ <div><button id="set3" dir="rtl">ABC אבג</button></div>
+ <div><bdi id="set4" dir="rtl">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR6.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR6.html
new file mode 100644
index 000000000..b54417b6f
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR6.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('ltr')">
+ <div><input type="text" value="ABC אבג" id="set0"></div>
+ <div><span id="set1">ABC אבג</span></div>
+ <div><textarea id="set2">ABC אבג</textarea></div>
+ <div><button id="set3">ABC אבג</button></div>
+ <div><bdi id="set4">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR7.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR7.html
new file mode 100644
index 000000000..0baeb9fc6
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR7.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('ltr')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">ABC אבג</span></div>
+ <div><textarea id="set2" dir="auto">ABC אבג</textarea></div>
+ <div><button id="set3" dir="auto">ABC אבג</button></div>
+ <div><bdi id="set4" dir="auto">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR8.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR8.html
new file mode 100644
index 000000000..ec1de3542
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-LTR8.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="foopy"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('ltr')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">ABC אבג</span></div>
+ <div><textarea id="set2" dir="foopy">ABC אבג</textarea></div>
+ <div><button id="set3" dir="foopy">ABC אבג</button></div>
+ <div><bdi id="set4" dir="foopy">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir1.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir1.html
new file mode 100644
index 000000000..2040663c3
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="rtl"></div>
+ <div><span id="set1" dir="rtl">ABC אבג</span></div>
+ <div><textarea id="set2" dir="rtl">ABC אבג</textarea></div>
+ <div><button id="set3" dir="rtl">ABC אבג</button></div>
+ <div><bdi id="set4" dir="rtl">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir2.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir2.html
new file mode 100644
index 000000000..f8c2e99a7
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('')">
+ <div><input type="text" value="ABC אבג" id="set0"></div>
+ <div><span id="set1">ABC אבג</span></div>
+ <div><textarea id="set2">ABC אבג</textarea></div>
+ <div><button id="set3">ABC אבג</button></div>
+ <div><bdi id="set4">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir3.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir3.html
new file mode 100644
index 000000000..c295012db
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir3.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">ABC אבג</span></div>
+ <div><textarea id="set2" dir="auto">ABC אבג</textarea></div>
+ <div><button id="set3" dir="auto">ABC אבג</button></div>
+ <div><bdi id="set4" dir="auto">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir4.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir4.html
new file mode 100644
index 000000000..13e0e5fc8
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir4.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="foopy"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">ABC אבג</span></div>
+ <div><textarea id="set2" dir="foopy">ABC אבג</textarea></div>
+ <div><button id="set3" dir="foopy">ABC אבג</button></div>
+ <div><bdi id="set4" dir="foopy">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir5.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir5.html
new file mode 100644
index 000000000..6dce96a60
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir5.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="removeAllDirAttribute()">
+ <div><input type="text" value="ABC אבג" id="set0" dir="rtl"></div>
+ <div><span id="set1" dir="rtl">ABC אבג</span></div>
+ <div><textarea id="set2" dir="rtl">ABC אבג</textarea></div>
+ <div><button id="set3" dir="rtl">ABC אבג</button></div>
+ <div><bdi id="set4" dir="rtl">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir6.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir6.html
new file mode 100644
index 000000000..2d9973fa1
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir6.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="removeAllDirAttribute()">
+ <div><input type="text" value="ABC אבג" id="set0"></div>
+ <div><span id="set1">ABC אבג</span></div>
+ <div><textarea id="set2">ABC אבג</textarea></div>
+ <div><button id="set3">ABC אבג</button></div>
+ <div><bdi id="set4">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir7.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir7.html
new file mode 100644
index 000000000..dd1964e01
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir7.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="removeAllDirAttribute()">
+ <div><input type="text" value="ABC אבג" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">ABC אבג</span></div>
+ <div><textarea id="set2" dir="auto">ABC אבג</textarea></div>
+ <div><button id="set3" dir="auto">ABC אבג</button></div>
+ <div><bdi id="set4" dir="auto">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir8.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir8.html
new file mode 100644
index 000000000..96d780935
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-NoDir8.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="foopy"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="removeAllDirAttribute()">
+ <div><input type="text" value="ABC אבג" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">ABC אבג</span></div>
+ <div><textarea id="set2" dir="foopy">ABC אבג</textarea></div>
+ <div><button id="set3" dir="foopy">ABC אבג</button></div>
+ <div><bdi id="set4" dir="foopy">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL1.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL1.html
new file mode 100644
index 000000000..c5a9bf42d
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('rtl')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="ltr"></div>
+ <div><span id="set1" dir="ltr">ABC אבג</span></div>
+ <div><textarea id="set2" dir="ltr">ABC אבג</textarea></div>
+ <div><button id="set3" dir="ltr">ABC אבג</button></div>
+ <div><bdi id="set4" dir="ltr">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL2.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL2.html
new file mode 100644
index 000000000..b8ed6cda8
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('rtl')">
+ <div><input type="text" value="ABC אבג" id="set0"></div>
+ <div><span id="set1">ABC אבג</span></div>
+ <div><textarea id="set2">ABC אבג</textarea></div>
+ <div><button id="set3">ABC אבג</button></div>
+ <div><span id="set4">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL3.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL3.html
new file mode 100644
index 000000000..528ffde04
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL3.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('rtl')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">ABC אבג</span></div>
+ <div><textarea id="set2" dir="auto">ABC אבג</textarea></div>
+ <div><button id="set3" dir="auto">ABC אבג</button></div>
+ <div><span id="set4" dir="auto">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL4.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL4.html
new file mode 100644
index 000000000..884c8fa85
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL4.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="foopy"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('rtl')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">ABC אבג</span></div>
+ <div><textarea id="set2" dir="foopy">ABC אבג</textarea></div>
+ <div><button id="set3" dir="foopy">ABC אבג</button></div>
+ <div><span id="set4" dir="foopy">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL5.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL5.html
new file mode 100644
index 000000000..5cf486c90
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL5.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('rtl')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="ltr"></div>
+ <div><span id="set1" dir="ltr">ABC אבג</span></div>
+ <div><textarea id="set2" dir="ltr">ABC אבג</textarea></div>
+ <div><button id="set3" dir="ltr">ABC אבג</button></div>
+ <div><bdi id="set4" dir="ltr">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL6.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL6.html
new file mode 100644
index 000000000..61c7331bd
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL6.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('rtl')">
+ <div><input type="text" value="ABC אבג" id="set0"></div>
+ <div><span id="set1">ABC אבג</span></div>
+ <div><textarea id="set2">ABC אבג</textarea></div>
+ <div><button id="set3">ABC אבג</button></div>
+ <div><span id="set4">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL7.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL7.html
new file mode 100644
index 000000000..c4cc154cb
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL7.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('rtl')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">ABC אבג</span></div>
+ <div><textarea id="set2" dir="auto">ABC אבג</textarea></div>
+ <div><button id="set3" dir="auto">ABC אבג</button></div>
+ <div><span id="set4" dir="auto">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL8.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL8.html
new file mode 100644
index 000000000..18e333978
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setLTR-RTL8.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="foopy"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('rtl')">
+ <div><input type="text" value="ABC אבג" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">ABC אבג</span></div>
+ <div><textarea id="set2" dir="foopy">ABC אבג</textarea></div>
+ <div><button id="set3" dir="foopy">ABC אבג</button></div>
+ <div><span id="set4" dir="foopy">ABC אבג</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto1.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto1.html
new file mode 100644
index 000000000..483d79fd5
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('auto')">
+ <div><input type="text" value="אבג ABC" id="set0"></div>
+ <div><span id="set1">אבג ABC</span></div>
+ <div><textarea id="set2">אבג ABC</textarea></div>
+ <div><button id="set3">אבג ABC</button></div>
+ <div><bdi id="set4">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto2.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto2.html
new file mode 100644
index 000000000..b0773e6f6
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('auto')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="rtl"></div>
+ <div><span id="set1" dir="rtl">אבג ABC</span></div>
+ <div><textarea id="set2" dir="rtl">אבג ABC</textarea></div>
+ <div><button id="set3" dir="rtl">אבג ABC</button></div>
+ <div><bdi id="set4" dir="rtl">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto3.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto3.html
new file mode 100644
index 000000000..77ce26cb3
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto3.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('auto')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">אבג ABC</span></div>
+ <div><textarea id="set2" dir="foopy">אבג ABC</textarea></div>
+ <div><button id="set3" dir="foopy">אבג ABC</button></div>
+ <div><bdi id="set4" dir="foopy">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto4.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto4.html
new file mode 100644
index 000000000..f8cabec1e
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto4.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('auto')">
+ <div><input type="text" value="אבג ABC" id="set0"></div>
+ <div><span id="set1">אבג ABC</span></div>
+ <div><textarea id="set2">אבג ABC</textarea></div>
+ <div><button id="set3">אבג ABC</button></div>
+ <div><bdi id="set4">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto5.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto5.html
new file mode 100644
index 000000000..20621a5a7
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto5.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('auto')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="rtl"></div>
+ <div><span id="set1" dir="rtl">אבג ABC</span></div>
+ <div><textarea id="set2" dir="rtl">אבג ABC</textarea></div>
+ <div><button id="set3" dir="rtl">אבג ABC</button></div>
+ <div><bdi id="set4" dir="rtl">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto6.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto6.html
new file mode 100644
index 000000000..c9e1b560f
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-Auto6.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('auto')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">אבג ABC</span></div>
+ <div><textarea id="set2" dir="foopy">אבג ABC</textarea></div>
+ <div><button id="set3" dir="foopy">אבג ABC</button></div>
+ <div><bdi id="set4" dir="foopy">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir1.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir1.html
new file mode 100644
index 000000000..a2ddd5292
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('foopy')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="rtl"></div>
+ <div><span id="set1" dir="rtl">אבג ABC</span></div>
+ <div><textarea id="set2" dir="rtl">אבג ABC</textarea></div>
+ <div><button id="set3" dir="rtl">אבג ABC</button></div>
+ <div><bdi id="set4" dir="rtl">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir2.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir2.html
new file mode 100644
index 000000000..87eb11819
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('foopy')">
+ <div><input type="text" value="אבג ABC" id="set0"></div>
+ <div><span id="set1">אבג ABC</span></div>
+ <div><textarea id="set2">אבג ABC</textarea></div>
+ <div><button id="set3">אבג ABC</button></div>
+ <div><bdi id="set4">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir3.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir3.html
new file mode 100644
index 000000000..17ec5b453
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir3.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('foopy')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">אבג ABC</span></div>
+ <div><textarea id="set2" dir="auto">אבג ABC</textarea></div>
+ <div><button id="set3" dir="auto">אבג ABC</button></div>
+ <div><bdi id="set4" dir="auto">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir4.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir4.html
new file mode 100644
index 000000000..b4c5ebc09
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir4.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="foopy"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('foopy')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">אבג ABC</span></div>
+ <div><textarea id="set2" dir="foopy">אבג ABC</textarea></div>
+ <div><button id="set3" dir="foopy">אבג ABC</button></div>
+ <div><bdi id="set4" dir="foopy">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir5.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir5.html
new file mode 100644
index 000000000..1859e89bc
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir5.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('foopy')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="rtl"></div>
+ <div><span id="set1" dir="rtl">אבג ABC</span></div>
+ <div><textarea id="set2" dir="rtl">אבג ABC</textarea></div>
+ <div><button id="set3" dir="rtl">אבג ABC</button></div>
+ <div><bdi id="set4" dir="rtl">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir6.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir6.html
new file mode 100644
index 000000000..06c3d7170
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir6.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('foopy')">
+ <div><input type="text" value="אבג ABC" id="set0"></div>
+ <div><span id="set1">אבג ABC</span></div>
+ <div><textarea id="set2">אבג ABC</textarea></div>
+ <div><button id="set3">אבג ABC</button></div>
+ <div><bdi id="set4">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir7.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir7.html
new file mode 100644
index 000000000..03239e88b
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir7.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('foopy')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">אבג ABC</span></div>
+ <div><textarea id="set2" dir="auto">אבג ABC</textarea></div>
+ <div><button id="set3" dir="auto">אבג ABC</button></div>
+ <div><bdi id="set4" dir="auto">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir8.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir8.html
new file mode 100644
index 000000000..fc353ac22
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-InvalidDir8.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="foopy"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('foopy')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">אבג ABC</span></div>
+ <div><textarea id="set2" dir="foopy">אבג ABC</textarea></div>
+ <div><button id="set3" dir="foopy">אבג ABC</button></div>
+ <div><bdi id="set4" dir="foopy">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR1.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR1.html
new file mode 100644
index 000000000..52fcf96b3
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('ltr')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="rtl"></div>
+ <div><span id="set1" dir="rtl">אבג ABC</span></div>
+ <div><textarea id="set2" dir="rtl">אבג ABC</textarea></div>
+ <div><button id="set3" dir="rtl">אבג ABC</button></div>
+ <div><bdi id="set4" dir="rtl">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR2.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR2.html
new file mode 100644
index 000000000..074eeab10
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('ltr')">
+ <div><input type="text" value="אבג ABC" id="set0"></div>
+ <div><span id="set1">אבג ABC</span></div>
+ <div><textarea id="set2">אבג ABC</textarea></div>
+ <div><button id="set3">אבג ABC</button></div>
+ <div><bdi id="set4">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR3.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR3.html
new file mode 100644
index 000000000..2bb5ad2de
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR3.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('ltr')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">אבג ABC</span></div>
+ <div><textarea id="set2" dir="auto">אבג ABC</textarea></div>
+ <div><button id="set3" dir="auto">אבג ABC</button></div>
+ <div><bdi id="set4" dir="auto">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR4.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR4.html
new file mode 100644
index 000000000..79372c6ed
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR4.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="foopy"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('ltr')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">אבג ABC</span></div>
+ <div><textarea id="set2" dir="foopy">אבג ABC</textarea></div>
+ <div><button id="set3" dir="foopy">אבג ABC</button></div>
+ <div><bdi id="set4" dir="foopy">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR5.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR5.html
new file mode 100644
index 000000000..212017015
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR5.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('ltr')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="rtl"></div>
+ <div><span id="set1" dir="rtl">אבג ABC</span></div>
+ <div><textarea id="set2" dir="rtl">אבג ABC</textarea></div>
+ <div><button id="set3" dir="rtl">אבג ABC</button></div>
+ <div><bdi id="set4" dir="rtl">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR6.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR6.html
new file mode 100644
index 000000000..272d5f9fc
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR6.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('ltr')">
+ <div><input type="text" value="אבג ABC" id="set0"></div>
+ <div><span id="set1">אבג ABC</span></div>
+ <div><textarea id="set2">אבג ABC</textarea></div>
+ <div><button id="set3">אבג ABC</button></div>
+ <div><bdi id="set4">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR7.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR7.html
new file mode 100644
index 000000000..d1d1185d2
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR7.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('ltr')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">אבג ABC</span></div>
+ <div><textarea id="set2" dir="auto">אבג ABC</textarea></div>
+ <div><button id="set3" dir="auto">אבג ABC</button></div>
+ <div><bdi id="set4" dir="auto">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR8.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR8.html
new file mode 100644
index 000000000..a6f9fa09a
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-LTR8.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="foopy"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('ltr')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">אבג ABC</span></div>
+ <div><textarea id="set2" dir="foopy">אבג ABC</textarea></div>
+ <div><button id="set3" dir="foopy">אבג ABC</button></div>
+ <div><bdi id="set4" dir="foopy">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir1.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir1.html
new file mode 100644
index 000000000..ba2bd8bab
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="rtl"></div>
+ <div><span id="set1" dir="rtl">אבג ABC</span></div>
+ <div><textarea id="set2" dir="rtl">אבג ABC</textarea></div>
+ <div><button id="set3" dir="rtl">אבג ABC</button></div>
+ <div><bdi id="set4" dir="rtl">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir2.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir2.html
new file mode 100644
index 000000000..5833b2e4a
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('')">
+ <div><input type="text" value="אבג ABC" id="set0"></div>
+ <div><span id="set1">אבג ABC</span></div>
+ <div><textarea id="set2">אבג ABC</textarea></div>
+ <div><button id="set3">אבג ABC</button></div>
+ <div><bdi id="set4">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir3.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir3.html
new file mode 100644
index 000000000..1a031d043
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir3.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">אבג ABC</span></div>
+ <div><textarea id="set2" dir="auto">אבג ABC</textarea></div>
+ <div><button id="set3" dir="auto">אבג ABC</button></div>
+ <div><bdi id="set4" dir="auto">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir4.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir4.html
new file mode 100644
index 000000000..53074850d
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir4.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="foopy"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">אבג ABC</span></div>
+ <div><textarea id="set2" dir="foopy">אבג ABC</textarea></div>
+ <div><button id="set3" dir="foopy">אבג ABC</button></div>
+ <div><bdi id="set4" dir="foopy">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir5.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir5.html
new file mode 100644
index 000000000..63fc1a746
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir5.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="removeAllDirAttribute()">
+ <div><input type="text" value="אבג ABC" id="set0" dir="rtl"></div>
+ <div><span id="set1" dir="rtl">אבג ABC</span></div>
+ <div><textarea id="set2" dir="rtl">אבג ABC</textarea></div>
+ <div><button id="set3" dir="rtl">אבג ABC</button></div>
+ <div><bdi id="set4" dir="rtl">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir6.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir6.html
new file mode 100644
index 000000000..31af1459d
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir6.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="removeAllDirAttribute()">
+ <div><input type="text" value="אבג ABC" id="set0"></div>
+ <div><span id="set1">אבג ABC</span></div>
+ <div><textarea id="set2">אבג ABC</textarea></div>
+ <div><button id="set3">אבג ABC</button></div>
+ <div><bdi id="set4">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir7.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir7.html
new file mode 100644
index 000000000..5fd61d42e
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir7.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="removeAllDirAttribute()">
+ <div><input type="text" value="אבג ABC" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">אבג ABC</span></div>
+ <div><textarea id="set2" dir="auto">אבג ABC</textarea></div>
+ <div><button id="set3" dir="auto">אבג ABC</button></div>
+ <div><bdi id="set4" dir="auto">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir8.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir8.html
new file mode 100644
index 000000000..d388d5377
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-NoDir8.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="foopy"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="removeAllDirAttribute()">
+ <div><input type="text" value="אבג ABC" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">אבג ABC</span></div>
+ <div><textarea id="set2" dir="foopy">אבג ABC</textarea></div>
+ <div><button id="set3" dir="foopy">אבג ABC</button></div>
+ <div><bdi id="set4" dir="foopy">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL1.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL1.html
new file mode 100644
index 000000000..45ee5c571
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('rtl')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="ltr"></div>
+ <div><span id="set1" dir="ltr">אבג ABC</span></div>
+ <div><textarea id="set2" dir="ltr">אבג ABC</textarea></div>
+ <div><button id="set3" dir="ltr">אבג ABC</button></div>
+ <div><bdi id="set4" dir="ltr">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL2.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL2.html
new file mode 100644
index 000000000..0df2fc8de
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('rtl')">
+ <div><input type="text" value="אבג ABC" id="set0"></div>
+ <div><span id="set1">אבג ABC</span></div>
+ <div><textarea id="set2">אבג ABC</textarea></div>
+ <div><button id="set3">אבג ABC</button></div>
+ <div><bdi id="set4">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL3.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL3.html
new file mode 100644
index 000000000..0dee370b6
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL3.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('rtl')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">אבג ABC</span></div>
+ <div><textarea id="set2" dir="auto">אבג ABC</textarea></div>
+ <div><button id="set3" dir="auto">אבג ABC</button></div>
+ <div><bdi id="set4" dir="auto">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL4.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL4.html
new file mode 100644
index 000000000..dbfbe2125
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL4.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="foopy"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDir('rtl')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">אבג ABC</span></div>
+ <div><textarea id="set2" dir="foopy">אבג ABC</textarea></div>
+ <div><button id="set3" dir="foopy">אבג ABC</button></div>
+ <div><bdi id="set4" dir="foopy">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL5.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL5.html
new file mode 100644
index 000000000..1b401367c
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL5.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('rtl')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="ltr"></div>
+ <div><span id="set1" dir="ltr">אבג ABC</span></div>
+ <div><textarea id="set2" dir="ltr">אבג ABC</textarea></div>
+ <div><button id="set3" dir="ltr">אבג ABC</button></div>
+ <div><bdi id="set4" dir="ltr">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL6.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL6.html
new file mode 100644
index 000000000..d2c70793c
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL6.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('rtl')">
+ <div><input type="text" value="אבג ABC" id="set0"></div>
+ <div><span id="set1">אבג ABC</span></div>
+ <div><textarea id="set2">אבג ABC</textarea></div>
+ <div><button id="set3">אבג ABC</button></div>
+ <div><bdi id="set4">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL7.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL7.html
new file mode 100644
index 000000000..ca0153cc2
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL7.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="auto"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('rtl')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="auto"></div>
+ <div><span id="set1" dir="auto">אבג ABC</span></div>
+ <div><textarea id="set2" dir="auto">אבג ABC</textarea></div>
+ <div><button id="set3" dir="auto">אבג ABC</button></div>
+ <div><bdi id="set4" dir="auto">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL8.html b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL8.html
new file mode 100644
index 000000000..15b323976
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/dynamicDirAuto-setRTL-RTL8.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Set and unset dir="foopy"</title>
+ <script type="text/javascript" src="setDir.js"></script>
+ <style>
+ textarea { resize: none; }
+ </style>
+ </head>
+ <body onload="setAllDirAttribute('rtl')">
+ <div><input type="text" value="אבג ABC" id="set0" dir="foopy"></div>
+ <div><span id="set1" dir="foopy">אבג ABC</span></div>
+ <div><textarea id="set2" dir="foopy">אבג ABC</textarea></div>
+ <div><button id="set3" dir="foopy">אבג ABC</button></div>
+ <div><bdi id="set4" dir="foopy">אבג ABC</bdi></div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/dirAuto/reftest-stylo.list b/layout/reftests/bidi/dirAuto/reftest-stylo.list
new file mode 100644
index 000000000..991841fee
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/reftest-stylo.list
@@ -0,0 +1,120 @@
+# DO NOT EDIT! This is a auto-generated temporary list for Stylo testing
+== bdi-auto-dir-default.html bdi-auto-dir-default.html
+== dir_auto-set-contained-dir-L.html dir_auto-set-contained-dir-L.html
+== dir_auto-set-contained-dir-R.html dir_auto-set-contained-dir-R.html
+== dir_auto-set-contained-invalid-dir-L.html dir_auto-set-contained-invalid-dir-L.html
+== dir_auto-set-contained-invalid-dir-R.html dir_auto-set-contained-invalid-dir-R.html
+== dir_auto-unset-contained-dir-L.html dir_auto-unset-contained-dir-L.html
+== dir_auto-unset-contained-dir-R.html dir_auto-unset-contained-dir-R.html
+== dynamicDirAuto-setLTR-Auto1.html dynamicDirAuto-setLTR-Auto1.html
+== dynamicDirAuto-setLTR-Auto2.html dynamicDirAuto-setLTR-Auto2.html
+== dynamicDirAuto-setLTR-Auto3.html dynamicDirAuto-setLTR-Auto3.html
+== dynamicDirAuto-setLTR-Auto4.html dynamicDirAuto-setLTR-Auto4.html
+== dynamicDirAuto-setLTR-Auto5.html dynamicDirAuto-setLTR-Auto5.html
+== dynamicDirAuto-setLTR-Auto6.html dynamicDirAuto-setLTR-Auto6.html
+== dynamicDirAuto-setLTR-LTR1.html dynamicDirAuto-setLTR-LTR1.html
+== dynamicDirAuto-setLTR-LTR2.html dynamicDirAuto-setLTR-LTR2.html
+== dynamicDirAuto-setLTR-LTR3.html dynamicDirAuto-setLTR-LTR3.html
+== dynamicDirAuto-setLTR-LTR4.html dynamicDirAuto-setLTR-LTR4.html
+== dynamicDirAuto-setLTR-LTR5.html dynamicDirAuto-setLTR-LTR5.html
+== dynamicDirAuto-setLTR-LTR6.html dynamicDirAuto-setLTR-LTR6.html
+== dynamicDirAuto-setLTR-LTR7.html dynamicDirAuto-setLTR-LTR7.html
+== dynamicDirAuto-setLTR-LTR8.html dynamicDirAuto-setLTR-LTR8.html
+== dynamicDirAuto-setLTR-RTL1.html dynamicDirAuto-setLTR-RTL1.html
+== dynamicDirAuto-setLTR-RTL2.html dynamicDirAuto-setLTR-RTL2.html
+== dynamicDirAuto-setLTR-RTL3.html dynamicDirAuto-setLTR-RTL3.html
+== dynamicDirAuto-setLTR-RTL4.html dynamicDirAuto-setLTR-RTL4.html
+== dynamicDirAuto-setLTR-RTL5.html dynamicDirAuto-setLTR-RTL5.html
+== dynamicDirAuto-setLTR-RTL6.html dynamicDirAuto-setLTR-RTL6.html
+== dynamicDirAuto-setLTR-RTL7.html dynamicDirAuto-setLTR-RTL7.html
+== dynamicDirAuto-setLTR-RTL8.html dynamicDirAuto-setLTR-RTL8.html
+== dynamicDirAuto-setLTR-NoDir1.html dynamicDirAuto-setLTR-NoDir1.html
+== dynamicDirAuto-setLTR-NoDir2.html dynamicDirAuto-setLTR-NoDir2.html
+== dynamicDirAuto-setLTR-NoDir3.html dynamicDirAuto-setLTR-NoDir3.html
+== dynamicDirAuto-setLTR-NoDir4.html dynamicDirAuto-setLTR-NoDir4.html
+== dynamicDirAuto-setLTR-NoDir5.html dynamicDirAuto-setLTR-NoDir5.html
+== dynamicDirAuto-setLTR-NoDir6.html dynamicDirAuto-setLTR-NoDir6.html
+== dynamicDirAuto-setLTR-NoDir7.html dynamicDirAuto-setLTR-NoDir7.html
+== dynamicDirAuto-setLTR-NoDir8.html dynamicDirAuto-setLTR-NoDir8.html
+== dynamicDirAuto-setLTR-InvalidDir1.html dynamicDirAuto-setLTR-InvalidDir1.html
+== dynamicDirAuto-setLTR-InvalidDir2.html dynamicDirAuto-setLTR-InvalidDir2.html
+== dynamicDirAuto-setLTR-InvalidDir3.html dynamicDirAuto-setLTR-InvalidDir3.html
+== dynamicDirAuto-setLTR-InvalidDir4.html dynamicDirAuto-setLTR-InvalidDir4.html
+== dynamicDirAuto-setLTR-InvalidDir5.html dynamicDirAuto-setLTR-InvalidDir5.html
+== dynamicDirAuto-setLTR-InvalidDir6.html dynamicDirAuto-setLTR-InvalidDir6.html
+== dynamicDirAuto-setLTR-InvalidDir7.html dynamicDirAuto-setLTR-InvalidDir7.html
+== dynamicDirAuto-setLTR-InvalidDir7.html dynamicDirAuto-setLTR-InvalidDir7.html
+== dynamicDirAuto-setRTL-Auto1.html dynamicDirAuto-setRTL-Auto1.html
+== dynamicDirAuto-setRTL-Auto2.html dynamicDirAuto-setRTL-Auto2.html
+== dynamicDirAuto-setRTL-Auto3.html dynamicDirAuto-setRTL-Auto3.html
+== dynamicDirAuto-setRTL-Auto4.html dynamicDirAuto-setRTL-Auto4.html
+== dynamicDirAuto-setRTL-Auto5.html dynamicDirAuto-setRTL-Auto5.html
+== dynamicDirAuto-setRTL-Auto6.html dynamicDirAuto-setRTL-Auto6.html
+== dynamicDirAuto-setRTL-LTR1.html dynamicDirAuto-setRTL-LTR1.html
+== dynamicDirAuto-setRTL-LTR2.html dynamicDirAuto-setRTL-LTR2.html
+== dynamicDirAuto-setRTL-LTR3.html dynamicDirAuto-setRTL-LTR3.html
+== dynamicDirAuto-setRTL-LTR4.html dynamicDirAuto-setRTL-LTR4.html
+== dynamicDirAuto-setRTL-LTR5.html dynamicDirAuto-setRTL-LTR5.html
+== dynamicDirAuto-setRTL-LTR6.html dynamicDirAuto-setRTL-LTR6.html
+== dynamicDirAuto-setRTL-LTR7.html dynamicDirAuto-setRTL-LTR7.html
+== dynamicDirAuto-setRTL-LTR8.html dynamicDirAuto-setRTL-LTR8.html
+== dynamicDirAuto-setRTL-RTL1.html dynamicDirAuto-setRTL-RTL1.html
+== dynamicDirAuto-setRTL-RTL2.html dynamicDirAuto-setRTL-RTL2.html
+== dynamicDirAuto-setRTL-RTL3.html dynamicDirAuto-setRTL-RTL3.html
+== dynamicDirAuto-setRTL-RTL4.html dynamicDirAuto-setRTL-RTL4.html
+== dynamicDirAuto-setRTL-RTL5.html dynamicDirAuto-setRTL-RTL5.html
+== dynamicDirAuto-setRTL-RTL6.html dynamicDirAuto-setRTL-RTL6.html
+== dynamicDirAuto-setRTL-RTL7.html dynamicDirAuto-setRTL-RTL7.html
+== dynamicDirAuto-setRTL-RTL8.html dynamicDirAuto-setRTL-RTL8.html
+== dynamicDirAuto-setRTL-NoDir1.html dynamicDirAuto-setRTL-NoDir1.html
+== dynamicDirAuto-setRTL-NoDir2.html dynamicDirAuto-setRTL-NoDir2.html
+== dynamicDirAuto-setRTL-NoDir3.html dynamicDirAuto-setRTL-NoDir3.html
+== dynamicDirAuto-setRTL-NoDir4.html dynamicDirAuto-setRTL-NoDir4.html
+== dynamicDirAuto-setRTL-NoDir5.html dynamicDirAuto-setRTL-NoDir5.html
+== dynamicDirAuto-setRTL-NoDir6.html dynamicDirAuto-setRTL-NoDir6.html
+== dynamicDirAuto-setRTL-NoDir7.html dynamicDirAuto-setRTL-NoDir7.html
+== dynamicDirAuto-setRTL-NoDir8.html dynamicDirAuto-setRTL-NoDir8.html
+== dynamicDirAuto-setRTL-InvalidDir1.html dynamicDirAuto-setRTL-InvalidDir1.html
+== dynamicDirAuto-setRTL-InvalidDir2.html dynamicDirAuto-setRTL-InvalidDir2.html
+== dynamicDirAuto-setRTL-InvalidDir3.html dynamicDirAuto-setRTL-InvalidDir3.html
+== dynamicDirAuto-setRTL-InvalidDir4.html dynamicDirAuto-setRTL-InvalidDir4.html
+== dynamicDirAuto-setRTL-InvalidDir5.html dynamicDirAuto-setRTL-InvalidDir5.html
+== dynamicDirAuto-setRTL-InvalidDir6.html dynamicDirAuto-setRTL-InvalidDir6.html
+== dynamicDirAuto-setRTL-InvalidDir7.html dynamicDirAuto-setRTL-InvalidDir7.html
+== dynamicDirAuto-setRTL-InvalidDir8.html dynamicDirAuto-setRTL-InvalidDir8.html
+== dynamicDirAuto-addLTR-Auto.html dynamicDirAuto-addLTR-Auto.html
+== dynamicDirAuto-addRTL-Auto.html dynamicDirAuto-addRTL-Auto.html
+== dynamicDirAuto-ChangeText-LTR1.html dynamicDirAuto-ChangeText-LTR1.html
+== dynamicDirAuto-ChangeText-LTR2.html dynamicDirAuto-ChangeText-LTR2.html
+== dynamicDirAuto-ChangeText-LTR3.html dynamicDirAuto-ChangeText-LTR3.html
+== dynamicDirAuto-ChangeText-LTR4.html dynamicDirAuto-ChangeText-LTR4.html
+== dynamicDirAuto-ChangeText-LTR5.html dynamicDirAuto-ChangeText-LTR5.html
+== dynamicDirAuto-ChangeText-LTR6.html dynamicDirAuto-ChangeText-LTR6.html
+== dynamicDirAuto-ChangeText-LTR7.html dynamicDirAuto-ChangeText-LTR7.html
+== dynamicDirAuto-ChangeText-LTR8.html dynamicDirAuto-ChangeText-LTR8.html
+== dynamicDirAuto-ChangeText-LTR9.html dynamicDirAuto-ChangeText-LTR9.html
+== dynamicDirAuto-ChangeText-LTR10.html dynamicDirAuto-ChangeText-LTR10.html
+== dynamicDirAuto-ChangeText-RTL1.html dynamicDirAuto-ChangeText-RTL1.html
+== dynamicDirAuto-ChangeText-RTL2.html dynamicDirAuto-ChangeText-RTL2.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,30,1) == dynamicDirAuto-ChangeText-RTL3.html dynamicDirAuto-ChangeText-RTL3.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,30,1) == dynamicDirAuto-ChangeText-RTL4.html dynamicDirAuto-ChangeText-RTL4.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,30,1) == dynamicDirAuto-ChangeText-RTL5.html dynamicDirAuto-ChangeText-RTL5.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,30,1) == dynamicDirAuto-ChangeText-RTL6.html dynamicDirAuto-ChangeText-RTL6.html
+== dynamicDirAuto-ChangeText-RTL7.html dynamicDirAuto-ChangeText-RTL7.html
+== dynamicDirAuto-ChangeText-RTL8.html dynamicDirAuto-ChangeText-RTL8.html
+== dynamicDirAuto-ChangeText-RTL9.html dynamicDirAuto-ChangeText-RTL9.html
+== dynamicDirAuto-ChangeText-RTL10.html dynamicDirAuto-ChangeText-RTL10.html
+== dynamicDirAuto-DeleteText-LTR1.html dynamicDirAuto-DeleteText-LTR1.html
+== dynamicDirAuto-DeleteText-LTR2.html dynamicDirAuto-DeleteText-LTR2.html
+== dynamicDirAuto-DeleteText-LTR3.html dynamicDirAuto-DeleteText-LTR3.html
+== dynamicDirAuto-DeleteText-RTL1.html dynamicDirAuto-DeleteText-RTL1.html
+== dynamicDirAuto-DeleteText-RTL2.html dynamicDirAuto-DeleteText-RTL2.html
+== dynamicDirAuto-DeleteText-RTL3.html dynamicDirAuto-DeleteText-RTL3.html
+== 839886-1.html 839886-1.html
+== 859093-1.html 859093-1.html
+== 889742-1.html 889742-1.html
+== 1103348-1.html 1103348-1.html
+== 1169267-delete-add-1a.html 1169267-delete-add-1a.html
+== 1169267-delete-add-1b.html 1169267-delete-add-1b.html
+== 1169267-delete-add-2a.html 1169267-delete-add-2a.html
+== 1169267-delete-add-2b.html 1169267-delete-add-2b.html
diff --git a/layout/reftests/bidi/dirAuto/reftest.list b/layout/reftests/bidi/dirAuto/reftest.list
new file mode 100644
index 000000000..456935442
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/reftest.list
@@ -0,0 +1,119 @@
+== bdi-auto-dir-default.html bdi-auto-dir-default-ref.html
+== dir_auto-set-contained-dir-L.html dir_auto-contained-dir-L-ref.html
+== dir_auto-set-contained-dir-R.html dir_auto-contained-dir-R-ref.html
+== dir_auto-set-contained-invalid-dir-L.html dir_auto-contained-dir-L-ref.html
+== dir_auto-set-contained-invalid-dir-R.html dir_auto-contained-dir-R-ref.html
+== dir_auto-unset-contained-dir-L.html dir_auto-unset-contained-dir-L-ref.html
+== dir_auto-unset-contained-dir-R.html dir_auto-unset-contained-dir-R-ref.html
+== dynamicDirAuto-setLTR-Auto1.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-Auto2.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-Auto3.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-Auto4.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-Auto5.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-Auto6.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-LTR1.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-LTR2.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-LTR3.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-LTR4.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-LTR5.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-LTR6.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-LTR7.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-LTR8.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-RTL1.html dynamicDirAuto-refLTR-RTL.html
+== dynamicDirAuto-setLTR-RTL2.html dynamicDirAuto-refLTR-RTL.html
+== dynamicDirAuto-setLTR-RTL3.html dynamicDirAuto-refLTR-RTL.html
+== dynamicDirAuto-setLTR-RTL4.html dynamicDirAuto-refLTR-RTL.html
+== dynamicDirAuto-setLTR-RTL5.html dynamicDirAuto-refLTR-RTL.html
+== dynamicDirAuto-setLTR-RTL6.html dynamicDirAuto-refLTR-RTL.html
+== dynamicDirAuto-setLTR-RTL7.html dynamicDirAuto-refLTR-RTL.html
+== dynamicDirAuto-setLTR-RTL8.html dynamicDirAuto-refLTR-RTL.html
+== dynamicDirAuto-setLTR-NoDir1.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-NoDir2.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-NoDir3.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-NoDir4.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-NoDir5.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-NoDir6.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-NoDir7.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-NoDir8.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-InvalidDir1.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-InvalidDir2.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-InvalidDir3.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-InvalidDir4.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-InvalidDir5.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-InvalidDir6.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-InvalidDir7.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setLTR-InvalidDir7.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-setRTL-Auto1.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-setRTL-Auto2.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-setRTL-Auto3.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-setRTL-Auto4.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-setRTL-Auto5.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-setRTL-Auto6.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-setRTL-LTR1.html dynamicDirAuto-refRTL-LTR.html
+== dynamicDirAuto-setRTL-LTR2.html dynamicDirAuto-refRTL-LTR.html
+== dynamicDirAuto-setRTL-LTR3.html dynamicDirAuto-refRTL-LTR.html
+== dynamicDirAuto-setRTL-LTR4.html dynamicDirAuto-refRTL-LTR.html
+== dynamicDirAuto-setRTL-LTR5.html dynamicDirAuto-refRTL-LTR.html
+== dynamicDirAuto-setRTL-LTR6.html dynamicDirAuto-refRTL-LTR.html
+== dynamicDirAuto-setRTL-LTR7.html dynamicDirAuto-refRTL-LTR.html
+== dynamicDirAuto-setRTL-LTR8.html dynamicDirAuto-refRTL-LTR.html
+== dynamicDirAuto-setRTL-RTL1.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-setRTL-RTL2.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-setRTL-RTL3.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-setRTL-RTL4.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-setRTL-RTL5.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-setRTL-RTL6.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-setRTL-RTL7.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-setRTL-RTL8.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-setRTL-NoDir1.html dynamicDirAuto-refRTL-NoDir.html
+== dynamicDirAuto-setRTL-NoDir2.html dynamicDirAuto-refRTL-NoDir.html
+== dynamicDirAuto-setRTL-NoDir3.html dynamicDirAuto-refRTL-NoDir.html
+== dynamicDirAuto-setRTL-NoDir4.html dynamicDirAuto-refRTL-NoDir.html
+== dynamicDirAuto-setRTL-NoDir5.html dynamicDirAuto-refRTL-NoDir.html
+== dynamicDirAuto-setRTL-NoDir6.html dynamicDirAuto-refRTL-NoDir.html
+== dynamicDirAuto-setRTL-NoDir7.html dynamicDirAuto-refRTL-NoDir.html
+== dynamicDirAuto-setRTL-NoDir8.html dynamicDirAuto-refRTL-NoDir.html
+== dynamicDirAuto-setRTL-InvalidDir1.html dynamicDirAuto-refRTL-NoDir.html
+== dynamicDirAuto-setRTL-InvalidDir2.html dynamicDirAuto-refRTL-NoDir.html
+== dynamicDirAuto-setRTL-InvalidDir3.html dynamicDirAuto-refRTL-NoDir.html
+== dynamicDirAuto-setRTL-InvalidDir4.html dynamicDirAuto-refRTL-NoDir.html
+== dynamicDirAuto-setRTL-InvalidDir5.html dynamicDirAuto-refRTL-NoDir.html
+== dynamicDirAuto-setRTL-InvalidDir6.html dynamicDirAuto-refRTL-NoDir.html
+== dynamicDirAuto-setRTL-InvalidDir7.html dynamicDirAuto-refRTL-NoDir.html
+== dynamicDirAuto-setRTL-InvalidDir8.html dynamicDirAuto-refRTL-NoDir.html
+== dynamicDirAuto-addLTR-Auto.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-addRTL-Auto.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-ChangeText-LTR1.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-ChangeText-LTR2.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-ChangeText-LTR3.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-ChangeText-LTR4.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-ChangeText-LTR5.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-ChangeText-LTR6.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-ChangeText-LTR7.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-ChangeText-LTR8.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-ChangeText-LTR9.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-ChangeText-LTR10.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-ChangeText-RTL1.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-ChangeText-RTL2.html dynamicDirAuto-refRTL-RTL.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,30,1) == dynamicDirAuto-ChangeText-RTL3.html dynamicDirAuto-refRTL-RTL.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,30,1) == dynamicDirAuto-ChangeText-RTL4.html dynamicDirAuto-refRTL-RTL.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,30,1) == dynamicDirAuto-ChangeText-RTL5.html dynamicDirAuto-refRTL-RTL.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,30,1) == dynamicDirAuto-ChangeText-RTL6.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-ChangeText-RTL7.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-ChangeText-RTL8.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-ChangeText-RTL9.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-ChangeText-RTL10.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-DeleteText-LTR1.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-DeleteText-LTR2.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-DeleteText-LTR3.html dynamicDirAuto-refLTR-LTR.html
+== dynamicDirAuto-DeleteText-RTL1.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-DeleteText-RTL2.html dynamicDirAuto-refRTL-RTL.html
+== dynamicDirAuto-DeleteText-RTL3.html dynamicDirAuto-refRTL-RTL.html
+== 839886-1.html 839886-1-ref.html
+== 859093-1.html 859093-1-ref.html
+== 889742-1.html 889742-1-ref.html
+== 1103348-1.html 1103348-1-ref.html
+== 1169267-delete-add-1a.html 1169267-delete-add-1-ref.html
+== 1169267-delete-add-1b.html 1169267-delete-add-1-ref.html
+== 1169267-delete-add-2a.html 1169267-delete-add-2-ref.html
+== 1169267-delete-add-2b.html 1169267-delete-add-2-ref.html
diff --git a/layout/reftests/bidi/dirAuto/setDir.js b/layout/reftests/bidi/dirAuto/setDir.js
new file mode 100644
index 000000000..0d8c2afb3
--- /dev/null
+++ b/layout/reftests/bidi/dirAuto/setDir.js
@@ -0,0 +1,247 @@
+function setAllDir(value)
+{
+ for (var i = 0; ; ++i) {
+ try {
+ theElement = document.getElementById("set" + i);
+ theElement.dir = value;
+ } catch(e) {
+ break;
+ }
+ }
+}
+
+function setAllDirAttribute(value)
+{
+ for (var i = 0; ; ++i) {
+ try {
+ theElement = document.getElementById("set" + i);
+ theElement.setAttribute("dir", value);
+ } catch(e) {
+ break;
+ }
+ }
+}
+
+function removeAllDirAttribute()
+{
+ for (var i = 0; ; ++i) {
+ try {
+ theElement = document.getElementById("set" + i);
+ theElement.removeAttribute("dir");
+ } catch(e) {
+ break;
+ }
+ }
+}
+
+function addOneElement(innerHTML)
+{
+ var container = document.getElementById("container");
+ var elem = document.createElement("div");
+ elem.innerHTML = innerHTML;
+ container.appendChild(elem);
+}
+
+function addLTRAutoElements()
+{
+ addOneElement('<input type="text" value="ABC אבג" id="set0" dir="auto">');
+ addOneElement('<span id="set1" dir="auto">ABC אבג</span>');
+ addOneElement('<textarea id="set2" dir="auto">ABC אבג</textarea>');
+ addOneElement('<button id="set3" dir="auto">ABC אבג</button>');
+ addOneElement('<bdi id="set4">ABC אבג</bdi>');
+}
+
+function addRTLAutoElements()
+{
+ addOneElement('<input type="text" value="אבג ABC" id="set0" dir="auto">');
+ addOneElement('<span id="set1" dir="auto">אבג ABC</span>');
+ addOneElement('<textarea id="set2" dir="auto">אבג ABC</textarea>');
+ addOneElement('<button id="set3" dir="auto">אבג ABC</button>');
+ addOneElement('<bdi id="set4">אבג ABC</bdi>');
+}
+
+function setAllTextValuesTo(newText)
+{
+ for (var i = 0; ; ++i) {
+ theElement = document.getElementById("set" + i);
+ if (!theElement) {
+ break;
+ }
+ if (theElement.tagName == "INPUT" ||
+ theElement.tagName == "TEXTAREA") {
+ theElement.value = newText;
+ } else {
+ theElement.firstChild.textContent = newText;
+ }
+ }
+}
+
+function setAllTextDefaultValuesTo(newText)
+{
+ for (var i = 0; ; ++i) {
+ theElement = document.getElementById("set" + i);
+ if (!theElement) {
+ break;
+ }
+ if (theElement.tagName == "INPUT" ||
+ theElement.tagName == "TEXTAREA") {
+ theElement.defaultValue = newText;
+ } else {
+ theElement.firstChild.textContent = newText;
+ }
+ }
+}
+
+function setAllTextChildrenTo(newText)
+{
+ for (var i = 0; ; ++i) {
+ theElement = document.getElementById("set" + i);
+ if (!theElement) {
+ break;
+ }
+ if (theElement.tagName == "INPUT") {
+ theElement.value = newText;
+ } else {
+ theElement.firstChild.textContent = newText;
+ }
+ }
+}
+
+function appendTextFromArray(textArray)
+{
+ for (var i = 0; ; ++i) {
+ theElement = document.getElementById("set" + i);
+ if (!theElement) {
+ break;
+ }
+ for (var j = 0; j < textArray.length; ++j) {
+ if (theElement.tagName == "INPUT") {
+ theElement.value += textArray[j];
+ } else {
+ var textNode = document.createTextNode(textArray[j]);
+ theElement.appendChild(textNode);
+ }
+ }
+ }
+}
+
+// Add the members of the array to the text content of the elements in
+// the document, not including the last member. Then delete the last but
+// one and add the last one
+// Useful for testing scenarios like bug 1169267
+function appendDeleteAppendTextFromArray(textArray)
+{
+ if (textArray.length < 2) {
+ return;
+ }
+
+ for (var i = 0; ; ++i) {
+ theElement = document.getElementById("set" + i);
+ if (!theElement) {
+ break;
+ }
+ var isInput = (theElement.tagName == "INPUT");
+ if (!isInput) {
+ var textNode = document.createTextNode("");
+ theElement.appendChild(textNode);
+ }
+
+ for (var j = 0; j < textArray.length - 1; ++j) {
+ if (isInput) {
+ theElement.value += textArray[j];
+ } else {
+ textNode.appendData(textArray[j]);
+ }
+ }
+
+ // delete the last element added
+ var deleteElt = textArray[textArray.length - 2];
+ if (isInput) {
+ theElement.value = theElement.value.slice(0, -deleteElt.length);
+ } else {
+ textNode.deleteData(textNode.length - deleteElt.length,
+ deleteElt.length);
+ }
+
+ // add the next element
+ var addElt = textArray[textArray.length - 1];
+ if (isInput) {
+ theElement.value += addElt;
+ } else {
+ textNode.appendData(addElt);
+ }
+ }
+}
+
+function appendSpansFromArray(textArray)
+{
+ for (var i = 0; ; ++i) {
+ theElement = document.getElementById("set" + i);
+ if (!theElement) {
+ break;
+ }
+ for (var j = 0; j < textArray.length; ++j) {
+ // fake the result for elements that can't have markup content
+ if (theElement.tagName == "INPUT") {
+ theElement.value += textArray[j];
+ } else if (theElement.tagName == "TEXTAREA") {
+ theElement.innerHTML += textArray[j];
+ } else {
+ var span = document.createElement("span");
+ span.innerHTML = textArray[j];
+ theElement.appendChild(span);
+ }
+ }
+ }
+}
+
+function prependTextFromArray(textArray)
+{
+ for (var i = 0; ; ++i) {
+ theElement = document.getElementById("set" + i);
+ if (!theElement) {
+ break;
+ }
+ for (var j = 0; j < textArray.length; ++j) {
+ if (theElement.tagName == "INPUT") {
+ theElement.value = textArray[j] + theElement.value;
+ } else {
+ var textNode = document.createTextNode(textArray[j]);
+ theElement.insertBefore(textNode, theElement.firstChild);
+ }
+ }
+ }
+}
+
+function prependSpansFromArray(textArray)
+{
+ for (var i = 0; ; ++i) {
+ theElement = document.getElementById("set" + i);
+ if (!theElement) {
+ break;
+ }
+ for (var j = 0; j < textArray.length; ++j) {
+ // fake the result for elements that can't have markup content
+ if (theElement.tagName == "INPUT") {
+ theElement.value = textArray[j] + theElement.value;
+ } else if (theElement.tagName == "TEXTAREA") {
+ theElement.innerHTML = textArray[j] + theElement.innerHTML;
+ } else {
+ var span = document.createElement("span");
+ span.innerHTML = textArray[j];
+ theElement.insertBefore(span, theElement.firstChild);
+ }
+ }
+ }
+}
+
+function removeElements()
+{
+ for (var i = 0; ; ++i) {
+ theElement = document.getElementById("set" + i);
+ if (!theElement) {
+ break;
+ }
+ theElement.parentNode.removeChild(theElement);
+ }
+}
diff --git a/layout/reftests/bidi/logicalmarquee.html b/layout/reftests/bidi/logicalmarquee.html
new file mode 100644
index 000000000..cb13827de
--- /dev/null
+++ b/layout/reftests/bidi/logicalmarquee.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=iso-8859-8-i">
+ <title>Marquee in Logical Hebrew</title>
+ </head>
+
+ <body>
+ <marquee scrollamount="0" behavior="alternate" direction="right">&#x05E2;&#x05D3; &#x05E9;&#x05D9;&#x05E4;&#x05D5;&#x05D7; &#x05D4;&#x05D9;&#x05D5;&#x05DD; &#x05D5;&#x05E0;&#x05E1;&#x05D5; &#x05D4;&#x05E6;&#x05DC;&#x05D9;&#x05DC;&#x05D9;&#x05DD;</marquee>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/marquee-ref.html b/layout/reftests/bidi/marquee-ref.html
new file mode 100644
index 000000000..d8778dc88
--- /dev/null
+++ b/layout/reftests/bidi/marquee-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=iso-8859-8-i">
+ <title>Marquee in Logical Hebrew</title>
+ </head>
+
+ <body>
+ <div dir="rtl" align="left">&#x05E2;&#x05D3; &#x05E9;&#x05D9;&#x05E4;&#x05D5;&#x05D7; &#x05D4;&#x05D9;&#x05D5;&#x05DD; &#x05D5;&#x05E0;&#x05E1;&#x05D5; &#x05D4;&#x05E6;&#x05DC;&#x05D9;&#x05DC;&#x05D9;&#x05DD;</div>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/mirroring-01-ref.html b/layout/reftests/bidi/mirroring-01-ref.html
new file mode 100644
index 000000000..a422e6632
--- /dev/null
+++ b/layout/reftests/bidi/mirroring-01-ref.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+</head>
+<body>
+ <!-- some paired chars that should mirror in RTL text -->
+ <p>c(b)a</p>
+ <p>c[b]a</p>
+ <p>c{b}a</p>
+ <p>c&lt;b&gt;a</p>
+</body>
+</html>
diff --git a/layout/reftests/bidi/mirroring-01.html b/layout/reftests/bidi/mirroring-01.html
new file mode 100644
index 000000000..0ed363ddf
--- /dev/null
+++ b/layout/reftests/bidi/mirroring-01.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+ p {
+ unicode-bidi:bidi-override;
+ direction:rtl;
+ text-align:left;
+ }
+ </style>
+</head>
+<body>
+ <!-- some paired chars that should mirror in RTL text -->
+ <p>a(b)c</p>
+ <p>a[b]c</p>
+ <p>a{b}c</p>
+ <p>a&lt;b&gt;c</p>
+</body>
+</html>
diff --git a/layout/reftests/bidi/mirroring-02-ref.html b/layout/reftests/bidi/mirroring-02-ref.html
new file mode 100644
index 000000000..ae4bef094
--- /dev/null
+++ b/layout/reftests/bidi/mirroring-02-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+</head>
+<body>
+ <!-- some chars that should NOT mirror... -->
+ <p>c&#x2019;b&#x2018;a</p>
+ <p>c&#x201d;b&#x201c;a</p>
+</body>
+</html>
diff --git a/layout/reftests/bidi/mirroring-02.html b/layout/reftests/bidi/mirroring-02.html
new file mode 100644
index 000000000..2706b2f29
--- /dev/null
+++ b/layout/reftests/bidi/mirroring-02.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+ p {
+ unicode-bidi:bidi-override;
+ direction:rtl;
+ text-align:left;
+ }
+ </style>
+</head>
+<body>
+ <!-- some chars that should NOT mirror... -->
+ <p>a&#x2018;b&#x2019;c</p>
+ <p>a&#x201c;b&#x201d;c</p>
+</body>
+</html>
diff --git a/layout/reftests/bidi/mirroring-03-ref.html b/layout/reftests/bidi/mirroring-03-ref.html
new file mode 100644
index 000000000..24bb1ec73
--- /dev/null
+++ b/layout/reftests/bidi/mirroring-03-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<title>Test for mirroring parentheses in Hebrew text</title>
+</head>
+<body>
+<p dir="rtl"><span style="unicode-bidi:bidi-override; direction:ltr;">&#x05d2;(&#x05d1;)&#x05d0;</span></p>
+</body>
+</html>
+
diff --git a/layout/reftests/bidi/mirroring-03.html b/layout/reftests/bidi/mirroring-03.html
new file mode 100644
index 000000000..8380ddc03
--- /dev/null
+++ b/layout/reftests/bidi/mirroring-03.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<title>Test for mirroring parentheses in Hebrew text</title>
+</head>
+<body>
+<p dir="rtl">&#x05d0;(&#x05d1;)&#x05d2;</p>
+</body>
+</html>
+
diff --git a/layout/reftests/bidi/mixedChartype-00-j.html b/layout/reftests/bidi/mixedChartype-00-j.html
new file mode 100644
index 000000000..7cf8629b9
--- /dev/null
+++ b/layout/reftests/bidi/mixedChartype-00-j.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<!-- Mixed chartype reftest 00: English - Hebrew -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+ text-align: justify;
+}
+ </style>
+ </head>
+ <body>
+ <p><span style="direction: ltr; unicode-bidi: bidi-override">Hello &#x5DD;&#x5DC;&#x5D5;&#x5E2;</span></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/mixedChartype-00-ref.html b/layout/reftests/bidi/mixedChartype-00-ref.html
new file mode 100644
index 000000000..ace2a53b1
--- /dev/null
+++ b/layout/reftests/bidi/mixedChartype-00-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!-- Mixed chartype reftest 00: English - Hebrew -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+}
+ </style>
+ </head>
+ <body>
+ <p>Hello &#x5E2;&#x5D5;&#x5DC;&#x5DD;</span></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/mixedChartype-00.html b/layout/reftests/bidi/mixedChartype-00.html
new file mode 100644
index 000000000..a1e2ca406
--- /dev/null
+++ b/layout/reftests/bidi/mixedChartype-00.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!-- Mixed chartype reftest 00: English - Hebrew -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body {
+ font-family: serif;
+ font-size: 24px;
+}
+ </style>
+ </head>
+ <body>
+ <p><span style="direction: ltr; unicode-bidi: bidi-override">Hello &#x5DD;&#x5DC;&#x5D5;&#x5E2;</span></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/mixedChartype-01-j.html b/layout/reftests/bidi/mixedChartype-01-j.html
new file mode 100644
index 000000000..f350d1f43
--- /dev/null
+++ b/layout/reftests/bidi/mixedChartype-01-j.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!-- Mixed chartype reftest 01: Hebrew - English -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body {
+ font-family: monospace;
+ font-size: 24px;
+}
+ </style>
+ </head>
+ <body>
+ <p><span style="direction: rtl; unicode-bidi: bidi-override">&#x5E9;&#x5DC;&#x5D5;&#x5DD; dlroW</span></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/mixedChartype-01-ref.html b/layout/reftests/bidi/mixedChartype-01-ref.html
new file mode 100644
index 000000000..0182f551b
--- /dev/null
+++ b/layout/reftests/bidi/mixedChartype-01-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!-- Mixed chartype reftest 01: Hebrew - English -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body {
+ font-family: monospace;
+ font-size: 24px;
+}
+ </style>
+ </head>
+ <body>
+ <p><span>World &#x5E9;&#x5DC;&#x5D5;&#x5DD;</span></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/mixedChartype-01.html b/layout/reftests/bidi/mixedChartype-01.html
new file mode 100644
index 000000000..f350d1f43
--- /dev/null
+++ b/layout/reftests/bidi/mixedChartype-01.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!-- Mixed chartype reftest 01: Hebrew - English -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body {
+ font-family: monospace;
+ font-size: 24px;
+}
+ </style>
+ </head>
+ <body>
+ <p><span style="direction: rtl; unicode-bidi: bidi-override">&#x5E9;&#x5DC;&#x5D5;&#x5DD; dlroW</span></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/mixedChartype-02-j.html b/layout/reftests/bidi/mixedChartype-02-j.html
new file mode 100644
index 000000000..d26fca251
--- /dev/null
+++ b/layout/reftests/bidi/mixedChartype-02-j.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<!-- Mixed chartype reftest 02: English - Arabic -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body { /* for Mac OS X with Core Text, we need to ensure an AAT (not OpenType)
+ font is used for the Arabic, as CT doesn't shape LTR-override Arabic
+ correctly (rdar://7231250 */
+ font-family: Geeza Pro, serif;
+ font-size: 24px;
+ text-align: justify;
+}
+ </style>
+ </head>
+ <body>
+ <p><span style="direction: ltr; unicode-bidi: bidi-override">Hello &#x629;&#x64A;&#x646;&#x648;&#x62F</span></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/mixedChartype-02-ref.html b/layout/reftests/bidi/mixedChartype-02-ref.html
new file mode 100644
index 000000000..b2edd771f
--- /dev/null
+++ b/layout/reftests/bidi/mixedChartype-02-ref.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<!-- Mixed chartype reftest 02: English - Arabic -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body { /* for Mac OS X with Core Text, we need to ensure an AAT (not OpenType)
+ font is used for the Arabic, as CT doesn't shape LTR-override Arabic
+ correctly (rdar://7231250 */
+ font-family: Geeza Pro, serif;
+ font-size: 24px;
+}
+ </style>
+ </head>
+ <body>
+ <p><span>Hello &#x62F;&#x648;&#x646;&#x64A;&#x629;</span></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/mixedChartype-02.html b/layout/reftests/bidi/mixedChartype-02.html
new file mode 100644
index 000000000..1bbb1e6fc
--- /dev/null
+++ b/layout/reftests/bidi/mixedChartype-02.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<!-- Mixed chartype reftest 02: English - Arabic -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body { /* for Mac OS X with Core Text, we need to ensure an AAT (not OpenType)
+ font is used for the Arabic, as CT doesn't shape LTR-override Arabic
+ correctly (rdar://7231250 */
+ font-family: Geeza Pro, serif;
+ font-size: 24px;
+}
+ </style>
+ </head>
+ <body>
+ <p><span style="direction: ltr; unicode-bidi: bidi-override">Hello &#x629;&#x64A;&#x646;&#x648;&#x62F</span></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/mixedChartype-03-j.html b/layout/reftests/bidi/mixedChartype-03-j.html
new file mode 100644
index 000000000..2d8c25b7f
--- /dev/null
+++ b/layout/reftests/bidi/mixedChartype-03-j.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<!-- Mixed chartype reftest 03: Arabic - English -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body {
+ font-family: monospace;
+ font-size: 24px;
+ text-align: justify;
+}
+ </style>
+ </head>
+ <body>
+ <p><span style="direction: rtl; unicode-bidi: bidi-override">&#x633;&#x644;&#x645;&#x627;&#x62A; dlroW</span></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/mixedChartype-03-ref.html b/layout/reftests/bidi/mixedChartype-03-ref.html
new file mode 100644
index 000000000..16231b753
--- /dev/null
+++ b/layout/reftests/bidi/mixedChartype-03-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!-- Mixed chartype reftest 03: Arabic - English -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body {
+ font-family: monospace;
+ font-size: 24px;
+}
+ </style>
+ </head>
+ <body>
+ <p><span>World &#x633;&#x644;&#x645;&#x627;&#x62A;</span></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/mixedChartype-03.html b/layout/reftests/bidi/mixedChartype-03.html
new file mode 100644
index 000000000..819a37d18
--- /dev/null
+++ b/layout/reftests/bidi/mixedChartype-03.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!-- Mixed chartype reftest 03: Arabic - English -->
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <style type="text/css">
+body {
+ font-family: monospace;
+ font-size: 24px;
+}
+ </style>
+ </head>
+ <body>
+ <p><span style="direction: rtl; unicode-bidi: bidi-override">&#x633;&#x644;&#x645;&#x627;&#x62A; dlroW</span></p>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/numeral/arabic-1-ref.html b/layout/reftests/bidi/numeral/arabic-1-ref.html
new file mode 100644
index 000000000..8bc1ea499
--- /dev/null
+++ b/layout/reftests/bidi/numeral/arabic-1-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="٠١٢">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/arabic-1.html b/layout/reftests/bidi/numeral/arabic-1.html
new file mode 100644
index 000000000..b9f8deb74
--- /dev/null
+++ b/layout/reftests/bidi/numeral/arabic-1.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="012">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/arabic-2-ref.html b/layout/reftests/bidi/numeral/arabic-2-ref.html
new file mode 100644
index 000000000..3a17736c1
--- /dev/null
+++ b/layout/reftests/bidi/numeral/arabic-2-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="متن١٢٣">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/arabic-2.html b/layout/reftests/bidi/numeral/arabic-2.html
new file mode 100644
index 000000000..7e8f727e6
--- /dev/null
+++ b/layout/reftests/bidi/numeral/arabic-2.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="متن123">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/arabic-3-ref.html b/layout/reftests/bidi/numeral/arabic-3-ref.html
new file mode 100644
index 000000000..5b43f2c27
--- /dev/null
+++ b/layout/reftests/bidi/numeral/arabic-3-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="text٢٣٤">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/arabic-3.html b/layout/reftests/bidi/numeral/arabic-3.html
new file mode 100644
index 000000000..fd77ee5f2
--- /dev/null
+++ b/layout/reftests/bidi/numeral/arabic-3.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="text234">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/arabic-4-ref.html b/layout/reftests/bidi/numeral/arabic-4-ref.html
new file mode 100644
index 000000000..84f7ec8fe
--- /dev/null
+++ b/layout/reftests/bidi/numeral/arabic-4-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="متن ٣٤٥">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/arabic-4.html b/layout/reftests/bidi/numeral/arabic-4.html
new file mode 100644
index 000000000..7206833f0
--- /dev/null
+++ b/layout/reftests/bidi/numeral/arabic-4.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="متن 345">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/arabic-5-ref.html b/layout/reftests/bidi/numeral/arabic-5-ref.html
new file mode 100644
index 000000000..03b58b702
--- /dev/null
+++ b/layout/reftests/bidi/numeral/arabic-5-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="text ٤٥٦">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/arabic-5.html b/layout/reftests/bidi/numeral/arabic-5.html
new file mode 100644
index 000000000..cb6621943
--- /dev/null
+++ b/layout/reftests/bidi/numeral/arabic-5.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="text 456">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/bug441782-1-ref.html b/layout/reftests/bidi/numeral/bug441782-1-ref.html
new file mode 100644
index 000000000..b896333c8
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug441782-1-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+٠١٢
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug441782-1.html b/layout/reftests/bidi/numeral/bug441782-1.html
new file mode 100644
index 000000000..db145ddba
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug441782-1.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+012
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug441782-2-ref.html b/layout/reftests/bidi/numeral/bug441782-2-ref.html
new file mode 100644
index 000000000..81ad71e2f
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug441782-2-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+متن١٢٣
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug441782-2.html b/layout/reftests/bidi/numeral/bug441782-2.html
new file mode 100644
index 000000000..9a81969a3
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug441782-2.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+متن123
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug441782-3-ref.html b/layout/reftests/bidi/numeral/bug441782-3-ref.html
new file mode 100644
index 000000000..0bfdbd9a9
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug441782-3-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+text٢٣٤
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug441782-3.html b/layout/reftests/bidi/numeral/bug441782-3.html
new file mode 100644
index 000000000..01408d082
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug441782-3.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+text234
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug441782-4-ref.html b/layout/reftests/bidi/numeral/bug441782-4-ref.html
new file mode 100644
index 000000000..5cc53dd11
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug441782-4-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+متن ٣٤٥
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug441782-4.html b/layout/reftests/bidi/numeral/bug441782-4.html
new file mode 100644
index 000000000..1437d291d
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug441782-4.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+متن 345
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug441782-5-ref.html b/layout/reftests/bidi/numeral/bug441782-5-ref.html
new file mode 100644
index 000000000..d1855ca8d
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug441782-5-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+text ٤٥٦
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug441782-5.html b/layout/reftests/bidi/numeral/bug441782-5.html
new file mode 100644
index 000000000..2b6b7cea1
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug441782-5.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+text 456
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug467672-1-ref.html b/layout/reftests/bidi/numeral/bug467672-1-ref.html
new file mode 100644
index 000000000..5d7965a34
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug467672-1-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+۳۴۵
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug467672-1.html b/layout/reftests/bidi/numeral/bug467672-1.html
new file mode 100644
index 000000000..1e572bd99
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug467672-1.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+345
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug467672-2-ref.html b/layout/reftests/bidi/numeral/bug467672-2-ref.html
new file mode 100644
index 000000000..2a73b8a25
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug467672-2-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+متن۳۴۵
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug467672-2.html b/layout/reftests/bidi/numeral/bug467672-2.html
new file mode 100644
index 000000000..0ffdb981c
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug467672-2.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+متن345
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug467672-3-ref.html b/layout/reftests/bidi/numeral/bug467672-3-ref.html
new file mode 100644
index 000000000..47e534b0b
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug467672-3-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+text۳۴۵
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug467672-3.html b/layout/reftests/bidi/numeral/bug467672-3.html
new file mode 100644
index 000000000..60e2e71db
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug467672-3.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+text345
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug467672-4-ref.html b/layout/reftests/bidi/numeral/bug467672-4-ref.html
new file mode 100644
index 000000000..3842dd5af
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug467672-4-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+متن ۳۴۵
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug467672-4.html b/layout/reftests/bidi/numeral/bug467672-4.html
new file mode 100644
index 000000000..1437d291d
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug467672-4.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+متن 345
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug467672-5-ref.html b/layout/reftests/bidi/numeral/bug467672-5-ref.html
new file mode 100644
index 000000000..0144f9422
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug467672-5-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+text ۳۴۵
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/bug467672-5.html b/layout/reftests/bidi/numeral/bug467672-5.html
new file mode 100644
index 000000000..9dbad10bc
--- /dev/null
+++ b/layout/reftests/bidi/numeral/bug467672-5.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+text 345
+</body>
+</html> \ No newline at end of file
diff --git a/layout/reftests/bidi/numeral/persian-1-ref.html b/layout/reftests/bidi/numeral/persian-1-ref.html
new file mode 100644
index 000000000..d12001f56
--- /dev/null
+++ b/layout/reftests/bidi/numeral/persian-1-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="۳۴۵">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/persian-1.html b/layout/reftests/bidi/numeral/persian-1.html
new file mode 100644
index 000000000..a8185022c
--- /dev/null
+++ b/layout/reftests/bidi/numeral/persian-1.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="345">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/persian-2-ref.html b/layout/reftests/bidi/numeral/persian-2-ref.html
new file mode 100644
index 000000000..ce738adfa
--- /dev/null
+++ b/layout/reftests/bidi/numeral/persian-2-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="متن۳۴۵">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/persian-2.html b/layout/reftests/bidi/numeral/persian-2.html
new file mode 100644
index 000000000..96e53d87c
--- /dev/null
+++ b/layout/reftests/bidi/numeral/persian-2.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="متن345">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/persian-3-ref.html b/layout/reftests/bidi/numeral/persian-3-ref.html
new file mode 100644
index 000000000..87018752d
--- /dev/null
+++ b/layout/reftests/bidi/numeral/persian-3-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="text۳۴۵">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/persian-3.html b/layout/reftests/bidi/numeral/persian-3.html
new file mode 100644
index 000000000..9546ed242
--- /dev/null
+++ b/layout/reftests/bidi/numeral/persian-3.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="text345">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/persian-4-ref.html b/layout/reftests/bidi/numeral/persian-4-ref.html
new file mode 100644
index 000000000..5ef1c2a8e
--- /dev/null
+++ b/layout/reftests/bidi/numeral/persian-4-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="متن ۳۴۵">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/persian-4.html b/layout/reftests/bidi/numeral/persian-4.html
new file mode 100644
index 000000000..7206833f0
--- /dev/null
+++ b/layout/reftests/bidi/numeral/persian-4.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="متن 345">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/persian-5-ref.html b/layout/reftests/bidi/numeral/persian-5-ref.html
new file mode 100644
index 000000000..1e368e406
--- /dev/null
+++ b/layout/reftests/bidi/numeral/persian-5-ref.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="text ۳۴۵">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/persian-5.html b/layout/reftests/bidi/numeral/persian-5.html
new file mode 100644
index 000000000..3e29ae7d3
--- /dev/null
+++ b/layout/reftests/bidi/numeral/persian-5.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <img src="youwontfindme.png" width="100" height="50" alt="text 345">
+</body>
+</html>
diff --git a/layout/reftests/bidi/numeral/reftest-stylo.list b/layout/reftests/bidi/numeral/reftest-stylo.list
new file mode 100644
index 000000000..b3cf247da
--- /dev/null
+++ b/layout/reftests/bidi/numeral/reftest-stylo.list
@@ -0,0 +1,121 @@
+# DO NOT EDIT! This is a auto-generated temporary list for Stylo testing
+pref(bidi.numeral,0) == arabic-1.html arabic-1.html
+pref(bidi.numeral,1) == arabic-1.html arabic-1.html
+pref(bidi.numeral,2) == arabic-1.html arabic-1.html
+pref(bidi.numeral,3) == arabic-1.html arabic-1.html
+pref(bidi.numeral,4) == arabic-1.html arabic-1.html
+skip pref(bidi.numeral,0) == arabic-2.html arabic-2.html
+skip pref(bidi.numeral,1) == arabic-2.html arabic-2.html
+skip pref(bidi.numeral,2) == arabic-2.html arabic-2.html
+skip pref(bidi.numeral,3) == arabic-2.html arabic-2.html
+skip pref(bidi.numeral,4) == arabic-2.html arabic-2.html
+pref(bidi.numeral,0) == arabic-3.html arabic-3.html
+pref(bidi.numeral,1) == arabic-3.html arabic-3.html
+pref(bidi.numeral,2) == arabic-3.html arabic-3.html
+pref(bidi.numeral,3) == arabic-3.html arabic-3.html
+pref(bidi.numeral,4) == arabic-3.html arabic-3.html
+pref(bidi.numeral,0) == arabic-4.html arabic-4.html
+pref(bidi.numeral,1) == arabic-4.html arabic-4.html
+pref(bidi.numeral,2) == arabic-4.html arabic-4.html
+pref(bidi.numeral,3) == arabic-4.html arabic-4.html
+pref(bidi.numeral,4) == arabic-4.html arabic-4.html
+pref(bidi.numeral,0) == arabic-5.html arabic-5.html
+pref(bidi.numeral,1) == arabic-5.html arabic-5.html
+pref(bidi.numeral,2) == arabic-5.html arabic-5.html
+pref(bidi.numeral,3) == arabic-5.html arabic-5.html
+pref(bidi.numeral,4) == arabic-5.html arabic-5.html
+pref(bidi.numeral,0) == bug441782-1.html bug441782-1.html
+pref(bidi.numeral,1) == bug441782-1.html bug441782-1.html
+pref(bidi.numeral,2) == bug441782-1.html bug441782-1.html
+pref(bidi.numeral,3) == bug441782-1.html bug441782-1.html
+pref(bidi.numeral,4) == bug441782-1.html bug441782-1.html
+pref(bidi.numeral,0) == bug441782-2.html bug441782-2.html
+pref(bidi.numeral,1) == bug441782-2.html bug441782-2.html
+pref(bidi.numeral,2) == bug441782-2.html bug441782-2.html
+pref(bidi.numeral,3) == bug441782-2.html bug441782-2.html
+pref(bidi.numeral,4) == bug441782-2.html bug441782-2.html
+pref(bidi.numeral,0) == bug441782-3.html bug441782-3.html
+fails-if(winWidget&&!layersGPUAccelerated&&!(/^Windows\x20NT\x205\.1/.test(http.oscpu))&&!skiaContent) fuzzy-if(winWidget&&!d2d&&d3d11,13,1) pref(bidi.numeral,1) == bug441782-3.html bug441782-3.html
+fails-if(winWidget&&!layersGPUAccelerated&&!(/^Windows\x20NT\x205\.1/.test(http.oscpu))&&!skiaContent) fuzzy-if(winWidget&&!d2d&&d3d11,13,1) pref(bidi.numeral,2) == bug441782-3.html bug441782-3.html
+fails-if(winWidget&&!layersGPUAccelerated&&!(/^Windows\x20NT\x205\.1/.test(http.oscpu))&&!skiaContent) fuzzy-if(winWidget&&!d2d&&d3d11,13,1) pref(bidi.numeral,3) == bug441782-3.html bug441782-3.html
+pref(bidi.numeral,4) == bug441782-3.html bug441782-3.html
+pref(bidi.numeral,0) == bug441782-4.html bug441782-4.html
+pref(bidi.numeral,1) == bug441782-4.html bug441782-4.html
+pref(bidi.numeral,2) == bug441782-4.html bug441782-4.html
+pref(bidi.numeral,3) == bug441782-4.html bug441782-4.html
+pref(bidi.numeral,4) == bug441782-4.html bug441782-4.html
+pref(bidi.numeral,0) == bug441782-5.html bug441782-5.html
+pref(bidi.numeral,1) == bug441782-5.html bug441782-5.html
+pref(bidi.numeral,2) == bug441782-5.html bug441782-5.html
+pref(bidi.numeral,3) == bug441782-5.html bug441782-5.html
+pref(bidi.numeral,4) == bug441782-5.html bug441782-5.html
+pref(bidi.numeral,0) == bug467672-1.html bug467672-1.html
+pref(bidi.numeral,1) == bug467672-1.html bug467672-1.html
+pref(bidi.numeral,2) == bug467672-1.html bug467672-1.html
+pref(bidi.numeral,3) == bug467672-1.html bug467672-1.html
+pref(bidi.numeral,4) == bug467672-1.html bug467672-1.html
+pref(bidi.numeral,5) == bug467672-1.html bug467672-1.html
+pref(bidi.numeral,6) == bug467672-1.html bug467672-1.html
+pref(bidi.numeral,0) == bug467672-2.html bug467672-2.html
+pref(bidi.numeral,1) == bug467672-2.html bug467672-2.html
+pref(bidi.numeral,2) == bug467672-2.html bug467672-2.html
+pref(bidi.numeral,3) == bug467672-2.html bug467672-2.html
+pref(bidi.numeral,4) == bug467672-2.html bug467672-2.html
+pref(bidi.numeral,5) == bug467672-2.html bug467672-2.html
+pref(bidi.numeral,6) == bug467672-2.html bug467672-2.html
+pref(bidi.numeral,0) == bug467672-3.html bug467672-3.html
+pref(bidi.numeral,1) == bug467672-3.html bug467672-3.html
+pref(bidi.numeral,2) == bug467672-3.html bug467672-3.html
+pref(bidi.numeral,3) == bug467672-3.html bug467672-3.html
+pref(bidi.numeral,4) == bug467672-3.html bug467672-3.html
+pref(bidi.numeral,5) == bug467672-3.html bug467672-3.html
+pref(bidi.numeral,6) == bug467672-3.html bug467672-3.html
+pref(bidi.numeral,0) == bug467672-4.html bug467672-4.html
+pref(bidi.numeral,1) == bug467672-4.html bug467672-4.html
+pref(bidi.numeral,2) == bug467672-4.html bug467672-4.html
+pref(bidi.numeral,3) == bug467672-4.html bug467672-4.html
+pref(bidi.numeral,4) == bug467672-4.html bug467672-4.html
+pref(bidi.numeral,5) == bug467672-4.html bug467672-4.html
+pref(bidi.numeral,6) == bug467672-4.html bug467672-4.html
+pref(bidi.numeral,0) == bug467672-5.html bug467672-5.html
+pref(bidi.numeral,1) == bug467672-5.html bug467672-5.html
+pref(bidi.numeral,2) == bug467672-5.html bug467672-5.html
+pref(bidi.numeral,3) == bug467672-5.html bug467672-5.html
+pref(bidi.numeral,4) == bug467672-5.html bug467672-5.html
+pref(bidi.numeral,5) == bug467672-5.html bug467672-5.html
+pref(bidi.numeral,6) == bug467672-5.html bug467672-5.html
+pref(bidi.numeral,0) == persian-1.html persian-1.html
+pref(bidi.numeral,1) == persian-1.html persian-1.html
+pref(bidi.numeral,2) == persian-1.html persian-1.html
+pref(bidi.numeral,3) == persian-1.html persian-1.html
+pref(bidi.numeral,4) == persian-1.html persian-1.html
+pref(bidi.numeral,5) == persian-1.html persian-1.html
+pref(bidi.numeral,6) == persian-1.html persian-1.html
+skip pref(bidi.numeral,0) == persian-2.html persian-2.html
+skip pref(bidi.numeral,1) == persian-2.html persian-2.html
+skip pref(bidi.numeral,2) == persian-2.html persian-2.html
+skip pref(bidi.numeral,3) == persian-2.html persian-2.html
+skip pref(bidi.numeral,4) == persian-2.html persian-2.html
+skip pref(bidi.numeral,5) == persian-2.html persian-2.html
+skip pref(bidi.numeral,6) == persian-2.html persian-2.html
+pref(bidi.numeral,0) == persian-3.html persian-3.html
+pref(bidi.numeral,1) == persian-3.html persian-3.html
+pref(bidi.numeral,2) == persian-3.html persian-3.html
+pref(bidi.numeral,3) == persian-3.html persian-3.html
+pref(bidi.numeral,4) == persian-3.html persian-3.html
+pref(bidi.numeral,5) == persian-3.html persian-3.html
+pref(bidi.numeral,6) == persian-3.html persian-3.html
+pref(bidi.numeral,0) == persian-4.html persian-4.html
+pref(bidi.numeral,1) == persian-4.html persian-4.html
+pref(bidi.numeral,2) == persian-4.html persian-4.html
+pref(bidi.numeral,3) == persian-4.html persian-4.html
+pref(bidi.numeral,4) == persian-4.html persian-4.html
+pref(bidi.numeral,5) == persian-4.html persian-4.html
+pref(bidi.numeral,6) == persian-4.html persian-4.html
+pref(bidi.numeral,0) == persian-5.html persian-5.html
+pref(bidi.numeral,1) == persian-5.html persian-5.html
+pref(bidi.numeral,2) == persian-5.html persian-5.html
+pref(bidi.numeral,3) == persian-5.html persian-5.html
+pref(bidi.numeral,4) == persian-5.html persian-5.html
+pref(bidi.numeral,5) == persian-5.html persian-5.html
+pref(bidi.numeral,6) == persian-5.html persian-5.html
diff --git a/layout/reftests/bidi/numeral/reftest.list b/layout/reftests/bidi/numeral/reftest.list
new file mode 100644
index 000000000..2863ae0b7
--- /dev/null
+++ b/layout/reftests/bidi/numeral/reftest.list
@@ -0,0 +1,120 @@
+pref(bidi.numeral,0) != arabic-1.html arabic-1-ref.html
+pref(bidi.numeral,1) == arabic-1.html arabic-1-ref.html
+pref(bidi.numeral,2) == arabic-1.html arabic-1-ref.html
+pref(bidi.numeral,3) == arabic-1.html arabic-1-ref.html
+pref(bidi.numeral,4) == arabic-1.html arabic-1-ref.html
+pref(bidi.numeral,0) != arabic-2.html arabic-2-ref.html
+pref(bidi.numeral,1) == arabic-2.html arabic-2-ref.html
+pref(bidi.numeral,2) == arabic-2.html arabic-2-ref.html
+pref(bidi.numeral,3) == arabic-2.html arabic-2-ref.html
+pref(bidi.numeral,4) == arabic-2.html arabic-2-ref.html
+pref(bidi.numeral,0) != arabic-3.html arabic-3-ref.html
+pref(bidi.numeral,1) == arabic-3.html arabic-3-ref.html
+pref(bidi.numeral,2) == arabic-3.html arabic-3-ref.html
+pref(bidi.numeral,3) == arabic-3.html arabic-3-ref.html
+pref(bidi.numeral,4) == arabic-3.html arabic-3-ref.html
+pref(bidi.numeral,0) != arabic-4.html arabic-4-ref.html
+pref(bidi.numeral,1) == arabic-4.html arabic-4-ref.html
+pref(bidi.numeral,2) == arabic-4.html arabic-4-ref.html
+pref(bidi.numeral,3) == arabic-4.html arabic-4-ref.html
+pref(bidi.numeral,4) == arabic-4.html arabic-4-ref.html
+pref(bidi.numeral,0) != arabic-5.html arabic-5-ref.html
+pref(bidi.numeral,1) == arabic-5.html arabic-5-ref.html
+pref(bidi.numeral,2) == arabic-5.html arabic-5-ref.html
+pref(bidi.numeral,3) == arabic-5.html arabic-5-ref.html
+pref(bidi.numeral,4) == arabic-5.html arabic-5-ref.html
+pref(bidi.numeral,0) != bug441782-1.html bug441782-1-ref.html
+pref(bidi.numeral,1) == bug441782-1.html bug441782-1-ref.html
+pref(bidi.numeral,2) == bug441782-1.html bug441782-1-ref.html
+pref(bidi.numeral,3) == bug441782-1.html bug441782-1-ref.html
+pref(bidi.numeral,4) == bug441782-1.html bug441782-1-ref.html
+pref(bidi.numeral,0) != bug441782-2.html bug441782-2-ref.html
+pref(bidi.numeral,1) == bug441782-2.html bug441782-2-ref.html
+pref(bidi.numeral,2) == bug441782-2.html bug441782-2-ref.html
+pref(bidi.numeral,3) == bug441782-2.html bug441782-2-ref.html
+pref(bidi.numeral,4) == bug441782-2.html bug441782-2-ref.html
+pref(bidi.numeral,0) != bug441782-3.html bug441782-3-ref.html
+fails-if(winWidget&&!layersGPUAccelerated&&!(/^Windows\x20NT\x205\.1/.test(http.oscpu))&&!skiaContent) fuzzy-if(winWidget&&!d2d&&d3d11,13,1) pref(bidi.numeral,1) == bug441782-3.html bug441782-3-ref.html
+fails-if(winWidget&&!layersGPUAccelerated&&!(/^Windows\x20NT\x205\.1/.test(http.oscpu))&&!skiaContent) fuzzy-if(winWidget&&!d2d&&d3d11,13,1) pref(bidi.numeral,2) == bug441782-3.html bug441782-3-ref.html
+fails-if(winWidget&&!layersGPUAccelerated&&!(/^Windows\x20NT\x205\.1/.test(http.oscpu))&&!skiaContent) fuzzy-if(winWidget&&!d2d&&d3d11,13,1) pref(bidi.numeral,3) == bug441782-3.html bug441782-3-ref.html
+pref(bidi.numeral,4) == bug441782-3.html bug441782-3-ref.html
+pref(bidi.numeral,0) != bug441782-4.html bug441782-4-ref.html
+pref(bidi.numeral,1) == bug441782-4.html bug441782-4-ref.html
+pref(bidi.numeral,2) == bug441782-4.html bug441782-4-ref.html
+pref(bidi.numeral,3) == bug441782-4.html bug441782-4-ref.html
+pref(bidi.numeral,4) == bug441782-4.html bug441782-4-ref.html
+pref(bidi.numeral,0) != bug441782-5.html bug441782-5-ref.html
+pref(bidi.numeral,1) == bug441782-5.html bug441782-5-ref.html
+pref(bidi.numeral,2) == bug441782-5.html bug441782-5-ref.html
+pref(bidi.numeral,3) == bug441782-5.html bug441782-5-ref.html
+pref(bidi.numeral,4) == bug441782-5.html bug441782-5-ref.html
+pref(bidi.numeral,0) != bug467672-1.html bug467672-1-ref.html
+pref(bidi.numeral,1) == bug467672-1.html bug467672-1-ref.html
+pref(bidi.numeral,2) == bug467672-1.html bug467672-1-ref.html
+pref(bidi.numeral,3) == bug467672-1.html bug467672-1-ref.html
+pref(bidi.numeral,4) == bug467672-1.html bug467672-1-ref.html
+pref(bidi.numeral,5) == bug467672-1.html bug467672-1-ref.html
+pref(bidi.numeral,6) == bug467672-1.html bug467672-1-ref.html
+pref(bidi.numeral,0) != bug467672-2.html bug467672-2-ref.html
+pref(bidi.numeral,1) == bug467672-2.html bug467672-2-ref.html
+pref(bidi.numeral,2) == bug467672-2.html bug467672-2-ref.html
+pref(bidi.numeral,3) == bug467672-2.html bug467672-2-ref.html
+pref(bidi.numeral,4) == bug467672-2.html bug467672-2-ref.html
+pref(bidi.numeral,5) == bug467672-2.html bug467672-2-ref.html
+pref(bidi.numeral,6) == bug467672-2.html bug467672-2-ref.html
+pref(bidi.numeral,0) != bug467672-3.html bug467672-3-ref.html
+pref(bidi.numeral,1) == bug467672-3.html bug467672-3-ref.html
+pref(bidi.numeral,2) == bug467672-3.html bug467672-3-ref.html
+pref(bidi.numeral,3) == bug467672-3.html bug467672-3-ref.html
+pref(bidi.numeral,4) == bug467672-3.html bug467672-3-ref.html
+pref(bidi.numeral,5) == bug467672-3.html bug467672-3-ref.html
+pref(bidi.numeral,6) == bug467672-3.html bug467672-3-ref.html
+pref(bidi.numeral,0) != bug467672-4.html bug467672-4-ref.html
+pref(bidi.numeral,1) == bug467672-4.html bug467672-4-ref.html
+pref(bidi.numeral,2) == bug467672-4.html bug467672-4-ref.html
+pref(bidi.numeral,3) == bug467672-4.html bug467672-4-ref.html
+pref(bidi.numeral,4) == bug467672-4.html bug467672-4-ref.html
+pref(bidi.numeral,5) == bug467672-4.html bug467672-4-ref.html
+pref(bidi.numeral,6) == bug467672-4.html bug467672-4-ref.html
+pref(bidi.numeral,0) != bug467672-5.html bug467672-5-ref.html
+pref(bidi.numeral,1) == bug467672-5.html bug467672-5-ref.html
+pref(bidi.numeral,2) == bug467672-5.html bug467672-5-ref.html
+pref(bidi.numeral,3) == bug467672-5.html bug467672-5-ref.html
+pref(bidi.numeral,4) == bug467672-5.html bug467672-5-ref.html
+pref(bidi.numeral,5) == bug467672-5.html bug467672-5-ref.html
+pref(bidi.numeral,6) == bug467672-5.html bug467672-5-ref.html
+pref(bidi.numeral,0) != persian-1.html persian-1-ref.html
+pref(bidi.numeral,1) == persian-1.html persian-1-ref.html
+pref(bidi.numeral,2) == persian-1.html persian-1-ref.html
+pref(bidi.numeral,3) == persian-1.html persian-1-ref.html
+pref(bidi.numeral,4) == persian-1.html persian-1-ref.html
+pref(bidi.numeral,5) == persian-1.html persian-1-ref.html
+pref(bidi.numeral,6) == persian-1.html persian-1-ref.html
+pref(bidi.numeral,0) != persian-2.html persian-2-ref.html
+pref(bidi.numeral,1) == persian-2.html persian-2-ref.html
+pref(bidi.numeral,2) == persian-2.html persian-2-ref.html
+pref(bidi.numeral,3) == persian-2.html persian-2-ref.html
+pref(bidi.numeral,4) == persian-2.html persian-2-ref.html
+pref(bidi.numeral,5) == persian-2.html persian-2-ref.html
+pref(bidi.numeral,6) == persian-2.html persian-2-ref.html
+pref(bidi.numeral,0) != persian-3.html persian-3-ref.html
+pref(bidi.numeral,1) == persian-3.html persian-3-ref.html
+pref(bidi.numeral,2) == persian-3.html persian-3-ref.html
+pref(bidi.numeral,3) == persian-3.html persian-3-ref.html
+pref(bidi.numeral,4) == persian-3.html persian-3-ref.html
+pref(bidi.numeral,5) == persian-3.html persian-3-ref.html
+pref(bidi.numeral,6) == persian-3.html persian-3-ref.html
+pref(bidi.numeral,0) != persian-4.html persian-4-ref.html
+pref(bidi.numeral,1) == persian-4.html persian-4-ref.html
+pref(bidi.numeral,2) == persian-4.html persian-4-ref.html
+pref(bidi.numeral,3) == persian-4.html persian-4-ref.html
+pref(bidi.numeral,4) == persian-4.html persian-4-ref.html
+pref(bidi.numeral,5) == persian-4.html persian-4-ref.html
+pref(bidi.numeral,6) == persian-4.html persian-4-ref.html
+pref(bidi.numeral,0) != persian-5.html persian-5-ref.html
+pref(bidi.numeral,1) == persian-5.html persian-5-ref.html
+pref(bidi.numeral,2) == persian-5.html persian-5-ref.html
+pref(bidi.numeral,3) == persian-5.html persian-5-ref.html
+pref(bidi.numeral,4) == persian-5.html persian-5-ref.html
+pref(bidi.numeral,5) == persian-5.html persian-5-ref.html
+pref(bidi.numeral,6) == persian-5.html persian-5-ref.html
diff --git a/layout/reftests/bidi/reftest-stylo.list b/layout/reftests/bidi/reftest-stylo.list
new file mode 100644
index 000000000..b6a48f9ca
--- /dev/null
+++ b/layout/reftests/bidi/reftest-stylo.list
@@ -0,0 +1,186 @@
+# DO NOT EDIT! This is a auto-generated temporary list for Stylo testing
+include dirAuto/reftest-stylo.list
+include numeral/reftest-stylo.list
+== bdi-element.html bdi-element.html
+== bidi-000.html bidi-000.html
+== bidi-001.html bidi-001.html
+== bidi-001-j.html bidi-001-j.html
+== bidi-001-v.html bidi-001-v.html
+== bidi-002.html bidi-002.html
+== bidi-003.html bidi-003.html
+== bidi-004.html bidi-004.html
+== bidi-004-j.html bidi-004-j.html
+== bidi-005.html bidi-005.html
+random-if(cocoaWidget) == bidi-006.html bidi-006.html
+# bug 734313
+random-if(cocoaWidget) == bidi-006-j.html bidi-006-j.html
+# bug 734313
+== bidiSVG-01.svg bidiSVG-01.svg
+== bidiSVG-02.svg bidiSVG-02.svg
+skip == bidiSVG-03.svg bidiSVG-03.svg
+== bidiSVG-04.svg bidiSVG-04.svg
+== bidiSVG-05.svg bidiSVG-05.svg
+random-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) HTTP(..) == bidiMirroring.svg bidiMirroring.svg
+fuzzy-if(Android,9,134) random-if(layersGPUAccelerated) == visualmarquee.html visualmarquee.html
+fuzzy-if(Android,9,134) random-if(layersGPUAccelerated) == logicalmarquee.html logicalmarquee.html
+== visualmarquee.html visualmarquee.html
+# test for glyph mirroring in right-to-left text
+== mirroring-01.html mirroring-01.html
+# quote marks are not supposed to mirror, but Unicode 5.0 said they should, so some systems do it
+random-if(cocoaWidget) == mirroring-02.html mirroring-02.html
+== mirroring-03.html mirroring-03.html
+== mixedChartype-00.html mixedChartype-00.html
+== mixedChartype-00-j.html mixedChartype-00-j.html
+== mixedChartype-01.html mixedChartype-01.html
+== mixedChartype-01-j.html mixedChartype-01-j.html
+== mixedChartype-02.html mixedChartype-02.html
+== mixedChartype-02-j.html mixedChartype-02-j.html
+== mixedChartype-03.html mixedChartype-03.html
+== mixedChartype-03-j.html mixedChartype-03-j.html
+== unicode-bidi-anonymous-001.html unicode-bidi-anonymous-001.html
+== unicode-bidi-anonymous-002.html unicode-bidi-anonymous-002.html
+== unicode-bidi-isolate-basic.html unicode-bidi-isolate-basic.html
+== unicode-bidi-isolate-aharon.html unicode-bidi-isolate-aharon.html
+fails fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,73,1) fuzzy-if(skiaContent,104,32) == unicode-bidi-plaintext.html unicode-bidi-plaintext.html
+== unicode-bidi-plaintext-textarea-1.html unicode-bidi-plaintext-textarea-1.html
+== unicode-bidi-plaintext-textarea-2.html unicode-bidi-plaintext-textarea-2.html
+== unicode-bidi-plaintext-textarea-3.html unicode-bidi-plaintext-textarea-3.html
+== unicode-bidi-plaintext-textarea-4.html unicode-bidi-plaintext-textarea-4.html
+== with-first-letter-1a.html with-first-letter-1a.html
+== with-first-letter-1b.html with-first-letter-1b.html
+random-if(cocoaWidget) == with-first-letter-2a.html with-first-letter-2a.html
+# bug 734313
+random-if(cocoaWidget) == with-first-letter-2b.html with-first-letter-2b.html
+# bug 734313
+== 83958-1a.html 83958-1a.html
+== 83958-1b.html 83958-1b.html
+== 83958-1c.html 83958-1c.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,111,7) == 83958-2a.html 83958-2a.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,111,7) == 83958-2b.html 83958-2b.html
+== 115921-1.html 115921-1.html
+== 115921-2.html 115921-2.html
+== 151407-1.html 151407-1.html
+== 151407-1a.html 151407-1a.html
+== 151407-2-ltr.html 151407-2-ltr.html
+== 151407-2-rtl.html 151407-2-rtl.html
+== 151407-2-auto.html 151407-2-auto.html
+== 151407-2-empty.html 151407-2-empty.html
+== 151407-2-foopy.html 151407-2-foopy.html
+== 151407-3-ltr.html 151407-3-ltr.html
+== 151407-3-rtl.html 151407-3-rtl.html
+== 151407-3-auto.html 151407-3-auto.html
+== 151407-3-foopy.html 151407-3-foopy.html
+== 229367-1.html 229367-1.html
+== 229367-2.html 229367-2.html
+== 229367-3.html 229367-3.html
+== 258928-1.html 258928-1.html
+== 263359-1.html 263359-1.html
+== 263359-1a.html 263359-1a.html
+== 263359-1b.html 263359-1b.html
+== 263359-2.html 263359-2.html
+== 263359-3.html 263359-3.html
+== 263359-4.html 263359-4.html
+random-if(winWidget) fuzzy-if(skiaContent,1,1700) == 267459-1.html 267459-1.html
+# depends on windows version, see bug 590101
+fuzzy-if(skiaContent,1,1100) == 267459-2.html 267459-2.html
+== 299065-1.html 299065-1.html
+random-if(winWidget) == 305643-1.html 305643-1.html
+# depends on windows version, see bug 590101
+== 332655-1.html 332655-1.html
+== 332655-2.html 332655-2.html
+== 381279-1.html 381279-1.html
+== 386339.html 386339.html
+== 409375.html 409375.html
+== 413542-1.html 413542-1.html
+== 413542-2.html 413542-2.html
+random-if((B2G&&browserIsRemote)||Mulet) == 413928-1.html 413928-1.html
+# Initial mulet triage: parity with B2G/B2G Desktop
+random-if((B2G&&browserIsRemote)||Mulet) == 413928-2.html 413928-2.html
+# Initial mulet triage: parity with B2G/B2G Desktop
+== 425338-1a.html 425338-1a.html
+== 425338-1b.html 425338-1b.html
+skip == 489517-1.html 489517-1.html
+== 489887-1.html 489887-1.html
+== 492231-1.html 492231-1.html
+== 496006-1.html 496006-1.html
+== 503269-1.html 503269-1.html
+== 503957-1.html 503957-1.html
+== 525740-1.html 525740-1.html
+== 536963-1.html 536963-1.html
+== 562169-1.html 562169-1.html
+== 562169-1a.html 562169-1a.html
+== 562169-2.html 562169-2.html
+== 562169-2a.html 562169-2a.html
+== 562169-3.html 562169-3.html
+== 562169-3a.html 562169-3a.html
+skip == 562169-4.html 562169-4.html
+== 588739-1.html 588739-1.html
+== 588739-2.html 588739-2.html
+== 588739-3.html 588739-3.html
+== 612843-1.html 612843-1.html
+== 613149-1a.html 613149-1a.html
+== 613149-1b.html 613149-1b.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,36,2) == 613149-2a.html 613149-2a.html
+fuzzy-if(Android,24,1) fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,36,2) == 613149-2b.html 613149-2b.html
+== 613157-1.html 613157-1.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,255,6) == 613157-2.html 613157-2.html
+== 662288-1.html 662288-1.html
+skip == 670226-1.html 670226-1.html
+== 676245-1.html 676245-1.html
+skip-if(B2G||Mulet) fuzzy-if(skiaContent,1,3) == 698291-1.html 698291-1.html
+# Initial mulet triage: parity with B2G/B2G Desktop
+== 698706-1.html 698706-1.html
+== 704837-1.html 704837-1.html
+== 712600-1.html 712600-1.html
+== 712600-2.html 712600-2.html
+skip == 712600-2-dyn.html 712600-2-dyn.html
+== 712600-3.html 712600-3.html
+== 718236-1.html 718236-1.html
+== 718236-2.html 718236-2.html
+== 718236-3.html 718236-3.html
+skip-if(B2G||Mulet) == 726420-1.html 726420-1.html
+# Initial mulet triage: parity with B2G/B2G Desktop
+== 726460-1.html 726460-1.html
+== 729047-1.html 729047-1.html
+== 730562-1.html 730562-1.html
+== 746987-1.html 746987-1.html
+== 746987-2.html 746987-2.html
+== 746987-3.html 746987-3.html
+== 746987-4.html 746987-4.html
+== 779003-1.html 779003-1.html
+== 779003-1-dynamic.html 779003-1-dynamic.html
+== 817406-1.html 817406-1.html
+== 817406-2.html 817406-2.html
+== 817406-3.html 817406-3.html
+== 817406-4.html 817406-4.html
+== 847242-1.html 847242-1.html
+skip-if((B2G&&browserIsRemote)||Mulet) fuzzy-if(xulRuntime.widgetToolkit=="gtk3",1,11) == 869833-1.xul 869833-1.xul
+# Initial mulet triage: parity with B2G/B2G Desktop
+== 922530-1.html 922530-1.html
+== 922550-1.html 922550-1.html
+== 1067268-1.html 1067268-1.html
+== 1069941-inline-bidi-border-1.html 1069941-inline-bidi-border-1.html
+== 1069941-inline-bidi-margin-1.html 1069941-inline-bidi-margin-1.html
+skip-if(B2G||Mulet) == 1155359-1.xul 1155359-1.xul
+== 1157726-1.html 1157726-1.html
+skip == 1161752.html 1161752.html
+== 1161752-5-embed.html 1161752-5-embed.html
+== brackets-1a-ltr.html brackets-1a-ltr.html
+== brackets-1a-rtl.html brackets-1a-rtl.html
+== brackets-1b-ltr.html brackets-1b-ltr.html
+== brackets-1b-rtl.html brackets-1b-rtl.html
+== brackets-1c-ltr.html brackets-1c-ltr.html
+== brackets-1c-rtl.html brackets-1c-rtl.html
+== brackets-2a-ltr.html brackets-2a-ltr.html
+fuzzy-if(Android,254,557) == brackets-2a-rtl.html brackets-2a-rtl.html
+== brackets-2b-ltr.html brackets-2b-ltr.html
+== brackets-2b-rtl.html brackets-2b-rtl.html
+== brackets-2c-ltr.html brackets-2c-ltr.html
+fuzzy-if(Android,254,231) == brackets-2c-rtl.html brackets-2c-rtl.html
+== brackets-3a-ltr.html brackets-3a-ltr.html
+== brackets-3a-rtl.html brackets-3a-rtl.html
+== brackets-3b-ltr.html brackets-3b-ltr.html
+== brackets-3b-rtl.html brackets-3b-rtl.html
+== 1217833-1.html 1217833-1.html
+== 1217833-2.html 1217833-2.html
+== 1231175-1.html 1231175-1.html
diff --git a/layout/reftests/bidi/reftest.list b/layout/reftests/bidi/reftest.list
new file mode 100644
index 000000000..83f1db00e
--- /dev/null
+++ b/layout/reftests/bidi/reftest.list
@@ -0,0 +1,174 @@
+include dirAuto/reftest.list
+include numeral/reftest.list
+== bdi-element.html bdi-element-ref.html
+== bidi-000.html bidi-000-ref.html
+== bidi-001.html bidi-001-ref.html
+== bidi-001-j.html bidi-001-ref.html
+== bidi-001-v.html bidi-001-ref.html
+== bidi-002.html bidi-002-ref.html
+== bidi-003.html bidi-003-ref.html
+fuzzy-if(gtkWidget,255,17) == bidi-004.html bidi-004-ref.html # inconsistency in the Hebrew font that gets used
+fuzzy-if(gtkWidget,255,17) == bidi-004-j.html bidi-004-ref.html # inconsistency in the Hebrew font that gets used
+== bidi-005.html bidi-005-ref.html
+random-if(cocoaWidget) == bidi-006.html bidi-006-ref.html # bug 734313
+random-if(cocoaWidget) == bidi-006-j.html bidi-006-ref.html # bug 734313
+== bidiSVG-01.svg bidiSVG-01-ref.svg
+== bidiSVG-02.svg bidiSVG-02-ref.svg
+== bidiSVG-03.svg bidiSVG-03-ref.svg
+fuzzy-if(skiaContent,1,1) == bidiSVG-04.svg bidiSVG-04-ref.svg
+== bidiSVG-05.svg bidiSVG-05-ref.svg
+random-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) HTTP(..) == bidiMirroring.svg bidiMirroring-ref.svg
+fuzzy-if(Android,9,134) random-if(layersGPUAccelerated) == visualmarquee.html marquee-ref.html
+fuzzy-if(Android,9,134) random-if(layersGPUAccelerated) == logicalmarquee.html marquee-ref.html
+== visualmarquee.html logicalmarquee.html
+# test for glyph mirroring in right-to-left text
+== mirroring-01.html mirroring-01-ref.html
+# quote marks are not supposed to mirror, but Unicode 5.0 said they should, so some systems do it
+random-if(cocoaWidget) == mirroring-02.html mirroring-02-ref.html
+== mirroring-03.html mirroring-03-ref.html
+== mixedChartype-00.html mixedChartype-00-ref.html
+== mixedChartype-00-j.html mixedChartype-00-ref.html
+== mixedChartype-01.html mixedChartype-01-ref.html
+== mixedChartype-01-j.html mixedChartype-01-ref.html
+== mixedChartype-02.html mixedChartype-02-ref.html
+== mixedChartype-02-j.html mixedChartype-02-ref.html
+== mixedChartype-03.html mixedChartype-03-ref.html
+== mixedChartype-03-j.html mixedChartype-03-ref.html
+== unicode-bidi-anonymous-001.html unicode-bidi-anonymous-001-ref.html
+== unicode-bidi-anonymous-002.html unicode-bidi-anonymous-002-ref.html
+== unicode-bidi-isolate-basic.html unicode-bidi-isolate-basic-ref.html
+== unicode-bidi-isolate-aharon.html unicode-bidi-isolate-aharon-ref.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,73,1) fuzzy-if(skiaContent,104,32) == unicode-bidi-plaintext.html unicode-bidi-plaintext-ref.html
+== unicode-bidi-plaintext-textarea-1.html unicode-bidi-plaintext-textarea-ref.html
+== unicode-bidi-plaintext-textarea-2.html unicode-bidi-plaintext-textarea-ref.html
+== unicode-bidi-plaintext-textarea-3.html unicode-bidi-plaintext-textarea-ref.html
+== unicode-bidi-plaintext-textarea-4.html unicode-bidi-plaintext-textarea-ref.html
+== with-first-letter-1a.html with-first-letter-1-ref.html
+== with-first-letter-1b.html with-first-letter-1-ref.html
+random-if(cocoaWidget) == with-first-letter-2a.html with-first-letter-2-ref.html # bug 734313
+random-if(cocoaWidget) == with-first-letter-2b.html with-first-letter-2-ref.html # bug 734313
+== 83958-1a.html 83958-1-ref.html
+== 83958-1b.html 83958-1-ref.html
+== 83958-1c.html 83958-1-ref.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,111,7) == 83958-2a.html 83958-2-ref.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,111,7) == 83958-2b.html 83958-2-ref.html
+== 115921-1.html 115921-1-ref.html
+== 115921-2.html 115921-2-ref.html
+== 151407-1.html 151407-1-ref.html
+== 151407-1a.html 151407-1-ref.html
+== 151407-2-ltr.html 151407-2-ltr-ref.html
+== 151407-2-rtl.html 151407-2-rtl-ref.html
+== 151407-2-auto.html 151407-2-auto-ref.html
+== 151407-2-empty.html 151407-2-empty-ref.html
+== 151407-2-foopy.html 151407-2-empty-ref.html
+== 151407-3-ltr.html 151407-3-ltr-ref.html
+== 151407-3-rtl.html 151407-3-rtl-ref.html
+== 151407-3-auto.html 151407-3-auto-ref.html
+== 151407-3-foopy.html 151407-3-empty-ref.html
+== 229367-1.html 229367-1-ref.html
+== 229367-2.html 229367-2-ref.html
+== 229367-3.html 229367-3-ref.html
+== 258928-1.html 258928-1-ref.html
+== 263359-1.html 263359-1-ref.html
+== 263359-1a.html 263359-1-ref.html
+!= 263359-1b.html 263359-1-ref.html
+== 263359-2.html 263359-2-ref.html
+== 263359-3.html 263359-3-ref.html
+== 263359-4.html 263359-4-ref.html
+random-if(winWidget) fuzzy-if(skiaContent,1,1700) == 267459-1.html 267459-1-ref.html # depends on windows version, see bug 590101
+fuzzy-if(skiaContent,1,1100) == 267459-2.html 267459-2-ref.html
+== 299065-1.html 299065-1-ref.html
+random-if(winWidget) == 305643-1.html 305643-1-ref.html # depends on windows version, see bug 590101
+== 332655-1.html 332655-1-ref.html
+== 332655-2.html 332655-2-ref.html
+== 381279-1.html 381279-1-ref.html
+== 386339.html 386339-ref.html
+== 409375.html 409375-ref.html
+== 413542-1.html 413542-1-ref.html
+== 413542-2.html 413542-2-ref.html
+== 413928-1.html 413928-1-ref.html
+== 413928-2.html 413928-2-ref.html
+== 425338-1a.html 425338-1-ref.html
+== 425338-1b.html 425338-1-ref.html
+== 489517-1.html 489517-1-ref.html
+== 489887-1.html 489887-1-ref.html
+== 492231-1.html 492231-1-ref.html
+== 496006-1.html 496006-1-ref.html
+== 503269-1.html 503269-1-ref.html
+== 503957-1.html 503957-1-ref.html
+== 525740-1.html 525740-1-ref.html
+== 536963-1.html 536963-1-ref.html
+== 562169-1.html 562169-1-ref.html
+== 562169-1a.html 562169-1-ref.html
+== 562169-2.html 562169-2-ref.html
+== 562169-2a.html 562169-2-ref.html
+== 562169-3.html 562169-3-ref.html
+== 562169-3a.html 562169-3-ref.html
+== 562169-4.html 562169-4-ref.html
+== 588739-1.html 588739-ref.html
+== 588739-2.html 588739-ref.html
+== 588739-3.html 588739-ref.html
+== 612843-1.html 612843-1-ref.html
+== 613149-1a.html 613149-1-ref.html
+== 613149-1b.html 613149-1-ref.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,36,2) == 613149-2a.html 613149-2-ref.html
+fuzzy-if(Android,24,1) fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,36,2) == 613149-2b.html 613149-2-ref.html
+== 613157-1.html 613157-1-ref.html
+fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia,255,6) == 613157-2.html 613157-2-ref.html
+== 662288-1.html 662288-1-ref.html
+== 670226-1.html 670226-1-ref.html
+== 676245-1.html 676245-1-ref.html
+fuzzy-if(skiaContent,1,3) == 698291-1.html 698291-1-ref.html
+== 698706-1.html 698706-1-ref.html
+== 704837-1.html 704837-1-ref.html
+== 712600-1.html 712600-1-ref.html
+== 712600-2.html 712600-2-ref.html
+== 712600-2-dyn.html 712600-2-ref.html
+== 712600-3.html 712600-3-ref.html
+== 718236-1.html 718236-1-ref.html
+== 718236-2.html 718236-2-ref.html
+== 718236-3.html 718236-3-ref.html
+== 726420-1.html 726420-1-ref.html
+== 726460-1.html 726460-1-ref.html
+== 729047-1.html 729047-1-ref.html
+== 730562-1.html 730562-1-ref.html
+== 746987-1.html 746987-1-ref.html
+== 746987-2.html 746987-2-ref.html
+== 746987-3.html 746987-3-ref.html
+== 746987-4.html 746987-4-ref.html
+== 779003-1.html 779003-1-ref.html
+== 779003-1-dynamic.html 779003-1-ref.html
+== 817406-1.html 817406-1-ref.html
+== 817406-2.html 817406-2-ref.html
+== 817406-3.html 817406-1-ref.html
+== 817406-4.html 817406-4-ref.html
+== 847242-1.html 847242-1-ref.html
+fuzzy-if(xulRuntime.widgetToolkit=="gtk3",1,11) == 869833-1.xul 869833-1-ref.xul
+== 922530-1.html 922530-1-ref.html
+== 922550-1.html 922550-1-ref.html
+== 1067268-1.html 1067268-1-ref.html
+== 1069941-inline-bidi-border-1.html 1069941-inline-bidi-border-1-ref.html
+== 1069941-inline-bidi-margin-1.html 1069941-inline-bidi-margin-1-ref.html
+!= 1155359-1.xul 1155359-1-ref.xul
+== 1157726-1.html 1157726-1-ref.html
+== 1161752.html 1161752-ref.html
+== 1161752-5-embed.html 1161752-5-embed-ref.html
+== brackets-1a-ltr.html brackets-1a-ltr-ref.html
+== brackets-1a-rtl.html brackets-1a-rtl-ref.html
+== brackets-1b-ltr.html brackets-1b-ltr-ref.html
+== brackets-1b-rtl.html brackets-1b-rtl-ref.html
+== brackets-1c-ltr.html brackets-1c-ltr-ref.html
+== brackets-1c-rtl.html brackets-1c-rtl-ref.html
+== brackets-2a-ltr.html brackets-2a-ltr-ref.html
+fuzzy-if(Android,254,557) == brackets-2a-rtl.html brackets-2a-rtl-ref.html
+== brackets-2b-ltr.html brackets-2b-ltr-ref.html
+== brackets-2b-rtl.html brackets-2b-rtl-ref.html
+== brackets-2c-ltr.html brackets-2c-ltr-ref.html
+fuzzy-if(Android,254,231) == brackets-2c-rtl.html brackets-2c-rtl-ref.html
+== brackets-3a-ltr.html brackets-3a-ltr-ref.html
+== brackets-3a-rtl.html brackets-3a-rtl-ref.html
+== brackets-3b-ltr.html brackets-3b-ltr-ref.html
+== brackets-3b-rtl.html brackets-3b-rtl-ref.html
+== 1217833-1.html 1217833-1-ref.html
+== 1217833-2.html 1217833-2-ref.html
+== 1231175-1.html 1231175-1-ref.html
diff --git a/layout/reftests/bidi/unicode-bidi-anonymous-001-ref.html b/layout/reftests/bidi/unicode-bidi-anonymous-001-ref.html
new file mode 100644
index 000000000..64941d5ca
--- /dev/null
+++ b/layout/reftests/bidi/unicode-bidi-anonymous-001-ref.html
@@ -0,0 +1,3 @@
+<!DOCTYPE HTML>
+<title>Test for 'unicode-bidi' on table cells</title>
+<table border><tr><td>abc</td></tr></table>
diff --git a/layout/reftests/bidi/unicode-bidi-anonymous-001.html b/layout/reftests/bidi/unicode-bidi-anonymous-001.html
new file mode 100644
index 000000000..a0e3dcb0a
--- /dev/null
+++ b/layout/reftests/bidi/unicode-bidi-anonymous-001.html
@@ -0,0 +1,3 @@
+<!DOCTYPE HTML>
+<title>Test for 'unicode-bidi' on table cells</title>
+<table border><tr><td style="unicode-bidi: bidi-override; direction: rtl; text-align: left">cba</td></tr></table>
diff --git a/layout/reftests/bidi/unicode-bidi-anonymous-002-ref.html b/layout/reftests/bidi/unicode-bidi-anonymous-002-ref.html
new file mode 100644
index 000000000..6da4f8dcf
--- /dev/null
+++ b/layout/reftests/bidi/unicode-bidi-anonymous-002-ref.html
@@ -0,0 +1,5 @@
+<!DOCTYPE HTML>
+<title>Test for 'unicode-bidi' on table cells</title>
+<fieldset>
+ abc
+</fieldset>
diff --git a/layout/reftests/bidi/unicode-bidi-anonymous-002.html b/layout/reftests/bidi/unicode-bidi-anonymous-002.html
new file mode 100644
index 000000000..9839b2901
--- /dev/null
+++ b/layout/reftests/bidi/unicode-bidi-anonymous-002.html
@@ -0,0 +1,5 @@
+<!DOCTYPE HTML>
+<title>Test for 'unicode-bidi' on table cells</title>
+<fieldset style="unicode-bidi: bidi-override; direction: rtl; text-align: left">
+ cba
+</fieldset>
diff --git a/layout/reftests/bidi/unicode-bidi-isolate-aharon-ref.html b/layout/reftests/bidi/unicode-bidi-isolate-aharon-ref.html
new file mode 100644
index 000000000..8bfa5a30e
--- /dev/null
+++ b/layout/reftests/bidi/unicode-bidi-isolate-aharon-ref.html
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<html><head>
+<title>Test cases for unicode-bidi:isolate</title>
+<style>
+</style>
+</head><body>
+opposite-to-base isolate followed by number.
+<div>
+ <div class="reference">
+ <span dir="ltr">&#x05D0;</span> (3 reviews)
+ </div>
+</div>
+<hr>
+opposite-to-base isolate with opposite-to-base text before it with neutrals in between.
+<div>
+ <div class="reference">
+ <span dir="ltr">&#x05D0;</span>: <span dir="ltr">&#x05D1;</span>
+ </div>
+</div>
+<hr>
+opposite-to-base isolate with opposite-to-base text before it and nothing in between.
+<div>
+ <div class="reference">
+ <bdo dir="ltr">&#x05D0;&#x05D1;</bdo>
+ </div>
+</div>
+<hr>
+two opposite-to-base isolates with neutrals in between.
+<div>
+ <div class="reference">
+ <span dir="ltr">&#x05D0;</span> = <span dir="ltr">&#x05D1;</span>
+ </div>
+</div>
+<hr>
+two opposite-to-base isolates with nothing in between.
+<div>
+ <div class="reference">
+ <bdo dir="ltr">&#x05D0;&#x05D1;</bdo>
+ </div>
+</div>
+<hr>
+same-as-base isolate preceded by opposite-to-base text and followed by number
+<div dir="rtl">
+ <div class="reference">
+ see <span dir="ltr">&#x05D0;</span><sup>3</sup>
+ </div>
+</div>
+<hr>
+same-as-base isolate surrounded by opposite-to-base text
+<div dir="rtl">
+ <div class="reference">
+ with <span dir="ltr">&#x05D0;</span>=<span dir="ltr">&#x05D1;</span> everywhere
+ </div>
+</div>
+<hr>
+chimeric isolate surrounded by chimeric text
+<div>
+ <div class="reference">
+ about that <span dir="ltr">&#x05D0;</span> - &#x05D1;
+ </div>
+</div>
+<hr>
+nested chimeric isolates surrounded by chimeric text
+<div>
+ <div class="reference">
+ about that strange <span dir="ltr">&#x05D0;</span> - <span dir="ltr">&#x05D1;</span> - &#x05D2;
+ </div>
+</div>
+</body></html>
diff --git a/layout/reftests/bidi/unicode-bidi-isolate-aharon.html b/layout/reftests/bidi/unicode-bidi-isolate-aharon.html
new file mode 100644
index 000000000..175150b46
--- /dev/null
+++ b/layout/reftests/bidi/unicode-bidi-isolate-aharon.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html><head>
+<title>Test cases for unicode-bidi:isolate</title>
+<style>
+ .isolate {
+ unicode-bidi: isolate;
+ }
+</style>
+</head><body>
+opposite-to-base isolate followed by number.
+<div>
+ <div class="test">
+ <span class="isolate">&#x05D0;</span> (3 reviews)
+ </div>
+</div>
+<hr>
+opposite-to-base isolate with opposite-to-base text before it with neutrals in between.
+<div>
+ <div class="test">
+ &#x05D0;: <span class="isolate">&#x05D1;</span>
+ </div>
+</div>
+<hr>
+opposite-to-base isolate with opposite-to-base text before it and nothing in between.
+<div>
+ <div class="test">
+ &#x05D0;<span class="isolate">&#x05D1;</span>
+ </div>
+</div>
+<hr>
+two opposite-to-base isolates with neutrals in between.
+<div>
+ <div class="test">
+ <span class="isolate">&#x05D0;</span> = <span class="isolate">&#x05D1;</span>
+ </div>
+</div>
+<hr>
+two opposite-to-base isolates with nothing in between.
+<div>
+ <div class="test">
+ <span class="isolate">&#x05D0;</span><span class="isolate">&#x05D1;</span>
+ </div>
+</div>
+<hr>
+same-as-base isolate preceded by opposite-to-base text and followed by number
+<div dir="rtl">
+ <div class="test">
+ see <span class="isolate">&#x05D0;</span><sup>3</sup>
+ </div>
+</div>
+<hr>
+same-as-base isolate surrounded by opposite-to-base text
+<div dir="rtl">
+ <div class="test">
+ with <span class="isolate">&#x05D0;</span>=<span class="isolate">&#x05D1;</span> everywhere
+ </div>
+</div>
+<hr>
+chimeric isolate surrounded by chimeric text
+<div>
+ <div class="test">
+ about <span class="isolate">that &#x05D0;</span> - &#x05D1;
+ </div>
+</div>
+<hr>
+nested chimeric isolates surrounded by chimeric text
+<div>
+ <div class="test">
+ about <span class="isolate">that <span class="isolate">strange &#x05D0;</span> - &#x05D1;</span> - &#x05D2;
+ </div>
+</div>
+</body></html>
diff --git a/layout/reftests/bidi/unicode-bidi-isolate-basic-ref.html b/layout/reftests/bidi/unicode-bidi-isolate-basic-ref.html
new file mode 100644
index 000000000..3009ca35f
--- /dev/null
+++ b/layout/reftests/bidi/unicode-bidi-isolate-basic-ref.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<script type="text/javascript" src="unicode-bidi-isolate-basic.js"></script>
+<style>
+.resultsDiv {
+ -moz-column-width: 3em;
+ -webkit-column-width: 3em;
+ -moz-column-gap: 5em;
+ -webkit-column-gap: 5em;
+ text-align: left;
+}
+.enclosed { display: inline-block; }
+</style>
+</head>
+<body onload="buildTable();">
+<div id="resultsContainer" style="position: relative">
+<div id="elem" class="resultsDiv"></div>
+</div>
+</body>
+</html>
diff --git a/layout/reftests/bidi/unicode-bidi-isolate-basic.html b/layout/reftests/bidi/unicode-bidi-isolate-basic.html
new file mode 100644
index 000000000..9162dbcf0
--- /dev/null
+++ b/layout/reftests/bidi/unicode-bidi-isolate-basic.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<script type="text/javascript" src="unicode-bidi-isolate-basic.js"></script>
+<style>
+.resultsDiv {
+ -moz-column-width: 3em;
+ -webkit-column-width: 3em;
+ -moz-column-gap: 5em;
+ -webkit-column-gap: 5em;
+ text-align: left;
+}
+.enclosed { unicode-bidi: isolate; }
+</style>
+</head>
+<body onload="buildTable()">
+<div id="resultsContainer" style="position: relative">
+<div id="elem" class="resultsDiv"></div>
+</div>
+</body>
+</html>
diff --git a/layout/reftests/bidi/unicode-bidi-isolate-basic.js b/layout/reftests/bidi/unicode-bidi-isolate-basic.js
new file mode 100644
index 000000000..e949e6a44
--- /dev/null
+++ b/layout/reftests/bidi/unicode-bidi-isolate-basic.js
@@ -0,0 +1,44 @@
+function buildTable()
+{
+ var seed = 0;
+
+ var neutrals = ['"', ")", "("];
+ var strongRTLs = ['א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז'];
+ var strongLTRs = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
+ var neutral = function() { return neutrals[seed++ % neutrals.length]; }
+ var strongRTL = function() { return strongRTLs[seed++ % strongRTLs.length]; }
+ var strongLTR = function() { return strongLTRs[seed++ % strongLTRs.length]; }
+ var charClassExamples = [neutral, strongRTL, strongLTR];
+ var possibleDirs = ['ltr', 'rtl'];
+
+ var elem=document.getElementById("elem");
+ for (outerDirIndex in possibleDirs) {
+ var outerDir = possibleDirs[outerDirIndex];
+ for (beforeSpanIndex in charClassExamples) {
+ var beforeSpan = charClassExamples[beforeSpanIndex];
+ for (spanDirIndex in possibleDirs) {
+ var spanDir = possibleDirs[spanDirIndex];
+ for (inSpanIndex in charClassExamples) {
+ var inSpan = charClassExamples[inSpanIndex];
+ for (afterSpanIndex in charClassExamples) {
+ var afterSpan = charClassExamples[afterSpanIndex];
+ function caseWithStyle() {
+ seed = 0;
+ var outerDiv = document.createElement("div");
+ outerDiv.dir = outerDir;
+ outerDiv.appendChild(document.createTextNode(beforeSpan()));
+ var span = document.createElement("span");
+ span.dir = spanDir;
+ span.setAttribute("class", "enclosed")
+ span.appendChild(document.createTextNode(inSpan()));
+ outerDiv.appendChild(span);
+ outerDiv.appendChild(document.createTextNode(afterSpan()));
+ return outerDiv;
+ }
+ elem.appendChild(caseWithStyle());
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/layout/reftests/bidi/unicode-bidi-plaintext-ref.html b/layout/reftests/bidi/unicode-bidi-plaintext-ref.html
new file mode 100644
index 000000000..8ded86a57
--- /dev/null
+++ b/layout/reftests/bidi/unicode-bidi-plaintext-ref.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+</head>
+<body>
+<div>
+!hello.<br>
+<span dir=rtl>
+!שלום.
+</span><br>
+<span dir=ltr>
+hello, לוי!
+</span><br>
+<span dir=rtl>
+שלום, WebKit!</span><br>
+<pre>
+a
+(
+!WebKit ,שלום
+hello, לוי!
+)
+</pre>
+</div>
+</body>
+</html>
diff --git a/layout/reftests/bidi/unicode-bidi-plaintext-textarea-1.html b/layout/reftests/bidi/unicode-bidi-plaintext-textarea-1.html
new file mode 100644
index 000000000..aec6d38df
--- /dev/null
+++ b/layout/reftests/bidi/unicode-bidi-plaintext-textarea-1.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html><head>
+<title>unicode-bidi:plaintext</title>
+<style>
+ textarea { text-align: left; resize: none; }
+</style>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+</head><body>
+<div>
+The exclamation mark should be on the left side of the first line
+and on the right side of the second line.
+</div>
+<textarea rows=4 cols=50 dir=auto>
+שלום!
+hello!
+</textarea>
+</body></html>
diff --git a/layout/reftests/bidi/unicode-bidi-plaintext-textarea-2.html b/layout/reftests/bidi/unicode-bidi-plaintext-textarea-2.html
new file mode 100644
index 000000000..aae0f4ffe
--- /dev/null
+++ b/layout/reftests/bidi/unicode-bidi-plaintext-textarea-2.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html><head>
+<title>unicode-bidi:plaintext</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style>
+ .plaintext {
+ unicode-bidi:plaintext;
+ }
+ textarea { text-align: left; resize: none; }
+</style>
+</head><body>
+<div>
+The exclamation mark should be on the left side of the first line
+and on the right side of the second line.
+</div>
+<textarea rows=4 cols=50 class="plaintext">
+שלום!
+hello!
+</textarea>
+</body></html>
diff --git a/layout/reftests/bidi/unicode-bidi-plaintext-textarea-3.html b/layout/reftests/bidi/unicode-bidi-plaintext-textarea-3.html
new file mode 100644
index 000000000..89ea8a105
--- /dev/null
+++ b/layout/reftests/bidi/unicode-bidi-plaintext-textarea-3.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html><head>
+<title>unicode-bidi:plaintext</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style>
+ .plaintext {
+ unicode-bidi:plaintext;
+ }
+ textarea { text-align: left; resize: none; }
+</style>
+</head><body>
+<div>
+The exclamation mark should be on the left side of the first line
+and on the right side of the second line.
+</div>
+<textarea rows=4 cols=50 dir="ltr" class="plaintext">
+שלום!
+hello!
+</textarea>
+</body></html>
diff --git a/layout/reftests/bidi/unicode-bidi-plaintext-textarea-4.html b/layout/reftests/bidi/unicode-bidi-plaintext-textarea-4.html
new file mode 100644
index 000000000..b9cc61289
--- /dev/null
+++ b/layout/reftests/bidi/unicode-bidi-plaintext-textarea-4.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html><head>
+<title>unicode-bidi:plaintext</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style>
+ .plaintext {
+ unicode-bidi:plaintext;
+ }
+ textarea { text-align: left; resize: none; }
+</style>
+</head><body>
+<div>
+The exclamation mark should be on the left side of the first line
+and on the right side of the second line.
+</div>
+<textarea rows=4 cols=50 dir="rtl" class="plaintext">
+שלום!
+hello!
+</textarea>
+</body></html>
diff --git a/layout/reftests/bidi/unicode-bidi-plaintext-textarea-ref.html b/layout/reftests/bidi/unicode-bidi-plaintext-textarea-ref.html
new file mode 100644
index 000000000..1e89c8190
--- /dev/null
+++ b/layout/reftests/bidi/unicode-bidi-plaintext-textarea-ref.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>unicode-bidi:plaintext</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style>
+ textarea { resize: none; }
+</style>
+</head>
+<body>
+<div>
+The exclamation mark should be on the left side of the first line
+and on the right side of the second line.
+</div>
+<textarea rows=4 cols=50 dir=ltr>
+&#x202b;שלום!&#x202c;
+&#x202a;hello!&#x202c
+</textarea>
+</body></html>
diff --git a/layout/reftests/bidi/unicode-bidi-plaintext.html b/layout/reftests/bidi/unicode-bidi-plaintext.html
new file mode 100644
index 000000000..2c8d19781
--- /dev/null
+++ b/layout/reftests/bidi/unicode-bidi-plaintext.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<style>
+div, pre { text-align: left; }
+</style>
+</head>
+<body>
+<div style="unicode-bidi: plaintext;">
+!hello.
+<br>
+!שלום.
+<br>
+hello, לוי!
+<br>
+שלום, WebKit!
+</div>
+<pre dir="auto">
+a
+(
+שלום, WebKit!
+hello, לוי!
+)
+</pre>
+</body>
+</html>
diff --git a/layout/reftests/bidi/visualmarquee.html b/layout/reftests/bidi/visualmarquee.html
new file mode 100644
index 000000000..932fd775a
--- /dev/null
+++ b/layout/reftests/bidi/visualmarquee.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=iso-8859-8">
+ <title>Marquee in Visual Hebrew</title>
+ </head>
+
+ <body>
+ <marquee scrollamount="0" behavior="alternate" direction="right">&#x05DD;&#x05D9;&#x05DC;&#x05D9;&#x05DC;&#x05E6;&#x05D4; &#x05D5;&#x05E1;&#x05E0;&#x05D5; &#x05DD;&#x05D5;&#x05D9;&#x05D4; &#x05D7;&#x05D5;&#x05E4;&#x05D9;&#x05E9; &#x05D3;&#x05E2;</marquee>
+ </body>
+</html>
diff --git a/layout/reftests/bidi/with-first-letter-1-ref.html b/layout/reftests/bidi/with-first-letter-1-ref.html
new file mode 100644
index 000000000..b476685ce
--- /dev/null
+++ b/layout/reftests/bidi/with-first-letter-1-ref.html
@@ -0,0 +1,19 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Test for bidi splitting and :first-letter</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<style type="text/css">
+
+p { unicode-bidi: bidi-override; }
+body { font-size: 300%; }
+
+</style>
+</head>
+<body>
+
+<p><span style="background: aqua">T</span>his has AB<span style="background:yellow">CD</span>תש<span style="background:yellow">בא</span></p>
+
+</body>
+</html>
diff --git a/layout/reftests/bidi/with-first-letter-1a.html b/layout/reftests/bidi/with-first-letter-1a.html
new file mode 100644
index 000000000..5724bf969
--- /dev/null
+++ b/layout/reftests/bidi/with-first-letter-1a.html
@@ -0,0 +1,19 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Test for bidi splitting and :first-letter</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<style type="text/css">
+
+p:first-letter { background: aqua; }
+body { font-size: 300%; }
+
+</style>
+</head>
+<body>
+
+<p>This has AB<span style="background:yellow">CDאב</span>שת</p>
+
+</body>
+</html>
diff --git a/layout/reftests/bidi/with-first-letter-1b.html b/layout/reftests/bidi/with-first-letter-1b.html
new file mode 100644
index 000000000..4f1266f43
--- /dev/null
+++ b/layout/reftests/bidi/with-first-letter-1b.html
@@ -0,0 +1,19 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Test for bidi splitting and :first-letter</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<style type="text/css">
+
+p:first-letter { background: aqua; }
+body { font-size: 300%; }
+
+</style>
+</head>
+<body>
+
+<p><span><span>This has AB<span style="background:yellow">CDאב</span>שת</span></span></p>
+
+</body>
+</html>
diff --git a/layout/reftests/bidi/with-first-letter-2-ref.html b/layout/reftests/bidi/with-first-letter-2-ref.html
new file mode 100644
index 000000000..4338fc3cc
--- /dev/null
+++ b/layout/reftests/bidi/with-first-letter-2-ref.html
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Test for bidi splitting and :first-letter</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<style type="text/css">
+
+p { unicode-bidi: bidi-override; }
+p:first-letter { float:left; font-size: 2em; }
+body { font-size: 300%; }
+
+</style>
+</head>
+<body>
+
+<p>This has AB<span style="background:yellow">CD</span>תש<span style="background:yellow">בא</span></p>
+
+</body>
+</html>
diff --git a/layout/reftests/bidi/with-first-letter-2a.html b/layout/reftests/bidi/with-first-letter-2a.html
new file mode 100644
index 000000000..8aa415c6c
--- /dev/null
+++ b/layout/reftests/bidi/with-first-letter-2a.html
@@ -0,0 +1,19 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Test for bidi splitting and :first-letter</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<style type="text/css">
+
+p:first-letter { float:left; font-size: 2em; }
+body { font-size: 300%; }
+
+</style>
+</head>
+<body>
+
+<p>This has AB<span style="background:yellow">CDאב</span>שת</p>
+
+</body>
+</html>
diff --git a/layout/reftests/bidi/with-first-letter-2b.html b/layout/reftests/bidi/with-first-letter-2b.html
new file mode 100644
index 000000000..cb80bd6d5
--- /dev/null
+++ b/layout/reftests/bidi/with-first-letter-2b.html
@@ -0,0 +1,19 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Test for bidi splitting and :first-letter</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<style type="text/css">
+
+p:first-letter { float:left; font-size: 2em; }
+body { font-size: 300%; }
+
+</style>
+</head>
+<body>
+
+<p><span><span>This has AB<span style="background:yellow">CDאב</span>שת</span></span></p>
+
+</body>
+</html>