Commit 84ce5770 authored by weinig@apple.com's avatar weinig@apple.com

WebCore:

2008-11-04  Sam Weinig  <sam@webkit.org>

        Reviewed by Simon Hausmann.

        Fix https://bugs.webkit.org/show_bug.cgi?id=21648
        navigator.mimeTypes and navigator.plugins don't expose item and namedItem to JS

        - Also adds constructors for Plugin, PluginArray, MimeType and MimeTypeArray.

        * bindings/js/JSMimeTypeArrayCustom.cpp:
        (WebCore::JSMimeTypeArray::nameGetter):
        * bindings/js/JSPluginArrayCustom.cpp:
        (WebCore::JSPluginArray::nameGetter):
        * page/DOMWindow.idl:
        * plugins/MimeType.idl:
        * plugins/MimeTypeArray.cpp:
        (WebCore::MimeTypeArray::namedItem):
        * plugins/MimeTypeArray.h:
        * plugins/MimeTypeArray.idl:
        * plugins/Plugin.idl:
        * plugins/PluginArray.cpp:
        (WebCore::PluginArray::namedItem):
        * plugins/PluginArray.h:
        * plugins/PluginArray.idl:

LayoutTests:

2008-11-04  Sam Weinig  <sam@webkit.org>

        Reviewed by Simon Hausmann.

        Update tests for https://bugs.webkit.org/show_bug.cgi?id=21648
        navigator.mimeTypes and navigator.plugins don't expose item and namedItem to JS

        * fast/dom/Window/window-properties-expected.txt:
        * fast/js/global-constructors-expected.txt:
        * plugins/plugin-javascript-access-expected.txt:
        * plugins/plugin-javascript-access.html:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@38129 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6a8fa334
2008-11-04 Sam Weinig <sam@webkit.org>
Reviewed by Simon Hausmann.
Update tests for https://bugs.webkit.org/show_bug.cgi?id=21648
navigator.mimeTypes and navigator.plugins don't expose item and namedItem to JS
* fast/dom/Window/window-properties-expected.txt:
* fast/js/global-constructors-expected.txt:
* plugins/plugin-javascript-access-expected.txt:
* plugins/plugin-javascript-access.html:
2008-11-05 Pierre-Olivier Latour <pol@apple.com>
Rubber-stamped by Dan Bernstein.
......
......@@ -919,6 +919,12 @@ window.MessagePort.prototype.postMessage [function]
window.MessagePort.prototype.removeEventListener [function]
window.MessagePort.prototype.start [function]
window.MessagePort.prototype.startConversation [function]
window.MimeType [object MimeTypeConstructor]
window.MimeType.prototype [object MimeTypePrototype]
window.MimeTypeArray [object MimeTypeArrayConstructor]
window.MimeTypeArray.prototype [object MimeTypeArrayPrototype]
window.MimeTypeArray.prototype.item [function]
window.MimeTypeArray.prototype.namedItem [function]
window.MouseEvent [object MouseEventConstructor]
window.MouseEvent.prototype [printed above as window.Event.prototype]
window.MutationEvent [object MutationEventConstructor]
......@@ -1034,6 +1040,13 @@ window.OverflowEvent.BOTH [number]
window.OverflowEvent.HORIZONTAL [number]
window.OverflowEvent.VERTICAL [number]
window.OverflowEvent.prototype [printed above as window.Event.prototype]
window.Plugin [object PluginConstructor]
window.Plugin.prototype [object PluginPrototype]
window.PluginArray [object PluginArrayConstructor]
window.PluginArray.prototype [object PluginArrayPrototype]
window.PluginArray.prototype.item [function]
window.PluginArray.prototype.namedItem [function]
window.PluginArray.prototype.refresh [function]
window.ProcessingInstruction [object ProcessingInstructionConstructor]
window.ProcessingInstruction.prototype [printed above as window.Node.prototype]
window.ProgressEvent [object ProgressEventConstructor]
......@@ -1436,13 +1449,10 @@ window.clientInformation.appVersion [string]
window.clientInformation.cookieEnabled [boolean]
window.clientInformation.javaEnabled [function]
window.clientInformation.language [string]
window.clientInformation.mimeTypes [object MimeTypeArray]
window.clientInformation.mimeTypes.length [number]
window.clientInformation.mimeTypes [printed above as window.MimeTypeArray.prototype]
window.clientInformation.onLine [boolean]
window.clientInformation.platform [string]
window.clientInformation.plugins [object PluginArray]
window.clientInformation.plugins.length [number]
window.clientInformation.plugins.refresh [function]
window.clientInformation.plugins [printed above as window.PluginArray.prototype]
window.clientInformation.product [string]
window.clientInformation.productSub [string]
window.clientInformation.userAgent [string]
......
......@@ -108,6 +108,8 @@ PASS MediaList.toString() is '[object MediaListConstructor]'
PASS MessageChannel.toString() is '[object MessageChannelConstructor]'
PASS MessageEvent.toString() is '[object MessageEventConstructor]'
PASS MessagePort.toString() is '[object MessagePortConstructor]'
PASS MimeType.toString() is '[object MimeTypeConstructor]'
PASS MimeTypeArray.toString() is '[object MimeTypeArrayConstructor]'
PASS MouseEvent.toString() is '[object MouseEventConstructor]'
PASS MutationEvent.toString() is '[object MutationEventConstructor]'
PASS NamedNodeMap.toString() is '[object NamedNodeMapConstructor]'
......@@ -117,6 +119,8 @@ PASS NodeList.toString() is '[object NodeListConstructor]'
PASS Notation.toString() is '[object NotationConstructor]'
PASS Option.toString() is '[object OptionConstructor]'
PASS OverflowEvent.toString() is '[object OverflowEventConstructor]'
PASS Plugin.toString() is '[object PluginConstructor]'
PASS PluginArray.toString() is '[object PluginArrayConstructor]'
PASS ProcessingInstruction.toString() is '[object ProcessingInstructionConstructor]'
PASS ProgressEvent.toString() is '[object ProgressEventConstructor]'
PASS Range.toString() is '[object RangeConstructor]'
......
......@@ -13,4 +13,16 @@ Description: test netscape content
Suffixes: testnetscape
PluginArray.item() works.
PluginArray.namedItem() works.
Type: application/x-webkit-test-netscape
Description: test netscape content
Suffixes: testnetscape
MimeTypeArray.item() works.
MimeTypeArray.namedItem() works.
......@@ -8,15 +8,13 @@
if (window.layoutTestController)
layoutTestController.dumpAsText()
var plugins = navigator.plugins;
plugins.refresh(false); // Supposedly helps if new plug-ins were added.
navigator.plugins.refresh(false); // Supposedly helps if new plug-ins were added.
var foundTestPlugin = false;
for (var pi = 0; pi != plugins.length; pi++) {
var plugin = plugins[pi];
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;
......@@ -34,6 +32,42 @@ for (var pi = 0; pi != plugins.length; pi++) {
document.writeln("<p>Suffixes: " + plugin[mi].suffixes + "<\/p>");
document.writeln("<br>");
}
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>");
}
}
for (var i = 0; i < navigator.mimeTypes.length; i++) {
var mimeType = navigator.mimeTypes[i];
// We can only guarantee that the Test PlugIn is installed.
if (mimeType.type != "application/x-webkit-test-netscape")
continue;
document.writeln("<p>Type: " + mimeType.type + "<\/p>");
document.writeln("<p>Description: " + mimeType.description + "<\/p>");
document.writeln("<p>Suffixes: " + mimeType.suffixes + "<\/p>");
if (navigator.mimeTypes.item(i).type == mimeType.type) {
document.writeln("<p>MimeTypeArray.item() works.<\/p>");
} else {
document.writeln("<p>FAIL. MimeTypeArray.item() does not work.<\/p>");
}
if (navigator.mimeTypes.namedItem(mimeType.type).type == mimeType.type) {
document.writeln("<p>MimeTypeArray.namedItem() works.<\/p>");
} else {
document.writeln("<p>FAIL. MimeTypeArray.namedItem() does not work.<\/p>");
}
}
if (!foundTestPlugin)
......
2008-11-04 Sam Weinig <sam@webkit.org>
Reviewed by Simon Hausmann.
Fix https://bugs.webkit.org/show_bug.cgi?id=21648
navigator.mimeTypes and navigator.plugins don't expose item and namedItem to JS
- Also adds constructors for Plugin, PluginArray, MimeType and MimeTypeArray.
* bindings/js/JSMimeTypeArrayCustom.cpp:
(WebCore::JSMimeTypeArray::nameGetter):
* bindings/js/JSPluginArrayCustom.cpp:
(WebCore::JSPluginArray::nameGetter):
* page/DOMWindow.idl:
* plugins/MimeType.idl:
* plugins/MimeTypeArray.cpp:
(WebCore::MimeTypeArray::namedItem):
* plugins/MimeTypeArray.h:
* plugins/MimeTypeArray.idl:
* plugins/Plugin.idl:
* plugins/PluginArray.cpp:
(WebCore::PluginArray::namedItem):
* plugins/PluginArray.h:
* plugins/PluginArray.idl:
2008-11-05 Steve Falkenburg <sfalken@apple.com>
Build fix.
......
/*
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -20,6 +21,7 @@
#include "JSMimeTypeArray.h"
#include "AtomicString.h"
#include "JSMimeType.h"
#include "MimeTypeArray.h"
namespace WebCore {
......@@ -34,7 +36,7 @@ bool JSMimeTypeArray::canGetItemsForName(ExecState*, MimeTypeArray* mimeTypeArra
JSValue* JSMimeTypeArray::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
JSMimeTypeArray* thisObj = static_cast<JSMimeTypeArray*>(asObject(slot.slotBase()));
return toJS(exec, thisObj->impl()->nameGetter(propertyName));
return toJS(exec, thisObj->impl()->namedItem(propertyName));
}
}
} // namespace WebCore
/*
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -20,6 +21,7 @@
#include "JSPluginArray.h"
#include "AtomicString.h"
#include "JSPlugin.h"
#include "PluginArray.h"
namespace WebCore {
......@@ -34,7 +36,7 @@ bool JSPluginArray::canGetItemsForName(ExecState*, PluginArray* pluginArray, con
JSValue* JSPluginArray::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
JSPluginArray* thisObj = static_cast<JSPluginArray*>(asObject(slot.slotBase()));
return toJS(exec, thisObj->impl()->nameGetter(propertyName));
return toJS(exec, thisObj->impl()->namedItem(propertyName));
}
}
} // namespace WebCore
......@@ -364,6 +364,12 @@ module window {
attribute XMLHttpRequestUploadConstructor XMLHttpRequestUpload;
attribute XMLHttpRequestExceptionConstructor XMLHttpRequestException;
attribute PluginConstructor Plugin;
attribute PluginArrayConstructor PluginArray;
attribute MimeTypeConstructor MimeType;
attribute MimeTypeArrayConstructor MimeTypeArray;
#if ENABLE_DOM_STORAGE
attribute StorageConstructor Storage;
attribute StorageEventConstructor StorageEvent;
......
/*
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2008 Apple Inc. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -19,7 +20,9 @@
module window {
interface MimeType {
interface [
GenerateConstructor
] MimeType {
readonly attribute DOMString type;
readonly attribute DOMString suffixes;
readonly attribute DOMString description;
......
/*
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -68,7 +69,7 @@ bool MimeTypeArray::canGetItemsForName(const AtomicString& propertyName)
return false;
}
PassRefPtr<MimeType> MimeTypeArray::nameGetter(const AtomicString& propertyName)
PassRefPtr<MimeType> MimeTypeArray::namedItem(const AtomicString& propertyName)
{
PluginData *data = getPluginData();
if (!data)
......
/*
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2008 Apple Inc. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -25,19 +26,12 @@
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
namespace JSC {
class ExecState;
};
namespace WebCore {
class AtomicString;
class Frame;
class PluginData;
// FIXME: Generated JSMimeTypeArray.cpp doesn't include JSMimeType.h for toJS
JSC::JSValue* toJS(JSC::ExecState*, MimeType*);
class MimeTypeArray : public RefCounted<MimeTypeArray> {
public:
static PassRefPtr<MimeTypeArray> create(Frame* frame) { return adoptRef(new MimeTypeArray(frame)); }
......@@ -48,13 +42,15 @@ namespace WebCore {
unsigned length() const;
PassRefPtr<MimeType> item(unsigned index);
bool canGetItemsForName(const AtomicString& propertyName);
PassRefPtr<MimeType> nameGetter(const AtomicString& propertyName);
PassRefPtr<MimeType> namedItem(const AtomicString& propertyName);
private:
MimeTypeArray(Frame*);
PluginData* getPluginData() const;
Frame* m_frame;
};
}
#endif
} // namespace WebCore
#endif // MimeTypeArray_h
/*
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2008 Apple Inc. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -19,8 +20,14 @@
module window {
interface [HasNameGetter, HasIndexGetter] MimeTypeArray {
interface [
GenerateConstructor,
HasNameGetter,
HasIndexGetter
] MimeTypeArray {
readonly attribute unsigned long length;
MimeType item(in unsigned long index);
MimeType namedItem(in DOMString name);
};
}
/*
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2008 Apple Inc. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -19,7 +20,11 @@
module window {
interface [HasNameGetter, HasIndexGetter] Plugin {
interface [
GenerateConstructor,
HasNameGetter,
HasIndexGetter
] Plugin {
readonly attribute DOMString name;
readonly attribute DOMString filename;
readonly attribute DOMString description;
......
/*
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -68,7 +69,7 @@ bool PluginArray::canGetItemsForName(const AtomicString& propertyName)
return false;
}
PassRefPtr<Plugin> PluginArray::nameGetter(const AtomicString& propertyName)
PassRefPtr<Plugin> PluginArray::namedItem(const AtomicString& propertyName)
{
PluginData* data = getPluginData();
if (!data)
......
/*
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2008 Apple Inc. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -25,19 +26,12 @@
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
namespace JSC {
class ExecState;
}
namespace WebCore {
class AtomicString;
class Frame;
class PluginData;
// FIXME: Generated JSPluginArray.cpp doesn't include JSPlugin.h for toJS
JSC::JSValue* toJS(JSC::ExecState*, Plugin*);
class PluginArray : public RefCounted<PluginArray> {
public:
static PassRefPtr<PluginArray> create(Frame* frame) { return adoptRef(new PluginArray(frame)); }
......@@ -48,15 +42,17 @@ namespace WebCore {
unsigned length() const;
PassRefPtr<Plugin> item(unsigned index);
bool canGetItemsForName(const AtomicString& propertyName);
PassRefPtr<Plugin> nameGetter(const AtomicString& propertyName);
PassRefPtr<Plugin> namedItem(const AtomicString& propertyName);
void refresh(bool reload);
private:
PluginArray(Frame*);
PluginData* getPluginData() const;
Frame* m_frame;
};
}
#endif
} // namespace WebCore
#endif // PluginArray_h
/*
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2008 Apple Inc. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -19,8 +20,14 @@
module window {
interface [HasNameGetter, HasIndexGetter] PluginArray {
interface [
GenerateConstructor,
HasNameGetter,
HasIndexGetter
] PluginArray {
readonly attribute unsigned long length;
Plugin item(in unsigned long index);
Plugin namedItem(in DOMString name);
void refresh(in boolean reload);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment