Debian Codegraph @

closure-library/closure/goog/html/silverlight_test.js

raw
1 // Copyright 2014 The Closure Library Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS-IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 /**
16 * @fileoverview Unit tests for goog.html.silverlight.
17 */
18
19 goog.provide('goog.html.silverlightTest');
20
21 goog.require('goog.html.SafeHtml');
22 goog.require('goog.html.TrustedResourceUrl');
23 goog.require('goog.html.silverlight');
24 goog.require('goog.string.Const');
25 goog.require('goog.testing.jsunit');
26
27 goog.setTestOnly('goog.html.silverlightTest');
28
29
30 function testCreateObjectForSilverlight() {
31 var trustedResourceUrl = goog.html.TrustedResourceUrl.fromConstant(
32 goog.string.Const.from('https://google.com/trusted&'));
33 assertSameHtml(
34 '<object data="data:application/x-silverlight-2," ' +
35 'type="application/x-silverlight-2" typemustmatch="" ' +
36 'class="test&lt;">' +
37 '<param name="source" value="https://google.com/trusted&amp;">' +
38 '<param name="onload" value="onload&lt;">' +
39 '</object>',
40 goog.html.silverlight.createObject(
41 trustedResourceUrl, {'onload': 'onload<'}, {'class': 'test<'}));
42
43 // Cannot override params, case insensitive.
44 assertThrows(function() {
45 goog.html.silverlight.createObject(
46 trustedResourceUrl, {'datA': 'cantdothis'});
47 });
48
49 // Cannot override attributes, case insensitive.
50 assertThrows(function() {
51 goog.html.silverlight.createObject(
52 trustedResourceUrl, {}, {'datA': 'cantdothis'});
53 });
54 }
55
56
57 function assertSameHtml(expected, html) {
58 assertEquals(expected, goog.html.SafeHtml.unwrap(html));
59 }