Permalink
Browse files

Use Trusted Types externs.

I've ported https://cs.chromium.org/lang:idl%20%5Cb(HTML%7CScript%7CScriptURL%7CURL)String%5Cb here.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=231185103
  • Loading branch information...
vrana authored and tjgq committed Jan 28, 2019
1 parent 4028470 commit 0aee97d3f0d0b5da5531a0f300c75498cb79a3bb
@@ -550,14 +550,14 @@ Document.prototype.queryCommandValue;

/**
* @see https://developer.mozilla.org/en/DOM/document.write
* @param {string} text
* @param {!TrustedHTML|string} text
* @return {undefined}
*/
Document.prototype.write = function(text) {};

/**
* @see https://developer.mozilla.org/en/DOM/document.writeln
* @param {string} text
* @param {!TrustedHTML|string} text
* @return {undefined}
*/
Document.prototype.writeln = function(text) {};
@@ -577,7 +577,7 @@ Document.prototype.getBoxObjectFor = function(element) {};
// http://lxr.mozilla.org/mozilla1.8/source/dom/public/idl/range/nsIDOMNSRange.idl

/**
* @param {string} tag
* @param {!TrustedHTML|string} tag
* @return {DocumentFragment}
*/
Range.prototype.createContextualFragment;
@@ -66,7 +66,7 @@ function DOMParser() {}
* var parser = new DOMParser();
* var doc = parser.parseFromString(aStr, "text/xml");
*
* @param {string} src The UTF16 string to be parsed.
* @param {!TrustedHTML|string} src The UTF16 string to be parsed.
* @param {string} type The content type of the string.
* @return {Document}
*/
@@ -1272,14 +1272,14 @@ Window.prototype.applicationCache;

/**
* @see https://developer.mozilla.org/En/DOM/Worker/Functions_available_to_workers
* @param {...string} var_args
* @param {...!TrustedScriptURL|string} var_args
* @return {undefined}
*/
Window.prototype.importScripts = function(var_args) {};

/**
* @see https://developer.mozilla.org/En/DOM/Worker/Functions_available_to_workers
* @param {...string} var_args
* @param {...!TrustedScriptURL|string} var_args
* @return {undefined}
*/
function importScripts(var_args) {}
@@ -1727,6 +1727,7 @@ HTMLAreaElement.prototype.ping;

/**
* @type {string}
* @implicitCast
* @see http://www.w3.org/TR/html-markup/iframe.html#iframe.attrs.srcdoc
*/
HTMLIFrameElement.prototype.srcdoc;
@@ -1843,7 +1844,7 @@ HTMLMediaElement.HAVE_ENOUGH_DATA; // = 4
/** @type {MediaError} */
HTMLMediaElement.prototype.error;

/** @type {string} */
/** @type {string} @implicitCast */
HTMLMediaElement.prototype.src;

/** @type {string} */
@@ -3458,6 +3459,7 @@ HTMLButtonElement.prototype.setCustomValidity = function(message) {};

/**
* @type {string}
* @implicitCast
* @see http://www.w3.org/TR/html5/forms.html#attr-fs-formaction
*/
HTMLButtonElement.prototype.formAction;
@@ -3488,6 +3490,7 @@ HTMLInputElement.prototype.formNoValidate;

/**
* @type {string}
* @implicitCast
* @see http://www.w3.org/TR/html5/forms.html#attr-fs-formaction
*/
HTMLInputElement.prototype.formAction;
@@ -3639,6 +3642,7 @@ HTMLEmbedElement.prototype.height;

/**
* @type {string}
* @implicitCast
* @see http://www.w3.org/TR/html5/the-embed-element.html#dom-embed-src
*/
HTMLEmbedElement.prototype.src;
@@ -4013,6 +4017,7 @@ ShadowRoot.prototype.olderShadowRoot;

/**
* @type {string}
* @implicitCast
*/
ShadowRoot.prototype.innerHTML;

@@ -4134,7 +4139,7 @@ HTMLSourceElement.prototype.media;
/** @type {string} */
HTMLSourceElement.prototype.sizes;

/** @type {string} */
/** @type {string} @implicitCast */
HTMLSourceElement.prototype.src;

/** @type {string} */
@@ -4528,7 +4533,7 @@ function HTMLTrackElement() {}
HTMLTrackElement.prototype.kind;


/** @type {string} */
/** @type {string} @implicitCast */
HTMLTrackElement.prototype.src;


@@ -179,7 +179,7 @@ Node.prototype.document;
* Inserts the given HTML text into the element at the location.
* @param {string} sWhere Where to insert the HTML text, one of 'beforeBegin',
* 'afterBegin', 'beforeEnd', 'afterEnd'.
* @param {string} sText HTML text to insert.
* @param {!TrustedHTML|string} sText HTML text to insert.
* @see http://msdn.microsoft.com/en-us/library/ms536452(VS.85).aspx
* @return {undefined}
*/
@@ -1123,6 +1123,7 @@ Element.prototype.onselectstart;

/**
* @type {string}
* @implicitCast
* @see http://msdn.microsoft.com/en-us/library/aa752326(VS.85).aspx
*/
Element.prototype.outerHTML;
@@ -1260,6 +1261,7 @@ Location.prototype.hostname;

/**
* @see http://msdn.microsoft.com/en-us/library/ms533867(VS.85).aspx
* @implicitCast
* @type {string}
*/
Location.prototype.href;
@@ -1296,7 +1298,7 @@ Location.prototype.search;

/**
* @see http://msdn.microsoft.com/en-us/library/ms536342(VS.85).aspx
* @param {string} url
* @param {!TrustedURL|string} url
* @return {undefined}
*/
Location.prototype.assign = function(url) {};
@@ -1310,7 +1312,7 @@ Location.prototype.assign = function(url) {};
Location.prototype.reload = function(opt_forceReload) {};

