|
1 | 1 | /** |
2 | | - * @license AngularJS v1.2.10 |
| 2 | + * @license AngularJS v1.2.12 |
3 | 3 | * (c) 2010-2014 Google, Inc. http://angularjs.org |
4 | 4 | * License: MIT |
5 | 5 | */ |
@@ -104,35 +104,37 @@ var $sanitizeMinErr = angular.$$minErr('$sanitize'); |
104 | 104 | </table> |
105 | 105 | </div> |
106 | 106 | </doc:source> |
107 | | - <doc:scenario> |
| 107 | + <doc:protractor> |
108 | 108 | it('should sanitize the html snippet by default', function() { |
109 | | - expect(using('#bind-html-with-sanitize').element('div').html()). |
| 109 | + expect(element(by.css('#bind-html-with-sanitize div')).getInnerHtml()). |
110 | 110 | toBe('<p>an html\n<em>click here</em>\nsnippet</p>'); |
111 | 111 | }); |
112 | 112 |
|
113 | 113 | it('should inline raw snippet if bound to a trusted value', function() { |
114 | | - expect(using('#bind-html-with-trust').element("div").html()). |
| 114 | + expect(element(by.css('#bind-html-with-trust div')).getInnerHtml()). |
115 | 115 | toBe("<p style=\"color:blue\">an html\n" + |
116 | 116 | "<em onmouseover=\"this.textContent='PWN3D!'\">click here</em>\n" + |
117 | 117 | "snippet</p>"); |
118 | 118 | }); |
119 | 119 |
|
120 | 120 | it('should escape snippet without any filter', function() { |
121 | | - expect(using('#bind-default').element('div').html()). |
| 121 | + expect(element(by.css('#bind-default div')).getInnerHtml()). |
122 | 122 | toBe("<p style=\"color:blue\">an html\n" + |
123 | 123 | "<em onmouseover=\"this.textContent='PWN3D!'\">click here</em>\n" + |
124 | 124 | "snippet</p>"); |
125 | 125 | }); |
126 | 126 |
|
127 | 127 | it('should update', function() { |
128 | | - input('snippet').enter('new <b onclick="alert(1)">text</b>'); |
129 | | - expect(using('#bind-html-with-sanitize').element('div').html()).toBe('new <b>text</b>'); |
130 | | - expect(using('#bind-html-with-trust').element('div').html()).toBe( |
| 128 | + element(by.model('snippet')).clear(); |
| 129 | + element(by.model('snippet')).sendKeys('new <b onclick="alert(1)">text</b>'); |
| 130 | + expect(element(by.css('#bind-html-with-sanitize div')).getInnerHtml()). |
| 131 | + toBe('new <b>text</b>'); |
| 132 | + expect(element(by.css('#bind-html-with-trust div')).getInnerHtml()).toBe( |
131 | 133 | 'new <b onclick="alert(1)">text</b>'); |
132 | | - expect(using('#bind-default').element('div').html()).toBe( |
| 134 | + expect(element(by.css('#bind-default div')).getInnerHtml()).toBe( |
133 | 135 | "new <b onclick=\"alert(1)\">text</b>"); |
134 | 136 | }); |
135 | | - </doc:scenario> |
| 137 | + </doc:protractor> |
136 | 138 | </doc:example> |
137 | 139 | */ |
138 | 140 | function $SanitizeProvider() { |
@@ -537,37 +539,38 @@ angular.module('ngSanitize', []).provider('$sanitize', $SanitizeProvider); |
537 | 539 | </tr> |
538 | 540 | </table> |
539 | 541 | </doc:source> |
540 | | - <doc:scenario> |
| 542 | + <doc:protractor> |
541 | 543 | it('should linkify the snippet with urls', function() { |
542 | | - expect(using('#linky-filter').binding('snippet | linky')). |
543 | | - toBe('Pretty text with some links: ' + |
544 | | - '<a href="http://angularjs.org/">http://angularjs.org/</a>, ' + |
545 | | - '<a href="mailto:us@somewhere.org">us@somewhere.org</a>, ' + |
546 | | - '<a href="mailto:another@somewhere.org">another@somewhere.org</a>, ' + |
547 | | - 'and one more: <a href="ftp://127.0.0.1/">ftp://127.0.0.1/</a>.'); |
| 544 | + expect(element(by.id('linky-filter')).element(by.binding('snippet | linky')).getText()). |
| 545 | + toBe('Pretty text with some links: http://angularjs.org/, us@somewhere.org, ' + |
| 546 | + 'another@somewhere.org, and one more: ftp://127.0.0.1/.'); |
| 547 | + expect(element.all(by.css('#linky-filter a')).count()).toEqual(4); |
548 | 548 | }); |
549 | 549 |
|
550 | | - it ('should not linkify snippet without the linky filter', function() { |
551 | | - expect(using('#escaped-html').binding('snippet')). |
552 | | - toBe("Pretty text with some links:\n" + |
553 | | - "http://angularjs.org/,\n" + |
554 | | - "mailto:us@somewhere.org,\n" + |
555 | | - "another@somewhere.org,\n" + |
556 | | - "and one more: ftp://127.0.0.1/."); |
| 550 | + it('should not linkify snippet without the linky filter', function() { |
| 551 | + expect(element(by.id('escaped-html')).element(by.binding('snippet')).getText()). |
| 552 | + toBe('Pretty text with some links: http://angularjs.org/, mailto:us@somewhere.org, ' + |
| 553 | + 'another@somewhere.org, and one more: ftp://127.0.0.1/.'); |
| 554 | + expect(element.all(by.css('#escaped-html a')).count()).toEqual(0); |
557 | 555 | }); |
558 | 556 |
|
559 | 557 | it('should update', function() { |
560 | | - input('snippet').enter('new http://link.'); |
561 | | - expect(using('#linky-filter').binding('snippet | linky')). |
562 | | - toBe('new <a href="http://link">http://link</a>.'); |
563 | | - expect(using('#escaped-html').binding('snippet')).toBe('new http://link.'); |
| 558 | + element(by.model('snippet')).clear(); |
| 559 | + element(by.model('snippet')).sendKeys('new http://link.'); |
| 560 | + expect(element(by.id('linky-filter')).element(by.binding('snippet | linky')).getText()). |
| 561 | + toBe('new http://link.'); |
| 562 | + expect(element.all(by.css('#linky-filter a')).count()).toEqual(1); |
| 563 | + expect(element(by.id('escaped-html')).element(by.binding('snippet')).getText()) |
| 564 | + .toBe('new http://link.'); |
564 | 565 | }); |
565 | 566 |
|
566 | 567 | it('should work with the target property', function() { |
567 | | - expect(using('#linky-target').binding("snippetWithTarget | linky:'_blank'")). |
568 | | - toBe('<a target="_blank" href="http://angularjs.org/">http://angularjs.org/</a>'); |
| 568 | + expect(element(by.id('linky-target')). |
| 569 | + element(by.binding("snippetWithTarget | linky:'_blank'")).getText()). |
| 570 | + toBe('http://angularjs.org/'); |
| 571 | + expect(element(by.css('#linky-target a')).getAttribute('target')).toEqual('_blank'); |
569 | 572 | }); |
570 | | - </doc:scenario> |
| 573 | + </doc:protractor> |
571 | 574 | </doc:example> |
572 | 575 | */ |
573 | 576 | angular.module('ngSanitize').filter('linky', ['$sanitize', function($sanitize) { |
|
0 commit comments