Reviewers: metaweta,
Description:
The value is the policy-rewritten URI, which may be inappropriate, but
it is at least a string value (and consistent with other properties).
Fixes <https://code.google.com/p/google-caja/issues/detail?id=1898>.
Please review this at https://codereview.appspot.com/99830043/
Affected files (+33, -3 lines):
M src/com/google/caja/plugin/domado.js
M tests/com/google/caja/plugin/test-domado-dom-guest.html
Index: src/com/google/caja/plugin/domado.js
===================================================================
--- src/com/google/caja/plugin/domado.js (revision 5679)
+++ src/com/google/caja/plugin/domado.js (working copy)
@@ -4607,13 +4607,16 @@
defineElement({
domClass: 'HTMLAnchorElement',
properties: function() { return {
+ // TODO(kpreid): Implement all components-of-the-URL properties
in
+ // a generic and consistently-virtualized way.
hash: PT.filter(
false,
function (value) { return unsuffix(value, idSuffix, value); },
false,
// TODO(felix8a): add suffix if href is self
identity),
- href: NP_UriValuedProperty('a', 'href')
+ href: NP_UriValuedProperty('a', 'href'),
+ pathname: PT.ROView(String)
}; }
});
Index: tests/com/google/caja/plugin/test-domado-dom-guest.html
===================================================================
--- tests/com/google/caja/plugin/test-domado-dom-guest.html (revision 5679)
+++ tests/com/google/caja/plugin/test-domado-dom-guest.html (working copy)
@@ -3221,11 +3221,11 @@
});
</script>
-<div class="testcontainer" id="testHash">
+<div class="testcontainer" id="testAnchorHash">
<a id='test-hash' href="#foo">test a.hash and hash in a.href</a>
</div>
<script type="text/javascript">
- jsunitRegister('testHash', function testHash() {
+ jsunitRegister('testAnchorHash', function testHash() {
var a = document.getElementById('test-hash');
assertEquals('#foo', a.hash);
@@ -3243,6 +3243,33 @@
});
</script>
+<div class="testcontainer" id="testAnchorPathname">
+ <a id="testAnchorPathname-a" href="http://example.invalid/path?query">
+ testAnchorPathname
+ </a>
+</div>
+<script type="text/javascript">
+ jsunitRegister('testAnchorPathname', function testHash() {
+ var a = document.getElementById('testAnchorPathname-a');
+
+ // The path of the output of the URI rewriter is "/".
+ // Seeing the rewritten URI is not actually desirable, but is
consistent
+ // with other behaviors. TODO(kpreid): Look into storing the original
+ // URI.
+ assertEquals('/', a.pathname);
+
+ // Currently do not support modifying a URL since the URI policy
rewrite
+ // is not reversible
+ expectFailure(function() {
+ a.pathname = '1';
+ }, 'Assignment fails', function(e) {
+ return e.name === 'TypeError';
+ });
+
+ pass();
+ });
+</script>
+
<div class="testcontainer" id="testBaseURI"></div>
<script type="text/javascript">
jsunitRegister('testBaseURI', function testBaseURI() {
--
---
You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.