/**
* @param {string} url
* @param {!TrustedURL|string} url
* @see http://msdn.microsoft.com/en-us/library/ms536712(VS.85).aspx
* @return {undefined}
*/
@@ -258,15 +258,15 @@ HTMLDocument.prototype.open = function(opt_mimeType, opt_replace) {};
HTMLDocument.prototype.close = function() {};

/**
* @param {string} text
* @param {!TrustedHTML|string} text
* @return {undefined}
* @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-75233634
* @override
*/
HTMLDocument.prototype.write = function(text) {};

/**
* @param {string} text
* @param {!TrustedHTML|string} text
* @return {undefined}
* @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-35318390
* @override
@@ -518,6 +518,7 @@ HTMLLinkElement.prototype.charset;

/**
* @type {string}
* @implicitCast
* @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-33532588
*/
HTMLLinkElement.prototype.href;
@@ -614,6 +615,7 @@ function HTMLBaseElement() {}

/**
* @type {string}
* @implicitCast
* @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-65382887
*/
HTMLBaseElement.prototype.href;
@@ -768,6 +770,7 @@ HTMLFormElement.prototype.acceptCharset;

/**
* @type {string}
* @implicitCast
* @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-74049184
*/
HTMLFormElement.prototype.action;
@@ -1062,6 +1065,7 @@ HTMLInputElement.prototype.size;

/**
* @type {string}
* @implicitCast
* @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-97320704
*/
HTMLInputElement.prototype.src;
@@ -1639,6 +1643,7 @@ HTMLAnchorElement.prototype.coords;

/**
* @type {string}
* @implicitCast
* @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-88517319
*/
HTMLAnchorElement.prototype.href;
@@ -1824,6 +1829,7 @@ HTMLObjectElement.prototype.code;

/**
* @type {string}
* @implicitCast
* @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-25709136
*/
HTMLObjectElement.prototype.codeBase;
@@ -1842,6 +1848,7 @@ HTMLObjectElement.prototype.contentDocument;

/**
* @type {string}
* @implicitCast
* @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-81766986
*/
HTMLObjectElement.prototype.data;
@@ -2066,6 +2073,7 @@ HTMLAreaElement.prototype.coords;

/**
* @type {string}
* @implicitCast
* @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-34672936
*/
HTMLAreaElement.prototype.href;
@@ -2132,12 +2140,14 @@ HTMLScriptElement.prototype.onreadystatechange;

/**
* @type {string}
* @implicitCast
* @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-75147231
*/
HTMLScriptElement.prototype.src;

/**
* @type {string}
* @implicitCast
* @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-46872999
*/
HTMLScriptElement.prototype.text;
@@ -2642,6 +2652,7 @@ HTMLFrameElement.prototype.scrolling;

/**
* @type {string}
* @implicitCast
* @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-78799535
*/
HTMLFrameElement.prototype.src;
@@ -2710,6 +2721,7 @@ HTMLIFrameElement.prototype.scrolling;

/**
* @type {string}
* @implicitCast
* @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-43933957
*/
HTMLIFrameElement.prototype.src;
@@ -0,0 +1,92 @@
/*
* Copyright 2018 The Closure Compiler Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* @fileoverview Definitions for W3C's Trusted Types specification.
* @see https://github.com/WICG/trusted-types
* @externs
*/


/** @constructor */
function TrustedHTML() {}

/** @constructor */
function TrustedScript() {}

/** @constructor */
function TrustedScriptURL() {}

/** @constructor */
function TrustedURL() {}


/** @constructor */
function TrustedTypePolicy() {}

/**
* @param {string} s
* @return {!TrustedHTML}
*/
TrustedTypePolicy.prototype.createHTML = function(s) {};

/**
* @param {string} s
* @return {!TrustedScript}
*/
TrustedTypePolicy.prototype.createScript = function(s) {};

/**
* @param {string} s
* @return {!TrustedScriptURL}
*/
TrustedTypePolicy.prototype.createScriptURL = function(s) {};

/**
* @param {string} s
* @return {!TrustedURL}
*/
TrustedTypePolicy.prototype.createURL = function(s) {};


/** @constructor */
function TrustedTypePolicyFactory() {}

/**
* @param {string} name
* @param {{
* createHTML: function(string): string,
* createScript: function(string): string,
* createScriptURL: function(string): string,
* createURL: function(string): string}} policy
* @param {boolean=} opt_expose
* @return {!TrustedTypePolicy}
*/
TrustedTypePolicyFactory.prototype.createPolicy = function(
name, policy, opt_expose) {};

/**
* @param {string} name
* @return {!TrustedTypePolicy}
*/
TrustedTypePolicyFactory.prototype.getExposedPolicy = function(name) {};

/** @return {!Array<string>} */
TrustedTypePolicyFactory.prototype.getPolicyNames = function() {};


/** @type {!TrustedTypePolicyFactory} */
var TrustedTypes;
@@ -189,7 +189,7 @@ function prompt(message, opt_value) {}
function setImmediate(callback, var_args) {}

/**
* @param {Function|string} callback
* @param {Function|!TrustedScript|string} callback
* @param {number=} opt_delay
* @param {...?} var_args
* @return {number}
@@ -199,7 +199,7 @@ function setImmediate(callback, var_args) {}
function setInterval(callback, opt_delay, var_args) {}

/**
* @param {Function|string} callback
* @param {Function|!TrustedScript|string} callback
* @param {number=} opt_delay
* @param {...*} var_args
* @return {number}

Large diffs are not rendered by default.

Oops, something went wrong.

0 comments on commit 0aee97d

Please sign in to comment.