mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-05 14:57:30 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
407
layout/inspector/inCSSValueSearch.cpp
Normal file
407
layout/inspector/inCSSValueSearch.cpp
Normal file
|
|
@ -0,0 +1,407 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "inCSSValueSearch.h"
|
||||
|
||||
#include "mozilla/StyleSheetInlines.h"
|
||||
#include "mozilla/dom/StyleSheetList.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMStyleSheetList.h"
|
||||
#include "nsIDOMCSSStyleSheet.h"
|
||||
#include "nsIDOMCSSRuleList.h"
|
||||
#include "nsIDOMCSSStyleRule.h"
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
#include "nsIDOMCSSImportRule.h"
|
||||
#include "nsIDOMCSSMediaRule.h"
|
||||
#include "nsIDOMCSSSupportsRule.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
inCSSValueSearch::inCSSValueSearch()
|
||||
: mResults(nullptr),
|
||||
mProperties(nullptr),
|
||||
mResultCount(0),
|
||||
mPropertyCount(0),
|
||||
mIsActive(false),
|
||||
mHoldResults(true),
|
||||
mReturnRelativeURLs(true),
|
||||
mNormalizeChromeURLs(false)
|
||||
{
|
||||
nsCSSProps::AddRefTable();
|
||||
mProperties = new nsCSSPropertyID[100];
|
||||
}
|
||||
|
||||
inCSSValueSearch::~inCSSValueSearch()
|
||||
{
|
||||
delete[] mProperties;
|
||||
delete mResults;
|
||||
nsCSSProps::ReleaseTable();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(inCSSValueSearch, inISearchProcess, inICSSValueSearch)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// inISearchProcess
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::GetIsActive(bool *aIsActive)
|
||||
{
|
||||
*aIsActive = mIsActive;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::GetResultCount(int32_t *aResultCount)
|
||||
{
|
||||
*aResultCount = mResultCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::GetHoldResults(bool *aHoldResults)
|
||||
{
|
||||
*aHoldResults = mHoldResults;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::SetHoldResults(bool aHoldResults)
|
||||
{
|
||||
mHoldResults = aHoldResults;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::SearchSync()
|
||||
{
|
||||
InitSearch();
|
||||
|
||||
if (!mDocument) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(mDocument);
|
||||
MOZ_ASSERT(document);
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI = document->GetBaseURI();
|
||||
|
||||
RefPtr<dom::StyleSheetList> sheets = document->StyleSheets();
|
||||
MOZ_ASSERT(sheets);
|
||||
|
||||
uint32_t length = sheets->Length();
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
RefPtr<StyleSheet> sheet = sheets->Item(i);
|
||||
SearchStyleSheet(sheet, baseURI);
|
||||
}
|
||||
|
||||
// XXX would be nice to search inline style as well.
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::SearchAsync(inISearchObserver *aObserver)
|
||||
{
|
||||
InitSearch();
|
||||
mObserver = aObserver;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::SearchStop()
|
||||
{
|
||||
KillSearch(inISearchObserver::IN_INTERRUPTED);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::SearchStep(bool* _retval)
|
||||
{
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::GetStringResultAt(int32_t aIndex, nsAString& _retval)
|
||||
{
|
||||
if (mHoldResults) {
|
||||
nsAutoString* result = mResults->ElementAt(aIndex);
|
||||
_retval = *result;
|
||||
} else if (aIndex == mResultCount-1) {
|
||||
_retval = mLastResult;
|
||||
} else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::GetIntResultAt(int32_t aIndex, int32_t *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::GetUIntResultAt(int32_t aIndex, uint32_t *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// inICSSValueSearch
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::GetDocument(nsIDOMDocument** aDocument)
|
||||
{
|
||||
*aDocument = mDocument;
|
||||
NS_IF_ADDREF(*aDocument);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::SetDocument(nsIDOMDocument* aDocument)
|
||||
{
|
||||
mDocument = aDocument;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::GetBaseURL(char16_t** aBaseURL)
|
||||
{
|
||||
if (!(*aBaseURL = ToNewUnicode(mBaseURL)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::SetBaseURL(const char16_t* aBaseURL)
|
||||
{
|
||||
mBaseURL.Assign(aBaseURL);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::GetReturnRelativeURLs(bool* aReturnRelativeURLs)
|
||||
{
|
||||
*aReturnRelativeURLs = mReturnRelativeURLs;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::SetReturnRelativeURLs(bool aReturnRelativeURLs)
|
||||
{
|
||||
mReturnRelativeURLs = aReturnRelativeURLs;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::GetNormalizeChromeURLs(bool *aNormalizeChromeURLs)
|
||||
{
|
||||
*aNormalizeChromeURLs = mNormalizeChromeURLs;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::SetNormalizeChromeURLs(bool aNormalizeChromeURLs)
|
||||
{
|
||||
mNormalizeChromeURLs = aNormalizeChromeURLs;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::AddPropertyCriteria(const char16_t *aPropName)
|
||||
{
|
||||
nsCSSPropertyID prop =
|
||||
nsCSSProps::LookupProperty(nsDependentString(aPropName),
|
||||
CSSEnabledState::eIgnoreEnabledState);
|
||||
mProperties[mPropertyCount] = prop;
|
||||
mPropertyCount++;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::GetTextCriteria(char16_t** aTextCriteria)
|
||||
{
|
||||
if (!(*aTextCriteria = ToNewUnicode(mTextCriteria)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inCSSValueSearch::SetTextCriteria(const char16_t* aTextCriteria)
|
||||
{
|
||||
mTextCriteria.Assign(aTextCriteria);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// inCSSValueSearch
|
||||
|
||||
nsresult
|
||||
inCSSValueSearch::InitSearch()
|
||||
{
|
||||
if (mHoldResults) {
|
||||
mResults = new nsTArray<nsAutoString *>();
|
||||
}
|
||||
|
||||
mResultCount = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
inCSSValueSearch::KillSearch(int16_t aResult)
|
||||
{
|
||||
mIsActive = true;
|
||||
mObserver->OnSearchEnd(this, aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
inCSSValueSearch::SearchStyleSheet(nsIDOMCSSStyleSheet* aStyleSheet, nsIURI* aBaseURL)
|
||||
{
|
||||
nsCOMPtr<nsIURI> baseURL;
|
||||
nsAutoString href;
|
||||
aStyleSheet->GetHref(href);
|
||||
if (href.IsEmpty())
|
||||
baseURL = aBaseURL;
|
||||
else
|
||||
NS_NewURI(getter_AddRefs(baseURL), href, nullptr, aBaseURL);
|
||||
|
||||
nsCOMPtr<nsIDOMCSSRuleList> rules;
|
||||
nsresult rv = aStyleSheet->GetCssRules(getter_AddRefs(rules));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return SearchRuleList(rules, baseURL);
|
||||
}
|
||||
|
||||
nsresult
|
||||
inCSSValueSearch::SearchRuleList(nsIDOMCSSRuleList* aRuleList, nsIURI* aBaseURL)
|
||||
{
|
||||
uint32_t length;
|
||||
aRuleList->GetLength(&length);
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
nsCOMPtr<nsIDOMCSSRule> rule;
|
||||
aRuleList->Item(i, getter_AddRefs(rule));
|
||||
uint16_t type;
|
||||
rule->GetType(&type);
|
||||
switch (type) {
|
||||
case nsIDOMCSSRule::STYLE_RULE: {
|
||||
nsCOMPtr<nsIDOMCSSStyleRule> styleRule = do_QueryInterface(rule);
|
||||
SearchStyleRule(styleRule, aBaseURL);
|
||||
} break;
|
||||
case nsIDOMCSSRule::IMPORT_RULE: {
|
||||
nsCOMPtr<nsIDOMCSSImportRule> importRule = do_QueryInterface(rule);
|
||||
nsCOMPtr<nsIDOMCSSStyleSheet> childSheet;
|
||||
importRule->GetStyleSheet(getter_AddRefs(childSheet));
|
||||
if (childSheet)
|
||||
SearchStyleSheet(childSheet, aBaseURL);
|
||||
} break;
|
||||
case nsIDOMCSSRule::MEDIA_RULE: {
|
||||
nsCOMPtr<nsIDOMCSSMediaRule> mediaRule = do_QueryInterface(rule);
|
||||
nsCOMPtr<nsIDOMCSSRuleList> childRules;
|
||||
mediaRule->GetCssRules(getter_AddRefs(childRules));
|
||||
SearchRuleList(childRules, aBaseURL);
|
||||
} break;
|
||||
case nsIDOMCSSRule::SUPPORTS_RULE: {
|
||||
nsCOMPtr<nsIDOMCSSSupportsRule> supportsRule = do_QueryInterface(rule);
|
||||
nsCOMPtr<nsIDOMCSSRuleList> childRules;
|
||||
supportsRule->GetCssRules(getter_AddRefs(childRules));
|
||||
SearchRuleList(childRules, aBaseURL);
|
||||
} break;
|
||||
default:
|
||||
// XXX handle nsIDOMCSSRule::PAGE_RULE if we ever support it
|
||||
break;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
inCSSValueSearch::SearchStyleRule(nsIDOMCSSStyleRule* aStyleRule, nsIURI* aBaseURL)
|
||||
{
|
||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> decl;
|
||||
nsresult rv = aStyleRule->GetStyle(getter_AddRefs(decl));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
uint32_t length;
|
||||
decl->GetLength(&length);
|
||||
nsAutoString property, value;
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
decl->Item(i, property);
|
||||
// XXX This probably ought to use GetPropertyCSSValue if it were
|
||||
// implemented.
|
||||
decl->GetPropertyValue(property, value);
|
||||
SearchStyleValue(value, aBaseURL);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
inCSSValueSearch::SearchStyleValue(const nsAFlatString& aValue, nsIURI* aBaseURL)
|
||||
{
|
||||
if (StringBeginsWith(aValue, NS_LITERAL_STRING("url(")) &&
|
||||
StringEndsWith(aValue, NS_LITERAL_STRING(")"))) {
|
||||
const nsASingleFragmentString &url =
|
||||
Substring(aValue, 4, aValue.Length() - 5);
|
||||
// XXXldb Need to do more with |mReturnRelativeURLs|, perhaps?
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), url, nullptr, aBaseURL);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsAutoCString spec;
|
||||
rv = uri->GetSpec(spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsAutoString *result = new NS_ConvertUTF8toUTF16(spec);
|
||||
if (mReturnRelativeURLs)
|
||||
EqualizeURL(result);
|
||||
mResults->AppendElement(result);
|
||||
++mResultCount;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
inCSSValueSearch::EqualizeURL(nsAutoString* aURL)
|
||||
{
|
||||
if (mNormalizeChromeURLs) {
|
||||
if (aURL->Find("chrome://", false, 0, 1) >= 0) {
|
||||
uint32_t len = aURL->Length();
|
||||
char16_t* result = new char16_t[len-8];
|
||||
const char16_t* src = aURL->get();
|
||||
uint32_t i = 9;
|
||||
uint32_t milestone = 0;
|
||||
uint32_t s = 0;
|
||||
while (i < len) {
|
||||
if (src[i] == '/') {
|
||||
milestone += 1;
|
||||
}
|
||||
if (milestone != 1) {
|
||||
result[i-9-s] = src[i];
|
||||
} else {
|
||||
s++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
result[i-9-s] = 0;
|
||||
|
||||
aURL->Assign(result);
|
||||
delete [] result;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
60
layout/inspector/inCSSValueSearch.h
Normal file
60
layout/inspector/inCSSValueSearch.h
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __inCSSValueSearch_h__
|
||||
#define __inCSSValueSearch_h__
|
||||
|
||||
#include "inICSSValueSearch.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "inISearchObserver.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsCSSProps.h"
|
||||
|
||||
class nsIDOMCSSStyleSheet;
|
||||
class nsIDOMCSSRuleList;
|
||||
class nsIDOMCSSStyleRule;
|
||||
class nsIURI;
|
||||
|
||||
class inCSSValueSearch final : public inICSSValueSearch
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_INISEARCHPROCESS
|
||||
NS_DECL_INICSSVALUESEARCH
|
||||
|
||||
inCSSValueSearch();
|
||||
|
||||
protected:
|
||||
virtual ~inCSSValueSearch();
|
||||
nsCOMPtr<inISearchObserver> mObserver;
|
||||
nsCOMPtr<nsIDOMDocument> mDocument;
|
||||
nsTArray<nsAutoString *>* mResults;
|
||||
nsCSSPropertyID* mProperties;
|
||||
nsString mLastResult;
|
||||
nsString mBaseURL;
|
||||
nsString mTextCriteria;
|
||||
int32_t mResultCount;
|
||||
uint32_t mPropertyCount;
|
||||
bool mIsActive;
|
||||
bool mHoldResults;
|
||||
bool mReturnRelativeURLs;
|
||||
bool mNormalizeChromeURLs;
|
||||
|
||||
nsresult InitSearch();
|
||||
nsresult KillSearch(int16_t aResult);
|
||||
nsresult SearchStyleSheet(nsIDOMCSSStyleSheet* aStyleSheet, nsIURI* aBaseURI);
|
||||
nsresult SearchRuleList(nsIDOMCSSRuleList* aRuleList, nsIURI* aBaseURI);
|
||||
nsresult SearchStyleRule(nsIDOMCSSStyleRule* aStyleRule, nsIURI* aBaseURI);
|
||||
nsresult SearchStyleValue(const nsAFlatString& aValue, nsIURI* aBaseURI);
|
||||
nsresult EqualizeURL(nsAutoString* aURL);
|
||||
};
|
||||
|
||||
// {4D977F60-FBE7-4583-8CB7-F5ED882293EF}
|
||||
#define IN_CSSVALUESEARCH_CID \
|
||||
{ 0x4d977f60, 0xfbe7, 0x4583, { 0x8c, 0xb7, 0xf5, 0xed, 0x88, 0x22, 0x93, 0xef } }
|
||||
|
||||
#endif // __inCSSValueSearch_h__
|
||||
1351
layout/inspector/inDOMUtils.cpp
Normal file
1351
layout/inspector/inDOMUtils.cpp
Normal file
File diff suppressed because it is too large
Load diff
42
layout/inspector/inDOMUtils.h
Normal file
42
layout/inspector/inDOMUtils.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __inDOMUtils_h__
|
||||
#define __inDOMUtils_h__
|
||||
|
||||
#include "inIDOMUtils.h"
|
||||
|
||||
class nsRuleNode;
|
||||
class nsStyleContext;
|
||||
class nsIAtom;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class Element;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
class inDOMUtils final : public inIDOMUtils
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_INIDOMUTILS
|
||||
|
||||
inDOMUtils();
|
||||
|
||||
private:
|
||||
virtual ~inDOMUtils();
|
||||
|
||||
// aStyleContext must be released by the caller once he's done with aRuleNode.
|
||||
static nsresult GetRuleNodeForElement(mozilla::dom::Element* aElement,
|
||||
nsIAtom* aPseudo,
|
||||
nsStyleContext** aStyleContext,
|
||||
nsRuleNode** aRuleNode);
|
||||
};
|
||||
|
||||
// {0a499822-a287-4089-ad3f-9ffcd4f40263}
|
||||
#define IN_DOMUTILS_CID \
|
||||
{0x0a499822, 0xa287, 0x4089, {0xad, 0x3f, 0x9f, 0xfc, 0xd4, 0xf4, 0x02, 0x63}}
|
||||
|
||||
#endif // __inDOMUtils_h__
|
||||
1283
layout/inspector/inDOMView.cpp
Normal file
1283
layout/inspector/inDOMView.cpp
Normal file
File diff suppressed because it is too large
Load diff
96
layout/inspector/inDOMView.h
Normal file
96
layout/inspector/inDOMView.h
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __inDOMView_h__
|
||||
#define __inDOMView_h__
|
||||
|
||||
#include "inIDOMView.h"
|
||||
#include "inIDOMUtils.h"
|
||||
|
||||
#include "nsITreeView.h"
|
||||
#include "nsITreeSelection.h"
|
||||
#include "nsStubMutationObserver.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class inDOMViewNode;
|
||||
class nsIDOMMozNamedAttrMap;
|
||||
|
||||
class inDOMView : public inIDOMView,
|
||||
public nsITreeView,
|
||||
public nsStubMutationObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_INIDOMVIEW
|
||||
NS_DECL_NSITREEVIEW
|
||||
|
||||
inDOMView();
|
||||
|
||||
// nsIMutationObserver
|
||||
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
||||
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
||||
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
||||
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
||||
NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
|
||||
|
||||
protected:
|
||||
virtual ~inDOMView();
|
||||
|
||||
nsCOMPtr<nsITreeBoxObject> mTree;
|
||||
nsCOMPtr<nsITreeSelection> mSelection;
|
||||
nsCOMPtr<inIDOMUtils> mDOMUtils;
|
||||
|
||||
bool mShowAnonymous;
|
||||
bool mShowSubDocuments;
|
||||
bool mShowWhitespaceNodes;
|
||||
bool mShowAccessibleNodes;
|
||||
uint32_t mWhatToShow;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> mRootNode;
|
||||
nsCOMPtr<nsIDOMDocument> mRootDocument;
|
||||
|
||||
nsTArray<inDOMViewNode*> mNodes;
|
||||
|
||||
inDOMViewNode* GetNodeAt(int32_t aIndex);
|
||||
int32_t GetRowCount();
|
||||
int32_t NodeToRow(inDOMViewNode* aNode);
|
||||
bool RowOutOfBounds(int32_t aRow, int32_t aCount);
|
||||
inDOMViewNode* CreateNode(nsIDOMNode* aNode, inDOMViewNode* aParent);
|
||||
void AppendNode(inDOMViewNode* aNode);
|
||||
void InsertNode(inDOMViewNode* aNode, int32_t aIndex);
|
||||
void RemoveNode(int32_t aIndex);
|
||||
void ReplaceNode(inDOMViewNode* aNode, int32_t aIndex);
|
||||
void InsertNodes(nsTArray<inDOMViewNode*>& aNodes, int32_t aIndex);
|
||||
void RemoveNodes(int32_t aIndex, int32_t aCount);
|
||||
void RemoveAllNodes();
|
||||
void ExpandNode(int32_t aRow);
|
||||
void CollapseNode(int32_t aRow);
|
||||
|
||||
nsresult RowToNode(int32_t aRow, inDOMViewNode** aNode);
|
||||
nsresult NodeToRow(nsIDOMNode* aNode, int32_t* aRow);
|
||||
|
||||
void InsertLinkAfter(inDOMViewNode* aNode, inDOMViewNode* aInsertAfter);
|
||||
void InsertLinkBefore(inDOMViewNode* aNode, inDOMViewNode* aInsertBefore);
|
||||
void RemoveLink(inDOMViewNode* aNode);
|
||||
void ReplaceLink(inDOMViewNode* aNewNode, inDOMViewNode* aOldNode);
|
||||
|
||||
nsresult GetChildNodesFor(nsIDOMNode* aNode, nsCOMArray<nsIDOMNode>& aResult);
|
||||
nsresult AppendKidsToArray(nsIDOMNodeList* aKids, nsCOMArray<nsIDOMNode>& aArray);
|
||||
nsresult AppendAttrsToArray(nsIDOMMozNamedAttrMap* aKids, nsCOMArray<nsIDOMNode>& aArray);
|
||||
nsresult GetFirstDescendantOf(inDOMViewNode* aNode, int32_t aRow, int32_t* aResult);
|
||||
nsresult GetLastDescendantOf(inDOMViewNode* aNode, int32_t aRow, int32_t* aResult);
|
||||
nsresult GetRealPreviousSibling(nsIDOMNode* aNode, nsIDOMNode* aRealParent, nsIDOMNode** aSibling);
|
||||
};
|
||||
|
||||
// {FB5C1775-1BBD-4b9c-ABB0-AE7ACD29E87E}
|
||||
#define IN_DOMVIEW_CID \
|
||||
{ 0xfb5c1775, 0x1bbd, 0x4b9c, { 0xab, 0xb0, 0xae, 0x7a, 0xcd, 0x29, 0xe8, 0x7e } }
|
||||
|
||||
#endif // __inDOMView_h__
|
||||
|
||||
|
||||
442
layout/inspector/inDeepTreeWalker.cpp
Normal file
442
layout/inspector/inDeepTreeWalker.cpp
Normal file
|
|
@ -0,0 +1,442 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 sw=2 et tw=79: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "inDeepTreeWalker.h"
|
||||
#include "inLayoutUtils.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMNodeFilter.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "inIDOMUtils.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsContentList.h"
|
||||
#include "ChildIterator.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* This implementation does not currently operaate according to the W3C spec.
|
||||
* In particular it does NOT handle DOM mutations during the walk. It also
|
||||
* ignores whatToShow and the filter.
|
||||
*****************************************************************************/
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
inDeepTreeWalker::inDeepTreeWalker()
|
||||
: mShowAnonymousContent(false),
|
||||
mShowSubDocuments(false),
|
||||
mShowDocumentsAsNodes(false),
|
||||
mWhatToShow(nsIDOMNodeFilter::SHOW_ALL)
|
||||
{
|
||||
}
|
||||
|
||||
inDeepTreeWalker::~inDeepTreeWalker()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(inDeepTreeWalker,
|
||||
inIDeepTreeWalker)
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// inIDeepTreeWalker
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::GetShowAnonymousContent(bool *aShowAnonymousContent)
|
||||
{
|
||||
*aShowAnonymousContent = mShowAnonymousContent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::SetShowAnonymousContent(bool aShowAnonymousContent)
|
||||
{
|
||||
mShowAnonymousContent = aShowAnonymousContent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::GetShowSubDocuments(bool *aShowSubDocuments)
|
||||
{
|
||||
*aShowSubDocuments = mShowSubDocuments;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::SetShowSubDocuments(bool aShowSubDocuments)
|
||||
{
|
||||
mShowSubDocuments = aShowSubDocuments;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::GetShowDocumentsAsNodes(bool *aShowDocumentsAsNodes)
|
||||
{
|
||||
*aShowDocumentsAsNodes = mShowDocumentsAsNodes;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::SetShowDocumentsAsNodes(bool aShowDocumentsAsNodes)
|
||||
{
|
||||
mShowDocumentsAsNodes = aShowDocumentsAsNodes;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::Init(nsIDOMNode* aRoot, uint32_t aWhatToShow)
|
||||
{
|
||||
if (!aRoot) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
mRoot = aRoot;
|
||||
mCurrentNode = aRoot;
|
||||
mWhatToShow = aWhatToShow;
|
||||
|
||||
mDOMUtils = do_GetService("@mozilla.org/inspector/dom-utils;1");
|
||||
return mDOMUtils ? NS_OK : NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// nsIDOMTreeWalker
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::GetRoot(nsIDOMNode** aRoot)
|
||||
{
|
||||
*aRoot = mRoot;
|
||||
NS_IF_ADDREF(*aRoot);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::GetWhatToShow(uint32_t* aWhatToShow)
|
||||
{
|
||||
*aWhatToShow = mWhatToShow;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::GetFilter(nsIDOMNodeFilter** aFilter)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::GetCurrentNode(nsIDOMNode** aCurrentNode)
|
||||
{
|
||||
*aCurrentNode = mCurrentNode;
|
||||
NS_IF_ADDREF(*aCurrentNode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMNode>
|
||||
inDeepTreeWalker::GetParent()
|
||||
{
|
||||
if (mCurrentNode == mRoot) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
MOZ_ASSERT(mDOMUtils, "mDOMUtils should have been initiated already in Init");
|
||||
mDOMUtils->GetParentForNode(mCurrentNode, mShowAnonymousContent,
|
||||
getter_AddRefs(parent));
|
||||
|
||||
uint16_t nodeType = 0;
|
||||
if (parent) {
|
||||
parent->GetNodeType(&nodeType);
|
||||
}
|
||||
// For compatibility reasons by default we skip the document nodes
|
||||
// from the walk.
|
||||
if (!mShowDocumentsAsNodes &&
|
||||
nodeType == nsIDOMNode::DOCUMENT_NODE &&
|
||||
parent != mRoot) {
|
||||
mDOMUtils->GetParentForNode(parent, mShowAnonymousContent,
|
||||
getter_AddRefs(parent));
|
||||
}
|
||||
|
||||
return parent.forget();
|
||||
}
|
||||
|
||||
static already_AddRefed<nsINodeList>
|
||||
GetChildren(nsIDOMNode* aParent,
|
||||
bool aShowAnonymousContent,
|
||||
bool aShowSubDocuments)
|
||||
{
|
||||
MOZ_ASSERT(aParent);
|
||||
|
||||
nsCOMPtr<nsINodeList> ret;
|
||||
if (aShowSubDocuments) {
|
||||
nsCOMPtr<nsIDOMDocument> domdoc = inLayoutUtils::GetSubDocumentFor(aParent);
|
||||
if (domdoc) {
|
||||
aParent = domdoc;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> parentAsContent = do_QueryInterface(aParent);
|
||||
if (parentAsContent && aShowAnonymousContent) {
|
||||
ret = parentAsContent->GetChildren(nsIContent::eAllChildren);
|
||||
} else {
|
||||
// If it's not a content, then it's a document (or an attribute but we can ignore that
|
||||
// case here). If aShowAnonymousContent is false we also want to fall back to ChildNodes
|
||||
// so we can skip any native anon content that GetChildren would return.
|
||||
nsCOMPtr<nsINode> parentNode = do_QueryInterface(aParent);
|
||||
MOZ_ASSERT(parentNode);
|
||||
ret = parentNode->ChildNodes();
|
||||
}
|
||||
return ret.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::SetCurrentNode(nsIDOMNode* aCurrentNode)
|
||||
{
|
||||
// mCurrentNode can only be null if init either failed, or has not been
|
||||
// called yet.
|
||||
if (!mCurrentNode || !aCurrentNode) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// If Document nodes are skipped by the walk, we should not allow
|
||||
// one to set one as the current node either.
|
||||
uint16_t nodeType = 0;
|
||||
aCurrentNode->GetNodeType(&nodeType);
|
||||
if (!mShowDocumentsAsNodes && nodeType == nsIDOMNode::DOCUMENT_NODE) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return SetCurrentNode(aCurrentNode, nullptr);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
inDeepTreeWalker::SetCurrentNode(nsIDOMNode* aCurrentNode,
|
||||
nsINodeList* aSiblings)
|
||||
{
|
||||
MOZ_ASSERT(aCurrentNode);
|
||||
|
||||
// We want to store the original state so in case of error
|
||||
// we can restore that.
|
||||
nsCOMPtr<nsINodeList> tmpSiblings = mSiblings;
|
||||
nsCOMPtr<nsIDOMNode> tmpCurrent = mCurrentNode;
|
||||
mSiblings = aSiblings;
|
||||
mCurrentNode = aCurrentNode;
|
||||
|
||||
// If siblings were not passed in as argument we have to
|
||||
// get them from the parent node of aCurrentNode.
|
||||
// Note: in the mShowDoucmentsAsNodes case when a sub document
|
||||
// is set as the current, we don't want to get the children
|
||||
// from the iframe accidentally here, so let's just skip this
|
||||
// part for document nodes, they should never have siblings.
|
||||
uint16_t nodeType = 0;
|
||||
aCurrentNode->GetNodeType(&nodeType);
|
||||
if (!mSiblings && nodeType != nsIDOMNode::DOCUMENT_NODE) {
|
||||
nsCOMPtr<nsIDOMNode> parent = GetParent();
|
||||
if (parent) {
|
||||
mSiblings = GetChildren(parent,
|
||||
mShowAnonymousContent,
|
||||
mShowSubDocuments);
|
||||
}
|
||||
}
|
||||
|
||||
if (mSiblings && mSiblings->Length()) {
|
||||
// We cached all the siblings (if there are any) of the current node, but we
|
||||
// still have to set the index too, to be able to iterate over them.
|
||||
nsCOMPtr<nsIContent> currentAsContent = do_QueryInterface(mCurrentNode);
|
||||
MOZ_ASSERT(currentAsContent);
|
||||
int32_t index = mSiblings->IndexOf(currentAsContent);
|
||||
if (index < 0) {
|
||||
// If someone tries to set current node to some value that is not reachable
|
||||
// otherwise, let's throw. (For example mShowAnonymousContent is false and some
|
||||
// XBL anon content was passed in)
|
||||
|
||||
// Restore state first.
|
||||
mCurrentNode = tmpCurrent;
|
||||
mSiblings = tmpSiblings;
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
mCurrentIndex = index;
|
||||
} else {
|
||||
mCurrentIndex = -1;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::ParentNode(nsIDOMNode** _retval)
|
||||
{
|
||||
*_retval = nullptr;
|
||||
if (!mCurrentNode || mCurrentNode == mRoot) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent = GetParent();
|
||||
|
||||
if (!parent) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = SetCurrentNode(parent);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
parent.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// FirstChild and LastChild are very similar methods, this is the generic
|
||||
// version for internal use. With aReverse = true it returns the LastChild.
|
||||
nsresult
|
||||
inDeepTreeWalker::EdgeChild(nsIDOMNode** _retval, bool aFront)
|
||||
{
|
||||
if (!mCurrentNode) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*_retval = nullptr;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> echild;
|
||||
if (mShowSubDocuments && mShowDocumentsAsNodes) {
|
||||
// GetChildren below, will skip the document node from
|
||||
// the walk. But if mShowDocumentsAsNodes is set to true
|
||||
// we want to include the (sub)document itself too.
|
||||
echild = inLayoutUtils::GetSubDocumentFor(mCurrentNode);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINodeList> children;
|
||||
if (!echild) {
|
||||
children = GetChildren(mCurrentNode,
|
||||
mShowAnonymousContent,
|
||||
mShowSubDocuments);
|
||||
if (children && children->Length() > 0) {
|
||||
nsINode* childNode = children->Item(aFront ? 0 : children->Length() - 1);
|
||||
echild = childNode ? childNode->AsDOMNode() : nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (echild) {
|
||||
nsresult rv = SetCurrentNode(echild, children);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ADDREF(*_retval = mCurrentNode);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::FirstChild(nsIDOMNode** _retval)
|
||||
{
|
||||
return EdgeChild(_retval, /* aFront = */ true);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::LastChild(nsIDOMNode **_retval)
|
||||
{
|
||||
return EdgeChild(_retval, /* aFront = */ false);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::PreviousSibling(nsIDOMNode **_retval)
|
||||
{
|
||||
*_retval = nullptr;
|
||||
if (!mCurrentNode || !mSiblings || mCurrentIndex < 1) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIContent* prev = mSiblings->Item(--mCurrentIndex);
|
||||
mCurrentNode = prev->AsDOMNode();
|
||||
NS_ADDREF(*_retval = mCurrentNode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::NextSibling(nsIDOMNode **_retval)
|
||||
{
|
||||
*_retval = nullptr;
|
||||
if (!mCurrentNode || !mSiblings ||
|
||||
mCurrentIndex + 1 >= (int32_t) mSiblings->Length()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIContent* next = mSiblings->Item(++mCurrentIndex);
|
||||
mCurrentNode = next->AsDOMNode();
|
||||
NS_ADDREF(*_retval = mCurrentNode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::PreviousNode(nsIDOMNode **_retval)
|
||||
{
|
||||
if (!mCurrentNode || mCurrentNode == mRoot) {
|
||||
// Nowhere to go from here
|
||||
*_retval = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
PreviousSibling(getter_AddRefs(node));
|
||||
|
||||
if (!node) {
|
||||
return ParentNode(_retval);
|
||||
}
|
||||
|
||||
// Now we're positioned at our previous sibling. But since the DOM tree
|
||||
// traversal is depth-first, the previous node is its most deeply nested last
|
||||
// child. Just loop until LastChild() returns null; since the LastChild()
|
||||
// call that returns null won't affect our position, we will then be
|
||||
// positioned at the correct node.
|
||||
while (node) {
|
||||
LastChild(getter_AddRefs(node));
|
||||
}
|
||||
|
||||
NS_ADDREF(*_retval = mCurrentNode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDeepTreeWalker::NextNode(nsIDOMNode **_retval)
|
||||
{
|
||||
if (!mCurrentNode) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// First try our kids
|
||||
FirstChild(_retval);
|
||||
|
||||
if (*_retval) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Now keep trying next siblings up the parent chain, but if we
|
||||
// discover there's nothing else restore our state.
|
||||
#ifdef DEBUG
|
||||
nsIDOMNode* origCurrentNode = mCurrentNode;
|
||||
#endif
|
||||
uint32_t lastChildCallsToMake = 0;
|
||||
while (1) {
|
||||
NextSibling(_retval);
|
||||
|
||||
if (*_retval) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
ParentNode(getter_AddRefs(parent));
|
||||
if (!parent) {
|
||||
// Nowhere else to go; we're done. Restore our state.
|
||||
while (lastChildCallsToMake--) {
|
||||
nsCOMPtr<nsIDOMNode> dummy;
|
||||
LastChild(getter_AddRefs(dummy));
|
||||
}
|
||||
NS_ASSERTION(mCurrentNode == origCurrentNode,
|
||||
"Didn't go back to the right node?");
|
||||
*_retval = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
++lastChildCallsToMake;
|
||||
}
|
||||
|
||||
NS_NOTREACHED("how did we get here?");
|
||||
return NS_OK;
|
||||
}
|
||||
65
layout/inspector/inDeepTreeWalker.h
Normal file
65
layout/inspector/inDeepTreeWalker.h
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __inDeepTreeWalker_h___
|
||||
#define __inDeepTreeWalker_h___
|
||||
|
||||
#include "inIDeepTreeWalker.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsINodeList;
|
||||
class inIDOMUtils;
|
||||
|
||||
class inDeepTreeWalker final : public inIDeepTreeWalker
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_INIDEEPTREEWALKER
|
||||
|
||||
inDeepTreeWalker();
|
||||
|
||||
nsresult SetCurrentNode(nsIDOMNode* aCurrentNode,
|
||||
nsINodeList* aSiblings);
|
||||
protected:
|
||||
virtual ~inDeepTreeWalker();
|
||||
|
||||
already_AddRefed<nsIDOMNode> GetParent();
|
||||
nsresult EdgeChild(nsIDOMNode** _retval, bool aReverse);
|
||||
|
||||
bool mShowAnonymousContent;
|
||||
bool mShowSubDocuments;
|
||||
bool mShowDocumentsAsNodes;
|
||||
|
||||
// The root node. previousNode and parentNode will return
|
||||
// null from here.
|
||||
nsCOMPtr<nsIDOMNode> mRoot;
|
||||
nsCOMPtr<nsIDOMNode> mCurrentNode;
|
||||
nsCOMPtr<inIDOMUtils> mDOMUtils;
|
||||
|
||||
// We cache the siblings of mCurrentNode as a list of nodes.
|
||||
// Notes: normally siblings are all the children of the parent
|
||||
// of mCurrentNode (that are interesting for use for the walk)
|
||||
// and mCurrentIndex is the index of mCurrentNode in that list
|
||||
// But if mCurrentNode is a (sub) document then instead of
|
||||
// storing a list that has only one element (the document)
|
||||
// and setting mCurrentIndex to null, we set mSibilings to null.
|
||||
// The reason for this is purely technical, since nsINodeList is
|
||||
// nsIContent based hence we cannot use it to store a document node.
|
||||
nsCOMPtr<nsINodeList> mSiblings;
|
||||
|
||||
// Index of mCurrentNode in the mSiblings list.
|
||||
int32_t mCurrentIndex;
|
||||
|
||||
// Currently unused. Should be a filter for nodes.
|
||||
uint32_t mWhatToShow;
|
||||
};
|
||||
|
||||
// {BFCB82C2-5611-4318-90D6-BAF4A7864252}
|
||||
#define IN_DEEPTREEWALKER_CID \
|
||||
{ 0xbfcb82c2, 0x5611, 0x4318, { 0x90, 0xd6, 0xba, 0xf4, 0xa7, 0x86, 0x42, 0x52 } }
|
||||
|
||||
#endif // __inDeepTreeWalker_h___
|
||||
29
layout/inspector/inICSSValueSearch.idl
Normal file
29
layout/inspector/inICSSValueSearch.idl
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "inISearchProcess.idl"
|
||||
|
||||
interface nsIDOMDocument;
|
||||
|
||||
[scriptable, uuid(e0d39e48-1dd1-11b2-81bd-9a0c117f0736)]
|
||||
interface inICSSValueSearch : inISearchProcess {
|
||||
|
||||
attribute nsIDOMDocument document;
|
||||
|
||||
// the base url for all returned URL results, if returnRelativeURLs is true
|
||||
attribute wstring baseURL;
|
||||
|
||||
// strip off the baseURL for all URL results if true
|
||||
attribute boolean returnRelativeURLs;
|
||||
|
||||
// correct the paths on a chrome url, such as turning global/skin/blah into global/blah
|
||||
attribute boolean normalizeChromeURLs;
|
||||
|
||||
// add a css property to search for
|
||||
void addPropertyCriteria(in wstring aPropName);
|
||||
|
||||
// set the text value to search for in the properties specified (optional)
|
||||
attribute wstring textCriteria;
|
||||
|
||||
};
|
||||
213
layout/inspector/inIDOMUtils.idl
Normal file
213
layout/inspector/inIDOMUtils.idl
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIArray;
|
||||
interface nsIArrayExtensions;
|
||||
interface nsIDOMCharacterData;
|
||||
interface nsIDOMElement;
|
||||
interface nsIDOMDocument;
|
||||
interface nsIDOMCSSRule;
|
||||
interface nsIDOMCSSStyleRule;
|
||||
interface nsIDOMNode;
|
||||
interface nsIDOMNodeList;
|
||||
interface nsIDOMFontFaceList;
|
||||
interface nsIDOMRange;
|
||||
interface nsIDOMCSSStyleSheet;
|
||||
|
||||
[scriptable, uuid(362e98c3-82c2-4ad8-8dcb-00e8e4eab497)]
|
||||
interface inIDOMUtils : nsISupports
|
||||
{
|
||||
// CSS utilities
|
||||
void getAllStyleSheets (in nsIDOMDocument aDoc,
|
||||
[optional] out unsigned long aLength,
|
||||
[array, size_is (aLength), retval] out nsISupports aSheets);
|
||||
nsIArrayExtensions getCSSStyleRules(in nsIDOMElement aElement, [optional] in DOMString aPseudo);
|
||||
|
||||
/**
|
||||
* Get the line number of a rule.
|
||||
*
|
||||
* @param nsIDOMCSSRule aRule The rule.
|
||||
* @return The rule's line number. Line numbers are 1-based.
|
||||
*/
|
||||
unsigned long getRuleLine(in nsIDOMCSSRule aRule);
|
||||
|
||||
/**
|
||||
* Get the column number of a rule.
|
||||
*
|
||||
* @param nsIDOMCSSRule aRule The rule.
|
||||
* @return The rule's column number. Column numbers are 1-based.
|
||||
*/
|
||||
unsigned long getRuleColumn(in nsIDOMCSSRule aRule);
|
||||
|
||||
/**
|
||||
* Like getRuleLine, but if the rule is in a <style> element,
|
||||
* returns a line number relative to the start of the element.
|
||||
*
|
||||
* @param nsIDOMCSSRule aRule the rule to examine
|
||||
* @return the line number of the rule, possibly relative to the
|
||||
* <style> element
|
||||
*/
|
||||
unsigned long getRelativeRuleLine(in nsIDOMCSSRule aRule);
|
||||
|
||||
[implicit_jscontext]
|
||||
jsval getCSSLexer(in DOMString aText);
|
||||
|
||||
// Utilities for working with selectors. We don't have a JS OM representation
|
||||
// of a single selector or a selector list yet, but given a rule we can index
|
||||
// into the selector list.
|
||||
//
|
||||
// This is a somewhat backwards API; once we move StyleRule to WebIDL we
|
||||
// should consider using [ChromeOnly] APIs on that.
|
||||
unsigned long getSelectorCount(in nsIDOMCSSStyleRule aRule);
|
||||
// For all three functions below, aSelectorIndex is 0-based
|
||||
AString getSelectorText(in nsIDOMCSSStyleRule aRule,
|
||||
in unsigned long aSelectorIndex);
|
||||
unsigned long long getSpecificity(in nsIDOMCSSStyleRule aRule,
|
||||
in unsigned long aSelectorIndex);
|
||||
// Note: This does not handle scoped selectors correctly, because it has no
|
||||
// idea what the right scope is.
|
||||
bool selectorMatchesElement(in nsIDOMElement aElement,
|
||||
in nsIDOMCSSStyleRule aRule,
|
||||
in unsigned long aSelectorIndex,
|
||||
[optional] in DOMString aPseudo);
|
||||
|
||||
// Utilities for working with CSS properties
|
||||
//
|
||||
// Returns true if the string names a property that is inherited by default.
|
||||
bool isInheritedProperty(in AString aPropertyName);
|
||||
|
||||
// Get a list of all our supported property names. Optionally
|
||||
// shorthands can be excluded or property aliases included.
|
||||
const unsigned long EXCLUDE_SHORTHANDS = (1<<0);
|
||||
const unsigned long INCLUDE_ALIASES = (1<<1);
|
||||
void getCSSPropertyNames([optional] in unsigned long aFlags,
|
||||
[optional] out unsigned long aCount,
|
||||
[retval, array, size_is(aCount)] out wstring aProps);
|
||||
|
||||
// Get a list of all valid keywords and colors for aProperty.
|
||||
void getCSSValuesForProperty(in AString aProperty,
|
||||
[optional] out unsigned long aLength,
|
||||
[array, size_is(aLength), retval] out wstring aValues);
|
||||
|
||||
// Utilities for working with CSS colors
|
||||
[implicit_jscontext]
|
||||
jsval colorNameToRGB(in DOMString aColorName);
|
||||
AString rgbToColorName(in octet aR, in octet aG, in octet aB);
|
||||
|
||||
// Convert a given CSS color string to rgba. Returns null on failure or an
|
||||
// InspectorRGBATuple on success.
|
||||
//
|
||||
// NOTE: Converting a color to RGBA may be lossy when converting from some
|
||||
// formats e.g. CMYK.
|
||||
[implicit_jscontext]
|
||||
jsval colorToRGBA(in DOMString aColorString);
|
||||
|
||||
// Check whether a given color is a valid CSS color.
|
||||
bool isValidCSSColor(in AString aColorString);
|
||||
|
||||
// Utilities for obtaining information about a CSS property.
|
||||
|
||||
// Check whether a CSS property and value are a valid combination. If the
|
||||
// property is pref-disabled it will still be processed.
|
||||
// aPropertyName: A property name e.g. "color"
|
||||
// aPropertyValue: A property value e.g. "red" or "red !important"
|
||||
bool cssPropertyIsValid(in AString aPropertyName, in AString aPropertyValue);
|
||||
|
||||
// Get a list of the longhands corresponding to the given CSS property. If
|
||||
// the property is a longhand already, just returns the property itself.
|
||||
// Throws on unsupported property names.
|
||||
void getSubpropertiesForCSSProperty(in AString aProperty,
|
||||
[optional] out unsigned long aLength,
|
||||
[array, size_is(aLength), retval] out wstring aValues);
|
||||
// Check whether a given CSS property is a shorthand. Throws on unsupported
|
||||
// property names.
|
||||
bool cssPropertyIsShorthand(in AString aProperty);
|
||||
|
||||
// Check whether values of the given type are valid values for the property.
|
||||
// For shorthands, checks whether there's a corresponding longhand property
|
||||
// that accepts values of this type. Throws on unsupported properties or
|
||||
// unknown types.
|
||||
const unsigned long TYPE_LENGTH = 0;
|
||||
const unsigned long TYPE_PERCENTAGE = 1;
|
||||
const unsigned long TYPE_COLOR = 2;
|
||||
const unsigned long TYPE_URL = 3;
|
||||
const unsigned long TYPE_ANGLE = 4;
|
||||
const unsigned long TYPE_FREQUENCY = 5;
|
||||
const unsigned long TYPE_TIME = 6;
|
||||
const unsigned long TYPE_GRADIENT = 7;
|
||||
const unsigned long TYPE_TIMING_FUNCTION = 8;
|
||||
const unsigned long TYPE_IMAGE_RECT = 9;
|
||||
const unsigned long TYPE_NUMBER = 10;
|
||||
bool cssPropertySupportsType(in AString aProperty, in unsigned long type);
|
||||
|
||||
// DOM Node utilities
|
||||
boolean isIgnorableWhitespace(in nsIDOMCharacterData aDataNode);
|
||||
// Returns the "parent" of a node. The parent of a document node is the
|
||||
// frame/iframe containing that document. aShowingAnonymousContent says
|
||||
// whether we are showing anonymous content.
|
||||
nsIDOMNode getParentForNode(in nsIDOMNode aNode,
|
||||
in boolean aShowingAnonymousContent);
|
||||
nsIDOMNodeList getChildrenForNode(in nsIDOMNode aNode,
|
||||
in boolean aShowingAnonymousContent);
|
||||
|
||||
// XBL utilities
|
||||
nsIArray getBindingURLs(in nsIDOMElement aElement);
|
||||
|
||||
// content state utilities
|
||||
unsigned long long getContentState(in nsIDOMElement aElement);
|
||||
/**
|
||||
* Setting and removing content state on an element. Both these functions
|
||||
* calling EventStateManager::SetContentState internally, the difference is
|
||||
* that for the remove case we simply pass in nullptr for the element.
|
||||
* Use them accordingly.
|
||||
*
|
||||
* @return Returns true if the state was set successfully. See more details
|
||||
* in EventStateManager.h SetContentState.
|
||||
*/
|
||||
bool setContentState(in nsIDOMElement aElement, in unsigned long long aState);
|
||||
bool removeContentState(in nsIDOMElement aElement, in unsigned long long aState);
|
||||
|
||||
nsIDOMFontFaceList getUsedFontFaces(in nsIDOMRange aRange);
|
||||
|
||||
/**
|
||||
* Get the names of all the supported pseudo-elements.
|
||||
* Pseudo-elements which are only accepted in UA style sheets are
|
||||
* not included.
|
||||
*
|
||||
* @param {unsigned long} aCount the number of items returned
|
||||
* @param {wstring[]} aNames the names
|
||||
*/
|
||||
void getCSSPseudoElementNames([optional] out unsigned long aCount,
|
||||
[retval, array, size_is(aCount)] out wstring aNames);
|
||||
|
||||
// pseudo-class style locking methods. aPseudoClass must be a valid pseudo-class
|
||||
// selector string, e.g. ":hover". ":any-link" and non-event-state
|
||||
// pseudo-classes are ignored.
|
||||
void addPseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass);
|
||||
void removePseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass);
|
||||
bool hasPseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass);
|
||||
void clearPseudoClassLocks(in nsIDOMElement aElement);
|
||||
|
||||
/**
|
||||
* Parse CSS and update the style sheet in place.
|
||||
*
|
||||
* @param DOMCSSStyleSheet aSheet
|
||||
* @param DOMString aInput
|
||||
* The new source string for the style sheet.
|
||||
*/
|
||||
void parseStyleSheet(in nsIDOMCSSStyleSheet aSheet, in DOMString aInput);
|
||||
/**
|
||||
* Scroll an element completely into view, if possible.
|
||||
* This is similar to ensureElementIsVisible but for all ancestors.
|
||||
*
|
||||
* @param DOMElement aElement
|
||||
*/
|
||||
void scrollElementIntoView(in nsIDOMElement aElement);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define IN_DOMUTILS_CONTRACTID "@mozilla.org/inspector/dom-utils;1"
|
||||
%}
|
||||
24
layout/inspector/inIDOMView.idl
Normal file
24
layout/inspector/inIDOMView.idl
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMNode;
|
||||
|
||||
[scriptable, uuid(FBB67442-27A3-483C-8EB2-29C3EED7514C)]
|
||||
interface inIDOMView : nsISupports
|
||||
{
|
||||
attribute nsIDOMNode rootNode;
|
||||
|
||||
attribute boolean showAnonymousContent;
|
||||
attribute boolean showSubDocuments;
|
||||
attribute boolean showWhitespaceNodes;
|
||||
attribute boolean showAccessibleNodes;
|
||||
attribute unsigned long whatToShow;
|
||||
|
||||
nsIDOMNode getNodeFromRowIndex(in long rowIndex);
|
||||
long getRowIndexFromNode(in nsIDOMNode node);
|
||||
|
||||
void rebuild();
|
||||
};
|
||||
47
layout/inspector/inIDeepTreeWalker.idl
Normal file
47
layout/inspector/inIDeepTreeWalker.idl
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMNode;
|
||||
interface nsIDOMNodeFilter;
|
||||
|
||||
// Note: the iterator does not handle DOM mutations gracefully. So if
|
||||
// the underlying DOM we are iterating over is changed, the behavior
|
||||
// of the walker is undefined. (With the current implementation we
|
||||
// cache the siblings of the current node and this list is not updated
|
||||
// when a mutation occurs).
|
||||
|
||||
[scriptable, uuid(6657e8eb-b646-48e7-993e-cfa6e96415b4)]
|
||||
interface inIDeepTreeWalker : nsISupports
|
||||
{
|
||||
attribute boolean showAnonymousContent;
|
||||
attribute boolean showSubDocuments;
|
||||
|
||||
// By default the walker skips document nodes from the iteration,
|
||||
// by setting this flag to true this behavior can be altered.
|
||||
attribute boolean showDocumentsAsNodes;
|
||||
|
||||
void init(in nsIDOMNode aRoot, in unsigned long aWhatToShow);
|
||||
|
||||
// Methods and attributes from nsIDOMTreeWalker, which is not scriptable.
|
||||
// Note: normally parentNode cannot go further up on the tree once it reached
|
||||
// the root, but setting currentNode does not have this limitation. If currentNode
|
||||
// is set to a node that does not have the root as its ancestor the walk can be
|
||||
// continued from there, and once we reach a node that is 'under' the root, the
|
||||
// limitation for the parentNode will work again.
|
||||
readonly attribute nsIDOMNode root;
|
||||
readonly attribute unsigned long whatToShow;
|
||||
readonly attribute nsIDOMNodeFilter filter;
|
||||
attribute nsIDOMNode currentNode;
|
||||
|
||||
nsIDOMNode parentNode();
|
||||
nsIDOMNode firstChild();
|
||||
nsIDOMNode lastChild();
|
||||
nsIDOMNode previousSibling();
|
||||
nsIDOMNode nextSibling();
|
||||
nsIDOMNode previousNode();
|
||||
nsIDOMNode nextNode();
|
||||
};
|
||||
|
||||
21
layout/inspector/inISearchObserver.idl
Normal file
21
layout/inspector/inISearchObserver.idl
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface inISearchProcess;
|
||||
|
||||
[scriptable, uuid(46226D9B-E398-4106-8D9B-225D4D0589F5)]
|
||||
interface inISearchObserver : nsISupports
|
||||
{
|
||||
// result codes which are sent to onSearchEnd
|
||||
const short IN_SUCCESS = 1; // search completed successfully
|
||||
const short IN_INTERRUPTED = 2; // search stopped due to user interruption
|
||||
const short IN_ERROR = 3; // search stopped due to an error
|
||||
|
||||
void onSearchStart(in inISearchProcess aModule);
|
||||
void onSearchResult(in inISearchProcess aModule);
|
||||
void onSearchEnd(in inISearchProcess aModule, in short aResult);
|
||||
void onSearchError(in inISearchProcess aModule, in AString aMessage);
|
||||
};
|
||||
49
layout/inspector/inISearchProcess.idl
Normal file
49
layout/inspector/inISearchProcess.idl
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsAString;
|
||||
interface inISearchObserver;
|
||||
|
||||
[scriptable, uuid(D5FA765B-2448-4686-B7C1-5FF13ACB0FC9)]
|
||||
interface inISearchProcess : nsISupports
|
||||
{
|
||||
// indicates if an asynchronous search is in progress
|
||||
readonly attribute boolean isActive;
|
||||
|
||||
// the number of results returned
|
||||
readonly attribute long resultCount;
|
||||
|
||||
// for optimization when doing an async search, this will optionally
|
||||
// destroy old results, assuming they will be fetched as soon as
|
||||
// the observer is notified of their presence. If true, then indices
|
||||
// pass to the get*ResultAt methods will return null for any index
|
||||
// other than the most recent one, and getResults will return null always.
|
||||
attribute boolean holdResults;
|
||||
|
||||
// start a synchronous search
|
||||
void searchSync();
|
||||
|
||||
// start an asynchronous search
|
||||
void searchAsync(in inISearchObserver aObserver);
|
||||
|
||||
// command an async process to stop immediately
|
||||
void searchStop();
|
||||
|
||||
// performs a step in the asynchronous search loop
|
||||
// return indicates true if loop is done, false if it should continue
|
||||
// This is there only for the benefit of asynchronous search controllers,
|
||||
// and is not for use by those who just wish to call searchAsync
|
||||
boolean searchStep();
|
||||
|
||||
// methods for getting results of specific types
|
||||
|
||||
AString getStringResultAt(in long aIndex);
|
||||
|
||||
long getIntResultAt(in long aIndex);
|
||||
|
||||
unsigned long getUIntResultAt(in long aIndex);
|
||||
};
|
||||
71
layout/inspector/inLayoutUtils.cpp
Normal file
71
layout/inspector/inLayoutUtils.cpp
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "inLayoutUtils.h"
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
EventStateManager*
|
||||
inLayoutUtils::GetEventStateManagerFor(nsIDOMElement *aElement)
|
||||
{
|
||||
NS_PRECONDITION(aElement, "Passing in a null element is bad");
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
aElement->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
|
||||
|
||||
if (!doc) {
|
||||
NS_WARNING("Could not get an nsIDocument!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsIPresShell *shell = doc->GetShell();
|
||||
if (!shell)
|
||||
return nullptr;
|
||||
|
||||
return shell->GetPresContext()->EventStateManager();
|
||||
}
|
||||
|
||||
nsIDOMDocument*
|
||||
inLayoutUtils::GetSubDocumentFor(nsIDOMNode* aNode)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
if (content) {
|
||||
nsCOMPtr<nsIDocument> doc = content->GetComposedDoc();
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(doc->GetSubDocumentFor(content)));
|
||||
|
||||
return domdoc;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsIDOMNode*
|
||||
inLayoutUtils::GetContainerFor(const nsIDocument& aDoc)
|
||||
{
|
||||
nsPIDOMWindowOuter* pwin = aDoc.GetWindow();
|
||||
if (!pwin) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(pwin->GetFrameElementInternal());
|
||||
return node;
|
||||
}
|
||||
|
||||
27
layout/inspector/inLayoutUtils.h
Normal file
27
layout/inspector/inLayoutUtils.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __inLayoutUtils_h__
|
||||
#define __inLayoutUtils_h__
|
||||
|
||||
class nsIDocument;
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNode;
|
||||
|
||||
namespace mozilla {
|
||||
class EventStateManager;
|
||||
} // namespace mozilla
|
||||
|
||||
class inLayoutUtils
|
||||
{
|
||||
public:
|
||||
static mozilla::EventStateManager*
|
||||
GetEventStateManagerFor(nsIDOMElement *aElement);
|
||||
static nsIDOMDocument* GetSubDocumentFor(nsIDOMNode* aNode);
|
||||
static nsIDOMNode* GetContainerFor(const nsIDocument& aDoc);
|
||||
};
|
||||
|
||||
#endif // __inLayoutUtils_h__
|
||||
58
layout/inspector/inSearchLoop.cpp
Normal file
58
layout/inspector/inSearchLoop.cpp
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "inSearchLoop.h"
|
||||
|
||||
#include "nsITimer.h"
|
||||
#include "nsIServiceManager.h"
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inSearchLoop::inSearchLoop(inISearchProcess* aSearchProcess)
|
||||
{
|
||||
mSearchProcess = aSearchProcess;
|
||||
nsresult rv;
|
||||
mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
||||
}
|
||||
|
||||
inSearchLoop::~inSearchLoop()
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// inSearchLoop
|
||||
|
||||
nsresult
|
||||
inSearchLoop::Start()
|
||||
{
|
||||
mTimer->InitWithFuncCallback(inSearchLoop::TimerCallback, (void*)this, 0, nsITimer::TYPE_REPEATING_SLACK);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
inSearchLoop::Step()
|
||||
{
|
||||
bool done = false;
|
||||
mSearchProcess->SearchStep(&done);
|
||||
|
||||
if (done)
|
||||
Stop();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
inSearchLoop::Stop()
|
||||
{
|
||||
mTimer->Cancel();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
inSearchLoop::TimerCallback(nsITimer *aTimer, void *aClosure)
|
||||
{
|
||||
inSearchLoop* loop = (inSearchLoop*) aClosure;
|
||||
loop->Step();
|
||||
}
|
||||
28
layout/inspector/inSearchLoop.h
Normal file
28
layout/inspector/inSearchLoop.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __inSearchLoop_h__
|
||||
#define __inSearchLoop_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsITimer.h"
|
||||
#include "inISearchProcess.h"
|
||||
|
||||
class inSearchLoop
|
||||
{
|
||||
public:
|
||||
explicit inSearchLoop(inISearchProcess* aSearchProcess);
|
||||
virtual ~inSearchLoop();
|
||||
|
||||
nsresult Start();
|
||||
nsresult Step();
|
||||
nsresult Stop();
|
||||
static void TimerCallback(nsITimer *aTimer, void *aClosure);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
nsCOMPtr<inISearchProcess> mSearchProcess;
|
||||
};
|
||||
|
||||
#endif
|
||||
49
layout/inspector/moz.build
Normal file
49
layout/inspector/moz.build
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
if CONFIG['ENABLE_TESTS']:
|
||||
MOCHITEST_CHROME_MANIFESTS += ['tests/chrome/chrome.ini']
|
||||
MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'inICSSValueSearch.idl',
|
||||
'inIDeepTreeWalker.idl',
|
||||
'inIDOMUtils.idl',
|
||||
'inIDOMView.idl',
|
||||
'inISearchObserver.idl',
|
||||
'inISearchProcess.idl',
|
||||
'nsIDOMFontFace.idl',
|
||||
'nsIDOMFontFaceList.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'inspector'
|
||||
|
||||
EXPORTS += [
|
||||
'nsFontFace.h',
|
||||
'nsFontFaceList.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'inCSSValueSearch.cpp',
|
||||
'inDeepTreeWalker.cpp',
|
||||
'inDOMUtils.cpp',
|
||||
'inLayoutUtils.cpp',
|
||||
'inSearchLoop.cpp',
|
||||
'nsFontFace.cpp',
|
||||
'nsFontFaceList.cpp',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_XUL']:
|
||||
UNIFIED_SOURCES += [
|
||||
'inDOMView.cpp',
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
LOCAL_INCLUDES += [
|
||||
'../style',
|
||||
'/dom/base',
|
||||
'/dom/xbl',
|
||||
]
|
||||
225
layout/inspector/nsFontFace.cpp
Normal file
225
layout/inspector/nsFontFace.cpp
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsFontFace.h"
|
||||
#include "nsIDOMCSSFontFaceRule.h"
|
||||
#include "nsCSSRules.h"
|
||||
#include "gfxTextRun.h"
|
||||
#include "gfxUserFontSet.h"
|
||||
#include "nsFontFaceLoader.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "decode.h"
|
||||
#include "zlib.h"
|
||||
#include "mozilla/dom/FontFaceSet.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
nsFontFace::nsFontFace(gfxFontEntry* aFontEntry,
|
||||
gfxFontGroup* aFontGroup,
|
||||
uint8_t aMatchType)
|
||||
: mFontEntry(aFontEntry),
|
||||
mFontGroup(aFontGroup),
|
||||
mMatchType(aMatchType)
|
||||
{
|
||||
}
|
||||
|
||||
nsFontFace::~nsFontFace()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsISupports
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsFontFace, nsIDOMFontFace)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIDOMFontFace
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontFace::GetFromFontGroup(bool * aFromFontGroup)
|
||||
{
|
||||
*aFromFontGroup =
|
||||
(mMatchType & gfxTextRange::kFontGroup) != 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontFace::GetFromLanguagePrefs(bool * aFromLanguagePrefs)
|
||||
{
|
||||
*aFromLanguagePrefs =
|
||||
(mMatchType & gfxTextRange::kPrefsFallback) != 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontFace::GetFromSystemFallback(bool * aFromSystemFallback)
|
||||
{
|
||||
*aFromSystemFallback =
|
||||
(mMatchType & gfxTextRange::kSystemFallback) != 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontFace::GetName(nsAString & aName)
|
||||
{
|
||||
if (mFontEntry->IsUserFont() && !mFontEntry->IsLocalUserFont()) {
|
||||
NS_ASSERTION(mFontEntry->mUserFontData, "missing userFontData");
|
||||
aName = mFontEntry->mUserFontData->mRealName;
|
||||
} else {
|
||||
aName = mFontEntry->RealFaceName();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontFace::GetCSSFamilyName(nsAString & aCSSFamilyName)
|
||||
{
|
||||
aCSSFamilyName = mFontEntry->FamilyName();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontFace::GetRule(nsIDOMCSSFontFaceRule **aRule)
|
||||
{
|
||||
// check whether this font entry is associated with an @font-face rule
|
||||
// in the relevant font group's user font set
|
||||
nsCSSFontFaceRule* rule = nullptr;
|
||||
if (mFontEntry->IsUserFont()) {
|
||||
FontFaceSet::UserFontSet* fontSet =
|
||||
static_cast<FontFaceSet::UserFontSet*>(mFontGroup->GetUserFontSet());
|
||||
if (fontSet) {
|
||||
FontFaceSet* fontFaceSet = fontSet->GetFontFaceSet();
|
||||
if (fontFaceSet) {
|
||||
rule = fontFaceSet->FindRuleForEntry(mFontEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*aRule = rule);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontFace::GetSrcIndex(int32_t * aSrcIndex)
|
||||
{
|
||||
if (mFontEntry->IsUserFont()) {
|
||||
NS_ASSERTION(mFontEntry->mUserFontData, "missing userFontData");
|
||||
*aSrcIndex = mFontEntry->mUserFontData->mSrcIndex;
|
||||
} else {
|
||||
*aSrcIndex = -1;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontFace::GetURI(nsAString & aURI)
|
||||
{
|
||||
aURI.Truncate();
|
||||
if (mFontEntry->IsUserFont() && !mFontEntry->IsLocalUserFont()) {
|
||||
NS_ASSERTION(mFontEntry->mUserFontData, "missing userFontData");
|
||||
if (mFontEntry->mUserFontData->mURI) {
|
||||
nsAutoCString spec;
|
||||
nsresult rv = mFontEntry->mUserFontData->mURI->GetSpec(spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
AppendUTF8toUTF16(spec, aURI);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontFace::GetLocalName(nsAString & aLocalName)
|
||||
{
|
||||
if (mFontEntry->IsLocalUserFont()) {
|
||||
NS_ASSERTION(mFontEntry->mUserFontData, "missing userFontData");
|
||||
aLocalName = mFontEntry->mUserFontData->mLocalName;
|
||||
} else {
|
||||
aLocalName.Truncate();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
AppendToFormat(nsAString & aResult, const char* aFormat)
|
||||
{
|
||||
if (!aResult.IsEmpty()) {
|
||||
aResult.Append(',');
|
||||
}
|
||||
aResult.AppendASCII(aFormat);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontFace::GetFormat(nsAString & aFormat)
|
||||
{
|
||||
aFormat.Truncate();
|
||||
if (mFontEntry->IsUserFont() && !mFontEntry->IsLocalUserFont()) {
|
||||
NS_ASSERTION(mFontEntry->mUserFontData, "missing userFontData");
|
||||
uint32_t formatFlags = mFontEntry->mUserFontData->mFormat;
|
||||
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_OPENTYPE) {
|
||||
AppendToFormat(aFormat, "opentype");
|
||||
}
|
||||
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_TRUETYPE) {
|
||||
AppendToFormat(aFormat, "truetype");
|
||||
}
|
||||
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_TRUETYPE_AAT) {
|
||||
AppendToFormat(aFormat, "truetype-aat");
|
||||
}
|
||||
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_EOT) {
|
||||
AppendToFormat(aFormat, "embedded-opentype");
|
||||
}
|
||||
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_SVG) {
|
||||
AppendToFormat(aFormat, "svg");
|
||||
}
|
||||
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_WOFF) {
|
||||
AppendToFormat(aFormat, "woff");
|
||||
}
|
||||
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_WOFF2) {
|
||||
AppendToFormat(aFormat, "woff2");
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontFace::GetMetadata(nsAString & aMetadata)
|
||||
{
|
||||
aMetadata.Truncate();
|
||||
if (mFontEntry->IsUserFont() && !mFontEntry->IsLocalUserFont()) {
|
||||
NS_ASSERTION(mFontEntry->mUserFontData, "missing userFontData");
|
||||
const gfxUserFontData* userFontData = mFontEntry->mUserFontData.get();
|
||||
if (userFontData->mMetadata.Length() && userFontData->mMetaOrigLen) {
|
||||
nsAutoCString str;
|
||||
str.SetLength(userFontData->mMetaOrigLen);
|
||||
if (str.Length() == userFontData->mMetaOrigLen) {
|
||||
switch (userFontData->mCompression) {
|
||||
case gfxUserFontData::kZlibCompression:
|
||||
{
|
||||
uLongf destLen = userFontData->mMetaOrigLen;
|
||||
if (uncompress((Bytef *)(str.BeginWriting()), &destLen,
|
||||
(const Bytef *)(userFontData->mMetadata.Elements()),
|
||||
userFontData->mMetadata.Length()) == Z_OK &&
|
||||
destLen == userFontData->mMetaOrigLen) {
|
||||
AppendUTF8toUTF16(str, aMetadata);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case gfxUserFontData::kBrotliCompression:
|
||||
{
|
||||
size_t decodedSize = userFontData->mMetaOrigLen;
|
||||
if (BrotliDecompressBuffer(userFontData->mMetadata.Length(),
|
||||
userFontData->mMetadata.Elements(),
|
||||
&decodedSize,
|
||||
(uint8_t*)str.BeginWriting()) == 1 &&
|
||||
decodedSize == userFontData->mMetaOrigLen) {
|
||||
AppendUTF8toUTF16(str, aMetadata);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
37
layout/inspector/nsFontFace.h
Normal file
37
layout/inspector/nsFontFace.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __nsFontFace_h__
|
||||
#define __nsFontFace_h__
|
||||
|
||||
#include "nsIDOMFontFace.h"
|
||||
|
||||
class gfxFontEntry;
|
||||
class gfxFontGroup;
|
||||
|
||||
class nsFontFace : public nsIDOMFontFace
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMFONTFACE
|
||||
|
||||
nsFontFace(gfxFontEntry* aFontEntry,
|
||||
gfxFontGroup* aFontGroup,
|
||||
uint8_t aMatchInfo);
|
||||
|
||||
gfxFontEntry* GetFontEntry() const { return mFontEntry.get(); }
|
||||
|
||||
void AddMatchType(uint8_t aMatchType) {
|
||||
mMatchType |= aMatchType;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~nsFontFace();
|
||||
|
||||
RefPtr<gfxFontEntry> mFontEntry;
|
||||
RefPtr<gfxFontGroup> mFontGroup;
|
||||
uint8_t mMatchType;
|
||||
};
|
||||
|
||||
#endif // __nsFontFace_h__
|
||||
83
layout/inspector/nsFontFaceList.cpp
Normal file
83
layout/inspector/nsFontFaceList.cpp
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsFontFaceList.h"
|
||||
#include "nsFontFace.h"
|
||||
#include "nsFontFaceLoader.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "gfxTextRun.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
|
||||
nsFontFaceList::nsFontFaceList()
|
||||
{
|
||||
}
|
||||
|
||||
nsFontFaceList::~nsFontFaceList()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsISupports
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsFontFaceList, nsIDOMFontFaceList)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIDOMFontFaceList
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontFaceList::Item(uint32_t index, nsIDOMFontFace **_retval)
|
||||
{
|
||||
NS_ENSURE_TRUE(index < mFontFaces.Count(), NS_ERROR_INVALID_ARG);
|
||||
|
||||
uint32_t current = 0;
|
||||
nsIDOMFontFace* result = nullptr;
|
||||
for (auto iter = mFontFaces.Iter(); !iter.Done(); iter.Next()) {
|
||||
if (current == index) {
|
||||
result = iter.UserData();
|
||||
break;
|
||||
}
|
||||
current++;
|
||||
}
|
||||
NS_ASSERTION(result != nullptr, "null entry in nsFontFaceList?");
|
||||
NS_IF_ADDREF(*_retval = result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontFaceList::GetLength(uint32_t *aLength)
|
||||
{
|
||||
*aLength = mFontFaces.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsFontFaceList
|
||||
|
||||
nsresult
|
||||
nsFontFaceList::AddFontsFromTextRun(gfxTextRun* aTextRun,
|
||||
uint32_t aOffset, uint32_t aLength)
|
||||
{
|
||||
gfxTextRun::Range range(aOffset, aOffset + aLength);
|
||||
gfxTextRun::GlyphRunIterator iter(aTextRun, range);
|
||||
while (iter.NextRun()) {
|
||||
gfxFontEntry *fe = iter.GetGlyphRun()->mFont->GetFontEntry();
|
||||
// if we have already listed this face, just make sure the match type is
|
||||
// recorded
|
||||
nsFontFace* existingFace =
|
||||
static_cast<nsFontFace*>(mFontFaces.GetWeak(fe));
|
||||
if (existingFace) {
|
||||
existingFace->AddMatchType(iter.GetGlyphRun()->mMatchType);
|
||||
} else {
|
||||
// A new font entry we haven't seen before
|
||||
RefPtr<nsFontFace> ff =
|
||||
new nsFontFace(fe, aTextRun->GetFontGroup(),
|
||||
iter.GetGlyphRun()->mMatchType);
|
||||
mFontFaces.Put(fe, ff);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
34
layout/inspector/nsFontFaceList.h
Normal file
34
layout/inspector/nsFontFaceList.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __nsFontFaceList_h__
|
||||
#define __nsFontFaceList_h__
|
||||
|
||||
#include "nsIDOMFontFaceList.h"
|
||||
#include "nsIDOMFontFace.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
|
||||
class gfxFontEntry;
|
||||
class gfxTextRun;
|
||||
|
||||
class nsFontFaceList : public nsIDOMFontFaceList
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMFONTFACELIST
|
||||
|
||||
nsFontFaceList();
|
||||
|
||||
nsresult AddFontsFromTextRun(gfxTextRun* aTextRun,
|
||||
uint32_t aOffset, uint32_t aLength);
|
||||
|
||||
protected:
|
||||
virtual ~nsFontFaceList();
|
||||
|
||||
nsInterfaceHashtable<nsPtrHashKey<gfxFontEntry>,nsIDOMFontFace> mFontFaces;
|
||||
};
|
||||
|
||||
#endif // __nsFontFaceList_h__
|
||||
32
layout/inspector/nsIDOMFontFace.idl
Normal file
32
layout/inspector/nsIDOMFontFace.idl
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMCSSFontFaceRule;
|
||||
interface nsIDOMCSSStyleDeclaration;
|
||||
|
||||
[scriptable, uuid(9a3b1272-6585-4f41-b08f-fdc5da444cd0)]
|
||||
interface nsIDOMFontFace : nsISupports
|
||||
{
|
||||
// An indication of how we found this font during font-matching.
|
||||
// Note that the same physical font may have been found in multiple ways within a range.
|
||||
readonly attribute boolean fromFontGroup;
|
||||
readonly attribute boolean fromLanguagePrefs;
|
||||
readonly attribute boolean fromSystemFallback;
|
||||
|
||||
// available for all fonts
|
||||
readonly attribute DOMString name; // full font name as obtained from the font resource
|
||||
readonly attribute DOMString CSSFamilyName; // a family name that could be used in CSS font-family
|
||||
// (not necessarily the actual name that was used,
|
||||
// due to aliases, generics, localized names, etc)
|
||||
|
||||
// meaningful only when the font is a user font defined using @font-face
|
||||
readonly attribute nsIDOMCSSFontFaceRule rule; // null if no associated @font-face rule
|
||||
readonly attribute long srcIndex; // index in the rule's src list, -1 if no @font-face rule
|
||||
readonly attribute DOMString URI; // null if not a downloaded font, i.e. local
|
||||
readonly attribute DOMString localName; // null if not a src:local(...) rule
|
||||
readonly attribute DOMString format; // as per http://www.w3.org/TR/css3-webfonts/#referencing
|
||||
readonly attribute DOMString metadata; // XML metadata from WOFF file (if any)
|
||||
};
|
||||
14
layout/inspector/nsIDOMFontFaceList.idl
Normal file
14
layout/inspector/nsIDOMFontFaceList.idl
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMFontFace;
|
||||
|
||||
[scriptable, uuid(2538579c-9472-4fd9-8dc1-d44ce4c1b7ba)]
|
||||
interface nsIDOMFontFaceList : nsISupports
|
||||
{
|
||||
nsIDOMFontFace item(in unsigned long index);
|
||||
readonly attribute unsigned long length;
|
||||
};
|
||||
7
layout/inspector/tests/bug1202095-2.css
Normal file
7
layout/inspector/tests/bug1202095-2.css
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* Bug 1202095 - parseStyleSheet should not re-load @imports
|
||||
*/
|
||||
|
||||
body {
|
||||
color: chartreuse;
|
||||
}
|
||||
7
layout/inspector/tests/bug1202095.css
Normal file
7
layout/inspector/tests/bug1202095.css
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* Bug 1202095 - parseStyleSheet should not re-load @imports
|
||||
*/
|
||||
|
||||
body {
|
||||
background-color: purple;
|
||||
}
|
||||
23
layout/inspector/tests/bug856317.css
Normal file
23
layout/inspector/tests/bug856317.css
Normal file
File diff suppressed because one or more lines are too long
BIN
layout/inspector/tests/chrome/GentiumPlus-R.woff
Normal file
BIN
layout/inspector/tests/chrome/GentiumPlus-R.woff
Normal file
Binary file not shown.
12
layout/inspector/tests/chrome/chrome.ini
Normal file
12
layout/inspector/tests/chrome/chrome.ini
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[DEFAULT]
|
||||
skip-if = os == 'android'
|
||||
support-files = GentiumPlus-R.woff
|
||||
|
||||
[test_bug467669.css]
|
||||
[test_bug467669.xul]
|
||||
[test_bug695639.css]
|
||||
[test_bug695639.xul]
|
||||
[test_bug708874.css]
|
||||
[test_bug708874.xul]
|
||||
[test_bug727834.css]
|
||||
[test_bug727834.xul]
|
||||
8
layout/inspector/tests/chrome/test_bug467669.css
Normal file
8
layout/inspector/tests/chrome/test_bug467669.css
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
@font-face {
|
||||
font-family: font-face-test-family;
|
||||
src: url(bad/font/name.ttf), url(GentiumPlus-R.woff) format("woff");
|
||||
}
|
||||
|
||||
.gentium {
|
||||
font-family: font-face-test-family;
|
||||
}
|
||||
174
layout/inspector/tests/chrome/test_bug467669.xul
Normal file
174
layout/inspector/tests/chrome/test_bug467669.xul
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
<?xml-stylesheet type="text/css" href="test_bug467669.css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=467669
|
||||
-->
|
||||
<window title="Mozilla Bug 467669"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="RunTest();">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
/** Test for Bug 467669 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function RunTest() {
|
||||
const CI = Components.interfaces;
|
||||
const CC = Components.classes;
|
||||
|
||||
const kIsLinux = navigator.platform.indexOf("Linux") == 0;
|
||||
const kIsMac = navigator.platform.indexOf("Mac") == 0;
|
||||
const kIsWin = navigator.platform.indexOf("Win") == 0;
|
||||
|
||||
var domUtils =
|
||||
CC["@mozilla.org/inspector/dom-utils;1"].getService(CI.inIDOMUtils);
|
||||
|
||||
var rng = document.createRange();
|
||||
var elem, fonts, f;
|
||||
|
||||
elem = document.getElementById("test1");
|
||||
rng.selectNode(elem);
|
||||
fonts = domUtils.getUsedFontFaces(rng);
|
||||
is(fonts.length, 1, "number of fonts for simple Latin text");
|
||||
f = fonts.item(0);
|
||||
is(f.rule, null, "rule");
|
||||
is(f.srcIndex, -1, "srcIndex");
|
||||
is(f.localName, "", "local name");
|
||||
is(f.URI, "", "URI");
|
||||
is(f.format, "", "format string");
|
||||
is(f.metadata, "", "metadata");
|
||||
// report(elem.id, fonts);
|
||||
|
||||
elem = document.getElementById("test2");
|
||||
rng.selectNode(elem);
|
||||
fonts = domUtils.getUsedFontFaces(rng);
|
||||
is(fonts.length, 3, "number of fonts for mixed serif, sans and monospaced text");
|
||||
// report(elem.id, fonts);
|
||||
|
||||
elem = document.getElementById("test3");
|
||||
rng.selectNode(elem);
|
||||
fonts = domUtils.getUsedFontFaces(rng);
|
||||
is(fonts.length, 2, "number of fonts for mixed Latin & Chinese");
|
||||
// report(elem.id, fonts);
|
||||
|
||||
// get properties of a @font-face font
|
||||
elem = document.getElementById("test4");
|
||||
rng.selectNode(elem);
|
||||
fonts = domUtils.getUsedFontFaces(rng);
|
||||
is(fonts.length, 1, "number of fonts in @font-face test");
|
||||
f = fonts.item(0);
|
||||
isnot(f.rule, null, "missing rule");
|
||||
is(f.srcIndex, 1, "srcIndex");
|
||||
is(f.localName, "", "local name");
|
||||
is(f.URI, "chrome://mochitests/content/chrome/layout/inspector/tests/chrome/GentiumPlus-R.woff", "bad URI");
|
||||
is(f.format, "woff", "format");
|
||||
is(/bukva:raz/.test(f.metadata), true, "metadata");
|
||||
// report(elem.id, fonts);
|
||||
|
||||
elem = document.getElementById("test5").childNodes[0];
|
||||
// check that string length is as expected, including soft hyphens
|
||||
is(elem.length, 42, "string length with soft hyphens");
|
||||
|
||||
// initial latin substring...
|
||||
rng.setStart(elem, 0);
|
||||
rng.setEnd(elem, 20); // "supercalifragilistic"
|
||||
fonts = domUtils.getUsedFontFaces(rng);
|
||||
is(fonts.length, 1, "number of fonts (Latin-only)");
|
||||
f = fonts.item(0);
|
||||
is(f.name, "Gentium Plus", "font name");
|
||||
is(f.CSSFamilyName, "font-face-test-family", "family name");
|
||||
is(f.fromFontGroup, true, "font matched in font group");
|
||||
|
||||
// extend to include a chinese character
|
||||
rng.setEnd(elem, 21);
|
||||
fonts = domUtils.getUsedFontFaces(rng);
|
||||
is(fonts.length, 2, "number of fonts (incl Chinese)");
|
||||
if (kIsMac || kIsWin) { // these are only implemented by the Mac & Win font backends
|
||||
var i;
|
||||
for (i = 0; i < fonts.length; ++i) {
|
||||
f = fonts.item(i);
|
||||
if (f.rule) {
|
||||
is(f.fromFontGroup, true, "@font-face font matched in group");
|
||||
is(f.fromLanguagePrefs, false, "not from language prefs");
|
||||
is(f.fromSystemFallback, false, "not from system fallback");
|
||||
} else {
|
||||
is(f.fromFontGroup, false, "not matched in group");
|
||||
is(f.fromLanguagePrefs, true, "from language prefs");
|
||||
is(f.fromSystemFallback, false, "not from system fallback");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// second half of the string includes ­ chars to check original/skipped mapping;
|
||||
// select just the final character
|
||||
rng.setStart(elem, elem.length - 1);
|
||||
rng.setEnd(elem, elem.length);
|
||||
is(rng.toString(), "!", "content of range");
|
||||
fonts = domUtils.getUsedFontFaces(rng);
|
||||
is(fonts.length, 1, "number of fonts for last char");
|
||||
f = fonts.item(0);
|
||||
is(f.name, "Gentium Plus", "font name");
|
||||
|
||||
// include the preceding character as well
|
||||
rng.setStart(elem, elem.length - 2);
|
||||
fonts = domUtils.getUsedFontFaces(rng);
|
||||
is(fonts.length, 2, "number of fonts for last two chars");
|
||||
|
||||
// then trim the final one
|
||||
rng.setEnd(elem, elem.length - 1);
|
||||
fonts = domUtils.getUsedFontFaces(rng);
|
||||
is(fonts.length, 1, "number of fonts for Chinese char");
|
||||
f = fonts.item(0);
|
||||
isnot(f.name, "Gentium Plus", "font name for Chinese char");
|
||||
|
||||
rng.selectNode(elem);
|
||||
fonts = domUtils.getUsedFontFaces(rng);
|
||||
// report("test5", fonts);
|
||||
|
||||
elem = document.getElementById("test6");
|
||||
rng.selectNode(elem);
|
||||
fonts = domUtils.getUsedFontFaces(rng);
|
||||
is(fonts.length, 2, "number of font faces for regular & italic");
|
||||
is(fonts.item(0).CSSFamilyName, fonts.item(1).CSSFamilyName, "same family for regular & italic");
|
||||
isnot(fonts.item(0).name, fonts.item(1).name, "different faces for regular & italic");
|
||||
// report(elem.id, fonts);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
// just for test-debugging purposes
|
||||
function report(e, f) {
|
||||
var fontNames = "";
|
||||
var i;
|
||||
for (i = 0; i < f.length; ++i) {
|
||||
if (i == 0) {
|
||||
fontNames += e + " fonts: "
|
||||
} else {
|
||||
fontNames += ", ";
|
||||
}
|
||||
fontNames += f.item(i).name;
|
||||
}
|
||||
dump(fontNames + "\n");
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<!-- html:body contains elements the test will inspect -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=467669"
|
||||
target="_blank">Mozilla Bug 467669</a>
|
||||
<div id="test1">Hello world</div>
|
||||
<div id="test2" style="font-family:sans-serif"><span style="font-family:serif">Hello</span> <tt>cruel</tt> world</div>
|
||||
<div id="test3">Hello, 你好</div>
|
||||
<div id="test4" class="gentium">Hello Gentium Plus!</div>
|
||||
<div id="test5" class="gentium">supercalifragilistic你ex­pi­a­li­do­cious好!</div>
|
||||
<div id="test6" style="font-family:serif">regular and <em>italic</em> text</div>
|
||||
</body>
|
||||
|
||||
</window>
|
||||
8
layout/inspector/tests/chrome/test_bug695639.css
Normal file
8
layout/inspector/tests/chrome/test_bug695639.css
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
@font-face {
|
||||
font-family: gent;
|
||||
src: url(GentiumPlus-R.woff) format("woff");
|
||||
}
|
||||
|
||||
.test {
|
||||
font-family: gent, sans-serif;
|
||||
}
|
||||
80
layout/inspector/tests/chrome/test_bug695639.xul
Normal file
80
layout/inspector/tests/chrome/test_bug695639.xul
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
<?xml-stylesheet type="text/css" href="test_bug695639.css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=695639
|
||||
-->
|
||||
<window title="Mozilla Bug 695639"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="RunTest();">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
/** Test for Bug 695639 - check that GetFontFacesForText handles wrapped lines properly **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function RunTest() {
|
||||
const CI = Components.interfaces;
|
||||
const CC = Components.classes;
|
||||
|
||||
var domUtils =
|
||||
CC["@mozilla.org/inspector/dom-utils;1"].getService(CI.inIDOMUtils);
|
||||
|
||||
var rng = document.createRange();
|
||||
var elem, fonts, f;
|
||||
|
||||
elem = document.getElementById("test").childNodes[0];
|
||||
rng.setStart(elem, 0);
|
||||
rng.setEnd(elem, 14);
|
||||
fonts = domUtils.getUsedFontFaces(rng);
|
||||
is(fonts.length, 2, "number of fonts used for entire text");
|
||||
|
||||
// initial latin substring...
|
||||
rng.setStart(elem, 0);
|
||||
rng.setEnd(elem, 5); // "Hello"
|
||||
fonts = domUtils.getUsedFontFaces(rng);
|
||||
is(fonts.length, 1, "number of fonts (1)");
|
||||
f = fonts.item(0);
|
||||
is(f.name, "Gentium Plus", "font name (1)");
|
||||
|
||||
// the space (where the line wraps) should also be Gentium
|
||||
rng.setStart(elem, 5);
|
||||
rng.setEnd(elem, 6); // space
|
||||
fonts = domUtils.getUsedFontFaces(rng);
|
||||
is(fonts.length, 1, "number of fonts (2)");
|
||||
f = fonts.item(0);
|
||||
is(f.name, "Gentium Plus", "font name (2)");
|
||||
|
||||
// the Chinese text "ni hao" should NOT be in Gentium
|
||||
rng.setStart(elem, 6);
|
||||
rng.setEnd(elem, 8); // two Chinese characters on second line
|
||||
fonts = domUtils.getUsedFontFaces(rng);
|
||||
is(fonts.length, 1, "number of fonts (3)");
|
||||
f = fonts.item(0);
|
||||
isnot(f.name, "Gentium Plus", "font name (3)");
|
||||
|
||||
// space and "world" should be Gentium again
|
||||
rng.setStart(elem, 8);
|
||||
rng.setEnd(elem, 14);
|
||||
fonts = domUtils.getUsedFontFaces(rng);
|
||||
is(fonts.length, 1, "number of fonts (4)");
|
||||
f = fonts.item(0);
|
||||
is(f.name, "Gentium Plus", "font name (4)");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
</style>
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=695639"
|
||||
target="_blank">Mozilla Bug 695639</a>
|
||||
<div style="width: 2em;" class="test" id="test">Hello 你好 world</div>
|
||||
</body>
|
||||
|
||||
</window>
|
||||
33
layout/inspector/tests/chrome/test_bug708874.css
Normal file
33
layout/inspector/tests/chrome/test_bug708874.css
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#test-div {
|
||||
color: rgb(0, 0, 0);
|
||||
font-family: serif;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
#test-div:hover {
|
||||
color: rgb(10, 0, 0);
|
||||
}
|
||||
|
||||
#test-div:active {
|
||||
font-family: Arial;
|
||||
}
|
||||
|
||||
#test-div:focus {
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
#test-button {
|
||||
color: rgb(0, 0, 0);
|
||||
}
|
||||
|
||||
#test-button:disabled {
|
||||
color: rgb(40, 0, 0);
|
||||
}
|
||||
|
||||
#test-link:visited {
|
||||
color: rgb(20, 0, 0);
|
||||
}
|
||||
|
||||
#test-link:link {
|
||||
color: rgb(30, 0, 0);
|
||||
}
|
||||
296
layout/inspector/tests/chrome/test_bug708874.xul
Normal file
296
layout/inspector/tests/chrome/test_bug708874.xul
Normal file
|
|
@ -0,0 +1,296 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
<?xml-stylesheet type="text/css" href="test_bug708874.css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=708874
|
||||
-->
|
||||
<window title="Mozilla Bug 708874"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="RunTests();">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
/** Test for Bug 708874 - API for locking pseudo-class state of an element **/
|
||||
|
||||
var DOMUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(Components.interfaces.inIDOMUtils);
|
||||
var DOMWindowUtils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
var defaultColor = "rgb(0, 0, 0)";
|
||||
var disabledColor = "rgb(40, 0, 0)";
|
||||
|
||||
function RunTests() {
|
||||
testLockEnabled();
|
||||
testLockDisabled();
|
||||
testVisited();
|
||||
testMultiple();
|
||||
testInvalid();
|
||||
testNotElement();
|
||||
}
|
||||
|
||||
function testLockEnabled() {
|
||||
var button = document.getElementById("test-button");
|
||||
|
||||
/* starting state is enabled */
|
||||
button.removeAttribute("disabled");
|
||||
|
||||
is(DOMUtils.hasPseudoClassLock(button, ":disabled"), false,
|
||||
"doesn't have lock at start");
|
||||
|
||||
is(window.getComputedStyle(button).color, defaultColor,
|
||||
"color is default color before locking on");
|
||||
|
||||
is(button.matches(":disabled"), false,
|
||||
"doesn't match selector at start");
|
||||
|
||||
/* lock */
|
||||
DOMUtils.addPseudoClassLock(button, ":disabled");
|
||||
|
||||
is(DOMUtils.hasPseudoClassLock(button, ":disabled"), true,
|
||||
"hasPseudoClassLock is true after locking");
|
||||
|
||||
is(window.getComputedStyle(button).color, disabledColor,
|
||||
":disabled style applied after adding lock");
|
||||
|
||||
is(button.matches(":disabled"), true,
|
||||
"matches selector after adding lock");
|
||||
|
||||
/* change state to disabled */
|
||||
button.setAttribute("disabled", "disabled");
|
||||
|
||||
is(window.getComputedStyle(button).color, disabledColor,
|
||||
":disabled style still applied after really disabling");
|
||||
|
||||
is(button.matches(":disabled"), true,
|
||||
"matches selector after adding lock");
|
||||
|
||||
/* remove lock */
|
||||
DOMUtils.removePseudoClassLock(button, ":disabled");
|
||||
|
||||
is(DOMUtils.hasPseudoClassLock(button, ":disabled"), false,
|
||||
"hasPseudoClassLock is false after removing on lock");
|
||||
|
||||
is(window.getComputedStyle(button).color, disabledColor,
|
||||
":disabled style still applied after removing lock");
|
||||
|
||||
is(button.matches(":disabled"), true,
|
||||
"matches selector after removing lock");
|
||||
|
||||
/* change state to enabled */
|
||||
button.removeAttribute("disabled");
|
||||
|
||||
is(window.getComputedStyle(button).color, defaultColor,
|
||||
"back to default style after un-disabling");
|
||||
|
||||
is(button.matches(":disabled"), false,
|
||||
"doesn't match selector after enabling");
|
||||
}
|
||||
|
||||
|
||||
function testLockDisabled() {
|
||||
var button = document.getElementById("test-button");
|
||||
|
||||
/* starting state is disabled */
|
||||
button.setAttribute("disabled", "disabled");
|
||||
|
||||
is(DOMUtils.hasPseudoClassLock(button, ":disabled"), false,
|
||||
"doesn't have lock at start");
|
||||
|
||||
is(window.getComputedStyle(button).color, disabledColor,
|
||||
"color is :disabled color before locking");
|
||||
|
||||
is(button.matches(":disabled"), true,
|
||||
"matches selector before locking");
|
||||
|
||||
/* lock */
|
||||
DOMUtils.addPseudoClassLock(button, ":disabled");
|
||||
|
||||
is(DOMUtils.hasPseudoClassLock(button, ":disabled"), true,
|
||||
"hasPseudoClassLock is true after locking");
|
||||
|
||||
is(window.getComputedStyle(button).color, disabledColor,
|
||||
":disabled style still applied after adding on lock");
|
||||
|
||||
is(button.matches(":disabled"), true,
|
||||
"matches selector after locking");
|
||||
|
||||
/* change state to enabled */
|
||||
button.removeAttribute("disabled");
|
||||
|
||||
is(window.getComputedStyle(button).color, disabledColor,
|
||||
":disabled style applied after enabling");
|
||||
|
||||
is(button.matches(":disabled"), true,
|
||||
"matches selector after enabling with lock on");
|
||||
|
||||
/* remove lock */
|
||||
DOMUtils.removePseudoClassLock(button, ":disabled");
|
||||
|
||||
is(DOMUtils.hasPseudoClassLock(button, ":disabled"), false,
|
||||
"hasPseudoClassLock is false after removing on lock");
|
||||
|
||||
is(window.getComputedStyle(button).color, defaultColor,
|
||||
"default style applied after removing lock");
|
||||
|
||||
is(button.matches(":disabled"), false,
|
||||
"doesn't match selector after unlocking");
|
||||
|
||||
/* change state to disabled */
|
||||
button.setAttribute("disabled", "disabled");
|
||||
|
||||
is(window.getComputedStyle(button).color, disabledColor,
|
||||
":disabled style applied after disabling after unlocking");
|
||||
|
||||
is(button.matches(":disabled"), true,
|
||||
"matches selector again after disabling");
|
||||
}
|
||||
|
||||
function testVisited() {
|
||||
var link = document.getElementById("test-link");
|
||||
var visitedColor = "rgb(20, 0, 0)";
|
||||
var unvisitedColor = "rgb(30, 0, 0)";
|
||||
|
||||
/* lock visited */
|
||||
DOMUtils.addPseudoClassLock(link, ":visited");
|
||||
|
||||
is(DOMUtils.hasPseudoClassLock(link, ":visited"), true,
|
||||
"hasPseudoClassLock is true after adding lock");
|
||||
|
||||
var color = DOMWindowUtils.getVisitedDependentComputedStyle(link,
|
||||
null, "color");
|
||||
is(color, visitedColor, "color is :visited color after locking");
|
||||
|
||||
/* lock unvisited */
|
||||
DOMUtils.addPseudoClassLock(link, ":link");
|
||||
|
||||
is(DOMUtils.hasPseudoClassLock(link, ":link"), true,
|
||||
"hasPseudoClassLock is true after adding :link lock");
|
||||
|
||||
is(DOMUtils.hasPseudoClassLock(link, ":visited"), false,
|
||||
"hasPseudoClassLock is false for :visited after adding :link lock");
|
||||
|
||||
var color = DOMWindowUtils.getVisitedDependentComputedStyle(link,
|
||||
null, "color");
|
||||
is(color, unvisitedColor, "color is :link color after locking :link");
|
||||
|
||||
/* lock visited back on */
|
||||
DOMUtils.addPseudoClassLock(link, ":visited");
|
||||
|
||||
is(DOMUtils.hasPseudoClassLock(link, ":visited"), true,
|
||||
"hasPseudoClassLock is true after adding :visited lock");
|
||||
|
||||
is(DOMUtils.hasPseudoClassLock(link, ":link"), false,
|
||||
"hasPseudoClassLock is false for :link after adding :visited lock");
|
||||
|
||||
var color = DOMWindowUtils.getVisitedDependentComputedStyle(link,
|
||||
null, "color");
|
||||
is(color, visitedColor, "color is :visited color after locking back on");
|
||||
}
|
||||
|
||||
function testMultiple() {
|
||||
var div = document.getElementById("test-div");
|
||||
|
||||
var styles = {
|
||||
":hover": {
|
||||
property: "color",
|
||||
value: "rgb(10, 0, 0)",
|
||||
defaultValue: "rgb(0, 0, 0)"
|
||||
},
|
||||
":active": {
|
||||
property: "font-family",
|
||||
value: "Arial",
|
||||
defaultValue: "serif"
|
||||
},
|
||||
":focus": {
|
||||
property: "font-weight",
|
||||
value: "800",
|
||||
defaultValue: "400"
|
||||
}
|
||||
};
|
||||
|
||||
for (var pseudo in styles) {
|
||||
DOMUtils.addPseudoClassLock(div, pseudo);
|
||||
}
|
||||
|
||||
for (var pseudo in styles) {
|
||||
is(DOMUtils.hasPseudoClassLock(div, pseudo), true,
|
||||
"hasPseudoClassLock is true after locking");
|
||||
|
||||
var style = styles[pseudo];
|
||||
is(window.getComputedStyle(div).getPropertyValue(style.property),
|
||||
style.value, "style for pseudo-class is applied after locking");
|
||||
|
||||
is(div.matches(pseudo), true,
|
||||
"matches selector after locking");
|
||||
}
|
||||
|
||||
DOMUtils.clearPseudoClassLocks(div);
|
||||
|
||||
for (var pseudo in styles) {
|
||||
is(DOMUtils.hasPseudoClassLock(div, pseudo), false,
|
||||
"hasPseudoClassLock is false after clearing");
|
||||
|
||||
is(window.getComputedStyle(div).getPropertyValue(style.property),
|
||||
style.defaultValue, "style is back to default after clearing");
|
||||
|
||||
is(div.matches(pseudo), false,
|
||||
"doesn't match selector after unlocking");
|
||||
}
|
||||
}
|
||||
|
||||
function testInvalid() {
|
||||
var div = document.getElementById("test-div");
|
||||
var pseudos = ["not a valid pseudo-class", ":ny-link", ":first-child"];
|
||||
|
||||
for (var i = 0; i < pseudos.length; i++) {
|
||||
var pseudo = pseudos[i];
|
||||
|
||||
// basically make sure these don't crash the browser.
|
||||
DOMUtils.addPseudoClassLock(div, pseudo);
|
||||
|
||||
is(DOMUtils.hasPseudoClassLock(div, pseudo), false);
|
||||
|
||||
DOMUtils.removePseudoClassLock(div, pseudo);
|
||||
}
|
||||
}
|
||||
|
||||
function testNotElement() {
|
||||
for (var value of [null, undefined, {}]) {
|
||||
SimpleTest.doesThrow(() => DOMUtils.hasPseudoClassLock(value, ":hover"),
|
||||
"hasPseudoClassLock should throw for " + value);
|
||||
SimpleTest.doesThrow(() => DOMUtils.addPseudoClassLock(value, ":hover"),
|
||||
"addPseudoClassLock should throw for " + value);
|
||||
SimpleTest.doesThrow(() => DOMUtils.removePseudoClassLock(value, ":hover"),
|
||||
"removePseudoClassLock should throw for " + value);
|
||||
SimpleTest.doesThrow(() => DOMUtils.clearPseudoClassLocks(value),
|
||||
"clearPseudoClassLocks should throw for " + value);
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=708874"
|
||||
target="_blank">Mozilla Bug 708874</a>
|
||||
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=708874">
|
||||
Mozilla Bug 708874 - API for locking pseudo-class state of an element
|
||||
</a>
|
||||
|
||||
<a id="test-link" href="http://notavisitedwebsite.com">
|
||||
test link
|
||||
</a>
|
||||
|
||||
<div id="test-div">
|
||||
test div
|
||||
</div>
|
||||
|
||||
<button id="test-button">
|
||||
test button
|
||||
</button>
|
||||
</body>
|
||||
|
||||
</window>
|
||||
7
layout/inspector/tests/chrome/test_bug727834.css
Normal file
7
layout/inspector/tests/chrome/test_bug727834.css
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
body {
|
||||
padding-top: 100px;
|
||||
}
|
||||
88
layout/inspector/tests/chrome/test_bug727834.xul
Normal file
88
layout/inspector/tests/chrome/test_bug727834.xul
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
vim: set ts=2 et sw=2 tw=80:
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
<?xml-stylesheet type="text/css" href="test_bug727834.css"?>
|
||||
<window title="Mozilla Bug 727834"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="RunTests();">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript"><![CDATA[
|
||||
/** Test for Bug 727834 - Add an API to (re)parse a style sheet in place **/
|
||||
|
||||
function RunTests() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
let DOMUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(Components.interfaces.inIDOMUtils);
|
||||
let body = document.querySelector("body");
|
||||
let testSheet = document.styleSheets[2];
|
||||
let rule = document.styleSheets[2].cssRules[0];
|
||||
|
||||
is(testSheet.cssRules.length, 1,
|
||||
"style sheet has 1 rule");
|
||||
is(rule.style.paddingTop, "100px",
|
||||
"original first rule has padding-top 100px");
|
||||
is(window.getComputedStyle(body).paddingTop, "100px",
|
||||
"original first rule applies");
|
||||
|
||||
DOMUtils.parseStyleSheet(testSheet,
|
||||
"@import url(test_bug727834.css); body{background: red;}");
|
||||
|
||||
is(testSheet.cssRules.length, 2,
|
||||
"style sheet now has 2 rules");
|
||||
is(window.getComputedStyle(body).backgroundColor, "rgb(255, 0, 0)",
|
||||
"background is now red");
|
||||
|
||||
let exceptionName;
|
||||
try {
|
||||
rule.style.paddingLeft = "100px";
|
||||
} catch (ex) {
|
||||
exceptionName = ex.name;
|
||||
} finally {
|
||||
is(exceptionName, "NS_ERROR_NOT_AVAILABLE",
|
||||
"original rule is not available for modification anymore");
|
||||
}
|
||||
is(window.getComputedStyle(body).paddingLeft, "0px",
|
||||
"original rule does not apply to document");
|
||||
|
||||
rule = testSheet.cssRules[0];
|
||||
|
||||
is(rule.parentStyleSheet, testSheet,
|
||||
"rule's parent style sheet is not null");
|
||||
|
||||
DOMUtils.parseStyleSheet(testSheet,
|
||||
"body{background: lime;}");
|
||||
|
||||
is(testSheet.cssRules.length, 1,
|
||||
"style sheet now has 1 rule");
|
||||
is(window.getComputedStyle(body).backgroundColor, "rgb(0, 255, 0)",
|
||||
"background is now lime");
|
||||
is(rule.parentStyleSheet, null,
|
||||
"detached rule's parent style sheet is null");
|
||||
|
||||
SimpleTest.executeSoon(function () {
|
||||
DOMUtils.parseStyleSheet(testSheet,
|
||||
"@import url(test_bug727834.css); body{background: blue;}");
|
||||
|
||||
is(testSheet.cssRules.length, 2,
|
||||
"style sheet now has 2 rules");
|
||||
is(window.getComputedStyle(body).backgroundColor, "rgb(0, 0, 255)",
|
||||
"background is now blue");
|
||||
is(testSheet.cssRules[0].parentStyleSheet, testSheet,
|
||||
"parent style sheet is the test sheet");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
]]></script>
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=727834">
|
||||
Mozilla Bug 727834 - Add an API to (re)parse a style sheet in place
|
||||
</a>
|
||||
</body>
|
||||
</window>
|
||||
17
layout/inspector/tests/file_bug522601.html
Normal file
17
layout/inspector/tests/file_bug522601.html
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=522601
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 522601</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="some content">
|
||||
<h1>Blah</h1>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
29
layout/inspector/tests/mochitest.ini
Normal file
29
layout/inspector/tests/mochitest.ini
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
[DEFAULT]
|
||||
support-files =
|
||||
bug1202095.css
|
||||
bug1202095-2.css
|
||||
bug856317.css
|
||||
file_bug522601.html
|
||||
|
||||
[test_bug462787.html]
|
||||
[test_bug462789.html]
|
||||
[test_bug522601.xhtml]
|
||||
[test_bug536379.html]
|
||||
[test_bug536379-2.html]
|
||||
[test_bug557726.html]
|
||||
[test_bug609549.xhtml]
|
||||
[test_bug806192.html]
|
||||
[test_bug856317.html]
|
||||
[test_bug877690.html]
|
||||
[test_bug1006595.html]
|
||||
[test_color_to_rgba.html]
|
||||
[test_css_property_is_shorthand.html]
|
||||
[test_css_property_is_valid.html]
|
||||
[test_getCSSPseudoElementNames.html]
|
||||
[test_getRelativeRuleLine.html]
|
||||
[test_get_all_style_sheets.html]
|
||||
[test_is_valid_css_color.html]
|
||||
[test_isinheritableproperty.html]
|
||||
[test_parseStyleSheet.html]
|
||||
[test_parseStyleSheetImport.html]
|
||||
[test_selectormatcheselement.html]
|
||||
118
layout/inspector/tests/test_bug1006595.html
Normal file
118
layout/inspector/tests/test_bug1006595.html
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1006595
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1006595</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 1006595 **/
|
||||
function arraysEqual(arr1, arr2, message) {
|
||||
is(arr1.length, arr2.length, message + " length");
|
||||
for (var i = 0; i < arr1.length; ++i) {
|
||||
is(arr1[i], arr2[i], message + " element at index " + i);
|
||||
}
|
||||
}
|
||||
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
var paddingSubProps = utils.getSubpropertiesForCSSProperty("padding");
|
||||
arraysEqual(paddingSubProps,
|
||||
[ "padding-top",
|
||||
"padding-right",
|
||||
"padding-bottom",
|
||||
"padding-left" ],
|
||||
"'padding' subproperties");
|
||||
|
||||
var displaySubProps = utils.getSubpropertiesForCSSProperty("color");
|
||||
arraysEqual(displaySubProps, [ "color" ],
|
||||
"'color' subproperties");
|
||||
|
||||
var varProps = utils.getSubpropertiesForCSSProperty("--foo");
|
||||
arraysEqual(varProps, ["--foo"], "'--foo' subproperties");
|
||||
|
||||
ok(utils.cssPropertyIsShorthand("padding"), "'padding' is a shorthand")
|
||||
ok(!utils.cssPropertyIsShorthand("color"), "'color' is not a shorthand")
|
||||
|
||||
ok(utils.cssPropertySupportsType("padding", utils.TYPE_LENGTH),
|
||||
"'padding' can be a length");
|
||||
ok(!utils.cssPropertySupportsType("padding", utils.TYPE_COLOR),
|
||||
"'padding' can't be a color");
|
||||
|
||||
ok(utils.cssPropertySupportsType("padding", utils.TYPE_PERCENTAGE),
|
||||
"'padding' can be a percentage");
|
||||
ok(!utils.cssPropertySupportsType("color", utils.TYPE_PERCENTAGE),
|
||||
"'color' can't be a percentage");
|
||||
|
||||
ok(utils.cssPropertySupportsType("color", utils.TYPE_COLOR),
|
||||
"'color' can be a color");
|
||||
ok(utils.cssPropertySupportsType("background", utils.TYPE_COLOR),
|
||||
"'background' can be a color");
|
||||
ok(!utils.cssPropertySupportsType("background-image", utils.TYPE_COLOR),
|
||||
"'background-image' can't be a color");
|
||||
|
||||
ok(utils.cssPropertySupportsType("background-image", utils.TYPE_URL),
|
||||
"'background-image' can be a URL");
|
||||
ok(utils.cssPropertySupportsType("background", utils.TYPE_URL),
|
||||
"'background' can be a URL");
|
||||
ok(!utils.cssPropertySupportsType("background-color", utils.TYPE_URL),
|
||||
"'background-color' can't be a URL");
|
||||
|
||||
// There are no properties claiming to be of TYPE_ANGLE. image-orientation
|
||||
// would be, but it doesn't use table-driven parsing.
|
||||
|
||||
// There are no properties claiming to be of TYPE_FREQUENCY
|
||||
|
||||
ok(utils.cssPropertySupportsType("transition", utils.TYPE_TIME),
|
||||
"'transition' can be a time");
|
||||
ok(utils.cssPropertySupportsType("transition-duration", utils.TYPE_TIME),
|
||||
"'transition-duration' can be a time");
|
||||
ok(!utils.cssPropertySupportsType("background-color", utils.TYPE_TIME),
|
||||
"'background-color' can't be a time");
|
||||
|
||||
ok(utils.cssPropertySupportsType("background-image", utils.TYPE_GRADIENT),
|
||||
"'background-image' can be a gradient");
|
||||
ok(utils.cssPropertySupportsType("background", utils.TYPE_GRADIENT),
|
||||
"'background' can be a gradient");
|
||||
ok(!utils.cssPropertySupportsType("background-color", utils.TYPE_GRADIENT),
|
||||
"'background-color' can't be a gradient");
|
||||
|
||||
ok(utils.cssPropertySupportsType("transition", utils.TYPE_TIMING_FUNCTION),
|
||||
"'transition' can be a timing function");
|
||||
ok(utils.cssPropertySupportsType("transition-timing-function",
|
||||
utils.TYPE_TIMING_FUNCTION),
|
||||
"'transition-duration' can be a timing function");
|
||||
ok(!utils.cssPropertySupportsType("background-color",
|
||||
utils.TYPE_TIMING_FUNCTION),
|
||||
"'background-color' can't be a timing function");
|
||||
|
||||
ok(utils.cssPropertySupportsType("background-image", utils.TYPE_IMAGE_RECT),
|
||||
"'background-image' can be an image rect");
|
||||
ok(utils.cssPropertySupportsType("background", utils.TYPE_IMAGE_RECT),
|
||||
"'background' can be an image rect");
|
||||
ok(!utils.cssPropertySupportsType("background-color", utils.TYPE_IMAGE_RECT),
|
||||
"'background-color' can't be an image rect");
|
||||
|
||||
ok(utils.cssPropertySupportsType("z-index", utils.TYPE_NUMBER),
|
||||
"'z-index' can be a number");
|
||||
ok(utils.cssPropertySupportsType("line-height", utils.TYPE_NUMBER),
|
||||
"'line-height' can be a number");
|
||||
ok(!utils.cssPropertySupportsType("background-color", utils.TYPE_NUMBER),
|
||||
"'background-color' can't be a number");
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1006595">Mozilla Bug 1006595</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
100
layout/inspector/tests/test_bug462787.html
Normal file
100
layout/inspector/tests/test_bug462787.html
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=462787
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 462787</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=462787">Mozilla Bug 462787</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 462787 **/
|
||||
|
||||
function do_test() {
|
||||
const INVALID_POINTER = SpecialPowers.Cr.NS_ERROR_INVALID_POINTER;
|
||||
|
||||
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
try {
|
||||
utils.getCSSStyleRules(null);
|
||||
ok(false, "expected an exception");
|
||||
}
|
||||
catch(e) {
|
||||
e = SpecialPowers.wrap(e);
|
||||
is(e.result, INVALID_POINTER, "got the expected exception");
|
||||
}
|
||||
|
||||
try {
|
||||
utils.getRuleLine(null);
|
||||
ok(false, "expected an exception");
|
||||
}
|
||||
catch(e) {
|
||||
e = SpecialPowers.wrap(e);
|
||||
is(e.result, INVALID_POINTER, "got the expected exception");
|
||||
}
|
||||
|
||||
try {
|
||||
utils.isIgnorableWhitespace(null);
|
||||
ok(false, "expected an exception");
|
||||
}
|
||||
catch(e) {
|
||||
e = SpecialPowers.wrap(e);
|
||||
is(e.result, INVALID_POINTER, "got the expected exception");
|
||||
}
|
||||
|
||||
try {
|
||||
utils.getParentForNode(null, true);
|
||||
ok(false, "expected an exception");
|
||||
}
|
||||
catch(e) {
|
||||
e = SpecialPowers.wrap(e);
|
||||
is(e.result, INVALID_POINTER, "got the expected exception");
|
||||
}
|
||||
|
||||
try {
|
||||
utils.getBindingURLs(null);
|
||||
ok(false, "expected an exception");
|
||||
}
|
||||
catch(e) {
|
||||
e = SpecialPowers.wrap(e);
|
||||
is(e.result, INVALID_POINTER, "got the expected exception");
|
||||
}
|
||||
|
||||
try {
|
||||
utils.getContentState(null);
|
||||
ok(false, "expected an exception");
|
||||
}
|
||||
catch(e) {
|
||||
e = SpecialPowers.wrap(e);
|
||||
is(e.result, INVALID_POINTER, "got the expected exception");
|
||||
}
|
||||
|
||||
try {
|
||||
utils.setContentState(null, false);
|
||||
ok(false, "expected an exception");
|
||||
}
|
||||
catch(e) {
|
||||
e = SpecialPowers.wrap(e);
|
||||
is(e.result, INVALID_POINTER, "got the expected exception");
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(do_test);
|
||||
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
94
layout/inspector/tests/test_bug462789.html
Normal file
94
layout/inspector/tests/test_bug462789.html
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=462789
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 462789</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=462789">Mozilla Bug 462789</a>
|
||||
<p id="display"><iframe id="bug462789_iframe" src="data:text/html,<html><head><style>*{color:black;}</style></head><body>xxx" style="display: none;"></iframe></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 462789 **/
|
||||
|
||||
function do_test() {
|
||||
const ERROR_INVALID_ARG = 0x80070057;
|
||||
const DOCUMENT_NODE_TYPE = 9;
|
||||
|
||||
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
var iframe = document.getElementById("bug462789_iframe");
|
||||
var docElement = iframe.contentDocument.documentElement;
|
||||
var body = docElement.children[1];
|
||||
var rule = iframe.contentDocument.styleSheets[0].cssRules[0];
|
||||
var text = body.firstChild;
|
||||
|
||||
try {
|
||||
var res = utils.getCSSStyleRules(docElement);
|
||||
is(res, null, "getCSSStyleRules");
|
||||
res = utils.getCSSStyleRules(body);
|
||||
is(res, null, "getCSSStyleRules");
|
||||
}
|
||||
catch(e) { ok(false, "got an unexpected exception:" + e); }
|
||||
|
||||
try {
|
||||
var res = utils.getRuleLine(rule);
|
||||
is(res, 1, "getRuleLine");
|
||||
}
|
||||
catch(e) { ok(false, "got an unexpected exception:" + e); }
|
||||
|
||||
try {
|
||||
var res = utils.isIgnorableWhitespace(text);
|
||||
is(res, false, "isIgnorableWhitespace");
|
||||
}
|
||||
catch(e) { ok(false, "got an unexpected exception:" + e); }
|
||||
|
||||
try {
|
||||
var res = utils.getParentForNode(docElement, true);
|
||||
is(res.nodeType, DOCUMENT_NODE_TYPE, "getParentForNode(docElement, true)");
|
||||
res = utils.getParentForNode(text, true);
|
||||
is(res.tagName, "BODY", "getParentForNode(text, true)");
|
||||
}
|
||||
catch(e) { ok(false, "got an unexpected exception:" + e); }
|
||||
|
||||
try {
|
||||
var res = utils.getBindingURLs(docElement);
|
||||
ok(SpecialPowers.call_Instanceof(res, SpecialPowers.Ci["nsIArray"]), "getBindingURLs result type");
|
||||
is(res.length, 0, "getBindingURLs array length");
|
||||
}
|
||||
catch(e) { ok(false, "got an unexpected exception:" + e); }
|
||||
|
||||
try {
|
||||
utils.getContentState(docElement);
|
||||
ok(true, "Should not throw");
|
||||
}
|
||||
catch(e) { ok(false, "Got an exception: " + e); }
|
||||
|
||||
try {
|
||||
utils.setContentState(docElement, false);
|
||||
ok(false, "expected an exception");
|
||||
}
|
||||
catch(e) {
|
||||
e = SpecialPowers.wrap(e);
|
||||
is(e.result, ERROR_INVALID_ARG, "got the expected exception");
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(do_test);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
274
layout/inspector/tests/test_bug522601.xhtml
Normal file
274
layout/inspector/tests/test_bug522601.xhtml
Normal file
|
|
@ -0,0 +1,274 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=522601
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 522601</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
|
||||
<bindings xmlns="http://www.mozilla.org/xbl">
|
||||
<binding id="testBinding">
|
||||
<content><div><children/></div><children includes="span"/></content>
|
||||
</binding>
|
||||
</bindings>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=522601">Mozilla Bug 522601</a>
|
||||
<p id="display" style="-moz-binding: url(#testBinding)">
|
||||
<span id="s">This is some text</span>
|
||||
More text
|
||||
<b id="b">Even more <i id="i1">Italic</i>text<i id="i2">And more italic</i></b></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<div id="subdoc">
|
||||
<iframe id="frame1" src="file_bug522601.html">frame text</iframe>
|
||||
</div>
|
||||
<div id="test-shadow">
|
||||
<h2 id="h2">light child</h2>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
/** Test for Bug 522601 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function testFunc(walker, func, expectedNode, str) {
|
||||
var oldCurrent = SpecialPowers.unwrap(walker.currentNode);
|
||||
var newNode = SpecialPowers.unwrap(walker[func]());
|
||||
is(newNode, expectedNode, "Unexpected node after " + str);
|
||||
is(SpecialPowers.unwrap(walker.currentNode), newNode ? newNode : oldCurrent,
|
||||
"Unexpected current node after " + str);
|
||||
}
|
||||
|
||||
addLoadEvent(function() {
|
||||
var walkerSubDocument =
|
||||
SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"]
|
||||
.createInstance(SpecialPowers.Ci.inIDeepTreeWalker);
|
||||
walkerSubDocument.showAnonymousContent = false;
|
||||
walkerSubDocument.showSubDocuments = true;
|
||||
walkerSubDocument.init($("frame1"), NodeFilter.SHOW_ALL);
|
||||
|
||||
is(SpecialPowers.unwrap(walkerSubDocument.currentNode), $("frame1"), "Unexpected sub-doc root");
|
||||
testFunc(walkerSubDocument, "firstChild", $("frame1").contentDocument.doctype,
|
||||
"step to sub documents doctype");
|
||||
testFunc(walkerSubDocument, "nextSibling", $("frame1").contentDocument.documentElement,
|
||||
"step to sub documents documentElement");
|
||||
|
||||
walkerSubDocument =
|
||||
SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"]
|
||||
.createInstance(SpecialPowers.Ci.inIDeepTreeWalker);
|
||||
walkerSubDocument.showAnonymousContent = false;
|
||||
walkerSubDocument.showSubDocuments = true;
|
||||
walkerSubDocument.showDocumentsAsNodes = true;
|
||||
walkerSubDocument.init($("frame1"), NodeFilter.SHOW_ALL);
|
||||
|
||||
is(SpecialPowers.unwrap(walkerSubDocument.currentNode), $("frame1"), "Unexpected sub-doc root");
|
||||
testFunc(walkerSubDocument, "firstChild", $("frame1").contentDocument,
|
||||
"step to sub document");
|
||||
testFunc(walkerSubDocument, "firstChild", $("frame1").contentDocument.doctype,
|
||||
"step to sub documents doctype");
|
||||
testFunc(walkerSubDocument, "nextSibling", $("frame1").contentDocument.documentElement,
|
||||
"step to sub documents documentElement");
|
||||
|
||||
walkerSubDocument.currentNode = $("frame1").contentDocument;
|
||||
is(SpecialPowers.unwrap(walkerSubDocument.currentNode), $("frame1").contentDocument,
|
||||
"setting currentNode to sub document");
|
||||
testFunc(walkerSubDocument, "nextSibling", null,
|
||||
"nextSibling for sub document is null");
|
||||
|
||||
var walkerFrameChild =
|
||||
SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"]
|
||||
.createInstance(SpecialPowers.Ci.inIDeepTreeWalker);
|
||||
walkerFrameChild.showAnonymousContent = false;
|
||||
walkerFrameChild.showSubDocuments = false;
|
||||
walkerFrameChild.init($("frame1"), NodeFilter.SHOW_ALL);
|
||||
|
||||
is(SpecialPowers.unwrap(walkerFrameChild.currentNode), $("frame1"), "Unexpected sub-doc root");
|
||||
testFunc(walkerFrameChild, "firstChild", $("frame1").firstChild,
|
||||
"step to frames child");
|
||||
|
||||
var walkerNonAnon =
|
||||
SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"]
|
||||
.createInstance(SpecialPowers.Ci.inIDeepTreeWalker);
|
||||
walkerNonAnon.init($("display"), NodeFilter.SHOW_ALL);
|
||||
walkerNonAnon.showAnonymousContent = false;
|
||||
|
||||
is(SpecialPowers.unwrap(walkerNonAnon.currentNode), $("display"), "Unexpected non-anon root");
|
||||
testFunc(walkerNonAnon, "nextNode", $("s").previousSibling,
|
||||
"step to some text");
|
||||
testFunc(walkerNonAnon, "nextNode", $("s"), "step to span");
|
||||
testFunc(walkerNonAnon, "nextNode", $("s").firstChild, "step to span text");
|
||||
testFunc(walkerNonAnon, "nextNode", $("s").nextSibling, "step to more text");
|
||||
testFunc(walkerNonAnon, "nextNode", $("b"), "step to bold");
|
||||
testFunc(walkerNonAnon, "nextNode", $("b").firstChild, "step to bold text");
|
||||
testFunc(walkerNonAnon, "nextNode", $("i1"), "step to first italic");
|
||||
testFunc(walkerNonAnon, "nextNode", $("i1").firstChild,
|
||||
"step to first italic text");
|
||||
testFunc(walkerNonAnon, "nextNode", $("i1").nextSibling,
|
||||
"step to more bold text");
|
||||
testFunc(walkerNonAnon, "nextNode", $("i2"), "step to second italic");
|
||||
testFunc(walkerNonAnon, "nextNode", $("i2").firstChild,
|
||||
"step to second italic text");
|
||||
testFunc(walkerNonAnon, "nextNode", null, "step past end");
|
||||
testFunc(walkerNonAnon, "parentNode", $("i2"), "step up to second italic");
|
||||
testFunc(walkerNonAnon, "parentNode", $("b"), "step up to bold");
|
||||
testFunc(walkerNonAnon, "nextNode", $("b").firstChild, "step to bold text again");
|
||||
testFunc(walkerNonAnon, "parentNode", $("b"), "step up to bold again");
|
||||
testFunc(walkerNonAnon, "parentNode", $("display"), "step up to display");
|
||||
testFunc(walkerNonAnon, "parentNode", null, "step up past root");
|
||||
testFunc(walkerNonAnon, "firstChild", $("s").previousSibling,
|
||||
"step firstChild to display first child");
|
||||
testFunc(walkerNonAnon, "nextSibling", $("s"),
|
||||
"step nextSibling to span");
|
||||
testFunc(walkerNonAnon, "nextSibling", $("s").nextSibling,
|
||||
"step nextSibling to more text");
|
||||
testFunc(walkerNonAnon, "nextSibling", $("b"), "step nextSibling to bold");
|
||||
testFunc(walkerNonAnon, "nextSibling", null, "step nextSibling past end");
|
||||
testFunc(walkerNonAnon, "previousSibling", $("s").nextSibling,
|
||||
"step previousSibling to more text");
|
||||
testFunc(walkerNonAnon, "previousSibling", $("s"),
|
||||
"step previousSibling to span");
|
||||
testFunc(walkerNonAnon, "previousSibling", $("s").previousSibling,
|
||||
"step previousSibling to display first child");
|
||||
testFunc(walkerNonAnon, "previousSibling", null,
|
||||
"step previousSibling past end");
|
||||
|
||||
// Move the walker over to the end
|
||||
while (walkerNonAnon.nextNode()) { /* do nothing */ }
|
||||
is(SpecialPowers.unwrap(walkerNonAnon.currentNode), $("i2").firstChild, "unexpected last node");
|
||||
testFunc(walkerNonAnon, "previousNode", $("i2"), "step back to second italic");
|
||||
testFunc(walkerNonAnon, "previousNode", $("i1").nextSibling,
|
||||
"step back to more bold text");
|
||||
testFunc(walkerNonAnon, "previousNode", $("i1").firstChild,
|
||||
"step back to first italic text");
|
||||
testFunc(walkerNonAnon, "previousNode", $("i1"), "step back to first italic");
|
||||
testFunc(walkerNonAnon, "previousNode", $("b").firstChild,
|
||||
"step back to bold text");
|
||||
testFunc(walkerNonAnon, "previousNode", $("b"), "step back to bold");
|
||||
testFunc(walkerNonAnon, "previousNode", $("s").nextSibling, "step back to more text");
|
||||
testFunc(walkerNonAnon, "previousNode", $("s").firstChild, "step back to span text");
|
||||
testFunc(walkerNonAnon, "previousNode", $("s"), "step back to span");
|
||||
testFunc(walkerNonAnon, "previousNode", $("s").previousSibling,
|
||||
"step back to some text");
|
||||
testFunc(walkerNonAnon, "previousNode", $("display"),
|
||||
"step back to root");
|
||||
testFunc(walkerNonAnon, "previousNode", null,
|
||||
"step back past root");
|
||||
|
||||
walkerNonAnon.currentNode = $("s");
|
||||
is(SpecialPowers.unwrap(walkerNonAnon.currentNode), SpecialPowers.unwrap($("s")),
|
||||
"Setting currentNode to span");
|
||||
|
||||
var anonDiv = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes($("display")))[0];
|
||||
|
||||
try {
|
||||
walkerNonAnon.currentNode = anonDiv;
|
||||
ok(false, "Setting current node to a node that is otherwise unreachable," +
|
||||
" with the current visibility settings should throw");
|
||||
} catch(e) {
|
||||
ok(e.toString().indexOf("NS_ERROR_ILLEGAL_VALUE") > -1, "Setting current node to an anon node should throw" +
|
||||
" NS_ERROR_ILLEGAL_VALUE if showAnonymousContent is set to false");
|
||||
is(SpecialPowers.unwrap(walkerNonAnon.currentNode), SpecialPowers.unwrap($("s")),
|
||||
"An unsuccessfull set currentNode should leave behind the old state");
|
||||
testFunc(walkerNonAnon, "nextSibling", $("s").nextSibling, "nextSibling after set currentNode");
|
||||
}
|
||||
|
||||
var walkerAnon =
|
||||
SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"]
|
||||
.createInstance(SpecialPowers.Ci.inIDeepTreeWalker);
|
||||
walkerAnon.showAnonymousContent = true;
|
||||
walkerAnon.init($("display"), NodeFilter.SHOW_ALL);
|
||||
|
||||
is(SpecialPowers.unwrap(walkerAnon.currentNode), $("display"), "Unexpected anon root");
|
||||
testFunc(walkerAnon, "nextNode", anonDiv,
|
||||
"step to anonymous div");
|
||||
testFunc(walkerAnon, "nextNode", $("s").previousSibling,
|
||||
"step to some text (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("s").nextSibling, "step to more text (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("b"), "step to bold (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("b").firstChild, "step to bold text (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("i1"), "step to first italic (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("i1").firstChild,
|
||||
"step to first italic text (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("i1").nextSibling,
|
||||
"step to more bold text (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("i2"), "step to second italic (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("i2").firstChild,
|
||||
"step to second italic text (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("s"), "step to span (anon)");
|
||||
testFunc(walkerAnon, "nextNode", $("s").firstChild, "step to span text (anon)");
|
||||
testFunc(walkerAnon, "nextNode", null, "step past end (anon)");
|
||||
testFunc(walkerAnon, "parentNode", $("s"), "step up to span (anon)");
|
||||
testFunc(walkerAnon, "parentNode", $("display"), "step up to display (anon)");
|
||||
testFunc(walkerAnon, "nextNode", anonDiv, "step to anonymous div again");
|
||||
testFunc(walkerAnon, "parentNode", $("display"),
|
||||
"step up to display again (anon)");
|
||||
testFunc(walkerAnon, "parentNode", null, "step up past root (anon)");
|
||||
testFunc(walkerAnon, "firstChild", anonDiv,
|
||||
"step firstChild to display first child (anon)");
|
||||
testFunc(walkerAnon, "nextSibling", $("s"),
|
||||
"step nextSibling to span (anon)");
|
||||
testFunc(walkerAnon, "nextSibling", null, "step nextSibling past end (anon)");
|
||||
testFunc(walkerAnon, "previousSibling", anonDiv,
|
||||
"step previousSibling to anonymous div");
|
||||
testFunc(walkerAnon, "previousSibling", null, "step previousSibling past end (anon)");
|
||||
|
||||
// Move the walker over to the end
|
||||
while (walkerAnon.nextNode()) { /* do nothing */ }
|
||||
testFunc(walkerAnon, "previousNode", $("s"), "step back to span (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("i2").firstChild,
|
||||
"step back to second italic text (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("i2"), "step back to second italic (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("i1").nextSibling,
|
||||
"step back to more bold text (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("i1").firstChild,
|
||||
"step back to first italic text (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("i1"), "step back to first italic (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("b").firstChild, "step back to bold text (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("b"), "step back to bold (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("s").nextSibling, "step back to more text (anon)");
|
||||
testFunc(walkerAnon, "previousNode", $("s").previousSibling,
|
||||
"step back to some text (anon)");
|
||||
testFunc(walkerAnon, "previousNode", anonDiv,
|
||||
"step back to anonymous div");
|
||||
testFunc(walkerAnon, "previousNode", $("display"), "step back to root (anon)");
|
||||
testFunc(walkerAnon, "previousNode", null, "step back past root (anon)");
|
||||
|
||||
var shadowdiv = document.querySelector('#test-shadow');
|
||||
var shadowRoot = shadowdiv.createShadowRoot();
|
||||
var h = document.createElement("header");
|
||||
var c = document.createElement("content");
|
||||
c.setAttribute("select", "h2");
|
||||
h.appendChild(c);
|
||||
shadowRoot.appendChild(h);
|
||||
|
||||
var walkerShadow =
|
||||
SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"]
|
||||
.createInstance(SpecialPowers.Ci.inIDeepTreeWalker);
|
||||
walkerShadow.showAnonymousContent = true;
|
||||
walkerShadow.init($("test-shadow"), NodeFilter.SHOW_ALL);
|
||||
var c1 = walkerShadow.nextNode();
|
||||
var c2 = walkerShadow.nextNode();
|
||||
var c3 = walkerShadow.nextNode();
|
||||
|
||||
walkerShadow.currentNode = c1;
|
||||
is(SpecialPowers.unwrap(walkerShadow.currentNode), h,
|
||||
"Unexpected shadow element 1");
|
||||
walkerShadow.currentNode = c2;
|
||||
is(SpecialPowers.unwrap(walkerShadow.currentNode), $("h2"),
|
||||
"Unexpected shadow element 2");
|
||||
walkerShadow.currentNode = c3;
|
||||
is(SpecialPowers.unwrap(walkerShadow.currentNode), $("h2").firstChild,
|
||||
"Unexpected shadow element 3");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
35
layout/inspector/tests/test_bug536379-2.html
Normal file
35
layout/inspector/tests/test_bug536379-2.html
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=536379
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 536379</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="data:text/css,@import 'data:text/css,p { color: green }'">
|
||||
<link rel="stylesheet" type="text/css" href="data:text/css,@import "data:text/css,@import 'data:text/css,p { color: green }'"">
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=536379">Mozilla Bug 536379</a>
|
||||
<p id="display"></p>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 536379 **/
|
||||
|
||||
const CI = SpecialPowers.Ci;
|
||||
const CC = SpecialPowers.Cc;
|
||||
|
||||
var domUtils =
|
||||
CC["@mozilla.org/inspector/dom-utils;1"].getService(CI.inIDOMUtils);
|
||||
var rules = domUtils.getCSSStyleRules(document.getElementById("display"));
|
||||
var firstPRule =
|
||||
rules.GetElementAt(rules.Count() - 2).QueryInterface(CI.nsIDOMCSSStyleRule);
|
||||
firstPRule.style.removeProperty("color");
|
||||
ok(true, "should not crash");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
46
layout/inspector/tests/test_bug536379.html
Normal file
46
layout/inspector/tests/test_bug536379.html
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=536379
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 536379</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="data:text/css,p { color: green }">
|
||||
<link rel="stylesheet" type="text/css" href="data:text/css,p { color: green }">
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=536379">Mozilla Bug 536379</a>
|
||||
<p id="display"></p>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 536379 **/
|
||||
|
||||
const CI = SpecialPowers.Ci;
|
||||
const CC = SpecialPowers.Cc;
|
||||
|
||||
var domUtils =
|
||||
CC["@mozilla.org/inspector/dom-utils;1"].getService(CI.inIDOMUtils);
|
||||
var rules = domUtils.getCSSStyleRules(document.getElementById("display"));
|
||||
var firstPRule =
|
||||
rules.GetElementAt(rules.Count() - 2).QueryInterface(CI.nsIDOMCSSStyleRule);
|
||||
firstPRule.style.removeProperty("color");
|
||||
ok(true, "should not crash");
|
||||
|
||||
var links = document.getElementsByTagName("link");
|
||||
is(links.length, 3, "links.length");
|
||||
is(SpecialPowers.unwrap(firstPRule.parentStyleSheet), links[1].sheet, "sheet match for first P rule");
|
||||
var secondPRule =
|
||||
rules.GetElementAt(rules.Count() - 1).QueryInterface(CI.nsIDOMCSSStyleRule);
|
||||
is(SpecialPowers.unwrap(secondPRule.parentStyleSheet), links[2].sheet, "sheet match for second P rule");
|
||||
is(links[1].href, links[2].href, "links should have same href");
|
||||
isnot(links[1].sheet, links[2].sheet, "links should have different sheets");
|
||||
isnot(firstPRule, secondPRule, "rules should be different");
|
||||
isnot(firstPRule.cssText, secondPRule.cssText, "text should be different since property was removed from one");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
95
layout/inspector/tests/test_bug557726.html
Normal file
95
layout/inspector/tests/test_bug557726.html
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=557726
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 557726</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<style id="pseudo-style">
|
||||
#div1 {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
#div1:first-letter {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#div1:before {
|
||||
content: '"';
|
||||
}
|
||||
|
||||
#div1:after {
|
||||
content: '"';
|
||||
}
|
||||
|
||||
#div1:after, #div1:before {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=557726">Mozilla Bug 557726</a>
|
||||
|
||||
<div id="div1">
|
||||
text with ::before, ::after, and ::first-letter pseudo-elements
|
||||
</div>
|
||||
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 557726 **/
|
||||
|
||||
function getSelectors (rules) {
|
||||
var styleElement = document.getElementById("pseudo-style");
|
||||
var selectors = [];
|
||||
for (var i = 0; i < rules.Count(); i++) {
|
||||
var rule = rules.GetElementAt(i).QueryInterface(SpecialPowers.Ci.nsIDOMCSSStyleRule);
|
||||
if (SpecialPowers.unwrap(rule.parentStyleSheet.ownerNode) == styleElement) // no user agent rules
|
||||
selectors.push(rule.selectorText);
|
||||
}
|
||||
return selectors;
|
||||
}
|
||||
|
||||
var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
var div = document.getElementById("div1");
|
||||
|
||||
/* empty or missing pseudo-element argument */
|
||||
var selectors = getSelectors(domUtils.getCSSStyleRules(div));
|
||||
is(selectors.length, 1, "psuedo-element argument should be optional");
|
||||
is(selectors[0], "#div1", "should only have the non-pseudo element rule");
|
||||
|
||||
selectors = getSelectors(domUtils.getCSSStyleRules(div, null));
|
||||
is(selectors.length, 1, "pseudo-element argument can be null");
|
||||
is(selectors[0], "#div1", "should only have the non pseudo-element rule");
|
||||
|
||||
selectors = getSelectors(domUtils.getCSSStyleRules(div, ""));
|
||||
is(selectors.length, 1, "pseudo-element argument can be empty string");
|
||||
is(selectors[0], "#div1", "should only have the non pseudo-element rule");
|
||||
|
||||
|
||||
/* invalid pseudo-element argument */
|
||||
var rules = domUtils.getCSSStyleRules(div, "not a valid pseudo element");
|
||||
is(rules, null, "invalid pseudo-element returns no rules list");
|
||||
|
||||
|
||||
/* valid pseudo-element argument */
|
||||
selectors = getSelectors(domUtils.getCSSStyleRules(div, ":first-letter"));
|
||||
is(selectors.length, 1, "pseudo-element argument can be used");
|
||||
is(selectors[0], "#div1::first-letter", "should only have the ::first-letter rule");
|
||||
|
||||
selectors = getSelectors(domUtils.getCSSStyleRules(div, ":before"));
|
||||
is(selectors.length, 2, "::before pseudo-element has two matching rules");
|
||||
isnot(selectors.indexOf("#div1::after, #div1::before"), -1, "fetched rule for ::before")
|
||||
isnot(selectors.indexOf("#div1::before"), -1, "fetched rule for ::before")
|
||||
|
||||
selectors = getSelectors(domUtils.getCSSStyleRules(div, ":first-line"));
|
||||
is(selectors.length, 0, "valid pseudo-element but no matching rules");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
67
layout/inspector/tests/test_bug609549.xhtml
Normal file
67
layout/inspector/tests/test_bug609549.xhtml
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=609549
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 609549</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
|
||||
<bindings xmlns="http://www.mozilla.org/xbl">
|
||||
<binding id="testBinding">
|
||||
<!-- No linebreaks since this is html and whitespace is preserved. -->
|
||||
<content><div anonid="box-A">x</div><div anonid="box-B"><children includes="span"/></div><div anonid="box-C">x</div><children/></content>
|
||||
</binding>
|
||||
</bindings>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=609549">Mozilla Bug 609549</a>
|
||||
<div id="bound" style="-moz-binding: url(#testBinding);"><p id="p">lorem ipsum dolor sit amet</p><span id="sandwiched">sandwiched</span></div>
|
||||
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
/** Test for Bug 609549 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
addLoadEvent(function() {
|
||||
var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"].
|
||||
getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
ok("getChildrenForNode" in domUtils, "domUtils has no getChildrenForNode");
|
||||
var withoutAnons = SpecialPowers.unwrap(domUtils.getChildrenForNode($("bound"), false));
|
||||
|
||||
is(withoutAnons.length, $("bound").childNodes.length,
|
||||
"withoutAnons should be the same length as childNodes");
|
||||
is(withoutAnons[0], $("p"), "didn't get paragraph - without anons");
|
||||
is(withoutAnons[1], $("sandwiched"),
|
||||
"didn't get sandwiched span - without anons");
|
||||
|
||||
var withAnons = domUtils.getChildrenForNode($("bound"), true);
|
||||
|
||||
is(withAnons.length, 4, "bad withAnons.length");
|
||||
is(withAnons[0].getAttribute("anonid"), "box-A",
|
||||
"didn't get anonymous box-A");
|
||||
is(withAnons[1].getAttribute("anonid"), "box-B",
|
||||
"didn't get anonymous box-B");
|
||||
is(withAnons[2].getAttribute("anonid"), "box-C",
|
||||
"didn't get anonymous box-C");
|
||||
is(withAnons[3].id, "p", "didn't get paragraph - with anons");
|
||||
|
||||
var bKids = domUtils.getChildrenForNode(withAnons[1], true);
|
||||
is(bKids.length, 1, "bKids.length is bad");
|
||||
is(SpecialPowers.unwrap(bKids[0]), $("sandwiched"),
|
||||
"didn't get sandwiched span inserted into box-B");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
26
layout/inspector/tests/test_bug806192.html
Normal file
26
layout/inspector/tests/test_bug806192.html
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=806192
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 806192</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
const utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
try {
|
||||
var res = utils.getBindingURLs({});
|
||||
ok(false, "didn't get error");
|
||||
}
|
||||
catch(e) { ok(true, "got expected exception"); }
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
84
layout/inspector/tests/test_bug856317.html
Normal file
84
layout/inspector/tests/test_bug856317.html
Normal file
File diff suppressed because one or more lines are too long
260
layout/inspector/tests/test_bug877690.html
Normal file
260
layout/inspector/tests/test_bug877690.html
Normal file
|
|
@ -0,0 +1,260 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=877690
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 877690</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 877690 **/
|
||||
|
||||
// Returns true if array contains item. False otherwise. Raises an exception if
|
||||
// array is not an Array object. If the item is found in array, remove item.
|
||||
function contains(array, item) {
|
||||
if (!array.indexOf) {
|
||||
throw new "First argument is not an array";
|
||||
}
|
||||
var index = array.indexOf(item);
|
||||
if (index == -1) {
|
||||
return false;
|
||||
}
|
||||
array.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns true if values contains all and only the expected values. False otherwise.
|
||||
function testValues(values, expected) {
|
||||
expected.forEach(function (expectedValue) {
|
||||
if (!contains(values, expectedValue)) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return values.length === 0;
|
||||
}
|
||||
|
||||
function do_test() {
|
||||
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
var getCSSValuesForProperty = function(prop) {
|
||||
return Array.from(utils.getCSSValuesForProperty(prop));
|
||||
}
|
||||
|
||||
// test a property with keywords and colors
|
||||
var prop = "color";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "initial", "inherit", "unset", "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure",
|
||||
"beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", "burlywood",
|
||||
"cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "currentColor",
|
||||
"cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkgrey",
|
||||
"darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred",
|
||||
"darksalmon", "darkseagreen", "darkslateblue", "darkslategray", "darkslategrey",
|
||||
"darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dimgrey", "dodgerblue",
|
||||
"firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold",
|
||||
"goldenrod", "gray", "grey", "green", "greenyellow", "honeydew", "hotpink", "indianred",
|
||||
"indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue",
|
||||
"lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey",
|
||||
"lightpink", "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightslategrey",
|
||||
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "mediumaquamarine",
|
||||
"mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen",
|
||||
"mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite",
|
||||
"navy", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen",
|
||||
"paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
|
||||
"purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen",
|
||||
"seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "slategrey", "snow", "springgreen",
|
||||
"steelblue", "tan", "teal", "thistle", "tomato", "transparent", "turquoise", "violet", "wheat",
|
||||
"white", "whitesmoke", "yellow", "yellowgreen", "rgb", "hsl", "rgba", "hsla" ];
|
||||
ok(testValues(values, expected), "property color's values.");
|
||||
|
||||
// test a shorthand property
|
||||
var prop = "background";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "initial", "inherit", "unset", "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure",
|
||||
"beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue",
|
||||
"chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "currentColor", "cyan", "darkblue",
|
||||
"darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkgrey", "darkkhaki", "darkmagenta",
|
||||
"darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue",
|
||||
"darkslategray", "darkslategrey", "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray",
|
||||
"dimgrey", "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
|
||||
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew", "hotpink", "indianred",
|
||||
"indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue",
|
||||
"lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey", "lightpink",
|
||||
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightslategrey", "lightsteelblue",
|
||||
"lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "mediumaquamarine", "mediumblue",
|
||||
"mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen",
|
||||
"mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
|
||||
"navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod",
|
||||
"palegreen", "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum",
|
||||
"powderblue", "purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown",
|
||||
"seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "slategrey",
|
||||
"snow", "springgreen", "steelblue", "tan", "teal", "thistle", "tomato", "transparent", "turquoise",
|
||||
"violet", "wheat", "white", "whitesmoke", "yellow", "yellowgreen", "no-repeat", "repeat",
|
||||
"repeat-x", "repeat-y", "space", "round", "fixed", "scroll", "local", "center", "top", "bottom", "left", "right",
|
||||
"border-box", "padding-box", "content-box", "border-box", "padding-box", "content-box", "text", "contain",
|
||||
"cover", "rgb", "hsl", "rgba", "hsla", "none", "-moz-element", "-moz-image-rect", "url", "linear-gradient",
|
||||
"radial-gradient", "repeating-linear-gradient", "repeating-radial-gradient", "-moz-linear-gradient",
|
||||
"-moz-radial-gradient", "-moz-repeating-linear-gradient", "-moz-repeating-radial-gradient" ];
|
||||
ok(testValues(values, expected), "Shorthand property values.");
|
||||
|
||||
var prop = "border";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "-moz-calc", "initial", "unset", "aliceblue",
|
||||
"antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet",
|
||||
"brown", "burlywood", "cadetblue", "calc", "chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk",
|
||||
"crimson", "currentColor", "cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkgrey", "darkkhaki",
|
||||
"darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
|
||||
"darkslateblue", "darkslategray", "darkslategrey", "darkturquoise", "darkviolet", "dashed", "deeppink",
|
||||
"deepskyblue", "dimgray", "dimgrey", "dodgerblue", "dotted", "double", "fill", "firebrick", "floralwhite",
|
||||
"forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray", "grey", "green", "greenyellow",
|
||||
"groove", "hidden", "honeydew", "hotpink", "hsl", "hsla", "indianred", "indigo", "inherit", "inset", "ivory",
|
||||
"khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", "lightcyan",
|
||||
"lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey", "lightpink", "lightsalmon", "lightseagreen",
|
||||
"lightskyblue", "lightslategray", "lightslategrey", "lightsteelblue", "lightyellow", "lime", "limegreen",
|
||||
"linen", "logical", "magenta", "maroon", "medium", "mediumaquamarine", "mediumblue", "mediumorchid",
|
||||
"mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
|
||||
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navy", "none",
|
||||
"oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "outset", "palegoldenrod", "palegreen",
|
||||
"paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "physical", "pink", "plum", "powderblue",
|
||||
"purple", "rebeccapurple", "red", "repeat", "rgb", "rgba", "ridge", "rosybrown", "round", "royalblue", "saddlebrown",
|
||||
"salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "slategrey",
|
||||
"snow", "solid", "space", "springgreen", "steelblue", "stretch", "tan", "teal", "thick", "thin", "thistle", "tomato",
|
||||
"transparent", "turquoise", "-moz-element", "-moz-image-rect", "url", "violet", "wheat", "white", "whitesmoke",
|
||||
"yellow", "yellowgreen", "linear-gradient", "radial-gradient", "repeating-linear-gradient",
|
||||
"repeating-radial-gradient", "-moz-linear-gradient", "-moz-radial-gradient", "-moz-repeating-linear-gradient",
|
||||
"-moz-repeating-radial-gradient" ]
|
||||
ok(testValues(values, expected), "Shorthand property values.");
|
||||
|
||||
// test keywords only
|
||||
var prop = "border-top";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "initial", "inherit", "unset", "thin", "medium", "thick", "none", "hidden", "dotted",
|
||||
"dashed", "solid", "double", "groove", "ridge", "inset", "outset",
|
||||
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black",
|
||||
"blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue", "chartreuse",
|
||||
"chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "currentColor", "cyan", "darkblue", "darkcyan",
|
||||
"darkgoldenrod", "darkgray", "darkgreen", "darkgrey", "darkkhaki", "darkmagenta", "darkolivegreen",
|
||||
"darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray",
|
||||
"darkslategrey", "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dimgrey",
|
||||
"dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
|
||||
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew", "hotpink", "indianred",
|
||||
"indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue",
|
||||
"lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey",
|
||||
"lightpink", "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightslategrey",
|
||||
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "mediumaquamarine",
|
||||
"mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen",
|
||||
"mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite",
|
||||
"navy", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen",
|
||||
"paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
|
||||
"purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen",
|
||||
"seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "slategrey", "snow", "springgreen",
|
||||
"steelblue", "tan", "teal", "thistle", "tomato", "transparent", "turquoise", "violet", "wheat", "white",
|
||||
"whitesmoke", "yellow", "yellowgreen", "calc", "-moz-calc", "rgb", "hsl", "rgba", "hsla" ];
|
||||
ok(testValues(values, expected), "property border-top's values.");
|
||||
|
||||
// tests no keywords or colors
|
||||
var prop = "padding-bottom";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "initial", "inherit", "unset", "calc", "-moz-calc" ];
|
||||
ok(testValues(values, expected), "property padding-bottom's values.");
|
||||
|
||||
// test proprety
|
||||
var prop = "display";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "initial", "inherit", "unset", "none", "inline", "block", "inline-block", "list-item",
|
||||
"table", "inline-table", "table-row-group", "table-header-group", "table-footer-group", "table-row",
|
||||
"table-column-group", "table-column", "table-cell", "table-caption", "-moz-box", "-moz-inline-box",
|
||||
"-moz-grid", "-moz-inline-grid", "-moz-grid-group", "-moz-grid-line", "-moz-stack", "-moz-inline-stack",
|
||||
"-moz-deck", "-moz-popup", "-moz-groupbox",
|
||||
"flex", "inline-flex", "-webkit-box", "-webkit-inline-box",
|
||||
"-webkit-flex", "-webkit-inline-flex",
|
||||
"grid", "inline-grid",
|
||||
"ruby", "ruby-base", "ruby-base-container", "ruby-text", "ruby-text-container",
|
||||
"contents" ];
|
||||
ok(testValues(values, expected), "property display's values.");
|
||||
|
||||
// test property
|
||||
var prop = "float";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "initial", "inherit", "unset", "none", "left", "right", "inline-start", "inline-end" ];
|
||||
ok(testValues(values, expected), "property float's values.");
|
||||
|
||||
// Test property with "auto"
|
||||
var prop = "margin";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "-moz-calc", "initial", "unset", "auto", "calc", "inherit" ];
|
||||
ok(testValues(values, expected), "property margin's values.");
|
||||
|
||||
// Test property with "normal"
|
||||
var prop = "font-style";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "initial", "inherit", "unset", "italic", "normal", "oblique" ];
|
||||
ok(testValues(values, expected), "property font-style's values.");
|
||||
|
||||
// Test property with "cubic-bezier" and "step".
|
||||
var prop = "-moz-transition";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "initial", "all", "unset", "cubic-bezier", "ease", "ease-in", "ease-in-out",
|
||||
"ease-out", "inherit", "linear", "none", "step-end", "step-start",
|
||||
"steps" ];
|
||||
ok(testValues(values, expected), "property -moz-transition's values.");
|
||||
|
||||
// test invalid property
|
||||
var prop = "invalidProperty";
|
||||
try {
|
||||
getCSSValuesForProperty(prop);
|
||||
ok(false, "invalid property should throw an exception");
|
||||
}
|
||||
catch(e) {
|
||||
// test passed
|
||||
}
|
||||
|
||||
// test border-image propery, for bug 973345
|
||||
var prop = "border-image";
|
||||
var values = getCSSValuesForProperty(prop);
|
||||
var expected = [ "-moz-calc", "initial", "unset", "aliceblue",
|
||||
"antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet",
|
||||
"brown", "burlywood", "cadetblue", "calc", "chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk",
|
||||
"crimson", "currentColor", "cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkgrey", "darkkhaki",
|
||||
"darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
|
||||
"darkslateblue", "darkslategray", "darkslategrey", "darkturquoise", "darkviolet", "dashed", "deeppink",
|
||||
"deepskyblue", "dimgray", "dimgrey", "dodgerblue", "dotted", "double", "fill", "firebrick", "floralwhite",
|
||||
"forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray", "grey", "green", "greenyellow",
|
||||
"groove", "hidden", "honeydew", "hotpink", "hsl", "hsla", "indianred", "indigo", "inherit", "inset", "ivory",
|
||||
"khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", "lightcyan",
|
||||
"lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey", "lightpink", "lightsalmon", "lightseagreen",
|
||||
"lightskyblue", "lightslategray", "lightslategrey", "lightsteelblue", "lightyellow", "lime", "limegreen",
|
||||
"linen", "logical", "magenta", "maroon", "medium", "mediumaquamarine", "mediumblue", "mediumorchid",
|
||||
"mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
|
||||
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navy", "none",
|
||||
"oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "outset", "palegoldenrod", "palegreen",
|
||||
"paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "physical", "pink", "plum", "powderblue",
|
||||
"purple", "rebeccapurple", "red", "repeat", "rgb", "rgba", "ridge", "rosybrown", "round", "royalblue", "saddlebrown",
|
||||
"salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "slategrey",
|
||||
"snow", "solid", "springgreen", "steelblue", "stretch", "tan", "teal", "thick", "thin", "thistle", "tomato",
|
||||
"transparent", "turquoise", "-moz-element", "-moz-image-rect", "url", "violet", "wheat", "white", "whitesmoke",
|
||||
"yellow", "yellowgreen", "linear-gradient", "radial-gradient", "repeating-linear-gradient",
|
||||
"repeating-radial-gradient", "-moz-linear-gradient", "-moz-radial-gradient", "-moz-repeating-linear-gradient",
|
||||
"-moz-repeating-radial-gradient" ]
|
||||
ok(testValues(values, expected), "property border-image's values.");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(do_test);
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=877690">Mozilla Bug 877690</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
55
layout/inspector/tests/test_color_to_rgba.html
Normal file
55
layout/inspector/tests/test_color_to_rgba.html
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test inDOMUtils::ColorToRGBA</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript;version=1.8">
|
||||
let utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
testColor("red", {r:255, g:0, b:0, a:1});
|
||||
testColor("#f00", {r:255, g:0, b:0, a:1});
|
||||
testColor("#ff0000", {r:255, g:0, b:0, a:1});
|
||||
testColor("ff0000", null);
|
||||
testColor("rgb(255,0,0)", {r:255, g:0, b:0, a:1});
|
||||
testColor("rgba(255,0,0)", {r:255, g:0, b:0, a:1});
|
||||
testColor("rgb(255,0,0,0.7)", {r:255, g:0, b:0, a:0.7});
|
||||
testColor("rgba(255,0,0,0.7)", {r:255, g:0, b:0, a:0.7});
|
||||
testColor("rgb(50%,75%,60%)", {r:128, g:191, b:153, a:1});
|
||||
testColor("rgba(50%,75%,60%)", {r:128, g:191, b:153, a:1});
|
||||
testColor("rgb(100%,50%,25%,0.7)", {r:255, g:128, b:64, a:0.7});
|
||||
testColor("rgba(100%,50%,25%,0.7)", {r:255, g:128, b:64, a:0.7});
|
||||
testColor("hsl(320,30%,10%)", {r:33, g:17, b:28, a:1});
|
||||
testColor("hsla(320,30%,10%)", {r:33, g:17, b:28, a:1});
|
||||
testColor("hsl(170,60%,40%,0.9)", {r:40, g:163, b:142, a:0.9});
|
||||
testColor("hsla(170,60%,40%,0.9)", {r:40, g:163, b:142, a:0.9});
|
||||
|
||||
function testColor(color, expected) {
|
||||
let rgb = utils.colorToRGBA(color);
|
||||
|
||||
if (rgb === null) {
|
||||
ok(expected === null, "color: " + color + " returns null");
|
||||
return;
|
||||
}
|
||||
|
||||
let {r, g, b, a} = rgb;
|
||||
|
||||
is(r, expected.r, "color: " + color + ", red component is converted correctly");
|
||||
is(g, expected.g, "color: " + color + ", green component is converted correctly");
|
||||
is(b, expected.b, "color: " + color + ", blue component is converted correctly");
|
||||
is(Math.round(a * 10) / 10, expected.a, "color: " + color + ", alpha component is a converted correctly");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test inDOMUtils::ColorToRGBA</h1>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
51
layout/inspector/tests/test_css_property_is_shorthand.html
Normal file
51
layout/inspector/tests/test_css_property_is_shorthand.html
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test inDOMUtils::CssPropertyIsShorthand</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript;version=1.8">
|
||||
let utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
let tests = [
|
||||
{
|
||||
property: "color",
|
||||
expected: false
|
||||
},
|
||||
{
|
||||
property: "background",
|
||||
expected: true
|
||||
},
|
||||
{
|
||||
property: "--anything",
|
||||
expected: false
|
||||
}
|
||||
];
|
||||
|
||||
for (let {property, expected} of tests) {
|
||||
let result = utils.cssPropertyIsShorthand(property);
|
||||
is(result, expected, "checking whether " + property + " is shorthand");
|
||||
}
|
||||
|
||||
let sawException = false;
|
||||
try {
|
||||
let result = utils.cssPropertyIsShorthand("nosuchproperty");
|
||||
} catch (e) {
|
||||
sawException = true;
|
||||
}
|
||||
ok(sawException, "checking whether nosuchproperty throws");
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test inDOMUtils::CssPropertyIsShorthand</h1>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
105
layout/inspector/tests/test_css_property_is_valid.html
Normal file
105
layout/inspector/tests/test_css_property_is_valid.html
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test inDOMUtils::CssPropertyIsValid</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript;version=1.8">
|
||||
let utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
let tests = [
|
||||
{
|
||||
property: "color",
|
||||
value: "red",
|
||||
expected: true
|
||||
},
|
||||
{
|
||||
property: "display",
|
||||
value: "none",
|
||||
expected: true
|
||||
},
|
||||
{
|
||||
property: "display",
|
||||
value: "red",
|
||||
expected: false
|
||||
},
|
||||
{
|
||||
property: "displayx",
|
||||
value: "none",
|
||||
expected: false
|
||||
},
|
||||
{
|
||||
property: "border",
|
||||
value: "1px solid blue",
|
||||
expected: true
|
||||
},
|
||||
{
|
||||
property: "border",
|
||||
value: "1 solid blue",
|
||||
expected: false
|
||||
},
|
||||
{
|
||||
property: "border",
|
||||
value: "1px underline blue",
|
||||
expected: false
|
||||
},
|
||||
{
|
||||
property: "border",
|
||||
value: "1px solid",
|
||||
expected: true
|
||||
},
|
||||
{
|
||||
property: "color",
|
||||
value: "blue !important",
|
||||
expected: true
|
||||
},
|
||||
{
|
||||
property: "color",
|
||||
value: "blue ! important",
|
||||
expected: true
|
||||
},
|
||||
{
|
||||
property: "color",
|
||||
value: "blue !impoxxxrtant",
|
||||
expected: false
|
||||
},
|
||||
{
|
||||
property: "color",
|
||||
value: "red; background:green;",
|
||||
expected: false
|
||||
},
|
||||
{
|
||||
property: "content",
|
||||
value: "\"hello\"",
|
||||
expected: true
|
||||
},
|
||||
{
|
||||
property: "color",
|
||||
value: "var(--some-kind-of-green)",
|
||||
expected: true
|
||||
}
|
||||
];
|
||||
|
||||
for (let {property, value, expected} of tests) {
|
||||
let valid = utils.cssPropertyIsValid(property, value);
|
||||
|
||||
if (expected) {
|
||||
ok(valid, property + ":" + value + " is valid");
|
||||
} else {
|
||||
ok(!valid, property + ":" + value + " is not valid");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test inDOMUtils::CssPropertyIsValid</h1>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
59
layout/inspector/tests/test_getCSSPseudoElementNames.html
Normal file
59
layout/inspector/tests/test_getCSSPseudoElementNames.html
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test inDOMUtils::getCSSPseudoElementNames</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript;version=1.8">
|
||||
let utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
let expected = new Set([
|
||||
":after",
|
||||
":before",
|
||||
":backdrop",
|
||||
":first-letter",
|
||||
":first-line",
|
||||
":placeholder",
|
||||
":-moz-color-swatch",
|
||||
":-moz-focus-inner",
|
||||
":-moz-focus-outer",
|
||||
":-moz-list-bullet",
|
||||
":-moz-list-number",
|
||||
":-moz-math-anonymous",
|
||||
":-moz-meter-bar",
|
||||
":-moz-placeholder",
|
||||
":-moz-progress-bar",
|
||||
":-moz-range-progress",
|
||||
":-moz-range-thumb",
|
||||
":-moz-range-track",
|
||||
":-moz-selection",
|
||||
]);
|
||||
|
||||
let names = utils.getCSSPseudoElementNames();
|
||||
for (let name of names) {
|
||||
ok(expected.has(name), name + " is included");
|
||||
expected.delete(name);
|
||||
}
|
||||
|
||||
if (expected.size > 0) {
|
||||
todo_is(expected.size, 0,
|
||||
"ideally all pseudo-element names would be listed in this test");
|
||||
for (let extra of expected) {
|
||||
info("extra element: " + extra);
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test inDOMUtils::getCSSPseudoElementNames</h1>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
69
layout/inspector/tests/test_getRelativeRuleLine.html
Normal file
69
layout/inspector/tests/test_getRelativeRuleLine.html
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test inDOMUtils::getRelativeRuleLine</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<style>
|
||||
@supports (not (whatever: 72 zq)) {
|
||||
#test {
|
||||
background-color: #f0c;
|
||||
}
|
||||
}
|
||||
|
||||
#test {
|
||||
color: #f0c;
|
||||
}
|
||||
</style>
|
||||
<style>#test { color: red; }</style>
|
||||
<style>
|
||||
@invalidatkeyword {
|
||||
}
|
||||
|
||||
#test {
|
||||
color: blue;
|
||||
}
|
||||
</style>
|
||||
<script type="application/javascript;version=1.8">
|
||||
let utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
let tests = [
|
||||
{ sheetNo: 0, ruleNo: 0, lineNo: 1, columnNo: 1 },
|
||||
{ sheetNo: 1, ruleNo: 0, lineNo: 2, columnNo: 15 },
|
||||
{ sheetNo: 1, ruleNo: 1, lineNo: 8, columnNo: 5 },
|
||||
{ sheetNo: 2, ruleNo: 0, lineNo: 1, columnNo: 1 },
|
||||
{ sheetNo: 2, ruleNo: 1, lineNo: 0, columnNo: 1 },
|
||||
{ sheetNo: 3, ruleNo: 0, lineNo: 5, columnNo: 6 },
|
||||
];
|
||||
|
||||
function doTest() {
|
||||
document.styleSheets[2].insertRule("body{}", 1);
|
||||
for (let test of tests) {
|
||||
let sheet = document.styleSheets[test.sheetNo];
|
||||
let rule = sheet.cssRules[test.ruleNo];
|
||||
let line = utils.getRelativeRuleLine(rule);
|
||||
let column = utils.getRuleColumn(rule);
|
||||
info("testing sheet " + test.sheetNo + ", rule " + test.ruleNo);
|
||||
is(line, test.lineNo, "line number is correct");
|
||||
is(column, test.columnNo, "column number is correct");
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test inDOMUtils::getRelativeRuleLine</h1>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
44
layout/inspector/tests/test_get_all_style_sheets.html
Normal file
44
layout/inspector/tests/test_get_all_style_sheets.html
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=734861
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 734861</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 734861 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest() {
|
||||
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
var res = utils.getAllStyleSheets(document);
|
||||
|
||||
var foundUA = false;
|
||||
for (var i = 0; i < res.length; i++) {
|
||||
if (res[i].href === "resource://gre-resources/ua.css") {
|
||||
foundUA = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ok(foundUA, "UA sheet should be returned with all the other sheets.");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body onload="runTest();">
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=734861">Mozilla Bug 734861</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
91
layout/inspector/tests/test_is_valid_css_color.html
Normal file
91
layout/inspector/tests/test_is_valid_css_color.html
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test inDOMUtils::isValidCSSColor</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript;version=1.8">
|
||||
let utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
// Color names
|
||||
let colors = utils.getCSSValuesForProperty("color");
|
||||
let notColor = ["hsl", "hsla", "inherit", "initial", "rgb", "rgba",
|
||||
"unset", "transparent", "currentColor"];
|
||||
for (let color of colors) {
|
||||
if (notColor.indexOf(color) !== -1) {
|
||||
continue;
|
||||
}
|
||||
ok(utils.isValidCSSColor(color), color + " is a valid color");
|
||||
ok(!utils.isValidCSSColor("xxx" + color), "xxx" + color + " is not a valid color");
|
||||
}
|
||||
|
||||
// rgb(a)
|
||||
for (let i = 0; i <= 265; i++) {
|
||||
ok(utils.isValidCSSColor("rgb(" + i + ",0,0)"), "rgb(" + i + ",0,0) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgb(0," + i + ",0)"), "rgb(0," + i + ",0) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgb(0,0," + i + ")"), "rgb(0,0," + i + ") is a valid color");
|
||||
ok(utils.isValidCSSColor("rgba(" + i + ",0,0,0.2)"), "rgba(" + i + ",0,0,0.2) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgba(0," + i + ",0,0.5)"), "rgba(0," + i + ",0,0.5) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgba(0,0," + i + ",0.7)"), "rgba(0,0," + i + ",0.7) is a valid color");
|
||||
|
||||
ok(!utils.isValidCSSColor("rgbxxx(" + i + ",0,0)"), "rgbxxx(" + i + ",0,0) is not a valid color");
|
||||
ok(!utils.isValidCSSColor("rgbxxx(0," + i + ",0)"), "rgbxxx(0," + i + ",0) is not a valid color");
|
||||
ok(!utils.isValidCSSColor("rgbxxx(0,0," + i + ")"), "rgbxxx(0,0," + i + ") is not a valid color");
|
||||
}
|
||||
|
||||
// rgb(a) (%)
|
||||
for (let i = 0; i <= 110; i++) {
|
||||
ok(utils.isValidCSSColor("rgb(" + i + "%,0%,0%)"), "rgb(" + i + "%,0%,0%) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgb(0%," + i + "%,0%)"), "rgb(0%," + i + "%,0%) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgb(0%,0%," + i + "%)"), "rgb(0%,0%," + i + "%) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgba(" + i + "%,0%,0%,0.2)"), "rgba(" + i + "%,0%,0%,0.2) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgba(0%," + i + "%,0%,0.5)"), "rgba(0%," + i + "%,0%,0.5) is a valid color");
|
||||
ok(utils.isValidCSSColor("rgba(0%,0%," + i + "%,0.7)"), "rgba(0%,0%," + i + "%,0.7) is a valid color");
|
||||
|
||||
ok(!utils.isValidCSSColor("rgbaxxx(" + i + "%,0%,0%,0.2)"), "rgbaxxx(" + i + "%,0%,0%,0.2) is not a valid color");
|
||||
ok(!utils.isValidCSSColor("rgbaxxx(0%," + i + "%,0%,0.5)"), "rgbaxxx(0%," + i + "%,0%,0.5) is not a valid color");
|
||||
ok(!utils.isValidCSSColor("rgbaxxx(0%,0%," + i + "%,0.7)"), "rgbaxxx(0%,0%," + i + "%,0.7) is not a valid color");
|
||||
}
|
||||
|
||||
// hsl(a)
|
||||
for (let i = 0; i <= 370; i++) {
|
||||
ok(utils.isValidCSSColor("hsl(" + i + ",30%,10%)"), "rgb(" + i + ",30%,10%) is a valid color");
|
||||
ok(utils.isValidCSSColor("hsla(" + i + ",60%,70%,0.2)"), "rgba(" + i + ",60%,70%,0.2) is a valid color");
|
||||
}
|
||||
for (let i = 0; i <= 110; i++) {
|
||||
ok(utils.isValidCSSColor("hsl(100," + i + "%,20%)"), "hsl(100," + i + "%,20%) is a valid color");
|
||||
ok(utils.isValidCSSColor("hsla(100,20%," + i + "%,0.6)"), "hsla(100,20%," + i + "%,0.6) is a valid color");
|
||||
}
|
||||
|
||||
// hex
|
||||
for (let i = 0; i <= 255; i++) {
|
||||
let hex = (i).toString(16);
|
||||
if (hex.length === 1) {
|
||||
hex = 0 + hex;
|
||||
}
|
||||
ok(utils.isValidCSSColor("#" + hex + "7777"), "#" + hex + "7777 is a valid color");
|
||||
ok(utils.isValidCSSColor("#77" + hex + "77"), "#77" + hex + "77 is a valid color");
|
||||
ok(utils.isValidCSSColor("#7777" + hex), "#7777" + hex + " is a valid color");
|
||||
}
|
||||
ok(!utils.isValidCSSColor("#kkkkkk"), "#kkkkkk is not a valid color");
|
||||
|
||||
// short hex
|
||||
for (let i = 0; i <= 16; i++) {
|
||||
let hex = (i).toString(16);
|
||||
ok(utils.isValidCSSColor("#" + hex + hex + hex), "#" + hex + hex + hex + " is a valid color");
|
||||
}
|
||||
ok(!utils.isValidCSSColor("#ggg"), "#ggg is not a valid color");
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test inDOMUtils::isValidCSSColor</h1>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
38
layout/inspector/tests/test_isinheritableproperty.html
Normal file
38
layout/inspector/tests/test_isinheritableproperty.html
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=699592
|
||||
-->
|
||||
<head>
|
||||
<title>Test for nsIDOMUtils::isInheritedProperty</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
function do_test() {
|
||||
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
is(utils.isInheritedProperty("font-size"), true, "font-size is inherited.");
|
||||
|
||||
is(utils.isInheritedProperty("min-width"), false, "min-width is not inherited.");
|
||||
|
||||
is(utils.isInheritedProperty("font"), true, "shorthand font property is inherited.");
|
||||
|
||||
is(utils.isInheritedProperty("border"), false, "shorthand border property not inherited.");
|
||||
is(utils.isInheritedProperty("garbage"), false, "Unknown property isn't inherited.");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(do_test);
|
||||
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
34
layout/inspector/tests/test_parseStyleSheet.html
Normal file
34
layout/inspector/tests/test_parseStyleSheet.html
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1195978
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1195978</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<style>
|
||||
body {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript">
|
||||
var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
var sheet = document.styleSheets[1];
|
||||
is(domUtils.getRelativeRuleLine(sheet.cssRules[0]), 2,
|
||||
"initial relative rule line");
|
||||
is(domUtils.getRuleLine(sheet.cssRules[0]), 11,
|
||||
"initial rule line");
|
||||
|
||||
domUtils.parseStyleSheet(sheet, "\nbody {\n color: blue;\n}\n");
|
||||
is(domUtils.getRelativeRuleLine(sheet.cssRules[0]), 2,
|
||||
"relative rule line after reparsing");
|
||||
is(domUtils.getRuleLine(sheet.cssRules[0]), 11,
|
||||
"relative rule line after reparsing");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
83
layout/inspector/tests/test_parseStyleSheetImport.html
Normal file
83
layout/inspector/tests/test_parseStyleSheetImport.html
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1202095
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1202095</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<style>
|
||||
@import url('bug1202095.css');
|
||||
@import url('bug1202095-2.css');
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript">
|
||||
var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
function do_test() {
|
||||
var sheet = document.styleSheets[1];
|
||||
var importRule = sheet.cssRules[0];
|
||||
is(importRule.type, SpecialPowers.Ci.nsIDOMCSSRule.IMPORT_RULE,
|
||||
"initial sheet has @import rule");
|
||||
|
||||
var importedSheet = importRule.styleSheet;
|
||||
importedSheet.deleteRule(0);
|
||||
is(importedSheet.cssRules.length, 0, "imported sheet now has no rules");
|
||||
|
||||
// "suffixed" refers to the "-2".
|
||||
var suffixedSheet = sheet.cssRules[1].styleSheet;
|
||||
domUtils.parseStyleSheet(suffixedSheet, "");
|
||||
is(suffixedSheet.cssRules.length, 0, "second imported sheet now has no rules");
|
||||
|
||||
// Re-parse the style sheet, preserving the imports.
|
||||
domUtils.parseStyleSheet(sheet, "@import url('bug1202095.css');" +
|
||||
"@import url('bug1202095-2.css');");
|
||||
is(sheet.cssRules[0].type, SpecialPowers.Ci.nsIDOMCSSRule.IMPORT_RULE,
|
||||
"re-parsed sheet has @import rule");
|
||||
is(sheet.cssRules[0].styleSheet, importedSheet,
|
||||
"imported sheet has not changed");
|
||||
is(sheet.cssRules[1].styleSheet, suffixedSheet,
|
||||
"second imported sheet has not changed");
|
||||
|
||||
// Re-parse the style sheet, preserving both imports, but changing
|
||||
// the order.
|
||||
domUtils.parseStyleSheet(sheet, "@import url('bug1202095-2.css');" +
|
||||
"@import url('bug1202095.css');");
|
||||
is(sheet.cssRules[0].styleSheet, suffixedSheet,
|
||||
"reordering preserved suffixed style sheet");
|
||||
is(sheet.cssRules[1].styleSheet, importedSheet,
|
||||
"reordering preserved unsuffixed style sheet");
|
||||
|
||||
// Re-parse the style sheet, removing the imports.
|
||||
domUtils.parseStyleSheet(sheet, "");
|
||||
is(sheet.cssRules.length, 0, "style sheet now has no rules");
|
||||
|
||||
// Re-parse the style sheet, adding one import back. This should
|
||||
// not allow reuse.
|
||||
domUtils.parseStyleSheet(sheet, "@import url('bug1202095.css');");
|
||||
is(sheet.cssRules[0].type, SpecialPowers.Ci.nsIDOMCSSRule.IMPORT_RULE,
|
||||
"re-re-re-parsed sheet has @import rule");
|
||||
isnot(sheet.cssRules[0].styleSheet, importedSheet,
|
||||
"imported sheet has changed now");
|
||||
|
||||
// Re-parse the style sheet, importing the same URL twice.
|
||||
// The style sheet should be reused once, but not two times.
|
||||
importedSheet = sheet.cssRules[0].styleSheet;
|
||||
domUtils.parseStyleSheet(sheet, "@import url('bug1202095.css');" +
|
||||
"@import url('bug1202095.css');");
|
||||
is(sheet.cssRules[0].styleSheet, importedSheet,
|
||||
"first imported sheet is reused");
|
||||
isnot(sheet.cssRules[1].styleSheet, importedSheet,
|
||||
"second imported sheet is reused");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(do_test);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
90
layout/inspector/tests/test_selectormatcheselement.html
Normal file
90
layout/inspector/tests/test_selectormatcheselement.html
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1037519
|
||||
-->
|
||||
<head>
|
||||
<title>Test for nsIDOMUtils::selectorMatchesElement</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<style type="text/css">
|
||||
#foo,
|
||||
#bar,
|
||||
#foo::before {
|
||||
color: red;
|
||||
}
|
||||
#foo::before,
|
||||
#bar::before {
|
||||
content: 'foo-before';
|
||||
color: green;
|
||||
}
|
||||
#foo::after,
|
||||
#bar::after {
|
||||
content: 'foo-after';
|
||||
color: blue;
|
||||
}
|
||||
#foo::first-line,
|
||||
#bar::first-line {
|
||||
text-decoration: underline;
|
||||
}
|
||||
#foo::first-letter,
|
||||
#bar::first-letter {
|
||||
font-variant: small-caps;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="foo">foo content</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
function do_test() {
|
||||
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
|
||||
var element = document.querySelector("#foo");
|
||||
|
||||
var elementRules = utils.getCSSStyleRules(element);
|
||||
var elementRule = elementRules.GetElementAt(elementRules.Count() - 1);
|
||||
|
||||
is (utils.selectorMatchesElement(element, elementRule, 0), true,
|
||||
"Matches #foo");
|
||||
is (utils.selectorMatchesElement(element, elementRule, 1), false,
|
||||
"Doesn't match #bar");
|
||||
is (utils.selectorMatchesElement(element, elementRule, 0, ":bogus"), false,
|
||||
"Doesn't match #foo with a bogus pseudo");
|
||||
is (utils.selectorMatchesElement(element, elementRule, 2, ":bogus"), false,
|
||||
"Doesn't match #foo::before with bogus pseudo");
|
||||
is (utils.selectorMatchesElement(element, elementRule, 0, ":after"), false,
|
||||
"Does match #foo::before with the :after pseudo");
|
||||
|
||||
checkPseudo(":before");
|
||||
checkPseudo(":after");
|
||||
checkPseudo(":first-letter");
|
||||
checkPseudo(":first-line");
|
||||
|
||||
SimpleTest.finish();
|
||||
|
||||
function checkPseudo(pseudo) {
|
||||
var rules = utils.getCSSStyleRules(element, pseudo);
|
||||
var rule = rules.GetElementAt(rules.Count() - 1);
|
||||
|
||||
is (utils.selectorMatchesElement(element, rule, 0), false,
|
||||
"Doesn't match without " + pseudo);
|
||||
is (utils.selectorMatchesElement(element, rule, 1), false,
|
||||
"Doesn't match without " + pseudo);
|
||||
|
||||
is (utils.selectorMatchesElement(element, rule, 0, pseudo), true,
|
||||
"Matches on #foo" + pseudo);
|
||||
is (utils.selectorMatchesElement(element, rule, 1, pseudo), false,
|
||||
"Doesn't match on #bar" + pseudo);
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(do_test);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue