-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement HTMLScriptElement.supports(type) method
Bug: 1245528, whatwg/html#6472 Change-Id: I9a902504cf692caa73ae7e49fd65895156bbf197 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3133553 Commit-Queue: Tsuyoshi Horo <horo@chromium.org> Reviewed-by: Hiroshige Hayashizaki <hiroshige@chromium.org> Cr-Commit-Position: refs/heads/main@{#918474}
- Loading branch information
1 parent
6f5c3e7
commit e02f4a5
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
html/semantics/scripting-1/the-script-element/script-supports.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>HTMLScriptElement.supports</title> | ||
<link rel=help href="https://html.spec.whatwg.org/#dom-script-supports"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
test(function() { | ||
assert_equals(typeof HTMLScriptElement.supports, 'function'); | ||
}, 'Type of HTMLScriptElement.supports is function'); | ||
|
||
test(function() { | ||
assert_true(HTMLScriptElement.supports('classic')); | ||
}, 'HTMLScriptElement.supports resurns true for \'classic\''); | ||
|
||
test(function() { | ||
assert_true(HTMLScriptElement.supports('module')); | ||
}, 'HTMLScriptElement.supports resurns true for \'module\''); | ||
|
||
test(function() { | ||
assert_false(HTMLScriptElement.supports('application/ecmascript')); | ||
assert_false(HTMLScriptElement.supports('application/javascript')); | ||
assert_false(HTMLScriptElement.supports('application/x-ecmascript')); | ||
assert_false(HTMLScriptElement.supports('application/x-javascript')); | ||
assert_false(HTMLScriptElement.supports('text/ecmascript')); | ||
assert_false(HTMLScriptElement.supports('text/javascript')); | ||
assert_false(HTMLScriptElement.supports('text/javascript1.0')); | ||
assert_false(HTMLScriptElement.supports('text/javascript1.1')); | ||
assert_false(HTMLScriptElement.supports('text/javascript1.2')); | ||
assert_false(HTMLScriptElement.supports('text/javascript1.3')); | ||
assert_false(HTMLScriptElement.supports('text/javascript1.4')); | ||
assert_false(HTMLScriptElement.supports('text/javascript1.5')); | ||
assert_false(HTMLScriptElement.supports('text/jscript')); | ||
assert_false(HTMLScriptElement.supports('text/livescript')); | ||
assert_false(HTMLScriptElement.supports('text/x-ecmascript')); | ||
assert_false(HTMLScriptElement.supports('text/x-javascript')); | ||
}, 'HTMLScriptElement.supports returns false for JavaScript MIME types'); | ||
|
||
test(function() { | ||
assert_false(HTMLScriptElement.supports('')); | ||
assert_false(HTMLScriptElement.supports(' ')); | ||
assert_false(HTMLScriptElement.supports('classic ')); | ||
assert_false(HTMLScriptElement.supports('module ')); | ||
assert_false(HTMLScriptElement.supports(' classic ')); | ||
assert_false(HTMLScriptElement.supports(' module ')); | ||
assert_false(HTMLScriptElement.supports('classics')); | ||
assert_false(HTMLScriptElement.supports('modules')); | ||
assert_false(HTMLScriptElement.supports('Classic')); | ||
assert_false(HTMLScriptElement.supports('Module')); | ||
assert_false(HTMLScriptElement.supports('unsupported')); | ||
}, 'HTMLScriptElement.supports returns false for unsupported types'); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<title>HTMLScriptElement.supports importmap</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
test(function() { | ||
assert_true(HTMLScriptElement.supports('importmap')); | ||
}, 'HTMLScriptElement.supports returns true for \'importmap\''); | ||
|
||
test(function() { | ||
assert_false(HTMLScriptElement.supports(' importmap')); | ||
assert_false(HTMLScriptElement.supports('importmap ')); | ||
assert_false(HTMLScriptElement.supports('Importmap')); | ||
assert_false(HTMLScriptElement.supports('ImportMap')); | ||
assert_false(HTMLScriptElement.supports('importMap')); | ||
assert_false(HTMLScriptElement.supports('import-map')); | ||
assert_false(HTMLScriptElement.supports('importmaps')); | ||
assert_false(HTMLScriptElement.supports('import-maps')); | ||
}, 'HTMLScriptElement.supports returns false for unsupported types'); | ||
|
||
</script> |