Skip to content

Commit

Permalink
FetchEvent should not forcibly reject an unresolved Promise when dest…
Browse files Browse the repository at this point in the history
…ructed

Currently an unresolved Promise on RespondWithObserver is forcibly rejected
when the RespondWithObserver is destructed. This means that an unresolved Promise
registered with fetchEvent.respondWith() is forcibly rejected when the fetchEvent
is destructed. This behavior is not good because it makes GC observable.
(For more details, see comment #2 and #4 in the CL discussion.)

Given the above, this CL stops rejecting an unresolved Promise in
RespondWithObserver's destructor. Also this CL removes a test that were
testing the behavior. The removed test should hang after this change
(because an unresolved Promise is never resolved nor rejected).

BUG=400645

Review URL: https://codereview.chromium.org/442183003

git-svn-id: svn://svn.chromium.org/blink/trunk@179695 bbb929c8-8fbe-4397-9dbb-9b2b20218538
  • Loading branch information
[email protected] committed Aug 7, 2014
1 parent 71d21e2 commit e414ddb
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 25 deletions.
18 changes: 0 additions & 18 deletions LayoutTests/http/tests/serviceworker/fetch-event.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,6 @@
.catch(unreached_rejection(t));
}());

(function() {
var t = async_test(
'Service Worker responds to fetch event with unresolved promise');
var scope = 'resources/simple.html?unresolved';
service_worker_unregister_and_register(t, worker, scope)
.then(t.step_func(function(sw) {
return wait_for_state(t, sw, 'activated');
}))
.then(t.step_func(function() { return with_iframe(scope); }))
.then(t.step_func(function(frame) {
assert_equals(frame.contentDocument.body.textContent,
'Here\'s a simple html file.\n',
'Response should come from fallback to native fetch');
return service_worker_unregister_and_done(t, scope);
}))
.catch(unreached_rejection(t));
}());

(function() {
var t = async_test('Service Worker fetches other file in fetch event');
var scope = 'resources/simple.html?fetch';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ function handleReject(event) {
}));
}

function handleUnresolved(event) {
event.respondWith(new Promise(function(resolve, reject) { }));
}

function handleFetch(event) {
event.respondWith(fetch('other.html'));
}
Expand All @@ -37,7 +33,6 @@ self.addEventListener('fetch', function(event) {
{ pattern: '?ignore', fn: function() {} },
{ pattern: '?null', fn: handleNullBody },
{ pattern: '?reject', fn: handleReject },
{ pattern: '?unresolved', fn: handleUnresolved },
{ pattern: '?fetch', fn: handleFetch }
];

Expand Down
2 changes: 0 additions & 2 deletions Source/modules/serviceworkers/RespondWithObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ PassRefPtr<RespondWithObserver> RespondWithObserver::create(ExecutionContext* co

RespondWithObserver::~RespondWithObserver()
{
if (m_state == Pending)
sendResponse(nullptr);
}

void RespondWithObserver::contextDestroyed()
Expand Down

0 comments on commit e414ddb

Please sign in to comment.