Diff
Modified: trunk/LayoutTests/ChangeLog (229482 => 229483)
--- trunk/LayoutTests/ChangeLog 2018-03-09 21:45:51 UTC (rev 229482)
+++ trunk/LayoutTests/ChangeLog 2018-03-09 21:47:31 UTC (rev 229483)
@@ -1,3 +1,15 @@
+2018-03-09 Youenn Fablet <[email protected]>
+
+ ServiceWorker should respect IDB and DOMCache partitioning
+ https://bugs.webkit.org/show_bug.cgi?id=183496
+
+ Reviewed by Brady Eidson.
+
+ * http/wpt/service-workers/resources/third-party-registration-frame.html: Added.
+ * http/wpt/service-workers/resources/third-party-worker.js: Added.
+ * http/wpt/service-workers/third-party-registration-expected.txt: Added.
+ * http/wpt/service-workers/third-party-registration.html: Added.
+
2018-03-09 Jer Noble <[email protected]>
Add new CSS env constants for use with fullscreen
Added: trunk/LayoutTests/http/wpt/service-workers/resources/third-party-registration-frame.html (0 => 229483)
--- trunk/LayoutTests/http/wpt/service-workers/resources/third-party-registration-frame.html (rev 0)
+++ trunk/LayoutTests/http/wpt/service-workers/resources/third-party-registration-frame.html 2018-03-09 21:47:31 UTC (rev 229483)
@@ -0,0 +1,34 @@
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+var activeWorker;
+async function doTest()
+{
+ registration = await navigator.serviceWorker.getRegistration(".");
+ if (registration)
+ await registration.unregister();
+ registration = await navigator.serviceWorker.register("third-party-worker.js", { scope : "." });
+ activeWorker = registration.active;
+ if (activeWorker)
+ return;
+ activeWorker = registration.installing;
+ await new Promise(resolve => {
+ activeWorker.addEventListener('statechange', () => {
+ if (activeWorker.state === "activated")
+ resolve();
+ });
+ });
+}
+window._onmessage_ = async (e) => {
+ await doTest();
+ navigator.serviceWorker._onmessage_ = (e) => {
+ parent.postMessage(e.data, '*');
+ }
+ activeWorker.postMessage(e.data);
+}
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/wpt/service-workers/resources/third-party-worker.js (0 => 229483)
--- trunk/LayoutTests/http/wpt/service-workers/resources/third-party-worker.js (rev 0)
+++ trunk/LayoutTests/http/wpt/service-workers/resources/third-party-worker.js 2018-03-09 21:47:31 UTC (rev 229483)
@@ -0,0 +1,76 @@
+addEventListener('activate', async (e) => {
+ await self.clients.claim();
+});
+addEventListener('message', async (e) => {
+ if (e.data ="" 'write') {
+ await writeDB();
+ await self.caches.open(e.data);
+ e.source.postMessage('written');
+ return;
+ }
+ if (e.data ="" 'read') {
+ var keys = await self.caches.keys();
+ var db = await readDB();
+ if (!db)
+ db = null;
+ var result = { cache : keys, db : db };
+ e.source.postMessage(JSON.stringify(result));
+ return;
+ }
+ e.source.postMessage('error');
+});
+
+function readDB() {
+ return new Promise(function(resolve, reject) {
+ var openRequest = indexedDB.open('db');
+
+ openRequest._onerror_ = reject;
+ openRequest._onupgradeneeded_ = function() {
+ var db = openRequest.result;
+ db.createObjectStore('store');
+ };
+
+ openRequest._onsuccess_ = function() {
+ var db = openRequest.result;
+ var tx = db.transaction('store');
+ var store = tx.objectStore('store');
+ var getRequest = store.get('key');
+
+ getRequest._onerror_ = function() {
+ db.close();
+ reject(getRequest.error);
+ };
+ getRequest._onsuccess_ = function() {
+ db.close();
+ resolve(getRequest.result);
+ };
+ };
+ });
+}
+
+function writeDB() {
+ return new Promise(function(resolve, reject) {
+ var openRequest = indexedDB.open('db');
+
+ openRequest._onerror_ = reject;
+ openRequest._onupgradeneeded_ = function() {
+ var db = openRequest.result;
+ db.createObjectStore('store');
+ };
+ openRequest._onsuccess_ = function() {
+ var db = openRequest.result;
+ var tx = db.transaction('store', 'readwrite');
+ var store = tx.objectStore('store');
+ store.put('value', 'key');
+
+ tx._onerror_ = function() {
+ db.close();
+ reject(tx.error);
+ };
+ tx._oncomplete_ = function() {
+ db.close();
+ resolve();
+ };
+ };
+ });
+}
Added: trunk/LayoutTests/http/wpt/service-workers/third-party-registration-expected.txt (0 => 229483)
--- trunk/LayoutTests/http/wpt/service-workers/third-party-registration-expected.txt (rev 0)
+++ trunk/LayoutTests/http/wpt/service-workers/third-party-registration-expected.txt 2018-03-09 21:47:31 UTC (rev 229483)
@@ -0,0 +1 @@
+PASS
Added: trunk/LayoutTests/http/wpt/service-workers/third-party-registration.html (0 => 229483)
--- trunk/LayoutTests/http/wpt/service-workers/third-party-registration.html (rev 0)
+++ trunk/LayoutTests/http/wpt/service-workers/third-party-registration.html 2018-03-09 21:47:31 UTC (rev 229483)
@@ -0,0 +1,37 @@
+<html>
+<head>
+<title>Service Worker third party registration</title>
+<script src=""
+</head>
+<body>
+<script>
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+}
+
+var shouldTest = !!window.location.hash;
+async function doTest()
+{
+ var iframe = await with_iframe("http://127.0.0.1:8801/WebKit/service-workers/resources/third-party-registration-frame.html");
+ var result = await new Promise((resolve) => {
+ window._onmessage_ = (e) => {
+ resolve(e.data);
+ };
+ iframe.contentWindow.postMessage(shouldTest ? "read" : "write", '*');
+ });
+ if (shouldTest) {
+ var expected = '{\"cache\":[],\"db\":null}';
+ document.body.innerHTML = result === expected ? "PASS" : ("FAIL: got " + result);
+ if (window.testRunner)
+ testRunner.notifyDone();
+ return;
+ }
+ iframe.remove();
+ window.location = "http://localhost:8801/WebKit/service-workers/third-party-registration.html#second";
+}
+doTest();
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (229482 => 229483)
--- trunk/Source/WebCore/ChangeLog 2018-03-09 21:45:51 UTC (rev 229482)
+++ trunk/Source/WebCore/ChangeLog 2018-03-09 21:47:31 UTC (rev 229483)
@@ -1,5 +1,19 @@
2018-03-09 Youenn Fablet <[email protected]>
+ ServiceWorker should respect IDB and DOMCache partitioning
+ https://bugs.webkit.org/show_bug.cgi?id=183496
+
+ Reviewed by Brady Eidson.
+
+ Test: http/wpt/service-workers/third-party-registration.html
+
+ Set the correct top origin of service worker ScriptExecutionContext.
+
+ * workers/service/context/ServiceWorkerThread.cpp:
+ (WebCore::ServiceWorkerThread::ServiceWorkerThread):
+
+2018-03-09 Youenn Fablet <[email protected]>
+
Cannot change audio input source device
https://bugs.webkit.org/show_bug.cgi?id=175975
<rdar://problem/34073589>
Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp (229482 => 229483)
--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp 2018-03-09 21:45:51 UTC (rev 229482)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp 2018-03-09 21:47:31 UTC (rev 229483)
@@ -71,7 +71,7 @@
// FIXME: Use valid runtime flags
ServiceWorkerThread::ServiceWorkerThread(const ServiceWorkerContextData& data, PAL::SessionID, String&& userAgent, WorkerLoaderProxy& loaderProxy, WorkerDebuggerProxy& debuggerProxy, IDBClient::IDBConnectionProxy* idbConnectionProxy, SocketProvider* socketProvider)
- : WorkerThread(data.scriptURL, "serviceworker:" + Inspector::IdentifiersFactory::createIdentifier(), WTFMove(userAgent), NetworkStateNotifier::singleton().onLine(), data.script, loaderProxy, debuggerProxy, DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, data.contentSecurityPolicy, false, SecurityOrigin::create(data.scriptURL).get(), MonotonicTime::now(), idbConnectionProxy, socketProvider, JSC::RuntimeFlags::createAllEnabled(), data.sessionID)
+ : WorkerThread(data.scriptURL, "serviceworker:" + Inspector::IdentifiersFactory::createIdentifier(), WTFMove(userAgent), NetworkStateNotifier::singleton().onLine(), data.script, loaderProxy, debuggerProxy, DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, data.contentSecurityPolicy, false, data.registration.key.topOrigin().securityOrigin().get(), MonotonicTime::now(), idbConnectionProxy, socketProvider, JSC::RuntimeFlags::createAllEnabled(), data.sessionID)
, m_data(data.isolatedCopy())
, m_workerObjectProxy(DummyServiceWorkerThreadProxy::shared())
{