Closed Bug 978657 Opened 10 years ago Closed 10 years ago

Provide Debugger 'introductionType' information for <script> element code

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla30

People

(Reporter: jimb, Assigned: jimb)

References

Details

Attachments

(2 files, 2 obsolete files)

JS code introduced by <script> elements doesn't have any introduction type information set, as retrieved by Debugger.Source.prototype.introductionType.
Try push:
https://tbpl.mozilla.org/?tree=Try&rev=4018f37e6e1d
Assignee: nobody → jimb
Status: NEW → ASSIGNED
This patch still needs tests for xul:script elements, which seem to be handled by a different place in the code: content/xul/content/src/nsXULElement.cpp instead of content/base/src/nsScriptLoader.cpp. I'll try to get to that tomorrow.
Attachment #8384417 - Attachment description: Provide introductionType information at every place in Firefox that evaluates JavaScript code. → Provide introductionType information for HTML and XUL <script> elements.
Using the addTest and runNextTest functions from inspector-helpers.js helps separate the tests from each other in a sane way. This patch is meant to have no effect.

It does change runNextTest to catch and report errors... I don't know why the test harness itself isn't reporting them. *GRR*
Attachment #8384419 - Flags: review?(past)
The patch I just attached needs to be applied before the main patch.

People wanting to try out the change should probably just get builds from the Try push linked to in comment 1.
Comment on attachment 8384419 [details] [diff] [review]
Convert test_Debugger.Source.prototype.introductionType.html to use addTest and runNextTest.

Review of attachment 8384419 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM.
Attachment #8384419 - Flags: review?(past) → review+
(In reply to Panos Astithas [:past] from comment #5)
> LGTM.

Thanks!
The mochitest-other test failures in the try push in comment 1 are the result of my neglecting to update another previously-existing test for the platform's (improved) behavior; so aside from the testing blunder, they're a good thing. I'll revise that test.
Okay, this one has tests for XUL scripts, too. Try push:
https://tbpl.mozilla.org/?tree=Try&rev=16ce16ed15a5
Attachment #8384417 - Attachment is obsolete: true
Attachment #8388863 - Flags: review?(bugs)
Comment on attachment 8388863 [details] [diff] [review]
Provide introductionType information for HTML and XUL <script> elements.

>-
>+if (false) {
Am I missing something here?
Attachment #8388863 - Flags: review?(bugs) → review-
I applied the patch and the introductionType is properly set to "scriptElement". The introductionScript is still missing (needed to complete the logic from here: bug 935203 comment 60).
Let me know if I should file a new bug for it.

Honza
(In reply to Olli Pettay [:smaug] from comment #10)
> >+if (false) {
> Am I missing something here?

I'm sorry --- that was careless. I'd diked out those tests temporarily.

Thus, the prior try push was thus kind of meaningless; here's a new one:
https://tbpl.mozilla.org/?tree=Try&rev=ff843b39690b
Revised patch.
Attachment #8388863 - Attachment is obsolete: true
Attachment #8389289 - Flags: review?(bugs)
Attachment #8389289 - Flags: review?(bugs) → review+
(In reply to Jan Honza Odvarko from comment #11)
> I applied the patch and the introductionType is properly set to
> "scriptElement". The introductionScript is still missing (needed to complete
> the logic from here: bug 935203 comment 60).
> Let me know if I should file a new bug for it.

<script> element code doesn't necessarily have an introductionScript. For example, if a <script> appears directly in the original HTML document, then there is no reasonable JS script that we can say "introduced" the element.

However, <script> element code should always have an associated 'element'. Could we synthesize names for them by looking at ownerDocument.location.href (in a content-distrustful way, of course)?
(In reply to Jim Blandy :jimb from comment #15)
> (In reply to Jan Honza Odvarko from comment #11)
> > I applied the patch and the introductionType is properly set to
> > "scriptElement". The introductionScript is still missing (needed to complete
> > the logic from here: bug 935203 comment 60).
> > Let me know if I should file a new bug for it.
> 
> <script> element code doesn't necessarily have an introductionScript. For
> example, if a <script> appears directly in the original HTML document, then
> there is no reasonable JS script that we can say "introduced" the element.
I see that make sense.

And what about having the introductionScript set only if it's created dynamically?
(could be done by dynamically created script).
This would help to compose unique URL through URL chaining (use parent script URL
that already uniquely identifies the parent script, that uses parent script URL, etc.)

There can be entire tree of dynamically created scripts and the URL can indicate what was the parent script (and grouping based on such URL chaining can simplify the UI). 

> However, <script> element code should always have an associated 'element'.
> Could we synthesize names for them by looking at ownerDocument.location.href
> (in a content-distrustful way, of course)?
Yes, that's what I am using now. The element is good for user-cross-link (Script panel -> HTML panel), but it doesn't have to have ID, the xpath is not much unique (e.g. script[2], script[3]),
so not that useful to generate URL (unless I am missing something).

Honza
> And what about having the introductionScript set only if it's created
> dynamically?
Btw. this would also help to distinguish between statically and dynamically
created scripElement scripts (which is currently impossible, or am I wrong?)

Honza
(In reply to Jan Honza Odvarko from comment #17)
> And what about having the introductionScript set only if it's created
> dynamically?
> (could be done by dynamically created script).
> This would help to compose unique URL through URL chaining (use parent
> script URL
> that already uniquely identifies the parent script, that uses parent script
> URL, etc.)
> 
> There can be entire tree of dynamically created scripts and the URL can
> indicate what was the parent script (and grouping based on such URL chaining
> can simplify the UI). 

Grouping things this way sounds like it could be nice. Filed as bug 983297.
(In reply to Jim Blandy :jimb from comment #19)
> Grouping things this way sounds like it could be nice. Filed as bug 983297.
Awesome!
Honza
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: