Closed
Bug 33203
Opened 25 years ago
Closed 25 years ago
Form Submission Observer Changes
Categories
(Core :: DOM: Core & HTML, defect, P3)
Core
DOM: Core & HTML
Tracking
()
VERIFIED
FIXED
M16
People
(Reporter: dougt, Assigned: pollmann)
References
Details
(Whiteboard: Fix in hand - need testcase)
Attachments
(6 files)
|
1.62 KB,
patch
|
Details | Diff | Splinter Review | |
|
3.76 KB,
patch
|
Details | Diff | Splinter Review | |
|
4.28 KB,
patch
|
Details | Diff | Splinter Review | |
|
1.66 KB,
patch
|
Details | Diff | Splinter Review | |
|
4.26 KB,
patch
|
Details | Diff | Splinter Review | |
|
6.43 KB,
patch
|
Details | Diff | Splinter Review |
I am working on integrating security into the browser. One of the needed
security dialogs is to alert the user when they are posting to an insecure site.
They way that one is notified of a form submission currently is through the
nsIFormSubmitObserver interface. There are a couple requirements that are
missing in this current mechanism.
1. Need to be able to cancel a form submission. I need to be able to return a
status code from the notification which will prevent the form submission from
occurring. This is so that when I present a dialog to the user, they will have
an option to cancel the form submit and prevent information being posted to an
insecure site.
2. Need to be able to register on a per nsIDOMWindow bases. Currently, to
receive notifications, you register with a global service, nsIObserverService.
This is suboptimal because every form submission is sent to every observer in
every context. I would like to be notified only when a form submission happens
'in' a particular nsIDOMWindow. So, the registration of the
nsIFormSubmitObserver should be based on a window.
?? Maybe it is possible to QI the nsIContent for the containing nsIDOMWindow,
then ask if the nsIDOMWindow that I am concerned with contains the nsIConent's
DOM window.
3. Lastly, I need to know how to go from a nsIContent in Notify(nsIContent*
formNode) to a nsIURL. Eric mentioned that he may be able to pass this via the
interface.
| Assignee | ||
Comment 1•25 years ago
|
||
Let's aim for M15 - if all goes according to plan! :)
Doug, you mentioned a per-window security object that monitors the current
security state of the page - can you point me to where that lives and possibly
explain relevent parts of it so that I can understand how this form submit
observer mechanism should work? Thanks!
Status: NEW → ASSIGNED
Target Milestone: --- → M15
| Reporter | ||
Comment 2•25 years ago
|
||
sure. Take a look at:
http://lxr.mozilla.org/seamonkey/source/extensions/psm-glue/src/nsSecureBrowserU
IImpl.cpp#117
This is called from javascript the first time the page loads. As you can see, I
make myself the DocLoaderObserver of the nsIDOMWindow I pass in which is
|window.content|. What I would like to do is only recieve form post events on
this nsIDOMWindow.
| Assignee | ||
Comment 3•25 years ago
|
||
I'll have to push this off until M16, sorry!
Target Milestone: M15 → M16
| Assignee | ||
Comment 4•25 years ago
|
||
I have this pretty much done. I'll attach the diffs tomorrow. I decided that
it would be simplest to just use the existing nsIFormSubmitObserver mechanism,
and add an extra parameter (for the nsIDOMWindow) on the notify method.
This means you'll have to check if the nsIDOMWindow is the same one the security
glue is hooked up to. I figure this check has to be made, either in the
security glue or in the form frame and it is a *lot* easier in the security
glue.
I've made all the needed changes in psm-glue, wallet, and layout (including code
to register as an observer in nsSecureBrowserUIImpl::Init and check if the
submit is for this nsIDOMWindow in ::Notify). It is running fine in my simple
tests, at least, as well as form submission works in general with bug 33952.
Printing "Got a notify" whenever a form submits. Will attach diffs shortly...
Whiteboard: Fix in hand
| Assignee | ||
Comment 5•25 years ago
|
||
Oh, yeah, and to stop a form from submitting you just need to return
any NS_ERROR_XXX code from the Notify method. :)
| Assignee | ||
Comment 6•25 years ago
|
||
| Assignee | ||
Comment 7•25 years ago
|
||
| Assignee | ||
Comment 8•25 years ago
|
||
| Assignee | ||
Comment 9•25 years ago
|
||
Oops, one update:
NS_IMETHODIMP nsSecureBrowserUIImpl::Notify(nsIContent* formNode, nsIDOMWindow*
window)
{
if (!formNode) {
return NS_ERROR_FAILURE;
}
if (!window || (mWindow != window)) {
return NS_ERROR_FAILURE;
}
printf("Got notified of form submit on window %p.\n",window);
return NS_OK;
}
Should read:
NS_IMETHODIMP nsSecureBrowserUIImpl::Notify(nsIContent* formNode, nsIDOMWindow*
window)
{
if (!formNode) {
return NS_ERROR_FAILURE;
}
if (!window || (mWindow != window)) {
return NS_OK;
}
printf("Got notified of form submit on window %p.\n",window);
return NS_OK;
}
This will allow forms to submit if there is more than one window open. *blush*
| Assignee | ||
Comment 10•25 years ago
|
||
Hi Doug,
Well I just got back to reading the original requirements. One more question,
for part 3) when you say you need to get the nsIURL, do you need to get the url
that the request is coming from, the URL that the form is being submitted to, or
both? Thanks.
Whiteboard: Fix in hand
| Reporter | ||
Comment 11•25 years ago
|
||
the post destination would be required.
| Assignee | ||
Comment 12•25 years ago
|
||
Thanks, no problem, I'll attach the updated diffs.
Whiteboard: Fix in hand
| Assignee | ||
Comment 13•25 years ago
|
||
| Assignee | ||
Comment 14•25 years ago
|
||
| Assignee | ||
Comment 15•25 years ago
|
||
| Reporter | ||
Comment 16•25 years ago
|
||
changes look good. r=dougt
| Assignee | ||
Comment 17•25 years ago
|
||
Fixes checked in. The tree was red every time I looked at it from the time I've
had the changes done until now. :S
Doug, I've also changed nsIFormSubmitObserver so it derives from nsIObserver,
per the review. The changes in psm-glue were not checked in (you will now not
need to implement nsIObserver):
+class nsSecureBrowserUIImpl : public nsIDocumentLoaderObserver,
+ public nsIFormSubmitObserver,
+ public nsIObserver,
+ public nsSecureBrowserUI
becomes:
+class nsSecureBrowserUIImpl : public nsIDocumentLoaderObserver,
+ public nsIFormSubmitObserver,
+ public nsSecureBrowserUI
and
+NS_IMPL_ISUPPORTS4(nsSecureBrowserUIImpl,
+ nsIDocumentLoaderObserver,
+ nsIFormSubmitObserver,
+ nsIObserver,
+ nsSecureBrowserUI);
becomes
+NS_IMPL_ISUPPORTS3(nsSecureBrowserUIImpl,
+ nsIDocumentLoaderObserver,
+ nsIFormSubmitObserver,
+ nsSecureBrowserUI);
otherwise, psm-glue diffs are pretty much the same. Good luck!
(QA note: there is no way to verify this change by running the program.)
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
| Assignee | ||
Comment 18•25 years ago
|
||
Comment 19•25 years ago
|
||
dougt, do you have a specific site/testcase I can use to verify this bug?
Thanks! - ckritzer
Whiteboard: Fix in hand → Fix in hand - need testcase
| Reporter | ||
Comment 20•25 years ago
|
||
Just verify that wallet still works. Also, you can see if you get a warning
message when you try to post to an insecure site.
Comment 21•25 years ago
|
||
Change "wallet" in above comment to "single signon". Wallet's capturing of data
is called into play explicitly and is not dependent on an observer. Single
signon, on the other hand, is dependent on the form-submission observer.
Comment 22•25 years ago
|
||
test mac
Comment 23•25 years ago
|
||
test linux
Comment 24•25 years ago
|
||
test windows
Comment 25•25 years ago
|
||
Marking VERIFIED FIXED on:
- MacOS9 2000-07-06-08-M17 Commercial
- Linux6 2000-07-07-10-M17 Commercial
- Win98 2000-07-07-13-M17 Commercial
Status: RESOLVED → VERIFIED
Updated•6 years ago
|
Component: HTML: Form Submission → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•