mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1218433 - Use AsyncOpen2 in dom/workers/ScriptLoader.cpp - part 2 - WPT, r=sicking
This commit is contained in:
parent
47084ff27b
commit
50affafc7d
@ -23,6 +23,11 @@
|
||||
page_id);
|
||||
worker.port.start();
|
||||
|
||||
worker.onerror = function(evt) {
|
||||
window.parent.postMessage({id:page_id, message:"blocked"},
|
||||
'http://mochi.test:8888');
|
||||
}
|
||||
|
||||
worker.port.onmessage = function(ev) {
|
||||
window.parent.postMessage({id:page_id, message:"allowed"}, 'http://mochi.test:8888');
|
||||
};
|
||||
|
@ -13,6 +13,11 @@
|
||||
page_id);
|
||||
worker.port.start();
|
||||
|
||||
worker.onerror = function(evt) {
|
||||
window.parent.postMessage({id:page_id, message:"blocked"},
|
||||
'http://mochi.test:8888');
|
||||
}
|
||||
|
||||
worker.port.onmessage = function(ev) {
|
||||
window.parent.postMessage({id:page_id, message:"allowed"},
|
||||
'http://mochi.test:8888');
|
||||
|
@ -18,6 +18,10 @@
|
||||
escape(shared_worker), page_id);
|
||||
worker.port.start();
|
||||
|
||||
worker.onerror = function(evt) {
|
||||
window.parent.postMessage({id:page_id, message:"blocked"}, 'http://mochi.test:8888');
|
||||
}
|
||||
|
||||
worker.port.onmessage = function(ev) {
|
||||
window.parent.postMessage({id:page_id, message:"allowed"}, 'http://mochi.test:8888');
|
||||
};
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
worker.onerror = function(error) {
|
||||
var msg = error.message;
|
||||
if (msg.match(/^: NetworkError/)) {
|
||||
if (msg.match(/^: NetworkError/) || msg.match(/Failed to load script/)) {
|
||||
// this means CSP blocked it
|
||||
msg = "blocked";
|
||||
}
|
||||
|
@ -8,9 +8,15 @@
|
||||
page_id = window.location.hash.substring(1);
|
||||
try {
|
||||
worker = new Worker('file_testserver.sjs?file='+escape("tests/dom/security/test/csp/file_child-src_worker.js"));
|
||||
|
||||
worker.onerror = function(e) {
|
||||
window.parent.postMessage({id:page_id, message:"blocked"}, 'http://mochi.test:8888');
|
||||
}
|
||||
|
||||
worker.onmessage = function(ev) {
|
||||
window.parent.postMessage({id:page_id, message:"allowed"}, 'http://mochi.test:8888');
|
||||
};
|
||||
}
|
||||
|
||||
worker.postMessage('foo');
|
||||
}
|
||||
catch (e) {
|
||||
|
@ -8,9 +8,15 @@
|
||||
page_id = window.location.hash.substring(1);
|
||||
try {
|
||||
worker = new Worker('data:application/javascript;charset=UTF-8,'+escape('onmessage = function(e) { postMessage("worker"); };'));
|
||||
|
||||
worker.onerror = function(e) {
|
||||
window.parent.postMessage({id:page_id, message:"blocked"}, 'http://mochi.test:8888');
|
||||
}
|
||||
|
||||
worker.onmessage = function(ev) {
|
||||
window.parent.postMessage({id:page_id, message:"allowed"}, 'http://mochi.test:8888');
|
||||
};
|
||||
}
|
||||
|
||||
worker.postMessage('foo');
|
||||
}
|
||||
catch (e) {
|
||||
|
@ -2,7 +2,3 @@
|
||||
type: testharness
|
||||
[unsupported_scheme]
|
||||
expected: FAIL
|
||||
|
||||
[javascript_url]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -2,7 +2,3 @@
|
||||
type: testharness
|
||||
[unsupported_scheme]
|
||||
expected: FAIL
|
||||
|
||||
[javascript_url]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -31,6 +31,10 @@ connect-src 'self'; script-src 'self' 'unsafe-inline'; child-src 'self';
|
||||
worker.onmessage = function(event) {
|
||||
alert_assert(event.data);
|
||||
};
|
||||
worker.onerror = function(event) {
|
||||
alert_assert('TEST COMPLETE');
|
||||
event.preventDefault();
|
||||
}
|
||||
} catch (e) {
|
||||
alert_assert('TEST COMPLETE');
|
||||
}
|
||||
|
@ -31,6 +31,10 @@ connect-src 'self'; script-src 'self' 'unsafe-inline'; child-src *;
|
||||
worker.onmessage = function(event) {
|
||||
alert_assert(event.data);
|
||||
};
|
||||
worker.onerror = function(event) {
|
||||
event.preventDefault();
|
||||
alert_assert('TEST COMPLETE');
|
||||
}
|
||||
} catch (e) {
|
||||
alert_assert('TEST COMPLETE');
|
||||
}
|
||||
|
@ -20,6 +20,9 @@ child-src 'none'; script-src 'self' 'unsafe-inline' 'unsafe-inline'; connect-src
|
||||
foo.onmessage = function(event) {
|
||||
alert_assert("FAIL");
|
||||
};
|
||||
foo.onerror = function(e) {
|
||||
alert_assert("PASS");
|
||||
}
|
||||
} catch (e) {
|
||||
alert_assert("PASS");
|
||||
}
|
||||
|
@ -83,7 +83,8 @@ function setAttributes(el, attrs) {
|
||||
function bindEvents(element, resolveEventName, rejectEventName) {
|
||||
element.eventPromise = new Promise(function(resolve, reject) {
|
||||
element.addEventListener(resolveEventName || "load", resolve);
|
||||
element.addEventListener(rejectEventName || "error", reject);
|
||||
element.addEventListener(rejectEventName || "error",
|
||||
function(e) { e.preventDefault(); reject(); } );
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -4,9 +4,14 @@
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
test(function() {
|
||||
assert_throws("SECURITY_ERR", function() {
|
||||
new Worker("ftp://example.org/support/WorkerBasic.js");
|
||||
});
|
||||
async_test(function(t) {
|
||||
try {
|
||||
var w = new Worker("ftp://example.org/support/WorkerBasic.js");
|
||||
w.onerror = t.step_func_done(function(e) {
|
||||
assert_true(e instanceof ErrorEvent);
|
||||
});
|
||||
} catch (e) {
|
||||
t.step_func_done(function(e) { assert_true(true); });
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@ -12,35 +12,54 @@
|
||||
// not propogate to the window before the tests finish
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
function testSharedWorkerHelper(t, script) {
|
||||
try {
|
||||
var worker = new SharedWorker(script, '');
|
||||
worker.onerror = t.step_func_done(function(e) {
|
||||
assert_true(e instanceof ErrorEvent);
|
||||
});
|
||||
} catch (e) {
|
||||
t.step_func_done(function(e) { assert_true(true); });
|
||||
}
|
||||
}
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new SharedWorker('unsupported:', ''); });
|
||||
}, "unsupported_scheme");
|
||||
|
||||
async_test(function() {
|
||||
var worker = new SharedWorker('data:,onconnect = function(e) { e.ports[0].postMessage(1); }', '');
|
||||
worker.port.onmessage = this.step_func_done(function(e) {
|
||||
assert_equals(e.data, 1);
|
||||
});
|
||||
}, "data_url");
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new SharedWorker('javascript:""', ''); });
|
||||
|
||||
async_test(function(t) {
|
||||
testSharedWorkerHelper(this, 'javascript:""');
|
||||
}, "javascript_url");
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new SharedWorker('about:blank', ''); });
|
||||
|
||||
async_test(function(t) {
|
||||
testSharedWorkerHelper(this, 'about:blank');
|
||||
}, "about_blank");
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new SharedWorker('http://www.opera.com/', ''); });
|
||||
|
||||
async_test(function(t) {
|
||||
testSharedWorkerHelper(this, 'http://www.opera.com/');
|
||||
}, "opera_com");
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new SharedWorker(location.protocol+'//'+location.hostname+':81/', ''); });
|
||||
|
||||
async_test(function(t) {
|
||||
testSharedWorkerHelper(this, location.protocol+'//'+location.hostname+':81/');
|
||||
}, "port_81");
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new SharedWorker('https://'+location.hostname+':80/', ''); });
|
||||
|
||||
async_test(function(t) {
|
||||
testSharedWorkerHelper(this, 'https://'+location.hostname+':80/');
|
||||
}, "https_port_80");
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new SharedWorker('https://'+location.hostname+':8000/', ''); });
|
||||
|
||||
async_test(function(t) {
|
||||
testSharedWorkerHelper(this, 'https://'+location.hostname+':8000/');
|
||||
}, "https_port_8000");
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new SharedWorker('http://'+location.hostname+':8012/', ''); });
|
||||
|
||||
async_test(function(t) {
|
||||
testSharedWorkerHelper(this, 'http://'+location.hostname+':8012/');
|
||||
}, "http_port_8012");
|
||||
</script>
|
||||
<!--
|
||||
|
@ -10,6 +10,17 @@
|
||||
// not propogate to the window before the tests finish
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
function testSharedWorkerHelper(t, script) {
|
||||
try {
|
||||
var worker = new SharedWorker(script, '');
|
||||
worker.onerror = t.step_func_done(function(e) {
|
||||
assert_true(e instanceof ErrorEvent);
|
||||
});
|
||||
} catch (e) {
|
||||
t.step_func_done(function(e) { assert_true(true); });
|
||||
}
|
||||
}
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new Worker('unsupported:'); });
|
||||
}, "unsupported_scheme");
|
||||
@ -21,31 +32,32 @@ async_test(function() {
|
||||
});
|
||||
}, "data_url");
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new Worker('about:blank'); });
|
||||
async_test(function(t) {
|
||||
testSharedWorkerHelper(t, 'about:blank');
|
||||
}, "about_blank");
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new Worker('http://www.example.invalid/'); });
|
||||
async_test(function(t) {
|
||||
testSharedWorkerHelper(t, 'http://www.example.invalid/');
|
||||
}, "example_invalid");
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new Worker(location.protocol+'//'+location.hostname+':81/'); });
|
||||
async_test(function(t) {
|
||||
testSharedWorkerHelper(t, location.protocol+'//'+location.hostname+':81/');
|
||||
}, "port_81");
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new Worker('https://'+location.hostname+':80/'); });
|
||||
async_test(function(t) {
|
||||
testSharedWorkerHelper(t, 'https://'+location.hostname+':80/');
|
||||
}, "https_port_80");
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new Worker('https://'+location.hostname+':8000/'); });
|
||||
async_test(function(t) {
|
||||
testSharedWorkerHelper(t, 'https://'+location.hostname+':8000/');
|
||||
}, "https_port_8000");
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new Worker('http://'+location.hostname+':8012/'); });
|
||||
async_test(function(t) {
|
||||
testSharedWorkerHelper(t, 'http://'+location.hostname+':8012/');
|
||||
}, "http_post_8012");
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new Worker('javascript:""'); });
|
||||
async_test(function(t) {
|
||||
testSharedWorkerHelper(t,'javascript:""');
|
||||
}, "javascript_url");
|
||||
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user