summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/javascript/Document.cpp13
-rw-r--r--fpdfsdk/javascript/Document.h2
-rw-r--r--testing/resources/javascript/document_props.in1
-rw-r--r--testing/resources/javascript/document_props_expected.txt3
4 files changed, 19 insertions, 0 deletions
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 9c680de906..161a5d09e9 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -91,6 +91,7 @@ JS_STATIC_PROP_ENTRY(path)
JS_STATIC_PROP_ENTRY(producer)
JS_STATIC_PROP_ENTRY(subject)
JS_STATIC_PROP_ENTRY(title)
+JS_STATIC_PROP_ENTRY(URL)
JS_STATIC_PROP_ENTRY(zoom)
JS_STATIC_PROP_ENTRY(zoomType)
END_JS_STATIC_PROP()
@@ -904,6 +905,18 @@ FX_BOOL Document::mouseY(IJS_Context* cc,
return TRUE;
}
+FX_BOOL Document::URL(IJS_Context* cc,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
+ if (vp.IsSetting()) {
+ CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
+ return FALSE;
+ }
+ vp << m_pDocument->GetPath();
+ return TRUE;
+}
+
FX_BOOL Document::baseURL(IJS_Context* cc,
CJS_PropValue& vp,
CFX_WideString& sError) {
diff --git a/fpdfsdk/javascript/Document.h b/fpdfsdk/javascript/Document.h
index 7e5d6dfe8a..ae2d6c1afe 100644
--- a/fpdfsdk/javascript/Document.h
+++ b/fpdfsdk/javascript/Document.h
@@ -259,6 +259,7 @@ class Document : public CJS_EmbedObj {
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError);
+ FX_BOOL URL(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
void AttachDoc(CPDFSDK_Document* pDoc);
CPDFSDK_Document* GetReaderDoc();
@@ -324,6 +325,7 @@ class CJS_Document : public CJS_Object {
JS_STATIC_PROP(producer, Document);
JS_STATIC_PROP(subject, Document);
JS_STATIC_PROP(title, Document);
+ JS_STATIC_PROP(URL, Document);
JS_STATIC_PROP(zoom, Document);
JS_STATIC_PROP(zoomType, Document);
diff --git a/testing/resources/javascript/document_props.in b/testing/resources/javascript/document_props.in
index c628fafad2..1882f79c8a 100644
--- a/testing/resources/javascript/document_props.in
+++ b/testing/resources/javascript/document_props.in
@@ -100,6 +100,7 @@ var document_props = [
'producer',
'subject',
'title',
+ 'URL',
'zoom',
'zoomType',
];
diff --git a/testing/resources/javascript/document_props_expected.txt b/testing/resources/javascript/document_props_expected.txt
index 4b60a624da..90914cda51 100644
--- a/testing/resources/javascript/document_props_expected.txt
+++ b/testing/resources/javascript/document_props_expected.txt
@@ -28,6 +28,7 @@ Alert: this.path is string /
Alert: this.producer is string
Alert: this.subject is string
Alert: this.title is string
+Alert: this.URL is string
Alert: this.zoom is undefined undefined
Alert: this.zoomType is undefined undefined
Alert: *** Setting properties ***
@@ -61,6 +62,7 @@ Alert: ERROR: Document.path: Cannot assign to readonly property.
Alert: this.producer = 3; yields 3
Alert: this.subject = 3; yields 3
Alert: this.title = 3; yields 3
+Alert: ERROR: Document.URL: Cannot assign to readonly property.
Alert: this.zoom = 3; yields 3
Alert: this.zoomType = 3; yields 3
Alert: *** Getting properties ***
@@ -93,5 +95,6 @@ Alert: this.path is string /
Alert: this.producer is string 3
Alert: this.subject is string 3
Alert: this.title is string 3
+Alert: this.URL is string
Alert: this.zoom is undefined undefined
Alert: this.zoomType is undefined undefined