Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
3216c04d
Commit
3216c04d
authored
Oct 13, 2022
by
Gabriel Ivăncescu
Committed by
Alexandre Julliard
Oct 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mshtml: Expose props via element name only for specific element types.
Signed-off-by:
Gabriel Ivăncescu
<
gabrielopcode@gmail.com
>
parent
baf7c13b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
13 deletions
+53
-13
htmldoc.c
dlls/mshtml/htmldoc.c
+19
-12
documentmode.js
dlls/mshtml/tests/documentmode.js
+34
-1
No files found.
dlls/mshtml/htmldoc.c
View file @
3216c04d
...
...
@@ -4820,23 +4820,30 @@ static inline HTMLDocument *impl_from_IDispatchEx(IDispatchEx *iface)
static
HRESULT
has_elem_name
(
nsIDOMHTMLDocument
*
nsdoc
,
const
WCHAR
*
name
)
{
nsIDOMNodeList
*
node_list
;
nsAString
name_str
;
static
const
WCHAR
fmt
[]
=
L":-moz-any(applet,embed,form,iframe,img,object)[name=
\"
%s
\"
]"
;
WCHAR
buf
[
128
],
*
selector
=
buf
;
nsAString
selector_str
;
nsIDOMElement
*
nselem
;
nsresult
nsres
;
UINT32
len
;
size_t
len
;
nsAString_InitDepend
(
&
name_str
,
name
);
nsres
=
nsIDOMHTMLDocument_GetElementsByName
(
nsdoc
,
&
name_str
,
&
node_list
);
nsAString_Finish
(
&
name_str
);
if
(
NS_FAILED
(
nsres
))
return
map_nsresult
(
nsres
);
len
=
wcslen
(
name
)
+
ARRAY_SIZE
(
fmt
)
-
2
/* %s */
;
if
(
len
>
ARRAY_SIZE
(
buf
)
&&
!
(
selector
=
heap_alloc
(
len
*
sizeof
(
WCHAR
))))
return
E_OUTOFMEMORY
;
swprintf
(
selector
,
len
,
fmt
,
name
);
nsres
=
nsIDOMNodeList_GetLength
(
node_list
,
&
len
);
nsIDOMNodeList_Release
(
node_list
);
nsAString_InitDepend
(
&
selector_str
,
selector
);
nsres
=
nsIDOMHTMLDocument_QuerySelector
(
nsdoc
,
&
selector_str
,
&
nselem
);
nsAString_Finish
(
&
selector_str
);
if
(
selector
!=
buf
)
heap_free
(
selector
);
if
(
NS_FAILED
(
nsres
))
return
map_nsresult
(
nsres
);
return
len
?
S_OK
:
DISP_E_UNKNOWNNAME
;
if
(
!
nselem
)
return
DISP_E_UNKNOWNNAME
;
nsIDOMElement_Release
(
nselem
);
return
S_OK
;
}
static
HRESULT
dispid_from_elem_name
(
HTMLDocumentNode
*
This
,
const
WCHAR
*
name
,
DISPID
*
dispid
)
...
...
@@ -5918,7 +5925,7 @@ static HRESULT HTMLDocumentNode_next_dispid(DispatchEx *dispex, DISPID id, DISPI
}
/* Populate possibly missing DISPIDs */
nsAString_InitDepend
(
&
nsstr
,
L"[name]"
);
nsAString_InitDepend
(
&
nsstr
,
L"
:-moz-any(applet,embed,form,iframe,img,object)
[name]"
);
nsres
=
nsIDOMHTMLDocument_QuerySelectorAll
(
This
->
nsdoc
,
&
nsstr
,
&
node_list
);
nsAString_Finish
(
&
nsstr
);
if
(
NS_FAILED
(
nsres
))
...
...
dlls/mshtml/tests/documentmode.js
View file @
3216c04d
...
...
@@ -669,7 +669,7 @@ sync_test("for..in", function() {
sync_test
(
"elem_by_id"
,
function
()
{
document
.
body
.
innerHTML
=
'<form id="testid" name="testname"></form>'
;
var
found
;
var
found
,
i
;
var
id_elem
=
document
.
getElementById
(
"testid"
);
ok
(
id_elem
.
tagName
===
"FORM"
,
"id_elem.tagName = "
+
id_elem
.
tagName
);
...
...
@@ -704,6 +704,39 @@ sync_test("elem_by_id", function() {
found
=
true
;
}
ok
(
found
,
"testname was not enumerated in document"
);
// these tags expose name as props, and id only if they have a name
var
tags
=
[
"embed"
,
"form"
,
"iframe"
,
"img"
];
for
(
i
in
tags
)
{
var
tag
=
tags
[
i
];
document
.
body
.
innerHTML
=
'<'
+
tag
+
' id="testid" name="testname"></'
+
tag
+
'><'
+
tag
+
' id="foobar"></'
+
tag
+
'>'
;
ok
(
"testname"
in
document
,
tag
+
" did not expose testname"
);
todo_wine
.
ok
(
"testid"
in
document
,
tag
+
" did not expose testid"
);
ok
(
!
(
"foobar"
in
document
),
tag
+
" exposed foobar"
);
}
// these tags always expose their id as well as name (we don't test applet because it makes Windows pop up a dialog box)
tags
=
[
"object"
];
for
(
i
in
tags
)
{
var
tag
=
tags
[
i
];
document
.
body
.
innerHTML
=
'<'
+
tag
+
' id="testid" name="testname"></'
+
tag
+
'><'
+
tag
+
' id="foobar"></'
+
tag
+
'>'
;
ok
(
"testname"
in
document
,
tag
+
" did not expose testname"
);
todo_wine
.
ok
(
"testid"
in
document
,
tag
+
" did not expose testid"
);
todo_wine
.
ok
(
"foobar"
in
document
,
tag
+
" did not expose foobar"
);
}
// all other tags don't expose props for either id or name, test a few of them here
tags
=
[
"a"
,
"b"
,
"body"
,
"center"
,
"div"
,
"frame"
,
"h2"
,
"head"
,
"html"
,
"input"
,
"meta"
,
"p"
,
"span"
,
"style"
,
"table"
,
"winetest"
];
for
(
i
in
tags
)
{
var
tag
=
tags
[
i
];
document
.
body
.
innerHTML
=
'<'
+
tag
+
' id="testid" name="testname"></'
+
tag
+
'><'
+
tag
+
' id="foobar"></'
+
tag
+
'>'
;
ok
(
!
(
"testname"
in
document
),
tag
+
" exposed testname"
);
ok
(
!
(
"testid"
in
document
),
tag
+
" exposed testid"
);
ok
(
!
(
"foobar"
in
document
),
tag
+
" exposed foobar"
);
}
});
sync_test
(
"doc_mode"
,
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment