Title: [193363] trunk
Revision
193363
Author
bfulg...@apple.com
Date
2015-12-03 12:06:17 -0800 (Thu, 03 Dec 2015)

Log Message

Allow _javascript_ to iterate over plugins for local files
https://bugs.webkit.org/show_bug.cgi?id=151783
<rdar://problem/23692113>

Source/WebCore:

Reviewed by Alexey Proskuryakov.

Test: http/tests/plugins/plugin-_javascript_-access.html
      plugins/plugin-_javascript_-access.html

* page/Page.cpp:
(WebCore::Page::showAllPlugins): True if we set the debugging flag to show
all plugins, or if the document's origin is from a local file.
* page/Page.h:

LayoutTests:

Modify the existing 'local file' plugin tests so that they don't turn on the debugging
flag to allow iterating over all plugins. Then create a new HTTP test (based on the
existing plugin-_javascript_-access test) to make sure that plugin iteration is blocked
for non-local-file access.

Reviewed by Alexey Proskuryakov.

* http/tests/plugins/plugin-_javascript_-access-expected.txt: Added.
* http/tests/plugins/plugin-_javascript_-access.html: Added.
* plugins/plugin-_javascript_-access.html: Remove unneeded 'internals.setShowAllPlugins' call.
* plugins/script-tests/navigator-mimeTypes-length.js: Ditto.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (193362 => 193363)


--- trunk/LayoutTests/ChangeLog	2015-12-03 20:01:57 UTC (rev 193362)
+++ trunk/LayoutTests/ChangeLog	2015-12-03 20:06:17 UTC (rev 193363)
@@ -1,3 +1,21 @@
+2015-12-03  Brent Fulgham  <bfulg...@apple.com>
+
+        Allow _javascript_ to iterate over plugins for local files
+        https://bugs.webkit.org/show_bug.cgi?id=151783
+        <rdar://problem/23692113>
+
+        Modify the existing 'local file' plugin tests so that they don't turn on the debugging
+        flag to allow iterating over all plugins. Then create a new HTTP test (based on the
+        existing plugin-_javascript_-access test) to make sure that plugin iteration is blocked
+        for non-local-file access.
+
+        Reviewed by Alexey Proskuryakov.
+
+        * http/tests/plugins/plugin-_javascript_-access-expected.txt: Added.
+        * http/tests/plugins/plugin-_javascript_-access.html: Added.
+        * plugins/plugin-_javascript_-access.html: Remove unneeded 'internals.setShowAllPlugins' call.
+        * plugins/script-tests/navigator-mimeTypes-length.js: Ditto.
+
 2015-12-03  Brady Eidson  <beid...@apple.com>
 
         Modern IDB: storage/indexeddb/cursor-skip-deleted.html fails.

Added: trunk/LayoutTests/http/tests/plugins/plugin-_javascript_-access-expected.txt (0 => 193363)


--- trunk/LayoutTests/http/tests/plugins/plugin-_javascript_-access-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/plugins/plugin-_javascript_-access-expected.txt	2015-12-03 20:06:17 UTC (rev 193363)
@@ -0,0 +1,41 @@
+Test 1: A non-local file should not be able to iterate over the plugins.
+
+PASS! (Could not find the netscape test plugin on a non-local file!)
+
+Test 2: Confirm the plugin is present.
+
+Name: WebKit Test PlugIn
+
+Description: Simple Netscape plug-in that handles test content for WebKit
+
+Filename: TestNetscapePlugIn.plugin
+
+Mime Types:
+
+Type: application/x-webkit-test-netscape
+
+Description: test netscape content
+
+Suffixes: testnetscape
+
+
+Plugin.item() works.
+
+Plugin.namedItem() works.
+
+Type: image/png
+
+Description: PNG image
+
+Suffixes: png
+
+
+Plugin.item() works.
+
+Plugin.namedItem() works.
+
+PluginArray.item() works.
+
+PluginArray.namedItem() works.
+
+PASS! (Found the netscape test plugin on a non-local file!)

Added: trunk/LayoutTests/http/tests/plugins/plugin-_javascript_-access.html (0 => 193363)


--- trunk/LayoutTests/http/tests/plugins/plugin-_javascript_-access.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/plugins/plugin-_javascript_-access.html	2015-12-03 20:06:17 UTC (rev 193363)
@@ -0,0 +1,77 @@
+<html>
+<head>
+    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+    <title>Installed Plug-ins</title>
+</head>
+<body>
+<script type="application/x-_javascript_">
+function checkForTestPlugin() {
+    for (var i = 0; i < navigator.plugins.length; i++) {
+        var plugin = navigator.plugins[i];
+
+        // We can only guarantee that the Test PlugIn is installed.
+        if (plugin.name != "WebKit Test PlugIn")
+            continue;
+
+        document.writeln("<p>Name: " + plugin.name + "<\/p>");
+        document.writeln("<p>Description: " + plugin.description + "<\/p>");
+        document.writeln("<p>Filename: " + plugin.filename + "<\/p>");
+
+        document.writeln("<p>Mime Types:<\/p>");
+        for (var mi = 0; mi != plugin.length; ++mi) {
+            document.writeln("<p>Type: " + plugin[mi].type + "<\/p>");
+            document.writeln("<p>Description: " + plugin[mi].description + "<\/p>");
+            document.writeln("<p>Suffixes: " + plugin[mi].suffixes + "<\/p>");
+            document.writeln("<br>");
+
+            if (plugin.item(mi).type == plugin[mi].type)
+                document.writeln("<p>Plugin.item() works.<\/p>");
+            else
+                document.writeln("<p>FAIL. Plugin.item() does not work.<\/p>");
+
+            if (plugin.namedItem(plugin[mi].type).type == plugin[mi].type)
+                document.writeln("<p>Plugin.namedItem() works.<\/p>");
+            else
+                document.writeln("<p>FAIL. Plugin.namedItem() does not work.<\/p>");
+        }
+
+        if (navigator.plugins.item(i).name == plugin.name)
+            document.writeln("<p>PluginArray.item() works.<\/p>");
+        else
+            document.writeln("<p>FAIL. PluginArray.item() does not work.<\/p>");
+
+        if (navigator.plugins.namedItem(plugin.name).name == plugin.name)
+            document.writeln("<p>PluginArray.namedItem() works.<\/p>");
+        else
+            document.writeln("<p>FAIL. PluginArray.namedItem() does not work.<\/p>");
+
+        return true;
+    }
+
+    return false;
+}
+   
+if (window.testRunner)
+    testRunner.dumpAsText()
+
+navigator.plugins.refresh(false); // Supposedly helps if new plug-ins were added.
+
+// A non-local file should not be allowed to iterate over the installed plugins.
+document.writeln("<p>Test 1: A non-local file should not be able to iterate over the plugins.<\/p>");
+if (checkForTestPlugin())
+    document.writeln("<p>FAILURE!  (Found the netscape test plugin on a non-local file!)<\/p>");
+else
+    document.writeln("<p>PASS!  (Could not find the netscape test plugin on a non-local file!)<\/p>");
+
+// Activate our debugging code to show all plugins to confirm we do have the test plugin.
+document.writeln("<p>Test 2: Confirm the plugin is present.<\/p>");
+if (window.internals)
+    internals.setShowAllPlugins(true);
+
+if (checkForTestPlugin())
+    document.writeln("<p>PASS!  (Found the netscape test plugin on a non-local file!)<\/p>");
+else
+    document.writeln("<p>FAILURE!  (Could not find netscape test plugin on a non-local file!)<\/p>");
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/plugins/plugin-_javascript_-access.html (193362 => 193363)


--- trunk/LayoutTests/plugins/plugin-_javascript_-access.html	2015-12-03 20:01:57 UTC (rev 193362)
+++ trunk/LayoutTests/plugins/plugin-_javascript_-access.html	2015-12-03 20:06:17 UTC (rev 193363)
@@ -8,9 +8,6 @@
 if (window.testRunner)
     testRunner.dumpAsText()
 
-if (window.internals)
-    internals.setShowAllPlugins(true);
-
 navigator.plugins.refresh(false); // Supposedly helps if new plug-ins were added.
 
 var foundTestPlugin = false;

Modified: trunk/LayoutTests/plugins/script-tests/navigator-mimeTypes-length.js (193362 => 193363)


--- trunk/LayoutTests/plugins/script-tests/navigator-mimeTypes-length.js	2015-12-03 20:01:57 UTC (rev 193362)
+++ trunk/LayoutTests/plugins/script-tests/navigator-mimeTypes-length.js	2015-12-03 20:06:17 UTC (rev 193363)
@@ -2,9 +2,6 @@
 "Test for bug 10038: REGRESSION: Length of navigator.mimeTypes collection returns number of installed plugins, not number of registered mime types."
 );
 
-if (window.internals)
-    internals.setShowAllPlugins(true);
-
 var numberOfMimeTypes = 0;
 for (var i = 0; i < navigator.plugins.length; ++i) {
     var plugin = navigator.plugins[i];

Modified: trunk/Source/WebCore/ChangeLog (193362 => 193363)


--- trunk/Source/WebCore/ChangeLog	2015-12-03 20:01:57 UTC (rev 193362)
+++ trunk/Source/WebCore/ChangeLog	2015-12-03 20:06:17 UTC (rev 193363)
@@ -1,3 +1,19 @@
+2015-12-03  Brent Fulgham  <bfulg...@apple.com>
+
+        Allow _javascript_ to iterate over plugins for local files
+        https://bugs.webkit.org/show_bug.cgi?id=151783
+        <rdar://problem/23692113>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Test: http/tests/plugins/plugin-_javascript_-access.html
+              plugins/plugin-_javascript_-access.html
+
+        * page/Page.cpp:
+        (WebCore::Page::showAllPlugins): True if we set the debugging flag to show
+        all plugins, or if the document's origin is from a local file.
+        * page/Page.h:
+
 2015-12-03  Jer Noble  <jer.no...@apple.com>
 
         Unreviewed build-fix; missing include.

Modified: trunk/Source/WebCore/page/Page.cpp (193362 => 193363)


--- trunk/Source/WebCore/page/Page.cpp	2015-12-03 20:01:57 UTC (rev 193362)
+++ trunk/Source/WebCore/page/Page.cpp	2015-12-03 20:06:17 UTC (rev 193363)
@@ -31,6 +31,7 @@
 #include "ContextMenuClient.h"
 #include "ContextMenuController.h"
 #include "DatabaseProvider.h"
+#include "DocumentLoader.h"
 #include "DocumentMarkerController.h"
 #include "DragController.h"
 #include "Editor.h"
@@ -519,6 +520,11 @@
     return *m_pluginData;
 }
 
+bool Page::showAllPlugins() const
+{
+    return m_showAllPlugins || mainFrame().loader().documentLoader()->url().isLocalFile();
+}
+
 inline MediaCanStartListener* Page::takeAnyMediaCanStartListener()
 {
     for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {

Modified: trunk/Source/WebCore/page/Page.h (193362 => 193363)


--- trunk/Source/WebCore/page/Page.h	2015-12-03 20:01:57 UTC (rev 193362)
+++ trunk/Source/WebCore/page/Page.h	2015-12-03 20:06:17 UTC (rev 193363)
@@ -487,7 +487,7 @@
 #endif
 
     void setShowAllPlugins(bool showAll) { m_showAllPlugins = showAll; }
-    bool showAllPlugins() const { return m_showAllPlugins; }
+    bool showAllPlugins() const;
 
 private:
     WEBCORE_EXPORT void initGroup();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to