Bug 118832

Summary: WorkerGlobalScope should support onoffline/ononline event handlers
Product: WebKit Reporter: Kwang Yul Seo <skyul>
Component: DOMAssignee: Kwang Yul Seo <skyul>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, benjamin, buildbot, cdumez, darin, haraken, rniwa, zarvai
Priority: P2 Keywords: WebExposed
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
URL: http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html#handler-workerglobalscope-onoffline
Attachments:
Description Flags
Patch
none
Patch
none
Archive of layout-test-results from webkit-ews-15 for mac-mountainlion-wk2
none
Patch
none
Patch ap: review+

Kwang Yul Seo
Reported 2013-07-17 22:28:19 PDT
http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html#handler-workerglobalscope-onoffline http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html#event-offline When the value that would be returned by the navigator.onLine attribute of a Window or WorkerGlobalScope changes from true to false, the user agent must queue a task to fire a simple event named offline at the Window or WorkerGlobalScope object. On the other hand, when the value that would be returned by the navigator.onLine attribute of a Window or WorkerGlobalScope changes from false to true, the user agent must queue a task to fire a simple event named online at the Window or WorkerGlobalScope object.
Attachments
Patch (17.89 KB, patch)
2013-07-17 23:30 PDT, Kwang Yul Seo
no flags
Patch (17.83 KB, patch)
2013-07-18 00:54 PDT, Kwang Yul Seo
no flags
Archive of layout-test-results from webkit-ews-15 for mac-mountainlion-wk2 (546.03 KB, application/zip)
2013-07-18 01:20 PDT, Build Bot
no flags
Patch (17.81 KB, patch)
2013-07-18 01:23 PDT, Kwang Yul Seo
no flags
Patch (19.94 KB, patch)
2013-07-18 16:49 PDT, Kwang Yul Seo
ap: review+
Kwang Yul Seo
Comment 1 2013-07-17 23:30:46 PDT
Chris Dumez
Comment 2 2013-07-18 00:30:49 PDT
Comment on attachment 206953 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=206953&action=review > Source/WebCore/platform/network/NetworkStateNotifier.cpp:-44 > - ASSERT(!m_networkStateChangedFunction); We should probably assert that function is not null. > Source/WebCore/platform/network/NetworkStateNotifier.h:69 > + typedef void (*NetworkStateChangedFunction)(bool m_isOnLine); I think we usually call them "Listener" not "Function". > Source/WebCore/workers/WorkerGlobalScope.cpp:120 > +static HashSet<WorkerGlobalScope*>* workerGlobalScopes; Why a pointer to a HashSet and not simply a HashSet? > Source/WebCore/workers/WorkerGlobalScope.cpp:160 > + ASSERT(!workerGlobalScopes->contains(this)); This can also be written as: AddResult addResult = workerGlobalScopes->add(this); ASSERT_UNUSED(addResult, addResult.isNewEntry); To look up only once.
Kwang Yul Seo
Comment 3 2013-07-18 00:54:59 PDT
Kwang Yul Seo
Comment 4 2013-07-18 00:56:45 PDT
(In reply to comment #2) > > Source/WebCore/platform/network/NetworkStateNotifier.cpp:-44 > > - ASSERT(!m_networkStateChangedFunction); > > We should probably assert that function is not null. Done. > > Source/WebCore/platform/network/NetworkStateNotifier.h:69 > > + typedef void (*NetworkStateChangedFunction)(bool m_isOnLine); > > I think we usually call them "Listener" not "Function". Okay. :s/Function/Listener/g and adjusted method and member variable names accordingly. > > Source/WebCore/workers/WorkerGlobalScope.cpp:120 > > +static HashSet<WorkerGlobalScope*>* workerGlobalScopes; > > Why a pointer to a HashSet and not simply a HashSet? I followed the convention used in Page.cpp: static HashSet<Page*>* allPages; > > Source/WebCore/workers/WorkerGlobalScope.cpp:160 > > + ASSERT(!workerGlobalScopes->contains(this)); > > This can also be written as: > AddResult addResult = workerGlobalScopes->add(this); > ASSERT_UNUSED(addResult, addResult.isNewEntry); > > To look up only once. Done.
Build Bot
Comment 5 2013-07-18 01:20:02 PDT
Comment on attachment 206960 [details] Patch Attachment 206960 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.appspot.com/results/1104423 New failing tests: http/tests/security/cross-origin-plugin-private-browsing-toggled.html
Build Bot
Comment 6 2013-07-18 01:20:04 PDT
Created attachment 206961 [details] Archive of layout-test-results from webkit-ews-15 for mac-mountainlion-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: webkit-ews-15 Port: mac-mountainlion-wk2 Platform: Mac OS X 10.8.3
Kwang Yul Seo
Comment 7 2013-07-18 01:23:10 PDT
Alexey Proskuryakov
Comment 8 2013-07-18 09:26:00 PDT
Comment on attachment 206962 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=206962&action=review > Source/WebCore/workers/WorkerGlobalScope.cpp:118 > +static Mutex& workerGlobalScopeSetMutex() > +{ > + AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); > + return mutex; > +} This is not cool, adding mutexes complicates the design and makes deadlocks more likely. Talking to workers should be done through WorkerGlobalScopeProxy, there is no need to create new cross-thread messaging mechanisms for that.
Kwang Yul Seo
Comment 9 2013-07-18 15:50:07 PDT
(In reply to comment #8) > This is not cool, adding mutexes complicates the design and makes deadlocks more likely. > > Talking to workers should be done through WorkerGlobalScopeProxy, there is no need to create new cross-thread messaging mechanisms for that. I see your point. I will rework the patch to use WorkerGlobalScopeProxy. Thanks for the comment.
Kwang Yul Seo
Comment 10 2013-07-18 16:49:06 PDT
Alexey Proskuryakov
Comment 11 2013-07-18 21:51:54 PDT
Comment on attachment 207034 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=207034&action=review Looks good to me. Please consider the suggestion below. > Source/WebCore/platform/network/NetworkStateNotifier.h:84 > + HashSet<NetworkStateChangeListener> m_listeners; Given that there is no way to remove from the set, and that the only operation we need is iteration, it seems much more efficient to use a vector than a HashSet.
Kwang Yul Seo
Comment 12 2013-07-18 21:53:36 PDT
(In reply to comment #11) > Looks good to me. Please consider the suggestion below. > > > Source/WebCore/platform/network/NetworkStateNotifier.h:84 > > + HashSet<NetworkStateChangeListener> m_listeners; > > Given that there is no way to remove from the set, and that the only operation we need is iteration, it seems much more efficient to use a vector than a HashSet. Thanks for the review. I will change HashSet to Vector as you suggested before landing the patch.
Kwang Yul Seo
Comment 13 2013-07-18 22:06:05 PDT
Zoltan Arvai
Comment 14 2013-07-19 04:12:34 PDT
(In reply to comment #13) > Committed r152885: <http://trac.webkit.org/changeset/152885> It seems the debug bots are in big trouble after the commit. On Qt debug we got 29501 failures. All debug bots on Apple master have "Failed exiting early after 50 crashes and 0 timeouts."
Kwang Yul Seo
Comment 15 2013-07-19 04:21:27 PDT
(In reply to comment #14) > (In reply to comment #13) > > Committed r152885: <http://trac.webkit.org/changeset/152885> > > It seems the debug bots are in big trouble after the commit. > On Qt debug we got 29501 failures. All debug bots on Apple master have "Failed exiting early after 50 crashes and 0 timeouts." Oops. I will fix it soon.
Kwang Yul Seo
Comment 16 2013-07-19 04:53:42 PDT
(In reply to comment #14) > (In reply to comment #13) > > Committed r152885: <http://trac.webkit.org/changeset/152885> > > It seems the debug bots are in big trouble after the commit. > On Qt debug we got 29501 failures. All debug bots on Apple master have "Failed exiting early after 50 crashes and 0 timeouts." Fixed. http://trac.webkit.org/changeset/152894
Note You need to log in before you can comment on or make changes to this bug.