Update web-platform-tests to revision 093a97b6ecc6484c201d704d38b47bef1964d59d
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
|
||||
<link rel="help" href="https://www.w3.org/TR/css-sizing-3/#sizing-values">
|
||||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
|
||||
<div id="container" data-expected-width="100" style="width:fit-content; min-width:100px; height:100px; background:red;">
|
||||
<div data-expected-width="100" style="width:fit-content; min-width:100%; height:100px; background:green;"></div>
|
||||
</div>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/check-layout-th.js"></script>
|
||||
<script>
|
||||
checkLayout("#container");
|
||||
</script>
|
|
@ -8,9 +8,10 @@
|
|||
<meta name="assert" content="A Single leading white-space constitutes a soft breaking opportunity, honoring the 'white-space: pre-wrap' property, that must prevent the word to be broken.">
|
||||
<style>
|
||||
div {
|
||||
position: relative;
|
||||
font-size: 20px;
|
||||
font-family: Ahem;
|
||||
position: relative;
|
||||
font-size: 20px;
|
||||
font-family: Ahem;
|
||||
line-height: 1em;
|
||||
}
|
||||
.red {
|
||||
position: absolute;
|
||||
|
@ -22,7 +23,6 @@ div {
|
|||
}
|
||||
.test {
|
||||
color: green;
|
||||
line-height: 1em;
|
||||
width: 5ch;
|
||||
|
||||
white-space: pre-wrap;
|
||||
|
|
|
@ -9,9 +9,10 @@
|
|||
<meta name="assert" content="A Single leading white-space constitutes a soft breaking opportunity, honoring the 'white-space: pre-wrap' property, that must prevent the word to be broken.">
|
||||
<style>
|
||||
div {
|
||||
position: relative;
|
||||
font-size: 20px;
|
||||
font-family: Ahem;
|
||||
position: relative;
|
||||
font-size: 20px;
|
||||
font-family: Ahem;
|
||||
line-height: 1em;
|
||||
}
|
||||
.fail {
|
||||
position: absolute;
|
||||
|
@ -21,7 +22,6 @@ div {
|
|||
span { color: green; }
|
||||
.test {
|
||||
color: green;
|
||||
line-height: 1em;
|
||||
width: 5ch;
|
||||
|
||||
white-space: pre-wrap;
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<title>CSS Text Test: overflow-wrap: break-word</title>
|
||||
<link rel="author" title="Koji Ishii" href="kojii@chromium.org">
|
||||
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-overflow-wrap-break-word">
|
||||
<link rel="match" href="reference/overflow-wrap-break-word-span-001-ref.html">
|
||||
<meta name="assert" content="Test when the `break-word` value is applied to an inline element.">
|
||||
<style>
|
||||
div {
|
||||
font-size: 10px;
|
||||
line-height: 1;
|
||||
width: 8ch;
|
||||
}
|
||||
span {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
</style>
|
||||
<div>12345<span>67890</span></div>
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<title>CSS Text Test: overflow-wrap: break-word</title>
|
||||
<link rel="author" title="Koji Ishii" href="kojii@chromium.org">
|
||||
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-overflow-wrap-break-word">
|
||||
<meta name="assert" content="Test when the `break-word` value is applied to an inline element.">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/check-layout-th.js"></script><style>
|
||||
div {
|
||||
font-size: 10px;
|
||||
line-height: 1;
|
||||
width: 5ch;
|
||||
}
|
||||
span {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
</style>
|
||||
<div id=container data-expected-height=20>12345678<span>90</span></div>
|
||||
|
||||
<script>
|
||||
checkLayout('#container')
|
||||
</script>
|
|
@ -0,0 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<style>
|
||||
div {
|
||||
font-size: 10px;
|
||||
line-height: 1;
|
||||
}
|
||||
</style>
|
||||
<div>12345678<br>90</div>
|
|
@ -6,7 +6,7 @@
|
|||
<link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com">
|
||||
<link rel="help" href="https://drafts.csswg.org/css-contain/#containment-layout">
|
||||
<link rel="help" href="https://drafts.csswg.org/css-flexbox-1/#valdef-align-items-baseline">
|
||||
<link rel="match" href="contain-layout-suppress-baseline-001-ref.html">
|
||||
<link rel="match" href="contain-layout-suppress-baseline-002-ref.html">
|
||||
<style>
|
||||
.flexBaselineCheck {
|
||||
display: flex;
|
||||
|
|
|
@ -32,7 +32,7 @@ for example:
|
|||
The test can then do different things based on the URL.
|
||||
|
||||
There are two utility scripts in that work well together with variants,
|
||||
`/common /subset-tests.js` and `/common/subset-tests-by- key.js`, where
|
||||
`/common/subset-tests.js` and `/common/subset-tests-by-key.js`, where
|
||||
a test that would otherwise have too many tests to be useful can be
|
||||
split up in ranges of subtests. For example:
|
||||
|
||||
|
|
|
@ -65,12 +65,22 @@
|
|||
async_test(function(t) {
|
||||
clickTimeMin = performance.now();
|
||||
clickAndBlockMain('button');
|
||||
// Use a dummy observer to know when both clicks have been dispatched.
|
||||
const observerPromise = new Promise((resolve, reject) => {
|
||||
let entryCount = 0;
|
||||
new PerformanceObserver(entryList => {
|
||||
entryCount += entryList.getEntries().length;
|
||||
if (entryCount >= 2)
|
||||
resolve();
|
||||
}).observe({ entryTypes: ['event'] });
|
||||
});
|
||||
// Event handlers will be dispatched asynchronously, so this will be called
|
||||
// before processing begins.
|
||||
processingStartMin = performance.now();
|
||||
on_event(window, 'load', e => {
|
||||
onloadStart = performance.now();
|
||||
clickAndBlockMain('button').then(wait).then(
|
||||
const clickPromise = clickAndBlockMain('button');
|
||||
Promise.all([observerPromise, clickPromise]).then(
|
||||
t.step_func_done(validateEntries));
|
||||
});
|
||||
}, "Event Timing: click, onload.");
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
if (numEventsObserved >= 2) {
|
||||
assert_equals(performance.getEntriesByType('event').length, 0,
|
||||
"There should be no buffered event entries.");
|
||||
assert_equals(performance.getEntriesByType('firstInput').length, 0,
|
||||
"There should be no buffered firstInput entries.");
|
||||
assert_equals(performance.getEntriesByType('firstInput').length, 1,
|
||||
"There should be a buffered firstInput entry.");
|
||||
// There should be 2 event entries and one firstInput entry.
|
||||
assert_equals(numEventsObserved, 2,
|
||||
"There should be 2 observed event entries.");
|
||||
|
@ -42,8 +42,8 @@
|
|||
}
|
||||
})).observe({ entryTypes: ['event', 'firstInput'] });
|
||||
on_event(window, 'load', () => {
|
||||
clickAndBlockMain('button').then(wait).then(() => {
|
||||
clickAndBlockMain('button').then(wait);
|
||||
clickAndBlockMain('button').then(() => {
|
||||
clickAndBlockMain('button');
|
||||
});
|
||||
});
|
||||
},
|
||||
|
|
|
@ -61,16 +61,22 @@ registration are lost
|
|||
(Dispatch and Process Click 2 (not buffered, observed))
|
||||
*/
|
||||
async_test(function(t) {
|
||||
on_event(window, 'load', () => {
|
||||
clickAndBlockMain('button').then(() => {
|
||||
startObserver(t);
|
||||
clickAndBlockMain('button').then(wait);
|
||||
processingStartMin = performance.now();
|
||||
});
|
||||
// Use a dummy observer to know when the first click has been dispatched.
|
||||
const observerPromise = new Promise((resolve, reject) => {
|
||||
new PerformanceObserver((entryList, observer) => {
|
||||
resolve();
|
||||
observer.disconnect();
|
||||
}).observe({ entryTypes: ['event'] });
|
||||
});
|
||||
on_event(window, 'load', () => {
|
||||
const clickPromise = clickAndBlockMain('button');
|
||||
Promise.all([observerPromise, clickPromise]).then(() => {
|
||||
startObserver(t);
|
||||
clickAndBlockMain('button');
|
||||
processingStartMin = performance.now();
|
||||
});
|
||||
},
|
||||
"Event Timing: onload, click, observer, click."
|
||||
);
|
||||
});
|
||||
},"Event Timing: onload, click, observer, click.");
|
||||
|
||||
</script>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta charset=utf-8 />
|
||||
<title>Event Timing: firstInput entry should be buffered even without observer</title>
|
||||
<button id='button'>Generate a 'click' event</button>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=/resources/testdriver.js></script>
|
||||
<script src=/resources/testdriver-vendor.js></script>
|
||||
|
||||
<script src=resources/event-timing-support.js></script>
|
||||
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
function testEntries() {
|
||||
// First callback is not ensured to have the entry.
|
||||
if (performance.getEntriesByType('firstInput').length === 0) {
|
||||
t.step_timeout(testEntries, 10);
|
||||
return;
|
||||
}
|
||||
assert_equals(performance.getEntriesByType('firstInput').length, 1,
|
||||
"There should be a firstInput entry in the performance timeline");
|
||||
const entry = performance.getEntriesByType('firstInput')[0];
|
||||
assert_equals(entry.name, 'click');
|
||||
assert_equals(entry.entryType, 'firstInput');
|
||||
assert_greater_than(entry.duration, 50,
|
||||
"The first input was a long one.");
|
||||
t.done();
|
||||
}
|
||||
clickAndBlockMain('button').then(wait).then(t.step_func(testEntries));
|
||||
},
|
||||
"Event Timing: check firstInput after onload, observer, click, click."
|
||||
);
|
||||
</script>
|
||||
</html>
|
18
tests/wpt/web-platform-tests/event-timing/idlharness.any.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
// META: global=window,worker
|
||||
// META: script=/resources/WebIDLParser.js
|
||||
// META: script=/resources/idlharness.js
|
||||
|
||||
// https://wicg.github.io/event-timing/
|
||||
|
||||
'use strict';
|
||||
|
||||
idl_test(
|
||||
['event-timing'],
|
||||
['performance-timeline', 'hr-time', 'dom'],
|
||||
idl_array => {
|
||||
idl_array.add_objects({
|
||||
Performance: ['performance'],
|
||||
// PerformanceEventTiming: [ TODO ]
|
||||
});
|
||||
}
|
||||
);
|
18
tests/wpt/web-platform-tests/interfaces/event-timing.idl
Normal file
|
@ -0,0 +1,18 @@
|
|||
// GENERATED CONTENT - DO NOT EDIT
|
||||
// Content was automatically extracted by Reffy into reffy-reports
|
||||
// (https://github.com/tidoust/reffy-reports)
|
||||
// Source: Event Timing API (https://wicg.github.io/event-timing/)
|
||||
|
||||
interface PerformanceEventTiming : PerformanceEntry {
|
||||
readonly attribute DOMHighResTimeStamp processingStart;
|
||||
readonly attribute DOMHighResTimeStamp processingEnd;
|
||||
readonly attribute boolean cancelable;
|
||||
};
|
||||
|
||||
interface EventCounts {
|
||||
readonly maplike<DOMString, unsigned long>;
|
||||
};
|
||||
|
||||
partial interface Performance {
|
||||
readonly attribute EventCounts eventCounts;
|
||||
};
|
|
@ -28,12 +28,12 @@ partial interface Navigator {
|
|||
[SecureContext, SameObject] readonly attribute NFC nfc;
|
||||
};
|
||||
|
||||
typedef (DOMString or ArrayBuffer or NFCMessage) NFCPushMessage;
|
||||
typedef (DOMString or ArrayBuffer or NFCMessage) NFCMessageSource;
|
||||
|
||||
[SecureContext]
|
||||
interface NFC {
|
||||
Promise<void> push(NFCPushMessage message, optional NFCPushOptions options);
|
||||
Promise<long> watch(MessageCallback callback, optional NFCWatchOptions options);
|
||||
Promise<void> push(NFCMessageSource message, optional NFCPushOptions options);
|
||||
Promise<void> watch(MessageCallback callback, optional NFCWatchOptions options);
|
||||
};
|
||||
|
||||
callback MessageCallback = void (NFCMessage message);
|
||||
|
|
|
@ -45,7 +45,7 @@ enum XREnvironmentBlendMode {
|
|||
attribute XRLayer baseLayer;
|
||||
|
||||
// Methods
|
||||
Promise<XRFrameOfReference> requestFrameOfReference(XRFrameOfReferenceType type, optional XRFrameOfReferenceOptions options);
|
||||
Promise<XRReferenceSpace> requestReferenceSpace(XRReferenceSpaceType type, optional XRReferenceSpaceOptions options);
|
||||
|
||||
FrozenArray<XRInputSource> getInputSources();
|
||||
|
||||
|
@ -57,7 +57,6 @@ enum XREnvironmentBlendMode {
|
|||
// Events
|
||||
attribute EventHandler onblur;
|
||||
attribute EventHandler onfocus;
|
||||
attribute EventHandler onresetpose;
|
||||
attribute EventHandler onend;
|
||||
attribute EventHandler onselect;
|
||||
attribute EventHandler oninputsourceschange;
|
||||
|
@ -70,34 +69,51 @@ callback XRFrameRequestCallback = void (DOMHighResTimeStamp time, XRFrame frame)
|
|||
[SecureContext, Exposed=Window] interface XRFrame {
|
||||
readonly attribute XRSession session;
|
||||
|
||||
XRViewerPose? getViewerPose(XRFrameOfReference frameOfRef);
|
||||
XRInputPose? getInputPose(XRInputSource inputSource, XRFrameOfReference frameOfRef);
|
||||
XRViewerPose? getViewerPose(optional XRReferenceSpace referenceSpace);
|
||||
XRInputPose? getInputPose(XRInputSource inputSource, optional XRReferenceSpace referenceSpace);
|
||||
};
|
||||
|
||||
[SecureContext, Exposed=Window] interface XRCoordinateSystem : EventTarget {
|
||||
Float32Array? getTransformTo(XRCoordinateSystem other);
|
||||
[SecureContext, Exposed=Window] interface XRSpace : EventTarget {
|
||||
Float32Array? getTransformTo(XRSpace other);
|
||||
};
|
||||
|
||||
enum XRFrameOfReferenceType {
|
||||
"head-model",
|
||||
enum XRReferenceSpaceType {
|
||||
"stationary",
|
||||
"bounded",
|
||||
"unbounded"
|
||||
};
|
||||
|
||||
dictionary XRReferenceSpaceOptions {
|
||||
required XRReferenceSpaceType type;
|
||||
};
|
||||
|
||||
[SecureContext, Exposed=Window] interface XRReferenceSpace : XRSpace {
|
||||
attribute EventHandler onreset;
|
||||
};
|
||||
|
||||
enum XRStationaryReferenceSpaceSubtype {
|
||||
"eye-level",
|
||||
"stage",
|
||||
"floor-level",
|
||||
"position-disabled"
|
||||
};
|
||||
|
||||
dictionary XRFrameOfReferenceOptions {
|
||||
boolean disableStageEmulation = false;
|
||||
double stageEmulationHeight = 0.0;
|
||||
dictionary XRStationaryReferenceSpaceOptions : XRReferenceSpaceOptions {
|
||||
required XRStationaryReferenceSpaceSubtype subtype;
|
||||
};
|
||||
|
||||
[SecureContext, Exposed=Window] interface XRFrameOfReference : XRCoordinateSystem {
|
||||
readonly attribute XRStageBounds? bounds;
|
||||
readonly attribute double emulatedHeight;
|
||||
|
||||
attribute EventHandler onboundschange;
|
||||
[SecureContext, Exposed=Window]
|
||||
interface XRStationaryReferenceSpace : XRReferenceSpace {
|
||||
readonly attribute XRStationaryReferenceSpaceSubtype subtype;
|
||||
};
|
||||
|
||||
[SecureContext, Exposed=Window] interface XRStageBounds {
|
||||
readonly attribute FrozenArray<DOMPointReadOnly> geometry;
|
||||
[SecureContext, Exposed=Window]
|
||||
interface XRBoundedReferenceSpace : XRReferenceSpace {
|
||||
readonly attribute FrozenArray<DOMPointReadOnly> boundsGeometry;
|
||||
};
|
||||
|
||||
[SecureContext, Exposed=Window]
|
||||
|
||||
interface XRUnboundedReferenceSpace : XRReferenceSpace {
|
||||
};
|
||||
|
||||
enum XREye {
|
||||
|
@ -224,11 +240,13 @@ dictionary XRInputSourceEventInit : EventInit {
|
|||
required XRInputSource inputSource;
|
||||
};
|
||||
|
||||
[SecureContext, Exposed=Window, Constructor(DOMString type, XRCoordinateSystemEventInit eventInitDict)]
|
||||
interface XRCoordinateSystemEvent : Event {
|
||||
readonly attribute XRCoordinateSystem coordinateSystem;
|
||||
[SecureContext, Exposed=Window, Constructor(DOMString type, XRReferenceSpaceEventInit eventInitDict)]
|
||||
interface XRReferenceSpaceEvent : Event {
|
||||
readonly attribute XRReferenceSpace referenceSpace;
|
||||
readonly attribute Float32Array? transformMatrix;
|
||||
};
|
||||
|
||||
dictionary XRCoordinateSystemEventInit : EventInit {
|
||||
required XRCoordinateSystem coordinateSystem;
|
||||
dictionary XRReferenceSpaceEventInit : EventInit {
|
||||
required XRReferenceSpace referenceSpace;
|
||||
Float32Array transformMatrix;
|
||||
};
|
||||
|
|
|
@ -30,14 +30,19 @@ promise_test(function(t) {
|
|||
|
||||
return new Promise(function(resolve, reject) {
|
||||
var channel = new MessageChannel();
|
||||
channel.port1.onmessage = resolve;
|
||||
channel.port1.onmessage = (event) => {
|
||||
if (event.data === 'done') {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
test(() => {
|
||||
assert_true(event.data.result);
|
||||
}, event.data.testName);
|
||||
};
|
||||
frame.contentWindow.postMessage({},
|
||||
host_info['HTTPS_ORIGIN'],
|
||||
[channel.port2]);
|
||||
});
|
||||
})
|
||||
.then(function(e) {
|
||||
assert_equals(e.data.results, 'finish');
|
||||
});
|
||||
}, 'Verify CORS XHR of fetch() in a Service Worker');
|
||||
</script>
|
||||
|
|
|
@ -26,38 +26,10 @@ function create_test_case_promise(url, with_credentials) {
|
|||
});
|
||||
}
|
||||
|
||||
function create_test_promise(url, with_credentials, expected_result) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
create_test_case_promise(url, with_credentials)
|
||||
.then(function(result) {
|
||||
if (result == expected_result) {
|
||||
resolve();
|
||||
} else {
|
||||
reject('Result of url:' + url + ' ' +
|
||||
' with_credentials: ' + with_credentials + ' must be ' +
|
||||
expected_result + ' but ' + result);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function create_serial_promise(test_cases) {
|
||||
var promise = Promise.resolve();
|
||||
test_cases.forEach(function(test_case) {
|
||||
promise = promise.then(function() {
|
||||
return create_test_promise(test_case[0], test_case[1], test_case[2]);
|
||||
});
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
|
||||
window.addEventListener('message', function(evt) {
|
||||
window.addEventListener('message', async (evt) => {
|
||||
var port = evt.ports[0];
|
||||
var url = host_info['HTTPS_ORIGIN'] + path;
|
||||
var remote_url = host_info['HTTPS_REMOTE_ORIGIN'] + path;
|
||||
// If the 4th value of the item of TEST_CASES is true, the test case outputs
|
||||
// warning messages. So such tests must be executed in serial to match the
|
||||
// expected output text.
|
||||
var TEST_CASES = [
|
||||
// Reject tests
|
||||
[url + '?reject', false, FAIL],
|
||||
|
@ -95,8 +67,8 @@ window.addEventListener('message', function(evt) {
|
|||
// Credential test (fallback)
|
||||
[url + '?Auth&ignore', false, SUCCESS],
|
||||
[url + '?Auth&ignore', true, SUCCESS],
|
||||
[remote_url + '?Auth&ignore', false, FAIL, true], // Executed in serial.
|
||||
[remote_url + '?Auth&ignore', true, FAIL, true], // Executed in serial.
|
||||
[remote_url + '?Auth&ignore', false, FAIL],
|
||||
[remote_url + '?Auth&ignore', true, FAIL],
|
||||
[
|
||||
remote_url + '?Auth&ACAOrigin=' + host_info['HTTPS_ORIGIN'] + '&ignore',
|
||||
false, 'STATUS401'
|
||||
|
@ -186,24 +158,13 @@ window.addEventListener('message', function(evt) {
|
|||
true, SUCCESS
|
||||
]
|
||||
];
|
||||
var promises = [];
|
||||
var serial_tests = [];
|
||||
for (var i = 0; i < TEST_CASES.length ; ++i) {
|
||||
if (!TEST_CASES[i][3]) {
|
||||
promises.push(create_test_promise(TEST_CASES[i][0],
|
||||
TEST_CASES[i][1],
|
||||
TEST_CASES[i][2]));
|
||||
} else {
|
||||
serial_tests.push(TEST_CASES[i]);
|
||||
}
|
||||
|
||||
let counter = 0;
|
||||
for (let test of TEST_CASES) {
|
||||
let result = await create_test_case_promise(test[0], test[1]);
|
||||
let testName = 'test ' + (++counter) + ': ' + test[0] + ' with credentials ' + test[1] + ' must be ' + test[2];
|
||||
port.postMessage({testName: testName, result: result === test[2]});
|
||||
}
|
||||
promises.push(create_serial_promise(serial_tests));
|
||||
Promise.all(promises)
|
||||
.then(function() {
|
||||
port.postMessage({results: 'finish'});
|
||||
})
|
||||
.catch(function(e) {
|
||||
port.postMessage({results: 'failure:' + e});
|
||||
});
|
||||
port.postMessage('done');
|
||||
}, false);
|
||||
</script>
|
||||
|
|
|
@ -1,92 +1,101 @@
|
|||
// META: title=StorageManager: estimate() for indexeddb
|
||||
|
||||
function indexedDbOpenRequest(t, dbname, upgrade_func) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const openRequest = indexedDB.open(dbname);
|
||||
t.add_cleanup(() => {
|
||||
indexedDbDeleteRequest(dbname);
|
||||
});
|
||||
|
||||
openRequest.onerror = () => {
|
||||
reject(openRequest.error);
|
||||
};
|
||||
openRequest.onsuccess = () => {
|
||||
resolve(openRequest.result);
|
||||
};
|
||||
openRequest.onupgradeneeded = event => {
|
||||
upgrade_func(openRequest.result);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function indexedDbDeleteRequest(name) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const deleteRequest = indexedDB.deleteDatabase(name);
|
||||
deleteRequest.onerror = () => {
|
||||
reject(deleteRequest.error);
|
||||
};
|
||||
deleteRequest.onsuccess = () => {
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function transactionPromise(txn) {
|
||||
return new Promise((resolve, reject) => {
|
||||
txn.onabort = () => {
|
||||
reject(txn.error);
|
||||
};
|
||||
txn.oncomplete = () => {
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
test(t => {
|
||||
assert_true('estimate' in navigator.storage);
|
||||
assert_equals(typeof navigator.storage.estimate, 'function');
|
||||
assert_true(navigator.storage.estimate() instanceof Promise);
|
||||
}, 'estimate() method exists and returns a Promise');
|
||||
|
||||
promise_test(t => {
|
||||
return navigator.storage.estimate().then(result => {
|
||||
assert_true(typeof result === 'object');
|
||||
assert_true('usage' in result);
|
||||
assert_equals(typeof result.usage, 'number');
|
||||
assert_true('quota' in result);
|
||||
assert_equals(typeof result.quota, 'number');
|
||||
});
|
||||
promise_test(async t => {
|
||||
const estimate = await navigator.storage.estimate();
|
||||
assert_true(typeof estimate === 'object');
|
||||
assert_true('usage' in estimate);
|
||||
assert_equals(typeof estimate.usage, 'number');
|
||||
assert_true('quota' in estimate);
|
||||
assert_equals(typeof estimate.quota, 'number');
|
||||
}, 'estimate() resolves to dictionary with members');
|
||||
|
||||
promise_test(t => {
|
||||
promise_test(async t => {
|
||||
const arraySize = 1e6;
|
||||
const objectStoreName = "storageManager";
|
||||
const dbname = this.window ? window.location.pathname :
|
||||
"estimate-worker.https.html";
|
||||
|
||||
let db;
|
||||
let usageBeforeCreate, usageAfterCreate, usageAfterPut;
|
||||
await indexedDbDeleteRequest(dbname);
|
||||
let estimate = await navigator.storage.estimate();
|
||||
|
||||
function deleteDB(name) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let deleteRequest = indexedDB.deleteDatabase(name);
|
||||
deleteRequest.onerror = () => { reject(deleteRequest.error); };
|
||||
deleteRequest.onsuccess = () => { resolve(); };
|
||||
});
|
||||
const usageBeforeCreate = estimate.usage;
|
||||
const db = await indexedDbOpenRequest(t, dbname, (db_to_upgrade) => {
|
||||
db_to_upgrade.createObjectStore(objectStoreName);
|
||||
});
|
||||
|
||||
estimate = await navigator.storage.estimate();
|
||||
const usageAfterCreate = estimate.usage;
|
||||
|
||||
assert_greater_than(
|
||||
usageAfterCreate, usageBeforeCreate,
|
||||
'estimated usage should increase after object store is created');
|
||||
|
||||
const txn = db.transaction(objectStoreName, 'readwrite');
|
||||
const buffer = new ArrayBuffer(arraySize);
|
||||
const view = new Uint8Array(buffer);
|
||||
|
||||
for (let i = 0; i < arraySize; i++) {
|
||||
view[i] = Math.floor(Math.random() * 255);
|
||||
}
|
||||
|
||||
return deleteDB(dbname)
|
||||
.then(() => {
|
||||
return navigator.storage.estimate();
|
||||
})
|
||||
.then(estimate => {
|
||||
usageBeforeCreate = estimate.usage;
|
||||
return new Promise((resolve, reject) => {
|
||||
let openRequest = indexedDB.open(dbname);
|
||||
openRequest.onerror = () => { reject(openRequest.error); };
|
||||
openRequest.onupgradeneeded = event => {
|
||||
openRequest.result.createObjectStore(objectStoreName);
|
||||
};
|
||||
openRequest.onsuccess = () => { resolve(openRequest.result); };
|
||||
});
|
||||
})
|
||||
.then(connection => {
|
||||
db = connection;
|
||||
return navigator.storage.estimate();
|
||||
})
|
||||
.then(estimate => {
|
||||
usageAfterCreate = estimate.usage;
|
||||
assert_greater_than(
|
||||
usageAfterCreate, usageBeforeCreate,
|
||||
'estimated usage should increase after object store is created');
|
||||
const testBlob = new Blob([buffer], {type: "binary/random"});
|
||||
txn.objectStore(objectStoreName).add(testBlob, 1);
|
||||
|
||||
let txn = db.transaction(objectStoreName, 'readwrite');
|
||||
let buffer = new ArrayBuffer(arraySize);
|
||||
let view = new Uint8Array(buffer);
|
||||
await transactionPromise(txn);
|
||||
|
||||
for (let i = 0; i < arraySize; i++) {
|
||||
view[i] = parseInt(Math.random() * 255);
|
||||
}
|
||||
estimate = await navigator.storage.estimate();
|
||||
const usageAfterPut = estimate.usage;
|
||||
assert_greater_than(
|
||||
usageAfterPut, usageAfterCreate,
|
||||
'estimated usage should increase after large value is stored');
|
||||
|
||||
let testBlob = new Blob([buffer], {type: "binary/random"});
|
||||
txn.objectStore(objectStoreName).add(testBlob, 1);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
txn.onabort = () => { reject(txn.error); };
|
||||
txn.oncomplete = () => { resolve(); };
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
return navigator.storage.estimate();
|
||||
})
|
||||
.then(estimate => {
|
||||
usageAfterPut = estimate.usage;
|
||||
assert_greater_than(
|
||||
usageAfterPut, usageAfterCreate,
|
||||
'estimated usage should increase after large value is stored');
|
||||
|
||||
db.close();
|
||||
return deleteDB(dbname);
|
||||
})
|
||||
.then(() => {
|
||||
t.done();
|
||||
});
|
||||
db.close();
|
||||
}, 'estimate() shows usage increase after large value is stored');
|
||||
|
|
|
@ -17,6 +17,7 @@ test_valid_value("cx", "0", "0px");
|
|||
test_valid_value("cx", "-1px");
|
||||
test_valid_value("cx", "calc(2em + 3ex)");
|
||||
test_valid_value("cx", "4%");
|
||||
test_valid_value("cx", "5ch");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 791 B After Width: | Height: | Size: 822 B |
|
@ -17,6 +17,7 @@ test_valid_value("cy", "0", "0px");
|
|||
test_valid_value("cy", "-1px");
|
||||
test_valid_value("cy", "calc(2em + 3ex)");
|
||||
test_valid_value("cy", "4%");
|
||||
test_valid_value("cy", "5rem");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 791 B After Width: | Height: | Size: 823 B |
|
@ -19,6 +19,7 @@ test_valid_value("rx", "0", "0px");
|
|||
test_valid_value("rx", "1px");
|
||||
test_valid_value("rx", "calc(2em + 3ex)");
|
||||
test_valid_value("rx", "4%");
|
||||
test_valid_value("rx", "5vw");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 830 B After Width: | Height: | Size: 861 B |
|
@ -19,6 +19,7 @@ test_valid_value("rx", "0", "0px");
|
|||
test_valid_value("rx", "1px");
|
||||
test_valid_value("rx", "calc(2em + 3ex)");
|
||||
test_valid_value("rx", "4%");
|
||||
test_valid_value("rx", "5vh");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 830 B After Width: | Height: | Size: 861 B |
|
@ -17,6 +17,7 @@ test_valid_value("x", "0", "0px");
|
|||
test_valid_value("x", "-1px");
|
||||
test_valid_value("x", "calc(2em + 3ex)");
|
||||
test_valid_value("x", "4%");
|
||||
test_valid_value("x", "5cm");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 784 B After Width: | Height: | Size: 814 B |
|
@ -17,6 +17,7 @@ test_valid_value("y", "0", "0px");
|
|||
test_valid_value("y", "-1px");
|
||||
test_valid_value("y", "calc(2em + 3ex)");
|
||||
test_valid_value("y", "4%");
|
||||
test_valid_value("y", "5mm");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 784 B After Width: | Height: | Size: 814 B |
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().colorInterpolation</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#ColorInterpolationProperty"/>
|
||||
<h:meta name="assert" content="color-interpolation computed value is as specified."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("color-interpolation", "auto");
|
||||
test_computed_value("color-interpolation", "srgb");
|
||||
test_computed_value("color-interpolation", "linearrgb");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 827 B |
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().colorRendering</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#ColorRenderingProperty"/>
|
||||
<h:meta name="assert" content="color-rendering computed value is as specified."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("color-rendering", "auto");
|
||||
test_computed_value("color-rendering", "optimizespeed");
|
||||
test_computed_value("color-rendering", "optimizequality");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 818 B |
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().fill</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#FillProperty"/>
|
||||
<h:meta name="assert" content="fill computed value is as specified, with url values absolute."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("fill", "none");
|
||||
test_computed_value("fill", "rgb(12, 34, 56)");
|
||||
|
||||
test_computed_value("fill", 'url("https://example.com/")');
|
||||
test_computed_value("fill", 'url("https://example.com/") none');
|
||||
test_computed_value("fill", 'url("https://example.com/") rgb(12, 34, 56)');
|
||||
|
||||
// context-fill and context-stroke are not yet supported by browsers.
|
||||
|
||||
test(() => {
|
||||
const target = document.getElementById('target');
|
||||
target.style['fill'] = 'url("a.b#c")';
|
||||
const result = getComputedStyle(target)['fill'];
|
||||
const resolved = new URL("a.b#c", document.URL).href;
|
||||
assert_equals(result, 'url("' + resolved + '")');
|
||||
}, 'url values are made absolute');
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
|
@ -2,7 +2,7 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Geometry Properties: getComputedValue().fillOpacity</title>
|
||||
<title>SVG Painting: getComputedValue().fillOpacity</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#FillOpacity"/>
|
||||
<h:meta name="assert" content="fill-opacity computed value is clamped to the range [0,1]."/>
|
||||
|
|
Before Width: | Height: | Size: 801 B After Width: | Height: | Size: 790 B |
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().fillRule</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#FillRuleProperty"/>
|
||||
<h:meta name="assert" content="fill-rule computed value is as specified."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("fill-rule", "nonzero");
|
||||
test_computed_value("fill-rule", "evenodd");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 726 B |
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().imageRendering</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#ImageRenderingProperty"/>
|
||||
<h:meta name="assert" content="image-rendering computed value is as specified."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("image-rendering", "auto");
|
||||
test_computed_value("image-rendering", "optimizequality");
|
||||
test_computed_value("image-rendering", "optimizespeed");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 818 B |
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().MarkerEnd</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#MarkerEndProperty"/>
|
||||
<h:meta name="assert" content="marker-end computed value is as specified, with url values absolute."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("marker-end", "none");
|
||||
test_computed_value("marker-end", 'url("https://example.com/")');
|
||||
|
||||
test(() => {
|
||||
const target = document.getElementById('target');
|
||||
target.style['marker-end'] = 'url("a.b#c")';
|
||||
const result = getComputedStyle(target)['marker-end'];
|
||||
const resolved = new URL("a.b#c", document.URL).href;
|
||||
assert_equals(result, 'url("' + resolved + '")');
|
||||
}, 'url values are made absolute');
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().markerMid</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#MarkerMidProperty"/>
|
||||
<h:meta name="assert" content="marker-mid computed value is as specified, with url values absolute."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("marker-mid", "none");
|
||||
test_computed_value("marker-mid", 'url("https://example.com/")');
|
||||
|
||||
test(() => {
|
||||
const target = document.getElementById('target');
|
||||
target.style['marker-mid'] = 'url("a.b#c")';
|
||||
const result = getComputedStyle(target)['marker-mid'];
|
||||
const resolved = new URL("a.b#c", document.URL).href;
|
||||
assert_equals(result, 'url("' + resolved + '")');
|
||||
}, 'url values are made absolute');
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().markerStart</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#MarkerStartProperty"/>
|
||||
<h:meta name="assert" content="marker-start computed value is as specified, with url values absolute."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("marker-start", "none");
|
||||
test_computed_value("marker-start", 'url("https://example.com/")');
|
||||
|
||||
test(() => {
|
||||
const target = document.getElementById('target');
|
||||
target.style['marker-start'] = 'url("a.b#c")';
|
||||
const result = getComputedStyle(target)['marker-start'];
|
||||
const resolved = new URL("a.b#c", document.URL).href;
|
||||
assert_equals(result, 'url("' + resolved + '")');
|
||||
}, 'url values are made absolute');
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().paintOrder</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#PaintOrderProperty"/>
|
||||
<h:meta name="assert" content="paint-order computed value is as specified."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("paint-order", "normal");
|
||||
|
||||
test_computed_value("paint-order", "fill");
|
||||
test_computed_value("paint-order", "stroke");
|
||||
test_computed_value("paint-order", "markers");
|
||||
|
||||
test_computed_value("paint-order", "fill stroke", "fill");
|
||||
test_computed_value("paint-order", "fill markers");
|
||||
test_computed_value("paint-order", "stroke fill", "stroke");
|
||||
test_computed_value("paint-order", "stroke markers");
|
||||
test_computed_value("paint-order", "markers fill", "markers");
|
||||
test_computed_value("paint-order", "markers stroke");
|
||||
|
||||
test_computed_value("paint-order", "fill stroke markers", "fill");
|
||||
test_computed_value("paint-order", "fill markers stroke", "fill markers");
|
||||
test_computed_value("paint-order", "stroke fill markers", "stroke");
|
||||
test_computed_value("paint-order", "stroke markers fill", "stroke markers");
|
||||
test_computed_value("paint-order", "markers fill stroke", "markers");
|
||||
test_computed_value("paint-order", "markers stroke fill", "markers stroke");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 1.6 KiB |
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().shapeRendering</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#ShapeRenderingProperty"/>
|
||||
<h:meta name="assert" content="shape-rendering computed value is as specified."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("shape-rendering", "auto");
|
||||
test_computed_value("shape-rendering", "optimizespeed");
|
||||
test_computed_value("shape-rendering", "crispedges");
|
||||
test_computed_value("shape-rendering", "geometricprecision");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 875 B |
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().stroke</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#StrokeProperty"/>
|
||||
<h:meta name="assert" content="stroke computed value is as specified, with url values absolute."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("stroke", "none");
|
||||
test_computed_value("stroke", "rgb(12, 34, 56)");
|
||||
|
||||
test_computed_value("stroke", 'url("https://example.com/")');
|
||||
test_computed_value("stroke", 'url("https://example.com/") none');
|
||||
test_computed_value("stroke", 'url("https://example.com/") rgb(12, 34, 56)');
|
||||
|
||||
// context-fill and context-stroke are not yet supported by browsers.
|
||||
|
||||
test(() => {
|
||||
const target = document.getElementById('target');
|
||||
target.style['stroke'] = 'url("a.b#c")';
|
||||
const result = getComputedStyle(target)['stroke'];
|
||||
const resolved = new URL("a.b#c", document.URL).href;
|
||||
assert_equals(result, 'url("' + resolved + '")');
|
||||
}, 'url values are made absolute');
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().strokeDasharray</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#StrokeDasharrayProperty"/>
|
||||
<h:meta name="assert" content="stroke-dasharray computed value uses absolute lengths."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<style>
|
||||
#target {
|
||||
font-size: 40px;
|
||||
}
|
||||
</style>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("stroke-dasharray", "none");
|
||||
|
||||
test_computed_value("stroke-dasharray", "10", "10px");
|
||||
test_computed_value("stroke-dasharray", "calc(10px + 0.5em)", "30px");
|
||||
test_computed_value("stroke-dasharray", "calc(10px - 0.5em)", "0px");
|
||||
test_computed_value("stroke-dasharray", "40%");
|
||||
test_computed_value("stroke-dasharray", "calc(50% + 60px)");
|
||||
|
||||
test_computed_value("stroke-dasharray", "10px 20% 30px", "10px, 20%, 30px");
|
||||
test_computed_value("stroke-dasharray", "0, 5", "0px, 5px");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
|
@ -20,7 +20,8 @@ test_valid_value("stroke-dasharray", "10px");
|
|||
test_valid_value("stroke-dasharray", "20%");
|
||||
test_valid_value("stroke-dasharray", "calc(2em + 3ex)");
|
||||
|
||||
test_valid_value("stroke-dasharray", "10px, 20%, 30px");
|
||||
test_valid_value("stroke-dasharray", "10pt 20% 30pc 40in", "10pt, 20%, 30pc, 40in");
|
||||
test_valid_value("stroke-dasharray", "10vmin, 20vmax, 30em, 40ex");
|
||||
test_valid_value("stroke-dasharray", "0, 5", ["0, 5", "0px, 5px"]); // Edge/Safari serialize numbers as lengths.
|
||||
|
||||
]]></script>
|
||||
|
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.2 KiB |
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().strokeDashoffset</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#StrokeDashoffsetProperty"/>
|
||||
<h:meta name="assert" content="stroke-dashoffset computed value is absolute length."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<style>
|
||||
#target {
|
||||
font-size: 40px;
|
||||
}
|
||||
</style>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("stroke-dashoffset", "10", "10px");
|
||||
test_computed_value("stroke-dashoffset", "0.5em", "20px");
|
||||
test_computed_value("stroke-dashoffset", "calc(10px + 0.5em)", "30px");
|
||||
test_computed_value("stroke-dashoffset", "calc(10px - 0.5em)", "-10px");
|
||||
test_computed_value("stroke-dashoffset", "-40%");
|
||||
test_computed_value("stroke-dashoffset", "calc(50% + 60px)");
|
||||
|
||||
// https://www.w3.org/TR/css-values-3/#absolute-lengths
|
||||
test_computed_value("stroke-dashoffset", "254cm", "9600px");
|
||||
test_computed_value("stroke-dashoffset", "2540mm", "9600px");
|
||||
test_computed_value("stroke-dashoffset", "10160Q", "9600px");
|
||||
test_computed_value("stroke-dashoffset", "1in", "96px");
|
||||
test_computed_value("stroke-dashoffset", "6pc", "96px");
|
||||
test_computed_value("stroke-dashoffset", "72pt", "96px");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
|
@ -17,6 +17,7 @@ test_valid_value("stroke-dashoffset", "0");
|
|||
test_valid_value("stroke-dashoffset", "10px");
|
||||
test_valid_value("stroke-dashoffset", "-20%");
|
||||
test_valid_value("stroke-dashoffset", "30");
|
||||
test_valid_value("stroke-dashoffset", "40Q", "40q");
|
||||
test_valid_value("stroke-dashoffset", "calc(2em + 3ex)");
|
||||
|
||||
]]></script>
|
||||
|
|
Before Width: | Height: | Size: 922 B After Width: | Height: | Size: 975 B |
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().strokeLinecap</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#StrokeLinecapProperty"/>
|
||||
<h:meta name="assert" content="stroke-linecap computed value is as specified."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("stroke-linecap", "butt");
|
||||
test_computed_value("stroke-linecap", "round");
|
||||
test_computed_value("stroke-linecap", "square");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 795 B |
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().strokeLinejoin</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#StrokeLinejoinProperty"/>
|
||||
<h:meta name="assert" content="stroke-linejoin computed value is as specified."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("stroke-linejoin", "miter");
|
||||
test_computed_value("stroke-linejoin", "round");
|
||||
test_computed_value("stroke-linejoin", "bevel");
|
||||
// "miter-clip" and "arcs" are not yet supported by browsers.
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 863 B |
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().strokeMiterlimit</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#StrokeMiterlimitProperty"/>
|
||||
<h:meta name="assert" content="stroke-miterlimit computed value is as specified."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("stroke-miterlimit", "0");
|
||||
test_computed_value("stroke-miterlimit", "0.5");
|
||||
test_computed_value("stroke-miterlimit", "1");
|
||||
test_computed_value("stroke-miterlimit", "7.5");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 852 B |
|
@ -2,7 +2,7 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Geometry Properties: getComputedValue().strokeOpacity</title>
|
||||
<title>SVG Painting: getComputedValue().strokeOpacity</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#StrokeOpacityProperty"/>
|
||||
<h:meta name="assert" content="stroke-opacity computed value is clamped to the range [0,1]."/>
|
||||
|
|
Before Width: | Height: | Size: 821 B After Width: | Height: | Size: 810 B |
|
@ -2,13 +2,15 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Geometry Properties: getComputedValue().strokeWidth</title>
|
||||
<title>SVG Painting: getComputedValue().strokeWidth</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#StrokeWidth"/>
|
||||
<h:meta name="assert" content="stroke-width computed value is absolute length."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<g id="ref"></g>
|
||||
<style>
|
||||
#target {
|
||||
#target, #ref {
|
||||
font-size: 40px;
|
||||
}
|
||||
</style>
|
||||
|
@ -23,5 +25,36 @@ test_computed_value("stroke-width", "calc(10px - 0.5em)", "0px");
|
|||
test_computed_value("stroke-width", "40%");
|
||||
test_computed_value("stroke-width", "calc(50% + 60px)");
|
||||
|
||||
const lengthUnits = [
|
||||
'em',
|
||||
'ex',
|
||||
'ch',
|
||||
'rem',
|
||||
'vw',
|
||||
'vh',
|
||||
'vmin',
|
||||
'vmax',
|
||||
'cm',
|
||||
'mm',
|
||||
'Q',
|
||||
'in',
|
||||
'pt',
|
||||
'pc',
|
||||
'px'
|
||||
];
|
||||
|
||||
for (let lengthUnit of lengthUnits) {
|
||||
const length = '987' + lengthUnit;
|
||||
test(() => {
|
||||
const target = document.getElementById('target');
|
||||
target.style.strokeWidth = length;
|
||||
|
||||
const ref = document.getElementById('ref');
|
||||
ref.style.wordSpacing = length;
|
||||
|
||||
assert_equals(getComputedStyle(target).strokeWidth, getComputedStyle(ref).wordSpacing);
|
||||
}, 'stroke-width computes ' + lengthUnit + ' lengths');
|
||||
}
|
||||
|
||||
]]></script>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 914 B After Width: | Height: | Size: 1.5 KiB |
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
width="800px" height="800px">
|
||||
<title>SVG Painting: getComputedValue().textRendering</title>
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#TextRenderingProperty"/>
|
||||
<h:meta name="assert" content="text-rendering computed value is as specified."/>
|
||||
</metadata>
|
||||
<g id="target"></g>
|
||||
<h:script src="/resources/testharness.js"/>
|
||||
<h:script src="/resources/testharnessreport.js"/>
|
||||
<h:script src="/css/support/computed-testcommon.js"/>
|
||||
<script><![CDATA[
|
||||
|
||||
test_computed_value("text-rendering", "auto");
|
||||
test_computed_value("text-rendering", "optimizespeed");
|
||||
test_computed_value("text-rendering", "optimizelegibility");
|
||||
test_computed_value("text-rendering", "geometricprecision");
|
||||
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 876 B |
|
@ -133,6 +133,7 @@ class SauceConnect():
|
|||
self.sauce_key = kwargs["sauce_key"]
|
||||
self.sauce_tunnel_id = kwargs["sauce_tunnel_id"]
|
||||
self.sauce_connect_binary = kwargs.get("sauce_connect_binary")
|
||||
self.sauce_connect_args = kwargs.get("sauce_connect_args")
|
||||
self.sauce_init_timeout = kwargs.get("sauce_init_timeout")
|
||||
self.sc_process = None
|
||||
self.temp_dir = None
|
||||
|
@ -171,7 +172,7 @@ class SauceConnect():
|
|||
"--readyfile=./sauce_is_ready",
|
||||
"--tunnel-domains",
|
||||
",".join(self.env_config.domains_set)
|
||||
])
|
||||
] + self.sauce_connect_args)
|
||||
|
||||
tot_wait = 0
|
||||
while not os.path.exists('./sauce_is_ready') and self.sc_process.poll() is None:
|
||||
|
|
|
@ -25,7 +25,8 @@ def test_sauceconnect_success():
|
|||
sauce_user="aaa",
|
||||
sauce_key="bbb",
|
||||
sauce_tunnel_id="ccc",
|
||||
sauce_connect_binary="ddd")
|
||||
sauce_connect_binary="ddd",
|
||||
sauce_connect_args=[])
|
||||
|
||||
with ConfigBuilder(browser_host="example.net") as env_config:
|
||||
sauce_connect(None, env_config)
|
||||
|
@ -54,7 +55,8 @@ def test_sauceconnect_failure_exit(readyfile, returncode):
|
|||
sauce_user="aaa",
|
||||
sauce_key="bbb",
|
||||
sauce_tunnel_id="ccc",
|
||||
sauce_connect_binary="ddd")
|
||||
sauce_connect_binary="ddd",
|
||||
sauce_connect_args=[])
|
||||
|
||||
with ConfigBuilder(browser_host="example.net") as env_config:
|
||||
sauce_connect(None, env_config)
|
||||
|
@ -82,7 +84,8 @@ def test_sauceconnect_cleanup():
|
|||
sauce_user="aaa",
|
||||
sauce_key="bbb",
|
||||
sauce_tunnel_id="ccc",
|
||||
sauce_connect_binary="ddd")
|
||||
sauce_connect_binary="ddd",
|
||||
sauce_connect_args=[])
|
||||
|
||||
with ConfigBuilder(browser_host="example.net") as env_config:
|
||||
sauce_connect(None, env_config)
|
||||
|
@ -106,7 +109,8 @@ def test_sauceconnect_failure_never_ready():
|
|||
sauce_user="aaa",
|
||||
sauce_key="bbb",
|
||||
sauce_tunnel_id="ccc",
|
||||
sauce_connect_binary="ddd")
|
||||
sauce_connect_binary="ddd",
|
||||
sauce_connect_args=[])
|
||||
|
||||
with ConfigBuilder(browser_host="example.net") as env_config:
|
||||
sauce_connect(None, env_config)
|
||||
|
@ -134,7 +138,8 @@ def test_sauceconnect_tunnel_domains():
|
|||
sauce_user="aaa",
|
||||
sauce_key="bbb",
|
||||
sauce_tunnel_id="ccc",
|
||||
sauce_connect_binary="ddd")
|
||||
sauce_connect_binary="ddd",
|
||||
sauce_connect_args=[])
|
||||
|
||||
with ConfigBuilder(browser_host="example.net",
|
||||
alternate_hosts={"alt": "example.org"},
|
||||
|
|
|
@ -302,6 +302,10 @@ scheme host and port.""")
|
|||
help="Number of seconds to wait for Sauce "
|
||||
"Connect tunnel to be available before "
|
||||
"aborting")
|
||||
sauce_group.add_argument("--sauce-connect-arg", action="append",
|
||||
default=[], dest="sauce_connect_args",
|
||||
help="Command-line argument to forward to the "
|
||||
"Sauce Connect binary (repeatable)")
|
||||
|
||||
webkit_group = parser.add_argument_group("WebKit-specific")
|
||||
webkit_group.add_argument("--webkit-port", dest="webkit_port",
|
||||
|
|
|
@ -284,6 +284,8 @@ def run_tests(config, test_paths, product, **kwargs):
|
|||
logger.suite_end()
|
||||
if repeat_until_unexpected and unexpected_total > 0:
|
||||
break
|
||||
if len(test_loader.test_ids) == skipped_tests:
|
||||
break
|
||||
|
||||
if test_total == 0:
|
||||
if skipped_tests > 0:
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="support/helper.sub.js"></script>
|
||||
|
||||
<meta http-equiv="Content-Security-Policy" content="trusted-types *">
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
<script>
|
||||
var container = document.querySelector('#container');
|
||||
|
||||
// Trusted Type assignments do not throw.
|
||||
async_test(t => {
|
||||
window.onclickTest = t.step_func_done();
|
||||
let policy = createScript_policy(window, 'onclick');
|
||||
let script = policy.createScript("window.onclickTest();");
|
||||
|
||||
let el = document.createElement('a');
|
||||
el.setAttribute('onclick', script);
|
||||
container.appendChild(el);
|
||||
el.click();
|
||||
}, "a.onclick assigned via policy (successful Script transformation).");
|
||||
</script>
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js" ></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="support/helper.sub.js"></script>
|
||||
|
||||
<meta http-equiv="Content-Security-Policy" content="trusted-types">
|
||||
<body>
|
||||
<script>
|
||||
// No name given test
|
||||
test(t => {
|
||||
assert_throws(new TypeError(),
|
||||
() => window.TrustedTypes.createPolicy('SomeName', { createHTML: s => s } ),
|
||||
"createPolicy with an empty trusted-types CSP directive");
|
||||
}, "No name list given - policy creation fails.");
|
||||
</script>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js" ></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="support/helper.sub.js"></script>
|
||||
|
||||
<meta http-equiv="Content-Security-Policy" content="trusted-types *">
|
||||
<body>
|
||||
<script>
|
||||
test(t => {
|
||||
let policy = window.TrustedTypes.createPolicy('SomeName', { createHTML: s => s } );
|
||||
assert_equals(policy.name, 'SomeName');
|
||||
}, "CSP supports wildcards.");
|
||||
</script>
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js" ></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="support/helper.sub.js"></script>
|
||||
|
||||
<meta http-equiv="Content-Security-Policy" content="trusted-types SomeName JustOneMoreName">
|
||||
<body>
|
||||
<script>
|
||||
// Whitelisted name test
|
||||
test(t => {
|
||||
let policy = window.TrustedTypes.createPolicy('SomeName', { createHTML: s => s } );
|
||||
assert_equals(policy.name, 'SomeName');
|
||||
}, "Whitelisted policy creation works.");
|
||||
|
||||
// Another whitelisted name test
|
||||
test(t => {
|
||||
let policy = window.TrustedTypes.createPolicy('JustOneMoreName', { createHTML: s => s } );
|
||||
assert_equals(policy.name, 'JustOneMoreName');
|
||||
}, "Another whitelisted policy creation works.");
|
||||
|
||||
// Non-whitelisted names test
|
||||
test(t => {
|
||||
assert_throws(new TypeError(), _ => {
|
||||
window.TrustedTypes.createPolicy('SomeOtherName', { createURL: s => s } );
|
||||
});
|
||||
}, "Non-whitelisted policy creation throws.");
|
||||
</script>
|
|
@ -0,0 +1,119 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js" ></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="support/helper.sub.js"></script>
|
||||
|
||||
<meta http-equiv="Content-Security-Policy" content="trusted-types *">
|
||||
<body>
|
||||
<script>
|
||||
test(t => {
|
||||
const p1 = TrustedTypes.createPolicy("policyHTMLAndScript", {
|
||||
createHTML: s => s,
|
||||
createScript: s => s
|
||||
});
|
||||
assert_throws(new TypeError(), _ => { p1.createScriptURL("foo"); });
|
||||
assert_throws(new TypeError(), _ => { p1.createURL("foo"); });
|
||||
|
||||
const p2 = TrustedTypes.createPolicy("policyURLAndScriptURL", {
|
||||
createURL: s => s,
|
||||
createScriptURL: s => s
|
||||
});
|
||||
assert_throws(new TypeError(), _ => { p2.createHTML("foo"); });
|
||||
assert_throws(new TypeError(), _ => { p2.createScript("foo"); });
|
||||
}, "calling undefined callbacks throws");
|
||||
|
||||
test(t => {
|
||||
const noopPolicy = {
|
||||
createHTML: (s) => s,
|
||||
createScriptURL: (s) => s,
|
||||
createURL: (s) => s,
|
||||
createScript: (s) => s,
|
||||
};
|
||||
policy = TrustedTypes.createPolicy(Math.random(), noopPolicy, true);
|
||||
let el = document.createElement("div");
|
||||
|
||||
el.title = policy.createHTML(INPUTS.URL);
|
||||
assert_equals(el.title, INPUTS.URL);
|
||||
|
||||
el.title = policy.createURL(INPUTS.HTML);
|
||||
assert_equals(el.title, "");
|
||||
}, "Attributes without type constraints will work as before.");
|
||||
|
||||
test(t => {
|
||||
const policy = TrustedTypes.createPolicy("nullpolicy", null);
|
||||
assert_throws(new TypeError(), _ => { policy.createScriptURL("foo"); });
|
||||
assert_throws(new TypeError(), _ => { policy.createURL("foo"); });
|
||||
assert_throws(new TypeError(), _ => { policy.createHTML("foo"); });
|
||||
assert_throws(new TypeError(), _ => { policy.createScript("foo"); });
|
||||
}, "TrustedTypes.createPolicy(.., null) creates empty policy.");
|
||||
|
||||
|
||||
// testCases contains a list of policy functions and expected results (when
|
||||
// called with a given default argument). They also use various helper
|
||||
// variables (declared just below) to test side effects or interactions of
|
||||
// global vars/functions with policy callbacks.
|
||||
let aGlobalVarForSideEffectTesting = "global";
|
||||
var aGlobalObject = { "foo": "well," };
|
||||
function aGlobalFunction(s) { return this.foo + " " + s; }
|
||||
function anotherGlobalFunction(s) { return s + "#" + this.foo; }
|
||||
var foo = "a global var named foo";
|
||||
|
||||
const stringTestCases = [
|
||||
[ s => s, "whatever" ],
|
||||
[ s => null, "null" ],
|
||||
[ s => "well, " + s, "well, whatever" ],
|
||||
[ s => { throw new Error() }, new Error() ],
|
||||
[ s => { aGlobalVarForSideEffectTesting = s; return s }, "whatever" ],
|
||||
[ s => aGlobalVarForSideEffectTesting + s, "whateverwhatever" ],
|
||||
[ aGlobalFunction.bind(aGlobalObject), "well, whatever" ],
|
||||
[ s => aGlobalFunction(s), "a global var named foo whatever" ],
|
||||
];
|
||||
|
||||
const urlTestCases = [
|
||||
[ s => s, INPUTS.SCRIPTURL ],
|
||||
[ s => null, "" ],
|
||||
[ s => s + "#duck", INPUTS.SCRIPTURL + "#duck" ],
|
||||
[ s => { throw new Error() }, new Error() ],
|
||||
[ s => s + "#" + aGlobalVarForSideEffectTesting,
|
||||
INPUTS.SCRIPTURL + "#global" ],
|
||||
[ anotherGlobalFunction.bind(aGlobalObject), INPUTS.SCRIPTURL + "#well," ],
|
||||
[ s => anotherGlobalFunction(s),
|
||||
INPUTS.SCRIPTURL + "#a%20global%20var%20named%20foo" ],
|
||||
];
|
||||
|
||||
function policyBuilder(trustedMethodName, trustedType, defaultArg) {
|
||||
return function(name, fn) {
|
||||
let options = {};
|
||||
options[trustedMethodName] = fn;
|
||||
let policy = window.TrustedTypes.createPolicy(name, options);
|
||||
let result = policy[trustedMethodName](defaultArg);
|
||||
assert_true(result instanceof trustedType);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
const testCases = [
|
||||
[TrustedHTML, "createHTML", "whatever", stringTestCases],
|
||||
[TrustedScript, "createScript", "whatever", stringTestCases],
|
||||
[TrustedURL, "createURL", INPUTS.SCRIPTURL, urlTestCases],
|
||||
[TrustedScriptURL, "createScriptURL", INPUTS.SCRIPTURL, urlTestCases],
|
||||
];
|
||||
|
||||
// Iterate over all trusted types, iterate over all test cases.
|
||||
// For each, build the suitable policy and check the result.
|
||||
for (let [trusted_class, trusted_method, default_arg, test_cases] of testCases) {
|
||||
aGlobalVarForSideEffectTesting = "global";
|
||||
let builder = policyBuilder(trusted_method, trusted_class, default_arg);
|
||||
for (let [index, [policy_fn, value]] of test_cases.entries()) {
|
||||
let subtest_name = "TestPolicy" + trusted_class.name + index;
|
||||
test(t => {
|
||||
if (value instanceof Error) {
|
||||
assert_throws(value, () => builder(subtest_name, policy_fn));
|
||||
} else {
|
||||
assert_equals("" + builder(subtest_name, policy_fn), value);
|
||||
}
|
||||
}, subtest_name + " (" + trusted_class.name + ": " +
|
||||
policy_fn.toString() + ")");
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js" ></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="support/helper.sub.js"></script>
|
||||
|
||||
<meta http-equiv="Content-Security-Policy" content="trusted-types *">
|
||||
<body>
|
||||
<script>
|
||||
// Not exposed policy test
|
||||
test(t => {
|
||||
let policy = window.TrustedTypes.createPolicy('SomeName', { createHTML: s => s } );
|
||||
assert_equals(window.TrustedTypes.getExposedPolicy('SomeName'), null);
|
||||
}, "Null is returned when policy is not exposed - by default");
|
||||
|
||||
// Non-existent policy test
|
||||
test(t => {
|
||||
assert_equals(window.TrustedTypes.getExposedPolicy('JustAName'), null);
|
||||
}, "Null is returned when policy is non-existent.");
|
||||
|
||||
// Exposed policy test
|
||||
test(t => {
|
||||
let policy = window.TrustedTypes.createPolicy('SomeOtherName', { createHTML: s => s }, true );
|
||||
assert_equals(window.TrustedTypes.getExposedPolicy('SomeOtherName'), policy);
|
||||
}, "Policy is returned when exposed == true.");
|
||||
</script>
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js" ></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="support/helper.sub.js"></script>
|
||||
|
||||
<meta http-equiv="Content-Security-Policy" content="trusted-types *">
|
||||
<body>
|
||||
<script>
|
||||
// Policy name test
|
||||
test(t => {
|
||||
let policy = TrustedTypes.createPolicy('hidden', { createHTML: s => s }, false );
|
||||
assert_true(policy instanceof TrustedTypePolicy);
|
||||
assert_equals(policy.name, 'hidden');
|
||||
}, "policy.name = name");
|
||||
|
||||
// Duplicate names test
|
||||
test(t => {
|
||||
assert_throws(new TypeError(), _ => {
|
||||
TrustedTypes.createPolicy('hidden', { createURL: s => s } );
|
||||
});
|
||||
}, "duplicate policy name attempt throws");
|
||||
|
||||
// Retrieve policy names tests
|
||||
test(t => {
|
||||
let policy = TrustedTypes.createPolicy('exposed', { createURL: s => s }, true );
|
||||
let names = TrustedTypes.getPolicyNames();
|
||||
assert_equals(names.length, 2);
|
||||
assert_true(names.includes('hidden'));
|
||||
assert_true(names.includes('exposed'));
|
||||
}, "getPolicyNames returns all policy names");
|
||||
</script>
|
|
@ -2,23 +2,26 @@
|
|||
<script src="/resources/testharness.js" ></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="support/helper.sub.js"></script>
|
||||
|
||||
<meta http-equiv="Content-Security-Policy" content="trusted-types SomeName JustOneMoreName">
|
||||
<body>
|
||||
<script>
|
||||
//Whitelisted name test
|
||||
// Whitelisted name test
|
||||
test(t => {
|
||||
let policy = window.TrustedTypes.createPolicy('SomeName', { createHTML: s => s } );
|
||||
assert_equals(policy.name, 'SomeName');
|
||||
}, "Whitelisted policy creation works");
|
||||
//Another whitelisted name test
|
||||
}, "Whitelisted policy creation works.");
|
||||
|
||||
// Another whitelisted name test
|
||||
test(t => {
|
||||
let policy = window.TrustedTypes.createPolicy('JustOneMoreName', { createHTML: s => s } );
|
||||
assert_equals(policy.name, 'JustOneMoreName');
|
||||
}, "Another whitelisted policy creation works");
|
||||
//Non-whitelisted names test
|
||||
}, "Another whitelisted policy creation works.");
|
||||
|
||||
// Non-whitelisted names test
|
||||
test(t => {
|
||||
assert_throws(new TypeError(), _ => {
|
||||
window.TrustedTypes.createPolicy('SomeOtherName', { createURL: s => s } );
|
||||
});
|
||||
}, "Non-whitelisted policy creation throws");
|
||||
}, "Non-whitelisted policy creation throws.");
|
||||
</script>
|
||||
|
|
|
@ -2,23 +2,25 @@
|
|||
<script src="/resources/testharness.js" ></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="support/helper.sub.js"></script>
|
||||
|
||||
<meta http-equiv="Content-Security-Policy" content="trusted-types *">
|
||||
<body>
|
||||
<script>
|
||||
//Not exposed policy test
|
||||
// Not exposed policy test
|
||||
test(t => {
|
||||
let policy = window.TrustedTypes.createPolicy('SomeName', { createHTML: s => s } );
|
||||
assert_equals(window.TrustedTypes.getExposedPolicy('SomeName'), null);
|
||||
}, "Null is returned when policy is not exposed");
|
||||
}, "Null is returned when policy is not exposed - by default");
|
||||
|
||||
//Non-existent policy test
|
||||
// Non-existent policy test
|
||||
test(t => {
|
||||
let policy = window.TrustedTypes.createPolicy('SomeOtherName', { createHTML: s => s } );
|
||||
assert_equals(window.TrustedTypes.getExposedPolicy('JustAName'), null);
|
||||
}, "Null is returned when policy is non-existent");
|
||||
}, "Null is returned when policy is non-existent.");
|
||||
|
||||
//Exposed policy test
|
||||
// Exposed policy test
|
||||
test(t => {
|
||||
let policy = window.TrustedTypes.createPolicy('EvenSomeOtherName', { createHTML: s => s }, true );
|
||||
assert_equals(window.TrustedTypes.getExposedPolicy('EvenSomeOtherName'), policy);
|
||||
}, "Policy is returned when exposed == true");
|
||||
}, "Policy is returned when exposed == true.");
|
||||
</script>
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
</head>
|
||||
<body>
|
||||
<script>
|
||||
// TrustedHTML assignments do not throw.
|
||||
// TrustedURL assignments do not throw.
|
||||
test(t => {
|
||||
document.body.innerText = '';
|
||||
let p = createHTML_policy(window, 1);
|
||||
let html = p.createHTML(INPUTS.HTML);
|
||||
document.write(html);
|
||||
|
@ -19,15 +20,19 @@
|
|||
|
||||
// String assignments throw.
|
||||
test(t => {
|
||||
const old = document.body.innerText;
|
||||
assert_throws(new TypeError(), _ => {
|
||||
document.write('A string');
|
||||
});
|
||||
assert_equals(document.body.innerText, old);
|
||||
}, "`document.write(string)` throws");
|
||||
|
||||
// Null assignment throws.
|
||||
test(t => {
|
||||
const old = document.body.innerText;
|
||||
assert_throws(new TypeError(), _ => {
|
||||
document.write(null);
|
||||
});
|
||||
assert_equals(document.body.innerText, old);
|
||||
}, "`document.write(null)` throws");
|
||||
</script>
|
||||
|
|
|
@ -103,6 +103,18 @@
|
|||
assert_element_accepts_non_trusted_type_explicit_set('a', 'rel', null, 'null');
|
||||
}, "a.rel accepts null");
|
||||
|
||||
test(t => {
|
||||
let div = document.createElement('div');
|
||||
let span = document.createElement('span');
|
||||
|
||||
div.setAttribute('src', INPUTS.URL);
|
||||
let attr = div.getAttributeNode('src');
|
||||
div.removeAttributeNode(attr);
|
||||
span.setAttributeNode(attr);
|
||||
|
||||
assert_equals(span.getAttribute('src'), INPUTS.URL);
|
||||
}, "`span.src = setAttributeNode(div.src)` with string works.");
|
||||
|
||||
test(t => {
|
||||
let el = document.createElement('iframe');
|
||||
|
||||
|
|
|
@ -19,16 +19,20 @@
|
|||
|
||||
// String assignments throw.
|
||||
test(t => {
|
||||
let href = location.href;
|
||||
assert_throws(new TypeError(), _ => {
|
||||
location.assign("A string");
|
||||
});
|
||||
assert_equals(location.href, href);
|
||||
}, "`location.assign = string` throws");
|
||||
|
||||
// Null assignment throws.
|
||||
test(t => {
|
||||
let href = location.href;
|
||||
assert_throws(new TypeError(), _ => {
|
||||
location.assign(null);
|
||||
});
|
||||
assert_equals(location.href, href);
|
||||
}, "`location.assign = null` throws");
|
||||
|
||||
// Create default policy. Applies to all subsequent tests.
|
||||
|
|
|
@ -19,19 +19,22 @@
|
|||
|
||||
// String assignments throw.
|
||||
test(t => {
|
||||
let href = location.href;
|
||||
assert_throws(new TypeError(), _ => {
|
||||
location.href = 'A string';
|
||||
});
|
||||
assert_equals(location.href, href);
|
||||
}, "`location.href = string` throws");
|
||||
|
||||
// Null assignment throws.
|
||||
test(t => {
|
||||
let href = location.href;
|
||||
assert_throws(new TypeError(), _ => {
|
||||
location.href = null;
|
||||
});
|
||||
assert_equals(location.href, href);
|
||||
}, "`location.href = null` throws");
|
||||
|
||||
|
||||
// Create default policy. Applies to all subsequent tests.
|
||||
let p = window.TrustedTypes.createPolicy("default",
|
||||
{ createURL: createLocationURLJS }, true);
|
||||
|
|
|
@ -19,16 +19,20 @@
|
|||
|
||||
// String replacements throw.
|
||||
test(t => {
|
||||
let href = location.href;
|
||||
assert_throws(new TypeError(), _ => {
|
||||
location.replace("A string");
|
||||
});
|
||||
assert_equals(location.href, href);
|
||||
}, "`location.replace = string` throws");
|
||||
|
||||
// Null replacement throws.
|
||||
test(t => {
|
||||
let href = location.href;
|
||||
assert_throws(new TypeError(), _ => {
|
||||
location.replace(null);
|
||||
});
|
||||
assert_equals(location.href, href);
|
||||
}, "`location.replace = null` throws");
|
||||
|
||||
// Create default policy. Applies to all subsequent tests.
|
||||
|
|
|
@ -87,9 +87,11 @@ function assert_element_accepts_trusted_type(tag, attribute, value, expected) {
|
|||
|
||||
function assert_throws_no_trusted_type(tag, attribute, value) {
|
||||
let elem = document.createElement(tag);
|
||||
let prev = elem[attribute];
|
||||
assert_throws(new TypeError(), _ => {
|
||||
elem[attribute] = value;
|
||||
});
|
||||
assert_equals(elem[attribute], prev);
|
||||
}
|
||||
|
||||
function assert_element_accepts_trusted_html_explicit_set(win, c, t, tag, attribute, expected) {
|
||||
|
@ -120,19 +122,24 @@ function assert_element_accepts_trusted_type_explicit_set(tag, attribute, value,
|
|||
let elem = document.createElement(tag);
|
||||
elem.setAttribute(attribute, value);
|
||||
assert_equals(elem[attribute] + "", expected);
|
||||
assert_equals(elem.getAttribute(attribute), expected);
|
||||
}
|
||||
|
||||
function assert_throws_no_trusted_type_explicit_set(tag, attribute, value) {
|
||||
let elem = document.createElement(tag);
|
||||
let prev = elem[attribute];
|
||||
assert_throws(new TypeError(), _ => {
|
||||
elem.setAttribute(attribute, value);
|
||||
});
|
||||
assert_equals(elem[attribute], prev);
|
||||
assert_equals(elem.getAttribute(attribute), null);
|
||||
}
|
||||
|
||||
function assert_element_accepts_non_trusted_type_explicit_set(tag, attribute, value, expected) {
|
||||
let elem = document.createElement(tag);
|
||||
elem.setAttribute(attribute, value);
|
||||
assert_equals(elem[attribute] + "", expected);
|
||||
assert_equals(elem.getAttribute(attribute), expected);
|
||||
}
|
||||
|
||||
let namespace = 'http://www.w3.org/1999/xhtml';
|
||||
|
|