Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/third_party/closure/goog/html/silverlight.js
2868 views
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
/**
17
* @fileoverview SafeHtml factory methods for creating object tags for
18
* loading Silverlight files.
19
*/
20
21
goog.provide('goog.html.silverlight');
22
23
goog.require('goog.html.SafeHtml');
24
goog.require('goog.html.TrustedResourceUrl');
25
goog.require('goog.html.flash');
26
goog.require('goog.string.Const');
27
28
29
/**
30
* Attributes and param tag name attributes not allowed to be overriden
31
* when calling createObjectForSilverlight().
32
*
33
* While values that should be specified as params are probably not
34
* recognized as attributes, we block them anyway just to be sure.
35
* @const {!Array<string>}
36
* @private
37
*/
38
goog.html.silverlight.FORBIDDEN_ATTRS_AND_PARAMS_ON_SILVERLIGHT_ = [
39
'data', // Always set to a fixed value.
40
'source', // Specifies the URL for the Silverlight file.
41
'type', // Always set to a fixed value.
42
'typemustmatch' // Always set to a fixed value.
43
];
44
45
46
/**
47
* Creates a SafeHtml representing an object tag, for loading Silverlight files.
48
*
49
* The following attributes are set to these fixed values:
50
* - data: data:application/x-silverlight-2,
51
* - type: application/x-silverlight-2
52
* - typemustmatch: "" (the empty string, meaning true for a boolean attribute)
53
*
54
* @param {!goog.html.TrustedResourceUrl} source The value of the source param.
55
* @param {?Object<string, string>=} opt_params Mapping used to generate child
56
* param tags. Each tag has a name and value attribute, as defined in
57
* mapping. Only names consisting of [a-zA-Z0-9-] are allowed. Value of
58
* null or undefined causes the param tag to be omitted.
59
* @param {?Object<string, ?goog.html.SafeHtml.AttributeValue>=} opt_attributes
60
* Mapping from other attribute names to their values. Only attribute names
61
* consisting of [a-zA-Z0-9-] are allowed. Value of null or undefined causes
62
* the attribute to be omitted.
63
* @return {!goog.html.SafeHtml} The SafeHtml content with the object tag.
64
* @throws {Error} If invalid attribute or param name, or attribute or param
65
* value is provided. Also if opt_attributes or opt_params contains any of
66
* the attributes set to fixed values, documented above, or contains source.
67
*
68
*/
69
goog.html.silverlight.createObject = function(
70
source, opt_params, opt_attributes) {
71
goog.html.flash.verifyKeysNotInMaps(
72
goog.html.silverlight.FORBIDDEN_ATTRS_AND_PARAMS_ON_SILVERLIGHT_,
73
opt_attributes, opt_params);
74
75
// We don't set default for Silverlight's EnableHtmlAccess and
76
// AllowHtmlPopupwindow because their default changes depending on whether
77
// a file loaded from the same domain.
78
var paramTags = goog.html.flash.combineParams({'source': source}, opt_params);
79
var fixedAttributes = {
80
'data': goog.html.TrustedResourceUrl.fromConstant(
81
goog.string.Const.from('data:application/x-silverlight-2,')),
82
'type': 'application/x-silverlight-2',
83
'typemustmatch': ''
84
};
85
var attributes =
86
goog.html.SafeHtml.combineAttributes(fixedAttributes, {}, opt_attributes);
87
88
return goog.html.SafeHtml.createSafeHtmlTagSecurityPrivateDoNotAccessOrElse(
89
'object', attributes, paramTags);
90
};
91
92