This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 216421 - Dynamically added <script> with external src not listed in Remote Files
Summary: Dynamically added <script> with external src not listed in Remote Files
Status: NEW
Alias: None
Product: web
Classification: Unclassified
Component: HTML Project (show other bugs)
Version: 7.3
Hardware: PC Linux
: P3 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-06 07:11 UTC by Vladimir Riha
Modified: 2013-12-12 06:16 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Riha 2012-08-06 07:11:42 UTC
I'm not sure if this should work or how often it is used, but if I create dynamically <script> with external src, it is not listed in Remote Files. The same happens if you create iframe with some external page (e.g. netbeans.org)

Code snippet:
...
<input type="button" value="Create script" onclick="loadScript('http://netbeans.org/images_www/js/switcher.js')"/>
...
 <script id="emptyScript" src=""></script>
<script>
function loadScript(src){
  $("#emptyScript").attr("src", src);
  // because following breaks editor - #216420
  // $("document").append("<script src='"+src+"'>< /script>");
}
</script>
...


Product Version: NetBeans IDE Dev (Build EaselCSS-441-on-20120805)
Java: 1.7.0_06-ea; Java HotSpot(TM) Client VM 23.2-b09
System: Linux version 3.0.0-23-generic running on i386; UTF-8; en_US (nb)
Comment 1 David Konecny 2012-08-07 20:17:29 UTC
The problem is that unless such JS code is executed we have no idea what's being loaded. Similar case is if user is using a JS library like RequireJS.

There is one way how we could improve this. When a file is run in Chrome or WebView then WebKit protocol tells us all JavaScripts it loaded in runtime. And we could cache those in project private settings and add them to Remote Files node. The problems of this solution to be aware of are:

* before project is run (and *all* its JavaScript code from all possible project's files) not all remote JS files will be listed in Remote Files node

* cache of these dynamically loaded remote JS files may become stale - we would not know that some remote file is not in use anymore

Do you think it would be worth to implement this? Or would it be easier to say that only *statically* referenced JS files are shown under Remote Files?
Comment 2 Vladimir Riha 2012-08-08 07:28:44 UTC
If you say that Remote files are not  only for "statically" declared scripts, then the first problem you mentioned would be expected behavior from my point of view. 

(In reply to comment #1)
> * cache of these dynamically loaded remote JS files may become stale - we would
> not know that some remote file is not in use anymore

That could be solved if Remote files node would have some context menu with action like Refresh that would delete all dynamically added scripts and load only the statically referenced. 

What is the current approach with refreshing Remote Files? Are they cached (the content of files, not list), if so is there a way to refresh them?
Comment 3 David Konecny 2012-08-08 19:04:37 UTC
Refresh action would solve it. That's a good idea. At the moment remote files are build from indexing data build by parsing API so it is accurate and up to date all the time.
Comment 4 David Konecny 2013-07-24 23:50:32 UTC
I think this is Enhancement rather than Defect. Would you agree?
Comment 5 Vladimir Riha 2013-07-25 05:59:34 UTC
Sure, no problem
Comment 6 Tomas Mysik 2013-12-12 06:16:05 UTC
Taking over.