#11277 closed defect (fixed)
Unexpected results using add_script with network-path references
| Reported by: | Owned by: | ||
|---|---|---|---|
| Priority: | normal | Milestone: | 1.0.2 |
| Component: | general | Version: | 1.1.1dev |
| Severity: | minor | Keywords: | patch, http link uri url |
| Cc: | Branch: | ||
| Release Notes: |
Network-path references (URLs starting with |
||
| API Changes: |
Network-path references (URLs starting with |
||
| Internal Changes: | |||
Description
During the last years network-path references are used more often due to the popularity of CDN solutions, the deployment of http/https/spdy/… and some issues in browsers (particularly MSIE) when switching to a different scheme to retrieve linked resources.
When trying to use add_script (or similar) function with network-path references this is what I get
>>> from wsgiref.util import setup_testing_defaults >>> environ = {} >>> setup_testing_defaults(environ) >>> from trac.web.api import Request >>> req = Request(environ, lambda *args, **kwargs: None) >>> req.locale = None >>> from trac.env import open_environment as oe >>> env = oe('/srv/trac/cleanmp') >>> from trac.web.chrome import Chrome >>> from trac.web import chrome >>> req.callbacks['chrome'] = chrome.Chrome(env).prepare_request >>> chrome.add_script(req, '//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js') >>> from pprint import pprint >>> pprint(req.chrome['scripts']) [{'charset': 'utf-8', 'href': '/chrome/common/js/jquery.js', 'prefix': None, 'suffix': None, 'type': 'text/javascript'}, {'charset': 'utf-8', 'href': '/chrome/common/js/babel.js', 'prefix': None, 'suffix': None, 'type': 'text/javascript'}, {'charset': 'utf-8', 'href': '/chrome/common/js/trac.js', 'prefix': None, 'suffix': None, 'type': 'text/javascript'}, {'charset': 'utf-8', 'href': '/chrome/common/js/search.js', 'prefix': None, 'suffix': None, 'type': 'text/javascript'}, {'charset': 'utf-8', 'href': '/ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js', 'prefix': None, 'suffix': None, 'type': 'text/javascript'}]
As can be seen it will not be expanded correctly.
N.B. Version in /trunk is 1.1.2 but I did not see such option in versions selector .
Attachments (0)
Change History (7)
comment:1 by , 12 years ago
| Keywords: | uri url added |
|---|---|
| Summary: | Unexpected results using Href with network-path references → Unexpected results using add_script with network-path references |
comment:2 by , 12 years ago
comment:3 by , 12 years ago
| Milestone: | → 1.0.2 |
|---|---|
| Owner: | set to |
| Status: | new → assigned |
I've tested the changes and everything looks good: rjollos.git:t11277.
The major question I have for the other Trac devs is about the naming of the function _chrome_resource_path - maybe someone will come up with a better function name - and whether the function should be public or private. I've made it private since it didn't seem very useful outside of the chrome module.
comment:5 by , 12 years ago
| API Changes: | modified (diff) |
|---|---|
| Release Notes: | modified (diff) |
| Resolution: | → fixed |
| Status: | assigned → closed |
Committed to 1.0-stable in [11975-11976]. Merged to trunk in [11977].



After applying this patch expected results are obtained